/** * Find the role used for Campaign Operations/AlphaStrike formation building rules. * * @param en The Entity * @return The role defined for the unit in data/unit_roles.txt, or UNDETERMINED if * the unit has no entry */ public static UnitRole getRoleFor(Entity en) { return getRoleFor(en.getShortNameRaw()); }
/** * If we remove a unit, we may need to update the duplicate identifier. TODO: This function is super slow :( * * @param entity */ private void checkDuplicateNamesDuringDelete(Entity entity) { Object o = duplicateNameHash.get(entity.getShortNameRaw()); if (o != null) { int count = ((Integer) o).intValue(); if (count > 1) { for (Unit u : getUnits()) { Entity e = u.getEntity(); if (e.getShortNameRaw().equals(entity.getShortNameRaw()) && (e.duplicateMarker > entity.duplicateMarker)) { e.duplicateMarker--; e.generateShortName(); e.generateDisplayName(); } } duplicateNameHash.put(entity.getShortNameRaw(), Integer.valueOf(count - 1)); } else { duplicateNameHash.remove(entity.getShortNameRaw()); } } }
/** * Returns the MechEntry corresponding to the entity */ public MechEntry entryFor(Entity entity, int secondaryPos) { //Some entities (QuadVees, LAMs) use different sprites depending on mode. String mode = entity.getTilesetModeString().toUpperCase(); // first, check for exact matches if (secondaryPos != -1) { if (exact.containsKey(entity.getShortNameRaw().toUpperCase()+mode+"_"+secondaryPos)) { return exact.get(entity.getShortNameRaw().toUpperCase()+mode+"_"+secondaryPos); } // next, chassis matches if (chassis.containsKey(entity.getChassis().toUpperCase()+mode+"_"+secondaryPos)) { return chassis.get(entity.getChassis().toUpperCase()+mode+"_"+secondaryPos); } // last, the generic model return genericFor(entity, secondaryPos); } if (exact.containsKey(entity.getShortNameRaw().toUpperCase() + mode)) { return exact.get(entity.getShortNameRaw().toUpperCase() + mode); } // next, chassis matches if (chassis.containsKey(entity.getChassis().toUpperCase() + mode)) { return chassis.get(entity.getChassis().toUpperCase() + mode); } // last, the generic model return genericFor(entity, secondaryPos); }
String rawName = e.getShortNameRaw(); ArrayList<Integer> namedIds = rawNameToId.get(rawName); if (namedIds == null) { String removedRawName = removedEntity.getShortNameRaw(); Integer count = duplicateNameHash.get(removedEntity.getShortNameRaw()); if ((count != null) && (count > 1)) { ArrayList<Integer> namedIds = rawNameToId.get(removedRawName); for (Integer i : namedIds) { Entity e = game.getEntity(i); String eRawName = e.getShortNameRaw(); if (eRawName.equals(removedRawName) && (e.duplicateMarker > removedEntity.duplicateMarker)) { e.duplicateMarker--; duplicateNameHash.put(removedEntity.getShortNameRaw(), new Integer(count - 1)); duplicateNameHash.remove(removedEntity.getShortNameRaw());
public Image imageFor(Entity entity, Component comp, int secondaryPos) { MechEntry entry = entryFor(entity, secondaryPos); if (entry == null) { System.err .println("Entry is null make sure that there is a default entry for " + entity.getShortNameRaw() + " in both mechset.txt and wreckset.txt. Default to " + LIGHT_STRING); System.err.flush(); entry = default_light; } if (entry.getImage() == null) { entry.loadImage(comp); } return entry.getImage(); }
public Image imageFor(Entity entity, int facing, int secondaryPos) { ArrayList<Integer> temp = new ArrayList<Integer>(); temp.add(entity.getId()); temp.add(secondaryPos); EntityImage entityImage = mechImages.get(temp); if (entityImage == null) { // probably double_blind. Try to load on the fly System.out .println("Loading image for " + entity.getShortNameRaw() + " on the fly."); //$NON-NLS-1$ //$NON-NLS-2$ loadImage(entity, secondaryPos); entityImage = mechImages.get(temp); if (entityImage == null) { // now it's a real problem System.out .println("Unable to load image for entity: " + entity.getShortNameRaw()); //$NON-NLS-1$ // Try to get a default image, so something is displayed MechEntry defaultEntry = mechTileset.genericFor(entity, -1); if (defaultEntry.getImage() == null) { defaultEntry.loadImage(boardview); } return defaultEntry.getImage(); } } // get image rotated for facing return entityImage.getFacing(facing); }
@Override public Object getValueAt(int rowIndex, int columnIndex) { final Entity en = entities.get(rowIndex); switch (columnIndex) { case COL_ENTITY: return en.getShortNameRaw(); case COL_BV: return en.calculateBattleValue(); case COL_MOVE: return en.getWalkMP() + "/" + en.getRunMPasString() + "/" + en.getJumpMP(); } return ""; }
public Image wreckMarkerFor(Entity entity, int secondaryPos) { ArrayList<Integer> temp = new ArrayList<Integer>(); temp.add(entity.getId()); temp.add(secondaryPos); EntityImage entityImage = mechImages.get(temp); if (entityImage == null) { // probably double_blind. Try to load on the fly System.out .println("Loading wreckMarker image for " + entity.getShortNameRaw() + " on the fly."); //$NON-NLS-1$ //$NON-NLS-2$ loadImage(entity, secondaryPos); entityImage = mechImages.get(temp); if (entityImage == null) { // now it's a real problem System.out .println("Unable to load wreckMarker image for entity: " + entity.getShortNameRaw()); //$NON-NLS-1$ // Try to get a default image, so something is displayed MechEntry defaultEntry = wreckTileset.genericFor(entity, -1); if (defaultEntry.getImage() == null) { defaultEntry.loadImage(boardview); } return defaultEntry.getImage(); } } return entityImage.getWreckFacing(entity.getFacing()); }
public void writeToXml(PrintWriter pw1, int indent) { pw1.println(MekHqXmlUtil.indentStr(indent) + "<personnelMarket>"); for (Person p : personnel) { p.writeToXml(pw1, indent + 1); } if (null != method) { method.writeToXml(pw1, indent); } if (paidRecruitment) { pw1.println(MekHqXmlUtil.indentStr(indent + 1) + "<paidRecruitment/>"); } MekHqXmlUtil.writeSimpleXmlTag(pw1, indent + 1, "paidRecruitType", paidRecruitType); for (UUID id : attachedEntities.keySet()) { pw1.println(MekHqXmlUtil.indentStr(indent + 1) + "<entity id=\"" + id.toString() + "\">" + attachedEntities.get(id).getShortNameRaw() + "</entity>"); } pw1.println(MekHqXmlUtil.indentStr(indent) + "</personnelMarket>"); }
protected void addBasicData(Entity entity) { model.put("formatBasicDataRow", new FormatTableRowMethod(new int[] { 30, 20, 5 }, new Justification[] { Justification.LEFT, Justification.LEFT, Justification.RIGHT })); model.put("fullName", entity.getShortNameRaw()); model.put("chassis", entity.getChassis()); model.put("techBase", formatTechBase(entity)); model.put("tonnage", NumberFormat.getInstance().format(entity.getWeight())); model.put("battleValue", NumberFormat.getInstance().format(entity.calculateBattleValue())); model.put("cost", NumberFormat.getInstance().format(entity.getCost(false))); final StringJoiner quirksList = new StringJoiner(", "); final Quirks quirks = entity.getQuirks(); for (final Enumeration<IOptionGroup> optionGroups = quirks.getGroups(); optionGroups.hasMoreElements();) { final IOptionGroup group = optionGroups.nextElement(); if (quirks.count(group.getKey()) > 0) { for (final Enumeration<IOption> options = group.getOptions(); options.hasMoreElements();) { final IOption option = options.nextElement(); if ((option != null) && option.booleanValue()) { quirksList.add(option.getDisplayableNameWithValue()); } } } } if (quirksList.length() > 0) { model.put("quirks", quirksList.toString()); } }
public Image iconFor(Entity entity) { ArrayList<Integer> temp = new ArrayList<Integer>(); temp.add(entity.getId()); temp.add(-1); EntityImage entityImage = mechImages.get(temp); if (entityImage == null) { // probably double_blind. Try to load on the fly System.out .println("Loading icon for " + entity.getShortNameRaw() + " on the fly."); //$NON-NLS-1$ //$NON-NLS-2$ loadImage(entity, -1); entityImage = mechImages.get(temp); if (entityImage == null) { // now it's a real problem System.out .println("Unable to load icon for entity: " + entity.getShortNameRaw()); //$NON-NLS-1$ // Try to get a default image, so something is displayed MechEntry defaultEntry = mechTileset.genericFor(entity, -1); if (defaultEntry.getImage() == null) { defaultEntry.loadImage(boardview); } if (defaultEntry.getImage() != null) { return ImageUtil.getScaledImage(defaultEntry.getImage(), 56, 48); } else { return null; } } } return entityImage.getIcon(); }
public void assignKills() { final String METHOD_NAME = "assignKills()"; //$NON-NLS-1$ for(Unit u : units) { for(String killed : killCredits.keySet()) { if(killCredits.get(killed).equalsIgnoreCase("None")) { continue; } if(u.getId().toString().equals(killCredits.get(killed))) { for(Person p : u.getActiveCrew()) { PersonStatus status = peopleStatus.get(p.getId()); if(null == status) { //this shouldnt happen so report MekHQ.getLogger().log(getClass(), METHOD_NAME, LogLevel.ERROR, "A null person status was found for person id " + p.getId().toString() //$NON-NLS-1$ + " when trying to assign kills"); //$NON-NLS-1$ continue; } status.addKill(new Kill(p.getId(), killed, u.getEntity().getShortNameRaw(), campaign.getCalendar().getTime())); } } } } }
sHead.append(entity.getShortNameRaw()); sHead.append("\n"); //$NON-NLS-1$ if (entity.isMixedTech()) {
DefaultMmLogger.getInstance().log(getClass(), "getTreeCellRendererComponent(JTree, Object, boolean, boolean, boolean, int, boolean)", LogLevel.WARNING, "No image found for " + fd.getEntity().getShortNameRaw());
public void loadUnit(Unit u) { unit = u; MechSummary mechSummary = MechSummaryCache.getInstance().getMech(unit.getEntity().getShortNameRaw()); Entity entity = null; try { entity = (new MechFileParser(mechSummary.getSourceFile(), mechSummary.getEntryName())).getEntity(); } catch (EntityLoadingException ex) { MekHQ.getLogger().error(getClass(), "loadUnit(Unit)", ex); //$NON-NLS-1$ } entity.setYear(unit.campaign.getCalendar().get(Calendar.YEAR)); UnitUtil.updateLoadedUnit(entity); entity.setModel(entity.getModel() + " Mk II"); removeAll(); // We need to override the values in the MML properties file with the campaign options settings. CConfig.setParam(CConfig.TECH_EXTINCT, String.valueOf(campaignGUI.getCampaign().showExtinct())); CConfig.setParam(CConfig.TECH_PROGRESSION, String.valueOf(campaignGUI.getCampaign().useVariableTechLevel())); CConfig.setParam(CConfig.TECH_SHOW_FACTION, String.valueOf(campaignGUI.getCampaign().getTechFaction() >= 0)); CConfig.setParam(CConfig.TECH_UNOFFICAL_NO_YEAR, String.valueOf(campaignGUI.getCampaign().unofficialNoYear())); CConfig.setParam(CConfig.TECH_USE_YEAR, String.valueOf(campaignGUI.getCampaign().getGameYear())); CConfig.setParam(CConfig.TECH_YEAR, String.valueOf(campaignGUI.getCampaign().getGameYear())); labPanel = getCorrectLab(entity); labPanel.setTechFaction(campaignGUI.getCampaign().getTechFaction()); refreshRefitSummary(); add(summaryPane, BorderLayout.LINE_START); add(labPanel, BorderLayout.CENTER); labPanel.refreshAll(); }
sHead.add(new Title(entity.getShortNameRaw())); String techLevel = entity.getStaticTechLevel().toString(); if (entity.isMixedTech()) {
&& ms.getName().equals(units.get(p.getUnitId()).getEntity().getShortNameRaw())) { p.setOriginalUnitId(p.getUnitId());
ms.getEntryName()).getEntity(); displayMessage("Validating Entity: " + entity.getShortNameRaw(), METHOD_NAME); //$NON-NLS-1$ EntityVerifier entityVerifier = EntityVerifier.getInstance( new MegaMekFile(Configuration.unitsDir(),
ent.getShortNameRaw()); if (index >= 0) { ent.setCanon(true);
private MechSummary getSummary(Entity e, File f, String entry) { MechSummary ms = new MechSummary(); ms.setName(e.getShortNameRaw()); ms.setChassis(e.getChassis()); ms.setModel(e.getModel());