From 50506bece5257e6792458d8b02212935610c5783 Mon Sep 17 00:00:00 2001 From: kuronekochomusuke Date: Mon, 16 Jan 2023 14:35:02 -0500 Subject: [PATCH 01/15] unit tool tip fixes --- .../client/ui/swing/boardview/BoardView.java | 6 ++---- .../client/ui/swing/tooltip/PilotToolTip.java | 18 ++++++++++-------- .../client/ui/swing/tooltip/UnitToolTip.java | 6 +++--- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/megamek/src/megamek/client/ui/swing/boardview/BoardView.java b/megamek/src/megamek/client/ui/swing/boardview/BoardView.java index 32d667306c2..dcc5caf9ad8 100644 --- a/megamek/src/megamek/client/ui/swing/boardview/BoardView.java +++ b/megamek/src/megamek/client/ui/swing/boardview/BoardView.java @@ -5463,7 +5463,7 @@ public String getHexTooltip(MouseEvent e) { // Distance from the selected unit and a planned movement end point if ((selectedEntity != null) && (selectedEntity.getPosition() != null)) { int distance = selectedEntity.getPosition().distance(mcoords); - txt.append("
"); + txt.append(""); if (distance == 1) { txt.append(Messages.getString("BoardView1.Tooltip.Distance1")); } else { @@ -5683,8 +5683,6 @@ public String getHexTooltip(MouseEvent e) { } } - txt.append(HTML_END); - // Check to see if the tool tip is completely empty if (txt.toString().equals(HTML_BEGIN +HTML_END)) { return ""; @@ -5846,7 +5844,7 @@ public void appendEntityTooltip(StringBuffer txt, @Nullable Entity entity) { } // Table to add a bar to the left of an entity in // the player's color - txt.append("
"); + txt.append("
"); txt.append(""); return result; } @@ -149,7 +152,6 @@ private static StringBuilder crewPortraits(final Entity entity, boolean showDefa } catch (Exception e) { LogManager.getLogger().error("", e); } - result.append(""); } return result; } diff --git a/megamek/src/megamek/client/ui/swing/tooltip/UnitToolTip.java b/megamek/src/megamek/client/ui/swing/tooltip/UnitToolTip.java index 8ba51d5c018..dfd3b8fd9b8 100644 --- a/megamek/src/megamek/client/ui/swing/tooltip/UnitToolTip.java +++ b/megamek/src/megamek/client/ui/swing/tooltip/UnitToolTip.java @@ -75,7 +75,6 @@ private static StringBuilder getEntityTipTable(Entity entity, Player localPlayer } StringBuilder result = new StringBuilder(); - result.append("\n
"); + + result.append("
"); + result.append(""); if (showPortrait) { result.append(crewPortraits(entity, showDefaultPortrait)); - // Add a spacer cell - int dist = (int) (GUIPreferences.getInstance().getGUIScale() * 10); - result.append(""); } result.append(crewInfoCell(entity)); - result.append(TABLE_END); + result.append("
"); + result.append("
"); result.append(scaledHTMLSpacer(3)); return result; } @@ -77,6 +77,7 @@ public static StringBuilder getCrewAdvs(Entity entity, boolean detailed) { StringBuilder result = new StringBuilder(); result.append(scaledHTMLSpacer(3)); result.append(crewAdvs(entity, detailed)); + return result; } @@ -85,6 +86,7 @@ private static StringBuilder crewInfoCell(final Entity entity) { Crew crew = entity.getCrew(); Game game = entity.getGame(); StringBuilder result = new StringBuilder(); + result.append("
"); result.append(guiScaledFontHTML()); // Name / Callsign and Status for each crew member @@ -118,6 +120,7 @@ private static StringBuilder crewInfoCell(final Entity entity) { result.append(CrewSkillSummaryUtil.getSkillNames(entity) + ": " + crew.getSkillsAsString(rpg_skills)); result.append(""); + result.append("
\n\n\n\n
\n"); Game game = entity.getGame(); // Unit Chassis and Player @@ -174,9 +173,10 @@ private static StringBuilder getEntityTipTable(Entity entity, Player localPlayer result.append(scaledHTMLSpacer(3) + "\n"); result.append(c3Info(entity)); } - result.append("
\n"); - return result; + StringBuilder r = new StringBuilder(); + r.append("
" + result + "
"); + return r; } private static boolean hideArmorLocation(Entity entity, int location) { From dcda5181aa5c296aaf15e657d750fe10bd3800f0 Mon Sep 17 00:00:00 2001 From: kuronekochomusuke Date: Mon, 16 Jan 2023 16:27:44 -0500 Subject: [PATCH 02/15] unit tool tip fixes 2 --- .../src/megamek/client/ui/swing/boardview/BoardView.java | 6 +++++- .../src/megamek/client/ui/swing/tooltip/PilotToolTip.java | 2 -- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/megamek/src/megamek/client/ui/swing/boardview/BoardView.java b/megamek/src/megamek/client/ui/swing/boardview/BoardView.java index dcc5caf9ad8..a15d168454e 100644 --- a/megamek/src/megamek/client/ui/swing/boardview/BoardView.java +++ b/megamek/src/megamek/client/ui/swing/boardview/BoardView.java @@ -5456,6 +5456,7 @@ public String getHexTooltip(MouseEvent e) { Hex mhex = game.getBoard().getHex(mcoords); StringBuffer txt = new StringBuffer(HTML_BEGIN); + txt.append("
"); // Hex Terrain if (GUIP.getShowMapHexPopup() && (mhex != null)) { appendTerrainTooltip(txt, mhex); @@ -5683,6 +5684,9 @@ public String getHexTooltip(MouseEvent e) { } } + txt.append("
"); + txt.append(HTML_END); + // Check to see if the tool tip is completely empty if (txt.toString().equals(HTML_BEGIN +HTML_END)) { return ""; @@ -5854,7 +5858,7 @@ public void appendEntityTooltip(StringBuffer txt, @Nullable Entity entity) { txt.append(" width=6>
"); // Entity tooltip - txt.append("
" + UnitToolTip.getEntityTipGame(entity, getLocalPlayer()) + "
"); } diff --git a/megamek/src/megamek/client/ui/swing/tooltip/PilotToolTip.java b/megamek/src/megamek/client/ui/swing/tooltip/PilotToolTip.java index 02e6bfbf43e..f50f8c4a99e 100644 --- a/megamek/src/megamek/client/ui/swing/tooltip/PilotToolTip.java +++ b/megamek/src/megamek/client/ui/swing/tooltip/PilotToolTip.java @@ -31,8 +31,6 @@ import static megamek.client.ui.swing.tooltip.TipUtil.getOptionList; import static megamek.client.ui.swing.tooltip.TipUtil.scaledHTMLSpacer; import static megamek.client.ui.swing.util.UIUtil.guiScaledFontHTML; -import static megamek.client.ui.swing.util.UIUtil.uiDarkBlue; -import static megamek.client.ui.swing.util.UIUtil.uiGray; import static megamek.client.ui.swing.util.UIUtil.uiQuirksColor; public final class PilotToolTip { From e7d51bc1e771309009d7eb102cbe11448c9a3f63 Mon Sep 17 00:00:00 2001 From: kuronekochomusuke Date: Mon, 16 Jan 2023 18:10:02 -0500 Subject: [PATCH 03/15] unit tool tip fixes 3 --- .../megamek/client/ui/swing/boardview/BoardView.java | 11 +++++------ .../client/ui/swing/unitDisplay/SummaryPanel.java | 2 ++ 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/megamek/src/megamek/client/ui/swing/boardview/BoardView.java b/megamek/src/megamek/client/ui/swing/boardview/BoardView.java index a15d168454e..495cfb1e113 100644 --- a/megamek/src/megamek/client/ui/swing/boardview/BoardView.java +++ b/megamek/src/megamek/client/ui/swing/boardview/BoardView.java @@ -5459,6 +5459,7 @@ public String getHexTooltip(MouseEvent e) { txt.append("
"); // Hex Terrain if (GUIP.getShowMapHexPopup() && (mhex != null)) { + txt.append("
"); appendTerrainTooltip(txt, mhex); // Distance from the selected unit and a planned movement end point @@ -5499,10 +5500,9 @@ public String getHexTooltip(MouseEvent e) { txt.append(Messages.getString("BoardView1.Tooltip.DistanceMoveN", disPM)); } } - - txt.append("
"); } + txt.append(""); appendBuildingsTooltip(txt, mhex); if (displayInvalidHexInfo) { @@ -5554,7 +5554,6 @@ public String getHexTooltip(MouseEvent e) { txt.append(""); } - // check if it's on any flares for (FlareSprite fSprite : flareSprites) { if (fSprite.isInside(point)) { @@ -5714,7 +5713,7 @@ public void appendTerrainTooltip(StringBuffer txt, @Nullable Hex mhex) { } Coords mcoords = mhex.getCoords(); - txt.append("
"); + txt.append(""); txt.append(Messages.getString("BoardView1.Tooltip.Hex", mcoords.getBoardNum(), mhex.getLevel())); txt.append("
"); @@ -5729,7 +5728,7 @@ public void appendTerrainTooltip(StringBuffer txt, @Nullable Hex mhex) { txt.append(name + "
"); } } - txt.append("
"); + txt.append(""); } @@ -5849,7 +5848,7 @@ public void appendEntityTooltip(StringBuffer txt, @Nullable Entity entity) { // Table to add a bar to the left of an entity in // the player's color txt.append("
"); - txt.append("
"); bv.appendTerrainTooltip(hexTxt, mhex); + hexTxt.append("
"); bv.appendBuildingsTooltip(hexTxt, mhex); } hexTxt.append(PilotToolTip.getCrewAdvs(entity, true)); From 82ea16424aec27e3a64663ad39bb6565ce154af6 Mon Sep 17 00:00:00 2001 From: kuronekochomusuke Date: Mon, 16 Jan 2023 19:03:05 -0500 Subject: [PATCH 04/15] unit tool tip fixes 4 --- .../client/ui/swing/boardview/BoardView.java | 13 ++++++------- .../client/ui/swing/tooltip/PilotToolTip.java | 11 ++++++++--- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/megamek/src/megamek/client/ui/swing/boardview/BoardView.java b/megamek/src/megamek/client/ui/swing/boardview/BoardView.java index 495cfb1e113..abd2a9fe679 100644 --- a/megamek/src/megamek/client/ui/swing/boardview/BoardView.java +++ b/megamek/src/megamek/client/ui/swing/boardview/BoardView.java @@ -5845,20 +5845,19 @@ public void appendEntityTooltip(StringBuffer txt, @Nullable Entity entity) { if (entity == null) { return; } + + txt.append("
"); // Table to add a bar to the left of an entity in // the player's color - txt.append("
"); - txt.append(""; // Entity tooltip - txt.append(UnitToolTip.getEntityTipGame(entity, getLocalPlayer())); - txt.append("
"); - + String col1 = "
"); + String col2 = "" + UnitToolTip.getEntityTipGame(entity, getLocalPlayer()) + ""; + String row = "" + col1 + col2 + ""; + txt.append("" + row + "
"); } private ArrayList getArtilleryAttacksAtLocation(Coords c) { diff --git a/megamek/src/megamek/client/ui/swing/tooltip/PilotToolTip.java b/megamek/src/megamek/client/ui/swing/tooltip/PilotToolTip.java index f50f8c4a99e..f0d727e7eec 100644 --- a/megamek/src/megamek/client/ui/swing/tooltip/PilotToolTip.java +++ b/megamek/src/megamek/client/ui/swing/tooltip/PilotToolTip.java @@ -55,7 +55,9 @@ private static StringBuilder getPilotTip(final Entity entity, boolean detailed, // The crew info (names etc.) and portraits, if shown, are placed // in a table side by side - result.append("
"); + if (!detailed) { + result.append("
"); + } result.append(""); if (showPortrait) { @@ -65,8 +67,11 @@ private static StringBuilder getPilotTip(final Entity entity, boolean detailed, result.append(crewInfoCell(entity)); result.append("
"); - result.append("
"); - result.append(scaledHTMLSpacer(3)); + if (!detailed) { + result.append("
"); + } else { + result.append(scaledHTMLSpacer(3)); + } return result; } From 3938cf71878f9bb01f752d76314fb334bc3556c0 Mon Sep 17 00:00:00 2001 From: kuronekochomusuke Date: Mon, 16 Jan 2023 19:59:32 -0500 Subject: [PATCH 05/15] unit tool tip fixes 5 --- .../i18n/megamek/client/messages.properties | 2 + .../client/ui/swing/boardview/BoardView.java | 39 ++++++++--------- .../client/ui/swing/tooltip/PilotToolTip.java | 42 +++++++++---------- .../ui/swing/unitDisplay/SummaryPanel.java | 8 ++-- 4 files changed, 48 insertions(+), 43 deletions(-) diff --git a/megamek/i18n/megamek/client/messages.properties b/megamek/i18n/megamek/client/messages.properties index ec565b91c68..02c2e8e48d0 100644 --- a/megamek/i18n/megamek/client/messages.properties +++ b/megamek/i18n/megamek/client/messages.properties @@ -546,6 +546,7 @@ BoardView1.Tooltip.NoMove=Did not move (Mod: {0}) BoardView1.Tooltip.NullWeaponName=NULL Weapon Name! BoardView1.Tooltip.OutOfAmmo=Out of Ammo! BoardView1.Tooltip.PartialWing=Partial Wing +BoardView1.Tooltip.Pilot=Pilot BoardView1.Tooltip.PilotPortrait= BoardView1.Tooltip.Prone=Prone BoardView1.Tooltip.Rapidfire=Rapid-fire @@ -562,6 +563,7 @@ BoardView1.Tooltip.SensorsHexNotInRange=Hex is not in sen BoardView1.Tooltip.Spotting=Spotting {0} BoardView1.Tooltip.Swarmed=Swarmed by {0} BoardView1.Tooltip.TakingCover=
(Taking Cover) +BoardView1.Tooltip.TF=TF BoardView1.Tooltip.ThisUnit=This unit BoardView1.Tooltip.Towing=Towing: {0} BoardView1.Tooltip.Turns=turns diff --git a/megamek/src/megamek/client/ui/swing/boardview/BoardView.java b/megamek/src/megamek/client/ui/swing/boardview/BoardView.java index abd2a9fe679..a5c41fe4986 100644 --- a/megamek/src/megamek/client/ui/swing/boardview/BoardView.java +++ b/megamek/src/megamek/client/ui/swing/boardview/BoardView.java @@ -5459,17 +5459,16 @@ public String getHexTooltip(MouseEvent e) { txt.append("
"); // Hex Terrain if (GUIP.getShowMapHexPopup() && (mhex != null)) { - txt.append("
"); - appendTerrainTooltip(txt, mhex); + StringBuffer s = new StringBuffer(); + appendTerrainTooltip(s, mhex); // Distance from the selected unit and a planned movement end point if ((selectedEntity != null) && (selectedEntity.getPosition() != null)) { int distance = selectedEntity.getPosition().distance(mcoords); - txt.append(""); if (distance == 1) { - txt.append(Messages.getString("BoardView1.Tooltip.Distance1")); + s.append(Messages.getString("BoardView1.Tooltip.Distance1")); } else { - txt.append(Messages.getString("BoardView1.Tooltip.DistanceN", distance)); + s.append(Messages.getString("BoardView1.Tooltip.DistanceN", distance)); } if (game.getOptions().booleanOption(OptionsConstants.ADVANCED_TACOPS_SENSORS)) { @@ -5483,26 +5482,30 @@ public String getHexTooltip(MouseEvent e) { if (game.getOptions().booleanOption(OptionsConstants.ADVANCED_INCLUSIVE_SENSOR_RANGE)) { minSensorRange = 0; } - txt.append("
"); + s.append("
"); if ((distance > minSensorRange) && (distance <= maxSensorRange)) { - txt.append(Messages.getString("BoardView1.Tooltip.SensorsHexInRange")); + s.append(Messages.getString("BoardView1.Tooltip.SensorsHexInRange")); } else { - txt.append(Messages.getString("BoardView1.Tooltip.SensorsHexNotInRange")); + s.append(Messages.getString("BoardView1.Tooltip.SensorsHexNotInRange")); } } if (game.getPhase().isMovement() && (movementTarget != null)) { - txt.append("
"); + s.append("
"); int disPM = movementTarget.distance(mcoords); if (disPM == 1) { - txt.append(Messages.getString("BoardView1.Tooltip.DistanceMove1")); + s.append(Messages.getString("BoardView1.Tooltip.DistanceMove1")); } else { - txt.append(Messages.getString("BoardView1.Tooltip.DistanceMoveN", disPM)); + s.append(Messages.getString("BoardView1.Tooltip.DistanceMoveN", disPM)); } } } - txt.append("
"); + + String t = "" + s + ""; + String col = "" + t + ""; + String row = "" + col + ""; + txt.append("" + row + "
"); appendBuildingsTooltip(txt, mhex); if (displayInvalidHexInfo) { @@ -5713,10 +5716,8 @@ public void appendTerrainTooltip(StringBuffer txt, @Nullable Hex mhex) { } Coords mcoords = mhex.getCoords(); - txt.append(""); - txt.append(Messages.getString("BoardView1.Tooltip.Hex", mcoords.getBoardNum(), mhex.getLevel())); - txt.append("
"); + String s = Messages.getString("BoardView1.Tooltip.Hex", mcoords.getBoardNum(), mhex.getLevel()) + "
"; // cycle through the terrains and report types found for (int terType: mhex.getTerrainTypes()) { @@ -5724,12 +5725,12 @@ public void appendTerrainTooltip(StringBuffer txt, @Nullable Hex mhex) { int ttl = mhex.getTerrain(terType).getLevel(); String name = Terrains.getDisplayName(terType, ttl); if (name != null) { - name += (tf > 0) ? " (TF: " + tf + ")" : ""; - txt.append(name + "
"); + String msg_tf = Messages.getString("BoardView1.Tooltip.TF"); + name += (tf > 0) ? " (" + msg_tf + ": " + tf + ")" : ""; + s += name + "
"; } } - txt.append("
"); - + txt.append("" + s + ""); } /** diff --git a/megamek/src/megamek/client/ui/swing/tooltip/PilotToolTip.java b/megamek/src/megamek/client/ui/swing/tooltip/PilotToolTip.java index f0d727e7eec..923aaa672f3 100644 --- a/megamek/src/megamek/client/ui/swing/tooltip/PilotToolTip.java +++ b/megamek/src/megamek/client/ui/swing/tooltip/PilotToolTip.java @@ -13,6 +13,7 @@ */ package megamek.client.ui.swing.tooltip; +import megamek.client.ui.Messages; import megamek.client.ui.swing.GUIPreferences; import megamek.client.ui.swing.util.UIUtil; import megamek.common.Configuration; @@ -52,21 +53,21 @@ public static StringBuilder getPilotTipShort(Entity entity, boolean showPortrait private static StringBuilder getPilotTip(final Entity entity, boolean detailed, boolean showPortrait, boolean showDefaultPortrait) { StringBuilder result = new StringBuilder(); - // The crew info (names etc.) and portraits, if shown, are placed - // in a table side by side - if (!detailed) { result.append("
"); } - result.append(""); + // The crew info (names etc.) and portraits, if shown, are placed + // in a table side by side + String cols = ""; if (showPortrait) { - result.append(crewPortraits(entity, showDefaultPortrait)); + cols = crewPortraits(entity, showDefaultPortrait).toString(); } - result.append(crewInfoCell(entity)); + cols += crewInfoCell(entity).toString(); + String row = "" + cols + ""; + result.append("
" + row + "
"); - result.append(""); if (!detailed) { result.append("
"); } else { @@ -88,9 +89,7 @@ public static StringBuilder getCrewAdvs(Entity entity, boolean detailed) { private static StringBuilder crewInfoCell(final Entity entity) { Crew crew = entity.getCrew(); Game game = entity.getGame(); - StringBuilder result = new StringBuilder(); - result.append(""); - result.append(guiScaledFontHTML()); + String s = ""; // Name / Callsign and Status for each crew member for (int i = 0; i < crew.getSlotCount(); i++) { @@ -99,31 +98,32 @@ private static StringBuilder crewInfoCell(final Entity entity) { } if ((crew.getNickname(i) != null) && !crew.getNickname(i).isBlank()) { - result.append(guiScaledFontHTML(UIUtil.uiNickColor()) + "'" - + crew.getNickname(i).toUpperCase() + "'"); + String t = "'" + crew.getNickname(i).toUpperCase() + "'"; + s += guiScaledFontHTML(UIUtil.uiNickColor()) + t + ""; } else if ((crew.getName(i) != null) && !crew.getName(i).isBlank()) { - result.append(crew.getName(i)); + s += crew.getName(i); } else { - result.append("Pilot"); + s += Messages.getString("BoardView1.Tooltip.Pilot"); } if (crew.getSlotCount() > 1) { - result.append(" \u2B1D " + crew.getCrewType().getRoleName(i)); + s += " \u2B1D " + crew.getCrewType().getRoleName(i); } if (!crew.getStatusDesc(i).isEmpty()) { - result.append(guiScaledFontHTML(GUIPreferences.getInstance().getWarningColor())); - result.append(" (" + crew.getStatusDesc(i) + ")"); + s += guiScaledFontHTML(GUIPreferences.getInstance().getWarningColor()) + " (" + crew.getStatusDesc(i) + ")"; } - result.append("
"); + s += "
"; } // Effective entity skill for the whole crew boolean rpg_skills = game.getOptions().booleanOption(OptionsConstants.RPG_RPG_GUNNERY); - result.append(CrewSkillSummaryUtil.getSkillNames(entity) + ": " + crew.getSkillsAsString(rpg_skills)); + s += CrewSkillSummaryUtil.getSkillNames(entity) + ": " + crew.getSkillsAsString(rpg_skills); - result.append(""); - result.append(""); + s = guiScaledFontHTML() + s + ""; + + StringBuilder result = new StringBuilder(); + result.append("" + s + ""); return result; } diff --git a/megamek/src/megamek/client/ui/swing/unitDisplay/SummaryPanel.java b/megamek/src/megamek/client/ui/swing/unitDisplay/SummaryPanel.java index ede626de00f..99e79108bd9 100644 --- a/megamek/src/megamek/client/ui/swing/unitDisplay/SummaryPanel.java +++ b/megamek/src/megamek/client/ui/swing/unitDisplay/SummaryPanel.java @@ -142,9 +142,11 @@ public void displayMech(Entity entity) { BoardView bv = unitDisplay.getClientGUI().getBoardView(); Hex mhex = entity.getGame().getBoard().getHex(entity.getPosition()); if (bv != null && mhex != null) { - hexTxt.append("
"); - bv.appendTerrainTooltip(hexTxt, mhex); - hexTxt.append("
"); + StringBuffer s = new StringBuffer(); + bv.appendTerrainTooltip(s, mhex); + String col = "" + s + ""; + String row = "" + col + ""; + hexTxt.append("" + row + "
"); bv.appendBuildingsTooltip(hexTxt, mhex); } hexTxt.append(PilotToolTip.getCrewAdvs(entity, true)); From 1ba3c948318b0bea4dec40c3ffb958231332c6c0 Mon Sep 17 00:00:00 2001 From: kuronekochomusuke Date: Mon, 16 Jan 2023 21:16:49 -0500 Subject: [PATCH 06/15] unit tool tip fixes 6 --- .../client/ui/swing/boardview/BoardView.java | 1 - .../client/ui/swing/lobby/MekTableModel.java | 6 +++++- .../client/ui/swing/tooltip/UnitToolTip.java | 4 +--- .../ui/swing/unitDisplay/SummaryPanel.java | 20 ++++++++++++++----- 4 files changed, 21 insertions(+), 10 deletions(-) diff --git a/megamek/src/megamek/client/ui/swing/boardview/BoardView.java b/megamek/src/megamek/client/ui/swing/boardview/BoardView.java index a5c41fe4986..0a7742e26c8 100644 --- a/megamek/src/megamek/client/ui/swing/boardview/BoardView.java +++ b/megamek/src/megamek/client/ui/swing/boardview/BoardView.java @@ -5501,7 +5501,6 @@ public String getHexTooltip(MouseEvent e) { } } - String t = "" + s + ""; String col = "" + t + ""; String row = "" + col + ""; diff --git a/megamek/src/megamek/client/ui/swing/lobby/MekTableModel.java b/megamek/src/megamek/client/ui/swing/lobby/MekTableModel.java index 2a0a399c91d..f0636e2c306 100644 --- a/megamek/src/megamek/client/ui/swing/lobby/MekTableModel.java +++ b/megamek/src/megamek/client/ui/swing/lobby/MekTableModel.java @@ -189,7 +189,11 @@ private void addCellData(Entity entity) { } else { MapSettings mset = chatLounge.mapSettings; Player lPlayer = clientGui.getClient().getLocalPlayer(); - unitTooltips.add( HTML_BEGIN + UnitToolTip.getEntityTipLobby(entity, lPlayer, mset) + HTML_END); + String s = UnitToolTip.getEntityTipLobby(entity, lPlayer, mset).toString(); + String col = "" + s + ""; + String row = "" + col + ""; + s = "" + row + "
"; + unitTooltips.add( HTML_BEGIN + s + HTML_END); pilotTooltips.add(HTML_BEGIN + PilotToolTip.getPilotTipDetailed(entity, true) + PilotToolTip.getCrewAdvs(entity, true) + HTML_END); } final boolean rpgSkills = clientGui.getClient().getGame().getOptions().booleanOption(OptionsConstants.RPG_RPG_GUNNERY); diff --git a/megamek/src/megamek/client/ui/swing/tooltip/UnitToolTip.java b/megamek/src/megamek/client/ui/swing/tooltip/UnitToolTip.java index dfd3b8fd9b8..fb576a0324a 100644 --- a/megamek/src/megamek/client/ui/swing/tooltip/UnitToolTip.java +++ b/megamek/src/megamek/client/ui/swing/tooltip/UnitToolTip.java @@ -174,9 +174,7 @@ private static StringBuilder getEntityTipTable(Entity entity, Player localPlayer result.append(c3Info(entity)); } - StringBuilder r = new StringBuilder(); - r.append("
" + result + "
"); - return r; + return result; } private static boolean hideArmorLocation(Entity entity, int location) { diff --git a/megamek/src/megamek/client/ui/swing/unitDisplay/SummaryPanel.java b/megamek/src/megamek/client/ui/swing/unitDisplay/SummaryPanel.java index 99e79108bd9..34abdf75b73 100644 --- a/megamek/src/megamek/client/ui/swing/unitDisplay/SummaryPanel.java +++ b/megamek/src/megamek/client/ui/swing/unitDisplay/SummaryPanel.java @@ -26,6 +26,7 @@ import megamek.client.ui.swing.widget.*; import megamek.common.*; import megamek.common.util.fileUtils.MegaMekFile; +import megamek.client.ui.swing.tooltip.TipUtil; import javax.swing.*; import java.awt.*; @@ -123,7 +124,6 @@ private void setBackGround() { * @param entity The Entity to display info for */ public void displayMech(Entity entity) { - Player localPlayer = unitDisplay.getClientGUI().getClient().getLocalPlayer(); if (entity == null) { @@ -138,18 +138,28 @@ public void displayMech(Entity entity) { // also allow cells do have bg colors StringBuffer hexTxt = new StringBuffer(""); hexTxt.append(PilotToolTip.getPilotTipDetailed(entity, true)); - hexTxt.append(UnitToolTip.getEntityTipUnitDisplay(entity, localPlayer)); + StringBuffer p = new StringBuffer(); + p.append(UnitToolTip.getEntityTipUnitDisplay(entity, localPlayer)); + String col = "" + p + ""; + String row = "" + col + ""; + hexTxt.append("" + row + "
"); + BoardView bv = unitDisplay.getClientGUI().getBoardView(); Hex mhex = entity.getGame().getBoard().getHex(entity.getPosition()); if (bv != null && mhex != null) { StringBuffer s = new StringBuffer(); bv.appendTerrainTooltip(s, mhex); - String col = "" + s + ""; - String row = "" + col + ""; + col = "" + s + ""; + row = "" + col + ""; hexTxt.append("" + row + "
"); bv.appendBuildingsTooltip(hexTxt, mhex); } - hexTxt.append(PilotToolTip.getCrewAdvs(entity, true)); + + String t = PilotToolTip.getCrewAdvs(entity, true).toString(); + col = "" + t + ""; + row = "" + col + ""; + hexTxt.append("" + row + "
"); + unitInfo.setText(HTML_BEGIN + padLeft(hexTxt.toString()) + HTML_END); } unitInfo.setOpaque(false); From f5f041acf27ee6d5fe2fdf2c39c4b1d4cd355850 Mon Sep 17 00:00:00 2001 From: kuronekochomusuke Date: Mon, 16 Jan 2023 21:24:33 -0500 Subject: [PATCH 07/15] unit tool tip fixes 7 --- .../src/megamek/client/ui/swing/unitDisplay/SummaryPanel.java | 1 - 1 file changed, 1 deletion(-) diff --git a/megamek/src/megamek/client/ui/swing/unitDisplay/SummaryPanel.java b/megamek/src/megamek/client/ui/swing/unitDisplay/SummaryPanel.java index 34abdf75b73..0ae28435e97 100644 --- a/megamek/src/megamek/client/ui/swing/unitDisplay/SummaryPanel.java +++ b/megamek/src/megamek/client/ui/swing/unitDisplay/SummaryPanel.java @@ -26,7 +26,6 @@ import megamek.client.ui.swing.widget.*; import megamek.common.*; import megamek.common.util.fileUtils.MegaMekFile; -import megamek.client.ui.swing.tooltip.TipUtil; import javax.swing.*; import java.awt.*; From fb2551018843fd42915ce44654a1b812f51c2079 Mon Sep 17 00:00:00 2001 From: kuronekochomusuke Date: Tue, 17 Jan 2023 22:25:50 -0500 Subject: [PATCH 08/15] unit tool tip fixes 7 --- .../ui/swing/boardview/AttackSprite.java | 16 +- .../client/ui/swing/boardview/BoardView.java | 231 +++--- .../client/ui/swing/lobby/MekTableModel.java | 6 +- .../client/ui/swing/tooltip/PilotToolTip.java | 51 +- .../client/ui/swing/tooltip/UnitToolTip.java | 733 ++++++++++-------- .../ui/swing/unitDisplay/SummaryPanel.java | 20 +- 6 files changed, 600 insertions(+), 457 deletions(-) diff --git a/megamek/src/megamek/client/ui/swing/boardview/AttackSprite.java b/megamek/src/megamek/client/ui/swing/boardview/AttackSprite.java index ac3aa8dd147..3e983dd76d2 100644 --- a/megamek/src/megamek/client/ui/swing/boardview/AttackSprite.java +++ b/megamek/src/megamek/client/ui/swing/boardview/AttackSprite.java @@ -373,16 +373,14 @@ public void addWeapon(SearchlightAttackAction attack) { @Override public StringBuffer getTooltip() { - StringBuffer tipString = new StringBuffer(); - tipString.append(""); - tipString.append(attackerDesc - + "
  " + Messages.getString("BoardView1.on") + " " + targetDesc); - tipString.append("
"); + String s = ""; + String f = ""; + + f = attackerDesc + "
  " + Messages.getString("BoardView1.on") + " " + targetDesc; + s = "" + f + ""; for (String wpD: weaponDescs) { - tipString.append("
"+wpD); + s += "
"+wpD; } - return tipString; + return new StringBuffer().append(s); } } \ No newline at end of file diff --git a/megamek/src/megamek/client/ui/swing/boardview/BoardView.java b/megamek/src/megamek/client/ui/swing/boardview/BoardView.java index 0a7742e26c8..cc86b10ae11 100644 --- a/megamek/src/megamek/client/ui/swing/boardview/BoardView.java +++ b/megamek/src/megamek/client/ui/swing/boardview/BoardView.java @@ -33,10 +33,7 @@ import megamek.client.ui.swing.tileset.HexTileset; import megamek.client.ui.swing.tileset.TilesetManager; import megamek.client.ui.swing.tooltip.UnitToolTip; -import megamek.client.ui.swing.util.CommandAction; -import megamek.client.ui.swing.util.ImageCache; -import megamek.client.ui.swing.util.KeyCommandBind; -import megamek.client.ui.swing.util.MegaMekController; +import megamek.client.ui.swing.util.*; import megamek.client.ui.swing.widget.MegamekBorder; import megamek.client.ui.swing.widget.SkinSpecification; import megamek.client.ui.swing.widget.SkinSpecification.UIComponents; @@ -5455,20 +5452,26 @@ public String getHexTooltip(MouseEvent e) { } Hex mhex = game.getBoard().getHex(mcoords); - StringBuffer txt = new StringBuffer(HTML_BEGIN); - txt.append("
"); + String b = ""; + String f = ""; + String t = ""; + String s = ""; + StringBuffer sb = new StringBuffer(); + //StringBuffer txt = new StringBuffer(); + // Hex Terrain if (GUIP.getShowMapHexPopup() && (mhex != null)) { - StringBuffer s = new StringBuffer(); - appendTerrainTooltip(s, mhex); + sb = new StringBuffer(); + appendTerrainTooltip(sb, mhex); + f += sb.toString(); // Distance from the selected unit and a planned movement end point if ((selectedEntity != null) && (selectedEntity.getPosition() != null)) { int distance = selectedEntity.getPosition().distance(mcoords); if (distance == 1) { - s.append(Messages.getString("BoardView1.Tooltip.Distance1")); + f += Messages.getString("BoardView1.Tooltip.Distance1"); } else { - s.append(Messages.getString("BoardView1.Tooltip.DistanceN", distance)); + f += Messages.getString("BoardView1.Tooltip.DistanceN", distance); } if (game.getOptions().booleanOption(OptionsConstants.ADVANCED_TACOPS_SENSORS)) { @@ -5482,40 +5485,44 @@ public String getHexTooltip(MouseEvent e) { if (game.getOptions().booleanOption(OptionsConstants.ADVANCED_INCLUSIVE_SENSOR_RANGE)) { minSensorRange = 0; } - s.append("
"); + f += "
"; if ((distance > minSensorRange) && (distance <= maxSensorRange)) { - s.append(Messages.getString("BoardView1.Tooltip.SensorsHexInRange")); + f += Messages.getString("BoardView1.Tooltip.SensorsHexInRange"); } else { - s.append(Messages.getString("BoardView1.Tooltip.SensorsHexNotInRange")); + f += Messages.getString("BoardView1.Tooltip.SensorsHexNotInRange"); } } if (game.getPhase().isMovement() && (movementTarget != null)) { - s.append("
"); + f += "
"; int disPM = movementTarget.distance(mcoords); if (disPM == 1) { - s.append(Messages.getString("BoardView1.Tooltip.DistanceMove1")); + f += Messages.getString("BoardView1.Tooltip.DistanceMove1"); } else { - s.append(Messages.getString("BoardView1.Tooltip.DistanceMoveN", disPM)); + f += Messages.getString("BoardView1.Tooltip.DistanceMoveN", disPM); } } } - String t = "" + s + ""; + t = "" + f + ""; String col = "" + t + ""; String row = "" + col + ""; - txt.append("" + row + "
"); - appendBuildingsTooltip(txt, mhex); + String table = "" + row + "
"; + s += table; + + sb = new StringBuffer(); + appendBuildingsTooltip(sb, mhex); + s += sb.toString(); if (displayInvalidHexInfo) { StringBuffer errBuff = new StringBuffer(); if (!mhex.isValid(errBuff)) { - txt.append(Messages.getString("BoardView1.invalidHex")); - txt.append("
"); + s += Messages.getString("BoardView1.invalidHex"); + s += "
"; String errors = errBuff.toString(); - errors = errors.replace("\n", "
"); - txt.append(errors); - txt.append("
"); + errors = errors.replace("\n", "
"); + s += errors; + s += "
"; } } } @@ -5523,7 +5530,7 @@ public String getHexTooltip(MouseEvent e) { // Show the player(s) that may deploy here // in the artillery autohit designation phase if (game.getPhase().isSetArtilleryAutohitHexes() && (mhex != null)) { - txt.append("
"); + t = ""; Enumeration allP = game.getPlayers(); boolean foundPlayer = false; // loop through all players @@ -5532,17 +5539,17 @@ public String getHexTooltip(MouseEvent e) { if (game.getBoard().isLegalDeployment(mcoords, cp)) { if (!foundPlayer) { foundPlayer = true; - txt.append(Messages.getString("BoardView1.Tooltip.ArtyAutoHeader")); + t += Messages.getString("BoardView1.Tooltip.ArtyAutoHeader"); } - txt.append("  "); - txt.append(cp.getName()); - txt.append("
"); + + f = "  " + cp.getName(); + b = "" + f + ""; + t += "" + b + ""; + t += "
"; } } if (foundPlayer) { - txt.append("
"); + t += "
"; } // Add a hint with keybind that the zones can be shown graphically @@ -5551,24 +5558,30 @@ public String getHexTooltip(MouseEvent e) { keybindText += "+"; } keybindText += KeyEvent.getKeyText(KeyCommandBind.getBindByCmd("autoArtyDeployZone").key); - txt.append(Messages.getString("BoardView1.Tooltip.ArtyAutoHint", keybindText)); + s += Messages.getString("BoardView1.Tooltip.ArtyAutoHint", keybindText); - txt.append("
"); + String col = "" + t + ""; + String row = "" + col + ""; + String table = "" + row + "
"; + s += table; } // check if it's on any flares for (FlareSprite fSprite : flareSprites) { if (fSprite.isInside(point)) { - txt.append(fSprite.getTooltip().toString()); + s += fSprite.getTooltip().toString(); } } // check if it's on any attacks for (AttackSprite aSprite : attackSprites) { if (aSprite.isInside(point)) { - txt.append("
"); - txt.append(aSprite.getTooltip().toString()); - txt.append("
"); + f = aSprite.getTooltip().toString(); + t = "" + f + ""; + String col = "" + t + ""; + String row = "" + col + ""; + String table = "" + row + "
"; + s += table; } } @@ -5576,10 +5589,12 @@ public String getHexTooltip(MouseEvent e) { var wreckList = useIsometric() ? isometricWreckSprites : wreckSprites; for (var wSprite : wreckList) { if (wSprite.getPosition().equals(mcoords)) { - txt.append("
"); - txt.append(guiScaledFontHTML()); - txt.append(wSprite.getTooltip()); - txt.append("
"); + f = wSprite.getTooltip().toString(); + t = guiScaledFontHTML() + f + ""; + String col = "" + t + ""; + String row = "" + col + ""; + String table = "" + row + "
"; + s += table; } } @@ -5594,19 +5609,26 @@ public String getHexTooltip(MouseEvent e) { // List only the first four units if (entityCount <= maxShown) { - appendEntityTooltip(txt, entity); + sb = new StringBuffer(); + appendEntityTooltip(sb, entity); + s += sb.toString(); } } // Info block if there are more than 4 units in that hex if (entityCount > maxShown) { - txt.append("
There "); + f = "There "; if (entityCount-maxShown == 1) { - txt.append("is 1 more
unit"); + f += "is 1 more
unit"; } else { - txt.append("are " + (entityCount - maxShown) + " more
units"); + f += "are " + (entityCount - maxShown) + " more
units"; } - txt.append(" in this hex...
"); - txt.append("
"); + f += " in this hex..."; + + t = "" + f + ""; + String col = "" + t + ""; + String row = "" + col + ""; + String table = "" + row + "
"; + s += table; } // Artillery attacks @@ -5626,14 +5648,16 @@ public String getHexTooltip(MouseEvent e) { } } - txt.append("
"); if (aaa.getTurnsTilHit() == 1) { - txt.append(Messages.getString("BoardView1.Tooltip.ArtilleryAttack1", wpName, ammoName)); + t = Messages.getString("BoardView1.Tooltip.ArtilleryAttack1", wpName, ammoName); } else { - txt.append(Messages.getString("BoardView1.Tooltip.ArtilleryAttackN", wpName, - ammoName, aaa.getTurnsTilHit())); + t = Messages.getString("BoardView1.Tooltip.ArtilleryAttackN", wpName, ammoName, aaa.getTurnsTilHit()); } - txt.append("
"); + + String col = "" + t + ""; + String row = "" + col + ""; + String table = "" + row + "
"; + s += table; } // Artillery fire adjustment @@ -5649,11 +5673,11 @@ public String getHexTooltip(MouseEvent e) { } if (amod == TargetRoll.AUTOMATIC_SUCCESS) { - txt.append(Messages.getString("BoardView1.ArtilleryAutohit")); + s += Messages.getString("BoardView1.ArtilleryAutohit"); } else { - txt.append(Messages.getString("BoardView1.ArtilleryAdjustment", amod)); + s += Messages.getString("BoardView1.ArtilleryAdjustment", amod); } - txt.append("
"); + s += "
"; } final Collection shdList = game.getBoard().getSpecialHexDisplay(mcoords); @@ -5672,21 +5696,22 @@ public String getHexTooltip(MouseEvent e) { || (isHexAutoHit && isTypeAutoHit))) { if (shd.getType() == SpecialHexDisplay.Type.PLAYER_NOTE) { if (localPlayer.equals(shd.getOwner())) { - txt.append("Note: "); + s += "Note: "; } else { - txt.append("Note (" + shd.getOwner().getName() + "): "); + s += "Note (" + shd.getOwner().getName() + "): "; } } String buf = shd.getInfo(); - buf = buf.replaceAll("\\n", "
"); - txt.append(buf); - txt.append("
"); + buf = buf.replaceAll("\\n", "
"); + s += buf; + s += "
"; } } } - txt.append("
"); - txt.append(HTML_END); + String d = "
" + s + "
"; + StringBuffer txt = new StringBuffer(); + txt.append(HTML_BEGIN + d + HTML_END); // Check to see if the tool tip is completely empty if (txt.toString().equals(HTML_BEGIN +HTML_END)) { @@ -5697,8 +5722,7 @@ public String getHexTooltip(MouseEvent e) { // (re)set the tooltip dismissal delay time to the preference // value so that the tooltip actually appears if (GUIP.getTooltipDismissDelay() >= 0) { - ToolTipManager.sharedInstance().setDismissDelay( - GUIP.getTooltipDismissDelay()); + ToolTipManager.sharedInstance().setDismissDelay(GUIP.getTooltipDismissDelay()); } else { ToolTipManager.sharedInstance().setDismissDelay(dismissDelay); } @@ -5740,26 +5764,32 @@ public void appendBuildingsTooltip(StringBuffer txt, @Nullable Hex mhex) { return; } Coords mcoords = mhex.getCoords(); + String f = ""; + String s = ""; + String t = ""; // Fuel Tank if (mhex.containsTerrain(Terrains.FUEL_TANK)) { // In the BoardEditor, buildings have no entry in the // buildings list of the board, so get the info from the hex if (clientgui == null) { - txt.append(""; + String row = "" + col + ""; + String table = "
"); - txt.append(Messages.getString("BoardView1.Tooltip.FuelTank", + f = Messages.getString("BoardView1.Tooltip.FuelTank", mhex.terrainLevel(Terrains.FUEL_TANK_ELEV), Terrains.getEditorName(Terrains.FUEL_TANK), mhex.terrainLevel(Terrains.FUEL_TANK_CF), - mhex.terrainLevel(Terrains.FUEL_TANK_MAGN))); + mhex.terrainLevel(Terrains.FUEL_TANK_MAGN)); } else { FuelTank bldg = (FuelTank) game.getBoard().getBuildingAt(mcoords); - txt.append("
"); - txt.append(Messages.getString("BoardView1.Tooltip.FuelTank", + f = Messages.getString("BoardView1.Tooltip.FuelTank", mhex.terrainLevel(Terrains.FUEL_TANK_ELEV), bldg.toString(), - bldg.getCurrentCF(mcoords), bldg.getMagnitude())); + bldg.getCurrentCF(mcoords), bldg.getMagnitude()); } - txt.append("
"); + + t = "" + f + ""; + String col = "
" + t + "
" + row + "
"; + s += table; } // Building @@ -5767,24 +5797,31 @@ public void appendBuildingsTooltip(StringBuffer txt, @Nullable Hex mhex) { // In the BoardEditor, buildings have no entry in the // buildings list of the board, so get the info from the hex if (clientgui == null) { - txt.append(""; + String row = "" + col + ""; + String table = "
"); - txt.append(Messages.getString("BoardView1.Tooltip.Building", + f = Messages.getString("BoardView1.Tooltip.Building", mhex.terrainLevel(Terrains.BLDG_ELEV), Terrains.getEditorName(Terrains.BUILDING), mhex.terrainLevel(Terrains.BLDG_CF), Math.max(mhex.terrainLevel(Terrains.BLDG_ARMOR), 0), - BasementType.getType(mhex.terrainLevel(Terrains.BLDG_BASEMENT_TYPE)).toString())); + BasementType.getType(mhex.terrainLevel(Terrains.BLDG_BASEMENT_TYPE)).toString()); + t = "" + f + ""; + String col = "" + t + "
" + row + "
"; + s += table; } else { Building bldg = game.getBoard().getBuildingAt(mcoords); - txt.append(""; + String row = "" + col + ""; + String table = "
"); - txt.append(Messages.getString("BoardView1.Tooltip.Building", + f = Messages.getString("BoardView1.Tooltip.Building", mhex.terrainLevel(Terrains.BLDG_ELEV), bldg.toString(), bldg.getCurrentCF(mcoords), bldg.getArmor(mcoords), - bldg.getBasement(mcoords).toString())); + bldg.getBasement(mcoords).toString()); if (bldg.getBasementCollapsed(mcoords)) { - txt.append(Messages.getString("BoardView1.Tooltip.BldgBasementCollapsed")); + f += Messages.getString("BoardView1.Tooltip.BldgBasementCollapsed"); } + t = "" + f + ""; + String col = "" + t + "
" + row + "
"; + s += table; } - txt.append(""); } // Bridge @@ -5792,17 +5829,19 @@ public void appendBuildingsTooltip(StringBuffer txt, @Nullable Hex mhex) { // In the BoardEditor, buildings have no entry in the // buildings list of the board, so get the info from the hex if (clientgui == null) { - txt.append(""; + String row = "" + col + ""; + String table = "
"); - txt.append(Messages.getString("BoardView1.Tooltip.Bridge", + f =Messages.getString("BoardView1.Tooltip.Bridge", mhex.terrainLevel(Terrains.BRIDGE_ELEV), Terrains.getEditorName(Terrains.BRIDGE), - mhex.terrainLevel(Terrains.BRIDGE_CF))); + mhex.terrainLevel(Terrains.BRIDGE_CF)); } else { Building bldg = game.getBoard().getBuildingAt(mcoords); - txt.append("
"); - txt.append(Messages.getString("BoardView1.Tooltip.Bridge", - mhex.terrainLevel(Terrains.BRIDGE_ELEV), bldg.toString(), bldg.getCurrentCF(mcoords))); + f = Messages.getString("BoardView1.Tooltip.Bridge", + mhex.terrainLevel(Terrains.BRIDGE_ELEV), bldg.toString(), bldg.getCurrentCF(mcoords)); } - txt.append("
"); + t = "" + f + ""; + String col = "
" + t + "
" + row + "
"; + s += table; } if (game.containsMinefield(mcoords)) { @@ -5814,29 +5853,31 @@ public void appendBuildingsTooltip(StringBuffer txt, @Nullable Hex mhex) { switch (mf.getType()) { case Minefield.TYPE_CONVENTIONAL: case Minefield.TYPE_COMMAND_DETONATED: - txt.append(mf.getName()).append(Messages.getString("BoardView1.minefield")).append("(").append(mf.getDensity()).append(")").append(" ").append(owner); + s += mf.getName() + Messages.getString("BoardView1.minefield") + "(" + mf.getDensity()+ ")" + " " + owner; break; case Minefield.TYPE_VIBRABOMB: if (mf.getPlayerId() == localPlayer.getId()) { - txt.append(mf.getName()).append(Messages.getString("BoardView1.minefield")) - .append("(").append(mf.getDensity()).append(")").append("(") - .append(mf.getSetting()).append(") ").append(owner); + s += mf.getName() + Messages.getString("BoardView1.minefield") + + "(" + mf.getDensity() + ")" + "(" + + mf.getSetting() + ") "+ owner; } else { - txt.append(mf.getName()).append(Messages.getString("BoardView1.minefield")).append("(").append(mf.getDensity()).append(")").append(" ").append(owner); + s += mf.getName() + Messages.getString("BoardView1.minefield") + "(" + mf.getDensity() + ")" + " " + owner; } break; case Minefield.TYPE_ACTIVE: case Minefield.TYPE_INFERNO: - txt.append(mf.getName()).append(Messages.getString("BoardView1.minefield")) - .append("(").append(mf.getDensity()).append(")").append(owner); + s += mf.getName() + Messages.getString("BoardView1.minefield") + + "(" + mf.getDensity() + ")" + owner; break; default: break; } - txt.append("
"); + s +="
"; } } + + txt.append(s); } /** * Appends HTML describing a given Entity aka Unit diff --git a/megamek/src/megamek/client/ui/swing/lobby/MekTableModel.java b/megamek/src/megamek/client/ui/swing/lobby/MekTableModel.java index f0636e2c306..156ddaea640 100644 --- a/megamek/src/megamek/client/ui/swing/lobby/MekTableModel.java +++ b/megamek/src/megamek/client/ui/swing/lobby/MekTableModel.java @@ -190,11 +190,9 @@ private void addCellData(Entity entity) { MapSettings mset = chatLounge.mapSettings; Player lPlayer = clientGui.getClient().getLocalPlayer(); String s = UnitToolTip.getEntityTipLobby(entity, lPlayer, mset).toString(); - String col = "" + s + ""; - String row = "" + col + ""; - s = "" + row + "
"; unitTooltips.add( HTML_BEGIN + s + HTML_END); - pilotTooltips.add(HTML_BEGIN + PilotToolTip.getPilotTipDetailed(entity, true) + PilotToolTip.getCrewAdvs(entity, true) + HTML_END); + s = PilotToolTip.getPilotTipDetailed(entity, true).toString() + PilotToolTip.getCrewAdvs(entity, true).toString(); + pilotTooltips.add(HTML_BEGIN + s + HTML_END); } final boolean rpgSkills = clientGui.getClient().getGame().getOptions().booleanOption(OptionsConstants.RPG_RPG_GUNNERY); if (chatLounge.isCompact()) { diff --git a/megamek/src/megamek/client/ui/swing/tooltip/PilotToolTip.java b/megamek/src/megamek/client/ui/swing/tooltip/PilotToolTip.java index 923aaa672f3..4d9bdc7b559 100644 --- a/megamek/src/megamek/client/ui/swing/tooltip/PilotToolTip.java +++ b/megamek/src/megamek/client/ui/swing/tooltip/PilotToolTip.java @@ -51,10 +51,10 @@ public static StringBuilder getPilotTipShort(Entity entity, boolean showPortrait // PRIVATE private static StringBuilder getPilotTip(final Entity entity, boolean detailed, boolean showPortrait, boolean showDefaultPortrait) { - StringBuilder result = new StringBuilder(); + String s = ""; if (!detailed) { - result.append("
"); + s += "
"; } // The crew info (names etc.) and portraits, if shown, are placed @@ -66,29 +66,33 @@ private static StringBuilder getPilotTip(final Entity entity, boolean detailed, cols += crewInfoCell(entity).toString(); String row = "" + cols + ""; - result.append("" + row + "
"); + s += "" + row + "
"; + s = "
" + s + "
"; if (!detailed) { - result.append("
"); + s += "
"; } else { - result.append(scaledHTMLSpacer(3)); + s += scaledHTMLSpacer(3); } - return result; + return new StringBuilder().append(s); } /** The crew advantages and MD */ public static StringBuilder getCrewAdvs(Entity entity, boolean detailed) { - StringBuilder result = new StringBuilder(); - result.append(scaledHTMLSpacer(3)); - result.append(crewAdvs(entity, detailed)); + String s = ""; + String f = ""; + + f = crewAdvs(entity, detailed).toString(); + s = scaledHTMLSpacer(3) + f + ""; - return result; + return new StringBuilder().append(s); } /** Returns a tooltip part with names and skills of the crew. */ private static StringBuilder crewInfoCell(final Entity entity) { Crew crew = entity.getCrew(); Game game = entity.getGame(); + String f = ""; String s = ""; // Name / Callsign and Status for each crew member @@ -98,8 +102,8 @@ private static StringBuilder crewInfoCell(final Entity entity) { } if ((crew.getNickname(i) != null) && !crew.getNickname(i).isBlank()) { - String t = "'" + crew.getNickname(i).toUpperCase() + "'"; - s += guiScaledFontHTML(UIUtil.uiNickColor()) + t + ""; + f = "'" + crew.getNickname(i).toUpperCase() + "'"; + s += guiScaledFontHTML(UIUtil.uiNickColor()) + f + ""; } else if ((crew.getName(i) != null) && !crew.getName(i).isBlank()) { s += crew.getName(i); } else { @@ -122,15 +126,15 @@ private static StringBuilder crewInfoCell(final Entity entity) { s = guiScaledFontHTML() + s + ""; - StringBuilder result = new StringBuilder(); - result.append("" + s + ""); - return result; + String col = "" + s + ""; + return new StringBuilder().append(col); } /** Returns a tooltip part with crew portraits. */ private static StringBuilder crewPortraits(final Entity entity, boolean showDefaultPortrait) { Crew crew = entity.getCrew(); - StringBuilder result = new StringBuilder(); + String col = ""; + for (int i = 0; i < crew.getSlotCount(); i++) { if ((!showDefaultPortrait) && crew.getPortrait(i).isDefault()) { continue; @@ -151,12 +155,13 @@ private static StringBuilder crewPortraits(final Entity entity, boolean showDefa bufferedImage.getGraphics().drawImage(portrait, 0, 0, null); ImageIO.write(bufferedImage, "PNG", tempFile); } - result.append(""); + String img = ""; + col += "" + img + ""; } catch (Exception e) { LogManager.getLogger().error("", e); } } - return result; + return new StringBuilder().append(col); } /** @@ -165,12 +170,12 @@ private static StringBuilder crewPortraits(final Entity entity, boolean showDefa * groups and number of advantages per group are given. */ private static StringBuilder crewAdvs(final Entity entity, boolean detailed) { + String s = ""; + String f = ""; Crew crew = entity.getCrew(); - StringBuilder result = new StringBuilder(); - result.append(guiScaledFontHTML(uiQuirksColor(), UnitToolTip.TT_SMALLFONT_DELTA)); - result.append(getOptionList(crew.getOptions().getGroups(), crew::countOptions, detailed)); - result.append(""); - return result; + f = getOptionList(crew.getOptions().getGroups(), crew::countOptions, detailed).toString(); + s = guiScaledFontHTML(uiQuirksColor(), UnitToolTip.TT_SMALLFONT_DELTA) + f + ""; + return new StringBuilder().append(s); } } diff --git a/megamek/src/megamek/client/ui/swing/tooltip/UnitToolTip.java b/megamek/src/megamek/client/ui/swing/tooltip/UnitToolTip.java index fb576a0324a..b8eaa629c76 100644 --- a/megamek/src/megamek/client/ui/swing/tooltip/UnitToolTip.java +++ b/megamek/src/megamek/client/ui/swing/tooltip/UnitToolTip.java @@ -74,107 +74,113 @@ private static StringBuilder getEntityTipTable(Entity entity, Player localPlayer return new StringBuilder(msg_senorreturn); } - StringBuilder result = new StringBuilder(); + String s = ""; + String f = ""; + String p = ""; Game game = entity.getGame(); // Unit Chassis and Player Player owner = game.getPlayer(entity.getOwnerId()); - result.append(guiScaledFontHTML(entity.getOwner().getColour().getColour())); String msg_clanbrackets =Messages.getString("BoardView1.Tooltip.ClanBrackets"); String clanStr = entity.isClan() && !entity.isMixedTech() ? " " + msg_clanbrackets + " " : ""; - result.append(entity.getChassis()).append(clanStr); - result.append(" (").append((int)entity.getWeight()).append("t)"); - result.append("  " + entity.getEntityTypeName(entity.getEntityType())); - result.append("
").append(owner.getName()); - result.append(UIUtil.guiScaledFontHTML(UIUtil.uiGray())); - result.append(MessageFormat.format(" [ID: {0}] ", entity.getId())); - result.append("\n"); + f = entity.getChassis() + clanStr; + f += " (" + (int) entity.getWeight() + "t)"; + f += "  " + entity.getEntityTypeName(entity.getEntityType()); + f += "
" + owner.getName(); + String msg_id = MessageFormat.format(" [ID: {0}]", entity.getId()); + f += UIUtil.guiScaledFontHTML(UIUtil.uiGray()) + msg_id + ""; + p += guiScaledFontHTML(entity.getOwner().getColour().getColour()) + f + ""; // Pilot; in the lounge the pilot is separate so don't add it there if (details && (mapSettings != null)) { - result.append(deploymentWarnings(entity, localPlayer, mapSettings)); - result.append("
"); + p += deploymentWarnings(entity, localPlayer, mapSettings) + "
"; } else { if (pilotInfo) { - result.append(forceEntry(entity, localPlayer)); + p += forceEntry(entity, localPlayer); } - result.append(inGameValues(entity, localPlayer)); + p += inGameValues(entity, localPlayer); if (pilotInfo) { - result.append(PilotToolTip.getPilotTipShort(entity, GUIP.getBoolean(GUIPreferences.SHOW_PILOT_PORTRAIT_TT))); + p += PilotToolTip.getPilotTipShort(entity, GUIP.getBoolean(GUIPreferences.SHOW_PILOT_PORTRAIT_TT)); } else { - result.append("
"); + p += "
"; } } - result.append("\n"); - + + s += p; + p = ""; + // An empty squadron should not show any info if (entity instanceof FighterSquadron && entity.getLoadedUnits().isEmpty()) { - return result; + String col = "" + s + ""; + String row = "" + col + ""; + String table = "" + row + "
"; + return new StringBuilder().append(table); } // Static entity values like move capability - result.append(guiScaledFontHTML()); - result.append(entityValues(entity)); - result.append("\n"); + f = entityValues(entity).toString(); + p += guiScaledFontHTML() + f + ""; // Status bar visual representation of armor and IS if (GUIP.getBoolean(GUIPreferences.SHOW_ARMOR_MINIVIS_TT)) { - result.append(scaledHTMLSpacer(3) + "\n"); - result.append(addArmorMiniVisToTT(entity)); + p += addArmorMiniVisToTT(entity); } // Weapon List if (GUIP.getBoolean(GUIPreferences.SHOW_WPS_IN_TT)) { - result.append(scaledHTMLSpacer(3) + "\n"); - result.append(guiScaledFontHTML() + "\n"); - result.append(weaponList(entity)); - result.append(ecmInfo(entity)); - result.append("\n"); + f = weaponList(entity).toString(); + f += ecmInfo(entity).toString(); + p += guiScaledFontHTML() + f + ""; } + s += p; + p = ""; + // Bomb List - result.append(bombList(entity)); + s += bombList(entity); // StratOps quirks, chassis and weapon if (game.getOptions().booleanOption(OptionsConstants.ADVANCED_STRATOPS_QUIRKS)) { - result.append(scaledHTMLSpacer(3) + "\n"); - result.append(guiScaledFontHTML(uiQuirksColor(), TT_SMALLFONT_DELTA)); + f = ""; String quirksList = getOptionList(entity.getQuirks().getGroups(), entity::countQuirks, details); if (!quirksList.isEmpty()) { - result.append(quirksList); + f = quirksList; } for (Mounted weapon: entity.getWeaponList()) { String wpQuirksList = getOptionList(weapon.getQuirks().getGroups(), grp -> weapon.countQuirks(), (e) -> weapon.getDesc(), details); if (!wpQuirksList.isEmpty()) { // Line break after weapon name not useful here - result.append(wpQuirksList.replace(":\n
", ":\n")); + f += wpQuirksList.replace(":
", ":"); } } - result.append("\n"); + p += guiScaledFontHTML(uiQuirksColor(), TT_SMALLFONT_DELTA) + f + ""; } // Partial repairs String partialList = getOptionList(entity.getPartialRepairs().getGroups(), grp -> entity.countPartialRepairs(), details); if (!partialList.isEmpty()) { - result.append(scaledHTMLSpacer(3) + "\n"); - result.append(guiScaledFontHTML(uiPartialRepairColor(), TT_SMALLFONT_DELTA)); - result.append(partialList); - result.append("\n"); + f = partialList; + p += guiScaledFontHTML(uiPartialRepairColor(), TT_SMALLFONT_DELTA) + f + ""; } if (!entity.getLoadedUnits().isEmpty()) { - result.append(scaledHTMLSpacer(3) + "\n"); - result.append(carriedUnits(entity)); + p += carriedUnits(entity); } if (details && entity.hasAnyC3System()) { - result.append(scaledHTMLSpacer(3) + "\n"); - result.append(c3Info(entity)); + p += c3Info(entity); } - return result; + s += p; + p = ""; + + String col = "" + s + ""; + String row = "" + col + ""; + String table = "" + row + "
"; + + return new StringBuilder().append(table); } private static boolean hideArmorLocation(Entity entity, int location) { @@ -188,17 +194,19 @@ private static String locationHeader(Entity entity, int location) { } private static StringBuilder sysCrits(Entity entity, int type, int index, int loc, String l) { - StringBuilder result = new StringBuilder();; + String s = ""; + String f = ""; int good = entity.getGoodCriticals(type, index, loc); int hits = entity.getHitCriticals(type, index, loc); boolean bad = (entity.getBadCriticals(type,index, loc) > 0); + if ((good + hits) > 0) { - result.append(guiScaledFontHTML(TT_SMALLFONT_DELTA)); - result.append("  " + l + ": "); - result.append("\n"); - result.append(systemBar(good, hits, bad)); + f = "  " + l + ": "; + s = guiScaledFontHTML(TT_SMALLFONT_DELTA) + f + ""; + s += systemBar(good, hits, bad); } - return result; + + return new StringBuilder().append(s); } /** Returns the graphical Armor representation. */ @@ -208,8 +216,13 @@ private static StringBuilder addArmorMiniVisToTT(Entity entity) { armorChar = GUIP.getString(GUIPreferences.ADVANCED_ARMORMINI_CAP_ARMOR_CHAR); } String internalChar = GUIP.getString(GUIPreferences.ADVANCED_ARMORMINI_IS_CHAR); - StringBuilder result = new StringBuilder(); - result.append("\n\n"); + String f = ""; + String col1 = ""; + String col2 = ""; + String col3 = ""; + String row = ""; + String rows = ""; + for (int loc = 0 ; loc < entity.locations(); loc++) { // do not show locations that do not support/have armor/internals like HULL on Aero if (hideArmorLocation(entity, loc)) { @@ -217,38 +230,31 @@ private static StringBuilder addArmorMiniVisToTT(Entity entity) { } boolean locDestroyed = (entity.getInternal(loc) == IArmorState.ARMOR_DOOMED || entity.getInternal(loc) == IArmorState.ARMOR_DESTROYED); - result.append("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"); + + col1 = ""; + col2 = ""; + col3 = ""; + row = "" + col1 + col2 + col3 + ""; + rows += row; } - result.append("\n
\n"); + if (locDestroyed) { // Destroyed location - result.append("\n\n"); - result.append(guiScaledFontHTML(TT_SMALLFONT_DELTA)); - result.append("  " + locationHeader(entity, loc) + ": "); - result.append("\n\n"); - result.append(destroyedLocBar(entity.getOArmor(loc, true))); - result.append("\n"); + col1 = ""; + f = "  " + locationHeader(entity, loc) + ": "; + col2 = guiScaledFontHTML(TT_SMALLFONT_DELTA) + f + ""; + col2 += destroyedLocBar(entity.getOArmor(loc, true)).toString(); } else { // Rear armor if (entity.hasRearArmor(loc)) { - result.append(guiScaledFontHTML(TT_SMALLFONT_DELTA)); String msg_abbr_rear = Messages.getString("BoardView1.Tooltip.AbbreviationRear"); - result.append("  " + locationHeader(entity, loc) + msg_abbr_rear + " "); - result.append("\n\n"); - result.append(intactLocBar(entity.getOArmor(loc, true), entity.getArmor(loc, true), armorChar)); - result.append("\n"); + f = "  " + locationHeader(entity, loc) + msg_abbr_rear + " "; + col1 = guiScaledFontHTML(TT_SMALLFONT_DELTA) + f + ""; + col1 += intactLocBar(entity.getOArmor(loc, true), entity.getArmor(loc, true), armorChar).toString(); } else { // No rear armor: empty table cells instead // At small font sizes, writing one character at the correct font size is // necessary to prevent the table rows from being spaced non-beautifully - result.append(guiScaledFontHTML(TT_SMALLFONT_DELTA) + " \n\n"); - result.append(guiScaledFontHTML(TT_SMALLFONT_DELTA) + " \n\n"); + col1 = guiScaledFontHTML(TT_SMALLFONT_DELTA) + " " + ""; } // Front armor - result.append(guiScaledFontHTML(TT_SMALLFONT_DELTA)); - result.append("  " + locationHeader(entity, loc) + ": "); - result.append("\n\n"); - result.append(intactLocBar(entity.getOInternal(loc), entity.getInternal(loc), internalChar)); - result.append(intactLocBar(entity.getOArmor(loc), entity.getArmor(loc), armorChar)); - result.append("\n"); + f = "  " + locationHeader(entity, loc) + ": "; + col2 = guiScaledFontHTML(TT_SMALLFONT_DELTA) + f + ""; + col2 += intactLocBar(entity.getOInternal(loc), entity.getInternal(loc), internalChar).toString(); + col2 += intactLocBar(entity.getOArmor(loc), entity.getArmor(loc), armorChar).toString(); } String msg_abbr_sensors = Messages.getString("BoardView1.Tooltip.AbbreviationSensors"); @@ -264,51 +270,53 @@ private static StringBuilder addArmorMiniVisToTT(Entity entity) { String msg_abbr_lowerleg = Messages.getString("BoardView1.Tooltip.AbbreviationLowerLeg"); String msg_abbr_foot = Messages.getString("BoardView1.Tooltip.AbbreviationLowerFoot"); - switch (loc) { case 0: - result.append(sysCrits(entity, CriticalSlot.TYPE_SYSTEM, Mech.SYSTEM_SENSORS, loc, msg_abbr_sensors)); - result.append(sysCrits(entity, CriticalSlot.TYPE_SYSTEM, Mech.SYSTEM_LIFE_SUPPORT, loc, msg_abbr_lifesupport)); - result.append("\n"); + col3 = sysCrits(entity, CriticalSlot.TYPE_SYSTEM, Mech.SYSTEM_SENSORS, loc, msg_abbr_sensors).toString(); + col3 += sysCrits(entity, CriticalSlot.TYPE_SYSTEM, Mech.SYSTEM_LIFE_SUPPORT, loc, msg_abbr_lifesupport).toString(); break; case 1: - result.append(sysCrits(entity, CriticalSlot.TYPE_SYSTEM, Mech.SYSTEM_ENGINE, loc, msg_abbr_engine)); - result.append(sysCrits(entity, CriticalSlot.TYPE_SYSTEM, Mech.SYSTEM_GYRO, loc, msg_abbr_gyro)); - result.append(sysCrits(entity, CriticalSlot.TYPE_SYSTEM, Mech.SYSTEM_SENSORS, loc, msg_abbr_sensors)); - result.append(sysCrits(entity, CriticalSlot.TYPE_SYSTEM, Mech.SYSTEM_LIFE_SUPPORT, loc, msg_abbr_lifesupport)); - result.append("\n"); + col3 = sysCrits(entity, CriticalSlot.TYPE_SYSTEM, Mech.SYSTEM_ENGINE, loc, msg_abbr_engine).toString(); + col3 += sysCrits(entity, CriticalSlot.TYPE_SYSTEM, Mech.SYSTEM_GYRO, loc, msg_abbr_gyro).toString(); + col3 += sysCrits(entity, CriticalSlot.TYPE_SYSTEM, Mech.SYSTEM_SENSORS, loc, msg_abbr_sensors).toString(); + col3 += sysCrits(entity, CriticalSlot.TYPE_SYSTEM, Mech.SYSTEM_LIFE_SUPPORT, loc, msg_abbr_lifesupport).toString(); break; case 2: case 3: - result.append(sysCrits(entity, CriticalSlot.TYPE_SYSTEM, Mech.SYSTEM_ENGINE, loc, msg_abbr_engine)); - result.append(sysCrits(entity, CriticalSlot.TYPE_SYSTEM, Mech.SYSTEM_LIFE_SUPPORT, loc, msg_abbr_gyro)); - result.append("\n"); + col3 = sysCrits(entity, CriticalSlot.TYPE_SYSTEM, Mech.SYSTEM_ENGINE, loc, msg_abbr_engine).toString(); + col3 += sysCrits(entity, CriticalSlot.TYPE_SYSTEM, Mech.SYSTEM_LIFE_SUPPORT, loc, msg_abbr_gyro).toString(); break; case 4: case 5: - result.append(sysCrits(entity, CriticalSlot.TYPE_SYSTEM, Mech.ACTUATOR_SHOULDER, loc, msg_abbr_shoulder)); - result.append(sysCrits(entity, CriticalSlot.TYPE_SYSTEM, Mech.ACTUATOR_UPPER_ARM, loc, msg_abbr_upperarm)); - result.append(sysCrits(entity, CriticalSlot.TYPE_SYSTEM, Mech.ACTUATOR_LOWER_ARM, loc, msg_abbr_lowerarm)); - result.append(sysCrits(entity, CriticalSlot.TYPE_SYSTEM, Mech.ACTUATOR_HAND, loc, msg_abbr_hand)); - result.append(sysCrits(entity, CriticalSlot.TYPE_SYSTEM, Mech.ACTUATOR_HIP, loc, msg_abbr_hip)); - result.append(sysCrits(entity, CriticalSlot.TYPE_SYSTEM, Mech.ACTUATOR_UPPER_LEG, loc, msg_abbr_upperleg)); - result.append(sysCrits(entity, CriticalSlot.TYPE_SYSTEM, Mech.ACTUATOR_LOWER_LEG, loc, msg_abbr_lowerleg)); - result.append(sysCrits(entity, CriticalSlot.TYPE_SYSTEM, Mech.ACTUATOR_FOOT, loc, msg_abbr_foot)); - result.append("\n"); + col3 = sysCrits(entity, CriticalSlot.TYPE_SYSTEM, Mech.ACTUATOR_SHOULDER, loc, msg_abbr_shoulder).toString(); + col3 += sysCrits(entity, CriticalSlot.TYPE_SYSTEM, Mech.ACTUATOR_UPPER_ARM, loc, msg_abbr_upperarm).toString(); + col3 += sysCrits(entity, CriticalSlot.TYPE_SYSTEM, Mech.ACTUATOR_LOWER_ARM, loc, msg_abbr_lowerarm).toString(); + col3 += sysCrits(entity, CriticalSlot.TYPE_SYSTEM, Mech.ACTUATOR_HAND, loc, msg_abbr_hand).toString(); + col3 += sysCrits(entity, CriticalSlot.TYPE_SYSTEM, Mech.ACTUATOR_HIP, loc, msg_abbr_hip).toString(); + col3 += sysCrits(entity, CriticalSlot.TYPE_SYSTEM, Mech.ACTUATOR_UPPER_LEG, loc, msg_abbr_upperleg).toString(); + col3 += sysCrits(entity, CriticalSlot.TYPE_SYSTEM, Mech.ACTUATOR_LOWER_LEG, loc, msg_abbr_lowerleg).toString(); + col3 += sysCrits(entity, CriticalSlot.TYPE_SYSTEM, Mech.ACTUATOR_FOOT, loc, msg_abbr_foot).toString(); break; case 6: case 7: - result.append(sysCrits(entity, CriticalSlot.TYPE_SYSTEM, Mech.ACTUATOR_HIP, loc, msg_abbr_hip)); - result.append(sysCrits(entity, CriticalSlot.TYPE_SYSTEM, Mech.ACTUATOR_UPPER_LEG, loc, msg_abbr_upperleg)); - result.append(sysCrits(entity, CriticalSlot.TYPE_SYSTEM, Mech.ACTUATOR_LOWER_LEG, loc, msg_abbr_lowerleg)); - result.append(sysCrits(entity, CriticalSlot.TYPE_SYSTEM, Mech.ACTUATOR_FOOT, loc, msg_abbr_foot)); - result.append("\n"); + col3 = sysCrits(entity, CriticalSlot.TYPE_SYSTEM, Mech.ACTUATOR_HIP, loc, msg_abbr_hip).toString(); + col3 += sysCrits(entity, CriticalSlot.TYPE_SYSTEM, Mech.ACTUATOR_UPPER_LEG, loc, msg_abbr_upperleg).toString(); + col3 += sysCrits(entity, CriticalSlot.TYPE_SYSTEM, Mech.ACTUATOR_LOWER_LEG, loc, msg_abbr_lowerleg).toString(); + col3 += sysCrits(entity, CriticalSlot.TYPE_SYSTEM, Mech.ACTUATOR_FOOT, loc, msg_abbr_foot).toString(); break; } - result.append("
" + col1 + "" + col2 + "" + col3 + "
\n"); - return result; + + String tbody = "" + rows + ""; + String table = "" + tbody + "
"; + + return new StringBuilder().append(table); } /** @@ -342,8 +350,9 @@ private static StringBuilder locBar(int orig, int curr, String dChar, boolean de if (orig == 0) { return new StringBuilder(""); } - - StringBuilder result = new StringBuilder(); + + String s = ""; + String f = ""; Color colorIntact = GUIP.getColor(GUIPreferences.ADVANCED_ARMORMINI_COLOR_INTACT); Color colorPartialDmg = GUIP.getColor(GUIPreferences.ADVANCED_ARMORMINI_COLOR_PARTIAL_DMG); Color colorDamaged = GUIP.getColor(GUIPreferences.ADVANCED_ARMORMINI_COLOR_DAMAGED); @@ -365,32 +374,34 @@ private static StringBuilder locBar(int orig, int curr, String dChar, boolean de } if (numIntact > 0) { - result.append(guiScaledFontHTML(colorIntact, TT_SMALLFONT_DELTA)); if (numIntact > 15 && numIntact + numDmgd > 30) { int tensIntact = (numIntact - 1) / 10; String msg_x = Messages.getString("BoardView1.Tooltip.X"); - result.append(dChar + msg_x + tensIntact * 10 + " "); - result.append(repeat(dChar, numIntact - 10 * tensIntact) + "\n"); + f = dChar + msg_x + tensIntact * 10; + f += repeat(dChar, numIntact - 10 * tensIntact); + s += guiScaledFontHTML(colorIntact, TT_SMALLFONT_DELTA) + f + ""; } else { - result.append(repeat(dChar, numIntact) + "\n"); + f = repeat(dChar, numIntact); + s += guiScaledFontHTML(colorIntact, TT_SMALLFONT_DELTA) + f + ""; } } if (numPartial > 0) { - result.append(guiScaledFontHTML(colorPartialDmg, TT_SMALLFONT_DELTA)); - result.append(repeat(dChar, numPartial) + "\n"); + f = repeat(dChar, numPartial); + s += guiScaledFontHTML(colorPartialDmg, TT_SMALLFONT_DELTA) + f + ""; } if (numDmgd > 0) { - result.append(guiScaledFontHTML(colorDamaged, TT_SMALLFONT_DELTA)); if (numDmgd > 15 && numIntact + numDmgd > 30) { int tensDmgd = (numDmgd - 1) / 10; String msg_x = Messages.getString("BoardView1.Tooltip.X"); - result.append(dChar + msg_x + tensDmgd * 10 + " "); - result.append(repeat(dChar, numDmgd - 10 * tensDmgd) + "\n"); + f = dChar + msg_x + tensDmgd * 10; + f += repeat(dChar, numDmgd - 10 * tensDmgd); + s += guiScaledFontHTML(colorIntact, TT_SMALLFONT_DELTA) + f + ""; } else { - result.append(repeat(dChar, numDmgd) + "\n"); + f = repeat(dChar, numDmgd); + s += guiScaledFontHTML(colorDamaged, TT_SMALLFONT_DELTA) + f + ""; } } - return result; + return new StringBuilder().append(s); } private static StringBuilder systemBar(int good, int bad, boolean destroyed) { @@ -399,7 +410,8 @@ private static StringBuilder systemBar(int good, int bad, boolean destroyed) { return new StringBuilder(""); } - StringBuilder result = new StringBuilder(); + String s = ""; + String f = ""; Color colorIntact = GUIP.getColor(GUIPreferences.ADVANCED_ARMORMINI_COLOR_INTACT); Color colorDamaged = GUIP.getColor(GUIPreferences.ADVANCED_ARMORMINI_COLOR_DAMAGED); String dChar = GUIP.getString(GUIPreferences.ADVANCED_ARMORMINI_DESTROYED_CHAR); @@ -407,21 +419,18 @@ private static StringBuilder systemBar(int good, int bad, boolean destroyed) { if (good > 0) { if (!destroyed) { - result.append(guiScaledFontHTML(colorIntact, TT_SMALLFONT_DELTA)); - result.append(repeat(iChar, good)); - result.append("\n"); + f = repeat(iChar, good); + s += guiScaledFontHTML(colorIntact, TT_SMALLFONT_DELTA) + f + ""; } else { - result.append(guiScaledFontHTML(colorDamaged, TT_SMALLFONT_DELTA)); - result.append(repeat(iChar, good)); - result.append("\n"); + f = repeat(iChar, good); + s += guiScaledFontHTML(colorDamaged, TT_SMALLFONT_DELTA) + f + ""; } } if (bad > 0) { - result.append(guiScaledFontHTML(colorDamaged, TT_SMALLFONT_DELTA)); - result.append(repeat(dChar, bad)); - result.append("\n"); + f =repeat(dChar, bad); + s += guiScaledFontHTML(colorDamaged, TT_SMALLFONT_DELTA) + f + ""; } - return result; + return new StringBuilder().append(s); } private static class WeaponInfo { @@ -578,18 +587,20 @@ private static StringBuilder weaponList(Entity entity) { } // Print to Tooltip - StringBuilder result = new StringBuilder(); + String col1 = ""; + String col2 = ""; + String row = ""; + String rows = ""; boolean subsequentLine = false; // Display sorted by weapon name var wps = new ArrayList<>(wpInfos.values()); wps.sort(Comparator.comparing(w -> w.sortString)); int totalWeaponCount = wpInfos.values().stream().filter(i -> i.ammos.isEmpty()).mapToInt(wp -> wp.count).sum(); boolean hasMultiples = wpInfos.values().stream().mapToInt(wp -> wp.count).anyMatch(c -> c > 1); - result.append(" 5 && hasMultiples) { // more than 5 weapons: group and list with a multiplier "4 x Small Laser" - result.append("\n\n\n\n"); } else { + col1 = ""; + col2 = ""; // few weapons: list each weapon separately for (int i = 0; i < currentEquip.count; i++) { - result.append("\n\n\n\n"); + col2 += addToTT("Weapon", false, currentEquip.count, techBase, nameStr, destStr).toString(); + col2 += weaponModifier(isDestroyed, currentEquip); + if (isDestroyed) { + col2 = "" + col2 + ""; + } + col2 += "
"; } - } - result.append("\n"); + }; + + col1 = guiScaledFontHTML(uiTTWeaponColor()) + col1 + ""; + col1 = ""; + col2 = guiScaledFontHTML(uiTTWeaponColor()) + col2 + ""; + col2 = ""; + row = "" + col1 + col2 + ""; } + + rows += row; } - result.append("
\n"); if (currentEquip.count > 1) { String msg_x = Messages.getString("BoardView1.Tooltip.X"); - result.append(currentEquip.count + " " + msg_x + " "); + col1 = currentEquip.count + " " + msg_x + " "; + } else { + col1 = ""; + } + + col2 = addToTT("Weapon", false, currentEquip.count, techBase, nameStr, destStr).toString(); + col2 += weaponModifier(isDestroyed, currentEquip); + if (isDestroyed) { + col2 = "" + col2 + ""; } - result.append("\n\n"); - result.append(addToTT("Weapon", false, currentEquip.count, techBase, nameStr, destStr)); - result.append(weaponModifier(isDestroyed, currentEquip)); - result.append("\n
\n\n"); - result.append(addToTT("Weapon", false, currentEquip.count, techBase, nameStr, destStr)); - result.append(weaponModifier(isDestroyed, currentEquip)); - result.append("\n
" + col1 + "" + col2 + "
\n"); - return result; + + String tbody = "" + rows + ""; + String table = "" + tbody + "
"; + + return new StringBuilder().append(table); } private static StringBuilder bombList(Entity entity) { - StringBuilder result = new StringBuilder(); + String col1 = ""; + String col2 = ""; + String col3= ""; + String row = ""; + String rows = ""; + String table = ""; if (entity.isBomber()) { int[] loadout = { }; @@ -664,50 +695,68 @@ private static StringBuilder bombList(Entity entity) { } else { loadout = entity.getBombLoadout(); } - result.append(" 0) { - result.append("\n\n\n\n\n"); + col1 = String.valueOf(count); + col2 = " x "; + col3 = BombType.getBombName(i); + + col1 = guiScaledFontHTML(uiTTWeaponColor()) + col1 + ""; + col1 = ""; + col2 = guiScaledFontHTML(uiTTWeaponColor()) + col2 + ""; + col2 = ""; + col3 = guiScaledFontHTML(uiTTWeaponColor()) + col3 + ""; + col3 = ""; + row = "" + col1 + col2 + col3 + ""; + } else { + row = ""; } + + rows += row; } - result.append("
\n"); - result.append(count + "\n"); - result.append("\n"); - result.append(" x \n"); - result.append("\n"); - result.append(BombType.getBombName(i) + "\n"); - result.append("
" + col1 + "" + col2 + "" + col3 + "
\n"); + + String tbody = "" + rows + ""; + table = "" + tbody + "
"; } - return result; + return new StringBuilder().append(table); } private static String weaponModifier(boolean isDestroyed, WeaponInfo currentEquip) { if (isDestroyed) { // Ends the strikethrough that is added for destroyed weapons - return ""; + return ""; } else if (currentEquip.isHotloaded) { String msg_hotloaded = Messages.getString("BoardView1.Tooltip.HotLoaded"); - return " \u22EF " + msg_hotloaded + ""; + String s = " " + msg_hotloaded + ""; + return " \u22EF" + s; } else if (currentEquip.isRapidFire) { String msg_rapidfire = Messages.getString("BoardView1.Tooltip.Rapidfire"); - return " \u22EF " + msg_rapidfire + ""; + String s = " " + msg_rapidfire + ""; + return " \u22EF" + s; } return ""; } /** Returns the ammo line(s) for the ammo of one weapon type. */ private static StringBuilder createAmmoEntry(WeaponInfo ammoInfo) { - StringBuilder result = new StringBuilder(); + String col1 = ""; + String col2 = ""; + String row = ""; + String rows = ""; + int totalAmmo = ammoInfo.ammos.values().stream().mapToInt(n -> n).sum(); if (totalAmmo == 0 && ammoInfo.ammoActiveWeaponCount > 0) { - result.append(guiScaledFontHTML(uiYellow(), -0.2f)); - result.append("\n\n\n\n"); String msg_outofammo = Messages.getString("BoardView1.Tooltip.OutOfAmmo"); - result.append("      " + msg_outofammo); - result.append("\n\n"); + col2 = "      " + msg_outofammo; + col1 = "" + col1 + ""; + col2 = guiScaledFontHTML(uiYellow(), -0.2f) + col2 + ""; + col2 = "" + col2 + ""; + row = "" + col1 + col2 + ""; + rows += row; } else { for (Entry ammo: ammoInfo.ammos.entrySet()) { String msg_standard = Messages.getString("BoardView1.Tooltip.Standard"); @@ -716,52 +765,54 @@ private static StringBuilder createAmmoEntry(WeaponInfo ammoInfo) { if (ammo.getValue() == 0) { continue; } - result.append("\n\n\n\n"); - result.append(guiScaledFontHTML(uiGreen(), -0.2f)); - result.append("      "); + col1 = ""; + col2 = "      "; String msg_shots = Messages.getString("BoardView1.Tooltip.Shots"); if (ammoInfo.ammoActiveWeaponCount > 1) { // Remaining ammo and multiple weapons using it - result.append(ammoName); + col2 += ammoName; String msg_turns = Messages.getString("BoardView1.Tooltip.Turns"); - result.append(ammo.getValue() / ammoInfo.ammoActiveWeaponCount).append(" " + msg_turns); - result.append(" (" + ammo.getValue() + " " + msg_shots + ")"); + col2 += ammo.getValue() / ammoInfo.ammoActiveWeaponCount + " " + msg_turns; + col2 += " (" + ammo.getValue() + " " + msg_shots + ")"; } else { // Remaining ammo and only one weapon using it - result.append(ammoName).append(ammo.getValue()).append(" " + msg_shots); + col2 += ammoName + ammo.getValue() + " " + msg_shots; } - result.append("\n\n\n"); + + col1 = "" + col1 + ""; + col2 = guiScaledFontHTML(uiYellow(), -0.2f) + col2 + ""; + col2 = "" + col2 + ""; + row = "" + col1 + col2 + ""; + rows += row; } } - return result; + + return new StringBuilder().append(rows); } /** Returns a line showing ECM / ECCM. */ private static StringBuilder ecmInfo(Entity entity) { - StringBuilder result = new StringBuilder(); - result.append(guiScaledFontHTML()); + String s = ""; if (entity.hasActiveECM()) { - result.append(ECM_SIGN).append(" "); String msg_ecmsource = Messages.getString("BoardView1.ecmSource"); - result.append(msg_ecmsource); + s += ECM_SIGN + " " + msg_ecmsource; } if (entity.hasActiveECCM()) { - result.append(ECM_SIGN).append(" "); String msg_eccmsource = Messages.getString("BoardView1.eccmSource"); - result.append(msg_eccmsource); + s += ECM_SIGN+ " " +msg_eccmsource; } - result.append("\n"); - return result; + + s = guiScaledFontHTML() + s + ""; + + return new StringBuilder().append(s); } /** Returns values that only are relevant when in-game such as heat. */ private static StringBuilder inGameValues(Entity entity, Player localPlayer) { - StringBuilder result = new StringBuilder(); Game game = entity.getGame(); boolean isGunEmplacement = entity instanceof GunEmplacement; - - // Coloring and italic to make these transient entries stand out - result.append(guiScaledFontHTML(uiLightViolet()) + "\n\n"); + String s = ""; + String f = ""; // BV Info // Hidden for invisible units when in double blind and hide enemy bv is selected @@ -774,145 +825,140 @@ private static StringBuilder inGameValues(Entity entity, Player localPlayer) { int currentBV = entity.calculateBattleValue(false, false); int initialBV = entity.getInitialBV(); double percentage = (double) currentBV / initialBV; - result.append(addToTT("BV", BR, currentBV, initialBV, percentage)); + s += addToTT("BV", BR, currentBV, initialBV, percentage).toString(); } String damageLevel; switch (entity.getDamageLevel()) { case Entity.DMG_CRIPPLED: String msg_crippled = Messages.getString("BoardView1.Tooltip.Crippled"); - damageLevel = guiScaledFontHTML(GUIP.getWarningColor()); - damageLevel += "  " + msg_crippled; - damageLevel += "\n"; + f = "  " + msg_crippled; + damageLevel = guiScaledFontHTML(GUIP.getWarningColor()) + f + ""; break; case Entity.DMG_HEAVY: String msg_heavydmg = Messages.getString("BoardView1.Tooltip.HeavyDmg"); - damageLevel = guiScaledFontHTML(GUIP.getWarningColor()); - damageLevel += "  " + msg_heavydmg; - damageLevel += "\n"; + f = "  " + msg_heavydmg; + damageLevel = guiScaledFontHTML(GUIP.getWarningColor()) + f + ""; break; case Entity.DMG_MODERATE: String msg_moderatedmg = Messages.getString("BoardView1.Tooltip.ModerateDmg"); - damageLevel = "  "+ msg_moderatedmg + "\n"; + damageLevel = "  "+ msg_moderatedmg; break; case Entity.DMG_LIGHT: String msg_lightdmg = Messages.getString("BoardView1.Tooltip.LightDmg"); - damageLevel = "  " + msg_lightdmg + "\n"; + damageLevel = "  " + msg_lightdmg ; + break; default: String msg_undamaged = Messages.getString("BoardView1.Tooltip.Undamaged"); - damageLevel = "  " + msg_undamaged + "\n"; + damageLevel = "  " + msg_undamaged; } - result.append(damageLevel); + s += damageLevel; // Actual Movement if (!isGunEmplacement) { // "Has not yet moved" only during movement phase if (!entity.isDone() && game.getPhase().isMovement()) { - result.append(addToTT("NotYetMoved", BR)); + s += addToTT("NotYetMoved", BR); } else if ((entity.isDone() && game.getPhase().isMovement()) || game.getPhase().isFiring()) { - result.append(guiScaledFontHTML(GUIP.getColorForMovement(entity.moved))); int tmm = Compute.getTargetMovementModifier(game, entity.getId()).getValue(); if (entity.moved == EntityMovementType.MOVE_NONE) { - result.append(addToTT("NoMove", BR, tmm)); + f += addToTT("NoMove", BR, tmm).toString(); } else { - result.append(addToTT("MovementF", BR, entity.getMovementString(entity.moved), - entity.delta_distance, tmm)); + f += addToTT("MovementF", BR, entity.getMovementString(entity.moved), + entity.delta_distance, tmm).toString(); } // Special Moves - if (entity.isEvading()) { - result.append(addToTT("Evade", NOBR)); + if (entity.isEvading()) { + f += addToTT("Evade", NOBR).toString(); } if ((entity instanceof Infantry) && ((Infantry) entity).isTakingCover()) { - result.append(addToTT("TakingCover", NOBR)); + f += addToTT("TakingCover", NOBR).toString(); } - if (entity.isCharging()) { - result.append(addToTT("Charging", BR)); + if (entity.isCharging()) { + f += addToTT("Charging", BR).toString(); } - if (entity.isMakingDfa()) { - result.append(addToTT("DFA", NOBR)); + if (entity.isMakingDfa()) { + f += addToTT("DFA", NOBR).toString(); } if (entity.isUnjammingRAC()) { - result.append("
"); + f += "
"; String msg_unjammingrac = Messages.getString("BoardView1.Tooltip.UnjammingRAC"); - result.append(msg_unjammingrac); + f += msg_unjammingrac; if (entity.getGame().getOptions().booleanOption(OptionsConstants.ADVCOMBAT_UNJAM_UAC)) { String msg_andac = Messages.getString("BoardView1.Tooltip.AndAC"); - result.append(msg_andac); + f += msg_andac; } } - result.append("\n"); + + s += guiScaledFontHTML(GUIP.getColorForMovement(entity.moved)) + f + ""; } } + f = ""; + if (entity.isAero()) { // Velocity, Altitude, Elevation, Fuel - result.append(guiScaledFontHTML(uiLightViolet())); IAero aero = (IAero) entity; - result.append(addToTT("AeroVelAltFuel", BR, aero.getCurrentVelocity(), aero.getAltitude(), aero.getFuel())); - result.append("\n"); + f += addToTT("AeroVelAltFuel", BR, aero.getCurrentVelocity(), aero.getAltitude(), aero.getFuel()).toString(); } else if (entity.getElevation() != 0) { // Elevation only - result.append(guiScaledFontHTML(uiLightViolet())); - result.append(addToTT("Elev", BR, entity.getElevation())); - result.append("\n"); + f += addToTT("Elev", BR, entity.getElevation()).toString(); } - result.append("
"); + s += guiScaledFontHTML(uiLightViolet()) + f + ""; + + s += "
"; String msg_facing = Messages.getString("BoardView1.Tooltip.Facing"); - result.append("  " + msg_facing + ": " + PlanetaryConditions.getWindDirDisplayableName(entity.getFacing())); + s += "  " + msg_facing + ": " + PlanetaryConditions.getWindDirDisplayableName(entity.getFacing()); if (entity.getFacing() != entity.getSecondaryFacing()) { String msg_twist = Messages.getString("BoardView1.Tooltip.Twist"); - result.append("  " + msg_twist + ": " + PlanetaryConditions.getWindDirDisplayableName(entity.getSecondaryFacing())); + s += "  " + msg_twist + ": " + PlanetaryConditions.getWindDirDisplayableName(entity.getSecondaryFacing()); } - result.append("\n"); // Heat, not shown for units with 999 heat sinks (vehicles) if (entity.getHeatCapacity() != 999) { int heat = entity.heat; - result.append(guiScaledFontHTML(GUIP.getColorForHeat(heat))); + f = ""; if (heat == 0) { - result.append(addToTT("Heat0", BR)); + f += addToTT("Heat0", BR).toString(); } else { - result.append(addToTT("Heat", BR, heat)); + f += addToTT("Heat", BR, heat).toString(); } - result.append(" / "+entity.getHeatCapacity()); - result.append("\n"); + f += " / "+entity.getHeatCapacity(); + s += guiScaledFontHTML(GUIP.getColorForHeat(heat)) + f + ""; } // Gun Emplacement Status if (isGunEmplacement) { GunEmplacement emp = (GunEmplacement) entity; if (emp.isTurret() && emp.isTurretLocked(emp.getLocTurret())) { - result.append(guiScaledFontHTML(GUIP.getWarningColor())); - result.append(addToTT("TurretLocked", BR)); - result.append("\n"); + f = addToTT("TurretLocked", BR).toString(); + s += guiScaledFontHTML(GUIP.getWarningColor()) + f + ""; } } // Unit Immobile if (!isGunEmplacement && entity.isImmobile()) { - result.append(guiScaledFontHTML(GUIP.getWarningColor())); - result.append(addToTT("Immobile", BR)); - result.append("\n"); + f = addToTT("Immobile", BR).toString(); + s += guiScaledFontHTML(GUIP.getWarningColor()) + f + ""; } // Unit Prone if (!isGunEmplacement && entity.isProne()) { - result.append(guiScaledFontHTML(GUIP.getWarningColor())); - result.append(addToTT("Prone", BR)); - result.append("\n"); + f = addToTT("Prone", BR).toString(); + s += guiScaledFontHTML(GUIP.getWarningColor()) + f + ""; } if (!entity.getHiddenActivationPhase().isUnknown()) { - result.append(addToTT("HiddenActivating", BR, entity.getHiddenActivationPhase().toString()) + "\n"); + s += addToTT("HiddenActivating", BR, entity.getHiddenActivationPhase().toString()).toString(); } else if (entity.isHidden()) { - result.append(addToTT("Hidden", BR) + "\n"); + s += addToTT("Hidden", BR).toString(); } // Jammed by ECM - don't know how to replicate this correctly from the boardview @@ -928,13 +974,14 @@ private static StringBuilder inGameValues(Entity entity, Player localPlayer) { "Entity %s is currently swarmed by an unknown attacker with id %s", entity.getId(), entity.getSwarmAttackerId())); } - result.append(addToTT("Swarmed", BR, - (swarmAttacker == null) ? "ERROR" : swarmAttacker.getDisplayName()) + "\n"); + String msg_error = Messages.getString("ERROR"); + String sa = (swarmAttacker == null) ? msg_error : swarmAttacker.getDisplayName(); + s += addToTT("Swarmed", BR, sa).toString(); } // Spotting if (entity.isSpotting() && game.hasEntity(entity.getSpotTargetId())) { - result.append(addToTT("Spotting", BR, game.getEntity(entity.getSpotTargetId()).getDisplayName()) + "\n"); + s += addToTT("Spotting", BR, game.getEntity(entity.getSpotTargetId()).getDisplayName()).toString(); } // If Double Blind, add information about who sees this Entity @@ -974,20 +1021,19 @@ private static StringBuilder inGameValues(Entity entity, Player localPlayer) { } if (tempList.length() > 1) { tempList.delete(tempList.length() - 2, tempList.length()); - result.append(addToTT("SeenBy", BR, tempList.toString()) + "\n"); + s += addToTT("SeenBy", BR, tempList.toString()).toString(); } } // If sensors, display what sensors this unit is using if (game.getOptions().booleanOption(OptionsConstants.ADVANCED_TACOPS_SENSORS) || game.getOptions().booleanOption(OptionsConstants.ADVAERORULES_STRATOPS_ADVANCED_SENSORS)) { - result.append(addToTT("Sensors", BR, entity.getSensorDesc(), Compute.getMaxVisualRange(entity, false)) + "\n"); + s += addToTT("Sensors", BR, entity.getSensorDesc(), Compute.getMaxVisualRange(entity, false)).toString(); } if (entity.hasAnyTypeNarcPodsAttached()) { - result.append(guiScaledFontHTML(uiLightRed())); - result.append(addToTT(entity.hasNarcPodsAttached() ? "Narced" : "INarced", BR)); - result.append("\n"); + f = addToTT(entity.hasNarcPodsAttached() ? "Narced" : "INarced", BR).toString(); + s += guiScaledFontHTML(uiLightRed()) + f + ""; } // Towing @@ -996,17 +1042,28 @@ private static StringBuilder inGameValues(Entity entity, Player localPlayer) { .map(id -> entity.getGame().getEntity(id).getShortName()) .collect(Collectors.joining(", ")); if (unitList.length() > 1) { - result.append(addToTT("Towing", BR, unitList) + "\n"); + s += addToTT("Towing", BR, unitList).toString(); } } - result.append("
\n\n"); - return result; + + // Coloring and italic to make these transient entries stand out + s = guiScaledFontHTML(uiLightViolet()) + s + ""; + s = "" + s + ""; + + return new StringBuilder().append(s); } /** Returns unit values that are relevant in-game and in the lobby such as movement ability. */ private static StringBuilder entityValues(Entity entity) { - StringBuilder result = new StringBuilder(); boolean isGunEmplacement = entity instanceof GunEmplacement; + String s = ""; + String f = ""; + String d = ""; + + String l1= ""; + String l2 = ""; + String l3 = ""; + String l4 = ""; // Unit movement ability if (!isGunEmplacement) { @@ -1082,10 +1139,10 @@ private static StringBuilder entityValues(Entity entity) { int walkMP = entity.getOriginalWalkMP(); int runMP = entity.getOriginalRunMP(); int jumpMP = entity.getOriginalJumpMP(); - result.append(addToTT("Movement", NOBR , walkMP, runMP)); + d = addToTT("Movement", NOBR , walkMP, runMP).toString(); if (jumpMP > 0) { - result.append("/" + jumpMP); + d += "/" + jumpMP; } int walkMPModified = entity.getWalkMP(true, false,false); @@ -1093,42 +1150,53 @@ private static StringBuilder entityValues(Entity entity) { int jumpMPModified = entity.getJumpMP(true); if ((walkMP != walkMPModified) || (runMP != runMPModified) || (jumpMP != jumpMPModified)) { - result.append(DOT_SPACER); - result.append(walkMPModified + "/" + runMPModified); + d += DOT_SPACER + walkMPModified + "/" + runMPModified; if (jumpMPModified > 0) { - result.append("/" + jumpMPModified); + d += "/" + jumpMPModified; } if (entity.getGame().getPlanetaryConditions().getGravity() != 1.0) { - result.append(DOT_SPACER + guiScaledFontHTML(GUIP.getWarningColor()) + entity.getGame().getPlanetaryConditions().getGravity() + "g\n"); + d += DOT_SPACER; + f = entity.getGame().getPlanetaryConditions().getGravity() + "g"; + d += guiScaledFontHTML(GUIP.getWarningColor()) + f + ""; } int walkMPNoHeat = entity.getWalkMP(true, true,false); int runMPNoHeat = entity.getRunMP(true, true, false); if ((walkMPNoHeat != walkMPModified) || (runMPNoHeat != runMPModified)) { - result.append(DOT_SPACER + guiScaledFontHTML(GUIP.getWarningColor()) + "\uD83D\uDD25\n"); + d += DOT_SPACER; + f = "\uD83D\uDD25"; + d += guiScaledFontHTML(GUIP.getWarningColor()) + f + ""; } } if (entity instanceof Tank) { - result.append(DOT_SPACER + entity.getMovementModeAsString()); + d += DOT_SPACER; + f = entity.getMovementModeAsString(); + d += guiScaledFontHTML(GUIP.getWarningColor()) + f + ""; } if (entity instanceof IBomber) { int bombMod = 0; bombMod = ((IBomber) entity).reduceMPByBombLoad(walkMP); if (bombMod != walkMP) { - result.append(DOT_SPACER + guiScaledFontHTML(GUIP.getWarningColor()) + "\uD83D\uDCA3" + "\n"); + d += DOT_SPACER; + f = "\uD83D\uDCA3"; + d+= guiScaledFontHTML(GUIP.getWarningColor()) + f + ""; } } int weatherMod = entity.getGame().getPlanetaryConditions().getMovementMods(entity); if ((weatherMod != 0) || (partialWingWeaterMod != 0)) { - result.append(DOT_SPACER + guiScaledFontHTML(GUIP.getWarningColor()) + "\u2602" + "\n"); + d += DOT_SPACER; + f = "\u2602"; + d += guiScaledFontHTML(GUIP.getWarningColor()) + f + ""; } if ((legsDestroyed > 0) || (hipHits > 0) || (actuatorHits > 0) || (jumpJetDistroyed > 0) || (paritalWingDistroyed > 0) || (jumpBoosterDistroyed > 0) || (entity.isImmobile()) || (entity.isGyroDestroyed())) { - result.append(DOT_SPACER + guiScaledFontHTML(GUIP.getWarningColor()) + "\uD83D\uDD27" + "\n"); + d += DOT_SPACER; + f = "\uD83D\uDD27"; + d += guiScaledFontHTML(GUIP.getWarningColor()) + f + ""; } if ((entity instanceof BipedMech) || (entity instanceof TripodMech)) { @@ -1139,18 +1207,22 @@ private static StringBuilder entityValues(Entity entity) { } if (shieldMod != 0) { - result.append(DOT_SPACER + guiScaledFontHTML(GUIP.getWarningColor()) + "\u26E8" + "\n"); + d += DOT_SPACER; + f = "\u26E8"; + d += guiScaledFontHTML(GUIP.getWarningColor()) + f + ""; } } if (entity.hasModularArmor()) { - result.append(DOT_SPACER + guiScaledFontHTML(GUIP.getWarningColor()) + "\u27EC\u25AE" + "\n"); + d += DOT_SPACER; + f = "\u27EC\u25AE"; + d += DOT_SPACER + guiScaledFontHTML(GUIP.getWarningColor()) + f + ""; } - result.append("\n"); + l1 = "
  • " + d + "
  • "; + d = ""; if ((jumpJetDistroyed > 0) || (jumpBoosterDistroyed > 0) || (paritalWingDistroyed > 0)) { - result.append("
    "); String jj = ""; if (jumpJetDistroyed > 0) { String msg_jumpjets = Messages.getString("BoardView1.Tooltip.JumpJets"); @@ -1167,7 +1239,7 @@ private static StringBuilder entityValues(Entity entity) { if (jj.startsWith(";")) { jj = jj.substring(2); } - result.append(jj + "\n"); + l2 = "
  • " + jj + "
  • "; } } @@ -1176,13 +1248,15 @@ private static StringBuilder entityValues(Entity entity) { Infantry inf = (Infantry) entity; int spec = inf.getSpecializations(); if (spec > 0) { - result.append(addToTT("InfSpec", BR, Infantry.getSpecializationName(spec)) + "\n"); + d += addToTT("InfSpec", NOBR, Infantry.getSpecializationName(spec)).toString(); + l3 = "
  • " + d + "
  • "; + d = ""; } } // Armor and Internals if (entity.isConventionalInfantry()) { - result.append("
    "); + d += ""; } else if (!isGunEmplacement) { String msg_unknown = Messages.getString("BoardView1.Tooltip.Unknown"); String armorType = TROView.formatArmorType(entity, true).replace(msg_unknown, ""); @@ -1192,78 +1266,88 @@ private static StringBuilder entityValues(Entity entity) { armorType = " (" + armorType + ")"; } String armorStr = " " + entity.getTotalArmor() + armorType; - result.append(addToTT("ArmorInternals", BR, armorStr, entity.getTotalInternal()) + "\n"); + d += addToTT("ArmorInternals", NOBR, armorStr, entity.getTotalInternal()).toString(); + l4 = "
  • " + d + "
  • "; + d = ""; } - return result; + + String u = "
      " + l1 + l2 + l3 + l4 + "
    "; + s += u; + + return new StringBuilder().append(s); } /** Returns warnings about problems that should be solved before deploying. */ private static StringBuilder deploymentWarnings(Entity entity, Player localPlayer, MapSettings mapSettings) { - StringBuilder result = new StringBuilder(); + String s = ""; + String f = ""; // Critical (red) warnings - result.append(guiScaledFontHTML(GUIP.getWarningColor())); if (entity.getGame().getPlanetaryConditions().whyDoomed(entity, entity.getGame()) != null) { String msg_cannotsurvive = Messages.getString("BoardView1.Tooltip.CannotSurvive"); - result.append("
    " + msg_cannotsurvive + " " + entity.getGame().getPlanetaryConditions().whyDoomed(entity, entity.getGame())); + f += "
    " + msg_cannotsurvive + " " + entity.getGame().getPlanetaryConditions().whyDoomed(entity, entity.getGame()); } if (entity.doomedInAtmosphere() && mapSettings.getMedium() == MapSettings.MEDIUM_ATMOSPHERE) { String msg_cannotsurviveatmo = Messages.getString("BoardView1.Tooltip.CannotSurviveAtmo"); - result.append("
    " + msg_cannotsurviveatmo); + f += "
    " + msg_cannotsurviveatmo; } if (entity.doomedOnGround() && mapSettings.getMedium() == MapSettings.MEDIUM_GROUND) { String msg_cannotsurviveground = Messages.getString("BoardView1.Tooltip.CannotSurviveGround"); - result.append("
    " + msg_cannotsurviveground); + f += "
    " + msg_cannotsurviveground; } if (entity.doomedInSpace() && mapSettings.getMedium() == MapSettings.MEDIUM_SPACE) { String msg_cannotsurvivespace = Messages.getString("BoardView1.Tooltip.CannotSurviveSpace"); - result.append("
    " + msg_cannotsurvivespace); + f += "
    " + msg_cannotsurvivespace; } - result.append("\n"); - + s += guiScaledFontHTML(GUIP.getWarningColor()) + f + ""; + + f = ""; // Non-critical (yellow) warnings - result.append(guiScaledFontHTML(uiYellow())); if (((entity.hasC3i() || entity.hasNavalC3()) && (entity.calculateFreeC3Nodes() == 5)) || ((entity.getC3Master() == null) && entity.hasC3S()) || (entity.hasNovaCEWS() && (entity.calculateFreeC3Nodes() == 2))) { String msg_unconnectedc3computer = Messages.getString("BoardView1.Tooltip.UnconnectedC3Computer"); - result.append("
    " + msg_unconnectedc3computer); + f += "
    " + msg_unconnectedc3computer; } // Non-critical (yellow) warnings if (entity instanceof FighterSquadron && entity.getLoadedUnits().isEmpty()) { String msg_fightersquadronempty = Messages.getString("BoardView1.Tooltip.FighterSquadronEmpty"); - result.append("
    " + msg_fightersquadronempty); + f += "
    " + msg_fightersquadronempty; } - result.append("\n"); - return result; + + s += guiScaledFontHTML(uiYellow()) + f + ""; + + return new StringBuilder().append(s); } /** Returns a list of units loaded onto this unit. */ private static StringBuilder carriedUnits(Entity entity) { - StringBuilder result = new StringBuilder(); - - result.append(guiScaledFontHTML()); + String s = ""; + String f = ""; + if (entity instanceof FighterSquadron) { String msg_fighter = Messages.getString("BoardView1.Tooltip.Fighters"); - result.append(msg_fighter + ":"); + f += msg_fighter + ":"; } else { String msg_carriedunits = Messages.getString("BoardView1.Tooltip.CarriedUnits"); - result.append(msg_carriedunits + ":"); + f += msg_carriedunits + ":"; } for (Entity carried: entity.getLoadedUnits()) { - result.append("
      ").append(carried.getShortNameRaw()); + f += "
      " + carried.getShortNameRaw(); if (PreferenceManager.getClientPreferences().getShowUnitId()) { - result.append(" [" + carried.getId() + "]"); + f += " [" + carried.getId() + "]"; } } - result.append("\n"); - return result; + + s = guiScaledFontHTML() + f + ""; + return new StringBuilder().append(s); } /** Returns the full force chain the entity is in as one text line. */ private static StringBuilder forceEntry(Entity entity, Player localPlayer) { - StringBuilder result = new StringBuilder(); + String s = ""; + String f = ""; if (entity.partOfForce()) { // Get the my / ally / enemy color and desaturate it @@ -1274,66 +1358,75 @@ private static StringBuilder forceEntry(Entity entity, Player localPlayer) { color = GUIP.getAllyUnitColor(); } color = addGray(color, 128).brighter(); - result.append(guiScaledFontHTML(color)).append("
    "); + f += "
    "; var forceChain = entity.getGame().getForces().forceChain(entity); for (int i = forceChain.size() - 1; i >= 0; i--) { - result.append(forceChain.get(i).getName()); - result.append(i != 0 ? ", " : ""); + f += forceChain.get(i).getName(); + f += i != 0 ? ", " : ""; } - result.append("\n"); + s = guiScaledFontHTML(color) + f + ""; } - return result; + + return new StringBuilder().append(s); } /** Returns an overview of the C3 system the unit is in. */ private static StringBuilder c3Info(Entity entity) { - StringBuilder result = new StringBuilder(); + String s = ""; + String f = ""; - result.append(guiScaledFontHTML()); List members = entity.getGame().getEntitiesVector().stream() .filter(e -> e.onSameC3NetworkAs(entity)) .sorted(Comparator.comparingInt(Entity::getId)) .map(e -> c3UnitName(e, entity)).collect(Collectors.toList()); if (members.size() > 1) { - result.append(guiScaledFontHTML(uiC3Color(), -0.2f)); if (entity.hasNhC3()) { String msg_c3i = Messages.getString("BoardView1.Tooltip.C3i"); String msg_nc3 = Messages.getString("BoardView1.Tooltip.NC3"); - result.append(entity.hasC3i() ? msg_c3i : msg_nc3); + f += entity.hasC3i() ? msg_c3i : msg_nc3; } else { String msg_c3 = Messages.getString("BoardView1.Tooltip.C3"); - result.append(msg_c3); + f += msg_c3; } String msg_network = Messages.getString("BoardView1.Tooltip.Network"); - result.append(" " + msg_network + ":
      "); - result.append(String.join("
      ", members)); - result.append("
    "); + f += " " + msg_network + ":
      "; + f += String.join("
      ", members); + f += "
    "; } - result.append("\n"); - return result; + s = guiScaledFontHTML(uiC3Color(), -0.2f) + f + ""; + + return new StringBuilder().append(s); } private static String c3UnitName(Entity c3member, Entity entity) { - StringBuilder result = new StringBuilder(); - result.append(guiScaledFontHTML(uiGray(), -0.2f)); - result.append(" [" + c3member.getId() + "] "); + String s = ""; + String it = ""; + String f = ""; + String tmp = ""; + + f = " [" + c3member.getId() + "] "; + if (c3member.isC3CompanyCommander()) { String msg_c3cc = Messages.getString("BoardView1.Tooltip.C3CC"); - result.append(msg_c3cc); + it += msg_c3cc + " "; } else if (c3member.hasC3M()) { String msg_c3m = Messages.getString("BoardView1.Tooltip.C3M"); - result.append(msg_c3m); + it += msg_c3m + " "; } - result.append("\n"); - result.append(c3member.getShortNameRaw()); - result.append(guiScaledFontHTML(uiGray(), -0.2f)); + + f += "" + it + ""; + s += guiScaledFontHTML(uiGray(), -0.2f) + f + ""; + s += c3member.getShortNameRaw(); + String msg_thisunit = Messages.getString("BoardView1.Tooltip.ThisUnit"); - result.append(c3member.equals(entity) ? " (" + msg_thisunit + ")" : ""); - result.append("\n"); - return result.toString(); - } + it = " (" + msg_thisunit + ")"; + tmp = "" + it + ""; + f = c3member.equals(entity) ? tmp : ""; + s += guiScaledFontHTML(uiGray(), -0.2f) + f + ""; + return s; + } /** Helper method to shorten repetitive calls. */ private static StringBuilder addToTT(String tipName, boolean startBR, Object... ttO) { diff --git a/megamek/src/megamek/client/ui/swing/unitDisplay/SummaryPanel.java b/megamek/src/megamek/client/ui/swing/unitDisplay/SummaryPanel.java index 0ae28435e97..8cbb303b9fa 100644 --- a/megamek/src/megamek/client/ui/swing/unitDisplay/SummaryPanel.java +++ b/megamek/src/megamek/client/ui/swing/unitDisplay/SummaryPanel.java @@ -23,6 +23,7 @@ import megamek.client.ui.swing.boardview.BoardView; import megamek.client.ui.swing.tooltip.PilotToolTip; import megamek.client.ui.swing.tooltip.UnitToolTip; +import megamek.client.ui.swing.util.UIUtil; import megamek.client.ui.swing.widget.*; import megamek.common.*; import megamek.common.util.fileUtils.MegaMekFile; @@ -138,10 +139,10 @@ public void displayMech(Entity entity) { StringBuffer hexTxt = new StringBuffer(""); hexTxt.append(PilotToolTip.getPilotTipDetailed(entity, true)); StringBuffer p = new StringBuffer(); - p.append(UnitToolTip.getEntityTipUnitDisplay(entity, localPlayer)); - String col = "" + p + ""; - String row = "" + col + ""; - hexTxt.append("" + row + "
    "); + hexTxt.append(UnitToolTip.getEntityTipUnitDisplay(entity, localPlayer)); + + String col = ""; + String row = ""; BoardView bv = unitDisplay.getClientGUI().getBoardView(); Hex mhex = entity.getGame().getBoard().getHex(entity.getPosition()); @@ -166,8 +167,15 @@ public void displayMech(Entity entity) { private String padLeft(String html) { int dist = (int) (GUIPreferences.getInstance().getGUIScale() * 5); - return "" - + "
    "+html+"
    "; + String col = ""; + String row = ""; + String tbody = ""; + String table = ""; + col = "" + html + ""; + row = "" + col + ""; + tbody = "" + row + ""; + table = "" + tbody + "
    "; + return table; } @Override From 051d6646af7e3d94af4bc729c9946613b77bca70 Mon Sep 17 00:00:00 2001 From: kuronekochomusuke Date: Wed, 18 Jan 2023 10:56:12 -0500 Subject: [PATCH 09/15] unit tool tip fixes 8 --- .../i18n/megamek/client/messages.properties | 47 ++++++++++--------- .../client/ui/swing/boardview/BoardView.java | 11 +++-- .../client/ui/swing/tooltip/UnitToolTip.java | 46 +++++++++++------- 3 files changed, 62 insertions(+), 42 deletions(-) diff --git a/megamek/i18n/megamek/client/messages.properties b/megamek/i18n/megamek/client/messages.properties index 02c2e8e48d0..4c058c053a0 100644 --- a/megamek/i18n/megamek/client/messages.properties +++ b/megamek/i18n/megamek/client/messages.properties @@ -480,8 +480,8 @@ BoardView1.Tooltip.AbbreviationUpperLeg=UL BoardView1.Tooltip.AbbreviationLowerLeg=LL BoardView1.Tooltip.AbbreviationLowerFoot=F BoardView1.Tooltip.ActiveTroopers=Active Troopers -BoardView1.Tooltip.AeroVelAltFuel=Velocity: {0}, Altitude: {1}, Fuel: {2} -BoardView1.Tooltip.AeroStartingVelAlt=Starting Velocity: {0}, Altitude: {1} +BoardView1.Tooltip.AeroVelAltFuel=Velocity: {0}, Altitude: {1}, Fuel: {2} +BoardView1.Tooltip.AeroStartingVelAlt=Starting Velocity: {0}, Altitude: {1} BoardView1.Tooltip.AndAC=/AC BoardView1.Tooltip.Ammo=Ammo BoardView1.Tooltip.AntiPersonnel=Anti-Personnel @@ -489,10 +489,10 @@ BoardView1.Tooltip.AP=AP BoardView1.Tooltip.ArmorInternals=Armor {0}; Internal {1} BoardView1.Tooltip.ArmorCapital=Capital BoardView1.Tooltip.Armor=Armor: {0} -BoardView1.Tooltip.ArtilleryAttack1=Artillery: {0} in 1 turn
      Ammo: {1} -BoardView1.Tooltip.ArtilleryAttackN=Artillery: {0} in {2} turns
      Ammo: {1} -BoardView1.Tooltip.Arrow= -BoardView1.Tooltip.BlockColored={0} +BoardView1.Tooltip.ArtilleryAttack1=Artillery: {0} in 1 turn
      Ammo: {1} +BoardView1.Tooltip.ArtilleryAttackN=Artillery: {0} in {2} turns
      Ammo: {1} +BoardView1.Tooltip.Arrow=➡ +BoardView1.Tooltip.BlockColored={0} BoardView1.Tooltip.BV=BV: {0} / {1} ({2, number, percent}) BoardView1.Tooltip.CannotSurvive=Cannot survive BoardView1.Tooltip.CannotSurviveAtmo=Cannot survive on a low/high atmosphere map! @@ -500,7 +500,7 @@ BoardView1.Tooltip.CannotSurviveGround=Cannot survive on a ground map! BoardView1.Tooltip.CannotSurviveSpace=Cannot survive in space! BoardView1.Tooltip.CarriedUnits=Carried Units BoardView1.Tooltip.Charging=(Charging) -BoardView1.Tooltip.ChassisPlayer={0}{2} - {1} +BoardView1.Tooltip.ChassisPlayer={0}{2} - {1} BoardView1.Tooltip.Clan=(C) BoardView1.Tooltip.ClanBrackets=[Clan] BoardView1.Tooltip.ClanParens=(Clan) @@ -512,13 +512,13 @@ BoardView1.Tooltip.C3M=C3M BoardView1.Tooltip.IsDestroyed= BoardView1.Tooltip.IS=(IS) BoardView1.Tooltip.ISBracket=[IS] -BoardView1.Tooltip.DFA=
    (Death from Above) +BoardView1.Tooltip.DFA=(Death from Above) BoardView1.Tooltip.Distance1=Distance from the selected unit: 1 Hex BoardView1.Tooltip.DistanceN=Distance from the selected unit: {0} Hexes -BoardView1.Tooltip.DistanceMove1=Distance from the movement end point: 1 Hex -BoardView1.Tooltip.DistanceMoveN=Distance from the movement end point: {0} Hexes -BoardView1.Tooltip.Elev=Elevation: {0} -BoardView1.Tooltip.Evade=
    (Evading) +BoardView1.Tooltip.DistanceMove1=Distance from the movement end point: 1 Hex +BoardView1.Tooltip.DistanceMoveN=Distance from the movement end point: {0} Hexes +BoardView1.Tooltip.Elev=Elevation: {0} +BoardView1.Tooltip.Evade=(Evading) BoardView1.Tooltip.Facing=Facing BoardView1.Tooltip.Fighters=Fighters BoardView1.Tooltip.FighterSquadronEmpty=This Fighter Squadron is empty @@ -532,22 +532,21 @@ BoardView1.Tooltip.HotLoadedParens=(Hot-Loaded) BoardView1.Tooltip.Immobile=Immobile BoardView1.Tooltip.InfSpec=Specialization: {0} BoardView1.Tooltip.Internals=Internal: {0} -BoardView1.Tooltip.Jammed=Jammed by Enemy ECM +BoardView1.Tooltip.Jammed=Jammed by Enemy ECM BoardView1.Tooltip.JumpBoosters=Jump Boosters BoardView1.Tooltip.JumpJets=Jump Jets BoardView1.Tooltip.LightDmg=LIGHT DMG BoardView1.Tooltip.ModerateDmg=MODERATE DMG BoardView1.Tooltip.Movement=Movement: {0}/{1} -BoardView1.Tooltip.MovementF={0} {1} (TMM: {2}) +BoardView1.Tooltip.MovementF={0} {1} (TMM: {2}) BoardView1.Tooltip.NC3=NC3 BoardView1.Tooltip.Network=Network -BoardView1.Tooltip.NotYetMoved=Has not yet moved -BoardView1.Tooltip.NoMove=Did not move (Mod: {0}) +BoardView1.Tooltip.NotYetMoved=Has not yet moved +BoardView1.Tooltip.NoMove=Did not move (Mod: {0}) BoardView1.Tooltip.NullWeaponName=NULL Weapon Name! BoardView1.Tooltip.OutOfAmmo=Out of Ammo! BoardView1.Tooltip.PartialWing=Partial Wing BoardView1.Tooltip.Pilot=Pilot -BoardView1.Tooltip.PilotPortrait= BoardView1.Tooltip.Prone=Prone BoardView1.Tooltip.Rapidfire=Rapid-fire BoardView1.Tooltip.SeenBy=Seen by: {0} @@ -555,25 +554,27 @@ BoardView1.Tooltip.Sensors=Sensor: {0}, Range: {1} BoardView1.Tooltip.Shots=shots BoardView1.Tooltip.Someone=Someone BoardView1.Tooltip.Standard=Standard -BoardView1.Tooltip.StartingElev=Starting Elevation: {0} +BoardView1.Tooltip.StartingElev=Starting Elevation: {0} BoardView1.Tooltip.Narced=Narc pod attached! BoardView1.Tooltip.INarced=iNarc pod attached! BoardView1.Tooltip.SensorsHexInRange=Hex is in sensor range -BoardView1.Tooltip.SensorsHexNotInRange=Hex is not in sensor range +BoardView1.Tooltip.SensorsHexNotInRange1=Hex is +BoardView1.Tooltip.SensorsHexNotInRange2=not +BoardView1.Tooltip.SensorsHexNotInRange3= in sensor range BoardView1.Tooltip.Spotting=Spotting {0} -BoardView1.Tooltip.Swarmed=Swarmed by {0} -BoardView1.Tooltip.TakingCover=
    (Taking Cover) +BoardView1.Tooltip.Swarmed=Swarmed by {0} +BoardView1.Tooltip.TakingCover=(Taking Cover) BoardView1.Tooltip.TF=TF BoardView1.Tooltip.ThisUnit=This unit BoardView1.Tooltip.Towing=Towing: {0} BoardView1.Tooltip.Turns=turns -BoardView1.Tooltip.TurretLocked=Turret locked! +BoardView1.Tooltip.TurretLocked=Turret locked! BoardView1.Tooltip.Twist=Twist BoardView1.Tooltip.UnconnectedC3Computer=Unconnected C3 Computer BoardView1.Tooltip.Undamaged=UNDAMAGED BoardView1.Tooltip.UnjammingRAC=Unjamming RAC BoardView1.Tooltip.Unknown=UNKNOWN -BoardView1.Tooltip.Weapon={3} {1}{2} +BoardView1.Tooltip.Weapon={3} {1}{2} BoardView1.Tooltip.Wreckof=Wreck of BoardView1.Tooltip.X=x BoardView1.Tooltip.ZZ=ZZ diff --git a/megamek/src/megamek/client/ui/swing/boardview/BoardView.java b/megamek/src/megamek/client/ui/swing/boardview/BoardView.java index cc86b10ae11..36875814186 100644 --- a/megamek/src/megamek/client/ui/swing/boardview/BoardView.java +++ b/megamek/src/megamek/client/ui/swing/boardview/BoardView.java @@ -5456,6 +5456,7 @@ public String getHexTooltip(MouseEvent e) { String f = ""; String t = ""; String s = ""; + String i = ""; StringBuffer sb = new StringBuffer(); //StringBuffer txt = new StringBuffer(); @@ -5489,7 +5490,10 @@ public String getHexTooltip(MouseEvent e) { if ((distance > minSensorRange) && (distance <= maxSensorRange)) { f += Messages.getString("BoardView1.Tooltip.SensorsHexInRange"); } else { - f += Messages.getString("BoardView1.Tooltip.SensorsHexNotInRange"); + f += Messages.getString("BoardView1.Tooltip.SensorsHexNotInRange1"); + String tmp = Messages.getString("BoardView1.Tooltip.SensorsHexNotInRange2"); + f += "" + tmp + ""; + f += Messages.getString("BoardView1.Tooltip.SensorsHexNotInRange3"); } } @@ -5497,10 +5501,11 @@ public String getHexTooltip(MouseEvent e) { f += "
    "; int disPM = movementTarget.distance(mcoords); if (disPM == 1) { - f += Messages.getString("BoardView1.Tooltip.DistanceMove1"); + i = Messages.getString("BoardView1.Tooltip.DistanceMove1"); } else { - f += Messages.getString("BoardView1.Tooltip.DistanceMoveN", disPM); + i = Messages.getString("BoardView1.Tooltip.DistanceMoveN", disPM); } + f += "" + i + ""; } } diff --git a/megamek/src/megamek/client/ui/swing/tooltip/UnitToolTip.java b/megamek/src/megamek/client/ui/swing/tooltip/UnitToolTip.java index b8eaa629c76..a8be2cedad6 100644 --- a/megamek/src/megamek/client/ui/swing/tooltip/UnitToolTip.java +++ b/megamek/src/megamek/client/ui/swing/tooltip/UnitToolTip.java @@ -813,6 +813,7 @@ private static StringBuilder inGameValues(Entity entity, Player localPlayer) { boolean isGunEmplacement = entity instanceof GunEmplacement; String s = ""; String f = ""; + String i = ""; // BV Info // Hidden for invisible units when in double blind and hide enemy bv is selected @@ -858,35 +859,44 @@ private static StringBuilder inGameValues(Entity entity, Player localPlayer) { if (!isGunEmplacement) { // "Has not yet moved" only during movement phase if (!entity.isDone() && game.getPhase().isMovement()) { - s += addToTT("NotYetMoved", BR); + i = addToTT("NotYetMoved", BR).toString(); + s += "" + i + ""; } else if ((entity.isDone() && game.getPhase().isMovement()) || game.getPhase().isFiring()) { int tmm = Compute.getTargetMovementModifier(game, entity.getId()).getValue(); if (entity.moved == EntityMovementType.MOVE_NONE) { - f += addToTT("NoMove", BR, tmm).toString(); + i = addToTT("NoMove", BR, tmm).toString().toString(); + f = "" + i + ""; } else { - f += addToTT("MovementF", BR, entity.getMovementString(entity.moved), + i = addToTT("MovementF", BR, entity.getMovementString(entity.moved), entity.delta_distance, tmm).toString(); + f = "" + i + ""; } // Special Moves if (entity.isEvading()) { - f += addToTT("Evade", NOBR).toString(); + i = addToTT("Evade", BR).toString(); + f = "" + i + ""; + f = "" + f + ""; } if ((entity instanceof Infantry) && ((Infantry) entity).isTakingCover()) { - f += addToTT("TakingCover", NOBR).toString(); + i = addToTT("TakingCover", BR).toString(); + f = "" + i + ""; + f = "" + f + ""; } if (entity.isCharging()) { - f += addToTT("Charging", BR).toString(); + f = addToTT("Charging", BR).toString(); } if (entity.isMakingDfa()) { - f += addToTT("DFA", NOBR).toString(); + i = addToTT("DFA", BR).toString(); + f = "" + i + ""; + f = "" + f + ""; } if (entity.isUnjammingRAC()) { - f += "
    "; + f = "
    "; String msg_unjammingrac = Messages.getString("BoardView1.Tooltip.UnjammingRAC"); f += msg_unjammingrac; if (entity.getGame().getOptions().booleanOption(OptionsConstants.ADVCOMBAT_UNJAM_UAC)) { @@ -904,21 +914,22 @@ private static StringBuilder inGameValues(Entity entity, Player localPlayer) { if (entity.isAero()) { // Velocity, Altitude, Elevation, Fuel IAero aero = (IAero) entity; - f += addToTT("AeroVelAltFuel", BR, aero.getCurrentVelocity(), aero.getAltitude(), aero.getFuel()).toString(); + i = addToTT("AeroVelAltFuel", BR, aero.getCurrentVelocity(), aero.getAltitude(), aero.getFuel()).toString(); } else if (entity.getElevation() != 0) { // Elevation only - f += addToTT("Elev", BR, entity.getElevation()).toString(); + i = addToTT("Elev", BR, entity.getElevation()).toString(); } - + f = "" + i + ""; s += guiScaledFontHTML(uiLightViolet()) + f + "
    "; s += "
    "; String msg_facing = Messages.getString("BoardView1.Tooltip.Facing"); - s += "  " + msg_facing + ": " + PlanetaryConditions.getWindDirDisplayableName(entity.getFacing()); + f = "  " + msg_facing + ": " + PlanetaryConditions.getWindDirDisplayableName(entity.getFacing()); if (entity.getFacing() != entity.getSecondaryFacing()) { String msg_twist = Messages.getString("BoardView1.Tooltip.Twist"); - s += "  " + msg_twist + ": " + PlanetaryConditions.getWindDirDisplayableName(entity.getSecondaryFacing()); + f = "  " + msg_twist + ": " + PlanetaryConditions.getWindDirDisplayableName(entity.getSecondaryFacing()); } + s += guiScaledFontHTML() + f + "
    "; // Heat, not shown for units with 999 heat sinks (vehicles) if (entity.getHeatCapacity() != 999) { @@ -937,7 +948,8 @@ private static StringBuilder inGameValues(Entity entity, Player localPlayer) { if (isGunEmplacement) { GunEmplacement emp = (GunEmplacement) entity; if (emp.isTurret() && emp.isTurretLocked(emp.getLocTurret())) { - f = addToTT("TurretLocked", BR).toString(); + i = addToTT("TurretLocked", BR).toString(); + f = "" + i + ""; s += guiScaledFontHTML(GUIP.getWarningColor()) + f + "
    "; } } @@ -976,7 +988,8 @@ private static StringBuilder inGameValues(Entity entity, Player localPlayer) { } String msg_error = Messages.getString("ERROR"); String sa = (swarmAttacker == null) ? msg_error : swarmAttacker.getDisplayName(); - s += addToTT("Swarmed", BR, sa).toString(); + f = addToTT("Swarmed", BR, sa).toString(); + s += "" + f + ""; } // Spotting @@ -1021,7 +1034,8 @@ private static StringBuilder inGameValues(Entity entity, Player localPlayer) { } if (tempList.length() > 1) { tempList.delete(tempList.length() - 2, tempList.length()); - s += addToTT("SeenBy", BR, tempList.toString()).toString(); + f = addToTT("SeenBy", BR, tempList.toString()).toString(); + s += guiScaledFontHTML() + f + "
    "; } } From 9402325e5f7eac70c424e037d58cc51491857c1b Mon Sep 17 00:00:00 2001 From: kuronekochomusuke Date: Wed, 18 Jan 2023 12:38:23 -0500 Subject: [PATCH 10/15] unit tool tip fixes 9 --- .../ui/swing/boardview/AttackSprite.java | 4 +++- .../client/ui/swing/boardview/BoardView.java | 20 +++++++++-------- .../client/ui/swing/tooltip/UnitToolTip.java | 8 +++---- .../megamek/client/ui/swing/util/UIUtil.java | 22 +++++++++++++++++++ 4 files changed, 40 insertions(+), 14 deletions(-) diff --git a/megamek/src/megamek/client/ui/swing/boardview/AttackSprite.java b/megamek/src/megamek/client/ui/swing/boardview/AttackSprite.java index 3e983dd76d2..7c782e486e7 100644 --- a/megamek/src/megamek/client/ui/swing/boardview/AttackSprite.java +++ b/megamek/src/megamek/client/ui/swing/boardview/AttackSprite.java @@ -26,6 +26,8 @@ import megamek.common.actions.SearchlightAttackAction; import megamek.common.actions.WeaponAttackAction; +import static megamek.client.ui.swing.util.UIUtil.guiScaledFontHTML; + /** * Sprite and info for an attack. Does not actually use the image buffer as * this can be horribly inefficient for long diagonal lines. Appears as an @@ -377,7 +379,7 @@ public StringBuffer getTooltip() { String f = ""; f = attackerDesc + "
      " + Messages.getString("BoardView1.on") + " " + targetDesc; - s = "" + f + ""; + s = guiScaledFontHTML(attackColor.getRGB()) + f + ""; for (String wpD: weaponDescs) { s += "
    "+wpD; } diff --git a/megamek/src/megamek/client/ui/swing/boardview/BoardView.java b/megamek/src/megamek/client/ui/swing/boardview/BoardView.java index 36875814186..85a50c0eb38 100644 --- a/megamek/src/megamek/client/ui/swing/boardview/BoardView.java +++ b/megamek/src/megamek/client/ui/swing/boardview/BoardView.java @@ -77,6 +77,8 @@ import static megamek.client.ui.swing.tooltip.TipUtil.*; import static megamek.client.ui.swing.util.UIUtil.guiScaledFontHTML; +import static megamek.client.ui.swing.util.UIUtil.uiBlack; +import static megamek.client.ui.swing.util.UIUtil.uiYellow; /** * Displays the board; lets the user scroll around and select points on it. @@ -5492,7 +5494,7 @@ public String getHexTooltip(MouseEvent e) { } else { f += Messages.getString("BoardView1.Tooltip.SensorsHexNotInRange1"); String tmp = Messages.getString("BoardView1.Tooltip.SensorsHexNotInRange2"); - f += "" + tmp + ""; + f += guiScaledFontHTML(GUIP.getWarningColor()) + tmp + ""; f += Messages.getString("BoardView1.Tooltip.SensorsHexNotInRange3"); } } @@ -5509,7 +5511,7 @@ public String getHexTooltip(MouseEvent e) { } } - t = "" + f + ""; + t = guiScaledFontHTML(uiBlack()) + f + ""; String col = "" + t + ""; String row = "" + col + ""; String table = "" + row + "
    "; @@ -5548,7 +5550,7 @@ public String getHexTooltip(MouseEvent e) { } f = "  " + cp.getName(); - b = "" + f + ""; + b = guiScaledFontHTML(cp.getColour().getColour()) + ">" + f + "
    "; t += "" + b + ""; t += "
    "; } @@ -5582,7 +5584,7 @@ public String getHexTooltip(MouseEvent e) { for (AttackSprite aSprite : attackSprites) { if (aSprite.isInside(point)) { f = aSprite.getTooltip().toString(); - t = "" + f + ""; + t = guiScaledFontHTML(uiBlack()) + f + "
    "; String col = "" + t + ""; String row = "" + col + ""; String table = "" + row + "
    "; @@ -5629,7 +5631,7 @@ public String getHexTooltip(MouseEvent e) { } f += " in this hex..."; - t = "" + f + ""; + t = guiScaledFontHTML(UIUtil.uiWhite()) + f + ""; String col = "" + t + ""; String row = "" + col + ""; String table = "" + row + "
    "; @@ -5790,7 +5792,7 @@ public void appendBuildingsTooltip(StringBuffer txt, @Nullable Hex mhex) { bldg.getCurrentCF(mcoords), bldg.getMagnitude()); } - t = "" + f + ""; + t = guiScaledFontHTML(uiBlack()) + f + ""; String col = "" + t + ""; String row = "" + col + ""; String table = "" + row + "
    "; @@ -5806,7 +5808,7 @@ public void appendBuildingsTooltip(StringBuffer txt, @Nullable Hex mhex) { mhex.terrainLevel(Terrains.BLDG_ELEV), Terrains.getEditorName(Terrains.BUILDING), mhex.terrainLevel(Terrains.BLDG_CF), Math.max(mhex.terrainLevel(Terrains.BLDG_ARMOR), 0), BasementType.getType(mhex.terrainLevel(Terrains.BLDG_BASEMENT_TYPE)).toString()); - t = "" + f + ""; + t = guiScaledFontHTML(uiBlack()) + f + ""; String col = "" + t + ""; String row = "" + col + ""; String table = "" + row + "
    "; @@ -5821,7 +5823,7 @@ public void appendBuildingsTooltip(StringBuffer txt, @Nullable Hex mhex) { if (bldg.getBasementCollapsed(mcoords)) { f += Messages.getString("BoardView1.Tooltip.BldgBasementCollapsed"); } - t = "" + f + ""; + t = guiScaledFontHTML(uiBlack()) + f + ""; String col = "" + t + ""; String row = "" + col + ""; String table = "" + row + "
    "; @@ -5842,7 +5844,7 @@ public void appendBuildingsTooltip(StringBuffer txt, @Nullable Hex mhex) { f = Messages.getString("BoardView1.Tooltip.Bridge", mhex.terrainLevel(Terrains.BRIDGE_ELEV), bldg.toString(), bldg.getCurrentCF(mcoords)); } - t = "" + f + ""; + t = guiScaledFontHTML(uiBlack()) + f + ""; String col = "" + t + ""; String row = "" + col + ""; String table = "" + row + "
    "; diff --git a/megamek/src/megamek/client/ui/swing/tooltip/UnitToolTip.java b/megamek/src/megamek/client/ui/swing/tooltip/UnitToolTip.java index a8be2cedad6..75a56b1736f 100644 --- a/megamek/src/megamek/client/ui/swing/tooltip/UnitToolTip.java +++ b/megamek/src/megamek/client/ui/swing/tooltip/UnitToolTip.java @@ -876,13 +876,13 @@ private static StringBuilder inGameValues(Entity entity, Player localPlayer) { if (entity.isEvading()) { i = addToTT("Evade", BR).toString(); f = "" + i + ""; - f = "" + f + ""; + f = guiScaledFontHTML(GUIP.getWarningColor()) + f + ""; } if ((entity instanceof Infantry) && ((Infantry) entity).isTakingCover()) { i = addToTT("TakingCover", BR).toString(); f = "" + i + ""; - f = "" + f + ""; + f = guiScaledFontHTML(GUIP.getWarningColor()) + f + ""; } if (entity.isCharging()) { @@ -892,7 +892,7 @@ private static StringBuilder inGameValues(Entity entity, Player localPlayer) { if (entity.isMakingDfa()) { i = addToTT("DFA", BR).toString(); f = "" + i + ""; - f = "" + f + ""; + f = guiScaledFontHTML(GUIP.getWarningColor()) + f + ""; } if (entity.isUnjammingRAC()) { @@ -989,7 +989,7 @@ private static StringBuilder inGameValues(Entity entity, Player localPlayer) { String msg_error = Messages.getString("ERROR"); String sa = (swarmAttacker == null) ? msg_error : swarmAttacker.getDisplayName(); f = addToTT("Swarmed", BR, sa).toString(); - s += "" + f + ""; + s += guiScaledFontHTML(GUIP.getWarningColor()) + f + ""; } // Spotting diff --git a/megamek/src/megamek/client/ui/swing/util/UIUtil.java b/megamek/src/megamek/client/ui/swing/util/UIUtil.java index 9b91ae4126a..6b57a0a127a 100644 --- a/megamek/src/megamek/client/ui/swing/util/UIUtil.java +++ b/megamek/src/megamek/client/ui/swing/util/UIUtil.java @@ -255,6 +255,24 @@ public static Color uiLightGreen() { public static Color uiYellow() { return uiBgBrightness() > 130 ? LIGHTUI_YELLOW : DARKUI_YELLOW; } + + /** + * Returns a light red color suitable as a text color. The supplied + * color depends on the UI look and feel and will be lighter for a + * dark UI LAF than for a light UI LAF. + */ + public static Color uiBlack() { + return uiBgBrightness() > 130 ? LIGHTUI_BLACK : DARKUI_BLACK; + } + + /** + * Returns a light red color suitable as a text color. The supplied + * color depends on the UI look and feel and will be lighter for a + * dark UI LAF than for a light UI LAF. + */ + public static Color uiWhite() { + return uiBgBrightness() > 130 ? LIGHTUI_WHITE : DARKUI_WHITE; + } /** * Returns a color for the UI display of Quirks/Advantages. Different @@ -1138,6 +1156,10 @@ public static Font getScaledFont() { private final static Color DARKUI_LIGHTGREEN = new Color(150, 210, 150); private final static Color LIGHTUI_DARKBLUE = new Color(225, 225, 245); private final static Color DARKUI_DARKBLUE = new Color(50, 50, 80); + private final static Color LIGHTUI_BLACK = new Color(0, 0, 0); + private final static Color DARKUI_BLACK = new Color(0, 0, 0); + private final static Color LIGHTUI_WHITE = new Color(255, 255, 255); + private final static Color DARKUI_WHITE = new Color(255, 255, 255); /** Returns an HTML FONT Size String, according to GUIScale (e.g. "style=font-size:22"). */ private static String sizeString() { From 2f8c2f14ede085a5d35280b9dd604fc925af6c0e Mon Sep 17 00:00:00 2001 From: kuronekochomusuke Date: Wed, 18 Jan 2023 13:08:30 -0500 Subject: [PATCH 11/15] unit tool tip fixes 10 --- .../client/ui/swing/boardview/BoardView.java | 2 +- .../client/ui/swing/tooltip/UnitToolTip.java | 45 +++++++++++-------- 2 files changed, 27 insertions(+), 20 deletions(-) diff --git a/megamek/src/megamek/client/ui/swing/boardview/BoardView.java b/megamek/src/megamek/client/ui/swing/boardview/BoardView.java index 85a50c0eb38..26e2d9d6f46 100644 --- a/megamek/src/megamek/client/ui/swing/boardview/BoardView.java +++ b/megamek/src/megamek/client/ui/swing/boardview/BoardView.java @@ -5507,7 +5507,7 @@ public String getHexTooltip(MouseEvent e) { } else { i = Messages.getString("BoardView1.Tooltip.DistanceMoveN", disPM); } - f += "" + i + ""; + f += "" + i + ""; } } diff --git a/megamek/src/megamek/client/ui/swing/tooltip/UnitToolTip.java b/megamek/src/megamek/client/ui/swing/tooltip/UnitToolTip.java index 75a56b1736f..5b9b82b90d8 100644 --- a/megamek/src/megamek/client/ui/swing/tooltip/UnitToolTip.java +++ b/megamek/src/megamek/client/ui/swing/tooltip/UnitToolTip.java @@ -860,28 +860,33 @@ private static StringBuilder inGameValues(Entity entity, Player localPlayer) { // "Has not yet moved" only during movement phase if (!entity.isDone() && game.getPhase().isMovement()) { i = addToTT("NotYetMoved", BR).toString(); - s += "" + i + ""; + f = "" + i + ""; + s += guiScaledFontHTML(GUIP.getColorForMovement(entity.moved)) + f + ""; } else if ((entity.isDone() && game.getPhase().isMovement()) - || game.getPhase().isFiring()) { + || (game.getPhase().isMovementReport()) + || (game.getPhase().isFiring()) + || (game.getPhase().isFiringReport()) + || (game.getPhase().isPhysical()) + || (game.getPhase().isPhysicalReport())) { int tmm = Compute.getTargetMovementModifier(game, entity.getId()).getValue(); if (entity.moved == EntityMovementType.MOVE_NONE) { i = addToTT("NoMove", BR, tmm).toString().toString(); - f = "" + i + ""; + f = "" + i + ""; } else { i = addToTT("MovementF", BR, entity.getMovementString(entity.moved), entity.delta_distance, tmm).toString(); - f = "" + i + ""; + f = "" + i + ""; } // Special Moves if (entity.isEvading()) { i = addToTT("Evade", BR).toString(); - f = "" + i + ""; + f = "" + i + ""; f = guiScaledFontHTML(GUIP.getWarningColor()) + f + ""; } if ((entity instanceof Infantry) && ((Infantry) entity).isTakingCover()) { i = addToTT("TakingCover", BR).toString(); - f = "" + i + ""; + f = "" + i + ""; f = guiScaledFontHTML(GUIP.getWarningColor()) + f + ""; } @@ -891,7 +896,7 @@ private static StringBuilder inGameValues(Entity entity, Player localPlayer) { if (entity.isMakingDfa()) { i = addToTT("DFA", BR).toString(); - f = "" + i + ""; + f = "" + i + ""; f = guiScaledFontHTML(GUIP.getWarningColor()) + f + ""; } @@ -909,6 +914,7 @@ private static StringBuilder inGameValues(Entity entity, Player localPlayer) { } } + i = ""; f = ""; if (entity.isAero()) { @@ -919,7 +925,7 @@ private static StringBuilder inGameValues(Entity entity, Player localPlayer) { // Elevation only i = addToTT("Elev", BR, entity.getElevation()).toString(); } - f = "" + i + ""; + f = "" + i + ""; s += guiScaledFontHTML(uiLightViolet()) + f + ""; s += "
    "; @@ -949,7 +955,7 @@ private static StringBuilder inGameValues(Entity entity, Player localPlayer) { GunEmplacement emp = (GunEmplacement) entity; if (emp.isTurret() && emp.isTurretLocked(emp.getLocTurret())) { i = addToTT("TurretLocked", BR).toString(); - f = "" + i + ""; + f = "" + i + ""; s += guiScaledFontHTML(GUIP.getWarningColor()) + f + ""; } } @@ -994,7 +1000,8 @@ private static StringBuilder inGameValues(Entity entity, Player localPlayer) { // Spotting if (entity.isSpotting() && game.hasEntity(entity.getSpotTargetId())) { - s += addToTT("Spotting", BR, game.getEntity(entity.getSpotTargetId()).getDisplayName()).toString(); + f = addToTT("Spotting", BR, game.getEntity(entity.getSpotTargetId()).getDisplayName()).toString(); + s += guiScaledFontHTML() + f + ""; } // If Double Blind, add information about who sees this Entity @@ -1299,19 +1306,19 @@ private static StringBuilder deploymentWarnings(Entity entity, Player localPlaye // Critical (red) warnings if (entity.getGame().getPlanetaryConditions().whyDoomed(entity, entity.getGame()) != null) { String msg_cannotsurvive = Messages.getString("BoardView1.Tooltip.CannotSurvive"); - f += "
    " + msg_cannotsurvive + " " + entity.getGame().getPlanetaryConditions().whyDoomed(entity, entity.getGame()); + f = "
    " + msg_cannotsurvive + " " + entity.getGame().getPlanetaryConditions().whyDoomed(entity, entity.getGame()); } if (entity.doomedInAtmosphere() && mapSettings.getMedium() == MapSettings.MEDIUM_ATMOSPHERE) { String msg_cannotsurviveatmo = Messages.getString("BoardView1.Tooltip.CannotSurviveAtmo"); - f += "
    " + msg_cannotsurviveatmo; + f = "
    " + msg_cannotsurviveatmo; } if (entity.doomedOnGround() && mapSettings.getMedium() == MapSettings.MEDIUM_GROUND) { String msg_cannotsurviveground = Messages.getString("BoardView1.Tooltip.CannotSurviveGround"); - f += "
    " + msg_cannotsurviveground; + f = "
    " + msg_cannotsurviveground; } if (entity.doomedInSpace() && mapSettings.getMedium() == MapSettings.MEDIUM_SPACE) { String msg_cannotsurvivespace = Messages.getString("BoardView1.Tooltip.CannotSurviveSpace"); - f += "
    " + msg_cannotsurvivespace; + f = "
    " + msg_cannotsurvivespace; } s += guiScaledFontHTML(GUIP.getWarningColor()) + f + ""; @@ -1321,13 +1328,13 @@ private static StringBuilder deploymentWarnings(Entity entity, Player localPlaye || ((entity.getC3Master() == null) && entity.hasC3S()) || (entity.hasNovaCEWS() && (entity.calculateFreeC3Nodes() == 2))) { String msg_unconnectedc3computer = Messages.getString("BoardView1.Tooltip.UnconnectedC3Computer"); - f += "
    " + msg_unconnectedc3computer; + f = "
    " + msg_unconnectedc3computer; } // Non-critical (yellow) warnings if (entity instanceof FighterSquadron && entity.getLoadedUnits().isEmpty()) { String msg_fightersquadronempty = Messages.getString("BoardView1.Tooltip.FighterSquadronEmpty"); - f += "
    " + msg_fightersquadronempty; + f = "
    " + msg_fightersquadronempty; } s += guiScaledFontHTML(uiYellow()) + f + ""; @@ -1372,7 +1379,7 @@ private static StringBuilder forceEntry(Entity entity, Player localPlayer) { color = GUIP.getAllyUnitColor(); } color = addGray(color, 128).brighter(); - f += "
    "; + f = "
    "; var forceChain = entity.getGame().getForces().forceChain(entity); for (int i = forceChain.size() - 1; i >= 0; i--) { f += forceChain.get(i).getName(); @@ -1397,10 +1404,10 @@ private static StringBuilder c3Info(Entity entity) { if (entity.hasNhC3()) { String msg_c3i = Messages.getString("BoardView1.Tooltip.C3i"); String msg_nc3 = Messages.getString("BoardView1.Tooltip.NC3"); - f += entity.hasC3i() ? msg_c3i : msg_nc3; + f = entity.hasC3i() ? msg_c3i : msg_nc3; } else { String msg_c3 = Messages.getString("BoardView1.Tooltip.C3"); - f += msg_c3; + f = msg_c3; } String msg_network = Messages.getString("BoardView1.Tooltip.Network"); f += " " + msg_network + ":
      "; From fe6cf9cea02956211471480e4d735e6a2eef14ab Mon Sep 17 00:00:00 2001 From: kuronekochomusuke Date: Wed, 18 Jan 2023 16:22:54 -0500 Subject: [PATCH 12/15] unit tool tip fixes 11 --- .../i18n/megamek/client/messages.properties | 14 +++--- .../ui/swing/boardview/AttackSprite.java | 19 ++++---- .../client/ui/swing/boardview/BoardView.java | 43 +++++++++++++------ .../client/ui/swing/tooltip/UnitToolTip.java | 9 ++-- 4 files changed, 55 insertions(+), 30 deletions(-) diff --git a/megamek/i18n/megamek/client/messages.properties b/megamek/i18n/megamek/client/messages.properties index 4c058c053a0..5573705df53 100644 --- a/megamek/i18n/megamek/client/messages.properties +++ b/megamek/i18n/megamek/client/messages.properties @@ -489,8 +489,10 @@ BoardView1.Tooltip.AP=AP BoardView1.Tooltip.ArmorInternals=Armor {0}; Internal {1} BoardView1.Tooltip.ArmorCapital=Capital BoardView1.Tooltip.Armor=Armor: {0} -BoardView1.Tooltip.ArtilleryAttack1=Artillery: {0} in 1 turn
      Ammo: {1} -BoardView1.Tooltip.ArtilleryAttackN=Artillery: {0} in {2} turns
      Ammo: {1} +BoardView1.Tooltip.ArtilleryAttackOne1=Artillery: {0} in 1 turn +BoardView1.Tooltip.ArtilleryAttackOne2=Ammo: {0} +BoardView1.Tooltip.ArtilleryAttackN1=Artillery: {0} in {1} turns +BoardView1.Tooltip.ArtilleryAttackN2=Ammo: {0} BoardView1.Tooltip.Arrow=➡ BoardView1.Tooltip.BlockColored={0} BoardView1.Tooltip.BV=BV: {0} / {1} ({2, number, percent}) @@ -575,7 +577,7 @@ BoardView1.Tooltip.Undamaged=UNDAMAGED BoardView1.Tooltip.UnjammingRAC=Unjamming RAC BoardView1.Tooltip.Unknown=UNKNOWN BoardView1.Tooltip.Weapon={3} {1}{2} -BoardView1.Tooltip.Wreckof=Wreck of +BoardView1.Tooltip.Wreckof=Wreck of BoardView1.Tooltip.X=x BoardView1.Tooltip.ZZ=ZZ @@ -587,8 +589,10 @@ BoardView1.Tooltip.BldgBasementCollapsed=
    (collapsed)Height: {0}, CF: {2} BoardView1.Tooltip.FuelTank={1}
    Height: {0}, CF: {2}
    Magnitude: {3} -BoardView1.Tooltip.ArtyAutoHint=You can show all players'
    deployment zones on the board
    by pressing {0}.
    -BoardView1.Tooltip.ArtyAutoHeader=Deployment Hex for Players:
    +BoardView1.Tooltip.ArtyAutoHint1=You can show all players' +BoardView1.Tooltip.ArtyAutoHint2=deployment zones on the board +BoardView1.Tooltip.ArtyAutoHint3= by pressing {0}. +BoardView1.Tooltip.ArtyAutoHeader=Deployment Hex for Players: #Hidden Units BoardView1.Tooltip.Hidden=Hidden! diff --git a/megamek/src/megamek/client/ui/swing/boardview/AttackSprite.java b/megamek/src/megamek/client/ui/swing/boardview/AttackSprite.java index 7c782e486e7..dc47713a621 100644 --- a/megamek/src/megamek/client/ui/swing/boardview/AttackSprite.java +++ b/megamek/src/megamek/client/ui/swing/boardview/AttackSprite.java @@ -10,11 +10,7 @@ import megamek.client.ui.Messages; import megamek.client.ui.swing.util.StraightArrowPolygon; -import megamek.common.Compute; -import megamek.common.Coords; -import megamek.common.Entity; -import megamek.common.Targetable; -import megamek.common.WeaponType; +import megamek.common.*; import megamek.common.actions.AttackAction; import megamek.common.actions.ChargeAttackAction; import megamek.common.actions.ClubAttackAction; @@ -25,8 +21,10 @@ import megamek.common.actions.PushAttackAction; import megamek.common.actions.SearchlightAttackAction; import megamek.common.actions.WeaponAttackAction; +import megamek.common.enums.GamePhase; import static megamek.client.ui.swing.util.UIUtil.guiScaledFontHTML; +import static megamek.client.ui.swing.util.UIUtil.uiBlack; /** * Sprite and info for an attack. Does not actually use the image buffer as @@ -375,13 +373,18 @@ public void addWeapon(SearchlightAttackAction attack) { @Override public StringBuffer getTooltip() { + GamePhase phase = this.boardView1.game.getPhase(); String s = ""; String f = ""; f = attackerDesc + "
      " + Messages.getString("BoardView1.on") + " " + targetDesc; - s = guiScaledFontHTML(attackColor.getRGB()) + f + "
    "; - for (String wpD: weaponDescs) { - s += "
    "+wpD; + s = guiScaledFontHTML(attackColor) + f + "
    "; + f = ""; + if ((phase.isFiring()) || (phase.isPhysical())) { + for (String wpD : weaponDescs) { + f += "
    " + wpD; + } + s += guiScaledFontHTML(uiBlack()) + f + "
    "; } return new StringBuffer().append(s); } diff --git a/megamek/src/megamek/client/ui/swing/boardview/BoardView.java b/megamek/src/megamek/client/ui/swing/boardview/BoardView.java index 26e2d9d6f46..88060ecc0b6 100644 --- a/megamek/src/megamek/client/ui/swing/boardview/BoardView.java +++ b/megamek/src/megamek/client/ui/swing/boardview/BoardView.java @@ -78,6 +78,7 @@ import static megamek.client.ui.swing.tooltip.TipUtil.*; import static megamek.client.ui.swing.util.UIUtil.guiScaledFontHTML; import static megamek.client.ui.swing.util.UIUtil.uiBlack; +import static megamek.client.ui.swing.util.UIUtil.uiWhite; import static megamek.client.ui.swing.util.UIUtil.uiYellow; /** @@ -5452,6 +5453,7 @@ public String getHexTooltip(MouseEvent e) { if (!game.getBoard().contains(mcoords)) { return null; } + Hex mhex = game.getBoard().getHex(mcoords); String b = ""; @@ -5546,11 +5548,11 @@ public String getHexTooltip(MouseEvent e) { if (game.getBoard().isLegalDeployment(mcoords, cp)) { if (!foundPlayer) { foundPlayer = true; - t += Messages.getString("BoardView1.Tooltip.ArtyAutoHeader"); + t += Messages.getString("BoardView1.Tooltip.ArtyAutoHeader") + "
    "; } f = "  " + cp.getName(); - b = guiScaledFontHTML(cp.getColour().getColour()) + ">" + f + ""; + b = guiScaledFontHTML(cp.getColour().getColour()) + f + ""; t += "" + b + ""; t += "
    "; } @@ -5565,7 +5567,12 @@ public String getHexTooltip(MouseEvent e) { keybindText += "+"; } keybindText += KeyEvent.getKeyText(KeyCommandBind.getBindByCmd("autoArtyDeployZone").key); - s += Messages.getString("BoardView1.Tooltip.ArtyAutoHint", keybindText); + i = Messages.getString("BoardView1.Tooltip.ArtyAutoHint1") + "
    "; + i += Messages.getString("BoardView1.Tooltip.ArtyAutoHint2") + "
    "; + i += Messages.getString("BoardView1.Tooltip.ArtyAutoHint3", keybindText); + t += "" + i + ""; + + t = guiScaledFontHTML(uiWhite()) + t + ""; String col = "" + t + ""; String row = "" + col + ""; @@ -5597,7 +5604,7 @@ public String getHexTooltip(MouseEvent e) { for (var wSprite : wreckList) { if (wSprite.getPosition().equals(mcoords)) { f = wSprite.getTooltip().toString(); - t = guiScaledFontHTML() + f + ""; + t = guiScaledFontHTML(uiBlack()) + f + ""; String col = "" + t + ""; String row = "" + col + ""; String table = "" + row + "
    "; @@ -5656,11 +5663,16 @@ public String getHexTooltip(MouseEvent e) { } if (aaa.getTurnsTilHit() == 1) { - t = Messages.getString("BoardView1.Tooltip.ArtilleryAttack1", wpName, ammoName); + f = Messages.getString("BoardView1.Tooltip.ArtilleryAttackOne1", wpName); + f += "
      "; + f += Messages.getString("BoardView1.Tooltip.ArtilleryAttackOne2", ammoName); } else { - t = Messages.getString("BoardView1.Tooltip.ArtilleryAttackN", wpName, ammoName, aaa.getTurnsTilHit()); + f = Messages.getString("BoardView1.Tooltip.ArtilleryAttackN1", wpName, aaa.getTurnsTilHit()); + f += "
      "; + f += Messages.getString("BoardView1.Tooltip.ArtilleryAttackN2", ammoName); } + t = guiScaledFontHTML(UIUtil.uiWhite()) + f + ""; String col = "" + t + ""; String row = "" + col + ""; String table = "" + row + "
    "; @@ -5680,16 +5692,18 @@ public String getHexTooltip(MouseEvent e) { } if (amod == TargetRoll.AUTOMATIC_SUCCESS) { - s += Messages.getString("BoardView1.ArtilleryAutohit"); + f = Messages.getString("BoardView1.ArtilleryAutohit"); } else { - s += Messages.getString("BoardView1.ArtilleryAdjustment", amod); + f = Messages.getString("BoardView1.ArtilleryAdjustment", amod); } - s += "
    "; + f = guiScaledFontHTML(UIUtil.uiWhite()) + f + ""; + s += f + "
    "; } final Collection shdList = game.getBoard().getSpecialHexDisplay(mcoords); int round = game.getRoundCount(); if (shdList != null) { + f = ""; boolean isHexAutoHit = localPlayer.getArtyAutoHitHexes().contains(mcoords); for (SpecialHexDisplay shd : shdList) { boolean isTypeAutoHit = shd.getType() == SpecialHexDisplay.Type.ARTILLERY_AUTOHIT; @@ -5703,17 +5717,20 @@ public String getHexTooltip(MouseEvent e) { || (isHexAutoHit && isTypeAutoHit))) { if (shd.getType() == SpecialHexDisplay.Type.PLAYER_NOTE) { if (localPlayer.equals(shd.getOwner())) { - s += "Note: "; + f += "Note: "; } else { - s += "Note (" + shd.getOwner().getName() + "): "; + f += "Note (" + shd.getOwner().getName() + "): "; } } String buf = shd.getInfo(); buf = buf.replaceAll("\\n", "
    "); - s += buf; - s += "
    "; + f += buf; + f = guiScaledFontHTML(UIUtil.uiWhite()) + f + ""; + f += "
    "; } } + + s += f; } String d = "
    " + s + "
    "; diff --git a/megamek/src/megamek/client/ui/swing/tooltip/UnitToolTip.java b/megamek/src/megamek/client/ui/swing/tooltip/UnitToolTip.java index 5b9b82b90d8..71fe3ea4340 100644 --- a/megamek/src/megamek/client/ui/swing/tooltip/UnitToolTip.java +++ b/megamek/src/megamek/client/ui/swing/tooltip/UnitToolTip.java @@ -196,8 +196,9 @@ private static String locationHeader(Entity entity, int location) { private static StringBuilder sysCrits(Entity entity, int type, int index, int loc, String l) { String s = ""; String f = ""; - int good = entity.getGoodCriticals(type, index, loc); + int total = entity.getNumberOfCriticals(type, index, loc); int hits = entity.getHitCriticals(type, index, loc); + int good = total - hits; boolean bad = (entity.getBadCriticals(type,index, loc) > 0); if ((good + hits) > 0) { @@ -420,15 +421,15 @@ private static StringBuilder systemBar(int good, int bad, boolean destroyed) { if (good > 0) { if (!destroyed) { f = repeat(iChar, good); - s += guiScaledFontHTML(colorIntact, TT_SMALLFONT_DELTA) + f + ""; + s = guiScaledFontHTML(colorIntact, TT_SMALLFONT_DELTA) + f + ""; } else { f = repeat(iChar, good); - s += guiScaledFontHTML(colorDamaged, TT_SMALLFONT_DELTA) + f + ""; + s = guiScaledFontHTML(colorDamaged, TT_SMALLFONT_DELTA) + f + ""; } } if (bad > 0) { f =repeat(dChar, bad); - s += guiScaledFontHTML(colorDamaged, TT_SMALLFONT_DELTA) + f + ""; + s = guiScaledFontHTML(colorDamaged, TT_SMALLFONT_DELTA) + f + ""; } return new StringBuilder().append(s); } From 54c44816f4c274852cf4944851847f4b7f0c5ff2 Mon Sep 17 00:00:00 2001 From: kuronekochomusuke Date: Wed, 18 Jan 2023 21:19:26 -0500 Subject: [PATCH 13/15] unit tool tip fixes 12 --- .../ui/swing/boardview/AttackSprite.java | 8 +- .../client/ui/swing/boardview/BoardView.java | 88 +++++---- .../client/ui/swing/tooltip/PilotToolTip.java | 48 ++--- .../client/ui/swing/tooltip/UnitToolTip.java | 172 +++++++++--------- .../ui/swing/unitDisplay/SummaryPanel.java | 6 +- 5 files changed, 162 insertions(+), 160 deletions(-) diff --git a/megamek/src/megamek/client/ui/swing/boardview/AttackSprite.java b/megamek/src/megamek/client/ui/swing/boardview/AttackSprite.java index dc47713a621..a62b8a92bec 100644 --- a/megamek/src/megamek/client/ui/swing/boardview/AttackSprite.java +++ b/megamek/src/megamek/client/ui/swing/boardview/AttackSprite.java @@ -374,18 +374,18 @@ public void addWeapon(SearchlightAttackAction attack) { @Override public StringBuffer getTooltip() { GamePhase phase = this.boardView1.game.getPhase(); - String s = ""; + String result = ""; String f = ""; f = attackerDesc + "
      " + Messages.getString("BoardView1.on") + " " + targetDesc; - s = guiScaledFontHTML(attackColor) + f + ""; + result = guiScaledFontHTML(attackColor) + f + ""; f = ""; if ((phase.isFiring()) || (phase.isPhysical())) { for (String wpD : weaponDescs) { f += "
    " + wpD; } - s += guiScaledFontHTML(uiBlack()) + f + ""; + result += guiScaledFontHTML(uiBlack()) + f + ""; } - return new StringBuffer().append(s); + return new StringBuffer().append(result); } } \ No newline at end of file diff --git a/megamek/src/megamek/client/ui/swing/boardview/BoardView.java b/megamek/src/megamek/client/ui/swing/boardview/BoardView.java index 88060ecc0b6..6a6b37d7182 100644 --- a/megamek/src/megamek/client/ui/swing/boardview/BoardView.java +++ b/megamek/src/megamek/client/ui/swing/boardview/BoardView.java @@ -79,7 +79,6 @@ import static megamek.client.ui.swing.util.UIUtil.guiScaledFontHTML; import static megamek.client.ui.swing.util.UIUtil.uiBlack; import static megamek.client.ui.swing.util.UIUtil.uiWhite; -import static megamek.client.ui.swing.util.UIUtil.uiYellow; /** * Displays the board; lets the user scroll around and select points on it. @@ -5459,7 +5458,7 @@ public String getHexTooltip(MouseEvent e) { String b = ""; String f = ""; String t = ""; - String s = ""; + String result = ""; String i = ""; StringBuffer sb = new StringBuffer(); //StringBuffer txt = new StringBuffer(); @@ -5517,21 +5516,22 @@ public String getHexTooltip(MouseEvent e) { String col = "" + t + ""; String row = "" + col + ""; String table = "" + row + "
    "; - s += table; + result += table; sb = new StringBuffer(); appendBuildingsTooltip(sb, mhex); - s += sb.toString(); + result += sb.toString(); if (displayInvalidHexInfo) { StringBuffer errBuff = new StringBuffer(); if (!mhex.isValid(errBuff)) { - s += Messages.getString("BoardView1.invalidHex"); - s += "
    "; + f = Messages.getString("BoardView1.invalidHex"); + f += "
    "; String errors = errBuff.toString(); errors = errors.replace("\n", "
    "); - s += errors; - s += "
    "; + f += errors; + f = guiScaledFontHTML(uiWhite()) + f + ""; + result += "
    " + f; } } } @@ -5577,13 +5577,13 @@ public String getHexTooltip(MouseEvent e) { String col = "" + t + ""; String row = "" + col + ""; String table = "" + row + "
    "; - s += table; + result += table; } // check if it's on any flares for (FlareSprite fSprite : flareSprites) { if (fSprite.isInside(point)) { - s += fSprite.getTooltip().toString(); + result += fSprite.getTooltip().toString(); } } @@ -5595,7 +5595,7 @@ public String getHexTooltip(MouseEvent e) { String col = "" + t + ""; String row = "" + col + ""; String table = "" + row + "
    "; - s += table; + result += table; } } @@ -5608,7 +5608,7 @@ public String getHexTooltip(MouseEvent e) { String col = "" + t + ""; String row = "" + col + ""; String table = "" + row + "
    "; - s += table; + result += table; } } @@ -5625,7 +5625,7 @@ public String getHexTooltip(MouseEvent e) { if (entityCount <= maxShown) { sb = new StringBuffer(); appendEntityTooltip(sb, entity); - s += sb.toString(); + result += sb.toString(); } } // Info block if there are more than 4 units in that hex @@ -5642,7 +5642,7 @@ public String getHexTooltip(MouseEvent e) { String col = "" + t + ""; String row = "" + col + ""; String table = "" + row + "
    "; - s += table; + result += table; } // Artillery attacks @@ -5676,7 +5676,7 @@ public String getHexTooltip(MouseEvent e) { String col = "" + t + ""; String row = "" + col + ""; String table = "" + row + "
    "; - s += table; + result += table; } // Artillery fire adjustment @@ -5697,7 +5697,7 @@ public String getHexTooltip(MouseEvent e) { f = Messages.getString("BoardView1.ArtilleryAdjustment", amod); } f = guiScaledFontHTML(UIUtil.uiWhite()) + f + ""; - s += f + "
    "; + result += f + "
    "; } final Collection shdList = game.getBoard().getSpecialHexDisplay(mcoords); @@ -5730,10 +5730,10 @@ public String getHexTooltip(MouseEvent e) { } } - s += f; + result += f; } - String d = "
    " + s + "
    "; + String d = "
    " + result + "
    "; StringBuffer txt = new StringBuffer(); txt.append(HTML_BEGIN + d + HTML_END); @@ -5764,7 +5764,10 @@ public void appendTerrainTooltip(StringBuffer txt, @Nullable Hex mhex) { Coords mcoords = mhex.getCoords(); - String s = Messages.getString("BoardView1.Tooltip.Hex", mcoords.getBoardNum(), mhex.getLevel()) + "
    "; + String result = ""; + String f = ""; + + f += Messages.getString("BoardView1.Tooltip.Hex", mcoords.getBoardNum(), mhex.getLevel()) + "
    "; // cycle through the terrains and report types found for (int terType: mhex.getTerrainTypes()) { @@ -5774,10 +5777,12 @@ public void appendTerrainTooltip(StringBuffer txt, @Nullable Hex mhex) { if (name != null) { String msg_tf = Messages.getString("BoardView1.Tooltip.TF"); name += (tf > 0) ? " (" + msg_tf + ": " + tf + ")" : ""; - s += name + "
    "; + f += name + "
    "; } } - txt.append("" + s + ""); + + result += guiScaledFontHTML(UIUtil.uiBlack()) + f + ""; + txt.append(result); } /** @@ -5789,7 +5794,7 @@ public void appendBuildingsTooltip(StringBuffer txt, @Nullable Hex mhex) { } Coords mcoords = mhex.getCoords(); String f = ""; - String s = ""; + String result = ""; String t = ""; // Fuel Tank @@ -5813,7 +5818,7 @@ public void appendBuildingsTooltip(StringBuffer txt, @Nullable Hex mhex) { String col = "" + t + ""; String row = "" + col + ""; String table = "" + row + "
    "; - s += table; + result += table; } // Building @@ -5829,7 +5834,7 @@ public void appendBuildingsTooltip(StringBuffer txt, @Nullable Hex mhex) { String col = "" + t + ""; String row = "" + col + ""; String table = "" + row + "
    "; - s += table; + result += table; } else { Building bldg = game.getBoard().getBuildingAt(mcoords); f = Messages.getString("BoardView1.Tooltip.Building", @@ -5844,7 +5849,7 @@ public void appendBuildingsTooltip(StringBuffer txt, @Nullable Hex mhex) { String col = "" + t + ""; String row = "" + col + ""; String table = "" + row + "
    "; - s += table; + result += table; } } @@ -5865,7 +5870,7 @@ public void appendBuildingsTooltip(StringBuffer txt, @Nullable Hex mhex) { String col = "" + t + ""; String row = "" + col + ""; String table = "" + row + "
    "; - s += table; + result += table; } if (game.containsMinefield(mcoords)) { @@ -5873,35 +5878,33 @@ public void appendBuildingsTooltip(StringBuffer txt, @Nullable Hex mhex) { for (int i = 0; i < minefields.size(); i++) { Minefield mf = minefields.elementAt(i); String owner = " (" + game.getPlayer(mf.getPlayerId()).getName() + ")"; + f = mf.getName() + " " + Messages.getString("BoardView1.minefield") + " (" + mf.getDensity()+ ")"; switch (mf.getType()) { case Minefield.TYPE_CONVENTIONAL: case Minefield.TYPE_COMMAND_DETONATED: - s += mf.getName() + Messages.getString("BoardView1.minefield") + "(" + mf.getDensity()+ ")" + " " + owner; + case Minefield.TYPE_ACTIVE: + case Minefield.TYPE_INFERNO: + f += " " + owner; break; case Minefield.TYPE_VIBRABOMB: if (mf.getPlayerId() == localPlayer.getId()) { - s += mf.getName() + Messages.getString("BoardView1.minefield") - + "(" + mf.getDensity() + ")" + "(" - + mf.getSetting() + ") "+ owner; + f += "(" + mf.getSetting() + ") " + owner; } else { - s += mf.getName() + Messages.getString("BoardView1.minefield") + "(" + mf.getDensity() + ")" + " " + owner; + f += owner; } break; - case Minefield.TYPE_ACTIVE: - case Minefield.TYPE_INFERNO: - s += mf.getName() + Messages.getString("BoardView1.minefield") - + "(" + mf.getDensity() + ")" + owner; - break; default: break; } - s +="
    "; + f = guiScaledFontHTML(UIUtil.uiWhite()) + f + ""; + result += f; + result += "
    "; } } - txt.append(s); + txt.append(result); } /** * Appends HTML describing a given Entity aka Unit @@ -5911,7 +5914,9 @@ public void appendEntityTooltip(StringBuffer txt, @Nullable Entity entity) { return; } - txt.append("
    "); + String result = ""; + + result += "
    "; // Table to add a bar to the left of an entity in // the player's color String color = "C0C0C0"; @@ -5922,7 +5927,10 @@ public void appendEntityTooltip(StringBuffer txt, @Nullable Entity entity) { // Entity tooltip String col2 = "" + UnitToolTip.getEntityTipGame(entity, getLocalPlayer()) + ""; String row = "" + col1 + col2 + ""; - txt.append("" + row + "
    "); + String table = "" + row + "
    "; + result += table; + + txt.append(result); } private ArrayList getArtilleryAttacksAtLocation(Coords c) { diff --git a/megamek/src/megamek/client/ui/swing/tooltip/PilotToolTip.java b/megamek/src/megamek/client/ui/swing/tooltip/PilotToolTip.java index 4d9bdc7b559..aeaed66895a 100644 --- a/megamek/src/megamek/client/ui/swing/tooltip/PilotToolTip.java +++ b/megamek/src/megamek/client/ui/swing/tooltip/PilotToolTip.java @@ -51,10 +51,10 @@ public static StringBuilder getPilotTipShort(Entity entity, boolean showPortrait // PRIVATE private static StringBuilder getPilotTip(final Entity entity, boolean detailed, boolean showPortrait, boolean showDefaultPortrait) { - String s = ""; + String result = ""; if (!detailed) { - s += "
    "; + result += "
    "; } // The crew info (names etc.) and portraits, if shown, are placed @@ -66,26 +66,26 @@ private static StringBuilder getPilotTip(final Entity entity, boolean detailed, cols += crewInfoCell(entity).toString(); String row = "" + cols + ""; - s += "" + row + "
    "; - s = "
    " + s + "
    "; + String table = "" + row + "
    "; + result += "
    " + table + "
    "; if (!detailed) { - s += "
    "; + result += "
    "; } else { - s += scaledHTMLSpacer(3); + result += scaledHTMLSpacer(3); } - return new StringBuilder().append(s); + return new StringBuilder().append(result); } /** The crew advantages and MD */ public static StringBuilder getCrewAdvs(Entity entity, boolean detailed) { - String s = ""; + String result = ""; String f = ""; f = crewAdvs(entity, detailed).toString(); - s = scaledHTMLSpacer(3) + f + ""; + result = scaledHTMLSpacer(3) + f + ""; - return new StringBuilder().append(s); + return new StringBuilder().append(result); } /** Returns a tooltip part with names and skills of the crew. */ @@ -93,7 +93,7 @@ private static StringBuilder crewInfoCell(final Entity entity) { Crew crew = entity.getCrew(); Game game = entity.getGame(); String f = ""; - String s = ""; + String result = ""; // Name / Callsign and Status for each crew member for (int i = 0; i < crew.getSlotCount(); i++) { @@ -103,30 +103,30 @@ private static StringBuilder crewInfoCell(final Entity entity) { if ((crew.getNickname(i) != null) && !crew.getNickname(i).isBlank()) { f = "'" + crew.getNickname(i).toUpperCase() + "'"; - s += guiScaledFontHTML(UIUtil.uiNickColor()) + f + ""; + result += guiScaledFontHTML(UIUtil.uiNickColor()) + f + ""; } else if ((crew.getName(i) != null) && !crew.getName(i).isBlank()) { - s += crew.getName(i); + result += crew.getName(i); } else { - s += Messages.getString("BoardView1.Tooltip.Pilot"); + result += Messages.getString("BoardView1.Tooltip.Pilot"); } if (crew.getSlotCount() > 1) { - s += " \u2B1D " + crew.getCrewType().getRoleName(i); + result += " \u2B1D " + crew.getCrewType().getRoleName(i); } if (!crew.getStatusDesc(i).isEmpty()) { - s += guiScaledFontHTML(GUIPreferences.getInstance().getWarningColor()) + " (" + crew.getStatusDesc(i) + ")"; + result += guiScaledFontHTML(GUIPreferences.getInstance().getWarningColor()) + " (" + crew.getStatusDesc(i) + ")"; } - s += "
    "; + result += "
    "; } // Effective entity skill for the whole crew boolean rpg_skills = game.getOptions().booleanOption(OptionsConstants.RPG_RPG_GUNNERY); - s += CrewSkillSummaryUtil.getSkillNames(entity) + ": " + crew.getSkillsAsString(rpg_skills); - - s = guiScaledFontHTML() + s + ""; + result += CrewSkillSummaryUtil.getSkillNames(entity) + ": " + crew.getSkillsAsString(rpg_skills); + + result = guiScaledFontHTML() + result + ""; - String col = "" + s + ""; + String col = "" + result + ""; return new StringBuilder().append(col); } @@ -170,12 +170,12 @@ private static StringBuilder crewPortraits(final Entity entity, boolean showDefa * groups and number of advantages per group are given. */ private static StringBuilder crewAdvs(final Entity entity, boolean detailed) { - String s = ""; + String result = ""; String f = ""; Crew crew = entity.getCrew(); f = getOptionList(crew.getOptions().getGroups(), crew::countOptions, detailed).toString(); - s = guiScaledFontHTML(uiQuirksColor(), UnitToolTip.TT_SMALLFONT_DELTA) + f + ""; - return new StringBuilder().append(s); + result = guiScaledFontHTML(uiQuirksColor(), UnitToolTip.TT_SMALLFONT_DELTA) + f + ""; + return new StringBuilder().append(result); } } diff --git a/megamek/src/megamek/client/ui/swing/tooltip/UnitToolTip.java b/megamek/src/megamek/client/ui/swing/tooltip/UnitToolTip.java index 71fe3ea4340..a204ccaace9 100644 --- a/megamek/src/megamek/client/ui/swing/tooltip/UnitToolTip.java +++ b/megamek/src/megamek/client/ui/swing/tooltip/UnitToolTip.java @@ -74,7 +74,7 @@ private static StringBuilder getEntityTipTable(Entity entity, Player localPlayer return new StringBuilder(msg_senorreturn); } - String s = ""; + String result = ""; String f = ""; String p = ""; Game game = entity.getGame(); @@ -106,12 +106,12 @@ private static StringBuilder getEntityTipTable(Entity entity, Player localPlayer } } - s += p; + result += p; p = ""; // An empty squadron should not show any info if (entity instanceof FighterSquadron && entity.getLoadedUnits().isEmpty()) { - String col = "" + s + ""; + String col = "" + result + ""; String row = "" + col + ""; String table = "" + row + "
    "; return new StringBuilder().append(table); @@ -119,32 +119,29 @@ private static StringBuilder getEntityTipTable(Entity entity, Player localPlayer // Static entity values like move capability f = entityValues(entity).toString(); - p += guiScaledFontHTML() + f + ""; + result += guiScaledFontHTML() + f + ""; // Status bar visual representation of armor and IS if (GUIP.getBoolean(GUIPreferences.SHOW_ARMOR_MINIVIS_TT)) { - p += addArmorMiniVisToTT(entity); + result += addArmorMiniVisToTT(entity); } // Weapon List if (GUIP.getBoolean(GUIPreferences.SHOW_WPS_IN_TT)) { f = weaponList(entity).toString(); f += ecmInfo(entity).toString(); - p += guiScaledFontHTML() + f + ""; + result += guiScaledFontHTML() + f + ""; } - s += p; - p = ""; - // Bomb List - s += bombList(entity); + result += bombList(entity); // StratOps quirks, chassis and weapon if (game.getOptions().booleanOption(OptionsConstants.ADVANCED_STRATOPS_QUIRKS)) { - f = ""; + f = "
    "; String quirksList = getOptionList(entity.getQuirks().getGroups(), entity::countQuirks, details); if (!quirksList.isEmpty()) { - f = quirksList; + f += quirksList; } for (Mounted weapon: entity.getWeaponList()) { String wpQuirksList = getOptionList(weapon.getQuirks().getGroups(), @@ -154,7 +151,7 @@ private static StringBuilder getEntityTipTable(Entity entity, Player localPlayer f += wpQuirksList.replace(":

    ", ":"); } } - p += guiScaledFontHTML(uiQuirksColor(), TT_SMALLFONT_DELTA) + f + ""; + result += guiScaledFontHTML(uiQuirksColor(), TT_SMALLFONT_DELTA) + f + ""; } // Partial repairs @@ -162,21 +159,18 @@ private static StringBuilder getEntityTipTable(Entity entity, Player localPlayer grp -> entity.countPartialRepairs(), details); if (!partialList.isEmpty()) { f = partialList; - p += guiScaledFontHTML(uiPartialRepairColor(), TT_SMALLFONT_DELTA) + f + ""; + result += guiScaledFontHTML(uiPartialRepairColor(), TT_SMALLFONT_DELTA) + f + ""; } if (!entity.getLoadedUnits().isEmpty()) { - p += carriedUnits(entity); + result += carriedUnits(entity); } if (details && entity.hasAnyC3System()) { - p += c3Info(entity); + result += c3Info(entity); } - s += p; - p = ""; - - String col = "" + s + ""; + String col = "" + result + ""; String row = "" + col + ""; String table = "" + row + "
    "; @@ -194,7 +188,7 @@ private static String locationHeader(Entity entity, int location) { } private static StringBuilder sysCrits(Entity entity, int type, int index, int loc, String l) { - String s = ""; + String result = ""; String f = ""; int total = entity.getNumberOfCriticals(type, index, loc); int hits = entity.getHitCriticals(type, index, loc); @@ -203,11 +197,11 @@ private static StringBuilder sysCrits(Entity entity, int type, int index, int lo if ((good + hits) > 0) { f = "  " + l + ": "; - s = guiScaledFontHTML(TT_SMALLFONT_DELTA) + f + ""; - s += systemBar(good, hits, bad); + result = guiScaledFontHTML(TT_SMALLFONT_DELTA) + f + ""; + result += systemBar(good, hits, bad); } - return new StringBuilder().append(s); + return new StringBuilder().append(result); } /** Returns the graphical Armor representation. */ @@ -352,7 +346,7 @@ private static StringBuilder locBar(int orig, int curr, String dChar, boolean de return new StringBuilder(""); } - String s = ""; + String result = ""; String f = ""; Color colorIntact = GUIP.getColor(GUIPreferences.ADVANCED_ARMORMINI_COLOR_INTACT); Color colorPartialDmg = GUIP.getColor(GUIPreferences.ADVANCED_ARMORMINI_COLOR_PARTIAL_DMG); @@ -380,15 +374,15 @@ private static StringBuilder locBar(int orig, int curr, String dChar, boolean de String msg_x = Messages.getString("BoardView1.Tooltip.X"); f = dChar + msg_x + tensIntact * 10; f += repeat(dChar, numIntact - 10 * tensIntact); - s += guiScaledFontHTML(colorIntact, TT_SMALLFONT_DELTA) + f + ""; + result += guiScaledFontHTML(colorIntact, TT_SMALLFONT_DELTA) + f + ""; } else { f = repeat(dChar, numIntact); - s += guiScaledFontHTML(colorIntact, TT_SMALLFONT_DELTA) + f + ""; + result += guiScaledFontHTML(colorIntact, TT_SMALLFONT_DELTA) + f + ""; } } if (numPartial > 0) { f = repeat(dChar, numPartial); - s += guiScaledFontHTML(colorPartialDmg, TT_SMALLFONT_DELTA) + f + ""; + result += guiScaledFontHTML(colorPartialDmg, TT_SMALLFONT_DELTA) + f + ""; } if (numDmgd > 0) { if (numDmgd > 15 && numIntact + numDmgd > 30) { @@ -396,13 +390,13 @@ private static StringBuilder locBar(int orig, int curr, String dChar, boolean de String msg_x = Messages.getString("BoardView1.Tooltip.X"); f = dChar + msg_x + tensDmgd * 10; f += repeat(dChar, numDmgd - 10 * tensDmgd); - s += guiScaledFontHTML(colorIntact, TT_SMALLFONT_DELTA) + f + ""; + result += guiScaledFontHTML(colorIntact, TT_SMALLFONT_DELTA) + f + ""; } else { f = repeat(dChar, numDmgd); - s += guiScaledFontHTML(colorDamaged, TT_SMALLFONT_DELTA) + f + ""; + result += guiScaledFontHTML(colorDamaged, TT_SMALLFONT_DELTA) + f + ""; } } - return new StringBuilder().append(s); + return new StringBuilder().append(result); } private static StringBuilder systemBar(int good, int bad, boolean destroyed) { @@ -411,7 +405,7 @@ private static StringBuilder systemBar(int good, int bad, boolean destroyed) { return new StringBuilder(""); } - String s = ""; + String result = ""; String f = ""; Color colorIntact = GUIP.getColor(GUIPreferences.ADVANCED_ARMORMINI_COLOR_INTACT); Color colorDamaged = GUIP.getColor(GUIPreferences.ADVANCED_ARMORMINI_COLOR_DAMAGED); @@ -421,17 +415,17 @@ private static StringBuilder systemBar(int good, int bad, boolean destroyed) { if (good > 0) { if (!destroyed) { f = repeat(iChar, good); - s = guiScaledFontHTML(colorIntact, TT_SMALLFONT_DELTA) + f + ""; + result = guiScaledFontHTML(colorIntact, TT_SMALLFONT_DELTA) + f + ""; } else { f = repeat(iChar, good); - s = guiScaledFontHTML(colorDamaged, TT_SMALLFONT_DELTA) + f + ""; + result = guiScaledFontHTML(colorDamaged, TT_SMALLFONT_DELTA) + f + ""; } } if (bad > 0) { f =repeat(dChar, bad); - s = guiScaledFontHTML(colorDamaged, TT_SMALLFONT_DELTA) + f + ""; + result = guiScaledFontHTML(colorDamaged, TT_SMALLFONT_DELTA) + f + ""; } - return new StringBuilder().append(s); + return new StringBuilder().append(result); } private static class WeaponInfo { @@ -793,26 +787,27 @@ private static StringBuilder createAmmoEntry(WeaponInfo ammoInfo) { /** Returns a line showing ECM / ECCM. */ private static StringBuilder ecmInfo(Entity entity) { - String s = ""; + String f = ""; + String result = ""; if (entity.hasActiveECM()) { String msg_ecmsource = Messages.getString("BoardView1.ecmSource"); - s += ECM_SIGN + " " + msg_ecmsource; + f += ECM_SIGN + " " + msg_ecmsource; } if (entity.hasActiveECCM()) { String msg_eccmsource = Messages.getString("BoardView1.eccmSource"); - s += ECM_SIGN+ " " +msg_eccmsource; + f += ECM_SIGN+ " " +msg_eccmsource; } - s = guiScaledFontHTML() + s + ""; + result = guiScaledFontHTML() + f + ""; - return new StringBuilder().append(s); + return new StringBuilder().append(result); } /** Returns values that only are relevant when in-game such as heat. */ private static StringBuilder inGameValues(Entity entity, Player localPlayer) { Game game = entity.getGame(); boolean isGunEmplacement = entity instanceof GunEmplacement; - String s = ""; + String result = ""; String f = ""; String i = ""; @@ -827,7 +822,7 @@ private static StringBuilder inGameValues(Entity entity, Player localPlayer) { int currentBV = entity.calculateBattleValue(false, false); int initialBV = entity.getInitialBV(); double percentage = (double) currentBV / initialBV; - s += addToTT("BV", BR, currentBV, initialBV, percentage).toString(); + result += addToTT("BV", BR, currentBV, initialBV, percentage).toString(); } String damageLevel; @@ -854,7 +849,7 @@ private static StringBuilder inGameValues(Entity entity, Player localPlayer) { String msg_undamaged = Messages.getString("BoardView1.Tooltip.Undamaged"); damageLevel = "  " + msg_undamaged; } - s += damageLevel; + result += damageLevel; // Actual Movement if (!isGunEmplacement) { @@ -862,7 +857,7 @@ private static StringBuilder inGameValues(Entity entity, Player localPlayer) { if (!entity.isDone() && game.getPhase().isMovement()) { i = addToTT("NotYetMoved", BR).toString(); f = "" + i + ""; - s += guiScaledFontHTML(GUIP.getColorForMovement(entity.moved)) + f + ""; + result += guiScaledFontHTML(GUIP.getColorForMovement(entity.moved)) + f + ""; } else if ((entity.isDone() && game.getPhase().isMovement()) || (game.getPhase().isMovementReport()) || (game.getPhase().isFiring()) @@ -911,7 +906,7 @@ private static StringBuilder inGameValues(Entity entity, Player localPlayer) { } } - s += guiScaledFontHTML(GUIP.getColorForMovement(entity.moved)) + f + ""; + result += guiScaledFontHTML(GUIP.getColorForMovement(entity.moved)) + f + ""; } } @@ -927,16 +922,16 @@ private static StringBuilder inGameValues(Entity entity, Player localPlayer) { i = addToTT("Elev", BR, entity.getElevation()).toString(); } f = "" + i + ""; - s += guiScaledFontHTML(uiLightViolet()) + f + ""; + result += guiScaledFontHTML(uiLightViolet()) + f + ""; - s += "
    "; + result += "
    "; String msg_facing = Messages.getString("BoardView1.Tooltip.Facing"); f = "  " + msg_facing + ": " + PlanetaryConditions.getWindDirDisplayableName(entity.getFacing()); if (entity.getFacing() != entity.getSecondaryFacing()) { String msg_twist = Messages.getString("BoardView1.Tooltip.Twist"); f = "  " + msg_twist + ": " + PlanetaryConditions.getWindDirDisplayableName(entity.getSecondaryFacing()); } - s += guiScaledFontHTML() + f + ""; + result += guiScaledFontHTML() + f + ""; // Heat, not shown for units with 999 heat sinks (vehicles) if (entity.getHeatCapacity() != 999) { @@ -948,7 +943,7 @@ private static StringBuilder inGameValues(Entity entity, Player localPlayer) { f += addToTT("Heat", BR, heat).toString(); } f += " / "+entity.getHeatCapacity(); - s += guiScaledFontHTML(GUIP.getColorForHeat(heat)) + f + ""; + result += guiScaledFontHTML(GUIP.getColorForHeat(heat)) + f + ""; } // Gun Emplacement Status @@ -957,27 +952,27 @@ private static StringBuilder inGameValues(Entity entity, Player localPlayer) { if (emp.isTurret() && emp.isTurretLocked(emp.getLocTurret())) { i = addToTT("TurretLocked", BR).toString(); f = "" + i + ""; - s += guiScaledFontHTML(GUIP.getWarningColor()) + f + ""; + result += guiScaledFontHTML(GUIP.getWarningColor()) + f + ""; } } // Unit Immobile if (!isGunEmplacement && entity.isImmobile()) { f = addToTT("Immobile", BR).toString(); - s += guiScaledFontHTML(GUIP.getWarningColor()) + f + ""; + result += guiScaledFontHTML(GUIP.getWarningColor()) + f + ""; } // Unit Prone if (!isGunEmplacement && entity.isProne()) { f = addToTT("Prone", BR).toString(); - s += guiScaledFontHTML(GUIP.getWarningColor()) + f + ""; + result += guiScaledFontHTML(GUIP.getWarningColor()) + f + ""; } if (!entity.getHiddenActivationPhase().isUnknown()) { - s += addToTT("HiddenActivating", BR, entity.getHiddenActivationPhase().toString()).toString(); + result += addToTT("HiddenActivating", BR, entity.getHiddenActivationPhase().toString()).toString(); } else if (entity.isHidden()) { - s += addToTT("Hidden", BR).toString(); + result += addToTT("Hidden", BR).toString(); } // Jammed by ECM - don't know how to replicate this correctly from the boardview @@ -996,13 +991,13 @@ private static StringBuilder inGameValues(Entity entity, Player localPlayer) { String msg_error = Messages.getString("ERROR"); String sa = (swarmAttacker == null) ? msg_error : swarmAttacker.getDisplayName(); f = addToTT("Swarmed", BR, sa).toString(); - s += guiScaledFontHTML(GUIP.getWarningColor()) + f + ""; + result += guiScaledFontHTML(GUIP.getWarningColor()) + f + ""; } // Spotting if (entity.isSpotting() && game.hasEntity(entity.getSpotTargetId())) { f = addToTT("Spotting", BR, game.getEntity(entity.getSpotTargetId()).getDisplayName()).toString(); - s += guiScaledFontHTML() + f + ""; + result += guiScaledFontHTML() + f + ""; } // If Double Blind, add information about who sees this Entity @@ -1043,19 +1038,19 @@ private static StringBuilder inGameValues(Entity entity, Player localPlayer) { if (tempList.length() > 1) { tempList.delete(tempList.length() - 2, tempList.length()); f = addToTT("SeenBy", BR, tempList.toString()).toString(); - s += guiScaledFontHTML() + f + ""; + result += guiScaledFontHTML() + f + ""; } } // If sensors, display what sensors this unit is using if (game.getOptions().booleanOption(OptionsConstants.ADVANCED_TACOPS_SENSORS) || game.getOptions().booleanOption(OptionsConstants.ADVAERORULES_STRATOPS_ADVANCED_SENSORS)) { - s += addToTT("Sensors", BR, entity.getSensorDesc(), Compute.getMaxVisualRange(entity, false)).toString(); + result += addToTT("Sensors", BR, entity.getSensorDesc(), Compute.getMaxVisualRange(entity, false)).toString(); } if (entity.hasAnyTypeNarcPodsAttached()) { f = addToTT(entity.hasNarcPodsAttached() ? "Narced" : "INarced", BR).toString(); - s += guiScaledFontHTML(uiLightRed()) + f + ""; + result += guiScaledFontHTML(uiLightRed()) + f + ""; } // Towing @@ -1064,24 +1059,23 @@ private static StringBuilder inGameValues(Entity entity, Player localPlayer) { .map(id -> entity.getGame().getEntity(id).getShortName()) .collect(Collectors.joining(", ")); if (unitList.length() > 1) { - s += addToTT("Towing", BR, unitList).toString(); + result += addToTT("Towing", BR, unitList).toString(); } } // Coloring and italic to make these transient entries stand out - s = guiScaledFontHTML(uiLightViolet()) + s + ""; - s = "" + s + ""; + result = guiScaledFontHTML(uiLightViolet()) + result + ""; + result = "" + result + ""; - return new StringBuilder().append(s); + return new StringBuilder().append(result); } /** Returns unit values that are relevant in-game and in the lobby such as movement ability. */ private static StringBuilder entityValues(Entity entity) { boolean isGunEmplacement = entity instanceof GunEmplacement; - String s = ""; + String result = ""; String f = ""; String d = ""; - String l1= ""; String l2 = ""; String l3 = ""; @@ -1193,7 +1187,7 @@ private static StringBuilder entityValues(Entity entity) { if (entity instanceof Tank) { d += DOT_SPACER; f = entity.getMovementModeAsString(); - d += guiScaledFontHTML(GUIP.getWarningColor()) + f + ""; + d += guiScaledFontHTML(uiWhite()) + f + ""; } if (entity instanceof IBomber) { @@ -1241,7 +1235,7 @@ private static StringBuilder entityValues(Entity entity) { d += DOT_SPACER + guiScaledFontHTML(GUIP.getWarningColor()) + f + ""; } - l1 = "
  • " + d + "
  • "; + l1 = "
  • " + d + "
  • "; d = ""; if ((jumpJetDistroyed > 0) || (jumpBoosterDistroyed > 0) || (paritalWingDistroyed > 0)) { @@ -1293,16 +1287,16 @@ private static StringBuilder entityValues(Entity entity) { d = ""; } - String u = "
      " + l1 + l2 + l3 + l4 + "
    "; - s += u; + String ul = "
      " + l1 + l2 + l3 + l4 + "
    "; + result += ul; - return new StringBuilder().append(s); + return new StringBuilder().append(result); } /** Returns warnings about problems that should be solved before deploying. */ private static StringBuilder deploymentWarnings(Entity entity, Player localPlayer, MapSettings mapSettings) { - String s = ""; + String result = ""; String f = ""; // Critical (red) warnings if (entity.getGame().getPlanetaryConditions().whyDoomed(entity, entity.getGame()) != null) { @@ -1321,7 +1315,7 @@ private static StringBuilder deploymentWarnings(Entity entity, Player localPlaye String msg_cannotsurvivespace = Messages.getString("BoardView1.Tooltip.CannotSurviveSpace"); f = "
    " + msg_cannotsurvivespace; } - s += guiScaledFontHTML(GUIP.getWarningColor()) + f + ""; + result += guiScaledFontHTML(GUIP.getWarningColor()) + f + ""; f = ""; // Non-critical (yellow) warnings @@ -1338,14 +1332,14 @@ private static StringBuilder deploymentWarnings(Entity entity, Player localPlaye f = "
    " + msg_fightersquadronempty; } - s += guiScaledFontHTML(uiYellow()) + f + ""; + result += guiScaledFontHTML(uiYellow()) + f + ""; - return new StringBuilder().append(s); + return new StringBuilder().append(result); } /** Returns a list of units loaded onto this unit. */ private static StringBuilder carriedUnits(Entity entity) { - String s = ""; + String result = ""; String f = ""; if (entity instanceof FighterSquadron) { @@ -1362,13 +1356,13 @@ private static StringBuilder carriedUnits(Entity entity) { } } - s = guiScaledFontHTML() + f + ""; - return new StringBuilder().append(s); + result = guiScaledFontHTML() + f + ""; + return new StringBuilder().append(result); } /** Returns the full force chain the entity is in as one text line. */ private static StringBuilder forceEntry(Entity entity, Player localPlayer) { - String s = ""; + String result = ""; String f = ""; if (entity.partOfForce()) { @@ -1386,15 +1380,15 @@ private static StringBuilder forceEntry(Entity entity, Player localPlayer) { f += forceChain.get(i).getName(); f += i != 0 ? ", " : ""; } - s = guiScaledFontHTML(color) + f + ""; + result = guiScaledFontHTML(color) + f + ""; } - return new StringBuilder().append(s); + return new StringBuilder().append(result); } /** Returns an overview of the C3 system the unit is in. */ private static StringBuilder c3Info(Entity entity) { - String s = ""; + String result = ""; String f = ""; List members = entity.getGame().getEntitiesVector().stream() @@ -1416,13 +1410,13 @@ private static StringBuilder c3Info(Entity entity) { f += "
    "; } - s = guiScaledFontHTML(uiC3Color(), -0.2f) + f + ""; + result = guiScaledFontHTML(uiC3Color(), -0.2f) + f + ""; - return new StringBuilder().append(s); + return new StringBuilder().append(result); } private static String c3UnitName(Entity c3member, Entity entity) { - String s = ""; + String result = ""; String it = ""; String f = ""; String tmp = ""; @@ -1438,16 +1432,16 @@ private static String c3UnitName(Entity c3member, Entity entity) { } f += "" + it + ""; - s += guiScaledFontHTML(uiGray(), -0.2f) + f + ""; - s += c3member.getShortNameRaw(); + result += guiScaledFontHTML(uiGray(), -0.2f) + f + ""; + result += c3member.getShortNameRaw(); String msg_thisunit = Messages.getString("BoardView1.Tooltip.ThisUnit"); it = " (" + msg_thisunit + ")"; tmp = "" + it + ""; f = c3member.equals(entity) ? tmp : ""; - s += guiScaledFontHTML(uiGray(), -0.2f) + f + ""; + result += guiScaledFontHTML(uiGray(), -0.2f) + f + ""; - return s; + return result; } /** Helper method to shorten repetitive calls. */ diff --git a/megamek/src/megamek/client/ui/swing/unitDisplay/SummaryPanel.java b/megamek/src/megamek/client/ui/swing/unitDisplay/SummaryPanel.java index 8cbb303b9fa..5b613b1e9f3 100644 --- a/megamek/src/megamek/client/ui/swing/unitDisplay/SummaryPanel.java +++ b/megamek/src/megamek/client/ui/swing/unitDisplay/SummaryPanel.java @@ -147,9 +147,9 @@ public void displayMech(Entity entity) { BoardView bv = unitDisplay.getClientGUI().getBoardView(); Hex mhex = entity.getGame().getBoard().getHex(entity.getPosition()); if (bv != null && mhex != null) { - StringBuffer s = new StringBuffer(); - bv.appendTerrainTooltip(s, mhex); - col = "" + s + ""; + StringBuffer sb = new StringBuffer(); + bv.appendTerrainTooltip(sb, mhex); + col = "" + sb + ""; row = "" + col + ""; hexTxt.append("" + row + "
    "); bv.appendBuildingsTooltip(hexTxt, mhex); From a352d93e644d75c663e1b9c0ec16c392cfa586aa Mon Sep 17 00:00:00 2001 From: kuronekochomusuke Date: Sun, 29 Jan 2023 11:56:11 -0500 Subject: [PATCH 14/15] correct issues --- .../client/ui/swing/boardview/BoardView.java | 24 +++++++++---------- .../client/ui/swing/tooltip/PilotToolTip.java | 2 +- .../client/ui/swing/tooltip/UnitToolTip.java | 2 +- .../ui/swing/unitDisplay/SummaryPanel.java | 1 - 4 files changed, 14 insertions(+), 15 deletions(-) diff --git a/megamek/src/megamek/client/ui/swing/boardview/BoardView.java b/megamek/src/megamek/client/ui/swing/boardview/BoardView.java index 4a8daffe051..a90d6ecd163 100644 --- a/megamek/src/megamek/client/ui/swing/boardview/BoardView.java +++ b/megamek/src/megamek/client/ui/swing/boardview/BoardView.java @@ -5587,18 +5587,6 @@ public String getHexTooltip(MouseEvent e) { } } - // check if it's on any attacks - for (AttackSprite aSprite : attackSprites) { - if (aSprite.isInside(mcoords)) { - f = aSprite.getTooltip().toString(); - t = guiScaledFontHTML(uiBlack()) + f + ""; - String col = "" + t + ""; - String row = "" + col + ""; - String table = "" + row + "
    "; - result += table; - } - } - // Add wreck info var wreckList = useIsometric() ? isometricWreckSprites : wreckSprites; for (var wSprite : wreckList) { @@ -5645,6 +5633,18 @@ public String getHexTooltip(MouseEvent e) { result += table; } + // check if it's on any attacks + for (AttackSprite aSprite : attackSprites) { + if (aSprite.isInside(mcoords)) { + f = aSprite.getTooltip().toString(); + t = guiScaledFontHTML(uiBlack()) + f + ""; + String col = "" + t + ""; + String row = "" + col + ""; + String table = "" + row + "
    "; + result += table; + } + } + // Artillery attacks for (ArtilleryAttackAction aaa : getArtilleryAttacksAtLocation(mcoords)) { // Default texts if no real names can be found diff --git a/megamek/src/megamek/client/ui/swing/tooltip/PilotToolTip.java b/megamek/src/megamek/client/ui/swing/tooltip/PilotToolTip.java index aeaed66895a..971476537d7 100644 --- a/megamek/src/megamek/client/ui/swing/tooltip/PilotToolTip.java +++ b/megamek/src/megamek/client/ui/swing/tooltip/PilotToolTip.java @@ -173,7 +173,7 @@ private static StringBuilder crewAdvs(final Entity entity, boolean detailed) { String result = ""; String f = ""; Crew crew = entity.getCrew(); - f = getOptionList(crew.getOptions().getGroups(), crew::countOptions, detailed).toString(); + f = getOptionList(crew.getOptions().getGroups(), crew::countOptions, detailed); result = guiScaledFontHTML(uiQuirksColor(), UnitToolTip.TT_SMALLFONT_DELTA) + f + ""; return new StringBuilder().append(result); } diff --git a/megamek/src/megamek/client/ui/swing/tooltip/UnitToolTip.java b/megamek/src/megamek/client/ui/swing/tooltip/UnitToolTip.java index d0c6008d380..25c809c4e99 100644 --- a/megamek/src/megamek/client/ui/swing/tooltip/UnitToolTip.java +++ b/megamek/src/megamek/client/ui/swing/tooltip/UnitToolTip.java @@ -867,7 +867,7 @@ private static StringBuilder inGameValues(Entity entity, Player localPlayer) { || (game.getPhase().isPhysicalReport())) { int tmm = Compute.getTargetMovementModifier(game, entity.getId()).getValue(); if (entity.moved == EntityMovementType.MOVE_NONE) { - i = addToTT("NoMove", BR, tmm).toString().toString(); + i = addToTT("NoMove", BR, tmm).toString(); f = "" + i + ""; } else { i = addToTT("MovementF", BR, entity.getMovementString(entity.moved), diff --git a/megamek/src/megamek/client/ui/swing/unitDisplay/SummaryPanel.java b/megamek/src/megamek/client/ui/swing/unitDisplay/SummaryPanel.java index 5b613b1e9f3..087f389a18d 100644 --- a/megamek/src/megamek/client/ui/swing/unitDisplay/SummaryPanel.java +++ b/megamek/src/megamek/client/ui/swing/unitDisplay/SummaryPanel.java @@ -138,7 +138,6 @@ public void displayMech(Entity entity) { // also allow cells do have bg colors StringBuffer hexTxt = new StringBuffer(""); hexTxt.append(PilotToolTip.getPilotTipDetailed(entity, true)); - StringBuffer p = new StringBuffer(); hexTxt.append(UnitToolTip.getEntityTipUnitDisplay(entity, localPlayer)); String col = ""; From ff487735bc7f4a4aab2e707ca23e458d5fb26831 Mon Sep 17 00:00:00 2001 From: kuronekochomusuke Date: Tue, 7 Feb 2023 12:34:41 -0500 Subject: [PATCH 15/15] variable names --- .../ui/swing/boardview/AttackSprite.java | 12 +- .../client/ui/swing/boardview/BoardView.java | 213 +++++----- .../client/ui/swing/tooltip/PilotToolTip.java | 35 +- .../client/ui/swing/tooltip/UnitToolTip.java | 392 +++++++++--------- 4 files changed, 321 insertions(+), 331 deletions(-) diff --git a/megamek/src/megamek/client/ui/swing/boardview/AttackSprite.java b/megamek/src/megamek/client/ui/swing/boardview/AttackSprite.java index 94645baa144..01d3c1fde9d 100644 --- a/megamek/src/megamek/client/ui/swing/boardview/AttackSprite.java +++ b/megamek/src/megamek/client/ui/swing/boardview/AttackSprite.java @@ -408,16 +408,16 @@ public void addWeapon(SearchlightAttackAction attack) { public StringBuffer getTooltip() { GamePhase phase = this.boardView1.game.getPhase(); String result = ""; - String f = ""; + String sAttacherDesc = ""; - f = attackerDesc + "
      " + Messages.getString("BoardView1.on") + " " + targetDesc; - result = guiScaledFontHTML(attackColor) + f + ""; - f = ""; + sAttacherDesc = attackerDesc + "
      " + Messages.getString("BoardView1.on") + " " + targetDesc; + result = guiScaledFontHTML(attackColor) + sAttacherDesc + ""; + String sAttacks = ""; if ((phase.isFiring()) || (phase.isPhysical())) { for (String wpD : weaponDescs) { - f += "
    " + wpD; + sAttacks += "
    " + wpD; } - result += guiScaledFontHTML(uiBlack()) + f + ""; + result += guiScaledFontHTML(uiBlack()) + sAttacks + ""; } return new StringBuffer().append(result); } diff --git a/megamek/src/megamek/client/ui/swing/boardview/BoardView.java b/megamek/src/megamek/client/ui/swing/boardview/BoardView.java index 74a6ee714c3..60111013182 100644 --- a/megamek/src/megamek/client/ui/swing/boardview/BoardView.java +++ b/megamek/src/megamek/client/ui/swing/boardview/BoardView.java @@ -5455,27 +5455,22 @@ public String getHexTooltip(MouseEvent e) { Hex mhex = game.getBoard().getHex(mcoords); - String b = ""; - String f = ""; - String t = ""; String result = ""; - String i = ""; - StringBuffer sb = new StringBuffer(); //StringBuffer txt = new StringBuffer(); // Hex Terrain if (GUIP.getShowMapHexPopup() && (mhex != null)) { - sb = new StringBuffer(); - appendTerrainTooltip(sb, mhex); - f += sb.toString(); + StringBuffer sbTerrain = new StringBuffer(); + appendTerrainTooltip(sbTerrain, mhex); + String sTrerain = sbTerrain.toString(); // Distance from the selected unit and a planned movement end point if ((selectedEntity != null) && (selectedEntity.getPosition() != null)) { int distance = selectedEntity.getPosition().distance(mcoords); if (distance == 1) { - f += Messages.getString("BoardView1.Tooltip.Distance1"); + sTrerain += Messages.getString("BoardView1.Tooltip.Distance1"); } else { - f += Messages.getString("BoardView1.Tooltip.DistanceN", distance); + sTrerain += Messages.getString("BoardView1.Tooltip.DistanceN", distance); } if (game.getOptions().booleanOption(OptionsConstants.ADVANCED_TACOPS_SENSORS)) { @@ -5489,49 +5484,50 @@ public String getHexTooltip(MouseEvent e) { if (game.getOptions().booleanOption(OptionsConstants.ADVANCED_INCLUSIVE_SENSOR_RANGE)) { minSensorRange = 0; } - f += "
    "; + sTrerain += "
    "; if ((distance > minSensorRange) && (distance <= maxSensorRange)) { - f += Messages.getString("BoardView1.Tooltip.SensorsHexInRange"); + sTrerain += Messages.getString("BoardView1.Tooltip.SensorsHexInRange"); } else { - f += Messages.getString("BoardView1.Tooltip.SensorsHexNotInRange1"); + sTrerain += Messages.getString("BoardView1.Tooltip.SensorsHexNotInRange1"); String tmp = Messages.getString("BoardView1.Tooltip.SensorsHexNotInRange2"); - f += guiScaledFontHTML(GUIP.getWarningColor()) + tmp + ""; - f += Messages.getString("BoardView1.Tooltip.SensorsHexNotInRange3"); + sTrerain += guiScaledFontHTML(GUIP.getWarningColor()) + tmp + ""; + sTrerain += Messages.getString("BoardView1.Tooltip.SensorsHexNotInRange3"); } } if (game.getPhase().isMovement() && (movementTarget != null)) { - f += "
    "; + sTrerain += "
    "; int disPM = movementTarget.distance(mcoords); + String sDinstanceMove = ""; if (disPM == 1) { - i = Messages.getString("BoardView1.Tooltip.DistanceMove1"); + sDinstanceMove = Messages.getString("BoardView1.Tooltip.DistanceMove1"); } else { - i = Messages.getString("BoardView1.Tooltip.DistanceMoveN", disPM); + sDinstanceMove = Messages.getString("BoardView1.Tooltip.DistanceMoveN", disPM); } - f += "" + i + ""; + sTrerain += "" + sDinstanceMove + ""; } } - t = guiScaledFontHTML(uiBlack()) + f + "
    "; - String col = "" + t + ""; + sTrerain = guiScaledFontHTML(uiBlack()) + sTrerain + "
    "; + String col = "" + sTrerain + ""; String row = "" + col + ""; String table = "" + row + "
    "; result += table; - sb = new StringBuffer(); - appendBuildingsTooltip(sb, mhex); - result += sb.toString(); + StringBuffer sbBuildings = new StringBuffer(); + appendBuildingsTooltip(sbBuildings, mhex); + result += sbBuildings.toString(); if (displayInvalidHexInfo) { StringBuffer errBuff = new StringBuffer(); if (!mhex.isValid(errBuff)) { - f = Messages.getString("BoardView1.invalidHex"); - f += "
    "; + String sInvalidHex = Messages.getString("BoardView1.invalidHex"); + sInvalidHex += "
    "; String errors = errBuff.toString(); errors = errors.replace("\n", "
    "); - f += errors; - f = guiScaledFontHTML(uiWhite()) + f + ""; - result += "
    " + f; + sInvalidHex += errors; + sInvalidHex = guiScaledFontHTML(uiWhite()) + sInvalidHex + ""; + result += "
    " + sInvalidHex; } } } @@ -5539,7 +5535,7 @@ public String getHexTooltip(MouseEvent e) { // Show the player(s) that may deploy here // in the artillery autohit designation phase if (game.getPhase().isSetArtilleryAutohitHexes() && (mhex != null)) { - t = ""; + String sAttilleryAutoHix = ""; Enumeration allP = game.getPlayers(); boolean foundPlayer = false; // loop through all players @@ -5548,29 +5544,29 @@ public String getHexTooltip(MouseEvent e) { if (game.getBoard().isLegalDeployment(mcoords, cp)) { if (!foundPlayer) { foundPlayer = true; - t += Messages.getString("BoardView1.Tooltip.ArtyAutoHeader") + "
    "; + sAttilleryAutoHix += Messages.getString("BoardView1.Tooltip.ArtyAutoHeader") + "
    "; } - f = "  " + cp.getName(); - b = guiScaledFontHTML(cp.getColour().getColour()) + f + ""; - t += "" + b + ""; - t += "
    "; + String sName = "  " + cp.getName(); + sName = guiScaledFontHTML(cp.getColour().getColour()) + sName + ""; + sAttilleryAutoHix += "" + sName + ""; + sAttilleryAutoHix += "
    "; } } if (foundPlayer) { - t += "
    "; + sAttilleryAutoHix += "
    "; } // Add a hint with keybind that the zones can be shown graphically String keybindText = KeyCommandBind.getDesc(KeyCommandBind.getBindByCmd("autoArtyDeployZone")); - i = Messages.getString("BoardView1.Tooltip.ArtyAutoHint1") + "
    "; - i += Messages.getString("BoardView1.Tooltip.ArtyAutoHint2") + "
    "; - i += Messages.getString("BoardView1.Tooltip.ArtyAutoHint3", keybindText); - t += "" + i + ""; + String msg_artyautohit = Messages.getString("BoardView1.Tooltip.ArtyAutoHint1") + "
    "; + msg_artyautohit += Messages.getString("BoardView1.Tooltip.ArtyAutoHint2") + "
    "; + msg_artyautohit += Messages.getString("BoardView1.Tooltip.ArtyAutoHint3", keybindText); + sAttilleryAutoHix += "" + msg_artyautohit + ""; - t = guiScaledFontHTML(uiWhite()) + t + ""; + sAttilleryAutoHix = guiScaledFontHTML(uiWhite()) + sAttilleryAutoHix + ""; - String col = "" + t + ""; + String col = "" + sAttilleryAutoHix + ""; String row = "" + col + ""; String table = "" + row + "
    "; result += table; @@ -5587,9 +5583,9 @@ public String getHexTooltip(MouseEvent e) { var wreckList = useIsometric() ? isometricWreckSprites : wreckSprites; for (var wSprite : wreckList) { if (wSprite.getPosition().equals(mcoords)) { - f = wSprite.getTooltip().toString(); - t = guiScaledFontHTML(uiBlack()) + f + ""; - String col = "" + t + ""; + String sWreck = wSprite.getTooltip().toString(); + sWreck = guiScaledFontHTML(uiBlack()) + sWreck + ""; + String col = "" + sWreck + ""; String row = "" + col + ""; String table = "" + row + "
    "; result += table; @@ -5607,23 +5603,23 @@ public String getHexTooltip(MouseEvent e) { // List only the first four units if (entityCount <= maxShown) { - sb = new StringBuffer(); - appendEntityTooltip(sb, entity); - result += sb.toString(); + StringBuffer sbEntity = new StringBuffer(); + appendEntityTooltip(sbEntity, entity); + result += sbEntity.toString(); } } // Info block if there are more than 4 units in that hex if (entityCount > maxShown) { - f = "There "; + String sUnitsInfo = "There "; if (entityCount-maxShown == 1) { - f += "is 1 more
    unit"; + sUnitsInfo += "is 1 more
    unit"; } else { - f += "are " + (entityCount - maxShown) + " more
    units"; + sUnitsInfo += "are " + (entityCount - maxShown) + " more
    units"; } - f += " in this hex..."; + sUnitsInfo += " in this hex..."; - t = guiScaledFontHTML(UIUtil.uiWhite()) + f + ""; - String col = "" + t + ""; + sUnitsInfo = guiScaledFontHTML(UIUtil.uiWhite()) + sUnitsInfo + ""; + String col = "" + sUnitsInfo + ""; String row = "" + col + ""; String table = "" + row + "
    "; result += table; @@ -5632,9 +5628,9 @@ public String getHexTooltip(MouseEvent e) { // check if it's on any attacks for (AttackSprite aSprite : attackSprites) { if (aSprite.isInside(mcoords)) { - f = aSprite.getTooltip().toString(); - t = guiScaledFontHTML(uiBlack()) + f + ""; - String col = "" + t + ""; + String sAttackSprite = aSprite.getTooltip().toString(); + sAttackSprite = guiScaledFontHTML(uiBlack()) + sAttackSprite + ""; + String col = "" + sAttackSprite + ""; String row = "" + col + ""; String table = "" + row + "
    "; result += table; @@ -5658,18 +5654,20 @@ public String getHexTooltip(MouseEvent e) { } } + String msg_artilleryatack; + if (aaa.getTurnsTilHit() == 1) { - f = Messages.getString("BoardView1.Tooltip.ArtilleryAttackOne1", wpName); - f += "
      "; - f += Messages.getString("BoardView1.Tooltip.ArtilleryAttackOne2", ammoName); + msg_artilleryatack = Messages.getString("BoardView1.Tooltip.ArtilleryAttackOne1", wpName); + msg_artilleryatack += "
      "; + msg_artilleryatack += Messages.getString("BoardView1.Tooltip.ArtilleryAttackOne2", ammoName); } else { - f = Messages.getString("BoardView1.Tooltip.ArtilleryAttackN1", wpName, aaa.getTurnsTilHit()); - f += "
      "; - f += Messages.getString("BoardView1.Tooltip.ArtilleryAttackN2", ammoName); + msg_artilleryatack = Messages.getString("BoardView1.Tooltip.ArtilleryAttackN1", wpName, aaa.getTurnsTilHit()); + msg_artilleryatack += "
      "; + msg_artilleryatack += Messages.getString("BoardView1.Tooltip.ArtilleryAttackN2", ammoName); } - t = guiScaledFontHTML(UIUtil.uiWhite()) + f + ""; - String col = "" + t + ""; + msg_artilleryatack = guiScaledFontHTML(UIUtil.uiWhite()) + msg_artilleryatack + ""; + String col = "" + msg_artilleryatack + ""; String row = "" + col + ""; String table = "" + row + "
    "; result += table; @@ -5687,19 +5685,21 @@ public String getHexTooltip(MouseEvent e) { amod = selectedEntity.aTracker.getModifier(curWeapon, mcoords); } + String msg_artilleryautohit; + if (amod == TargetRoll.AUTOMATIC_SUCCESS) { - f = Messages.getString("BoardView1.ArtilleryAutohit"); + msg_artilleryautohit = Messages.getString("BoardView1.ArtilleryAutohit"); } else { - f = Messages.getString("BoardView1.ArtilleryAdjustment", amod); + msg_artilleryautohit = Messages.getString("BoardView1.ArtilleryAdjustment", amod); } - f = guiScaledFontHTML(UIUtil.uiWhite()) + f + ""; - result += f + "
    "; + msg_artilleryautohit = guiScaledFontHTML(UIUtil.uiWhite()) + msg_artilleryautohit + ""; + result += msg_artilleryautohit + "
    "; } final Collection shdList = game.getBoard().getSpecialHexDisplay(mcoords); int round = game.getRoundCount(); if (shdList != null) { - f = ""; + String sSpecialHex = ""; boolean isHexAutoHit = localPlayer.getArtyAutoHitHexes().contains(mcoords); for (SpecialHexDisplay shd : shdList) { boolean isTypeAutoHit = shd.getType() == SpecialHexDisplay.Type.ARTILLERY_AUTOHIT; @@ -5713,25 +5713,25 @@ public String getHexTooltip(MouseEvent e) { || (isHexAutoHit && isTypeAutoHit))) { if (shd.getType() == SpecialHexDisplay.Type.PLAYER_NOTE) { if (localPlayer.equals(shd.getOwner())) { - f += "Note: "; + sSpecialHex += "Note: "; } else { - f += "Note (" + shd.getOwner().getName() + "): "; + sSpecialHex += "Note (" + shd.getOwner().getName() + "): "; } } String buf = shd.getInfo(); buf = buf.replaceAll("\\n", "
    "); - f += buf; - f = guiScaledFontHTML(UIUtil.uiWhite()) + f + ""; - f += "
    "; + sSpecialHex += buf; + sSpecialHex = guiScaledFontHTML(UIUtil.uiWhite()) + sSpecialHex + ""; + sSpecialHex += "
    "; } } - result += f; + result += sSpecialHex; } - String d = "
    " + result + "
    "; + String div = "
    " + result + "
    "; StringBuffer txt = new StringBuffer(); - txt.append(HTML_BEGIN + d + HTML_END); + txt.append(HTML_BEGIN + div + HTML_END); // Check to see if the tool tip is completely empty if (txt.toString().equals(HTML_BEGIN +HTML_END)) { @@ -5759,11 +5759,8 @@ public void appendTerrainTooltip(StringBuffer txt, @Nullable Hex mhex) { } Coords mcoords = mhex.getCoords(); - String result = ""; - String f = ""; - - f += Messages.getString("BoardView1.Tooltip.Hex", mcoords.getBoardNum(), mhex.getLevel()) + "
    "; + String sTerrian = Messages.getString("BoardView1.Tooltip.Hex", mcoords.getBoardNum(), mhex.getLevel()) + "
    "; // cycle through the terrains and report types found for (int terType: mhex.getTerrainTypes()) { @@ -5773,11 +5770,11 @@ public void appendTerrainTooltip(StringBuffer txt, @Nullable Hex mhex) { if (name != null) { String msg_tf = Messages.getString("BoardView1.Tooltip.TF"); name += (tf > 0) ? " (" + msg_tf + ": " + tf + ")" : ""; - f += name + "
    "; + sTerrian += name + "
    "; } } - result += guiScaledFontHTML(UIUtil.uiBlack()) + f + ""; + result += guiScaledFontHTML(UIUtil.uiBlack()) + sTerrian + ""; txt.append(result); } @@ -5789,29 +5786,29 @@ public void appendBuildingsTooltip(StringBuffer txt, @Nullable Hex mhex) { return; } Coords mcoords = mhex.getCoords(); - String f = ""; + String result = ""; - String t = ""; // Fuel Tank if (mhex.containsTerrain(Terrains.FUEL_TANK)) { + String sFuelTank = ""; // In the BoardEditor, buildings have no entry in the // buildings list of the board, so get the info from the hex if (clientgui == null) { - f = Messages.getString("BoardView1.Tooltip.FuelTank", + sFuelTank = Messages.getString("BoardView1.Tooltip.FuelTank", mhex.terrainLevel(Terrains.FUEL_TANK_ELEV), Terrains.getEditorName(Terrains.FUEL_TANK), mhex.terrainLevel(Terrains.FUEL_TANK_CF), mhex.terrainLevel(Terrains.FUEL_TANK_MAGN)); } else { FuelTank bldg = (FuelTank) game.getBoard().getBuildingAt(mcoords); - f = Messages.getString("BoardView1.Tooltip.FuelTank", + sFuelTank = Messages.getString("BoardView1.Tooltip.FuelTank", mhex.terrainLevel(Terrains.FUEL_TANK_ELEV), bldg.toString(), bldg.getCurrentCF(mcoords), bldg.getMagnitude()); } - t = guiScaledFontHTML(uiBlack()) + f + ""; - String col = "" + t + ""; + sFuelTank = guiScaledFontHTML(uiBlack()) + sFuelTank + ""; + String col = "" + sFuelTank + ""; String row = "" + col + ""; String table = "" + row + "
    "; result += table; @@ -5819,30 +5816,31 @@ public void appendBuildingsTooltip(StringBuffer txt, @Nullable Hex mhex) { // Building if (mhex.containsTerrain(Terrains.BUILDING)) { + String sBuilding; // In the BoardEditor, buildings have no entry in the // buildings list of the board, so get the info from the hex if (clientgui == null) { - f = Messages.getString("BoardView1.Tooltip.Building", + sBuilding = Messages.getString("BoardView1.Tooltip.Building", mhex.terrainLevel(Terrains.BLDG_ELEV), Terrains.getEditorName(Terrains.BUILDING), mhex.terrainLevel(Terrains.BLDG_CF), Math.max(mhex.terrainLevel(Terrains.BLDG_ARMOR), 0), BasementType.getType(mhex.terrainLevel(Terrains.BLDG_BASEMENT_TYPE)).toString()); - t = guiScaledFontHTML(uiBlack()) + f + ""; - String col = "" + t + ""; + sBuilding = guiScaledFontHTML(uiBlack()) + sBuilding + ""; + String col = "" + sBuilding + ""; String row = "" + col + ""; String table = "" + row + "
    "; result += table; } else { Building bldg = game.getBoard().getBuildingAt(mcoords); - f = Messages.getString("BoardView1.Tooltip.Building", + sBuilding = Messages.getString("BoardView1.Tooltip.Building", mhex.terrainLevel(Terrains.BLDG_ELEV), bldg.toString(), bldg.getCurrentCF(mcoords), bldg.getArmor(mcoords), bldg.getBasement(mcoords).toString()); if (bldg.getBasementCollapsed(mcoords)) { - f += Messages.getString("BoardView1.Tooltip.BldgBasementCollapsed"); + sBuilding += Messages.getString("BoardView1.Tooltip.BldgBasementCollapsed"); } - t = guiScaledFontHTML(uiBlack()) + f + ""; - String col = "" + t + ""; + sBuilding = guiScaledFontHTML(uiBlack()) + sBuilding + ""; + String col = "" + sBuilding + ""; String row = "" + col + ""; String table = "" + row + "
    "; result += table; @@ -5851,19 +5849,20 @@ public void appendBuildingsTooltip(StringBuffer txt, @Nullable Hex mhex) { // Bridge if (mhex.containsTerrain(Terrains.BRIDGE)) { + String sBridge; // In the BoardEditor, buildings have no entry in the // buildings list of the board, so get the info from the hex if (clientgui == null) { - f =Messages.getString("BoardView1.Tooltip.Bridge", + sBridge = Messages.getString("BoardView1.Tooltip.Bridge", mhex.terrainLevel(Terrains.BRIDGE_ELEV), Terrains.getEditorName(Terrains.BRIDGE), mhex.terrainLevel(Terrains.BRIDGE_CF)); } else { Building bldg = game.getBoard().getBuildingAt(mcoords); - f = Messages.getString("BoardView1.Tooltip.Bridge", + sBridge = Messages.getString("BoardView1.Tooltip.Bridge", mhex.terrainLevel(Terrains.BRIDGE_ELEV), bldg.toString(), bldg.getCurrentCF(mcoords)); } - t = guiScaledFontHTML(uiBlack()) + f + ""; - String col = "" + t + ""; + sBridge = guiScaledFontHTML(uiBlack()) + sBridge + ""; + String col = "" + sBridge + ""; String row = "" + col + ""; String table = "" + row + "
    "; result += table; @@ -5874,28 +5873,28 @@ public void appendBuildingsTooltip(StringBuffer txt, @Nullable Hex mhex) { for (int i = 0; i < minefields.size(); i++) { Minefield mf = minefields.elementAt(i); String owner = " (" + game.getPlayer(mf.getPlayerId()).getName() + ")"; - f = mf.getName() + " " + Messages.getString("BoardView1.minefield") + " (" + mf.getDensity()+ ")"; + String sMinefield = mf.getName() + " " + Messages.getString("BoardView1.minefield") + " (" + mf.getDensity()+ ")"; switch (mf.getType()) { case Minefield.TYPE_CONVENTIONAL: case Minefield.TYPE_COMMAND_DETONATED: case Minefield.TYPE_ACTIVE: case Minefield.TYPE_INFERNO: - f += " " + owner; + sMinefield += " " + owner; break; case Minefield.TYPE_VIBRABOMB: if (mf.getPlayerId() == localPlayer.getId()) { - f += "(" + mf.getSetting() + ") " + owner; + sMinefield += "(" + mf.getSetting() + ") " + owner; } else { - f += owner; + sMinefield += owner; } break; default: break; } - f = guiScaledFontHTML(UIUtil.uiWhite()) + f + ""; - result += f; + sMinefield = guiScaledFontHTML(UIUtil.uiWhite()) + sMinefield + ""; + result += sMinefield; result += "
    "; } } diff --git a/megamek/src/megamek/client/ui/swing/tooltip/PilotToolTip.java b/megamek/src/megamek/client/ui/swing/tooltip/PilotToolTip.java index 971476537d7..a88190fe2ec 100644 --- a/megamek/src/megamek/client/ui/swing/tooltip/PilotToolTip.java +++ b/megamek/src/megamek/client/ui/swing/tooltip/PilotToolTip.java @@ -74,16 +74,14 @@ private static StringBuilder getPilotTip(final Entity entity, boolean detailed, } else { result += scaledHTMLSpacer(3); } + return new StringBuilder().append(result); } /** The crew advantages and MD */ public static StringBuilder getCrewAdvs(Entity entity, boolean detailed) { - String result = ""; - String f = ""; - - f = crewAdvs(entity, detailed).toString(); - result = scaledHTMLSpacer(3) + f + ""; + String sCrewAdvs = crewAdvs(entity, detailed).toString(); + String result = scaledHTMLSpacer(3) + sCrewAdvs + ""; return new StringBuilder().append(result); } @@ -92,41 +90,40 @@ public static StringBuilder getCrewAdvs(Entity entity, boolean detailed) { private static StringBuilder crewInfoCell(final Entity entity) { Crew crew = entity.getCrew(); Game game = entity.getGame(); - String f = ""; String result = ""; // Name / Callsign and Status for each crew member for (int i = 0; i < crew.getSlotCount(); i++) { + String sCrew = ""; if (crew.isMissing(i)) { continue; } if ((crew.getNickname(i) != null) && !crew.getNickname(i).isBlank()) { - f = "'" + crew.getNickname(i).toUpperCase() + "'"; - result += guiScaledFontHTML(UIUtil.uiNickColor()) + f + ""; + String sNickName = "'" + crew.getNickname(i).toUpperCase() + "'"; + sCrew += guiScaledFontHTML(UIUtil.uiNickColor()) + sNickName + ""; } else if ((crew.getName(i) != null) && !crew.getName(i).isBlank()) { - result += crew.getName(i); + sCrew += crew.getName(i); } else { - result += Messages.getString("BoardView1.Tooltip.Pilot"); + sCrew += Messages.getString("BoardView1.Tooltip.Pilot"); } if (crew.getSlotCount() > 1) { - result += " \u2B1D " + crew.getCrewType().getRoleName(i); + sCrew += " \u2B1D " + crew.getCrewType().getRoleName(i); } if (!crew.getStatusDesc(i).isEmpty()) { - result += guiScaledFontHTML(GUIPreferences.getInstance().getWarningColor()) + " (" + crew.getStatusDesc(i) + ")"; + sCrew += guiScaledFontHTML(GUIPreferences.getInstance().getWarningColor()) + " (" + crew.getStatusDesc(i) + ")"; } - result += "
    "; + result += sCrew + "
    "; } // Effective entity skill for the whole crew boolean rpg_skills = game.getOptions().booleanOption(OptionsConstants.RPG_RPG_GUNNERY); result += CrewSkillSummaryUtil.getSkillNames(entity) + ": " + crew.getSkillsAsString(rpg_skills); - result = guiScaledFontHTML() + result + ""; - String col = "" + result + ""; + return new StringBuilder().append(col); } @@ -161,6 +158,7 @@ private static StringBuilder crewPortraits(final Entity entity, boolean showDefa LogManager.getLogger().error("", e); } } + return new StringBuilder().append(col); } @@ -171,10 +169,11 @@ private static StringBuilder crewPortraits(final Entity entity, boolean showDefa */ private static StringBuilder crewAdvs(final Entity entity, boolean detailed) { String result = ""; - String f = ""; + String sOptionList = ""; Crew crew = entity.getCrew(); - f = getOptionList(crew.getOptions().getGroups(), crew::countOptions, detailed); - result = guiScaledFontHTML(uiQuirksColor(), UnitToolTip.TT_SMALLFONT_DELTA) + f + ""; + sOptionList = getOptionList(crew.getOptions().getGroups(), crew::countOptions, detailed); + result = guiScaledFontHTML(uiQuirksColor(), UnitToolTip.TT_SMALLFONT_DELTA) + sOptionList + ""; + return new StringBuilder().append(result); } diff --git a/megamek/src/megamek/client/ui/swing/tooltip/UnitToolTip.java b/megamek/src/megamek/client/ui/swing/tooltip/UnitToolTip.java index 25c809c4e99..6bda927f844 100644 --- a/megamek/src/megamek/client/ui/swing/tooltip/UnitToolTip.java +++ b/megamek/src/megamek/client/ui/swing/tooltip/UnitToolTip.java @@ -75,39 +75,42 @@ private static StringBuilder getEntityTipTable(Entity entity, Player localPlayer } String result = ""; - String f = ""; - String p = ""; Game game = entity.getGame(); // Unit Chassis and Player Player owner = game.getPlayer(entity.getOwnerId()); String msg_clanbrackets =Messages.getString("BoardView1.Tooltip.ClanBrackets"); String clanStr = entity.isClan() && !entity.isMixedTech() ? " " + msg_clanbrackets + " " : ""; - f = entity.getChassis() + clanStr; - f += " (" + (int) entity.getWeight() + "t)"; - f += "  " + entity.getEntityTypeName(entity.getEntityType()); - f += "
    " + owner.getName(); + String sChassisPlayerInfo = entity.getChassis() + clanStr; + sChassisPlayerInfo += " (" + (int) entity.getWeight() + "t)"; + sChassisPlayerInfo += "  " + entity.getEntityTypeName(entity.getEntityType()); + sChassisPlayerInfo += "
    " + owner.getName(); String msg_id = MessageFormat.format(" [ID: {0}]", entity.getId()); - f += UIUtil.guiScaledFontHTML(UIUtil.uiGray()) + msg_id + ""; - p += guiScaledFontHTML(entity.getOwner().getColour().getColour()) + f + ""; + sChassisPlayerInfo += UIUtil.guiScaledFontHTML(UIUtil.uiGray()) + msg_id + ""; + sChassisPlayerInfo = guiScaledFontHTML(entity.getOwner().getColour().getColour()) + sChassisPlayerInfo + ""; + + result += sChassisPlayerInfo; // Pilot; in the lounge the pilot is separate so don't add it there + String sPilotInfo = ""; + if (details && (mapSettings != null)) { - p += deploymentWarnings(entity, localPlayer, mapSettings) + "
    "; + sPilotInfo += deploymentWarnings(entity, localPlayer, mapSettings) + "
    "; } else { if (pilotInfo) { - p += forceEntry(entity, localPlayer); + sPilotInfo += forceEntry(entity, localPlayer); } - p += inGameValues(entity, localPlayer); + + sPilotInfo += inGameValues(entity, localPlayer); + if (pilotInfo) { - p += PilotToolTip.getPilotTipShort(entity, GUIP.getBoolean(GUIPreferences.SHOW_PILOT_PORTRAIT_TT)); + sPilotInfo += PilotToolTip.getPilotTipShort(entity, GUIP.getBoolean(GUIPreferences.SHOW_PILOT_PORTRAIT_TT)); } else { - p += "
    "; + sPilotInfo += "
    "; } } - result += p; - p = ""; + result += sPilotInfo; // An empty squadron should not show any info if (entity instanceof FighterSquadron && entity.getLoadedUnits().isEmpty()) { @@ -118,8 +121,8 @@ private static StringBuilder getEntityTipTable(Entity entity, Player localPlayer } // Static entity values like move capability - f = entityValues(entity).toString(); - result += guiScaledFontHTML() + f + ""; + String sEntityInfo = entityValues(entity).toString(); + result += guiScaledFontHTML() + sEntityInfo + ""; // Status bar visual representation of armor and IS if (GUIP.getBoolean(GUIPreferences.SHOW_ARMOR_MINIVIS_TT)) { @@ -128,9 +131,9 @@ private static StringBuilder getEntityTipTable(Entity entity, Player localPlayer // Weapon List if (GUIP.getBoolean(GUIPreferences.SHOW_WPS_IN_TT)) { - f = weaponList(entity).toString(); - f += ecmInfo(entity).toString(); - result += guiScaledFontHTML() + f + ""; + String sWeaponList = weaponList(entity).toString(); + sWeaponList += ecmInfo(entity).toString(); + result += guiScaledFontHTML() + sWeaponList + ""; } // Bomb List @@ -138,28 +141,27 @@ private static StringBuilder getEntityTipTable(Entity entity, Player localPlayer // StratOps quirks, chassis and weapon if (game.getOptions().booleanOption(OptionsConstants.ADVANCED_STRATOPS_QUIRKS)) { - f = "
    "; + String sQuirks = "
    "; String quirksList = getOptionList(entity.getQuirks().getGroups(), entity::countQuirks, details); if (!quirksList.isEmpty()) { - f += quirksList; + sQuirks += quirksList; } for (Mounted weapon: entity.getWeaponList()) { String wpQuirksList = getOptionList(weapon.getQuirks().getGroups(), grp -> weapon.countQuirks(), (e) -> weapon.getDesc(), details); if (!wpQuirksList.isEmpty()) { // Line break after weapon name not useful here - f += wpQuirksList.replace(":
    ", ":"); + sQuirks += wpQuirksList.replace(":
    ", ":"); } } - result += guiScaledFontHTML(uiQuirksColor(), TT_SMALLFONT_DELTA) + f + ""; + result += guiScaledFontHTML(uiQuirksColor(), TT_SMALLFONT_DELTA) + sQuirks + ""; } // Partial repairs String partialList = getOptionList(entity.getPartialRepairs().getGroups(), grp -> entity.countPartialRepairs(), details); if (!partialList.isEmpty()) { - f = partialList; - result += guiScaledFontHTML(uiPartialRepairColor(), TT_SMALLFONT_DELTA) + f + ""; + result += guiScaledFontHTML(uiPartialRepairColor(), TT_SMALLFONT_DELTA) + partialList + ""; } if (!entity.getLoadedUnits().isEmpty()) { @@ -187,17 +189,16 @@ private static String locationHeader(Entity entity, int location) { return entity.isConventionalInfantry() ? ((Infantry) entity).getShootingStrength() + " " + msg_activetroopers : entity.getLocationAbbr(location); } - private static StringBuilder sysCrits(Entity entity, int type, int index, int loc, String l) { + private static StringBuilder sysCrits(Entity entity, int type, int index, int loc, String locAbbr) { String result = ""; - String f = ""; int total = entity.getNumberOfCriticals(type, index, loc); int hits = entity.getHitCriticals(type, index, loc); int good = total - hits; boolean bad = (entity.getBadCriticals(type,index, loc) > 0); if ((good + hits) > 0) { - f = "  " + l + ": "; - result = guiScaledFontHTML(TT_SMALLFONT_DELTA) + f + ""; + locAbbr = "  " + locAbbr + ": "; + result = guiScaledFontHTML(TT_SMALLFONT_DELTA) + locAbbr + ""; result += systemBar(good, hits, bad); } @@ -211,7 +212,6 @@ private static StringBuilder addArmorMiniVisToTT(Entity entity) { armorChar = GUIP.getString(GUIPreferences.ADVANCED_ARMORMINI_CAP_ARMOR_CHAR); } String internalChar = GUIP.getString(GUIPreferences.ADVANCED_ARMORMINI_IS_CHAR); - String f = ""; String col1 = ""; String col2 = ""; String col3 = ""; @@ -229,15 +229,15 @@ private static StringBuilder addArmorMiniVisToTT(Entity entity) { if (locDestroyed) { // Destroyed location col1 = ""; - f = "  " + locationHeader(entity, loc) + ": "; - col2 = guiScaledFontHTML(TT_SMALLFONT_DELTA) + f + ""; + String sLocHeader = "  " + locationHeader(entity, loc) + ": "; + col2 = guiScaledFontHTML(TT_SMALLFONT_DELTA) + sLocHeader + ""; col2 += destroyedLocBar(entity.getOArmor(loc, true)).toString(); } else { // Rear armor if (entity.hasRearArmor(loc)) { String msg_abbr_rear = Messages.getString("BoardView1.Tooltip.AbbreviationRear"); - f = "  " + locationHeader(entity, loc) + msg_abbr_rear + " "; - col1 = guiScaledFontHTML(TT_SMALLFONT_DELTA) + f + ""; + String sLocHeader = "  " + locationHeader(entity, loc) + msg_abbr_rear + " "; + col1 = guiScaledFontHTML(TT_SMALLFONT_DELTA) + sLocHeader + ""; col1 += intactLocBar(entity.getOArmor(loc, true), entity.getArmor(loc, true), armorChar).toString(); } else { // No rear armor: empty table cells instead @@ -246,8 +246,8 @@ private static StringBuilder addArmorMiniVisToTT(Entity entity) { col1 = guiScaledFontHTML(TT_SMALLFONT_DELTA) + " " + ""; } // Front armor - f = "  " + locationHeader(entity, loc) + ": "; - col2 = guiScaledFontHTML(TT_SMALLFONT_DELTA) + f + ""; + String sLocHeader = "  " + locationHeader(entity, loc) + ": "; + col2 = guiScaledFontHTML(TT_SMALLFONT_DELTA) + sLocHeader + ""; col2 += intactLocBar(entity.getOInternal(loc), entity.getInternal(loc), internalChar).toString(); col2 += intactLocBar(entity.getOArmor(loc), entity.getArmor(loc), armorChar).toString(); } @@ -348,7 +348,6 @@ private static StringBuilder locBar(int orig, int curr, String dChar, boolean de } String result = ""; - String f = ""; Color colorIntact = GUIP.getColor(GUIPreferences.ADVANCED_ARMORMINI_COLOR_INTACT); Color colorPartialDmg = GUIP.getColor(GUIPreferences.ADVANCED_ARMORMINI_COLOR_PARTIAL_DMG); Color colorDamaged = GUIP.getColor(GUIPreferences.ADVANCED_ARMORMINI_COLOR_DAMAGED); @@ -373,28 +372,28 @@ private static StringBuilder locBar(int orig, int curr, String dChar, boolean de if (numIntact > 15 && numIntact + numDmgd > 30) { int tensIntact = (numIntact - 1) / 10; String msg_x = Messages.getString("BoardView1.Tooltip.X"); - f = dChar + msg_x + tensIntact * 10; - f += repeat(dChar, numIntact - 10 * tensIntact); - result += guiScaledFontHTML(colorIntact, TT_SMALLFONT_DELTA) + f + ""; + String sIntact = dChar + msg_x + tensIntact * 10; + sIntact += repeat(dChar, numIntact - 10 * tensIntact); + result += guiScaledFontHTML(colorIntact, TT_SMALLFONT_DELTA) + sIntact + ""; } else { - f = repeat(dChar, numIntact); - result += guiScaledFontHTML(colorIntact, TT_SMALLFONT_DELTA) + f + ""; + String sIntact = repeat(dChar, numIntact); + result += guiScaledFontHTML(colorIntact, TT_SMALLFONT_DELTA) + sIntact + ""; } } if (numPartial > 0) { - f = repeat(dChar, numPartial); - result += guiScaledFontHTML(colorPartialDmg, TT_SMALLFONT_DELTA) + f + ""; + String sPartial = repeat(dChar, numPartial); + result += guiScaledFontHTML(colorPartialDmg, TT_SMALLFONT_DELTA) + sPartial + ""; } if (numDmgd > 0) { if (numDmgd > 15 && numIntact + numDmgd > 30) { int tensDmgd = (numDmgd - 1) / 10; String msg_x = Messages.getString("BoardView1.Tooltip.X"); - f = dChar + msg_x + tensDmgd * 10; - f += repeat(dChar, numDmgd - 10 * tensDmgd); - result += guiScaledFontHTML(colorIntact, TT_SMALLFONT_DELTA) + f + ""; + String sDamage = dChar + msg_x + tensDmgd * 10; + sDamage += repeat(dChar, numDmgd - 10 * tensDmgd); + result += guiScaledFontHTML(colorIntact, TT_SMALLFONT_DELTA) + sDamage + ""; } else { - f = repeat(dChar, numDmgd); - result += guiScaledFontHTML(colorDamaged, TT_SMALLFONT_DELTA) + f + ""; + String sDamage = repeat(dChar, numDmgd); + result += guiScaledFontHTML(colorDamaged, TT_SMALLFONT_DELTA) + sDamage + ""; } } return new StringBuilder().append(result); @@ -407,7 +406,6 @@ private static StringBuilder systemBar(int good, int bad, boolean destroyed) { } String result = ""; - String f = ""; Color colorIntact = GUIP.getColor(GUIPreferences.ADVANCED_ARMORMINI_COLOR_INTACT); Color colorDamaged = GUIP.getColor(GUIPreferences.ADVANCED_ARMORMINI_COLOR_DAMAGED); String dChar = GUIP.getString(GUIPreferences.ADVANCED_ARMORMINI_DESTROYED_CHAR); @@ -415,16 +413,16 @@ private static StringBuilder systemBar(int good, int bad, boolean destroyed) { if (good > 0) { if (!destroyed) { - f = repeat(iChar, good); - result = guiScaledFontHTML(colorIntact, TT_SMALLFONT_DELTA) + f + ""; + String sGood = repeat(iChar, good); + result = guiScaledFontHTML(colorIntact, TT_SMALLFONT_DELTA) + sGood + ""; } else { - f = repeat(iChar, good); - result = guiScaledFontHTML(colorDamaged, TT_SMALLFONT_DELTA) + f + ""; + String sGood = repeat(iChar, good); + result = guiScaledFontHTML(colorDamaged, TT_SMALLFONT_DELTA) + sGood + ""; } } if (bad > 0) { - f =repeat(dChar, bad); - result = guiScaledFontHTML(colorDamaged, TT_SMALLFONT_DELTA) + f + ""; + String sBad =repeat(dChar, bad); + result = guiScaledFontHTML(colorDamaged, TT_SMALLFONT_DELTA) + sBad + ""; } return new StringBuilder().append(result); } @@ -788,18 +786,18 @@ private static StringBuilder createAmmoEntry(WeaponInfo ammoInfo) { /** Returns a line showing ECM / ECCM. */ private static StringBuilder ecmInfo(Entity entity) { - String f = ""; + String sECMInfo = ""; String result = ""; if (entity.hasActiveECM()) { String msg_ecmsource = Messages.getString("BoardView1.ecmSource"); - f += ECM_SIGN + " " + msg_ecmsource; + sECMInfo += ECM_SIGN + " " + msg_ecmsource; } if (entity.hasActiveECCM()) { String msg_eccmsource = Messages.getString("BoardView1.eccmSource"); - f += ECM_SIGN+ " " +msg_eccmsource; + sECMInfo += ECM_SIGN+ " " +msg_eccmsource; } - result = guiScaledFontHTML() + f + ""; + result = guiScaledFontHTML() + sECMInfo + ""; return new StringBuilder().append(result); } @@ -809,8 +807,6 @@ private static StringBuilder inGameValues(Entity entity, Player localPlayer) { Game game = entity.getGame(); boolean isGunEmplacement = entity instanceof GunEmplacement; String result = ""; - String f = ""; - String i = ""; // BV Info // Hidden for invisible units when in double blind and hide enemy bv is selected @@ -830,13 +826,13 @@ private static StringBuilder inGameValues(Entity entity, Player localPlayer) { switch (entity.getDamageLevel()) { case Entity.DMG_CRIPPLED: String msg_crippled = Messages.getString("BoardView1.Tooltip.Crippled"); - f = "  " + msg_crippled; - damageLevel = guiScaledFontHTML(GUIP.getWarningColor()) + f + ""; + damageLevel = "  " + msg_crippled; + damageLevel = guiScaledFontHTML(GUIP.getWarningColor()) + damageLevel + ""; break; case Entity.DMG_HEAVY: String msg_heavydmg = Messages.getString("BoardView1.Tooltip.HeavyDmg"); - f = "  " + msg_heavydmg; - damageLevel = guiScaledFontHTML(GUIP.getWarningColor()) + f + ""; + damageLevel = "  " + msg_heavydmg; + damageLevel = guiScaledFontHTML(GUIP.getWarningColor()) + damageLevel + ""; break; case Entity.DMG_MODERATE: String msg_moderatedmg = Messages.getString("BoardView1.Tooltip.ModerateDmg"); @@ -856,9 +852,9 @@ private static StringBuilder inGameValues(Entity entity, Player localPlayer) { if (!isGunEmplacement) { // "Has not yet moved" only during movement phase if (!entity.isDone() && game.getPhase().isMovement()) { - i = addToTT("NotYetMoved", BR).toString(); - f = "" + i + ""; - result += guiScaledFontHTML(GUIP.getColorForMovement(entity.moved)) + f + ""; + String sNotYetMoved = addToTT("NotYetMoved", BR).toString(); + sNotYetMoved = "" + sNotYetMoved + ""; + result += guiScaledFontHTML(GUIP.getColorForMovement(entity.moved)) + sNotYetMoved + ""; } else if ((entity.isDone() && game.getPhase().isMovement()) || (game.getPhase().isMovementReport()) || (game.getPhase().isFiring()) @@ -866,107 +862,113 @@ private static StringBuilder inGameValues(Entity entity, Player localPlayer) { || (game.getPhase().isPhysical()) || (game.getPhase().isPhysicalReport())) { int tmm = Compute.getTargetMovementModifier(game, entity.getId()).getValue(); + String sMove = ""; + if (entity.moved == EntityMovementType.MOVE_NONE) { - i = addToTT("NoMove", BR, tmm).toString(); - f = "" + i + ""; + sMove = addToTT("NoMove", BR, tmm).toString(); + sMove = "" + sMove + ""; } else { - i = addToTT("MovementF", BR, entity.getMovementString(entity.moved), + sMove = addToTT("MovementF", BR, entity.getMovementString(entity.moved), entity.delta_distance, tmm).toString(); - f = "" + i + ""; + sMove = "" + sMove + ""; } + // Special Moves if (entity.isEvading()) { - i = addToTT("Evade", BR).toString(); - f = "" + i + ""; - f = guiScaledFontHTML(GUIP.getWarningColor()) + f + ""; + String sSpecialMove = addToTT("Evade", BR).toString(); + sSpecialMove = "" + sSpecialMove + ""; + sSpecialMove = guiScaledFontHTML(GUIP.getWarningColor()) + sSpecialMove + ""; + sMove += sSpecialMove; } if ((entity instanceof Infantry) && ((Infantry) entity).isTakingCover()) { - i = addToTT("TakingCover", BR).toString(); - f = "" + i + ""; - f = guiScaledFontHTML(GUIP.getWarningColor()) + f + ""; + String sTakingCover = addToTT("TakingCover", BR).toString(); + sTakingCover = "" + sTakingCover + ""; + sTakingCover = guiScaledFontHTML(GUIP.getWarningColor()) + sTakingCover + ""; + sMove += sTakingCover; } if (entity.isCharging()) { - f = addToTT("Charging", BR).toString(); + sMove += addToTT("Charging", BR).toString(); } if (entity.isMakingDfa()) { - i = addToTT("DFA", BR).toString(); - f = "" + i + ""; - f = guiScaledFontHTML(GUIP.getWarningColor()) + f + ""; + String sDFA = addToTT("DFA", BR).toString(); + sDFA = "" + sDFA + ""; + sDFA = guiScaledFontHTML(GUIP.getWarningColor()) + sDFA + ""; + sMove += sDFA; } if (entity.isUnjammingRAC()) { - f = "
    "; + String sUnJamming = "
    "; String msg_unjammingrac = Messages.getString("BoardView1.Tooltip.UnjammingRAC"); - f += msg_unjammingrac; + sUnJamming += msg_unjammingrac; if (entity.getGame().getOptions().booleanOption(OptionsConstants.ADVCOMBAT_UNJAM_UAC)) { String msg_andac = Messages.getString("BoardView1.Tooltip.AndAC"); - f += msg_andac; + sUnJamming += msg_andac; } + sMove += sUnJamming; } - result += guiScaledFontHTML(GUIP.getColorForMovement(entity.moved)) + f + ""; + result += guiScaledFontHTML(GUIP.getColorForMovement(entity.moved)) + sMove + ""; } } - i = ""; - f = ""; + String sAeroInfo = ""; if (entity.isAero()) { // Velocity, Altitude, Elevation, Fuel IAero aero = (IAero) entity; - i = addToTT("AeroVelAltFuel", BR, aero.getCurrentVelocity(), aero.getAltitude(), aero.getFuel()).toString(); + sAeroInfo = addToTT("AeroVelAltFuel", BR, aero.getCurrentVelocity(), aero.getAltitude(), aero.getFuel()).toString(); } else if (entity.getElevation() != 0) { // Elevation only - i = addToTT("Elev", BR, entity.getElevation()).toString(); + sAeroInfo = addToTT("Elev", BR, entity.getElevation()).toString(); } - f = "" + i + ""; - result += guiScaledFontHTML(uiLightViolet()) + f + ""; + sAeroInfo = "" + sAeroInfo + ""; + result += guiScaledFontHTML(uiLightViolet()) + sAeroInfo + ""; result += "
    "; String msg_facing = Messages.getString("BoardView1.Tooltip.Facing"); - f = "  " + msg_facing + ": " + PlanetaryConditions.getWindDirDisplayableName(entity.getFacing()); + String sFacingTwist = "  " + msg_facing + ": " + PlanetaryConditions.getWindDirDisplayableName(entity.getFacing()); if (entity.getFacing() != entity.getSecondaryFacing()) { String msg_twist = Messages.getString("BoardView1.Tooltip.Twist"); - f = "  " + msg_twist + ": " + PlanetaryConditions.getWindDirDisplayableName(entity.getSecondaryFacing()); + sFacingTwist += "  " + msg_twist + ": " + PlanetaryConditions.getWindDirDisplayableName(entity.getSecondaryFacing()); } - result += guiScaledFontHTML() + f + ""; + result += guiScaledFontHTML() + sFacingTwist + ""; // Heat, not shown for units with 999 heat sinks (vehicles) if (entity.getHeatCapacity() != 999) { int heat = entity.heat; - f = ""; + String sHeat = ""; if (heat == 0) { - f += addToTT("Heat0", BR).toString(); + sHeat += addToTT("Heat0", BR).toString(); } else { - f += addToTT("Heat", BR, heat).toString(); + sHeat += addToTT("Heat", BR, heat).toString(); } - f += " / "+entity.getHeatCapacity(); - result += guiScaledFontHTML(GUIP.getColorForHeat(heat)) + f + ""; + sHeat += " / "+entity.getHeatCapacity(); + result += guiScaledFontHTML(GUIP.getColorForHeat(heat)) + sHeat + ""; } // Gun Emplacement Status if (isGunEmplacement) { GunEmplacement emp = (GunEmplacement) entity; if (emp.isTurret() && emp.isTurretLocked(emp.getLocTurret())) { - i = addToTT("TurretLocked", BR).toString(); - f = "" + i + ""; - result += guiScaledFontHTML(GUIP.getWarningColor()) + f + ""; + String sTurretLocked = addToTT("TurretLocked", BR).toString(); + sTurretLocked = "" + sTurretLocked + ""; + result += guiScaledFontHTML(GUIP.getWarningColor()) + sTurretLocked + ""; } } // Unit Immobile if (!isGunEmplacement && entity.isImmobile()) { - f = addToTT("Immobile", BR).toString(); - result += guiScaledFontHTML(GUIP.getWarningColor()) + f + ""; + String sImmobile = addToTT("Immobile", BR).toString(); + result += guiScaledFontHTML(GUIP.getWarningColor()) + sImmobile + ""; } // Unit Prone if (!isGunEmplacement && entity.isProne()) { - f = addToTT("Prone", BR).toString(); - result += guiScaledFontHTML(GUIP.getWarningColor()) + f + ""; + String sUnitProne = addToTT("Prone", BR).toString(); + result += guiScaledFontHTML(GUIP.getWarningColor()) + sUnitProne + ""; } @@ -991,14 +993,14 @@ private static StringBuilder inGameValues(Entity entity, Player localPlayer) { } String msg_error = Messages.getString("ERROR"); String sa = (swarmAttacker == null) ? msg_error : swarmAttacker.getDisplayName(); - f = addToTT("Swarmed", BR, sa).toString(); - result += guiScaledFontHTML(GUIP.getWarningColor()) + f + ""; + String sSwarmed = addToTT("Swarmed", BR, sa).toString(); + result += guiScaledFontHTML(GUIP.getWarningColor()) + sSwarmed + ""; } // Spotting if (entity.isSpotting() && game.hasEntity(entity.getSpotTargetId())) { - f = addToTT("Spotting", BR, game.getEntity(entity.getSpotTargetId()).getDisplayName()).toString(); - result += guiScaledFontHTML() + f + ""; + String sSpotting = addToTT("Spotting", BR, game.getEntity(entity.getSpotTargetId()).getDisplayName()).toString(); + result += guiScaledFontHTML() + sSpotting + ""; } // If Double Blind, add information about who sees this Entity @@ -1038,8 +1040,8 @@ private static StringBuilder inGameValues(Entity entity, Player localPlayer) { } if (tempList.length() > 1) { tempList.delete(tempList.length() - 2, tempList.length()); - f = addToTT("SeenBy", BR, tempList.toString()).toString(); - result += guiScaledFontHTML() + f + ""; + String sSeenBy = addToTT("SeenBy", BR, tempList.toString()).toString(); + result += guiScaledFontHTML() + sSeenBy + ""; } } @@ -1050,8 +1052,8 @@ private static StringBuilder inGameValues(Entity entity, Player localPlayer) { } if (entity.hasAnyTypeNarcPodsAttached()) { - f = addToTT(entity.hasNarcPodsAttached() ? "Narced" : "INarced", BR).toString(); - result += guiScaledFontHTML(uiLightRed()) + f + ""; + String sNarced = addToTT(entity.hasNarcPodsAttached() ? "Narced" : "INarced", BR).toString(); + result += guiScaledFontHTML(uiLightRed()) + sNarced + ""; } // Towing @@ -1075,8 +1077,6 @@ private static StringBuilder inGameValues(Entity entity, Player localPlayer) { private static StringBuilder entityValues(Entity entity) { boolean isGunEmplacement = entity instanceof GunEmplacement; String result = ""; - String f = ""; - String d = ""; String l1= ""; String l2 = ""; String l3 = ""; @@ -1156,10 +1156,10 @@ private static StringBuilder entityValues(Entity entity) { int walkMP = entity.getOriginalWalkMP(); int runMP = entity.getOriginalRunMP(); int jumpMP = entity.getOriginalJumpMP(); - d = addToTT("Movement", NOBR , walkMP, runMP).toString(); + String sMove = addToTT("Movement", NOBR , walkMP, runMP).toString(); if (jumpMP > 0) { - d += "/" + jumpMP; + sMove += "/" + jumpMP; } int walkMPModified = entity.getWalkMP(true, false,false); @@ -1167,51 +1167,51 @@ private static StringBuilder entityValues(Entity entity) { int jumpMPModified = entity.getJumpMP(true); if ((walkMP != walkMPModified) || (runMP != runMPModified) || (jumpMP != jumpMPModified)) { - d += DOT_SPACER + walkMPModified + "/" + runMPModified; + sMove += DOT_SPACER + walkMPModified + "/" + runMPModified; if (jumpMPModified > 0) { - d += "/" + jumpMPModified; + sMove += "/" + jumpMPModified; } if (entity.getGame().getPlanetaryConditions().getGravity() != 1.0) { - d += DOT_SPACER; - f = entity.getGame().getPlanetaryConditions().getGravity() + "g"; - d += guiScaledFontHTML(GUIP.getWarningColor()) + f + ""; + sMove += DOT_SPACER; + String sGravity = entity.getGame().getPlanetaryConditions().getGravity() + "g"; + sMove += guiScaledFontHTML(GUIP.getWarningColor()) + sGravity + ""; } int walkMPNoHeat = entity.getWalkMP(true, true,false); int runMPNoHeat = entity.getRunMP(true, true, false); if ((walkMPNoHeat != walkMPModified) || (runMPNoHeat != runMPModified)) { - d += DOT_SPACER; - f = "\uD83D\uDD25"; - d += guiScaledFontHTML(GUIP.getWarningColor()) + f + ""; + sMove += DOT_SPACER; + String sHeat = "\uD83D\uDD25"; + sMove += guiScaledFontHTML(GUIP.getWarningColor()) + sHeat + ""; } } - d += DOT_SPACER; - f = entity.getMovementModeAsString(); - d += guiScaledFontHTML(uiWhite()) + f + ""; + sMove += DOT_SPACER; + String sMoveMode = entity.getMovementModeAsString(); + sMove += sMoveMode; if (entity instanceof IBomber) { int bombMod = 0; bombMod = ((IBomber) entity).reduceMPByBombLoad(walkMP); if (bombMod != walkMP) { - d += DOT_SPACER; - f = "\uD83D\uDCA3"; - d+= guiScaledFontHTML(GUIP.getWarningColor()) + f + ""; + sMove += DOT_SPACER; + String sBomb = "\uD83D\uDCA3"; + sMove += guiScaledFontHTML(GUIP.getWarningColor()) + sBomb + ""; } } int weatherMod = entity.getGame().getPlanetaryConditions().getMovementMods(entity); if ((weatherMod != 0) || (partialWingWeaterMod != 0)) { - d += DOT_SPACER; - f = "\u2602"; - d += guiScaledFontHTML(GUIP.getWarningColor()) + f + ""; + sMove += DOT_SPACER; + String sWeather = "\u2602"; + sMove += guiScaledFontHTML(GUIP.getWarningColor()) + sWeather + ""; } if ((legsDestroyed > 0) || (hipHits > 0) || (actuatorHits > 0) || (jumpJetDistroyed > 0) || (paritalWingDistroyed > 0) || (jumpBoosterDistroyed > 0) || (entity.isImmobile()) || (entity.isGyroDestroyed())) { - d += DOT_SPACER; - f = "\uD83D\uDD27"; - d += guiScaledFontHTML(GUIP.getWarningColor()) + f + ""; + sMove += DOT_SPACER; + String sDamage = "\uD83D\uDD27"; + sMove += guiScaledFontHTML(GUIP.getWarningColor()) + sDamage + ""; } if ((entity instanceof BipedMech) || (entity instanceof TripodMech)) { @@ -1222,20 +1222,19 @@ private static StringBuilder entityValues(Entity entity) { } if (shieldMod != 0) { - d += DOT_SPACER; - f = "\u26E8"; - d += guiScaledFontHTML(GUIP.getWarningColor()) + f + ""; + sMove += DOT_SPACER; + String sShield = "\u26E8"; + sMove += guiScaledFontHTML(GUIP.getWarningColor()) + sShield + ""; } } if (entity.hasModularArmor()) { - d += DOT_SPACER; - f = "\u27EC\u25AE"; - d += DOT_SPACER + guiScaledFontHTML(GUIP.getWarningColor()) + f + ""; + sMove += DOT_SPACER; + String sArmor = "\u27EC\u25AE"; + sMove += DOT_SPACER + guiScaledFontHTML(GUIP.getWarningColor()) + sArmor + ""; } - l1 = "
  • " + d + "
  • "; - d = ""; + l1 = "
  • " + sMove + "
  • "; if ((jumpJetDistroyed > 0) || (jumpBoosterDistroyed > 0) || (paritalWingDistroyed > 0)) { String jj = ""; @@ -1263,16 +1262,13 @@ private static StringBuilder entityValues(Entity entity) { Infantry inf = (Infantry) entity; int spec = inf.getSpecializations(); if (spec > 0) { - d += addToTT("InfSpec", NOBR, Infantry.getSpecializationName(spec)).toString(); - l3 = "
  • " + d + "
  • "; - d = ""; + String sInfantrySpec = addToTT("InfSpec", NOBR, Infantry.getSpecializationName(spec)).toString(); + l3 = "
  • " + sInfantrySpec + "
  • "; } } // Armor and Internals - if (entity.isConventionalInfantry()) { - d += ""; - } else if (!isGunEmplacement) { + if (!isGunEmplacement) { String msg_unknown = Messages.getString("BoardView1.Tooltip.Unknown"); String armorType = TROView.formatArmorType(entity, true).replace(msg_unknown, ""); if (!armorType.isBlank()) { @@ -1281,9 +1277,8 @@ private static StringBuilder entityValues(Entity entity) { armorType = " (" + armorType + ")"; } String armorStr = " " + entity.getTotalArmor() + armorType; - d += addToTT("ArmorInternals", NOBR, armorStr, entity.getTotalInternal()).toString(); - l4 = "
  • " + d + "
  • "; - d = ""; + String sArmorInternals = addToTT("ArmorInternals", NOBR, armorStr, entity.getTotalInternal()).toString(); + l4 = "
  • " + sArmorInternals + "
  • "; } String ul = "
      " + l1 + l2 + l3 + l4 + "
    "; @@ -1296,42 +1291,42 @@ private static StringBuilder entityValues(Entity entity) { private static StringBuilder deploymentWarnings(Entity entity, Player localPlayer, MapSettings mapSettings) { String result = ""; - String f = ""; + String sWarnings = ""; // Critical (red) warnings if (entity.getGame().getPlanetaryConditions().whyDoomed(entity, entity.getGame()) != null) { String msg_cannotsurvive = Messages.getString("BoardView1.Tooltip.CannotSurvive"); - f = "
    " + msg_cannotsurvive + " " + entity.getGame().getPlanetaryConditions().whyDoomed(entity, entity.getGame()); + sWarnings += "
    " + msg_cannotsurvive + " " + entity.getGame().getPlanetaryConditions().whyDoomed(entity, entity.getGame()); } if (entity.doomedInAtmosphere() && mapSettings.getMedium() == MapSettings.MEDIUM_ATMOSPHERE) { String msg_cannotsurviveatmo = Messages.getString("BoardView1.Tooltip.CannotSurviveAtmo"); - f = "
    " + msg_cannotsurviveatmo; + sWarnings += "
    " + msg_cannotsurviveatmo; } if (entity.doomedOnGround() && mapSettings.getMedium() == MapSettings.MEDIUM_GROUND) { String msg_cannotsurviveground = Messages.getString("BoardView1.Tooltip.CannotSurviveGround"); - f = "
    " + msg_cannotsurviveground; + sWarnings += "
    " + msg_cannotsurviveground; } if (entity.doomedInSpace() && mapSettings.getMedium() == MapSettings.MEDIUM_SPACE) { String msg_cannotsurvivespace = Messages.getString("BoardView1.Tooltip.CannotSurviveSpace"); - f = "
    " + msg_cannotsurvivespace; + sWarnings += "
    " + msg_cannotsurvivespace; } - result += guiScaledFontHTML(GUIP.getWarningColor()) + f + ""; + result += guiScaledFontHTML(GUIP.getWarningColor()) + sWarnings + ""; - f = ""; + String sNoncritial = ""; // Non-critical (yellow) warnings if (((entity.hasC3i() || entity.hasNavalC3()) && (entity.calculateFreeC3Nodes() == 5)) || ((entity.getC3Master() == null) && entity.hasC3S()) || (entity.hasNovaCEWS() && (entity.calculateFreeC3Nodes() == 2))) { String msg_unconnectedc3computer = Messages.getString("BoardView1.Tooltip.UnconnectedC3Computer"); - f = "
    " + msg_unconnectedc3computer; + sNoncritial += "
    " + msg_unconnectedc3computer; } // Non-critical (yellow) warnings if (entity instanceof FighterSquadron && entity.getLoadedUnits().isEmpty()) { String msg_fightersquadronempty = Messages.getString("BoardView1.Tooltip.FighterSquadronEmpty"); - f = "
    " + msg_fightersquadronempty; + sNoncritial += "
    " + msg_fightersquadronempty; } - result += guiScaledFontHTML(uiYellow()) + f + ""; + result += guiScaledFontHTML(uiYellow()) + sNoncritial + ""; return new StringBuilder().append(result); } @@ -1339,30 +1334,30 @@ private static StringBuilder deploymentWarnings(Entity entity, Player localPlaye /** Returns a list of units loaded onto this unit. */ private static StringBuilder carriedUnits(Entity entity) { String result = ""; - String f = ""; + String sCarriedUnits = ""; if (entity instanceof FighterSquadron) { String msg_fighter = Messages.getString("BoardView1.Tooltip.Fighters"); - f += msg_fighter + ":"; + sCarriedUnits += msg_fighter + ":"; } else { String msg_carriedunits = Messages.getString("BoardView1.Tooltip.CarriedUnits"); - f += msg_carriedunits + ":"; + sCarriedUnits += msg_carriedunits + ":"; } for (Entity carried: entity.getLoadedUnits()) { - f += "
      " + carried.getShortNameRaw(); + sCarriedUnits += "
      " + carried.getShortNameRaw(); if (PreferenceManager.getClientPreferences().getShowUnitId()) { - f += " [" + carried.getId() + "]"; + sCarriedUnits += " [" + carried.getId() + "]"; } } - result = guiScaledFontHTML() + f + ""; + result = guiScaledFontHTML() + sCarriedUnits + ""; return new StringBuilder().append(result); } /** Returns the full force chain the entity is in as one text line. */ private static StringBuilder forceEntry(Entity entity, Player localPlayer) { String result = ""; - String f = ""; + String sForceEntry = ""; if (entity.partOfForce()) { // Get the my / ally / enemy color and desaturate it @@ -1373,13 +1368,13 @@ private static StringBuilder forceEntry(Entity entity, Player localPlayer) { color = GUIP.getAllyUnitColor(); } color = addGray(color, 128).brighter(); - f = "
    "; + sForceEntry = "
    "; var forceChain = entity.getGame().getForces().forceChain(entity); for (int i = forceChain.size() - 1; i >= 0; i--) { - f += forceChain.get(i).getName(); - f += i != 0 ? ", " : ""; + sForceEntry += forceChain.get(i).getName(); + sForceEntry += i != 0 ? ", " : ""; } - result = guiScaledFontHTML(color) + f + ""; + result = guiScaledFontHTML(color) + sForceEntry + ""; } return new StringBuilder().append(result); @@ -1388,7 +1383,7 @@ private static StringBuilder forceEntry(Entity entity, Player localPlayer) { /** Returns an overview of the C3 system the unit is in. */ private static StringBuilder c3Info(Entity entity) { String result = ""; - String f = ""; + String sC3Info = ""; List members = entity.getGame().getEntitiesVector().stream() .filter(e -> e.onSameC3NetworkAs(entity)) @@ -1398,47 +1393,44 @@ private static StringBuilder c3Info(Entity entity) { if (entity.hasNhC3()) { String msg_c3i = Messages.getString("BoardView1.Tooltip.C3i"); String msg_nc3 = Messages.getString("BoardView1.Tooltip.NC3"); - f = entity.hasC3i() ? msg_c3i : msg_nc3; + sC3Info = entity.hasC3i() ? msg_c3i : msg_nc3; } else { String msg_c3 = Messages.getString("BoardView1.Tooltip.C3"); - f = msg_c3; + sC3Info = msg_c3; } String msg_network = Messages.getString("BoardView1.Tooltip.Network"); - f += " " + msg_network + ":
      "; - f += String.join("
      ", members); - f += "
    "; + sC3Info += " " + msg_network + ":
      "; + sC3Info += String.join("
      ", members); + sC3Info += "
    "; } - result = guiScaledFontHTML(uiC3Color(), -0.2f) + f + ""; + result = guiScaledFontHTML(uiC3Color(), -0.2f) + sC3Info + ""; return new StringBuilder().append(result); } private static String c3UnitName(Entity c3member, Entity entity) { String result = ""; - String it = ""; - String f = ""; + String msg_c3 = ""; + String sC3UnitName = ""; String tmp = ""; - f = " [" + c3member.getId() + "] "; + sC3UnitName = " [" + c3member.getId() + "] "; if (c3member.isC3CompanyCommander()) { - String msg_c3cc = Messages.getString("BoardView1.Tooltip.C3CC"); - it += msg_c3cc + " "; + msg_c3 = Messages.getString("BoardView1.Tooltip.C3CC") + " "; } else if (c3member.hasC3M()) { - String msg_c3m = Messages.getString("BoardView1.Tooltip.C3M"); - it += msg_c3m + " "; + msg_c3 = Messages.getString("BoardView1.Tooltip.C3M") + " "; } - f += "" + it + ""; - result += guiScaledFontHTML(uiGray(), -0.2f) + f + ""; + sC3UnitName += "" + msg_c3 + ""; + result += guiScaledFontHTML(uiGray(), -0.2f) + sC3UnitName + ""; result += c3member.getShortNameRaw(); - String msg_thisunit = Messages.getString("BoardView1.Tooltip.ThisUnit"); - it = " (" + msg_thisunit + ")"; - tmp = "" + it + ""; - f = c3member.equals(entity) ? tmp : ""; - result += guiScaledFontHTML(uiGray(), -0.2f) + f + ""; + String msg_thisunit = " (" + Messages.getString("BoardView1.Tooltip.ThisUnit") + ")"; + tmp = "" + msg_thisunit + ""; + String sC3Member = c3member.equals(entity) ? tmp : ""; + result += guiScaledFontHTML(uiGray(), -0.2f) + sC3Member + ""; return result; }