From 598fd99e61bec4d20f548ebce700ec63b92ca480 Mon Sep 17 00:00:00 2001 From: kuronekochomusuke Date: Sun, 13 Oct 2024 16:22:43 -0400 Subject: [PATCH] correct issues --- .../swing/boardview/TWBoardViewTooltip.java | 28 +++- .../client/ui/swing/tooltip/HexTooltip.java | 12 +- .../client/ui/swing/tooltip/UnitToolTip.java | 136 ++++++++++++------ .../ui/swing/unitDisplay/SummaryPanel.java | 1 - .../ui/swing/unitDisplay/WeaponPanel.java | 3 - .../megamek/client/ui/swing/util/UIUtil.java | 5 +- 6 files changed, 125 insertions(+), 60 deletions(-) diff --git a/megamek/src/megamek/client/ui/swing/boardview/TWBoardViewTooltip.java b/megamek/src/megamek/client/ui/swing/boardview/TWBoardViewTooltip.java index 20b125a54b..4557e87b92 100644 --- a/megamek/src/megamek/client/ui/swing/boardview/TWBoardViewTooltip.java +++ b/megamek/src/megamek/client/ui/swing/boardview/TWBoardViewTooltip.java @@ -63,6 +63,8 @@ public String getTooltip(Point point, Coords movementTarget) { if (!game.getBoard().contains(coords)) { return null; } + + String fontSizeAttr = String.format("class=%s", GUIP.getUnitToolTipFontSizeMod()); Entity selectedEntity = (clientGui != null) ? clientGui.getDisplayedUnit() : null; Player localPlayer = localPlayer(); Hex mhex = game.getBoard().getHex(coords); @@ -125,9 +127,13 @@ public String getTooltip(Point point, Coords movementTarget) { String sInvalidHex = Messages.getString("BoardView1.invalidHex"); sInvalidHex += "
"; sInvalidHex += String.join("
", errors); - attr = String.format("FACE=Dialog COLOR=%s", UIUtil.toColorHexString((GUIP.getUnitToolTipFGColor()))); + attr = String.format("FACE=Dialog COLOR=%s", UIUtil.toColorHexString((GUIP.getUnitToolTipTerrainFGColor()))); sInvalidHex += UIUtil.tag("FONT", attr, sInvalidHex); - result += "
" + sInvalidHex; + sInvalidHex = UIUtil.tag("span", fontSizeAttr, sInvalidHex); + col = UIUtil.tag("TD", "", sInvalidHex); + row = UIUtil.tag("TR", "", col); + attr = String.format("BORDER=0 BGCOLOR=%s width=100%%", GUIPreferences.hexColor(GUIP.getUnitToolTipTerrainBGColor())); + result += UIUtil.tag("TABLE", attr, row); } } } @@ -177,6 +183,7 @@ public String getTooltip(Point point, Coords movementTarget) { String attr = String.format("FACE=Dialog COLOR=%s", UIUtil.toColorHexString(GUIP.getUnitToolTipBlockFGColor())); sUnitsInfo = UIUtil.tag("FONT", attr, sUnitsInfo); + sUnitsInfo = UIUtil.tag("span", fontSizeAttr, sUnitsInfo); String col = UIUtil.tag("TD", "", sUnitsInfo); String row = UIUtil.tag("TR", "", col); attr = String.format("BORDER=0 BGCOLOR=%s width=100%%", GUIPreferences.hexColor(GUIP.getUnitToolTipBlockBGColor())); @@ -191,6 +198,7 @@ public String getTooltip(Point point, Coords movementTarget) { String attr = String.format("FACE=Dialog COLOR=%s", UIUtil.toColorHexString(GUIP.getUnitToolTipAltFGColor())); sAttackSprite = UIUtil.tag("FONT", attr, sAttackSprite); + sAttackSprite = UIUtil.tag("span", fontSizeAttr, sAttackSprite); String col = UIUtil.tag("TD", "", sAttackSprite); String row = UIUtil.tag("TR", "", col); attr = String.format("BORDER=0 BGCOLOR=%s width=100%%", GUIPreferences.hexColor(GUIP.getUnitToolTipAltBGColor())); @@ -231,6 +239,7 @@ public String getTooltip(Point point, Coords movementTarget) { String attr = String.format("FACE=Dialog COLOR=%s", UIUtil.toColorHexString(GUIP.getUnitToolTipBlockFGColor())); msg_artilleryatack = UIUtil.tag("FONT", attr, msg_artilleryatack); + msg_artilleryatack = UIUtil.tag("span", fontSizeAttr, msg_artilleryatack); String col = UIUtil.tag("TD", "", msg_artilleryatack); String row = UIUtil.tag("TR", "", col); attr = String.format("BORDER=0 BGCOLOR=%s width=100%%", GUIPreferences.hexColor(GUIP.getUnitToolTipBlockBGColor())); @@ -261,7 +270,11 @@ public String getTooltip(Point point, Coords movementTarget) { String attr = String.format("FACE=Dialog COLOR=%s", UIUtil.toColorHexString(GUIP.getUnitToolTipFGColor())); msg_artilleryautohit = UIUtil.tag("FONT", attr, msg_artilleryautohit); - result += msg_artilleryautohit + "
"; + msg_artilleryautohit = UIUtil.tag("span", fontSizeAttr, msg_artilleryautohit); + String col = UIUtil.tag("TD", "", msg_artilleryautohit); + String row = UIUtil.tag("TR", "", col); + attr = String.format("BORDER=0 BGCOLOR=%s width=100%%", GUIPreferences.hexColor(GUIP.getUnitToolTipBGColor())); + result += UIUtil.tag("TABLE", attr, row); } final Collection shdList = game.getBoard().getSpecialHexDisplay(coords); @@ -295,7 +308,11 @@ public String getTooltip(Point point, Coords movementTarget) { } } - result += sSpecialHex; + sSpecialHex = UIUtil.tag("span", fontSizeAttr, sSpecialHex); + String col = UIUtil.tag("TD", "", sSpecialHex); + String row = UIUtil.tag("TR", "", col); + String attr = String.format("BORDER=0 BGCOLOR=%s width=100%%", GUIPreferences.hexColor(GUIP.getUnitToolTipBGColor())); + result += UIUtil.tag("TABLE", attr, row); } StringBuilder txt = new StringBuilder(); @@ -356,8 +373,7 @@ public void appendEntityTooltip(StringBuffer txt, @Nullable Entity entity) { String result = "
"; String entityTip = UnitToolTip.getEntityTipGame(entity, localPlayer()).toString(); - String table = UnitToolTip.addPlayerColorBoarder(GUIP, entity, entityTip); - result += table; + result += entityTip; txt.append(result); } diff --git a/megamek/src/megamek/client/ui/swing/tooltip/HexTooltip.java b/megamek/src/megamek/client/ui/swing/tooltip/HexTooltip.java index 82f50bf34f..2f57a669b2 100644 --- a/megamek/src/megamek/client/ui/swing/tooltip/HexTooltip.java +++ b/megamek/src/megamek/client/ui/swing/tooltip/HexTooltip.java @@ -69,7 +69,7 @@ public static String getHexTip(Hex mhex, @Nullable Client client, GUIPreferences sFuelTank = UIUtil.tag("span", fontSizeAttr, sFuelTank); String col = UIUtil.tag("TD", "", sFuelTank); String row = UIUtil.tag("TR", "", col); - attr = String.format("BORDER=0 BGCOLOR=%s width=100%%", GUIPreferences.hexColor(GUIP.getUnitToolTipBuildingBGColor())); + attr = String.format("CELLSPACING=0 CELLPADDING=0 BORDER=0 BGCOLOR=%s width=100%%", GUIPreferences.hexColor(GUIP.getUnitToolTipBuildingBGColor())); String table = UIUtil.tag("TABLE", attr, row); result.append(table); } @@ -105,7 +105,7 @@ public static String getHexTip(Hex mhex, @Nullable Client client, GUIPreferences sBuilding = UIUtil.tag("span", fontSizeAttr, sBuilding); String col = UIUtil.tag("TD", "", sBuilding); String row = UIUtil.tag("TR", "", col); - attr = String.format("BORDER=0 BGCOLOR=%s width=100%%", GUIPreferences.hexColor(GUIP.getUnitToolTipBuildingBGColor())); + attr = String.format("CELLSPACING=0 CELLPADDING=0 BORDER=0 BGCOLOR=%s width=100%%", GUIPreferences.hexColor(GUIP.getUnitToolTipBuildingBGColor())); String table = UIUtil.tag("TABLE", attr, row); result.append(table); } @@ -133,7 +133,7 @@ public static String getHexTip(Hex mhex, @Nullable Client client, GUIPreferences sBridge = UIUtil.tag("span", fontSizeAttr, sBridge); String col = UIUtil.tag("TD", "", sBridge); String row = UIUtil.tag("TR", "", col); - attr = String.format("BORDER=0 BGCOLOR=%s width=100%%", GUIPreferences.hexColor(GUIP.getUnitToolTipBuildingBGColor())); + attr = String.format("CELLSPACING=0 CELLPADDING=0 BORDER=0 BGCOLOR=%s width=100%%", GUIPreferences.hexColor(GUIP.getUnitToolTipBuildingBGColor())); String table = UIUtil.tag("TABLE", attr, row); result.append(table); } @@ -204,7 +204,7 @@ public static String getBuildingTargetTip(BuildingTarget target, Board board, GU sBuilding = UIUtil.tag("span", fontSizeAttr, sBuilding); String col = UIUtil.tag("TD", "", sBuilding); String row = UIUtil.tag("TR", "", col); - attr = String.format("BORDER=0 BGCOLOR=%s width=100%%", GUIPreferences.hexColor(GUIP.getUnitToolTipBuildingBGColor())); + attr = String.format("CELLSPACING=0 CELLPADDING=0 BORDER=0 BGCOLOR=%s width=100%%", GUIPreferences.hexColor(GUIP.getUnitToolTipBuildingBGColor())); String table = UIUtil.tag("TABLE", attr, row); return table; @@ -353,7 +353,7 @@ public static String getAttilleryHit(GUIPreferences GUIP, Game game, Coords coor sAttilleryAutoHix = UIUtil.tag("span", fontSizeAttr, sAttilleryAutoHix); String col = UIUtil.tag("TD", "", sAttilleryAutoHix); String row = UIUtil.tag("TR", "", col); - attr = String.format("BORDER=0 BGCOLOR=%s width=100%%", GUIPreferences.hexColor(GUIP.getUnitToolTipBGColor())); + attr = String.format("CELLSPACING=0 CELLPADDING=0 BORDER=0 BGCOLOR=%s width=100%%", GUIPreferences.hexColor(GUIP.getUnitToolTipBGColor())); String table = UIUtil.tag("TABLE", attr, row); return table; @@ -399,7 +399,7 @@ public static String getWrecks(GUIPreferences GUIP, BoardView bv, Coords coords) rows += row; } - attr = String.format("BORDER=0 BGCOLOR=%s width=100%%", GUIPreferences.hexColor(GUIP.getUnitToolTipAltBGColor())); + attr = String.format("CELLSPACING=0 CELLPADDING=0 BORDER=0 BGCOLOR=%s width=100%%", GUIPreferences.hexColor(GUIP.getUnitToolTipAltBGColor())); String table = UIUtil.tag("TABLE", attr, rows); result = table; } diff --git a/megamek/src/megamek/client/ui/swing/tooltip/UnitToolTip.java b/megamek/src/megamek/client/ui/swing/tooltip/UnitToolTip.java index fd2d50630d..87ff48859d 100644 --- a/megamek/src/megamek/client/ui/swing/tooltip/UnitToolTip.java +++ b/megamek/src/megamek/client/ui/swing/tooltip/UnitToolTip.java @@ -141,7 +141,7 @@ private static StringBuilder getEntityTipTable(Entity entity, Player localPlayer if (entity instanceof FighterSquadron && entity.getLoadedUnits().isEmpty()) { String col = UIUtil.tag("TD", "", result); String row = UIUtil.tag("TR", "", col); - String table = UIUtil.tag("TABLE", "width=100%", row); + String table = UIUtil.tag("TABLE", "CELLSPACING=0 CELLPADDING=0 width=100%", row); return new StringBuilder().append(table); } @@ -163,9 +163,6 @@ private static StringBuilder getEntityTipTable(Entity entity, Player localPlayer // Bomb List result += bombList(entity); - // StratOps quirks, chassis and weapon - result += getQuirks(entity, game, details); - // Partial repairs result += getPartialRepairs(entity, details); @@ -178,10 +175,13 @@ private static StringBuilder getEntityTipTable(Entity entity, Player localPlayer // C3 Info result += c3Info(entity, details); + // StratOps quirks, chassis and weapon + result += getQuirks(entity, game, details); + String col = UIUtil.tag("TD", "", result); String row = UIUtil.tag("TR", "", col); String table = UIUtil.tag("TABLE", "CELLSPACING=0 CELLPADDING=0 width=100%", row); - + table = UnitToolTip.addPlayerColorBoarder(GUIP, entity, table); return new StringBuilder().append(table); } @@ -202,8 +202,10 @@ public static String getTargetTipDetail(Targetable target, @Nullable Client clie public static String getTargetTipSummary(Targetable target, @Nullable Client client) { if (target == null) { return Messages.getString("BoardView1.Tooltip.NoTarget"); - } else if (target instanceof Entity) { - return getTargetTipSummaryEntity((Entity) target, client); + } else if (target instanceof Entity targetEntity) { + String result = getTargetTipSummaryEntity((Entity) target, client); + result = UnitToolTip.addPlayerColorBoarder(GUIP, targetEntity, result); + return result; } else if (target instanceof BuildingTarget) { return HexTooltip.getOneLineSummary((BuildingTarget) target, (client != null) ? client.getBoard() : null); } @@ -226,7 +228,7 @@ public static String getTargetTipSummaryEntity(Entity entity, @Nullable Client c return result; } - public static String addPlayerColorBoarder(GUIPreferences GUIP, Entity entity, String entityTip) { + private static String addPlayerColorBoarder(GUIPreferences GUIP, Entity entity, String entityTip) { Color color = GUIP.getUnitToolTipFGColor(); // the player's color // Table to add a bar to the left of an entity in @@ -311,7 +313,7 @@ private static String getPilotInfo(Entity entity, boolean pilotInfoShow, boolean private static String getQuirks(Entity entity, Game game, boolean details) { if (game.getOptions().booleanOption(OptionsConstants.ADVANCED_STRATOPS_QUIRKS)) { - String sQuirks = "
"; + String sQuirks = ""; String quirksList = getOptionList(entity.getQuirks().getGroups(), entity::countQuirks, details); if (!quirksList.isEmpty()) { sQuirks += quirksList; @@ -325,10 +327,18 @@ private static String getQuirks(Entity entity, Game game, boolean details) { } } - String attr = String.format("FACE=Dialog COLOR=%s", UIUtil.toColorHexString(GUIP.getUnitToolTipQuirkColor())); - sQuirks = UIUtil.tag("FONT", attr, sQuirks); - String fontSizeAttr = String.format("class=%s", GUIP.getUnitToolTipFontSizeMod()); - sQuirks = UIUtil.tag("span", fontSizeAttr, sQuirks); + if (!sQuirks.isEmpty()) { + String attr = String.format("FACE=Dialog COLOR=%s", UIUtil.toColorHexString(GUIP.getUnitToolTipQuirkColor())); + sQuirks = UIUtil.tag("FONT", attr, sQuirks); + String fontSizeAttr = String.format("class=%s", GUIP.getUnitToolTipFontSizeMod()); + sQuirks = UIUtil.tag("span", fontSizeAttr, sQuirks); + + String col = UIUtil.tag("TD", "", sQuirks); + String row = UIUtil.tag("TR", "", col); + String tbody = UIUtil.tag("TBODY", "", row); + sQuirks = UIUtil.tag("TABLE", "CELLSPACING=0 CELLPADDING=0", tbody); + } + return sQuirks; } @@ -344,7 +354,12 @@ private static String getPartialRepairs(Entity entity, boolean details) { String attr = String.format("FACE=Dialog COLOR=%s", UIUtil.toColorHexString(GUIP.getPrecautionColor())); partialList = UIUtil.tag("FONT", attr, partialList); String fontSizeAttr = String.format("class=%s", GUIP.getUnitToolTipFontSizeMod()); - result = UIUtil.tag("span", fontSizeAttr, partialList); + partialList = UIUtil.tag("span", fontSizeAttr, partialList); + + String col = UIUtil.tag("TD", "", partialList); + String row = UIUtil.tag("TR", "", col); + String tbody = UIUtil.tag("TBODY", "", row); + result = UIUtil.tag("TABLE", "CELLSPACING=0 CELLPADDING=0", tbody); } return result; @@ -1306,8 +1321,15 @@ private static StringBuilder ecmInfo(Entity entity) { sECMInfo += ECM_SIGN + " " + msg_eccmsource; } - String fontSizeAttr = String.format("class=%s", GUIP.getUnitToolTipFontSizeMod()); - result = UIUtil.tag("span", fontSizeAttr, sECMInfo); + if (!sECMInfo.isEmpty()) { + String fontSizeAttr = String.format("class=%s", GUIP.getUnitToolTipFontSizeMod()); + sECMInfo = UIUtil.tag("span", fontSizeAttr, sECMInfo); + + String col = UIUtil.tag("TD", "", sECMInfo); + String row = UIUtil.tag("TR", "", col); + String tbody = UIUtil.tag("TBODY", "", row); + result = UIUtil.tag("TABLE", "CELLSPACING=0 CELLPADDING=0", tbody); + } return new StringBuilder().append(result); } @@ -1765,11 +1787,11 @@ private static StringBuilder inGameValues(Entity entity, Player localPlayer, boo String col = ""; String row = ""; String rows = ""; + String attr = ""; Game game = entity.getGame(); GameOptions gameOptions = game.getOptions(); PlanetaryConditions conditions = game.getPlanetaryConditions(); boolean isGunEmplacement = entity instanceof GunEmplacement; - String result = ""; String fontSizeAttr = String.format("class=%s", GUIP.getUnitToolTipFontSizeMod()); if (!inGameValue) { @@ -1782,7 +1804,7 @@ private static StringBuilder inGameValues(Entity entity, Player localPlayer, boo bvDamageLevel += " " + getDamageLevelDesc(entity, true); if (!bvDamageLevel.isEmpty()) { - String attr = String.format("FACE=Dialog COLOR=%s", UIUtil.toColorHexString((GUIP.getUnitToolTipHighlightColor()))); + attr = String.format("FACE=Dialog COLOR=%s", UIUtil.toColorHexString((GUIP.getUnitToolTipHighlightColor()))); bvDamageLevel = UIUtil.tag("FONT", attr, bvDamageLevel); bvDamageLevel = UIUtil.tag("span", fontSizeAttr, bvDamageLevel); col = UIUtil.tag("TD", "", bvDamageLevel); @@ -1810,12 +1832,14 @@ private static StringBuilder inGameValues(Entity entity, Player localPlayer, boo sFacingTwist += "  " + msg_twist + ": " + entity.getFacingName(entity.getSecondaryFacing()); } - String attr = String.format("FACE=Dialog COLOR=%s", UIUtil.toColorHexString((GUIP.getUnitToolTipHighlightColor()))); - sFacingTwist = UIUtil.tag("FONT", attr, sFacingTwist); - sFacingTwist = UIUtil.tag("span", fontSizeAttr, sFacingTwist); - col = UIUtil.tag("TD", "", sFacingTwist); - row = UIUtil.tag("TR", "", col); - rows += row; + if (!sFacingTwist.isEmpty()) { + attr = String.format("FACE=Dialog COLOR=%s", UIUtil.toColorHexString((GUIP.getUnitToolTipHighlightColor()))); + sFacingTwist = UIUtil.tag("FONT", attr, sFacingTwist); + sFacingTwist = UIUtil.tag("span", fontSizeAttr, sFacingTwist); + col = UIUtil.tag("TD", "", sFacingTwist); + row = UIUtil.tag("TR", "", col); + rows += row; + } // Heat String heatInfo = getHeatInfo(entity); @@ -1860,9 +1884,8 @@ private static StringBuilder inGameValues(Entity entity, Player localPlayer, boo } String table = UIUtil.tag("TABLE", "CELLSPACING=0 CELLPADDING=0", rows); - result = table; - return new StringBuilder().append(result); + return new StringBuilder().append(table); } /** @@ -2169,8 +2192,7 @@ private static StringBuilder deploymentWarnings(Entity entity, MapSettings mapSe sWarnings += "
" + msg_cannotsurvivespace; } - String attr = String.format("FACE=Dialog COLOR=%s", UIUtil.toColorHexString(GUIP.getWarningColor())); - result += UIUtil.tag("FONT", attr, sWarnings); + result += sWarnings; String sNoncritial = ""; // Non-critical (yellow) warnings @@ -2187,9 +2209,16 @@ private static StringBuilder deploymentWarnings(Entity entity, MapSettings mapSe sNoncritial += "
" + msg_fightersquadronempty; } - attr = String.format("FACE=Dialog COLOR=%s", UIUtil.toColorHexString(GUIP.getCautionColor())); - result += UIUtil.tag("FONT", attr, sNoncritial); - result += "
"; + result += sNoncritial; + if (!result.isEmpty()) { + String attr = String.format("FACE=Dialog COLOR=%s", UIUtil.toColorHexString(GUIP.getCautionColor())); + result += UIUtil.tag("FONT", attr, result); + + String col = UIUtil.tag("TD", "", result); + String row = UIUtil.tag("TR", "", col); + String tbody = UIUtil.tag("TBODY", "", row); + result = UIUtil.tag("TABLE", "CELLSPACING=0 CELLPADDING=0", tbody); + } return new StringBuilder().append(result); } @@ -2216,7 +2245,12 @@ private static StringBuilder carriedUnits(Entity entity) { } String fontSizeAttr = String.format("class=%s", GUIP.getUnitToolTipFontSizeMod()); - result = UIUtil.tag("span", fontSizeAttr, sCarriedUnits); + sCarriedUnits = UIUtil.tag("span", fontSizeAttr, sCarriedUnits); + + String col = UIUtil.tag("TD", "", sCarriedUnits); + String row = UIUtil.tag("TR", "", col); + String tbody = UIUtil.tag("TBODY", "", row); + result = UIUtil.tag("TABLE", "CELLSPACING=0 CELLPADDING=0", tbody); } return new StringBuilder().append(result); @@ -2224,19 +2258,25 @@ private static StringBuilder carriedUnits(Entity entity) { private static StringBuilder carriedCargo(Entity entity) { StringBuilder sb = new StringBuilder(); + String result = ""; List cargoList = entity.getDistinctCarriedObjects(); if (!cargoList.isEmpty()) { - sb.append(Messages.getString("MissionRole.cargo")); - sb.append(":
  "); + String carriedCargo = Messages.getString("MissionRole.cargo"); + carriedCargo += ":
  "; for (ICarryable cargo : entity.getDistinctCarriedObjects()) { - sb.append(cargo.toString()); - sb.append("
  "); + carriedCargo += cargo.toString(); + carriedCargo += "
  "; } + + String col = UIUtil.tag("TD", "", carriedCargo); + String row = UIUtil.tag("TR", "", col); + String tbody = UIUtil.tag("TBODY", "", row); + result = UIUtil.tag("TABLE", "CELLSPACING=0 CELLPADDING=0", tbody); } - return sb; + return sb.append(result); } @@ -2266,10 +2306,18 @@ private static StringBuilder forceEntry(Entity entity, Player localPlayer) { color = GUIP.getAllyUnitColor(); } - String attr = String.format("FACE=Dialog COLOR=%s", UIUtil.toColorHexString(color)); - sForceEntry = UIUtil.tag("FONT", attr, getForceInfo(entity)); - String fontSizeAttr = String.format("class=%s", GUIP.getUnitToolTipFontSizeMod()); - result = UIUtil.tag("span", fontSizeAttr, sForceEntry); + String force = getForceInfo(entity); + if (!force.isEmpty()) { + String attr = String.format("FACE=Dialog COLOR=%s", UIUtil.toColorHexString(color)); + sForceEntry = UIUtil.tag("FONT", attr, force); + String fontSizeAttr = String.format("class=%s", GUIP.getUnitToolTipFontSizeMod()); + sForceEntry = UIUtil.tag("span", fontSizeAttr, sForceEntry); + + String col = UIUtil.tag("TD", "", sForceEntry); + String row = UIUtil.tag("TR", "", col); + String tbody = UIUtil.tag("TBODY", "", row); + result = UIUtil.tag("TABLE", "CELLSPACING=0 CELLPADDING=0", tbody); + } } return new StringBuilder().append(result); @@ -2303,8 +2351,12 @@ private static StringBuilder c3Info(Entity entity, boolean details) { String attr = String.format("FACE=Dialog COLOR=%s", UIUtil.toColorHexString(GUIP.getUnitToolTipHighlightColor())); sC3Info = UIUtil.tag("FONT", attr, sC3Info); String fontSizeAttr = String.format("class=%s", GUIP.getUnitToolTipFontSizeMod()); - result = UIUtil.tag("span", fontSizeAttr, sC3Info); + sC3Info = UIUtil.tag("span", fontSizeAttr, sC3Info); + String col = UIUtil.tag("TD", "", sC3Info); + String row = UIUtil.tag("TR", "", col); + String tbody = UIUtil.tag("TBODY", "", row); + result = UIUtil.tag("TABLE", "CELLSPACING=0 CELLPADDING=0", tbody); } return new StringBuilder().append(result); diff --git a/megamek/src/megamek/client/ui/swing/unitDisplay/SummaryPanel.java b/megamek/src/megamek/client/ui/swing/unitDisplay/SummaryPanel.java index e8d3382425..6cecbd8919 100644 --- a/megamek/src/megamek/client/ui/swing/unitDisplay/SummaryPanel.java +++ b/megamek/src/megamek/client/ui/swing/unitDisplay/SummaryPanel.java @@ -156,7 +156,6 @@ public void displayMek(Entity entity) { rows += row; String unitTip = UnitToolTip.getEntityTipUnitDisplay(entity, localPlayer).toString(); - unitTip = UnitToolTip.addPlayerColorBoarder(GUIP, entity, unitTip); col = UIUtil.tag("TD", "", unitTip); row = UIUtil.tag("TR", "", col); rows += row; diff --git a/megamek/src/megamek/client/ui/swing/unitDisplay/WeaponPanel.java b/megamek/src/megamek/client/ui/swing/unitDisplay/WeaponPanel.java index 62d7b9a71f..a4244c3639 100644 --- a/megamek/src/megamek/client/ui/swing/unitDisplay/WeaponPanel.java +++ b/megamek/src/megamek/client/ui/swing/unitDisplay/WeaponPanel.java @@ -984,9 +984,6 @@ private void updateTargetInfo() { txt = Messages.getString("MekDisplay.NoTarget"); } else { txt = UnitToolTip.getTargetTipDetail(target, client); - if (target instanceof Entity targetEntity) { - txt = UnitToolTip.addPlayerColorBoarder(GUIP, targetEntity, txt); - } } wTargetInfo.setText(UnitToolTip.wrapWithHTML(txt)); diff --git a/megamek/src/megamek/client/ui/swing/util/UIUtil.java b/megamek/src/megamek/client/ui/swing/util/UIUtil.java index 5baacea723..889c83cee9 100644 --- a/megamek/src/megamek/client/ui/swing/util/UIUtil.java +++ b/megamek/src/megamek/client/ui/swing/util/UIUtil.java @@ -110,8 +110,9 @@ public static String fontHTML(float deltaScale) { * Returns an HTML - tag attribute text end tag */ public static String tag(String tag, String attributes, String text) { - String format = attributes.isEmpty() ? "<%s>%s" : "<%s %s>%s"; - String result = attributes.isEmpty() ? String.format(format, tag, text, tag) : String.format(format, tag, attributes, text, tag); + attributes = attributes.isEmpty() ? attributes : ' ' + attributes; + String format = "<%s%s>%s"; + String result = String.format(format, tag, attributes, text, tag); return result; }