protected MechSummary getMechByName(String name) { return MechSummaryCache.getInstance().getMech(name); }
public MechSummary findShip(int unitType) { WeightedTable<String> table = null; if (unitType == UnitType.JUMPSHIP) { table = jsTable; } else if (unitType == UnitType.DROPSHIP) { table = dsTable; } String shipName = table.select(); if (shipName == null) { return null; } return MechSummaryCache.getInstance().getMech(shipName); }
retVal.cash = Long.parseLong(wn2.getTextContent()); } else if (wn2.getNodeName().equalsIgnoreCase("entityName")) { MechSummary summary = MechSummaryCache.getInstance().getMech(wn2.getTextContent()); if(null == summary) { throw(new EntityLoadingException());
if (mr == null) { newEntry = true; MechSummary ms = MechSummaryCache.getInstance().getMech(modelKey); if (ms != null) { mr = new ModelRecord(ms);
private void writeCustoms(PrintWriter pw1) { for (String name : customs) { MechSummary ms = MechSummaryCache.getInstance().getMech(name); if (ms == null) { continue;
public static void main(String[] ARGS) throws Exception { MechSummary ms = MechSummaryCache.getInstance().getMech(ARGS[0]); Entity e = new MechFileParser(ms.getSourceFile(), ms.getEntryName()) .getEntity(); System.out.println(format(e)); } }
private void btnOKActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnHireActionPerformed String chassis = txtChassis.getText().trim(); String model = txtModel.getText().trim(); if(chassis.isEmpty()) { chassis = refit.getOriginalEntity().getChassis(); } if(model.isEmpty()) { model = refit.getOriginalEntity().getModel() + " Mk II"; } if(null != MechSummaryCache.getInstance().getMech(chassis + " " + model)) { JOptionPane.showMessageDialog(null, "There is already a unit in the database with this name.\nPlease select a different name.", "Name already in use", JOptionPane.ERROR_MESSAGE); return; } refit.getNewEntity().setChassis(chassis); refit.getNewEntity().setModel(model); this.setVisible(false); }
public SkinEditorMainGUI() { super(new BorderLayout()); this.addComponentListener(this); panMain.setLayout(cardsMain); panSecondary.setLayout(cardsSecondary); JPanel panDisplay = new JPanel(new BorderLayout()); panDisplay.add(panMain, BorderLayout.CENTER); panDisplay.add(panSecondary, BorderLayout.SOUTH); add(panDisplay, BorderLayout.CENTER); UnitLoadingDialog unitLoadingDialog = new UnitLoadingDialog(frame); if (!MechSummaryCache.getInstance().isInitialized()) { unitLoadingDialog.setVisible(true); } try { MechSummary ms = MechSummaryCache.getInstance().getMech( "Archer ARC-2W"); testEntity = new MechFileParser(ms.getSourceFile(), ms.getEntryName()).getEntity(); } catch (EntityLoadingException e) { e.printStackTrace(); } }
/** * Get a faction-specific ITechnology object that can be used to calculate tech levels for the given unit. * If values have not been generated for the techFaction, a new task will be started. * * @param unit The <code>Unit</code> for which to calculate the tech progression. * @param techFaction The faction to use in calculating the progression. * @param block If the task has not completed this method will wait until completion if block is true, * or return null if block is false. If the task has completed, it will return the value * without waiting. * @return An ITechnology object for the unit and faction. If the task has not completed and * block is false, or there was an exception processing the task, null is returned. */ public static ITechnology getProgression(final Unit unit, final int techFaction, final boolean block) { MechSummary ms = MechSummaryCache.getInstance().getMech(unit.getEntity().getShortName()); if (null != ms) { return getProgression(ms, techFaction, block); } else { return null; } }
public void loadEntities(Ruleset.ProgressListener l, double progress) { if (element) { MechSummary ms = MechSummaryCache.getInstance().getMech(getModelName()); if (ms != null) { try { entity = new MechFileParser(ms.getSourceFile(), ms.getEntryName()).getEntity(); entity.setCrew(getCo().createCrew(entity.defaultCrewType())); entity.setExternalIdAsString(UUID.randomUUID().toString()); } catch (EntityLoadingException ex) { DefaultMmLogger.getInstance().log(getClass(), "loadEntities(Ruleset#ProgressListener, double)", LogLevel.ERROR, "Error loading " + ms.getName() + " from file " + ms.getSourceFile().getPath()); DefaultMmLogger.getInstance().error(getClass(), "loadEntities(Ruleset#ProgressListener, double)", ex); } } } int count = subforces.size() + attached.size(); subforces.forEach(fd -> fd.loadEntities(l, progress / count)); attached.forEach(fd -> fd.loadEntities(l, progress / count)); if (count == 0 && null != l) { l.updateProgress(progress, "Loading entities"); } }
public static Entity getBrandNewUndamagedEntity(String entityShortName) { MechSummary mechSummary = MechSummaryCache.getInstance().getMech( entityShortName); if (mechSummary == null) { return null; } MechFileParser mechFileParser = null; try { mechFileParser = new MechFileParser(mechSummary.getSourceFile()); } catch (EntityLoadingException ex) { MekHQ.getLogger().error(Campaign.class, "getBrandNewUndamagedEntity(String)", ex); } if (mechFileParser == null) { return null; } return mechFileParser.getEntity(); }
private void initializeExtraCostsAndTons() { alternateCost = 0; alternateTon = 0; //simplest way to do this is just get the full cost and tonnage of a new unit and divide by //squad size MechSummary summary = MechSummaryCache.getInstance().getMech(getChassis() + " " + getModel()); if(null != summary) { int squadSize = summary.getArmorTypes().length - 1; alternateCost = summary.getAlternateCost()/squadSize; alternateTon = summary.getSuitWeight(); introYear = summary.getYear(); } }
@Override public Object getNewEquipment() { final String METHOD_NAME = "getNewEquipment()"; //$NON-NLS-1$ String name = getEntity().getChassis() + " " + getEntity().getModel(); name = name.trim(); MechSummary summary = MechSummaryCache.getInstance().getMech(name); if(null == summary) { //throw(new EntityLoadingException()); MekHQ.getLogger().log(getClass(), METHOD_NAME, LogLevel.ERROR, "Could not find a mech summary for " + name); //$NON-NLS-1$ return null; } try { return new MechFileParser(summary.getSourceFile(), summary.getEntryName()).getEntity(); } catch (EntityLoadingException e) { MekHQ.getLogger().log(getClass(), METHOD_NAME, LogLevel.ERROR, "Could not load " + summary.getEntryName()); //$NON-NLS-1$ return null; } }
private void populateRefits() { ArrayList<Refit> refits = new ArrayList<Refit>(); for(String model : Utilities.getAllVariants(unit.getEntity(), campaign)) { MechSummary summary = MechSummaryCache.getInstance().getMech(unit.getEntity().getChassis() + " " + model); if(null == summary) { continue; } try { Entity refitEn = new MechFileParser(summary.getSourceFile(), summary.getEntryName()).getEntity(); if(null != refitEn) { Refit r = new Refit(unit, refitEn, false, false); if(null == r.checkFixable()) { refits.add(r); } } } catch (EntityLoadingException ex) { MekHQ.getLogger().error(getClass(), "populateRefits()", ex); //$NON-NLS-1$ } } refitModel = new RefitTableModel(refits); }
String[] parts = s.split(SEPARATOR_COMMA, -1); String sRef = parts[0]; MechSummary ms = MechSummaryCache.getInstance().getMech(sRef); if (ms == null) { throw new ScenarioLoaderException("missingRequiredEntity", sRef); //$NON-NLS-1$
public void resetUnit() { MechSummary mechSummary = MechSummaryCache.getInstance().getMech(unit.getEntity().getShortName()); Entity entity = null; try { entity = (new MechFileParser(mechSummary.getSourceFile(), mechSummary.getEntryName())).getEntity(); } catch (EntityLoadingException ex) { MekHQ.getLogger().error(getClass(), "resetUnit()", ex); //$NON-NLS-1$ } entity.setYear(unit.campaign.getCalendar().get(Calendar.YEAR)); UnitUtil.updateLoadedUnit(entity); removeAll(); labPanel = getCorrectLab(entity); refreshRefitSummary(); add(summaryPane, BorderLayout.LINE_START); add(labPanel, BorderLayout.CENTER); labPanel.refreshAll(); }
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(); }
public void purchaseShipSearchResult() { final String METHOD_NAME = "purchaseShipSearchResult()"; //$NON-NLS-1$ MechSummary ms = MechSummaryCache.getInstance().getMech(shipSearchResult); if (ms == null) { MekHQ.getLogger().log(getClass(), METHOD_NAME, LogLevel.ERROR,
public UnitStatus(Unit unit) { this.unit = unit; this.name = unit.getName(); chassis = unit.getEntity().getChassis(); model = unit.getEntity().getModel(); //assume its a total loss until we find something that says otherwise totalLoss = true; //create a brand new entity until we find one MechSummary summary = MechSummaryCache.getInstance().getMech(getLookupName()); if(null == summary) { } else { try { entity = unit.getEntity() == null ? new MechFileParser(summary.getSourceFile(), summary.getEntryName()).getEntity() : unit.getEntity(); baseEntity = new MechFileParser(summary.getSourceFile(), summary.getEntryName()).getEntity(); } catch (EntityLoadingException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }
private void addSubParts() { MechSummary summary = MechSummaryCache.getInstance().getMech(getChassis() + " " + getModel()); if(null == summary) { return;