use of megamek.common.QuadMech in project megameklab by MegaMek.
the class ImageHelper method getRecordSheet.
public static Image getRecordSheet(Entity unit, boolean advanced) {
Image recordSheet = null;
String path = new File(recordSheetPath).getAbsolutePath() + File.separatorChar;
if (unit instanceof BipedMech) {
if (advanced) {
recordSheet = new ImageIcon(path + "tobiped.png").getImage();
} else {
recordSheet = new ImageIcon(path + "twbiped.png").getImage();
}
} else if (unit instanceof QuadMech) {
if (advanced) {
recordSheet = new ImageIcon(path + "toquad.png").getImage();
} else {
recordSheet = new ImageIcon(path + "twquad.png").getImage();
}
} else if (unit instanceof VTOL) {
recordSheet = new ImageIcon(path + "twvee-vtol.png").getImage();
} else if ((unit instanceof LargeSupportTank) || ((unit instanceof Tank) && ((Tank) unit).isSuperHeavy())) {
if (unit.getOInternal(LargeSupportTank.LOC_TURRET) > 0) {
recordSheet = new ImageIcon(path + "twvee-lgsupground-turret.png").getImage();
} else {
recordSheet = new ImageIcon(path + "twvee-lgsupground.png").getImage();
}
} else if (unit instanceof Tank) {
if ((unit.getMovementMode() == EntityMovementMode.NAVAL) || (unit.getMovementMode() == EntityMovementMode.SUBMARINE) || (unit.getMovementMode() == EntityMovementMode.HYDROFOIL)) {
if (unit.getOInternal(((Tank) unit).getLocTurret()) > 0) {
recordSheet = new ImageIcon(path + "twnaval-turret.png").getImage();
} else {
recordSheet = new ImageIcon(path + "twnaval.png").getImage();
}
} else if (advanced) {
String imageName = "twvee-" + unit.getMovementModeAsString().toLowerCase().trim() + "-dualturret.png";
recordSheet = new ImageIcon(path + imageName).getImage();
} else {
String imageName = "twvee-" + unit.getMovementModeAsString().toLowerCase().trim() + ".png";
recordSheet = new ImageIcon(path + imageName).getImage();
}
} else if (unit instanceof Aero) {
if (unit instanceof Dropship) {
if (unit.getMovementMode() == EntityMovementMode.AERODYNE) {
recordSheet = new ImageIcon(path + "twaerodyneds.png").getImage();
} else {
recordSheet = new ImageIcon(path + "twspheroidds.png").getImage();
}
} else if (unit instanceof ConvFighter) {
recordSheet = new ImageIcon(path + "twconventionalfighter.png").getImage();
} else if (unit instanceof SmallCraft) {
if (unit.getMovementMode() == EntityMovementMode.AERODYNE) {
recordSheet = new ImageIcon(path + "twaero-smallcraft.png").getImage();
} else {
recordSheet = new ImageIcon(path + "twspheroid-smallcraft.png").getImage();
}
} else {
recordSheet = new ImageIcon(path + "twaero.png").getImage();
}
} else if (unit instanceof BattleArmor) {
recordSheet = new ImageIcon(path + "twba.png").getImage();
} else if (unit instanceof Protomech) {
recordSheet = new ImageIcon(path + "twproto.png").getImage();
}
return recordSheet;
}
use of megamek.common.QuadMech in project megameklab by MegaMek.
the class MainUI method createNewUnit.
@Override
public void createNewUnit(long entityType, boolean isPrimitive, boolean isIndustrial, Entity oldEntity) {
int cockpit = Mech.COCKPIT_STANDARD;
int at = EquipmentType.T_ARMOR_STANDARD;
int st = EquipmentType.T_STRUCTURE_STANDARD;
if (isPrimitive && isIndustrial) {
cockpit = Mech.COCKPIT_PRIMITIVE_INDUSTRIAL;
at = EquipmentType.T_ARMOR_PRIMITIVE;
st = EquipmentType.T_STRUCTURE_INDUSTRIAL;
} else if (isPrimitive) {
cockpit = Mech.COCKPIT_PRIMITIVE;
at = EquipmentType.T_ARMOR_PRIMITIVE;
} else if (isIndustrial) {
cockpit = Mech.COCKPIT_INDUSTRIAL;
at = EquipmentType.T_ARMOR_INDUSTRIAL;
st = EquipmentType.T_STRUCTURE_INDUSTRIAL;
}
if (entityType == Entity.ETYPE_TRIPOD_MECH) {
setEntity(new TripodMech(Mech.GYRO_STANDARD, Mech.COCKPIT_TRIPOD));
getEntity().setTechLevel(TechConstants.T_IS_TW_NON_BOX);
} else if (entityType == Entity.ETYPE_QUAD_MECH) {
setEntity(new QuadMech(Mech.GYRO_STANDARD, cockpit));
getEntity().setTechLevel(TechConstants.T_IS_TW_NON_BOX);
} else if (entityType == Entity.ETYPE_LAND_AIR_MECH) {
setEntity(new LandAirMech(Mech.GYRO_STANDARD, Mech.COCKPIT_STANDARD, LandAirMech.LAM_STANDARD));
getEntity().setTechLevel(TechConstants.T_IS_ADVANCED);
getEntity().setManualBV(-1);
} else if (entityType == Entity.ETYPE_QUADVEE) {
setEntity(new QuadVee(Mech.GYRO_STANDARD, QuadVee.MOTIVE_TRACK));
getEntity().setTechLevel(TechConstants.T_CLAN_ADVANCED);
UnitUtil.createSpreadMounts((Mech) getEntity(), EquipmentType.get("Tracks"));
getEntity().setManualBV(-1);
} else {
// type == 0
setEntity(new BipedMech(Mech.GYRO_STANDARD, cockpit));
getEntity().setTechLevel(TechConstants.T_IS_TW_NON_BOX);
}
Mech mech = (Mech) getEntity();
getEntity().setWeight(25);
if (entityType == Entity.ETYPE_LAND_AIR_MECH) {
mech.setEngine(new Engine(75, Engine.NORMAL_ENGINE, 0));
UnitUtil.updateJumpJets(((Mech) getEntity()), 3, Mech.JUMP_STANDARD);
} else {
mech.setEngine(new Engine(25, Engine.NORMAL_ENGINE, 0));
}
getEntity().setArmorType(at);
getEntity().setArmorTechLevel(getEntity().getTechLevel());
getEntity().setStructureType(st);
mech.addGyro();
mech.addEngineCrits();
if (isPrimitive) {
mech.addPrimitiveCockpit();
} else if (isIndustrial) {
mech.addIndustrialCockpit();
} else if (Entity.ETYPE_QUADVEE == entityType) {
mech.addQuadVeeCockpit();
} else {
mech.addCockpit();
}
UnitUtil.updateHeatSinks(mech, 10, "Single");
getEntity().autoSetInternal();
for (int loc = 0; loc < getEntity().locations(); loc++) {
mech.initializeArmor(0, loc);
mech.initializeRearArmor(0, loc);
}
if (null == oldEntity) {
mech.setChassis("New");
mech.setModel("Mek");
mech.setYear(3145);
} else {
mech.setChassis(oldEntity.getChassis());
mech.setModel(oldEntity.getModel());
mech.setYear(Math.max(oldEntity.getYear(), mech.getConstructionTechAdvancement().getIntroductionDate()));
mech.setSource(oldEntity.getSource());
mech.setManualBV(oldEntity.getManualBV());
SimpleTechLevel lvl = SimpleTechLevel.max(mech.getStaticTechLevel(), SimpleTechLevel.convertCompoundToSimple(oldEntity.getTechLevel()));
mech.setTechLevel(lvl.getCompoundTechLevel(oldEntity.isClan()));
mech.setMixedTech(oldEntity.isMixedTech());
}
}
use of megamek.common.QuadMech in project megameklab by MegaMek.
the class StatusBar method refresh.
public void refresh() {
int heat = getMech().getHeatCapacity();
double tonnage = getMech().getWeight();
double currentTonnage;
int bv = getMech().calculateBattleValue();
int maxCrits;
if (getMech() instanceof TripodMech) {
maxCrits = 84;
} else if (getMech() instanceof QuadMech) {
maxCrits = 66;
} else {
maxCrits = 78;
}
int currentCrits = UnitUtil.countUsedCriticals(getMech());
long currentCost = (long) Math.round(getMech().getCost(false));
testEntity = new TestMech(getMech(), entityVerifier.mechOption, null);
currentTonnage = testEntity.calculateWeight();
currentTonnage += UnitUtil.getUnallocatedAmmoTonnage(getMech());
double totalHeat = calculateTotalHeat();
heatSink.setText("Heat: " + totalHeat + "/" + heat);
heatSink.setToolTipText("Total Heat Generated/Total Heat Dissipated");
if (totalHeat > heat) {
heatSink.setForeground(Color.red);
} else {
heatSink.setForeground(Color.black);
}
tons.setText("Tonnage: " + currentTonnage + "/" + tonnage);
tons.setToolTipText("Current Tonnage/Max Tonnage");
if (currentTonnage > tonnage) {
tons.setForeground(Color.red);
} else {
tons.setForeground(Color.black);
}
bvLabel.setText("BV: " + bv);
bvLabel.setToolTipText("BV 2.0");
cost.setText("Cost: " + formatter.format(currentCost) + " C-bills");
crits.setText("Criticals: " + currentCrits + "/" + maxCrits);
if (currentCrits > maxCrits) {
crits.setForeground(Color.red);
} else {
crits.setForeground(Color.BLACK);
}
}
use of megamek.common.QuadMech in project megameklab by MegaMek.
the class UnitUtil method createSpreadMounts.
/**
* create a Mounted and corresponding CriticalSlots for the passed in
* <code>EquipmentType</code> on the passed in <code>Mech</code>
*
* @param unit
* @param equip
* @return
*/
public static Mounted createSpreadMounts(Mech unit, EquipmentType equip) {
final String METHOD_NAME = "createSpreadMounts(Mech, EquipmentType)";
// how many non-spreadable contiguous blocks of crits?
int blocks = 0;
boolean isMisc = equip instanceof MiscType;
blocks = equip.getCriticals(unit);
List<Integer> locations = new ArrayList<Integer>();
if (isMisc) {
if ((equip.hasFlag(MiscType.F_INDUSTRIAL_TSM) || equip.hasFlag(MiscType.F_TSM))) {
// all crits user placeable
for (int i = 0; i < equip.getCriticals(unit); i++) {
locations.add(Entity.LOC_NONE);
}
} else if (equip.hasFlag(MiscType.F_ENVIRONMENTAL_SEALING)) {
// 1 crit in each location
for (int i = 0; i < unit.locations(); i++) {
locations.add(i);
}
} else if (equip.hasFlag(MiscType.F_STEALTH)) {
// 2 in arms, legs, side torsos
locations.add(Mech.LOC_LLEG);
locations.add(Mech.LOC_RLEG);
locations.add(Mech.LOC_LARM);
locations.add(Mech.LOC_RARM);
locations.add(Mech.LOC_LT);
locations.add(Mech.LOC_RT);
blocks = 6;
// Need to account for the center leg
if (unit instanceof TripodMech) {
locations.add(Mech.LOC_CLEG);
blocks++;
}
} else if (equip.hasFlag(MiscType.F_SCM)) {
// 1 in arms, legs, side torsos
locations.add(Mech.LOC_LLEG);
locations.add(Mech.LOC_RLEG);
locations.add(Mech.LOC_LARM);
locations.add(Mech.LOC_RARM);
locations.add(Mech.LOC_LT);
locations.add(Mech.LOC_RT);
blocks = 6;
} else if ((equip.hasFlag(MiscType.F_TRACKS) || equip.hasFlag(MiscType.F_TALON) || equip.hasFlag(MiscType.F_JUMP_BOOSTER))) {
// 1 block in each leg
locations.add(Mech.LOC_LLEG);
locations.add(Mech.LOC_RLEG);
if (unit instanceof QuadMech) {
locations.add(Mech.LOC_LARM);
locations.add(Mech.LOC_RARM);
}
blocks = (unit instanceof BipedMech ? 2 : 4);
// Need to account for the center leg
if (unit instanceof TripodMech) {
locations.add(Mech.LOC_CLEG);
blocks = 3;
}
} else if (equip.hasFlag(MiscType.F_PARTIAL_WING)) {
// one block in each side torso
locations.add(Mech.LOC_LT);
locations.add(Mech.LOC_RT);
blocks = 2;
} else if ((equip.hasFlag(MiscType.F_VOIDSIG) || equip.hasFlag(MiscType.F_NULLSIG) || equip.hasFlag(MiscType.F_BLUE_SHIELD))) {
// Need to account for the center leg
if (unit instanceof TripodMech) {
blocks++;
}
// 1 crit in each location, except the head
for (int i = Mech.LOC_CT; i < unit.locations(); i++) {
locations.add(i);
}
} else if (equip.hasFlag(MiscType.F_CHAMELEON_SHIELD)) {
// Need to account for the center leg
if (unit instanceof TripodMech) {
blocks++;
}
// 1 crit in each location except head and CT
for (int i = Mech.LOC_RT; i < unit.locations(); i++) {
locations.add(i);
}
}
}
boolean firstBlock = true;
Mounted mount = new Mounted(unit, equip);
for (; blocks > 0; blocks--) {
// how many crits per block?
int crits = UnitUtil.getCritsUsed(unit, equip);
for (int i = 0; i < crits; i++) {
try {
if (firstBlock || (locations.get(0) == Entity.LOC_NONE)) {
// create only one mount per equipment, for BV and stuff
addMounted(unit, mount, locations.get(0), false);
if (firstBlock) {
firstBlock = false;
}
if (locations.get(0) == Entity.LOC_NONE) {
// only user-placable spread stuff gets location
// none
// for those, we need to create a mount for each
// crit,
// otherwise we can't correctly let the user place
// them
// luckily, that only affects TSM, so BV works out
// correctly
mount = new Mounted(unit, equip);
}
} else {
CriticalSlot cs = new CriticalSlot(mount);
if (!unit.addCritical(locations.get(0), cs)) {
UnitUtil.removeCriticals(unit, mount);
JOptionPane.showMessageDialog(null, "No room for equipment", mount.getName() + " does not fit into " + unit.getLocationName(locations.get(0)), JOptionPane.INFORMATION_MESSAGE);
unit.getMisc().remove(mount);
unit.getEquipment().remove(mount);
return null;
}
}
} catch (LocationFullException lfe) {
getLogger().log(UnitUtil.class, METHOD_NAME, lfe);
JOptionPane.showMessageDialog(null, lfe.getMessage(), mount.getName() + " does not fit into " + unit.getLocationName(locations.get(0)), JOptionPane.INFORMATION_MESSAGE);
unit.getMisc().remove(mount);
unit.getEquipment().remove(mount);
return null;
}
}
locations.remove(0);
}
return mount;
}
use of megamek.common.QuadMech in project megameklab by MegaMek.
the class CriticalView method refresh.
public void refresh() {
laPanel.removeAll();
raPanel.removeAll();
llPanel.removeAll();
rlPanel.removeAll();
clPanel.removeAll();
ltPanel.removeAll();
rtPanel.removeAll();
ctPanel.removeAll();
headPanel.removeAll();
clPanel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEmptyBorder(), "", TitledBorder.TOP, TitledBorder.DEFAULT_POSITION));
// the CritListCellRenderer has a default size of 110x15 and
// the border has a width of 1 so this should make each one the right
// size
Dimension size = new Dimension(112, 182);
Dimension legSize = new Dimension(112, 92);
synchronized (getMech()) {
for (int location = 0; location < getMech().locations(); location++) {
// JPanel locationPanel = new JPanel();
Vector<String> critNames = new Vector<String>(1, 1);
for (int slot = 0; slot < getMech().getNumberOfCriticals(location); slot++) {
CriticalSlot cs = getMech().getCritical(location, slot);
if (cs == null) {
if (showEmpty) {
critNames.add(MtfFile.EMPTY);
}
} else if (cs.getType() == CriticalSlot.TYPE_SYSTEM) {
critNames.add(getMech().getSystemName(cs.getIndex()));
} else if (cs.getType() == CriticalSlot.TYPE_EQUIPMENT) {
try {
Mounted m = cs.getMount();
// Critical didn't get removed. Remove it now.
if (m == null) {
m = cs.getMount();
if (m == null) {
getMech().setCritical(location, slot, null);
if (showEmpty) {
critNames.add(MtfFile.EMPTY);
}
continue;
}
cs.setMount(m);
}
StringBuffer critName = new StringBuffer(m.getName());
if (critName.length() > 25) {
critName.setLength(25);
critName.append("...");
}
if (m.isRearMounted()) {
critName.append(" (R)");
}
if (m.isMechTurretMounted()) {
critName.append(" (T)");
}
critNames.add(critName.toString());
} catch (Exception ex) {
ex.printStackTrace();
}
}
}
if (critNames.size() == 0) {
critNames.add(MtfFile.EMPTY);
}
DropTargetCriticalList<String> criticalSlotList = new DropTargetCriticalList<String>(critNames, eSource, refresh, showEmpty);
criticalSlotList.setVisibleRowCount(critNames.size());
criticalSlotList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
criticalSlotList.setFont(new Font("Arial", Font.PLAIN, 10));
criticalSlotList.setName(Integer.toString(location));
criticalSlotList.setBorder(BorderFactory.createLineBorder(Color.BLACK, 1));
switch(location) {
case Mech.LOC_HEAD:
criticalSlotList.setSize(legSize);
criticalSlotList.setPreferredSize(legSize);
criticalSlotList.setMaximumSize(legSize);
headPanel.add(criticalSlotList);
break;
case Mech.LOC_LARM:
if (getMech() instanceof QuadMech) {
laPanel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEmptyBorder(), "Front Left Leg", TitledBorder.TOP, TitledBorder.DEFAULT_POSITION));
criticalSlotList.setSize(legSize);
criticalSlotList.setPreferredSize(legSize);
criticalSlotList.setMaximumSize(legSize);
} else {
laPanel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEmptyBorder(), "Left Arm", TitledBorder.TOP, TitledBorder.DEFAULT_POSITION));
criticalSlotList.setSize(size);
criticalSlotList.setPreferredSize(size);
criticalSlotList.setMaximumSize(size);
}
laPanel.add(criticalSlotList);
break;
case Mech.LOC_RARM:
if (getMech() instanceof QuadMech) {
raPanel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEmptyBorder(), "Front Right Leg", TitledBorder.TOP, TitledBorder.DEFAULT_POSITION));
criticalSlotList.setSize(legSize);
criticalSlotList.setPreferredSize(legSize);
criticalSlotList.setMaximumSize(legSize);
} else {
raPanel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEmptyBorder(), "Right Arm", TitledBorder.TOP, TitledBorder.DEFAULT_POSITION));
criticalSlotList.setSize(size);
criticalSlotList.setPreferredSize(size);
criticalSlotList.setMaximumSize(size);
}
raPanel.add(criticalSlotList);
break;
case Mech.LOC_CT:
criticalSlotList.setSize(size);
criticalSlotList.setPreferredSize(size);
criticalSlotList.setMaximumSize(size);
ctPanel.add(criticalSlotList);
break;
case Mech.LOC_LT:
criticalSlotList.setSize(size);
criticalSlotList.setPreferredSize(size);
criticalSlotList.setMaximumSize(size);
ltPanel.add(criticalSlotList);
break;
case Mech.LOC_RT:
criticalSlotList.setSize(size);
criticalSlotList.setPreferredSize(size);
criticalSlotList.setMaximumSize(size);
rtPanel.add(criticalSlotList);
break;
case Mech.LOC_LLEG:
if (getMech() instanceof QuadMech) {
llPanel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEmptyBorder(), "Rear Left Leg", TitledBorder.TOP, TitledBorder.DEFAULT_POSITION));
} else {
llPanel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEmptyBorder(), "Left Leg", TitledBorder.TOP, TitledBorder.DEFAULT_POSITION));
}
criticalSlotList.setSize(legSize);
criticalSlotList.setPreferredSize(legSize);
criticalSlotList.setMaximumSize(legSize);
llPanel.add(criticalSlotList);
break;
case Mech.LOC_RLEG:
if (getMech() instanceof QuadMech) {
rlPanel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEmptyBorder(), "Rear Right Leg", TitledBorder.TOP, TitledBorder.DEFAULT_POSITION));
} else {
rlPanel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEmptyBorder(), "Right Leg", TitledBorder.TOP, TitledBorder.DEFAULT_POSITION));
}
criticalSlotList.setSize(legSize);
criticalSlotList.setPreferredSize(legSize);
criticalSlotList.setMaximumSize(legSize);
rlPanel.add(criticalSlotList);
break;
case Mech.LOC_CLEG:
clPanel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEmptyBorder(), "Center Leg", TitledBorder.TOP, TitledBorder.DEFAULT_POSITION));
criticalSlotList.setSize(legSize);
criticalSlotList.setPreferredSize(legSize);
criticalSlotList.setMaximumSize(legSize);
clPanel.add(criticalSlotList);
break;
}
}
ctPanel.invalidate();
raPanel.invalidate();
headPanel.invalidate();
laPanel.invalidate();
ltPanel.invalidate();
rtPanel.invalidate();
llPanel.invalidate();
rlPanel.invalidate();
clPanel.invalidate();
ctPanel.repaint();
raPanel.repaint();
headPanel.repaint();
laPanel.repaint();
ltPanel.repaint();
rtPanel.repaint();
llPanel.repaint();
rlPanel.repaint();
clPanel.invalidate();
}
}
Aggregations