use of megameklab.com.ui.Mek.tabs.BuildTab in project megameklab by MegaMek.
the class BuildView method jMenuLoadSplitComponent_actionPerformed.
private void jMenuLoadSplitComponent_actionPerformed(int location, int secondaryLocation, int primarySlots, int selectedRow) {
Mounted eq = (Mounted) equipmentTable.getModel().getValueAt(selectedRow, CriticalTableModel.EQUIPMENT);
int crits = UnitUtil.getCritsUsed(getMech(), eq.getType());
int openSlots = Math.min(primarySlots, UnitUtil.getHighestContinuousNumberOfCrits(getMech(), location));
eq.setSecondLocation(secondaryLocation);
for (int slot = 0; slot < openSlots; slot++) {
try {
UnitUtil.addMounted(getMech(), eq, location, false);
} catch (Exception ex) {
ex.printStackTrace();
}
}
crits -= openSlots;
for (int slot = 0; slot < crits; slot++) {
try {
UnitUtil.addMounted(getMech(), eq, secondaryLocation, false);
} catch (Exception ex) {
ex.printStackTrace();
}
}
UnitUtil.changeMountStatus(getMech(), eq, location, secondaryLocation, false);
// go back up to grandparent build tab and fire a full refresh.
((BuildTab) getParent().getParent()).refreshAll();
}
use of megameklab.com.ui.Mek.tabs.BuildTab in project megameklab by MegaMek.
the class MainUI method reloadTabs.
@Override
public void reloadTabs() {
masterPanel.removeAll();
configPane.removeAll();
masterPanel.setLayout(new BorderLayout());
structureTab = new StructureTab(this);
previewTab = new PreviewTab(this);
statusbar = new StatusBar(this);
equipmentTab = new EquipmentTab(this);
buildTab = new BuildTab(this, equipmentTab);
structureTab.addRefreshedListener(this);
equipmentTab.addRefreshedListener(this);
buildTab.addRefreshedListener(this);
statusbar.addRefreshedListener(this);
configPane.addTab("Structure/Armor", structureTab);
// ConfigPane.addTab("Armor", armorTab);
configPane.addTab("Equipment", equipmentTab);
// ConfigPane.addTab("Weapons", weaponTab);
configPane.addTab("Assign Criticals", buildTab);
configPane.addTab("Preview", previewTab);
// masterPanel.add(header);
masterPanel.add(configPane, BorderLayout.CENTER);
masterPanel.add(statusbar, BorderLayout.SOUTH);
refreshHeader();
this.repaint();
}
use of megameklab.com.ui.Mek.tabs.BuildTab in project megameklab by MegaMek.
the class BuildView method jMenuLoadComponent_actionPerformed.
private void jMenuLoadComponent_actionPerformed(int location, int selectedRow) {
Mounted eq = (Mounted) equipmentTable.getModel().getValueAt(selectedRow, CriticalTableModel.EQUIPMENT);
if (eq.getType().isSpreadable() || eq.isSplitable()) {
if (!(eq.getType() instanceof MiscType) || !eq.getType().hasFlag(MiscType.F_TARGCOMP)) {
jMenuLoadSplitComponent_actionPerformed(location, Entity.LOC_NONE, 1, selectedRow);
} else {
// Targetting computer is flagged as spreadable so the slots will be added one at a time when loaded,
// since we don't have a way of indicating the number of slots until we know all the weapons. But
// it's not really splittable, so we need to put add all the slots at once.
jMenuLoadSplitComponent_actionPerformed(location, Entity.LOC_NONE, eq.getType().getCriticals(getMech()), selectedRow);
}
return;
}
try {
if ((eq.getType() instanceof WeaponType) && eq.getType().hasFlag(WeaponType.F_VGL)) {
String[] facings;
if (location == Mech.LOC_LT) {
facings = new String[4];
facings[0] = "Front";
facings[1] = "Front-Left";
facings[2] = "Rear-Left";
facings[3] = "Rear";
} else if (location == Mech.LOC_RT) {
facings = new String[4];
facings[0] = "Front";
facings[1] = "Front-Right";
facings[2] = "Rear-Right";
facings[3] = "Rear";
} else if (location == Mech.LOC_CT) {
facings = new String[2];
facings[0] = "Front";
facings[1] = "Rear";
} else {
JOptionPane.showMessageDialog(this, "VGL must be placed in torso location!", "Invalid location", JOptionPane.WARNING_MESSAGE);
return;
}
String facing = (String) JOptionPane.showInputDialog(this, "Please choose the facing of the VGL", "Choose Facing", JOptionPane.QUESTION_MESSAGE, null, facings, facings[0]);
if (facing == null) {
return;
}
UnitUtil.addMounted(getMech(), eq, location, false);
if (facing.equals("Front-Left")) {
eq.setFacing(5);
} else if (facing.equals("Front-Right")) {
eq.setFacing(1);
} else if (facing.equals("Rear-Right")) {
eq.setFacing(2);
} else if (facing.equals("Rear-Left")) {
eq.setFacing(4);
} else if (facing.equals("Rear")) {
eq.setFacing(3);
UnitUtil.changeMountStatus(getMech(), eq, location, -1, true);
}
} else {
UnitUtil.addMounted(getMech(), eq, location, false);
}
} catch (Exception ex) {
ex.printStackTrace();
}
UnitUtil.changeMountStatus(getMech(), eq, location, -1, false);
// go back up to grandparent build tab and fire a full refresh.
((BuildTab) getParent().getParent()).refreshAll();
}
Aggregations