Skip to content

Commit

Permalink
Merge pull request #1393 from SJuliez/infantry-weight-breakdown
Browse files Browse the repository at this point in the history
Weight Breakdown Adaptation
  • Loading branch information
neoancient authored Jan 16, 2024
2 parents d7e6185 + c61a448 commit 4f7d16d
Showing 1 changed file with 6 additions and 32 deletions.
38 changes: 6 additions & 32 deletions megameklab/src/megameklab/ui/MenuBar.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

import megamek.client.ui.dialogs.BVDisplayDialog;
import megamek.client.ui.dialogs.CostDisplayDialog;
import megamek.client.ui.dialogs.WeightDisplayDialog;
import megamek.client.ui.swing.UnitLoadingDialog;
import megamek.common.*;
import megamek.common.annotations.Nullable;
Expand Down Expand Up @@ -1366,42 +1367,15 @@ public static void showUnitSpecs(Entity unit, JFrame frame) {
}
}

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

JTextPane textPane = new JTextPane();
JScrollPane scroll = new JScrollPane();

textPane.setText(testEntity.printEntity().toString());
textPane.setEditable(false);
textPane.setCaret(new DefaultCaret());

scroll.setViewportView(textPane);
scroll.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
scroll.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
scroll.getVerticalScrollBar().setUnitIncrement(20);

scroll.setVisible(true);

JDialog jdialog = new JDialog();

jdialog.add(scroll);
jdialog.pack();
jdialog.setLocationRelativeTo(frame);
jdialog.setVisible(true);

try {
textPane.setSelectionStart(0);
textPane.setSelectionEnd(0);
} catch (Exception ignored) {

public static void showUnitWeightBreakDown(Entity entity, JFrame frame) {
if (entity != null) {
new WeightDisplayDialog(frame, entity).setVisible(true);
}
}

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

0 comments on commit 4f7d16d

Please sign in to comment.