Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove hardcoded html font size #6085

Merged
merged 3 commits into from
Oct 11, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -171,14 +171,14 @@
// ECM
if (entity.hasActiveECM()) {
firstEntry = dotSpacerOnlyFirst(result, firstEntry);
result.append(fontHTML(GUIP.getUnitToolTipHighlightColor(), 0.2f) + ECM_SIGN + "</FONT>");
result.append(fontHTML(GUIP.getUnitToolTipHighlightColor()) + ECM_SIGN + "</FONT>");

Check notice

Code scanning / CodeQL

Deprecated method or constructor invocation Note

Invoking
UIUtil.fontHTML
should be avoided because it has been deprecated.
}

// Quirk Count
int quirkCount = entity.countQuirks() + entity.countWeaponQuirks();
if (quirkCount > 0) {
firstEntry = dotSpacerOnlyFirst(result, firstEntry);
result.append(fontHTML(GUIP.getUnitToolTipQuirkColor(), 0.2f) + QUIRKS_SIGN + "</FONT>");
result.append(fontHTML(GUIP.getUnitToolTipHighlightColor()) + QUIRKS_SIGN + "</FONT>");

Check notice

Code scanning / CodeQL

Deprecated method or constructor invocation Note

Invoking
UIUtil.fontHTML
should be avoided because it has been deprecated.
}

// C3 ...
Expand Down Expand Up @@ -300,10 +300,10 @@
* 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();
Expand All @@ -327,22 +327,22 @@
} else {
fLevel = "\u25E5&nbsp;&nbsp; ";
}
result.append(fontHTML(color, size) + fLevel + "</FONT>");
result.append(fontHTML(color) + fLevel + "</FONT>");

Check notice

Code scanning / CodeQL

Deprecated method or constructor invocation Note

Invoking
UIUtil.fontHTML
should be avoided because it has been deprecated.

// Name
String fName = force.getName();
fName = "<B>" + fName + "</B>";
result.append(fontHTML(color, size) + fName + "</FONT>");
result.append(fontHTML(color) + fName + "</FONT>");

Check notice

Code scanning / CodeQL

Deprecated method or constructor invocation Note

Invoking
UIUtil.fontHTML
should be avoided because it has been deprecated.

// ID
String id = " [" + force.getId() + "]";
result.append(fontHTML(GUIP.getUnitToolTipHighlightColor(), size) + id + "</FONT>");
result.append(fontHTML(GUIP.getUnitToolTipHighlightColor()) + id + "</FONT>");

Check notice

Code scanning / CodeQL

Deprecated method or constructor invocation Note

Invoking
UIUtil.fontHTML
should be avoided because it has been deprecated.

// Display force owner
if ((ownerId != client.getLocalPlayerNumber()) && (owner != null)) {
result.append(DOT_SPACER);
String oName = "\u2691 " + owner.getName();
result.append(fontHTML(color, size) + oName + "</FONT>");
result.append(fontHTML(color) + oName + "</FONT>");

Check notice

Code scanning / CodeQL

Deprecated method or constructor invocation Note

Invoking
UIUtil.fontHTML
should be avoided because it has been deprecated.
}

// BV
Expand All @@ -353,23 +353,23 @@
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 + "</FONT>");
result.append(fontHTML(color) + msg_bvplain + "</FONT>");

Check notice

Code scanning / CodeQL

Deprecated method or constructor invocation Note

Invoking
UIUtil.fontHTML
should be avoided because it has been deprecated.

// Unit Type
long unittypes = fullEntities.stream().map(e -> Entity.getEntityMajorTypeName(e.getEntityType())).distinct().count();
result.append(DOT_SPACER);

if (unittypes > 1) {
String msg_mixed = Messages.getString("ChatLounge.Mixed");
result.append(fontHTML(color, size) + msg_mixed + "</FONT>");
result.append(fontHTML(color) + msg_mixed + "</FONT>");

Check notice

Code scanning / CodeQL

Deprecated method or constructor invocation Note

Invoking
UIUtil.fontHTML
should be avoided because it has been deprecated.
} else if (unittypes == 1) {
Entity entity = CollectionUtil.anyOneElement(fullEntities);
String eType = UnitType.getTypeName(entity.getUnitType());
result.append(fontHTML(color, size) + eType + "</FONT>");
result.append(fontHTML(color) + eType + "</FONT>");

Check notice

Code scanning / CodeQL

Deprecated method or constructor invocation Note

Invoking
UIUtil.fontHTML
should be avoided because it has been deprecated.
}

} else {
result.append(fontHTML(color, size) + "Empty" + "</FONT>");
result.append(fontHTML(color) + "Empty" + "</FONT>");

Check notice

Code scanning / CodeQL

Deprecated method or constructor invocation Note

Invoking
UIUtil.fontHTML
should be avoided because it has been deprecated.
}

