Search in sources :

Example 1 with UnitSelectorDialog

use of megamek.client.ui.swing.UnitSelectorDialog in project megameklab by MegaMek.

the class MenuBarCreator method jMenuGetUnitBVFromCache_actionPerformed.

private void jMenuGetUnitBVFromCache_actionPerformed() {
    UnitLoadingDialog unitLoadingDialog = new UnitLoadingDialog(parentFrame);
    unitLoadingDialog.setVisible(true);
    UnitSelectorDialog viewer = new UnitSelectorDialog(parentFrame, unitLoadingDialog, true);
    Entity tempEntity = viewer.getChosenEntity();
    if (null == tempEntity) {
        return;
    }
    tempEntity.calculateBattleValue(true, true);
    UnitUtil.showBVCalculations(tempEntity.getBVText(), parentFrame);
}
Also used : Entity(megamek.common.Entity) UnitLoadingDialog(megamek.client.ui.swing.UnitLoadingDialog) UnitSelectorDialog(megamek.client.ui.swing.UnitSelectorDialog)

Example 2 with UnitSelectorDialog

use of megamek.client.ui.swing.UnitSelectorDialog in project megameklab by MegaMek.

the class MenuBarCreator method jMenuGetUnitBreakdownFromCache_actionPerformed.

private void jMenuGetUnitBreakdownFromCache_actionPerformed() {
    UnitLoadingDialog unitLoadingDialog = new UnitLoadingDialog(parentFrame);
    unitLoadingDialog.setVisible(true);
    UnitSelectorDialog viewer = new UnitSelectorDialog(parentFrame, unitLoadingDialog, true);
    Entity tempEntity = viewer.getChosenEntity();
    if (null == tempEntity) {
        return;
    }
    UnitUtil.showUnitCostBreakDown(tempEntity, parentFrame);
}
Also used : Entity(megamek.common.Entity) UnitLoadingDialog(megamek.client.ui.swing.UnitLoadingDialog) UnitSelectorDialog(megamek.client.ui.swing.UnitSelectorDialog)

Example 3 with UnitSelectorDialog

use of megamek.client.ui.swing.UnitSelectorDialog in project megameklab by MegaMek.

the class MenuBarCreator method jMenuGetUnitWeightBreakdownFromCache_actionPerformed.

private void jMenuGetUnitWeightBreakdownFromCache_actionPerformed() {
    UnitLoadingDialog unitLoadingDialog = new UnitLoadingDialog(parentFrame);
    unitLoadingDialog.setVisible(true);
    UnitSelectorDialog viewer = new UnitSelectorDialog(parentFrame, unitLoadingDialog, true);
    Entity tempEntity = viewer.getChosenEntity();
    if (null == tempEntity) {
        return;
    }
    UnitUtil.showUnitWeightBreakDown(tempEntity, parentFrame);
}
Also used : Entity(megamek.common.Entity) UnitLoadingDialog(megamek.client.ui.swing.UnitLoadingDialog) UnitSelectorDialog(megamek.client.ui.swing.UnitSelectorDialog)

Example 4 with UnitSelectorDialog

use of megamek.client.ui.swing.UnitSelectorDialog in project megameklab by MegaMek.

the class MenuBarCreator method loadUnit.

