Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Call CostDisplayDialog in MML #1095

Merged
merged 3 commits into from
May 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions megameklab/src/megameklab/ui/MenuBar.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
*/
package megameklab.ui;

import megamek.client.ui.dialogs.CostDisplayDialog;
import megamek.client.ui.swing.UnitLoadingDialog;
import megamek.common.*;
import megamek.common.annotations.Nullable;
Expand Down Expand Up @@ -808,7 +809,7 @@ private JMenu createUnitCostBreakdownMenu() {
miCurrentUnitCostBreakdown.setName("miCurrentUnitCostBreakdown");
miCurrentUnitCostBreakdown.setMnemonic(KeyEvent.VK_U);
miCurrentUnitCostBreakdown.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_U, InputEvent.ALT_DOWN_MASK));
miCurrentUnitCostBreakdown.addActionListener(evt -> UnitUtil.showUnitCostBreakDown(getFrame(), getFrame().getEntity()));
miCurrentUnitCostBreakdown.addActionListener(evt -> new CostDisplayDialog(getFrame(), getFrame().getEntity()).setVisible(true));
unitCostBreakdownMenu.add(miCurrentUnitCostBreakdown);

final JMenuItem miUnitCostBreakdownFromCache = new JMenuItem(resources.getString("FromCache.text"));
Expand Down Expand Up @@ -928,7 +929,7 @@ private void jMenuGetUnitBreakdownFromCache_actionPerformed() {
UnitLoadingDialog unitLoadingDialog = new UnitLoadingDialog(getFrame());
unitLoadingDialog.setVisible(true);
MegaMekLabUnitSelectorDialog viewer = new MegaMekLabUnitSelectorDialog(getFrame(), unitLoadingDialog);
UnitUtil.showUnitCostBreakDown(getFrame(), viewer.getChosenEntity());
new CostDisplayDialog(getFrame(), viewer.getChosenEntity()).setVisible(true);
}

private void jMenuGetUnitWeightBreakdownFromCache_actionPerformed() {
Expand Down Expand Up @@ -998,7 +999,7 @@ private void jMenuGetUnitBreakdownFromFile_actionPerformed() {
}

try {
UnitUtil.showUnitCostBreakDown(getFrame(), new MechFileParser(unitFile).getEntity());
new CostDisplayDialog(getFrame(), new MechFileParser(unitFile).getEntity()).setVisible(true);
} catch (Exception ex) {
JOptionPane.showMessageDialog(getFrame(),
String.format(resources.getString("message.invalidUnit.format"),
Expand Down
11 changes: 1 addition & 10 deletions megameklab/src/megameklab/util/UnitUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
package megameklab.util;

import megamek.client.ui.dialogs.BVDisplayDialog;
import megamek.client.ui.dialogs.CostDisplayDialog;
import megamek.common.*;
import megamek.common.annotations.Nullable;
import megamek.common.verifier.*;
Expand Down Expand Up @@ -3481,15 +3482,6 @@ public static void showUnitSpecs(Entity unit, JFrame frame) {
}
}

public static void showUnitCostBreakDown(final JFrame frame, final @Nullable Entity entity) {
if (entity == null) {
return;
}
entity.calculateBattleValue(true, true);
entity.getCost(true);
new BVDisplayDialog(frame, entity).setVisible(true);
}

public static void showUnitWeightBreakDown(Entity unit, JFrame frame) {
TestEntity testEntity = getEntityVerifier(unit);

Expand Down Expand Up @@ -3533,7 +3525,6 @@ public static void showBVCalculations(final JFrame frame, final @Nullable Entity
if (entity == null) {
return;
}
entity.calculateBattleValue(true, true);
new BVDisplayDialog(frame, entity).setVisible(true);
}

Expand Down