return UnitToolTip.wrapWithHTML(result.toString());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -635,15 +635,15 @@

// ECM
if (entity.hasActiveECM()) {
result.append(fontHTML(uiC3Color(), 0.2f));
result.append(fontHTML(uiC3Color()));

Check notice

Code scanning / CodeQL

Deprecated method or constructor invocation Note

Invoking
UIUtil.fontHTML
should be avoided because it has been deprecated.
result.append(ECM_SIGN);
result.append("</FONT>");
}

// Quirk Count
int quirkCount = entity.countQuirks() + entity.countWeaponQuirks();
if (quirkCount > 0) {
result.append(fontHTML(uiQuirksColor(), 0.2f));
result.append(fontHTML(uiQuirksColor()));

Check notice

Code scanning / CodeQL

Deprecated method or constructor invocation Note

Invoking
UIUtil.fontHTML
should be avoided because it has been deprecated.
result.append(QUIRKS_SIGN);
result.append("</FONT>");
}
Expand Down Expand Up @@ -770,7 +770,7 @@

// Info tooltip sign
if (forceView) {
result.append(fontHTML(uiGreen(), 0.3f));
result.append(fontHTML(uiGreen()));

Check notice

Code scanning / CodeQL

Deprecated method or constructor invocation Note

Invoking
UIUtil.fontHTML
should be avoided because it has been deprecated.
result.append("&nbsp; \u24D8");
}

Expand Down Expand Up @@ -805,7 +805,7 @@
* units are provided.
*/
static String formatForceCompact(Force force, ChatLounge lobby) {
return formatForce(force, lobby, 0);
return formatForce(force, lobby);
}

