public static synchronized MechSummaryCache getInstance() { return getInstance(false); }
void updateCounts() { lCacheCount.setText(String.valueOf(MechSummaryCache.getInstance() .getCacheCount())); lFileCount.setText(String.valueOf(MechSummaryCache.getInstance() .getFileCount())); lZipCount.setText(String.valueOf(MechSummaryCache.getInstance() .getZipCount())); } }
@Override public Map<MechSummary, ITechnology> call() throws Exception { Map<MechSummary,ITechnology> map = new HashMap<MechSummary,ITechnology>(); for (MechSummary ms : MechSummaryCache.getInstance().getAllMechs()) { map.put(ms, calcTechProgression(ms, techFaction)); } return map; } };
protected MechSummary getMechByName(String name) { return MechSummaryCache.getInstance().getMech(name); }
public void die() { MechSummaryCache.getInstance().removeListener(mechSummaryCacheListener); }
public void run() { while (!loadingDone && !MechSummaryCache.getInstance().isInitialized()) { updateCounts(); try { Thread.sleep(UPDATE_FREQUENCY); } catch (InterruptedException e) { // not supposed to come here } } } };
public static void main(String[] args) { boolean ignoreUnofficial = true; for (int i = 0; i < args.length; i++) { if (args[i].equals("-unofficial")){ ignoreUnofficial = false; } else { System.err.println("Error: Invalid argument.\n"); //$NON-NLS-1$ System.err.println("Usage:\n\tGenerateGenericIconList [flags] \n\n" + //$NON-NLS-1$ "Valid Flags: \n" + //$NON-NLS-1$ "-unofficial \t Consider unofficial units in data dir\n"); //$NON-NLS-1$ return; } } GenerateGenericIconList gen = new GenerateGenericIconList(); mechSummaryCache = MechSummaryCache.getInstance(ignoreUnofficial); mechSummaryCache.addListener(gen); }
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); }
public static void main(String[] args) { EquipmentType.initializeTypes(); QuirkRewriteTool qc = new QuirkRewriteTool(); mechSummaryCache = MechSummaryCache.getInstance(true); mechSummaryCache.addListener(qc); }
public static void main(String[] args) { EquipmentType.initializeTypes(); QuirkTool qc = new QuirkTool(); mechSummaryCache = MechSummaryCache.getInstance(true); mechSummaryCache.addListener(qc); }
private void exportList(int connId, String path) { try { PrintWriter pw1 = new PrintWriter(new FileWriter(path)); MechSummary[] msums = MechSummaryCache.getInstance().getAllMechs(); for (MechSummary ms1 : msums) { pw1.println(ms1.getChassis() + ", " + ms1.getModel() + ", " + ms1.getBV()); } pw1.flush(); pw1.close(); server.sendServerChat(server.getPlayer(connId).getName() + " has exported a unit list."); } catch (Exception e) { server.sendServerChat(connId, "/exportlist: execution failed"); server.sendServerChat(connId, e.toString()); } } }
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)); } }
/** Creates new form UnitSelectorDialog */ public UnitSelectorDialog(Frame frame, Campaign c, boolean add) { super(frame, true); unitModel = new MechTableModel(); addToCampaign = add; //TODO: the proper way to do this would be to create a listener interface that has //methods like buyUnit, addUnit, etc. that we could register with this dialog //and then update when needed this.campaign = c; formatter = new DecimalFormat(); asd = new AdvancedSearchDialog(frame, campaign.getCalendar().get(GregorianCalendar.YEAR)); initComponents(); MechSummary[] allMechs = MechSummaryCache.getInstance().getAllMechs(); setMechs(allMechs); setLocationRelativeTo(frame); }
/** * 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 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); }
private void stockBattleArmorSuits(Campaign c) { //this is just a test for(MechSummary summary : MechSummaryCache.getInstance().getAllMechs()) { if(!summary.getUnitType().equals("BattleArmor")) { continue; } //FIXME: I can't pull entity movement mode and quad shape off of mechsummary //try loading the full entity, but this might take too long if(null != summary) { Entity newEntity = null; try { newEntity = new MechFileParser(summary.getSourceFile(), summary.getEntryName()).getEntity(); } catch (EntityLoadingException e) { e.printStackTrace(); } if(null != newEntity) { BattleArmorSuit ba = new BattleArmorSuit(summary.getChassis(), summary.getModel(), (int)summary.getTons(), 1, summary.getWeightClass(), summary.getWalkMp(), summary.getJumpMp(), newEntity.entityIsQuad(), summary.isClan(), newEntity.getMovementMode(), c); parts.add(ba); } } } }
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(); }