private void loadUnit() {
    UnitLoadingDialog unitLoadingDialog = new UnitLoadingDialog(parentFrame);
    unitLoadingDialog.setVisible(true);
    UnitSelectorDialog viewer = new UnitSelectorDialog(parentFrame, unitLoadingDialog, true);
    Entity newUnit = viewer.getChosenEntity();
    viewer.setVisible(false);
    viewer.dispose();
    if (null == newUnit) {
        return;
    }
    if (UnitUtil.validateUnit(newUnit).trim().length() > 0) {
        JOptionPane.showMessageDialog(parentFrame, String.format("Warning:Invalid unit, it might load incorrectly!\n%1$s", UnitUtil.validateUnit(newUnit)));
    }
    if (newUnit.getEntityType() != parentFrame.getEntity().getEntityType()) {
        MegaMekLabMainUI newUI = null;
        if (newUnit.hasETypeFlag(Entity.ETYPE_SMALL_CRAFT)) {
            newUI = new megameklab.com.ui.Dropship.MainUI(((Aero) newUnit).isPrimitive());
        } else if (newUnit.hasETypeFlag(Entity.ETYPE_AERO) && !(newUnit.hasETypeFlag(Entity.ETYPE_JUMPSHIP) || newUnit.hasETypeFlag(Entity.ETYPE_FIXED_WING_SUPPORT))) {
            newUI = new megameklab.com.ui.Aero.MainUI(((Aero) newUnit).isPrimitive());
        } else if (newUnit.hasETypeFlag(Entity.ETYPE_BATTLEARMOR)) {
            newUI = new megameklab.com.ui.BattleArmor.MainUI();
        } else if (newUnit.hasETypeFlag(Entity.ETYPE_INFANTRY)) {
            newUI = new megameklab.com.ui.Infantry.MainUI();
        } else if (newUnit.hasETypeFlag(Entity.ETYPE_MECH)) {
            newUI = new megameklab.com.ui.Mek.MainUI();
        } else if (newUnit.hasETypeFlag(Entity.ETYPE_TANK) && !newUnit.hasETypeFlag(Entity.ETYPE_GUN_EMPLACEMENT)) {
            newUI = new megameklab.com.ui.Vehicle.MainUI();
        }
        if (null == newUI) {
            JOptionPane.showMessageDialog(parentFrame, "Warning: Could not create new UI, aborting unit load!" + System.lineSeparator() + "Probable cause: Unsupported unit type.");
            return;
        }
        parentFrame.dispose();
        UnitUtil.updateLoadedUnit(newUnit);
        newUI.setEntity(newUnit);
        newUI.reloadTabs();
        newUI.repaint();
        newUI.refreshAll();
        return;
    }
    CConfig.updateSaveFiles("");
    UnitUtil.updateLoadedUnit(newUnit);
    if (viewer.getChosenMechSummary().getSourceFile().getName().endsWith(".zip")) {
        String fileName = viewer.getChosenMechSummary().getSourceFile().getAbsolutePath();
        fileName = fileName.substring(0, fileName.lastIndexOf(File.separatorChar) + 1);
        fileName = fileName + viewer.getChosenMechSummary().getName() + ".mtf";
        CConfig.updateSaveFiles(fileName);
    } else {
        CConfig.updateSaveFiles(viewer.getChosenMechSummary().getSourceFile().getAbsolutePath());
    }
    parentFrame.setEntity(newUnit);
    reload();
    refresh();
    parentFrame.setVisible(true);
}
Also used : MegaMekLabMainUI(megameklab.com.ui.MegaMekLabMainUI) Entity(megamek.common.Entity) UnitLoadingDialog(megamek.client.ui.swing.UnitLoadingDialog) UnitSelectorDialog(megamek.client.ui.swing.UnitSelectorDialog) MegaMek(megamek.MegaMek) MegaMekLabMainUI(megameklab.com.ui.MegaMekLabMainUI) Aero(megamek.common.Aero) BattleArmor(megamek.common.BattleArmor)

Example 5 with UnitSelectorDialog

use of megamek.client.ui.swing.UnitSelectorDialog in project megameklab by MegaMek.

the class MenuBarCreator method jMenuGetUnitSpecsFromCache_actionPerformed.

private void jMenuGetUnitSpecsFromCache_actionPerformed() {
    UnitLoadingDialog unitLoadingDialog = new UnitLoadingDialog(parentFrame);
    unitLoadingDialog.setVisible(true);
    UnitSelectorDialog viewer = new UnitSelectorDialog(parentFrame, unitLoadingDialog, true);
    Entity tempEntity = viewer.getChosenEntity();
    if (null == tempEntity) {
        return;
    }
    UnitUtil.showUnitSpecs(tempEntity, parentFrame);
}
Also used : Entity(megamek.common.Entity) UnitLoadingDialog(megamek.client.ui.swing.UnitLoadingDialog) UnitSelectorDialog(megamek.client.ui.swing.UnitSelectorDialog)

Aggregations

UnitLoadingDialog (megamek.client.ui.swing.UnitLoadingDialog)9 UnitSelectorDialog (megamek.client.ui.swing.UnitSelectorDialog)9 Entity (megamek.common.Entity)9 File (java.io.File)1 JFileChooser (javax.swing.JFileChooser)1 FileNameExtensionFilter (javax.swing.filechooser.FileNameExtensionFilter)1 MegaMek (megamek.MegaMek)1 Aero (megamek.common.Aero)1 BattleArmor (megamek.common.BattleArmor)1 MechFileParser (megamek.common.MechFileParser)1 MegaMekLabMainUI (megameklab.com.ui.MegaMekLabMainUI)1