/**
Expand All @@ -815,10 +815,10 @@
* 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();
Expand All @@ -835,7 +835,7 @@
color = addGray(color, 128).brighter();

StringBuilder result = new StringBuilder("<HTML><NOBR>");
result.append(fontHTML(color, size));
result.append(fontHTML(color));

Check notice

Code scanning / CodeQL

Deprecated method or constructor invocation Note

Invoking
UIUtil.fontHTML
should be avoided because it has been deprecated.

// A top-level / subforce special char
if (force.isTopLevel()) {
Expand All @@ -849,24 +849,24 @@

// ID
if (PreferenceManager.getClientPreferences().getShowUnitId()) {
result.append(fontHTML(uiGray(), size));
result.append(fontHTML(uiGray()));

Check notice

Code scanning / CodeQL

Deprecated method or constructor invocation Note

Invoking
UIUtil.fontHTML
should be avoided because it has been deprecated.
result.append(" [").append(force.getId()).append("]</FONT>");
}

// Display force owner
if ((ownerId != client.getLocalPlayerNumber()) && (owner != null)) {
result.append(fontHTML(size));
result.append(fontHTML());

Check notice

Code scanning / CodeQL

Deprecated method or constructor invocation Note

Invoking
UIUtil.fontHTML
should be avoided because it has been deprecated.
result.append(DOT_SPACER).append("</FONT>");

PlayerColour ownerColour = (owner.getColour() == null) ? PlayerColour.FIRE_BRICK : owner.getColour();
result.append(fontHTML(ownerColour.getColour(), size));
result.append(fontHTML(ownerColour.getColour()));

Check notice

Code scanning / CodeQL

Deprecated method or constructor invocation Note

Invoking
UIUtil.fontHTML
should be avoided because it has been deprecated.
result.append("\u2691 ");
result.append(owner.getName()).append("</FONT>");
}

// BV
List<Entity> fullEntities = ForceAssignable.filterToEntityList(lobby.game().getForces().getFullEntities(force));
result.append(fontHTML(color, size));
result.append(fontHTML(color));

Check notice

Code scanning / CodeQL

Deprecated method or constructor invocation Note

Invoking
UIUtil.fontHTML
should be avoided because it has been deprecated.
result.append(DOT_SPACER);
int totalBv = fullEntities.stream().filter(e -> !e.isPartOfFighterSquadron())
.mapToInt(Entity::calculateBattleValue).sum();
Expand All @@ -876,7 +876,7 @@
// Unit Type
long unittypes = fullEntities.stream().map(e -> Entity.getEntityMajorTypeName(e.getEntityType())).distinct()
.count();
result.append(fontHTML(color, size));
result.append(fontHTML(color));

Check notice

Code scanning / CodeQL

Deprecated method or constructor invocation Note

Invoking
UIUtil.fontHTML
should be avoided because it has been deprecated.
result.append(DOT_SPACER);
if (unittypes > 1) {
String msg_mixed = Messages.getString("ChatLounge.Mixed");
Expand Down Expand Up @@ -943,9 +943,8 @@
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());

Check notice

Code scanning / CodeQL

Deprecated method or constructor invocation Note

Invoking
UIUtil.fontHTML
should be avoided because it has been deprecated.

if (blindDrop) {
result.append("<B>" + Messages.getString("ChatLounge.Unknown") + "</B>");
Expand All @@ -957,7 +956,7 @@
result.append("<B>No " + crew.getCrewType().getRoleName(0) + "</B>");
} else {
if ((crew.getNickname(0) != null) && !crew.getNickname(0).isEmpty()) {
result.append(fontHTML(uiNickColor(), overallScale));
result.append(fontHTML(uiNickColor()));

Check notice

Code scanning / CodeQL

Deprecated method or constructor invocation Note

Invoking
UIUtil.fontHTML
should be avoided because it has been deprecated.
result.append("<B>'" + crew.getNickname(0).toUpperCase() + "'</B></FONT>");
} else {
result.append("<B>" + crew.getDesc(0) + "</B>");
Expand All @@ -973,7 +972,7 @@

// Advantages, MD, Edge
if ((crew.countOptions(LVL3_ADVANTAGES) > 0) || (crew.countOptions(MD_ADVANTAGES) > 0)) {
result.append(fontHTML(uiQuirksColor(), overallScale));
result.append(fontHTML(uiQuirksColor()));

Check notice

Code scanning / CodeQL

Deprecated method or constructor invocation Note

Invoking
UIUtil.fontHTML
should be avoided because it has been deprecated.
result.append(Messages.getString("ChatLounge.abilities"));
result.append("</FONT>");
}
Expand Down
7 changes: 3 additions & 4 deletions megamek/src/megamek/client/ui/swing/lobby/MekTableModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -273,11 +273,10 @@
StringBuilder result = new StringBuilder("<HTML><NOBR>");
Player owner = ownerOf(entity);
boolean isEnemy = clientGui.getClient().getLocalPlayer().isEnemyOf(owner);
float size = chatLounge.isCompact() ? 0 : 0.2f;
String sep = chatLounge.isCompact() ? DOT_SPACER : "<BR>";
result.append(UIUtil.fontHTML(owner.getColour().getColour(), size)).append(owner.getName())
.append("</FONT>").append(fontHTML(size)).append(sep).append("</FONT>")
.append(UIUtil.fontHTML(isEnemy ? Color.RED : uiGreen(), size))
result.append(UIUtil.fontHTML(owner.getColour().getColour())).append(owner.getName())

Check notice

Code scanning / CodeQL

Deprecated method or constructor invocation Note

Invoking
UIUtil.fontHTML
should be avoided because it has been deprecated.
.append("</FONT>").append(fontHTML()).append(sep).append("</FONT>")

Check notice

Code scanning / CodeQL

Deprecated method or constructor invocation Note

Invoking
UIUtil.fontHTML
should be avoided because it has been deprecated.
.append(UIUtil.fontHTML(isEnemy ? Color.RED : uiGreen()))

Check notice

Code scanning / CodeQL

Deprecated method or constructor invocation Note

Invoking
UIUtil.fontHTML
should be avoided because it has been deprecated.
.append(Player.TEAM_NAMES[owner.getTeam()]);
return result.toString();
}
Expand Down
19 changes: 9 additions & 10 deletions megamek/src/megamek/client/ui/swing/lobby/TeamOverviewPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -331,20 +331,19 @@

@Override
public Object getValueAt(int row, int col) {
float textSizeDelta = isDetached ? -0.1f : 0.2f;
StringBuilder result = new StringBuilder("<HTML><NOBR>");
TOMCOLS column = TOMCOLS.values()[col];
switch (column) {
case TEAM:
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) + "&nbsp;");
result.append(UIUtil.fontHTML(color) + "&nbsp;");

Check notice

Code scanning / CodeQL

Deprecated method or constructor invocation Note

Invoking
UIUtil.fontHTML
should be avoided because it has been deprecated.
result.append(teamNames.get(row) + "</FONT>");
break;

case TONNAGE:
result.append(fontHTML(textSizeDelta) + "<CENTER>");
result.append(fontHTML() + "<CENTER>");

Check notice

Code scanning / CodeQL

Deprecated method or constructor invocation Note

Invoking
UIUtil.fontHTML
should be avoided because it has been deprecated.
double ton = (double) tons.get(row) / 1000;
if (ton < 10) {
result.append(String.format("%.2f", ton) + " Tons");
Expand All @@ -355,7 +354,7 @@
break;

case COST:
result.append(fontHTML(textSizeDelta) + "<CENTER>");
result.append(fontHTML() + "<CENTER>");

Check notice

Code scanning / CodeQL

Deprecated method or constructor invocation Note

Invoking
UIUtil.fontHTML
should be avoided because it has been deprecated.
if (costs.get(row) < 10_000_000) {
result.append(String.format("%,d", costs.get(row)) + " C-Bills");
} else {
Expand All @@ -368,21 +367,21 @@
return teams.get(row).players();

case BV:
result.append(fontHTML(textSizeDelta) + "<CENTER>");
result.append(fontHTML() + "<CENTER>");

Check notice

Code scanning / CodeQL

Deprecated method or constructor invocation Note

Invoking
UIUtil.fontHTML
should be avoided because it has been deprecated.
result.append(NumberFormat.getIntegerInstance().format(bvs.get(row)));
result.append(relativeValue(bvs, row));
break;

case UNITS:
if (!seeTeam(row)) {
return "<HTML>" + UIUtil.fontHTML(UIUtil.uiGray(), textSizeDelta - 0.1f) + "Unavailable";
return "<HTML>" + UIUtil.fontHTML(UIUtil.uiGray()) + "Unavailable";

Check notice

Code scanning / CodeQL

Deprecated method or constructor invocation Note

Invoking
UIUtil.fontHTML
should be avoided because it has been deprecated.
}
result.append(fontHTML(textSizeDelta - 0.1f));
result.append(fontHTML());

Check notice

Code scanning / CodeQL

Deprecated method or constructor invocation Note

Invoking
UIUtil.fontHTML
should be avoided because it has been deprecated.
result.append(units.get(row));
break;

case HIDDEN:
result.append(fontHTML(textSizeDelta) + "<CENTER>");
result.append(fontHTML() + "<CENTER>");

Check notice

Code scanning / CodeQL

Deprecated method or constructor invocation Note

Invoking
UIUtil.fontHTML
should be avoided because it has been deprecated.
var percentage = hidden.get(row);
result.append(percentage == 0 ? "--" : NumberFormat.getPercentInstance().format(percentage));

Expand Down Expand Up @@ -416,10 +415,10 @@
String selectedTeam = teamNames.get(selectedRow);
long percentage = 100 * values.get(row) / baseValue;
if (isDetached) {
return "<BR>" + UIUtil.fontHTML(UIUtil.uiGray(), -0.1f)
return "<BR>" + UIUtil.fontHTML(UIUtil.uiGray())

Check notice

Code scanning / CodeQL

Deprecated method or constructor invocation Note

Invoking
UIUtil.fontHTML
should be avoided because it has been deprecated.
+ String.format("(%d %%)", percentage);
} else {
return "<BR>" + UIUtil.fontHTML(UIUtil.uiGray(), -0.1f)
return "<BR>" + UIUtil.fontHTML(UIUtil.uiGray())

Check notice

Code scanning / CodeQL

Deprecated method or constructor invocation Note

Invoking
UIUtil.fontHTML
should be avoided because it has been deprecated.
+ String.format("(%d %% of %s)", percentage, selectedTeam);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,8 @@
String sOptionList = "";
Crew crew = entity.getCrew();
sOptionList = getOptionList(crew.getOptions().getGroups(), crew::countOptions, detailed);
result = UIUtil.fontHTML(uiQuirksColor(), UnitToolTip.TT_SMALLFONT_DELTA) + sOptionList + "</FONT>";
sOptionList = UIUtil.fontHTML(uiQuirksColor()) + sOptionList + "</FONT>";

Check notice

Code scanning / CodeQL

Deprecated method or constructor invocation Note

Invoking
UIUtil.fontHTML
should be avoided because it has been deprecated.
result = "<span class=xx-small>" + sOptionList + "</span>";

return new StringBuilder().append(result);
}
Expand Down
Loading