-
Notifications
You must be signed in to change notification settings - Fork 176
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add transmission of TOEs between campaigns
- Loading branch information
1 parent
24e5684
commit b97c54a
Showing
11 changed files
with
646 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
/* | ||
* Copyright (c) 2020 The MegaMek Team. | ||
* | ||
* This file is part of MekHQ. | ||
* | ||
* MekHQ is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* MekHQ is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with MekHQ. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
package mekhq.gui; | ||
|
||
import java.awt.Component; | ||
|
||
import javax.swing.JTree; | ||
import javax.swing.UIManager; | ||
import javax.swing.tree.DefaultTreeCellRenderer; | ||
|
||
import mekhq.online.forces.RemoteForce; | ||
import mekhq.online.forces.RemoteUnit; | ||
|
||
public class RemoteForceRenderer extends DefaultTreeCellRenderer { | ||
|
||
private static final long serialVersionUID = 1L; | ||
|
||
public Component getTreeCellRendererComponent( | ||
JTree tree, | ||
Object value, | ||
boolean sel, | ||
boolean expanded, | ||
boolean leaf, | ||
int row, | ||
boolean hasFocus) { | ||
|
||
super.getTreeCellRendererComponent( | ||
tree, value, sel, | ||
expanded, leaf, row, | ||
hasFocus); | ||
setBackground(UIManager.getColor("Tree.background")); | ||
setForeground(UIManager.getColor("Tree.textForeground")); | ||
if (sel) { | ||
setBackground(UIManager.getColor("Tree.selectionBackground")); | ||
setForeground(UIManager.getColor("Tree.selectionForeground")); | ||
} | ||
|
||
if (value instanceof RemoteUnit) { | ||
RemoteUnit u = (RemoteUnit)value; | ||
String name = u.getCommander(); | ||
if (name == null) { | ||
name = "<font color='red'>No Crew</font>"; | ||
} | ||
String uname = "<i>" + u.getName() + "</i>"; | ||
|
||
setText("<html>" + name + ", " + uname + "</html>"); | ||
} | ||
if (value instanceof RemoteForce) { | ||
RemoteForce f = (RemoteForce)value; | ||
|
||
setText("<html>" + f.getName() + "</html>"); | ||
} | ||
|
||
return this; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
/* | ||
* Copyright (c) 2020 The MegaMek Team. | ||
* | ||
* This file is part of MekHQ. | ||
* | ||
* MekHQ is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* MekHQ is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with MekHQ. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
package mekhq.gui.model; | ||
|
||
import java.util.Vector; | ||
|
||
import javax.swing.event.TreeModelListener; | ||
import javax.swing.tree.TreeModel; | ||
import javax.swing.tree.TreePath; | ||
|
||
import mekhq.online.forces.RemoteForce; | ||
import mekhq.online.forces.RemoteTOE; | ||
import mekhq.online.forces.RemoteUnit; | ||
|
||
public class RemoteOrgTreeModel implements TreeModel { | ||
|
||
private RemoteForce rootForce; | ||
private Vector<TreeModelListener> listeners = new Vector<TreeModelListener>(); | ||
|
||
public RemoteOrgTreeModel() { | ||
rootForce = RemoteForce.emptyForce(); | ||
} | ||
|
||
public RemoteOrgTreeModel(RemoteTOE toe) { | ||
rootForce = toe.getForces(); | ||
} | ||
|
||
@Override | ||
public Object getChild(Object parent, int index) { | ||
if(parent instanceof RemoteForce) { | ||
return ((RemoteForce)parent).getAllChildren().get(index); | ||
} | ||
return null; | ||
} | ||
|
||
@Override | ||
public int getChildCount(Object parent) { | ||
if(parent instanceof RemoteForce) { | ||
return ((RemoteForce)parent).getAllChildren().size(); | ||
} | ||
return 0; | ||
} | ||
|
||
@Override | ||
public int getIndexOfChild(Object parent, Object child) { | ||
if(parent instanceof RemoteForce) { | ||
return ((RemoteForce)parent).getAllChildren().indexOf(child); | ||
} | ||
return 0; | ||
} | ||
|
||
@Override | ||
public Object getRoot() { | ||
return rootForce; | ||
} | ||
|
||
@Override | ||
public boolean isLeaf(Object node) { | ||
return node instanceof RemoteUnit | ||
|| (node instanceof RemoteForce && ((RemoteForce)node).getAllChildren().size() == 0); | ||
} | ||
|
||
@Override | ||
public void valueForPathChanged(TreePath arg0, Object arg1) { | ||
// TODO Auto-generated method stub | ||
} | ||
|
||
public void addTreeModelListener( TreeModelListener listener ) { | ||
if ( listener != null && !listeners.contains( listener ) ) { | ||
listeners.addElement( listener ); | ||
} | ||
} | ||
|
||
public void removeTreeModelListener( TreeModelListener listener ) { | ||
if ( listener != null ) { | ||
listeners.removeElement( listener ); | ||
} | ||
} | ||
} |
Oops, something went wrong.