From 1a5f47481bcd6d655e788b19e28bd55d31a3202a Mon Sep 17 00:00:00 2001 From: kuronekochomusuke Date: Thu, 10 Oct 2024 19:00:33 -0400 Subject: [PATCH 1/3] remove hardcoded html font size --- .../ForceDisplayMekCellFormatter.java | 24 +++--- .../ui/swing/lobby/LobbyMekCellFormatter.java | 31 ++++---- .../client/ui/swing/lobby/MekTableModel.java | 7 +- .../ui/swing/lobby/TeamOverviewPanel.java | 19 +++-- .../client/ui/swing/tooltip/PilotToolTip.java | 3 +- .../client/ui/swing/tooltip/UnitToolTip.java | 79 +++++++++++-------- .../megamek/client/ui/swing/util/UIUtil.java | 9 --- megamek/src/megamek/common/Report.java | 3 + 8 files changed, 90 insertions(+), 85 deletions(-) diff --git a/megamek/src/megamek/client/ui/swing/forceDisplay/ForceDisplayMekCellFormatter.java b/megamek/src/megamek/client/ui/swing/forceDisplay/ForceDisplayMekCellFormatter.java index 8230702519..c2d4884d51 100644 --- a/megamek/src/megamek/client/ui/swing/forceDisplay/ForceDisplayMekCellFormatter.java +++ b/megamek/src/megamek/client/ui/swing/forceDisplay/ForceDisplayMekCellFormatter.java @@ -171,14 +171,14 @@ static String formatUnitCompact(Entity entity, ClientGUI clientGUI) { // ECM if (entity.hasActiveECM()) { firstEntry = dotSpacerOnlyFirst(result, firstEntry); - result.append(fontHTML(GUIP.getUnitToolTipHighlightColor(), 0.2f) + ECM_SIGN + ""); + result.append(fontHTML(GUIP.getUnitToolTipHighlightColor()) + ECM_SIGN + ""); } // Quirk Count int quirkCount = entity.countQuirks() + entity.countWeaponQuirks(); if (quirkCount > 0) { firstEntry = dotSpacerOnlyFirst(result, firstEntry); - result.append(fontHTML(GUIP.getUnitToolTipQuirkColor(), 0.2f) + QUIRKS_SIGN + ""); + result.append(fontHTML(GUIP.getUnitToolTipHighlightColor()) + QUIRKS_SIGN + ""); } // C3 ... @@ -300,10 +300,10 @@ static String formatUnitCompact(Entity entity, ClientGUI clientGUI) { * for the compact display mode. Assumes that no enemy or blind-drop-hidden units are provided. */ static String formatForceCompact(Force force, ClientGUI clientGUI) { - return formatForce(force, clientGUI, 0); + return formatForce(force, clientGUI); } - private static String formatForce(Force force, ClientGUI clientGUI, float size) { + private static String formatForce(Force force, ClientGUI clientGUI) { Client client = clientGUI.getClient(); Game game = client.getGame(); Player localPlayer = client.getLocalPlayer(); @@ -327,22 +327,22 @@ private static String formatForce(Force force, ClientGUI clientGUI, float size) } else { fLevel = "\u25E5   "; } - result.append(fontHTML(color, size) + fLevel + ""); + result.append(fontHTML(color) + fLevel + ""); // Name String fName = force.getName(); fName = "" + fName + ""; - result.append(fontHTML(color, size) + fName + ""); + result.append(fontHTML(color) + fName + ""); // ID String id = " [" + force.getId() + "]"; - result.append(fontHTML(GUIP.getUnitToolTipHighlightColor(), size) + id + ""); + result.append(fontHTML(GUIP.getUnitToolTipHighlightColor()) + id + ""); // Display force owner if ((ownerId != client.getLocalPlayerNumber()) && (owner != null)) { result.append(DOT_SPACER); String oName = "\u2691 " + owner.getName(); - result.append(fontHTML(color, size) + oName + ""); + result.append(fontHTML(color) + oName + ""); } // BV @@ -353,7 +353,7 @@ private static String formatForce(Force force, ClientGUI clientGUI, float size) if (totalBv > 0) { String msg_bvplain = Messages.getString("ChatLounge.BVplain"); msg_bvplain = msg_bvplain + " " + String.format("%,d", totalBv); - result.append(fontHTML(color, size) + msg_bvplain + ""); + result.append(fontHTML(color) + msg_bvplain + ""); // Unit Type long unittypes = fullEntities.stream().map(e -> Entity.getEntityMajorTypeName(e.getEntityType())).distinct().count(); @@ -361,15 +361,15 @@ private static String formatForce(Force force, ClientGUI clientGUI, float size) if (unittypes > 1) { String msg_mixed = Messages.getString("ChatLounge.Mixed"); - result.append(fontHTML(color, size) + msg_mixed + ""); + result.append(fontHTML(color) + msg_mixed + ""); } else if (unittypes == 1) { Entity entity = CollectionUtil.anyOneElement(fullEntities); String eType = UnitType.getTypeName(entity.getUnitType()); - result.append(fontHTML(color, size) + eType + ""); + result.append(fontHTML(color) + eType + ""); } } else { - result.append(fontHTML(color, size) + "Empty" + ""); + result.append(fontHTML(color) + "Empty" + ""); } return UnitToolTip.wrapWithHTML(result.toString()); diff --git a/megamek/src/megamek/client/ui/swing/lobby/LobbyMekCellFormatter.java b/megamek/src/megamek/client/ui/swing/lobby/LobbyMekCellFormatter.java index 6664937750..e99114f09a 100644 --- a/megamek/src/megamek/client/ui/swing/lobby/LobbyMekCellFormatter.java +++ b/megamek/src/megamek/client/ui/swing/lobby/LobbyMekCellFormatter.java @@ -635,7 +635,7 @@ static String formatUnitCompact(Entity entity, ChatLounge lobby, boolean forceVi // ECM if (entity.hasActiveECM()) { - result.append(fontHTML(uiC3Color(), 0.2f)); + result.append(fontHTML(uiC3Color())); result.append(ECM_SIGN); result.append(""); } @@ -643,7 +643,7 @@ static String formatUnitCompact(Entity entity, ChatLounge lobby, boolean forceVi // Quirk Count int quirkCount = entity.countQuirks() + entity.countWeaponQuirks(); if (quirkCount > 0) { - result.append(fontHTML(uiQuirksColor(), 0.2f)); + result.append(fontHTML(uiQuirksColor())); result.append(QUIRKS_SIGN); result.append(""); } @@ -770,7 +770,7 @@ static String formatUnitCompact(Entity entity, ChatLounge lobby, boolean forceVi // Info tooltip sign if (forceView) { - result.append(fontHTML(uiGreen(), 0.3f)); + result.append(fontHTML(uiGreen())); result.append("  \u24D8"); } @@ -805,7 +805,7 @@ static String formatUnitCompact(Entity entity, ChatLounge lobby, boolean forceVi * units are provided. */ static String formatForceCompact(Force force, ChatLounge lobby) { - return formatForce(force, lobby, 0); + return formatForce(force, lobby); } /** @@ -815,10 +815,10 @@ static String formatForceCompact(Force force, ChatLounge lobby) { * units are provided. */ static String formatForceFull(Force force, ChatLounge lobby) { - return formatForce(force, lobby, 0.2f); + return formatForce(force, lobby); } - private static String formatForce(Force force, ChatLounge lobby, float size) { + private static String formatForce(Force force, ChatLounge lobby) { Client client = lobby.getClientgui().getClient(); Game game = client.getGame(); Player localPlayer = client.getLocalPlayer(); @@ -835,7 +835,7 @@ private static String formatForce(Force force, ChatLounge lobby, float size) { color = addGray(color, 128).brighter(); StringBuilder result = new StringBuilder(""); - result.append(fontHTML(color, size)); + result.append(fontHTML(color)); // A top-level / subforce special char if (force.isTopLevel()) { @@ -849,24 +849,24 @@ private static String formatForce(Force force, ChatLounge lobby, float size) { // ID if (PreferenceManager.getClientPreferences().getShowUnitId()) { - result.append(fontHTML(uiGray(), size)); + result.append(fontHTML(uiGray())); result.append(" [").append(force.getId()).append("]"); } // Display force owner if ((ownerId != client.getLocalPlayerNumber()) && (owner != null)) { - result.append(fontHTML(size)); + result.append(fontHTML()); result.append(DOT_SPACER).append(""); PlayerColour ownerColour = (owner.getColour() == null) ? PlayerColour.FIRE_BRICK : owner.getColour(); - result.append(fontHTML(ownerColour.getColour(), size)); + result.append(fontHTML(ownerColour.getColour())); result.append("\u2691 "); result.append(owner.getName()).append(""); } // BV List fullEntities = ForceAssignable.filterToEntityList(lobby.game().getForces().getFullEntities(force)); - result.append(fontHTML(color, size)); + result.append(fontHTML(color)); result.append(DOT_SPACER); int totalBv = fullEntities.stream().filter(e -> !e.isPartOfFighterSquadron()) .mapToInt(Entity::calculateBattleValue).sum(); @@ -876,7 +876,7 @@ private static String formatForce(Force force, ChatLounge lobby, float size) { // Unit Type long unittypes = fullEntities.stream().map(e -> Entity.getEntityMajorTypeName(e.getEntityType())).distinct() .count(); - result.append(fontHTML(color, size)); + result.append(fontHTML(color)); result.append(DOT_SPACER); if (unittypes > 1) { String msg_mixed = Messages.getString("ChatLounge.Mixed"); @@ -943,9 +943,8 @@ static String formatPilotFull(Entity entity, boolean blindDrop) { final Crew crew = entity.getCrew(); final GameOptions options = entity.getGame().getOptions(); final boolean rpgSkills = options.booleanOption(OptionsConstants.RPG_RPG_GUNNERY); - final float overallScale = 0f; - result.append(fontHTML(overallScale)); + result.append(fontHTML()); if (blindDrop) { result.append("" + Messages.getString("ChatLounge.Unknown") + ""); @@ -957,7 +956,7 @@ static String formatPilotFull(Entity entity, boolean blindDrop) { result.append("No " + crew.getCrewType().getRoleName(0) + ""); } else { if ((crew.getNickname(0) != null) && !crew.getNickname(0).isEmpty()) { - result.append(fontHTML(uiNickColor(), overallScale)); + result.append(fontHTML(uiNickColor())); result.append("'" + crew.getNickname(0).toUpperCase() + "'"); } else { result.append("" + crew.getDesc(0) + ""); @@ -973,7 +972,7 @@ static String formatPilotFull(Entity entity, boolean blindDrop) { // Advantages, MD, Edge if ((crew.countOptions(LVL3_ADVANTAGES) > 0) || (crew.countOptions(MD_ADVANTAGES) > 0)) { - result.append(fontHTML(uiQuirksColor(), overallScale)); + result.append(fontHTML(uiQuirksColor())); result.append(Messages.getString("ChatLounge.abilities")); result.append(""); } diff --git a/megamek/src/megamek/client/ui/swing/lobby/MekTableModel.java b/megamek/src/megamek/client/ui/swing/lobby/MekTableModel.java index 6427000ca3..aab113c7db 100644 --- a/megamek/src/megamek/client/ui/swing/lobby/MekTableModel.java +++ b/megamek/src/megamek/client/ui/swing/lobby/MekTableModel.java @@ -273,11 +273,10 @@ private String playerCellContent(final InGameObject entity) { StringBuilder result = new StringBuilder(""); Player owner = ownerOf(entity); boolean isEnemy = clientGui.getClient().getLocalPlayer().isEnemyOf(owner); - float size = chatLounge.isCompact() ? 0 : 0.2f; String sep = chatLounge.isCompact() ? DOT_SPACER : "
"; - result.append(UIUtil.fontHTML(owner.getColour().getColour(), size)).append(owner.getName()) - .append("").append(fontHTML(size)).append(sep).append("") - .append(UIUtil.fontHTML(isEnemy ? Color.RED : uiGreen(), size)) + result.append(UIUtil.fontHTML(owner.getColour().getColour())).append(owner.getName()) + .append("").append(fontHTML()).append(sep).append("") + .append(UIUtil.fontHTML(isEnemy ? Color.RED : uiGreen())) .append(Player.TEAM_NAMES[owner.getTeam()]); return result.toString(); } diff --git a/megamek/src/megamek/client/ui/swing/lobby/TeamOverviewPanel.java b/megamek/src/megamek/client/ui/swing/lobby/TeamOverviewPanel.java index 0faf5c9680..c119e174b0 100644 --- a/megamek/src/megamek/client/ui/swing/lobby/TeamOverviewPanel.java +++ b/megamek/src/megamek/client/ui/swing/lobby/TeamOverviewPanel.java @@ -331,7 +331,6 @@ public Class getColumnClass(int c) { @Override public Object getValueAt(int row, int col) { - float textSizeDelta = isDetached ? -0.1f : 0.2f; StringBuilder result = new StringBuilder("
"); TOMCOLS column = TOMCOLS.values()[col]; switch (column) { @@ -339,12 +338,12 @@ public Object getValueAt(int row, int col) { boolean isEnemy = !teams.get(row).players().contains(clientGui.getClient().getLocalPlayer()); Color color = isEnemy ? GUIPreferences.getInstance().getEnemyUnitColor() : GUIPreferences.getInstance().getMyUnitColor(); - result.append(UIUtil.fontHTML(color, textSizeDelta) + " "); + result.append(UIUtil.fontHTML(color) + " "); result.append(teamNames.get(row) + ""); break; case TONNAGE: - result.append(fontHTML(textSizeDelta) + "
"); + result.append(fontHTML() + "
"); double ton = (double) tons.get(row) / 1000; if (ton < 10) { result.append(String.format("%.2f", ton) + " Tons"); @@ -355,7 +354,7 @@ public Object getValueAt(int row, int col) { break; case COST: - result.append(fontHTML(textSizeDelta) + "
"); + result.append(fontHTML() + "
"); if (costs.get(row) < 10_000_000) { result.append(String.format("%,d", costs.get(row)) + " C-Bills"); } else { @@ -368,21 +367,21 @@ public Object getValueAt(int row, int col) { return teams.get(row).players(); case BV: - result.append(fontHTML(textSizeDelta) + "
"); + result.append(fontHTML() + "
"); result.append(NumberFormat.getIntegerInstance().format(bvs.get(row))); result.append(relativeValue(bvs, row)); break; case UNITS: if (!seeTeam(row)) { - return "" + UIUtil.fontHTML(UIUtil.uiGray(), textSizeDelta - 0.1f) + "Unavailable"; + return "" + UIUtil.fontHTML(UIUtil.uiGray()) + "Unavailable"; } - result.append(fontHTML(textSizeDelta - 0.1f)); + result.append(fontHTML()); result.append(units.get(row)); break; case HIDDEN: - result.append(fontHTML(textSizeDelta) + "
"); + result.append(fontHTML() + "
"); var percentage = hidden.get(row); result.append(percentage == 0 ? "--" : NumberFormat.getPercentInstance().format(percentage)); @@ -416,10 +415,10 @@ private String relativeValue(ArrayList values, int row) { String selectedTeam = teamNames.get(selectedRow); long percentage = 100 * values.get(row) / baseValue; if (isDetached) { - return "
" + UIUtil.fontHTML(UIUtil.uiGray(), -0.1f) + return "
" + UIUtil.fontHTML(UIUtil.uiGray()) + String.format("(%d %%)", percentage); } else { - return "
" + UIUtil.fontHTML(UIUtil.uiGray(), -0.1f) + return "
" + UIUtil.fontHTML(UIUtil.uiGray()) + String.format("(%d %% of %s)", percentage, selectedTeam); } } diff --git a/megamek/src/megamek/client/ui/swing/tooltip/PilotToolTip.java b/megamek/src/megamek/client/ui/swing/tooltip/PilotToolTip.java index 7f62d534e0..30fada8bd5 100644 --- a/megamek/src/megamek/client/ui/swing/tooltip/PilotToolTip.java +++ b/megamek/src/megamek/client/ui/swing/tooltip/PilotToolTip.java @@ -246,7 +246,8 @@ private static StringBuilder crewAdvs(final Entity entity, boolean detailed) { String sOptionList = ""; Crew crew = entity.getCrew(); sOptionList = getOptionList(crew.getOptions().getGroups(), crew::countOptions, detailed); - result = UIUtil.fontHTML(uiQuirksColor(), UnitToolTip.TT_SMALLFONT_DELTA) + sOptionList + ""; + sOptionList = UIUtil.fontHTML(uiQuirksColor()) + sOptionList + ""; + result = "" + 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 bca3bfb1eb..2a28b3c97e 100644 --- a/megamek/src/megamek/client/ui/swing/tooltip/UnitToolTip.java +++ b/megamek/src/megamek/client/ui/swing/tooltip/UnitToolTip.java @@ -51,8 +51,6 @@ public final class UnitToolTip { private static final MMLogger logger = MMLogger.create(UnitToolTip.class); - /** The font size reduction for Quirks */ - final static float TT_SMALLFONT_DELTA = -0.2f; private static final GUIPreferences GUIP = GUIPreferences.getInstance(); public static StringBuilder lobbyTip(InGameObject unit, Player localPlayer, MapSettings mapSettings) { @@ -280,7 +278,8 @@ private static String getQuirks(Entity entity, Game game, boolean details) { } } - return UIUtil.fontHTML(GUIP.getUnitToolTipQuirkColor(), TT_SMALLFONT_DELTA) + sQuirks + ""; + sQuirks = UIUtil.fontHTML(GUIP.getUnitToolTipQuirkColor()) + sQuirks + ""; + return "" + sQuirks + ""; } return ""; @@ -292,7 +291,8 @@ private static String getPartialRepairs(Entity entity, boolean details) { grp -> entity.countPartialRepairs(), details); if (!partialList.isEmpty()) { - result += UIUtil.fontHTML(GUIP.getPrecautionColor(), TT_SMALLFONT_DELTA) + partialList + ""; + partialList = UIUtil.fontHTML(GUIP.getPrecautionColor()) + partialList + ""; + result += "" + partialList + ""; } return result; @@ -311,7 +311,7 @@ private static String locationHeader(Entity entity, int location) { } private static StringBuilder sysCrits(Entity entity, int type, int index, int loc, String locAbbr) { - String result = ""; + String result = "" + " " + "";; int total = entity.getNumberOfCriticals(type, index, loc); int hits = entity.getHitCriticals(type, index, loc); int good = total - hits; @@ -319,7 +319,7 @@ private static StringBuilder sysCrits(Entity entity, int type, int index, int lo if ((good + hits) > 0) { locAbbr = "  " + locAbbr + ": "; - result = fontHTML(TT_SMALLFONT_DELTA) + locAbbr + ""; + result = "" + locAbbr + ""; result += systemBar(good, hits, bad); } @@ -334,7 +334,7 @@ private static StringBuilder sysStabilizers(Tank tank, int loc, String locAbbr) boolean bad = hits > 0; locAbbr = "  " + locAbbr + ": "; - result = fontHTML(TT_SMALLFONT_DELTA) + locAbbr + ""; + result = "" + locAbbr + ""; result += systemBar(good, hits, bad); return new StringBuilder().append(result); @@ -348,7 +348,7 @@ private static StringBuilder sysTurretLocked(Tank tank, int loc, String locAbbr) boolean bad = hits > 0; locAbbr = "  " + locAbbr + ": "; - result = fontHTML(TT_SMALLFONT_DELTA) + locAbbr + ""; + result = "" + locAbbr + ""; result += systemBar(good, hits, bad); return new StringBuilder().append(result); @@ -362,7 +362,7 @@ private static StringBuilder sysEngineHit(Tank tank, String locAbbr) { boolean bad = hits > 0; locAbbr = "  " + locAbbr + ": "; - result = fontHTML(TT_SMALLFONT_DELTA) + locAbbr + ""; + result = "" + locAbbr + ""; result += systemBar(good, hits, bad); return new StringBuilder().append(result); @@ -376,7 +376,7 @@ private static StringBuilder sysSensorHit(Tank tank, String locAbbr) { boolean bad = hits > 0; locAbbr = "  " + locAbbr + ": "; - result = fontHTML(TT_SMALLFONT_DELTA) + locAbbr + ""; + result = "" + locAbbr + ""; result += systemBar(good, hits, bad); return new StringBuilder().append(result); @@ -390,7 +390,7 @@ private static StringBuilder sysMinorMovementDamage(Tank tank, String locAbbr) { boolean bad = hits > 0; locAbbr = "  " + locAbbr + ": "; - result = fontHTML(TT_SMALLFONT_DELTA) + locAbbr + ""; + result = "" + locAbbr + ""; result += systemBar(good, hits, bad); return new StringBuilder().append(result); @@ -404,7 +404,7 @@ private static StringBuilder sysModerateMovementDamage(Tank tank, String locAbbr boolean bad = hits > 0; locAbbr = "  " + locAbbr + ": "; - result = fontHTML(TT_SMALLFONT_DELTA) + locAbbr + ""; + result = "" + locAbbr + ""; result += systemBar(good, hits, bad); return new StringBuilder().append(result); @@ -418,7 +418,7 @@ private static StringBuilder sysHeavyMovementDamage(Tank tank, String locAbbr) { boolean bad = hits > 0; locAbbr = "  " + locAbbr + ": "; - result = fontHTML(TT_SMALLFONT_DELTA) + locAbbr + ""; + result = "" + locAbbr + ""; result += systemBar(good, hits, bad); return new StringBuilder().append(result); @@ -474,24 +474,24 @@ private static StringBuilder addArmorMiniVisToTT(Entity entity) { // Destroyed location col1 = ""; String sLocHeader = "  " + locationHeader(entity, loc) + ": "; - col2 = fontHTML(TT_SMALLFONT_DELTA) + sLocHeader + ""; + col2 = "" + sLocHeader + ""; col2 += destroyedLocBar(entity.getOArmor(loc, true)).toString(); } else { // Rear armor if (entity.hasRearArmor(loc)) { String msg_abbr_rear = Messages.getString("BoardView1.Tooltip.AbbreviationRear"); String sLocHeader = "  " + locationHeader(entity, loc) + msg_abbr_rear + " "; - col1 = fontHTML(TT_SMALLFONT_DELTA) + sLocHeader + ""; + col1 = "" + sLocHeader + ""; 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 - col1 = fontHTML(TT_SMALLFONT_DELTA) + " " + ""; + col1 = "" + " " + ""; } // Front armor String sLocHeader = "  " + locationHeader(entity, loc) + ": "; - col2 = fontHTML(TT_SMALLFONT_DELTA) + sLocHeader + ""; + col2 = "" + sLocHeader + ""; col2 += intactLocBar(entity.getOInternal(loc), entity.getInternal(loc), internalChar).toString(); col2 += intactLocBar(entity.getOArmor(loc), entity.getArmor(loc), armorChar).toString(); } @@ -553,7 +553,7 @@ private static StringBuilder addArmorMiniVisToTT(Entity entity) { .toString(); break; default: - col3 = ""; + col3 = "" + " " + ""; } } else if (entity instanceof SuperHeavyTank || entity instanceof LargeSupportTank) { Tank tank = (Tank) entity; @@ -575,7 +575,7 @@ private static StringBuilder addArmorMiniVisToTT(Entity entity) { : ""; break; default: - col3 = ""; + col3 = "" + " " + ""; } } else if (entity instanceof Tank) { Tank tank = (Tank) entity; @@ -595,7 +595,7 @@ private static StringBuilder addArmorMiniVisToTT(Entity entity) { : ""; break; default: - col3 = ""; + col3 = "" + " " + ""; } } @@ -711,15 +711,18 @@ private static StringBuilder locBar(int orig, int curr, String dChar, boolean de String msg_x = Messages.getString("BoardView1.Tooltip.X"); String sIntact = dChar + msg_x + tensIntact * 10; sIntact += repeat(dChar, numIntact - 10 * tensIntact); - result += UIUtil.fontHTML(colorIntact, TT_SMALLFONT_DELTA) + sIntact + ""; + sIntact = UIUtil.fontHTML(colorIntact) + sIntact + ""; + result += "" + sIntact + ""; } else { String sIntact = repeat(dChar, numIntact); - result += UIUtil.fontHTML(colorIntact, TT_SMALLFONT_DELTA) + sIntact + ""; + sIntact = UIUtil.fontHTML(colorIntact) + sIntact + ""; + result += "" + sIntact + ""; } } if (numPartial > 0) { String sPartial = repeat(dChar, numPartial); - result += UIUtil.fontHTML(colorPartialDmg, TT_SMALLFONT_DELTA) + sPartial + ""; + sPartial = UIUtil.fontHTML(colorPartialDmg) + sPartial + ""; + result += "" + sPartial + ""; } if (numDmgd > 0) { if (numDmgd > 15 && numIntact + numDmgd > 30) { @@ -727,10 +730,12 @@ private static StringBuilder locBar(int orig, int curr, String dChar, boolean de String msg_x = Messages.getString("BoardView1.Tooltip.X"); String sDamage = dChar + msg_x + tensDmgd * 10; sDamage += repeat(dChar, numDmgd - 10 * tensDmgd); - result += UIUtil.fontHTML(colorDamaged, TT_SMALLFONT_DELTA) + sDamage + ""; + sDamage = UIUtil.fontHTML(colorDamaged) + sDamage + ""; + result += "" + sDamage + ""; } else { String sDamage = repeat(dChar, numDmgd); - result += UIUtil.fontHTML(colorDamaged, TT_SMALLFONT_DELTA) + sDamage + ""; + sDamage = UIUtil.fontHTML(colorDamaged) + sDamage + ""; + result += "" + sDamage + ""; } } return new StringBuilder().append(result); @@ -751,15 +756,18 @@ private static StringBuilder systemBar(int good, int bad, boolean destroyed) { if (good > 0) { if (!destroyed) { String sGood = repeat(iChar, good); - result = UIUtil.fontHTML(colorIntact, TT_SMALLFONT_DELTA) + sGood + ""; + sGood = UIUtil.fontHTML(colorIntact) + sGood + ""; + result = "" + sGood + ""; } else { String sGood = repeat(iChar, good); - result = UIUtil.fontHTML(colorDamaged, TT_SMALLFONT_DELTA) + sGood + ""; + sGood = UIUtil.fontHTML(colorDamaged) + sGood + ""; + result = "" + sGood + ""; } } if (bad > 0) { String sBad = repeat(dChar, bad); - result += UIUtil.fontHTML(colorDamaged, TT_SMALLFONT_DELTA) + sBad + ""; + sBad = UIUtil.fontHTML(colorDamaged) + sBad + ""; + result += "" + sBad + ""; } return new StringBuilder().append(result); } @@ -1141,7 +1149,8 @@ private static StringBuilder createAmmoEntry(WeaponInfo ammoInfo) { String msg_outofammo = Messages.getString("BoardView1.Tooltip.OutOfAmmo"); col2 = "      " + msg_outofammo; col1 = "" + col1 + ""; - col2 = UIUtil.fontHTML(GUIP.getCautionColor(), -0.2f) + col2 + ""; + col2 = UIUtil.fontHTML(GUIP.getCautionColor()) + col2 + ""; + col2 = "" + col2 + ""; col2 = "" + col2 + ""; row = "" + col1 + col2 + ""; rows += row; @@ -1169,7 +1178,8 @@ private static StringBuilder createAmmoEntry(WeaponInfo ammoInfo) { } col1 = "" + col1 + ""; - col2 = UIUtil.fontHTML(GUIP.getCautionColor(), -0.2f) + col2 + ""; + col2 = UIUtil.fontHTML(GUIP.getCautionColor()) + col2 + ""; + col2 = "" + col2 + ""; col2 = "" + col2 + ""; row = "" + col1 + col2 + ""; rows += row; @@ -2025,7 +2035,8 @@ private static StringBuilder c3Info(Entity entity, boolean details) { sC3Info += "
"; } - result = UIUtil.fontHTML(GUIP.getUnitToolTipHighlightColor(), -0.2f) + sC3Info + ""; + sC3Info = UIUtil.fontHTML(GUIP.getUnitToolTipHighlightColor()) + sC3Info + ""; + result = "" + sC3Info + ""; } @@ -2047,13 +2058,15 @@ private static String c3UnitName(Entity c3member, Entity entity) { } sC3UnitName += "" + msg_c3 + ""; - result += UIUtil.fontHTML(GUIP.getUnitToolTipFGColor(), -0.2f) + sC3UnitName + ""; + sC3UnitName = UIUtil.fontHTML(GUIP.getUnitToolTipFGColor()) + sC3UnitName + ""; + result += "" + sC3UnitName + ""; result += c3member.getShortNameRaw(); String msg_thisunit = " (" + Messages.getString("BoardView1.Tooltip.ThisUnit") + ")"; tmp = "" + msg_thisunit + ""; String sC3Member = c3member.equals(entity) ? tmp : ""; - result += UIUtil.fontHTML(GUIP.getUnitToolTipFGColor(), -0.2f) + sC3Member + ""; + sC3Member = UIUtil.fontHTML(GUIP.getUnitToolTipFGColor()) + sC3Member + ""; + result += "" + sC3Member + ""; return result; } diff --git a/megamek/src/megamek/client/ui/swing/util/UIUtil.java b/megamek/src/megamek/client/ui/swing/util/UIUtil.java index ed681b79ed..95ff27801f 100644 --- a/megamek/src/megamek/client/ui/swing/util/UIUtil.java +++ b/megamek/src/megamek/client/ui/swing/util/UIUtil.java @@ -106,15 +106,6 @@ public static String fontHTML(float deltaScale) { return ""; } - /** - * Returns an HTML FONT tag setting the color to the given col, the font face to Dialog and the font size according to the given scale - * delta, where the font size target is standard font size * (1 + deltaScale) - */ - @Deprecated - public static String fontHTML(Color col, float deltaScale) { - return ""; - } - /** Returns the yellow and gui-scaled warning sign. */ public static String warningSign() { return fontHTML(uiYellow()) + WARNING_SIGN + ""; diff --git a/megamek/src/megamek/common/Report.java b/megamek/src/megamek/common/Report.java index 3f3d075cca..7d8b899ad1 100644 --- a/megamek/src/megamek/common/Report.java +++ b/megamek/src/megamek/common/Report.java @@ -724,6 +724,9 @@ public static void setupStylesheet(StyleSheet styleSheet) { styleSheet.addRule("span.success { color: " + hexColor(GUIP.getReportSuccessColor()) + " }"); styleSheet.addRule("span.miss { color: " + hexColor(GUIP.getReportMissColor()) + " }"); styleSheet.addRule("span.info { color: " + hexColor(GUIP.getReportInfoColor()) + " }"); + styleSheet.addRule("span.small { font-size: small; }"); + styleSheet.addRule("span.x-small { font-size: x-small; }"); + styleSheet.addRule("span.xx-small { font-size: xx-small; }"); } public String span(String name, String text) { From bc6a532a5fb97d6d2c66b73d1bf5518c2ac7fcbe Mon Sep 17 00:00:00 2001 From: kuronekochomusuke Date: Thu, 10 Oct 2024 20:11:31 -0400 Subject: [PATCH 2/3] use xx-small on more items in unittooltip --- .../client/ui/swing/tooltip/UnitToolTip.java | 20 +++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/megamek/src/megamek/client/ui/swing/tooltip/UnitToolTip.java b/megamek/src/megamek/client/ui/swing/tooltip/UnitToolTip.java index 2a28b3c97e..0f4dc65ccf 100644 --- a/megamek/src/megamek/client/ui/swing/tooltip/UnitToolTip.java +++ b/megamek/src/megamek/client/ui/swing/tooltip/UnitToolTip.java @@ -1037,7 +1037,7 @@ private static StringBuilder weaponList(Entity entity) { String msg_x = Messages.getString("BoardView1.Tooltip.X"); col1 = currentEquip.count + " " + msg_x + " "; } else { - col1 = ""; + col1 = " "; } col2 = addToTT("Weapon", false, currentEquip.count, techBase, nameStr, destStr).toString(); @@ -1046,7 +1046,7 @@ private static StringBuilder weaponList(Entity entity) { col2 = "" + col2 + ""; } } else { - col1 = ""; + col1 = " "; col2 = ""; // few weapons: list each weapon separately for (int i = 0; i < currentEquip.count; i++) { @@ -1057,12 +1057,15 @@ private static StringBuilder weaponList(Entity entity) { } col2 += "
"; } + col2 = col2.substring(1, col2.length() - 4); } ; col1 = UIUtil.fontHTML(GUIP.getUnitToolTipWeaponColor()) + col1 + "
"; + col1 = "" + col1 + ""; col1 = "" + col1 + ""; col2 = UIUtil.fontHTML(GUIP.getUnitToolTipWeaponColor()) + col2 + ""; + col2 = "" + col2 + ""; col2 = "" + col2 + ""; row = "" + col1 + col2 + ""; } @@ -1147,8 +1150,10 @@ private static StringBuilder createAmmoEntry(WeaponInfo ammoInfo) { int totalAmmo = ammoInfo.ammos.values().stream().mapToInt(n -> n).sum(); if (totalAmmo == 0 && ammoInfo.ammoActiveWeaponCount > 0) { String msg_outofammo = Messages.getString("BoardView1.Tooltip.OutOfAmmo"); - col2 = "      " + msg_outofammo; + col1 = " "; + col1 = "" + col1 + ""; col1 = "" + col1 + ""; + col2 = "      " + msg_outofammo; col2 = UIUtil.fontHTML(GUIP.getCautionColor()) + col2 + ""; col2 = "" + col2 + ""; col2 = "" + col2 + ""; @@ -1163,7 +1168,7 @@ private static StringBuilder createAmmoEntry(WeaponInfo ammoInfo) { if (ammo.getValue() == 0) { continue; } - col1 = ""; + col1 = " "; col2 = "      "; String msg_shots = Messages.getString("BoardView1.Tooltip.Shots"); if (ammoInfo.ammoActiveWeaponCount > 1) { @@ -1177,6 +1182,7 @@ private static StringBuilder createAmmoEntry(WeaponInfo ammoInfo) { col2 += ammoName + ammo.getValue() + " " + msg_shots; } + col1 = "" + col1 + ""; col1 = "" + col1 + ""; col2 = UIUtil.fontHTML(GUIP.getCautionColor()) + col2 + ""; col2 = "" + col2 + ""; @@ -1202,7 +1208,8 @@ private static StringBuilder ecmInfo(Entity entity) { sECMInfo += ECM_SIGN + " " + msg_eccmsource; } - result = UIUtil.fontHTML() + sECMInfo + ""; + sECMInfo = UIUtil.fontHTML() + sECMInfo + ""; + result = "" + sECMInfo + ""; result = UIUtil.fontHTML() + result + ""; return new StringBuilder().append(result); @@ -1959,7 +1966,8 @@ private static StringBuilder carriedUnits(Entity entity) { } } - result = UIUtil.fontHTML() + sCarriedUnits + ""; + sCarriedUnits = UIUtil.fontHTML() + sCarriedUnits + ""; + result = "" + sCarriedUnits + ""; } return new StringBuilder().append(result); From ad8cb63976086066dcfaf679a6ed2dbc70a39d41 Mon Sep 17 00:00:00 2001 From: kuronekochomusuke Date: Thu, 10 Oct 2024 20:47:44 -0400 Subject: [PATCH 3/3] use xx-small on even more items in unittooltip --- .../client/ui/swing/tooltip/UnitToolTip.java | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/megamek/src/megamek/client/ui/swing/tooltip/UnitToolTip.java b/megamek/src/megamek/client/ui/swing/tooltip/UnitToolTip.java index 0f4dc65ccf..c8b0784e1e 100644 --- a/megamek/src/megamek/client/ui/swing/tooltip/UnitToolTip.java +++ b/megamek/src/megamek/client/ui/swing/tooltip/UnitToolTip.java @@ -1600,12 +1600,14 @@ private static StringBuilder inGameValues(Entity entity, Player localPlayer, boo if (tempList.length() > 1) { tempList.delete(tempList.length() - 2, tempList.length()); String sSeenBy = addToTT("SeenBy", BR, tempList.toString()).toString(); - result += UIUtil.fontHTML() + sSeenBy + ""; + sSeenBy = UIUtil.fontHTML() + sSeenBy + ""; + result += "" + sSeenBy + ""; } } } if (showSensors) { + String sensors = ""; // If sensors, display what sensors this unit is using if (gameOptions.booleanOption(OptionsConstants.ADVANCED_TACOPS_SENSORS) || (gameOptions.booleanOption(OptionsConstants.ADVAERORULES_STRATOPS_ADVANCED_SENSORS)) @@ -1614,17 +1616,18 @@ private static StringBuilder inGameValues(Entity entity, Player localPlayer, boo if (conditions.getLight().isDuskOrFullMoonOrMoonlessOrPitchBack()) { visualRange += " (" + Compute.getMaxVisualRange(entity, true) + ")"; } - result += addToTT("Sensors", BR, getSensorDesc(entity), visualRange); + sensors += addToTT("Sensors", BR, getSensorDesc(entity), visualRange); } else { String visualRange = Compute.getMaxVisualRange(entity, false) + ""; if (conditions.getLight().isDuskOrFullMoonOrMoonlessOrPitchBack()) { visualRange += " (" + Compute.getMaxVisualRange(entity, true) + ")"; } - result += addToTT("Visual", BR, visualRange); + sensors += addToTT("Visual", BR, visualRange); } if (gameOptions.booleanOption(OptionsConstants.ADVANCED_TACOPS_BAP) && entity.hasBAP()) { - result += addToTT("BAPRange", NOBR, entity.getBAPRange()); + sensors += addToTT("BAPRange", NOBR, entity.getBAPRange()); } + result += "" + sensors + ""; } if (entity.hasAnyTypeNarcPodsAttached()) { @@ -2012,7 +2015,8 @@ private static StringBuilder forceEntry(Entity entity, Player localPlayer) { sForceEntry += forceChain.get(i).getName(); sForceEntry += i != 0 ? ", " : ""; } - result = UIUtil.fontHTML(color) + sForceEntry + ""; + sForceEntry = UIUtil.fontHTML(color) + sForceEntry + ""; + result = "" + sForceEntry + ""; } return new StringBuilder().append(result);