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

Weight Breakdown Adaptation #1393

Merged
merged 1 commit into from
Jan 16, 2024
Merged
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
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);
}
}
Loading