buttonList = new ArrayList<>();
+ ReportCommand[] commands = ReportCommand.values();
+ CommandComparator comparator = new CommandComparator();
+ Arrays.sort(commands, comparator);
+ for (ReportCommand cmd : commands) {
+ buttonList.add(buttons.get(cmd));
+ }
+ return buttonList;
}
/**
- * Show or hide the "reroll inititiative" button in this report display.
- *
- * @param show
- * a boolean
that indicates that the button should
- * be shown in this report display.
+ * Clears all current actions
*/
- public void showRerollButton(boolean show) {
- rerollInitiativeB.setVisible(show);
+ @Override
+ public void clear() {
+
}
/**
@@ -133,136 +138,46 @@ public void showRerollButton(boolean show) {
*/
@Override
public void ready() {
- rerollInitiativeB.setEnabled(false);
+ if (!clientgui.getBoardView().isTileImagesLoaded()) {
+ return;
+ }
+
butDone.setEnabled(false);
+ setReportEnabled(false);
+ setPlayerListEnabled(false);
+ setRerollInitiativeEnabled(false);
clientgui.getClient().sendDone(true);
}
- /**
- * Requests an initiative reroll and disables the ready button.
- */
- public void rerollInitiative() {
- rerolled = true;
- rerollInitiativeB.setEnabled(false);
- // butDone.setEnabled(false);
- clientgui.getClient().sendRerollInitiativeRequest();
+ public void setReportEnabled(boolean enabled) {
+ buttons.get(ReportCommand.REPORT_REPORT).setEnabled(enabled);
}
- /**
- * have we rerolled init this round?
- */
- public boolean hasRerolled() {
- return rerolled;
+ public void setPlayerListEnabled(boolean enabled) {
+ buttons.get(ReportCommand.REPORT_PLAYERLIST).setEnabled(enabled);
}
- public void resetButtons() {
- resetReadyButton();
- if (clientgui.getClient().getGame().getPhase().isInitiativeReport()
- && clientgui.getClient().getGame().hasTacticalGenius(clientgui.getClient().getLocalPlayer())) {
- showRerollButton(true);
- } else {
- showRerollButton(false);
- }
- rerollInitiativeB.setEnabled(true);
+ public void setRerollInitiativeEnabled(boolean enabled) {
+ buttons.get(ReportCommand.REPORT_REROLLINITIATIVE).setEnabled(enabled);
}
- public void resetReadyButton() {
- butDone.setEnabled(true);
- }
-
- public void resetRerollButton() {
- rerollInitiativeB.setEnabled(true);
- }
-
- public void setReportTab(int round, String roundText, String phaseText) {
- if (round == 0) {
- // The deployment reports (round 0) are combined with round one's
- // report.
- round = 1;
- }
- if (tabs.indexOfTab(MSG_ROUND + " " + round) == -1) {
- // Need a new tab for the new round.
-
- // get rid of phase tab
- int phaseTab = tabs.indexOfTab(MSG_PHASE);
- if (phaseTab >= 0) {
- tabs.removeTabAt(phaseTab);
- }
- if (phaseTab == -1) {
- phaseTab += 1; // special handling for round 0
- }
-
- // add as many round tabs as necessary to catch us up
- JTextPane ta;
- // TODO: we should remove the use of client
- final Client client = clientgui.getClient();
- for (int catchup = phaseTab + 1; catchup <= round; catchup++) {
- if (tabs.indexOfTab(MSG_ROUND + " " + catchup) != -1) {
- ((JTextPane) ((JScrollPane) tabs.getComponentAt(tabs
- .indexOfTab(MSG_ROUND + " " + catchup))).getViewport()
- .getView()).setText(""
- + client.receiveReport(client.getGame().getReports(
- catchup)) + "
");
- continue;
- }
- String text = roundText;
- if (catchup != round) {
- text = client.receiveReport(client.getGame().getReports(catchup));
- }
- ta = new JTextPane();
- ta.addHyperlinkListener(this);
- setupStylesheet(ta);
- BASE64ToolKit toolKit = new BASE64ToolKit();
- ta.setEditorKit(toolKit);
- ta.setText("" + text + "
");
- ta.setEditable(false);
- ta.setOpaque(false);
- tabs.add(MSG_ROUND + " " + catchup, new JScrollPane(ta));
- }
-
- // add the new current phase tab
- ta = new JTextPane();
- ta.addHyperlinkListener(this);
- setupStylesheet(ta);
- BASE64ToolKit toolKit = new BASE64ToolKit();
- ta.setEditorKit(toolKit);
- ta.setText("" + phaseText + "
");
- ta.setEditable(false);
- ta.setOpaque(false);
-
-
- JScrollPane sp = new JScrollPane(ta);
- tabs.add(MSG_PHASE, sp);
- tabs.setSelectedComponent(sp);
- } else {
- // Update the existing round tab and the phase tab.
- ((JTextPane) ((JScrollPane) tabs.getComponentAt(tabs.indexOfTab(MSG_ROUND + " " + round))).getViewport().getView()).setText("" + roundText + "
");
- ((JTextPane) ((JScrollPane) tabs.getComponentAt(tabs.indexOfTab(MSG_PHASE))).getViewport().getView()).setText("" + phaseText + "
");
+ public void resetRerollInitiativeEnabled() {
+ if (!rerolled) {
+ setRerollInitiativeEnabled(true);
}
}
- public static void setupStylesheet(JTextPane pane) {
- pane.setContentType("text/html");
- StyleSheet styleSheet = ((HTMLEditorKit) pane.getEditorKit()).getStyleSheet();
- Report.setupStylesheet(styleSheet);
- }
-
- public void appendReportTab(String additionalText) {
- int phaseTab = tabs.indexOfTab(MSG_PHASE);
- if (phaseTab > 0) {
- JTextPane pane = ((JTextPane) ((JScrollPane) tabs.getComponentAt(phaseTab - 1)).getViewport().getView());
- BASE64ToolKit toolKit = new BASE64ToolKit();
- pane.setEditorKit(toolKit);
- pane.setText(pane.getText() + ""+additionalText+"
");
- }
- JTextPane pane = ((JTextPane) ((JScrollPane) tabs.getComponentAt(phaseTab)).getViewport().getView());
- BASE64ToolKit toolKit = new BASE64ToolKit();
- pane.setEditorKit(toolKit);
- pane.setText(pane.getText() + ""+additionalText+"
");
+ public void setDoneEnabled(boolean enabled) {
+ butDone.setEnabled(enabled);
}
- public void resetTabs() {
- tabs.removeAll();
+ /**
+ * Requests an initiative reroll and disables the ready button.
+ */
+ public void rerollInitiative() {
+ rerolled = true;
+ setRerollInitiativeEnabled(false);
+ clientgui.getClient().sendRerollInitiativeRequest();
}
//
@@ -270,36 +185,52 @@ public void resetTabs() {
//
@Override
public void actionPerformed(ActionEvent ev) {
- if (ev.getActionCommand().equalsIgnoreCase(RD_ACTIONCOMMAND_REROLLINITIATIVE)) {
+ if (ev.getActionCommand().equalsIgnoreCase(ReportCommand.REPORT_REROLLINITIATIVE.getCmd())) {
rerollInitiative();
+ } else if ((ev.getActionCommand().equalsIgnoreCase(ReportCommand.REPORT_REPORT.getCmd()))) {
+ GUIP.toggleRoundReportEnabled();
+ } else if ((ev.getActionCommand().equalsIgnoreCase(ReportCommand.REPORT_PLAYERLIST.getCmd()))) {
+ GUIP.togglePlayerListEnabled();
+ }
+ }
+
+ private void resetButtons() {
+ butDone.setEnabled(true);
+ setReportEnabled(true);
+ setPlayerListEnabled(true);
+
+ if ((clientgui.getClient().getGame().getPhase() == GamePhase.INITIATIVE_REPORT) && clientgui.getClient().getGame().hasTacticalGenius(clientgui.getClient().getLocalPlayer())) {
+ setRerollInitiativeEnabled(true);
}
}
@Override
public void gamePhaseChange(GamePhaseChangeEvent e) {
-
// Are we ignoring events?
if (isIgnoringEvents()) {
return;
}
- setReportTab(clientgui.getClient().getGame().getRoundCount(), clientgui.getClient().roundReport, clientgui.getClient().phaseReport);
- resetButtons();
rerolled = false;
- SwingUtilities.invokeLater(() -> {
- int phaseTab = tabs.indexOfTab(MSG_PHASE);
- if (phaseTab > 0) {
- JViewport vp = ((JScrollPane) tabs.getComponentAt(phaseTab - 1)).getViewport();
- vp.setViewPosition(new Point());
- }
- JViewport vp = ((JScrollPane) tabs.getComponentAt(phaseTab)).getViewport();
- vp.setViewPosition(new Point());
- });
- }
-
- public void clear() {
- // move along, move along, nothing to see here
+ GamePhase phase = clientgui.getClient().getGame().getPhase();
+
+ switch (phase) {
+ case INITIATIVE_REPORT:
+ case TARGETING_REPORT:
+ case MOVEMENT_REPORT:
+ case OFFBOARD_REPORT:
+ case FIRING_REPORT:
+ case PHYSICAL_REPORT:
+ case END_REPORT:
+ case VICTORY:
+ resetButtons();
+ setStatusBarText(phase.toString());
+ break;
+ default:
+ setStatusBarText(phase.toString());
+ break;
+ }
}
/**
@@ -308,67 +239,7 @@ public void clear() {
@Override
public void removeAllListeners() {
clientgui.getClient().getGame().removeGameListener(this);
- GUIPreferences.getInstance().removePreferenceChangeListener(this);
- }
-
- private JComponent activePane() {
- return (JComponent) ((JScrollPane) tabs.getSelectedComponent()).getViewport().getView();
- }
-
- @Override
- public void hyperlinkUpdate(HyperlinkEvent evt) {
- String evtDesc = evt.getDescription();
- if (evt.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
- if (evtDesc.startsWith(Report.ENTITY_LINK)) {
- String idString = evtDesc.substring(Report.ENTITY_LINK.length());
- int id;
- try {
- id = Integer.parseInt(idString);
- } catch (Exception ex) {
- id = -1;
- }
- Entity ent = clientgui.getClient().getGame().getEntity(id);
- if (ent != null) {
- clientgui.getUnitDisplay().displayEntity(ent);
- clientgui.setUnitDisplayVisible(true);
- }
- } else if (evtDesc.startsWith(Report.TOOLTIP_LINK)) {
- String desc = evtDesc.substring(Report.TOOLTIP_LINK.length());
- JOptionPane.showMessageDialog(clientgui, desc, Messages.getString(MSG_DETAILS),
- JOptionPane.PLAIN_MESSAGE);
- }
- } else if (evt.getEventType() == HyperlinkEvent.EventType.ENTERED) {
- if (evtDesc.startsWith(Report.TOOLTIP_LINK)) {
- String desc = evtDesc.substring(Report.TOOLTIP_LINK.length());
- activePane().setToolTipText(desc);
- }
- } else if (evt.getEventType() == HyperlinkEvent.EventType.EXITED) {
- activePane().setToolTipText(null);
- }
+ clientgui.getBoardView().removeBoardViewListener(this);
+ clientgui.getBoardView().removeKeyListener(this);
}
- private void adaptToGUIScale() {
- UIUtil.adjustContainer(panelTop, UIUtil.FONT_SCALE1);
- UIUtil.scaleComp(butDone, UIUtil.FONT_SCALE2);
-
- for (int i = 0; i < tabs.getTabCount(); i++) {
- Component cp = tabs.getComponentAt(i);
- if (cp instanceof JScrollPane) {
- Component pane = ((JScrollPane) cp).getViewport().getView();
- if (pane instanceof JTextPane) {
- JTextPane tp = (JTextPane) pane;
- setupStylesheet(tp);
- tp.setText(tp.getText());
- }
- }
- }
- }
-
- @Override
- public void preferenceChange(PreferenceChangeEvent e) {
- // Update the text size when the GUI scaling changes
- if (e.getName().equals(GUIPreferences.GUI_SCALE)) {
- adaptToGUIScale();
- }
- }
-
}
diff --git a/megamek/src/megamek/client/ui/swing/TargetingPhaseDisplay.java b/megamek/src/megamek/client/ui/swing/TargetingPhaseDisplay.java
index 1beb65d5f2d..ced68cd775f 100644
--- a/megamek/src/megamek/client/ui/swing/TargetingPhaseDisplay.java
+++ b/megamek/src/megamek/client/ui/swing/TargetingPhaseDisplay.java
@@ -609,7 +609,7 @@ private void endMyTurn() {
if ((phase == clientgui.getClient().getGame().getPhase())
&& (null != next) && (null != ce())
&& (next.getOwnerId() != ce().getOwnerId())) {
- clientgui.setUnitDisplayVisible(false);
+ clientgui.maybeShowUnitDisplay();
}
cen = Entity.NONE;
target(null);
diff --git a/megamek/src/megamek/client/ui/swing/boardview/BoardView.java b/megamek/src/megamek/client/ui/swing/boardview/BoardView.java
index b4855242b5e..32d667306c2 100644
--- a/megamek/src/megamek/client/ui/swing/boardview/BoardView.java
+++ b/megamek/src/megamek/client/ui/swing/boardview/BoardView.java
@@ -411,6 +411,8 @@ public class BoardView extends JPanel implements Scrollable, BoardListener, Mous
/** The coords where the mouse was last. */
Coords lastCoords;
+ private GUIPreferences GUIP = GUIPreferences.getInstance();
+
/**
* Construct a new board view for the specified game
*/
@@ -419,6 +421,10 @@ public BoardView(final Game game, final MegaMekController controller, ClientGUI
this.game = game;
this.clientgui = clientgui;
+ if (GUIP == null) {
+ GUIP = GUIPreferences.getInstance();
+ }
+
hexImageCache = new ImageCache<>();
tileManager = new TilesetManager(this);
@@ -480,8 +486,8 @@ public BoardView(final Game game, final MegaMekController controller, ClientGUI
double ihdy = ((double) inhexDelta.y) / ((double) HEX_H) / scale;
int oldzoomIndex = zoomIndex;
- boolean ZoomNoCtrl = GUIPreferences.getInstance().getMouseWheelZoom();
- boolean wheelFlip = GUIPreferences.getInstance().getMouseWheelZoomFlip();
+ boolean ZoomNoCtrl = GUIP.getMouseWheelZoom();
+ boolean wheelFlip = GUIP.getMouseWheelZoomFlip();
boolean zoomIn = (we.getWheelRotation() > 0) ^ wheelFlip; // = XOR
boolean doZoom = ZoomNoCtrl ^ we.isControlDown(); // = XOR
boolean horizontalScroll = !doZoom && we.isShiftDown();
@@ -535,7 +541,7 @@ public void mouseMoved(MouseEvent e) {
int deltaX = point.x - prevTipX;
int deltaY = point.y - prevTipY;
double deltaMagnitude = Math.sqrt(deltaX * deltaX + deltaY * deltaY);
- if (deltaMagnitude > GUIPreferences.getInstance().getTooltipDistSuppression()) {
+ if (deltaMagnitude > GUIP.getTooltipDistSuppression()) {
prevTipX = -1; prevTipY = -1;
// Set the dismissal delay to 0 so that the tooltip
// goes away and does not reappear until the mouse
@@ -622,7 +628,7 @@ public void mouseDragged(MouseEvent e) {
secondLOSSprite = new CursorSprite(this, Color.red);
PreferenceManager.getClientPreferences().addPreferenceChangeListener(this);
- GUIPreferences.getInstance().addPreferenceChangeListener(this);
+ GUIP.addPreferenceChangeListener(this);
KeyBindParser.addPreferenceChangeListener(this);
SpecialHexDisplay.Type.ARTILLERY_HIT.init();
@@ -871,7 +877,7 @@ public void preferenceChange(PreferenceChangeEvent e) {
break;
case GUIPreferences.UNIT_LABEL_STYLE:
- clientgui.systemMessage("Label style changed to " + GUIPreferences.getInstance().getUnitLabelStyle().description);
+ clientgui.systemMessage("Label style changed to " + GUIP.getUnitLabelStyle().description);
case GUIPreferences.UNIT_LABEL_BORDER:
case GUIPreferences.TEAM_COLORING:
case GUIPreferences.SHOW_DAMAGE_DECAL:
@@ -1018,18 +1024,23 @@ public void removeDisplayable(IDisplayable disp) {
*/
@Override
public synchronized void paintComponent(Graphics g) {
- GUIPreferences guip = GUIPreferences.getInstance();
-
- if (guip.getBoolean(GUIPreferences.ADVANCED_SHOW_FPS)) {
+ if (GUIP.getBoolean(GUIPreferences.ADVANCED_SHOW_FPS)) {
paintCompsStartTime = System.nanoTime();
}
- if (guip.getAntiAliasing()) {
+ if (GUIP.getAntiAliasing()) {
((Graphics2D) g).setRenderingHint(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);
}
+ Rectangle viewRect = scrollpane.getVisibleRect();
+
if (!isTileImagesLoaded()) {
+ MetalTheme theme = new DefaultMetalTheme();
+ g.setColor(theme.getControl());
+ g.fillRect(-getX(), -getY(), (int) viewRect.getWidth(),
+ (int) viewRect.getHeight());
+ g.setColor(theme.getControlTextColor());
g.drawString(Messages.getString("BoardView1.loadingImages"), 20, 50);
if (!tileManager.isStarted()) {
LogManager.getLogger().info("Loading images for board");
@@ -1040,7 +1051,6 @@ public synchronized void paintComponent(Graphics g) {
return;
}
- Rectangle viewRect = scrollpane.getVisibleRect();
if (bvBgShouldTile && (bvBgImage != null)) {
Rectangle clipping = g.getClipBounds();
int x = 0;
@@ -1100,12 +1110,12 @@ public synchronized void paintComponent(Graphics g) {
drawHexes(g, g.getClipBounds());
// draw wrecks
- if (guip.getShowWrecks() && !useIsometric()) {
+ if (GUIP.getShowWrecks() && !useIsometric()) {
drawSprites(g, wreckSprites);
}
// Field of Fire
- if (!useIsometric() && GUIPreferences.getInstance().getShowFieldOfFire()) {
+ if (!useIsometric() && GUIP.getShowFieldOfFire()) {
drawSprites(g, fieldofFireSprites);
}
@@ -1215,7 +1225,7 @@ public synchronized void paintComponent(Graphics g) {
disp.draw(g, displayablesRect);
}
- if (guip.getBoolean(GUIPreferences.ADVANCED_SHOW_FPS)) {
+ if (GUIP.getBoolean(GUIPreferences.ADVANCED_SHOW_FPS)) {
if (frameCount == FRAMES) {
averageTime = totalTime / FRAMES;
totalTime = 0;
@@ -1396,7 +1406,7 @@ private void updateShadowMap() {
// this seems to need a lot of additional copying (paint shadow on a clean map for this level alone; soften up; copy to real shadow
// map with clipping area active; get new clean shadow map for next shadowed level;
// too much hassle currently; it works so beautifully
- if (!GUIPreferences.getInstance().getShadowMap()) {
+ if (!GUIP.getShadowMap()) {
return;
}
@@ -1536,7 +1546,7 @@ private void updateShadowMap() {
Transparency.TRANSLUCENT);
Graphics gS = elevShadow.getGraphics();
Point2D p1 = new Point2D.Double(eSize.width / 2, eSize.height / 2);
- if (GUIPreferences.getInstance().getHexInclines()) {
+ if (GUIP.getHexInclines()) {
// With inclines, the level 1 shadows are only very slight
int beg = 4;
p1.setLocation(p1.getX() + deltaX * beg, p1.getY() + deltaY * beg);
@@ -1891,7 +1901,7 @@ private void drawHexLayer(Point p, Graphics g, Color col, boolean outOfFOV,
// create stripe effect for FOV darkening but not for colored weapon
// ranges
- int fogStripes = GUIPreferences.getInstance().getFovStripes();
+ int fogStripes = GUIP.getFovStripes();
if (outOfFOV && (fogStripes > 0) && (g instanceof Graphics2D)) {
float lineSpacing = fogStripes;
// totally transparent here hurts the eyes
@@ -2150,7 +2160,7 @@ public BufferedImage getEntireBoardImage(boolean ignoreUnits, boolean useBaseZoo
Image entireBoard = createImage(boardSize.width, boardSize.height);
Graphics2D boardGraph = (Graphics2D) entireBoard.getGraphics();
boardGraph.setClip(0, 0, boardSize.width, boardSize.height);
- if (GUIPreferences.getInstance().getAntiAliasing()) {
+ if (GUIP.getAntiAliasing()) {
boardGraph.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
}
@@ -2164,12 +2174,12 @@ public BufferedImage getEntireBoardImage(boolean ignoreUnits, boolean useBaseZoo
// If we aren't ignoring units, draw everything else
if (!ignoreUnits) {
// draw wrecks
- if (GUIPreferences.getInstance().getShowWrecks() && !useIsometric()) {
+ if (GUIP.getShowWrecks() && !useIsometric()) {
drawSprites(boardGraph, wreckSprites);
}
// Field of Fire
- if (!useIsometric() && GUIPreferences.getInstance().getShowFieldOfFire()) {
+ if (!useIsometric() && GUIP.getShowFieldOfFire()) {
drawSprites(boardGraph, fieldofFireSprites);
}
@@ -2288,8 +2298,7 @@ private void drawHexes(Graphics g, Rectangle view, boolean saveBoardImage) {
if ((hex != null)) {
drawHex(c, g, saveBoardImage);
drawOrthograph(c, g);
- if (GUIPreferences.getInstance()
- .getShowFieldOfFire()) {
+ if (GUIP.getShowFieldOfFire()) {
drawHexSpritesForHex(c, g, fieldofFireSprites);
}
drawHexSpritesForHex(c, g, moveEnvSprites);
@@ -2308,7 +2317,7 @@ private void drawHexes(Graphics g, Rectangle view, boolean saveBoardImage) {
Hex hex = board.getHex(c);
if (hex != null) {
if (!saveBoardImage) {
- if (GUIPreferences.getInstance().getShowWrecks()) {
+ if (GUIP.getShowWrecks()) {
drawIsometricWreckSpritesForHex(c, g, isometricWreckSprites);
}
drawIsometricSpritesForHex(c, g, isometricSprites);
@@ -2342,7 +2351,6 @@ private void drawHex(Coords c, Graphics boardGraph, boolean saveBoardImage) {
return;
}
- final GUIPreferences guip = GUIPreferences.getInstance();
final Hex hex = game.getBoard().getHex(c);
final Point hexLoc = getHexLocation(c);
@@ -2491,7 +2499,7 @@ private void drawHex(Coords c, Graphics boardGraph, boolean saveBoardImage) {
}
// Add the terrain & building shadows
- if (guip.getBoolean(GUIPreferences.SHADOWMAP) && (shadowMap != null)) {
+ if (GUIP.getBoolean(GUIPreferences.SHADOWMAP) && (shadowMap != null)) {
Point p1SRC = getHexLocationLargeTile(c.getX(), c.getY(), 1);
Point p2SRC = new Point(p1SRC.x + HEX_W, p1SRC.y + HEX_H);
Point p2DST = new Point(hex_size.width, hex_size.height);
@@ -2531,7 +2539,7 @@ private void drawHex(Coords c, Graphics boardGraph, boolean saveBoardImage) {
}
// AO Hex Shadow in this hex when a higher one is adjacent
- if (guip.getBoolean(GUIPreferences.AOHEXSHADOWS)) {
+ if (GUIP.getBoolean(GUIPreferences.AOHEXSHADOWS)) {
for (int dir : allDirections) {
Shape ShadowShape = getElevationShadowArea(c, dir);
GradientPaint gpl = getElevationShadowGP(c, dir);
@@ -2600,7 +2608,7 @@ private void drawHex(Coords c, Graphics boardGraph, boolean saveBoardImage) {
}
// Darken the hex for nighttime, if applicable
- if (guip.getBoolean(GUIPreferences.ADVANCED_DARKEN_MAP_AT_NIGHT)
+ if (GUIP.getBoolean(GUIPreferences.ADVANCED_DARKEN_MAP_AT_NIGHT)
&& IlluminationLevel.determineIlluminationLevel(game, c).isNone()
&& (game.getPlanetaryConditions().getLight() > PlanetaryConditions.L_DAY)) {
for (int x = 0; x < hexImage.getWidth(); ++x) {
@@ -2611,7 +2619,7 @@ private void drawHex(Coords c, Graphics boardGraph, boolean saveBoardImage) {
}
// Set the text color according to Preferences or Light Gray in space
- g.setColor(guip.getMapTextColor());
+ g.setColor(GUIP.getMapTextColor());
if (game.getBoard().inSpace()) {
g.setColor(Color.LIGHT_GRAY);
}
@@ -2634,7 +2642,7 @@ private void drawHex(Coords c, Graphics boardGraph, boolean saveBoardImage) {
}
// write hex coordinate unless deactivated or scale factor too small
- if (guip.getBoolean(GUIPreferences.SHOW_COORDS) && (scale >= 0.5)) {
+ if (GUIP.getCoordsEnabled() && (scale >= 0.5)) {
drawCenteredString(c.getBoardNum(), 0, (int) (12 * scale), font_hexnum, g);
}
@@ -2658,13 +2666,13 @@ private void drawHex(Coords c, Graphics boardGraph, boolean saveBoardImage) {
ypos -= 10;
}
if (height > 0) {
- g.setColor(GUIPreferences.getInstance().getColor("AdvancedBuildingTextColor"));
+ g.setColor(GUIP.getColor("AdvancedBuildingTextColor"));
drawCenteredString(Messages.getString("BoardView1.HEIGHT") + height,
0, (int) (ypos * scale), font_elev, g);
ypos -= 10;
}
if (hex.terrainLevel(Terrains.FOLIAGE_ELEV) == 1) {
- g.setColor(GUIPreferences.getInstance().getColor(
+ g.setColor(GUIP.getColor(
GUIPreferences.ADVANCED_LOW_FOLIAGE_COLOR));
drawCenteredString(Messages.getString("BoardView1.LowFoliage"),
0, (int) (ypos * scale), font_elev, g);
@@ -2695,42 +2703,42 @@ private void drawHex(Coords c, Graphics boardGraph, boolean saveBoardImage) {
// draw elevation borders
if (drawElevationLine(c, 0)) {
drawIsometricElevation(c, Color.GRAY, p1, p2, 0, g);
- if (guip.getBoolean(GUIPreferences.LEVELHIGHLIGHT)) {
+ if (GUIP.getBoolean(GUIPreferences.LEVELHIGHLIGHT)) {
g.drawLine(s21, 0, s62, 0);
}
}
if (drawElevationLine(c, 1)) {
drawIsometricElevation(c, Color.DARK_GRAY, p3, p1, 1, g);
- if (guip.getBoolean(GUIPreferences.LEVELHIGHLIGHT)) {
+ if (GUIP.getBoolean(GUIPreferences.LEVELHIGHLIGHT)) {
g.drawLine(s62, 0, s83, s35);
}
}
if (drawElevationLine(c, 2)) {
drawIsometricElevation(c, Color.LIGHT_GRAY, p4, p5, 2, g);
- if (guip.getBoolean(GUIPreferences.LEVELHIGHLIGHT)) {
+ if (GUIP.getBoolean(GUIPreferences.LEVELHIGHLIGHT)) {
g.drawLine(s83, s36, s62, s71);
}
}
if (drawElevationLine(c, 3)) {
drawIsometricElevation(c, Color.GRAY, p6, p5, 3, g);
- if (guip.getBoolean(GUIPreferences.LEVELHIGHLIGHT)) {
+ if (GUIP.getBoolean(GUIPreferences.LEVELHIGHLIGHT)) {
g.drawLine(s62, s71, s21, s71);
}
}
if (drawElevationLine(c, 4)) {
drawIsometricElevation(c, Color.DARK_GRAY, p7, p6, 4, g);
- if (guip.getBoolean(GUIPreferences.LEVELHIGHLIGHT)) {
+ if (GUIP.getBoolean(GUIPreferences.LEVELHIGHLIGHT)) {
g.drawLine(s21, s71, 0, s36);
}
}
if (drawElevationLine(c, 5)) {
drawIsometricElevation(c, Color.LIGHT_GRAY, p8, p2, 5, g);
- if (guip.getBoolean(GUIPreferences.LEVELHIGHLIGHT)) {
+ if (GUIP.getBoolean(GUIPreferences.LEVELHIGHLIGHT)) {
g.drawLine(0, s35, s21, 0);
}
@@ -2739,8 +2747,8 @@ private void drawHex(Coords c, Graphics boardGraph, boolean saveBoardImage) {
boolean hasLoS = fovHighlightingAndDarkening.draw(g, c, 0, 0, saveBoardImage);
// draw mapsheet borders
- if (GUIPreferences.getInstance().getShowMapsheets()) {
- g.setColor(GUIPreferences.getInstance().getColor(GUIPreferences.ADVANCED_MAPSHEET_COLOR));
+ if (GUIP.getShowMapsheets()) {
+ g.setColor(GUIP.getColor(GUIPreferences.ADVANCED_MAPSHEET_COLOR));
if ((c.getX() % 16) == 0) {
// left edge of sheet (edge 4 & 5)
g.drawLine(s21, s71, 0, s36);
@@ -2768,7 +2776,7 @@ private void drawHex(Coords c, Graphics boardGraph, boolean saveBoardImage) {
}
}
- if (!hasLoS && guip.getFovGrayscale()) {
+ if (!hasLoS && GUIP.getFovGrayscale()) {
// rework the pixels to grayscale
for (int x = 0; x < hexImage.getWidth(); x++) {
for (int y = 0; y < hexImage.getHeight(); y++) {
@@ -2816,7 +2824,7 @@ private void drawOrthograph(Coords c, Graphics boardGraph) {
BufferedImage scaledImage = ImageUtil.createAcceleratedImage(getScaledImage(image, true));
// Darken the hex for nighttime, if applicable
- if (GUIPreferences.getInstance().getBoolean(GUIPreferences.ADVANCED_DARKEN_MAP_AT_NIGHT)
+ if (GUIP.getBoolean(GUIPreferences.ADVANCED_DARKEN_MAP_AT_NIGHT)
&& IlluminationLevel.determineIlluminationLevel(game, c).isNone()
&& (game.getPlanetaryConditions().getLight() > PlanetaryConditions.L_DAY)) {
for (int x = 0; x < scaledImage.getWidth(null); ++x) {
@@ -2864,7 +2872,7 @@ private final void drawIsometricElevation(Coords c, Color color, Point p1, Point
final Hex dest = game.getBoard().getHexInDir(c, dir);
final Hex src = game.getBoard().getHex(c);
- if (!useIsometric() || GUIPreferences.getInstance().getBoolean(GUIPreferences.FLOATINGISO)) {
+ if (!useIsometric() || GUIP.getBoolean(GUIPreferences.FLOATINGISO)) {
return;
}
@@ -3025,7 +3033,7 @@ public int getNightDarkenedColor(int rgb) {
// no shadow area when the current hex is not lower than the next hex in direction
if (srcHex.getLevel() >= destHex.getLevel()) {
return null;
- } else if (GUIPreferences.getInstance().getHexInclines()
+ } else if (GUIP.getHexInclines()
&& (destHex.getLevel() - srcHex.getLevel() < 2)
&& !destHex.hasCliffTopTowards(srcHex)) {
return null;
@@ -3580,7 +3588,7 @@ public void centerOnHex(@Nullable Coords c) {
return;
}
- if (GUIPreferences.getInstance().getBoolean("SOFTCENTER")) {
+ if (GUIP.getBoolean("SOFTCENTER")) {
// Soft Centering:
// set the target point
Point p = getCentreHexLocation(c);
@@ -3752,20 +3760,20 @@ public void drawMovementData(Entity entity, MovePath md) {
case MOVE_RUN:
case MOVE_VTOL_RUN:
case MOVE_OVER_THRUST:
- col = GUIPreferences.getInstance().getColor("AdvancedMoveRunColor");
+ col = GUIP.getColor("AdvancedMoveRunColor");
break;
case MOVE_SPRINT:
case MOVE_VTOL_SPRINT:
- col = GUIPreferences.getInstance().getColor("AdvancedMoveSprintColor");
+ col = GUIP.getColor("AdvancedMoveSprintColor");
break;
case MOVE_JUMP:
- col = GUIPreferences.getInstance().getColor("AdvancedMoveJumpColor");
+ col = GUIP.getColor("AdvancedMoveJumpColor");
break;
case MOVE_ILLEGAL:
- col = GUIPreferences.getInstance().getColor("AdvancedMoveIllegalColor");
+ col = GUIP.getColor("AdvancedMoveIllegalColor");
break;
default:
- col = GUIPreferences.getInstance().getColor("AdvancedMoveDefaultColor");
+ col = GUIP.getColor("AdvancedMoveDefaultColor");
break;
}
movementTarget = md.getLastStep().getPosition();
@@ -3851,24 +3859,23 @@ public void setMovementEnvelope(Map mvEnvData, int walk, int ru
return;
}
- GUIPreferences guip = GUIPreferences.getInstance();
for (Coords loc : mvEnvData.keySet()) {
Color spriteColor = null;
int mvType = -1;
if (gear == MovementDisplay.GEAR_JUMP || gear == MovementDisplay.GEAR_DFA) {
if (mvEnvData.get(loc) <= jump) {
- spriteColor = guip.getColor(GUIPreferences.ADVANCED_MOVE_JUMP_COLOR);
+ spriteColor = GUIP.getColor(GUIPreferences.ADVANCED_MOVE_JUMP_COLOR);
mvType = 1;
}
} else {
if (mvEnvData.get(loc) <= walk) {
- spriteColor = guip.getColor(GUIPreferences.ADVANCED_MOVE_DEFAULT_COLOR);
+ spriteColor = GUIP.getColor(GUIPreferences.ADVANCED_MOVE_DEFAULT_COLOR);
mvType = 2;
} else if (mvEnvData.get(loc) <= run) {
- spriteColor = guip.getColor(GUIPreferences.ADVANCED_MOVE_RUN_COLOR);
+ spriteColor = GUIP.getColor(GUIPreferences.ADVANCED_MOVE_RUN_COLOR);
mvType = 3;
} else {
- spriteColor = guip.getColor(GUIPreferences.ADVANCED_MOVE_SPRINT_COLOR);
+ spriteColor = GUIP.getColor(GUIPreferences.ADVANCED_MOVE_SPRINT_COLOR);
mvType = 4;
}
}
@@ -4342,8 +4349,8 @@ protected void secondLOSHex(Coords c2, Coords c1) {
StringBuffer message = new StringBuffer();
LosEffects le;
if ((ae == null) || (te == null)) {
- boolean mechInFirst = GUIPreferences.getInstance().getMechInFirst();
- boolean mechInSecond = GUIPreferences.getInstance().getMechInSecond();
+ boolean mechInFirst = GUIP.getMechInFirst();
+ boolean mechInSecond = GUIP.getMechInSecond();
LosEffects.AttackInfo ai = new LosEffects.AttackInfo();
ai.attackPos = c1;
ai.targetPos = c2;
@@ -4487,7 +4494,7 @@ synchronized boolean doMoveUnits(long idleTime) {
if (!movingUnits.isEmpty()) {
moveWait += idleTime;
- if (moveWait > GUIPreferences.getInstance().getInt("AdvancedMoveStepDelay")) {
+ if (moveWait > GUIP.getInt("AdvancedMoveStepDelay")) {
ArrayList spent = new ArrayList<>();
for (MovingUnit move : movingUnits) {
@@ -4617,9 +4624,9 @@ public void mouseExited(MouseEvent me) {
// Reset the tooltip dismissal delay to the preference
// value so that elements outside the boardview can
// use tooltips
- if (GUIPreferences.getInstance().getTooltipDismissDelay() >= 0) {
+ if (GUIP.getTooltipDismissDelay() >= 0) {
ToolTipManager.sharedInstance().setDismissDelay(
- GUIPreferences.getInstance().getTooltipDismissDelay());
+ GUIP.getTooltipDismissDelay());
} else {
ToolTipManager.sharedInstance().setDismissDelay(dismissDelay);
}
@@ -4890,7 +4897,7 @@ public void mouseAction(Coords coords, int mtype, int modifiers, int mouseButton
@Override
public void boardNewBoard(BoardEvent b) {
updateBoard();
- game.getBoard().initializeAllAutomaticTerrain(GUIPreferences.getInstance().getHexInclines());
+ game.getBoard().initializeAllAutomaticTerrain(GUIP.getHexInclines());
clearHexImageCache();
clearShadowMap();
repaint();
@@ -4951,7 +4958,6 @@ public void gameEntityChange(GameEntityChangeEvent e) {
final Vector mp = e.getMovePath();
final Entity en = e.getEntity();
final GameOptions gopts = game.getOptions();
- GUIPreferences guip = GUIPreferences.getInstance();
updateEcmList();
@@ -4972,7 +4978,7 @@ public void gameEntityChange(GameEntityChangeEvent e) {
if (game.getPhase().isMovement()) {
refreshMoveVectors();
}
- if ((mp != null) && !mp.isEmpty() && guip.getShowMoveStep()
+ if ((mp != null) && !mp.isEmpty() && GUIP.getShowMoveStep()
&& !gopts.booleanOption(OptionsConstants.INIT_SIMULTANEOUS_MOVEMENT)) {
if ((localPlayer == null)
|| !game.getOptions().booleanOption(OptionsConstants.ADVANCED_DOUBLE_BLIND)
@@ -5029,7 +5035,7 @@ public void gameBoardNew(GameBoardNewEvent e) {
}
}
}
- game.getBoard().initializeAllAutomaticTerrain(GUIPreferences.getInstance().getHexInclines());
+ game.getBoard().initializeAllAutomaticTerrain(GUIP.getHexInclines());
clearHexImageCache();
updateBoard();
clearShadowMap();
@@ -5043,7 +5049,7 @@ public void gameBoardChanged(GameBoardChangeEvent e) {
@Override
public void gamePhaseChange(GamePhaseChangeEvent e) {
- if (GUIPreferences.getInstance().getGameSummaryBoardView()
+ if (GUIP.getGameSummaryBoardView()
&& (e.getOldPhase().isDeployment() || e.getOldPhase().isMovement()
|| e.getOldPhase().isTargeting() || e.getOldPhase().isFiring()
|| e.getOldPhase().isPhysical())) {
@@ -5451,7 +5457,7 @@ public String getHexTooltip(MouseEvent e) {
StringBuffer txt = new StringBuffer(HTML_BEGIN);
// Hex Terrain
- if (GUIPreferences.getInstance().getShowMapHexPopup() && (mhex != null)) {
+ if (GUIP.getShowMapHexPopup() && (mhex != null)) {
appendTerrainTooltip(txt, mhex);
// Distance from the selected unit and a planned movement end point
@@ -5687,9 +5693,9 @@ public String getHexTooltip(MouseEvent e) {
// Now that a valid tooltip text seems to be present,
// (re)set the tooltip dismissal delay time to the preference
// value so that the tooltip actually appears
- if (GUIPreferences.getInstance().getTooltipDismissDelay() >= 0) {
+ if (GUIP.getTooltipDismissDelay() >= 0) {
ToolTipManager.sharedInstance().setDismissDelay(
- GUIPreferences.getInstance().getTooltipDismissDelay());
+ GUIP.getTooltipDismissDelay());
} else {
ToolTipManager.sharedInstance().setDismissDelay(dismissDelay);
}
@@ -6041,7 +6047,7 @@ private void zoom() {
checkZoomIndex();
stopSoftCentering();
scale = ZOOM_FACTORS[zoomIndex];
- GUIPreferences.getInstance().setMapZoomIndex(zoomIndex);
+ GUIP.setMapZoomIndex(zoomIndex);
hex_size = new Dimension((int) (HEX_W * scale), (int) (HEX_H * scale));
@@ -6233,7 +6239,7 @@ public void die() {
ourTask.cancel();
fovHighlightingAndDarkening.die();
KeyBindParser.removePreferenceChangeListener(this);
- GUIPreferences.getInstance().removePreferenceChangeListener(this);
+ GUIP.removePreferenceChangeListener(this);
PreferenceManager.getClientPreferences().removePreferenceChangeListener(this);
}
@@ -6287,8 +6293,8 @@ public void clearHexImageCache(Set coords) {
* Check to see if the HexImageCache should be cleared because of field-of-view changes.
*/
public void checkFoVHexImageCacheClear() {
- boolean darken = GUIPreferences.getInstance().getBoolean(GUIPreferences.FOV_DARKEN);
- boolean highlight = GUIPreferences.getInstance().getBoolean(GUIPreferences.FOV_HIGHLIGHT);
+ boolean darken = GUIP.getBoolean(GUIPreferences.FOV_DARKEN);
+ boolean highlight = GUIP.getBoolean(GUIPreferences.FOV_HIGHLIGHT);
if (game.getPhase().isMovement() && (darken || highlight)) {
clearHexImageCache();
}
diff --git a/megamek/src/megamek/client/ui/swing/boardview/PlanetaryConditionsOverlay.java b/megamek/src/megamek/client/ui/swing/boardview/PlanetaryConditionsOverlay.java
index 747a3abc4d6..52f90bd920b 100644
--- a/megamek/src/megamek/client/ui/swing/boardview/PlanetaryConditionsOverlay.java
+++ b/megamek/src/megamek/client/ui/swing/boardview/PlanetaryConditionsOverlay.java
@@ -153,7 +153,7 @@ public void draw(Graphics graph, Rectangle clipBounds) {
}
}
- distSide = clientGui.getWidth() - (overlayWidth + 100);
+ distSide = clipBounds.width - (overlayWidth + 100);
// draw the cached image to the boardview
// uses Composite to draw the image with variable transparency
diff --git a/megamek/src/megamek/client/ui/swing/lobby/ChatLounge.java b/megamek/src/megamek/client/ui/swing/lobby/ChatLounge.java
index d488719e034..fcc4d3dc5af 100644
--- a/megamek/src/megamek/client/ui/swing/lobby/ChatLounge.java
+++ b/megamek/src/megamek/client/ui/swing/lobby/ChatLounge.java
@@ -84,6 +84,7 @@
import java.awt.image.ImageFilter;
import java.awt.image.ImageProducer;
import java.io.*;
+import java.text.MessageFormat;
import java.text.NumberFormat;
import java.util.List;
import java.util.*;
@@ -110,7 +111,7 @@ public class ChatLounge extends AbstractPhaseDisplay implements
static final int MEKTREE_ROWHEIGHT_FULL = 40;
private final static int TEAMOVERVIEW_BORDER = 45;
private final static int MAP_POPUP_OFFSET = -2; // a slight offset so cursor sits inside popup
-
+
private JTabbedPane panTabs = new JTabbedPane();
private JPanel panUnits = new JPanel();
private JPanel panMap = new JPanel();
@@ -345,6 +346,8 @@ public class ChatLounge extends AbstractPhaseDisplay implements
private static final String MSG_VIEWGAMEBOARD = Messages.getString("BoardSelectionDialog.ViewGameBoard");
private static final String MSG_FIGHTERSQUADRONBOMBERROR = Messages.getString("FighterSquadron.bomberror");
+ private static final String MSG_MAPSETUPXMLFILES = Messages.getString("ChatLounge.map.SetupXMLfiles");
+
/** Creates a new chat lounge for the clientgui.getClient(). */
public ChatLounge(ClientGUI clientgui) {
super(clientgui, SkinSpecification.UIComponents.ChatLounge.getComp(),
@@ -2077,7 +2080,7 @@ private void saveMapSetup() {
selectedFile = new File(selectedFile.getPath() + CL_KEY_FILEEXTENTION_XML);
}
if (selectedFile.exists()) {
- String msg = Messages.getFormattedString(MSG_MAPSAVESETUPREPLACE, selectedFile.getName());
+ String msg = MessageFormat.format(MSG_MAPSAVESETUPREPLACE, selectedFile.getName());
if (!MMConfirmDialog.confirm(clientgui.frame, MSG_MAPCONFIRMREPLACE, msg)) {
return;
}
@@ -2154,7 +2157,7 @@ public boolean accept(File f) {
@Override
public String getDescription() {
- return "Map Setup XML files";
+ return MSG_MAPSETUPXMLFILES;
}
};
diff --git a/megamek/src/megamek/client/ui/swing/minimap/Minimap.java b/megamek/src/megamek/client/ui/swing/minimap/Minimap.java
index 59bdb212b50..cd89192d035 100644
--- a/megamek/src/megamek/client/ui/swing/minimap/Minimap.java
+++ b/megamek/src/megamek/client/ui/swing/minimap/Minimap.java
@@ -162,7 +162,7 @@ public void windowClosing(WindowEvent e) {
GUIP.setMinimapEnabled(false);
}
});
-
+
result.add(new Minimap(result, game, bv, cg));
result.pack();
return result;
@@ -510,7 +510,7 @@ private synchronized void drawMap(boolean forceDraw) {
addRoadElements(h, j, k);
// Color invalid hexes red when in the Map Editor
if ((game != null) && game.getPhase().isUnknown() && !h.isValid(null)) {
- gg.setColor(GUIPreferences.getInstance().getWarningColor());
+ gg.setColor(GUIP.getWarningColor());
paintCoord(gg, j, k, true);
}
}
@@ -1342,11 +1342,12 @@ public void boardChangedHex(BoardEvent b) {
private final GameListener gameListener = new GameListenerAdapter() {
@Override
public void gamePhaseChange(GamePhaseChangeEvent e) {
- if (GUIPreferences.getInstance().getGameSummaryMinimap()
+ if (GUIP.getGameSummaryMinimap()
&& (e.getOldPhase().isDeployment() || e.getOldPhase().isMovement()
|| e.getOldPhase().isTargeting() || e.getOldPhase().isPremovement()
|| e.getOldPhase().isPrefiring() || e.getOldPhase().isFiring()
|| e.getOldPhase().isPhysical())) {
+
File dir = new File(Configuration.gameSummaryImagesMMDir(), game.getUUIDString());
if (!dir.exists()) {
dir.mkdirs();
diff --git a/megamek/src/megamek/client/ui/swing/skinEditor/SkinEditorMainGUI.java b/megamek/src/megamek/client/ui/swing/skinEditor/SkinEditorMainGUI.java
index eb33a4898c8..80e55ac29a3 100644
--- a/megamek/src/megamek/client/ui/swing/skinEditor/SkinEditorMainGUI.java
+++ b/megamek/src/megamek/client/ui/swing/skinEditor/SkinEditorMainGUI.java
@@ -409,16 +409,6 @@ public void switchPanel(GamePhase phase) {
// Handle phase-specific items.
switch (phase) {
case LOUNGE:
- // reset old report tabs and images, if any
- ReportDisplay rD = (ReportDisplay) phaseComponents.get(String
- .valueOf(GamePhase.INITIATIVE_REPORT));
- if (rD != null) {
- rD.resetTabs();
- }
- //ChatLounge cl = (ChatLounge) phaseComponents.get(
- // String.valueOf(Game.Phase.LOUNGE));
- // cb.setDoneButton(cl.butDone);
- // cl.add(cb.getComponent(), BorderLayout.SOUTH);
getBoardView().getTilesetManager().reset();
break;
case DEPLOY_MINEFIELDS:
@@ -437,11 +427,6 @@ public void switchPanel(GamePhase phase) {
case PHYSICAL_REPORT:
case END_REPORT:
case VICTORY:
- rD = (ReportDisplay) phaseComponents.get(String
- .valueOf(GamePhase.INITIATIVE_REPORT));
- // cb.setDoneButton(rD.butDone);
- //rD.add(cb.getComponent(), GBC.eol().fill(
- // GridBagConstraints.HORIZONTAL));
break;
default:
break;
@@ -674,7 +659,7 @@ public int[] doChoiceDialog(String title, String question, String[] choices) {
*/
public void doAlertDialog(String title, String message) {
JTextPane textArea = new JTextPane();
- ReportDisplay.setupStylesheet(textArea);
+ Report.setupStylesheet(textArea);
textArea.setEditable(false);
JScrollPane scrollPane = new JScrollPane(textArea,
diff --git a/megamek/src/megamek/client/ui/swing/unitDisplay/UnitDisplay.java b/megamek/src/megamek/client/ui/swing/unitDisplay/UnitDisplay.java
index e2f53fb5c73..33b95904d8a 100644
--- a/megamek/src/megamek/client/ui/swing/unitDisplay/UnitDisplay.java
+++ b/megamek/src/megamek/client/ui/swing/unitDisplay/UnitDisplay.java
@@ -16,15 +16,20 @@
import megamek.client.event.MechDisplayEvent;
import megamek.client.event.MechDisplayListener;
+import megamek.client.ui.Messages;
+import megamek.client.ui.dialogs.UnitDisplayDialog;
import megamek.client.ui.swing.ClientGUI;
import megamek.client.ui.swing.GUIPreferences;
import megamek.client.ui.swing.UnitDisplayOrderPreferences;
import megamek.client.ui.swing.util.CommandAction;
import megamek.client.ui.swing.util.KeyCommandBind;
import megamek.client.ui.swing.util.MegaMekController;
+import megamek.client.ui.swing.util.UIUtil;
import megamek.client.ui.swing.widget.MechPanelTabStrip;
import megamek.common.Entity;
import megamek.common.annotations.Nullable;
+import megamek.common.preference.IPreferenceChangeListener;
+import megamek.common.preference.PreferenceChangeEvent;
import org.apache.logging.log4j.LogManager;
import javax.swing.*;
@@ -38,10 +43,11 @@
* Displays the info for a mech. This is also a sort of interface for special
* movement and firing actions.
*/
-public class UnitDisplay extends JPanel {
+public class UnitDisplay extends JPanel implements IPreferenceChangeListener {
// buttons & gizmos for top level
private static final long serialVersionUID = -2060993542227677984L;
private JButton butSwitchView;
+ private JButton butSwitchLocation;
private JPanel panA1;
private JPanel panA2;
private JPanel panB1;
@@ -63,6 +69,7 @@ public class UnitDisplay extends JPanel {
private ExtraPanel ePan;
private ClientGUI clientgui;
private Entity currentlyDisplaying;
+ private JLabel labTitle;
private ArrayList eventListeners = new ArrayList<>();
public static final String NON_TABBED_GENERAL = "General";
@@ -86,6 +93,12 @@ public class UnitDisplay extends JPanel {
public static final int NON_TABBED_FOUR_INDEX = 4;
public static final int NON_TABBED_FIVE_INDEX = 5;
+ private static final String MSG_SWITCHLOCATION = Messages.getString("UnitDisplay.SwitchLocation");
+ private static final String MSG_SWITCHVIEW = Messages.getString("UnitDisplay.SwitchView");
+
+ private static final GUIPreferences GUIP = GUIPreferences.getInstance();
+ private static final UnitDisplayOrderPreferences UDOP = UnitDisplayOrderPreferences.getInstance();
+
/**
* Creates and lays out a new mech display.
*
@@ -103,6 +116,8 @@ public UnitDisplay(@Nullable ClientGUI clientgui,
super(new GridBagLayout());
this.clientgui = clientgui;
+ labTitle = new JLabel("Title");
+
tabStrip = new MechPanelTabStrip(this);
displayP = new JPanel(new CardLayout());
mPan = new SummaryPanel(this);
@@ -120,6 +135,9 @@ public UnitDisplay(@Nullable ClientGUI clientgui,
c.weighty = 0.0;
c.gridwidth = GridBagConstraints.REMAINDER;
+ ((GridBagLayout) getLayout()).setConstraints(labTitle, c);
+ add(labTitle);
+
((GridBagLayout) getLayout()).setConstraints(tabStrip, c);
add(tabStrip);
@@ -144,7 +162,8 @@ public UnitDisplay(@Nullable ClientGUI clientgui,
splitA1 = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
splitB1 = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
splitC1 = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
- butSwitchView = new JButton("switch view");
+ butSwitchView = new JButton(MSG_SWITCHVIEW);
+ butSwitchLocation = new JButton(MSG_SWITCHLOCATION);
splitABC.setOneTouchExpandable(true);
splitBC.setOneTouchExpandable(true);
@@ -173,55 +192,71 @@ public UnitDisplay(@Nullable ClientGUI clientgui,
splitABC.setLeftComponent(splitA1);
splitABC.setRightComponent(splitBC);
- splitABC.setDividerLocation(GUIPreferences.getInstance().getDisplaySplitABCLoc());
- splitBC.setDividerLocation(GUIPreferences.getInstance().getDisplaySplitBCLoc());
- splitA1.setDividerLocation(GUIPreferences.getInstance().getDisplaySplitA1Loc());
- splitB1.setDividerLocation(GUIPreferences.getInstance().getDisplaySplitB1Loc());
- splitC1.setDividerLocation(GUIPreferences.getInstance().getDisplaySplitC1Loc());
-
- butSwitchView.setPreferredSize(new Dimension(500,20));
+ splitABC.setDividerLocation(GUIP.getUnitDisplaySplitABCLoc());
+ splitBC.setDividerLocation(GUIP.getUnitDisplaySplitBCLoc());
+ splitA1.setDividerLocation(GUIP.getUnitDisplaySplitA1Loc());
+ splitB1.setDividerLocation(GUIP.getUnitDisplaySplitB1Loc());
+ splitC1.setDividerLocation(GUIP.getUnitDisplaySplitC1Loc());
c.fill = GridBagConstraints.BOTH;
c.insets = new Insets(0, 1, 1, 1);
c.weightx = 1.0;
c.weighty = 0.0;
- c.gridwidth = GridBagConstraints.REMAINDER;
+ c.gridwidth = 1;
+ c.anchor = GridBagConstraints.WEST;
((GridBagLayout) getLayout()).setConstraints(butSwitchView, c);
add(butSwitchView);
+ c.weightx = 1.0;
+ c.anchor = GridBagConstraints.EAST;
+ c.gridwidth = GridBagConstraints.REMAINDER;
+ ((GridBagLayout) getLayout()).setConstraints(butSwitchLocation, c);
+ add(butSwitchLocation);
+
butSwitchView.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
if (clientgui != null) {
- if (!(GUIPreferences.getInstance().getDisplayStartTabbed())) {
+ UnitDisplayDialog unitDisplayDialog = clientgui.getUnitDisplayDialog();
+ if (!(GUIP.getUnitDisplayStartTabbed())) {
saveSplitterLoc();
- GUIPreferences.getInstance().setDisplayNontabbedPosX(clientgui.unitDisplay.getRootPane().getParent().getLocation().x);
- GUIPreferences.getInstance().setDisplayNontabbedPosY(clientgui.unitDisplay.getRootPane().getParent().getLocation().y);
- GUIPreferences.getInstance().setDisplayNonTabbedSizeWidth(clientgui.unitDisplay.getRootPane().getParent().getSize().width);
- GUIPreferences.getInstance().setDisplayNonTabbedSizeHeight(clientgui.unitDisplay.getRootPane().getParent().getSize().height);
- clientgui.unitDisplay.getRootPane().getParent().setLocation(GUIPreferences.getInstance().getDisplayPosX(), GUIPreferences.getInstance().getDisplayPosY());
- clientgui.unitDisplay.getRootPane().getParent().setSize(GUIPreferences.getInstance().getDisplaySizeWidth(), GUIPreferences.getInstance().getDisplaySizeHeight());
+ GUIP.setUnitDisplayNontabbedPosX(unitDisplayDialog.getLocation().x);
+ GUIP.setUnitDisplayNontabbedPosY(unitDisplayDialog.getLocation().y);
+ GUIP.setUnitDisplayNonTabbedSizeWidth(unitDisplayDialog.getSize().width);
+ GUIP.setUnitDisplayNonTabbedSizeHeight(unitDisplayDialog.getSize().height);
+ unitDisplayDialog.setLocation(GUIP.getUnitDisplayPosX(), GUIP.getUnitDisplayPosY());
+ unitDisplayDialog.setSize(GUIP.getUnitDisplaySizeWidth(), GUIP.getUnitDisplaySizeHeight());
setDisplayTabbed();
} else {
- GUIPreferences.getInstance().setDisplayPosX(clientgui.unitDisplay.getRootPane().getParent().getLocation().x);
- GUIPreferences.getInstance().setDisplayPosY(clientgui.unitDisplay.getRootPane().getParent().getLocation().y);
- GUIPreferences.getInstance().setDisplaySizeWidth(clientgui.unitDisplay.getRootPane().getParent().getSize().width);
- GUIPreferences.getInstance().setDisplaySizeHeight(clientgui.unitDisplay.getRootPane().getParent().getSize().height);
- clientgui.unitDisplay.getRootPane().getParent().setLocation(GUIPreferences.getInstance().getDisplayNontabbedPosX(), GUIPreferences.getInstance().getDisplayNontabbedPosY());
- clientgui.unitDisplay.getRootPane().getParent().setSize(GUIPreferences.getInstance().getDisplayNonTabbedSizeWidth(), GUIPreferences.getInstance().getDisplayNonTabbedSizeHeight());
+ GUIP.setUnitDisplayPosX(unitDisplayDialog.getLocation().x);
+ GUIP.setUnitDisplayPosY(unitDisplayDialog.getLocation().y);
+ GUIP.setUnitDisplaySizeWidth(unitDisplayDialog.getSize().width);
+ GUIP.setUnitDisplaySizeHeight(unitDisplayDialog.getSize().height);
+ unitDisplayDialog.setLocation(GUIP.getUnitDisplayNontabbedPosX(), GUIP.getUnitDisplayNontabbedPosY());
+ unitDisplayDialog.setSize(GUIP.getUnitDisplayNonTabbedSizeWidth(), GUIP.getUnitDisplayNonTabbedSizeHeight());
setDisplayNonTabbed();
}
}
}
});
- if (GUIPreferences.getInstance().getDisplayStartTabbed()) {
+ butSwitchLocation.addActionListener(new ActionListener() {
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ GUIP.toggleUnitDisplayLocation();
+ }
+ });
+
+ if (GUIP.getUnitDisplayStartTabbed()) {
setDisplayTabbed();
}
else {
setDisplayNonTabbed();
}
+
+ adaptToGUIScale();
+ GUIP.addPreferenceChangeListener(this);
}
/**
@@ -229,7 +264,6 @@ public void actionPerformed(ActionEvent e) {
*
*/
private void setDisplayTabbed() {
-
tabStrip.setVisible(true);
displayP.removeAll();
@@ -252,7 +286,7 @@ private void setDisplayTabbed() {
displayP.revalidate();
displayP.repaint();
- GUIPreferences.getInstance().setDisplayStartTabbed(true);
+ GUIP.setUnitDisplayStartTabbed(true);
}
/**
@@ -277,19 +311,19 @@ public void setDisplayNonTabbed() {
sPan.setVisible(true);
ePan.setVisible(true);
- linkParentChild(UnitDisplay.NON_TABBED_A1, UnitDisplayOrderPreferences.getInstance().getString(UnitDisplay.NON_TABBED_A1));
- linkParentChild(UnitDisplay.NON_TABBED_B1, UnitDisplayOrderPreferences.getInstance().getString(UnitDisplay.NON_TABBED_B1));
- linkParentChild(UnitDisplay.NON_TABBED_C1, UnitDisplayOrderPreferences.getInstance().getString(UnitDisplay.NON_TABBED_C1));
- linkParentChild(UnitDisplay.NON_TABBED_A2, UnitDisplayOrderPreferences.getInstance().getString(UnitDisplay.NON_TABBED_A2));
- linkParentChild(UnitDisplay.NON_TABBED_B2, UnitDisplayOrderPreferences.getInstance().getString(UnitDisplay.NON_TABBED_B2));
- linkParentChild(UnitDisplay.NON_TABBED_C2, UnitDisplayOrderPreferences.getInstance().getString(UnitDisplay.NON_TABBED_C2));
+ linkParentChild(UnitDisplay.NON_TABBED_A1, UDOP.getString(UnitDisplay.NON_TABBED_A1));
+ linkParentChild(UnitDisplay.NON_TABBED_B1, UDOP.getString(UnitDisplay.NON_TABBED_B1));
+ linkParentChild(UnitDisplay.NON_TABBED_C1, UDOP.getString(UnitDisplay.NON_TABBED_C1));
+ linkParentChild(UnitDisplay.NON_TABBED_A2, UDOP.getString(UnitDisplay.NON_TABBED_A2));
+ linkParentChild(UnitDisplay.NON_TABBED_B2, UDOP.getString(UnitDisplay.NON_TABBED_B2));
+ linkParentChild(UnitDisplay.NON_TABBED_C2, UDOP.getString(UnitDisplay.NON_TABBED_C2));
displayP.add(splitABC);
displayP.revalidate();
displayP.repaint();
- GUIPreferences.getInstance().setDisplayStartTabbed(false);
+ GUIP.setUnitDisplayStartTabbed(false);
}
/**
@@ -297,11 +331,11 @@ public void setDisplayNonTabbed() {
*
*/
public void saveSplitterLoc() {
- GUIPreferences.getInstance().setDisplaySplitABCLoc(splitABC.getDividerLocation());
- GUIPreferences.getInstance().setDisplaySplitBCLoc(splitBC.getDividerLocation());
- GUIPreferences.getInstance().setDisplaySplitA1Loc(splitA1.getDividerLocation());
- GUIPreferences.getInstance().setDisplaySplitB1Loc(splitB1.getDividerLocation());
- GUIPreferences.getInstance().setDisplaySplitC2Loc(splitC1.getDividerLocation());
+ GUIP.setUnitDisplaySplitABCLoc(splitABC.getDividerLocation());
+ GUIP.setUnitDisplaySplitBCLoc(splitBC.getDividerLocation());
+ GUIP.setUnitDisplaySplitA1Loc(splitA1.getDividerLocation());
+ GUIP.setUnitDisplaySplitB1Loc(splitB1.getDividerLocation());
+ GUIP.setUnitDisplaySplitC2Loc(splitC1.getDividerLocation());
}
/**
@@ -358,6 +392,10 @@ private void addChildPanel(JPanel p, String v) {
}
}
+ public void setTitleVisible(boolean b) {
+ labTitle.setVisible(b);
+ }
+
/**
* Register the keyboard commands that the UnitDisplay should process
*
@@ -381,7 +419,7 @@ public boolean shouldPerformAction() {
@Override
public void performAction() {
- if (GUIPreferences.getInstance().getDisplayStartTabbed()) {
+ if (GUIP.getUnitDisplayStartTabbed()) {
((CardLayout) displayP.getLayout()).show(displayP, MechPanelTabStrip.SUMMARY);
}
@@ -405,7 +443,7 @@ public boolean shouldPerformAction() {
@Override
public void performAction() {
- if (GUIPreferences.getInstance().getDisplayStartTabbed()) {
+ if (GUIP.getUnitDisplayStartTabbed()) {
((CardLayout) displayP.getLayout()).show(displayP, MechPanelTabStrip.PILOT);
}
@@ -429,7 +467,7 @@ public boolean shouldPerformAction() {
@Override
public void performAction() {
- if (GUIPreferences.getInstance().getDisplayStartTabbed()) {
+ if (GUIP.getUnitDisplayStartTabbed()) {
((CardLayout) displayP.getLayout()).show(displayP, MechPanelTabStrip.ARMOR);
}
@@ -453,7 +491,7 @@ public boolean shouldPerformAction() {
@Override
public void performAction() {
- if (GUIPreferences.getInstance().getDisplayStartTabbed()) {
+ if (GUIP.getUnitDisplayStartTabbed()) {
((CardLayout) displayP.getLayout()).show(displayP, MechPanelTabStrip.SYSTEMS);
}
@@ -477,7 +515,7 @@ public boolean shouldPerformAction() {
@Override
public void performAction() {
- if (GUIPreferences.getInstance().getDisplayStartTabbed()) {
+ if (GUIP.getUnitDisplayStartTabbed()) {
((CardLayout) displayP.getLayout()).show(displayP, MechPanelTabStrip.WEAPONS);
}
@@ -501,7 +539,7 @@ public boolean shouldPerformAction() {
@Override
public void performAction() {
- if (GUIPreferences.getInstance().getDisplayStartTabbed()) {
+ if (GUIP.getUnitDisplayStartTabbed()) {
((CardLayout) displayP.getLayout()).show(displayP, MechPanelTabStrip.EXTRAS);
}
@@ -547,6 +585,7 @@ public void displayEntity(Entity en) {
if (clientgui != null) {
clientgui.getUnitDisplayDialog().setTitle(enName);
+ labTitle.setText(enName);
}
currentlyDisplaying = en;
@@ -570,7 +609,7 @@ public Entity getCurrentEntity() {
* Changes to the specified panel.
*/
public void showPanel(String s) {
- if (GUIPreferences.getInstance().getDisplayStartTabbed()) {
+ if (GUIP.getUnitDisplayStartTabbed()) {
((CardLayout) displayP.getLayout()).show(displayP, s);
}
@@ -594,7 +633,7 @@ public void showPanel(String s) {
* @param loc
*/
public void showSpecificSystem(int loc) {
- if (GUIPreferences.getInstance().getDisplayStartTabbed()) {
+ if (GUIP.getUnitDisplayStartTabbed()) {
((CardLayout) displayP.getLayout()).show(displayP, MechPanelTabStrip.SYSTEMS);
}
@@ -639,4 +678,16 @@ void processMechDisplayEvent(MechDisplayEvent event) {
public ClientGUI getClientGUI() {
return clientgui;
}
-}
\ No newline at end of file
+
+ private void adaptToGUIScale() {
+ UIUtil.adjustContainer(this, UIUtil.FONT_SCALE1);
+ }
+
+ @Override
+ public void preferenceChange(PreferenceChangeEvent e) {
+ // Update the text size when the GUI scaling changes
+ if (e.getName().equals(GUIPreferences.GUI_SCALE)) {
+ adaptToGUIScale();
+ }
+ }
+}
diff --git a/megamek/src/megamek/common/Report.java b/megamek/src/megamek/common/Report.java
index d3cec3d650a..a294bc36e68 100755
--- a/megamek/src/megamek/common/Report.java
+++ b/megamek/src/megamek/common/Report.java
@@ -19,6 +19,7 @@
import org.apache.logging.log4j.LogManager;
import javax.swing.*;
+import javax.swing.text.html.HTMLEditorKit;
import javax.swing.text.html.StyleSheet;
import java.awt.*;
import java.io.Serializable;
@@ -561,6 +562,12 @@ public static void addNewline(Vector v) {
}
}
+ public static void setupStylesheet(JTextPane pane) {
+ pane.setContentType("text/html");
+ StyleSheet styleSheet = ((HTMLEditorKit) pane.getEditorKit()).getStyleSheet();
+ Report.setupStylesheet(styleSheet);
+ }
+
public static void setupStylesheet(StyleSheet styleSheet) {
Font font = UIManager.getFont("Label.font");
int size = UIUtil.scaleForGUI(UIUtil.FONT_SCALE1);
diff --git a/megamek/src/megamek/common/enums/GamePhase.java b/megamek/src/megamek/common/enums/GamePhase.java
index 09ff7afc137..c10d74087e4 100644
--- a/megamek/src/megamek/common/enums/GamePhase.java
+++ b/megamek/src/megamek/common/enums/GamePhase.java
@@ -181,6 +181,7 @@ public boolean isReport() {
case FIRING_REPORT:
case PHYSICAL_REPORT:
case END_REPORT:
+ case VICTORY:
return true;
default:
return false;
@@ -202,6 +203,14 @@ public boolean isOnMap() {
case PHYSICAL:
case DEPLOY_MINEFIELDS:
case SET_ARTILLERY_AUTOHIT_HEXES:
+ case INITIATIVE_REPORT:
+ case TARGETING_REPORT:
+ case MOVEMENT_REPORT:
+ case OFFBOARD_REPORT:
+ case FIRING_REPORT:
+ case PHYSICAL_REPORT:
+ case END_REPORT:
+ case VICTORY:
return true;
default:
return false;
diff --git a/megamek/src/megamek/server/GameManager.java b/megamek/src/megamek/server/GameManager.java
index 7ae22b61b7f..f405349b16a 100644
--- a/megamek/src/megamek/server/GameManager.java
+++ b/megamek/src/megamek/server/GameManager.java
@@ -1130,7 +1130,7 @@ public void decrementASEWTurns() {
* Called at the beginning of certain phases to make every player not ready.
*/
private void resetPlayersDone() {
- if (getGame().getPhase().isReport()) {
+ if ((getGame().getPhase().isReport()) && (!getGame().getPhase().isVictory())) {
return;
}
@@ -1833,6 +1833,7 @@ public boolean accept(Entity entity) {
case END_REPORT:
resetActivePlayersDone();
sendReport();
+ entityAllUpdate();
if (game.getOptions().booleanOption(OptionsConstants.BASE_PARANOID_AUTOSAVE)) {
autoSave();
}