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

add unittooltip font size scaling #6098

Merged
merged 7 commits into from
Oct 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 2 additions & 2 deletions megamek/i18n/megamek/client/messages.properties
Original file line number Diff line number Diff line change
Expand Up @@ -1139,8 +1139,6 @@ CommonSettingsDialog.armorMiniCriticalChar.tooltip=The character representing bl
CommonSettingsDialog.armorMiniCriticalChar=Critical Character:
CommonSettingsDialog.armorMiniDestroyedChar.tooltip=The character representing a destroyed component when hovering the mouse over a unit.
CommonSettingsDialog.armorMiniDestroyedChar=Destroyed Character:
CommonSettingsDialog.armorMiniFontSizeMod.tooltip=Font Size Modifier of the Armor mini display
CommonSettingsDialog.armorMiniFontSizeMod=Font Size Mod:
CommonSettingsDialog.armorMiniInternalStructureChar.tooltip=The character representing blocks of internal structure when hovering the mouse over a unit.
CommonSettingsDialog.armorMiniInternalStructureChar=Internal Structure Character:
CommonSettingsDialog.armorMiniUnitsPerBlock.tooltip=The number of armor or IS points represented by each character "block" in the tooltip.
Expand Down Expand Up @@ -1363,6 +1361,8 @@ CommonSettingsDialog.unitDisplay=Unit Tooltip / Unit Display
CommonSettingsDialog.unitDisplayHeatToolTip=Max heat value for each level
CommonSettingsDialog.unitTooltipMaxWidth=Max Width for Unit Tooltip
CommonSettingsDialog.unitTooltipMaxWidth.tooltip=keeps tool tip from growing too wide
CommonSettingsDialog.unitTooltipFontSizeMod.tooltip=Font size modifier of the Unit Tool Tip
CommonSettingsDialog.unitTooltipFontSizeMod=Unit Tool Tip font size mod:
CommonSettingsDialog.useAverageSkills=Use the current random skill settings when adding units in the lobby.
CommonSettingsDialog.useGPinUnitSelection=Display Gunnery and Piloting in Unit Selection screen for BV/PV
CommonSettingsDialog.useAutoCenter=Use automatic unit centering on the board
Expand Down
36 changes: 21 additions & 15 deletions megamek/src/megamek/client/ui/swing/CommonSettingsDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ private <T> void moveElement(DefaultListModel<T> srcModel, int srcIndex, int trg
private JTextField unitTooltipArmorMiniCriticalCharText;
private JTextField unitTooltipArmorMiniDestroyedCharText;
private JTextField unitTooltipArmorMiniCapArmorCharText;
private JTextField unitTooltipArmorMiniFontSizeModText;
private JComboBox<String> unitTooltipFontSizeModCbo;
private JTextField unitTooltipArmorMiniUnitsPerBlockText;
private JTextField unitDisplayMekArmorLargeFontSizeText;
private JTextField unitDisplayMekArmorMediumFontSizeText;
Expand Down Expand Up @@ -1113,6 +1113,24 @@ private JPanel getUnitDisplayPanel() {
row.add(tooltipDistSupression);
comps.add(row);

JLabel unitTooltipFontSizeModLabel = new JLabel(
Messages.getString("CommonSettingsDialog.unitTooltipFontSizeMod"));

unitTooltipFontSizeModCbo = new JComboBox<>();
unitTooltipFontSizeModCbo.addItem("large");
unitTooltipFontSizeModCbo.addItem("medium");
unitTooltipFontSizeModCbo.addItem("small");
unitTooltipFontSizeModCbo.addItem("x-small");
unitTooltipFontSizeModCbo.addItem("xx-small");
unitTooltipFontSizeModCbo.setSelectedItem(GUIP.getUnitToolTipFontSizeMod());
unitTooltipFontSizeModCbo.setMaximumSize(new Dimension(300, 60));

unitTooltipFontSizeModCbo.setToolTipText(Messages.getString("CommonSettingsDialog.unitTooltipFontSizeMod.tooltip"));
row = new ArrayList<>();
row.add(unitTooltipFontSizeModLabel);
row.add(unitTooltipFontSizeModCbo);
comps.add(row);

comps.add(checkboxEntry(showWpsinTT, null));
comps.add(checkboxEntry(showWpsLocinTT, null));
comps.add(checkboxEntry(showPilotPortraitTT, null));
Expand Down Expand Up @@ -1270,18 +1288,6 @@ private JPanel getUnitDisplayPanel() {
row.add(unitTooltipArmorMiniUnitsPerBlockText);
comps.add(row);

JLabel unitTooltipFontSizeModLabel = new JLabel(
Messages.getString("CommonSettingsDialog.armorMiniFontSizeMod"));
unitTooltipArmorMiniFontSizeModText = new JTextField(5);
unitTooltipArmorMiniFontSizeModText.setText(String.format("%d", GUIP.getUnitToolTipArmorMiniFontSizeMod()));
unitTooltipArmorMiniFontSizeModText.setMaximumSize(new Dimension(150, 40));
unitTooltipArmorMiniFontSizeModText
.setToolTipText(Messages.getString("CommonSettingsDialog.armorMiniFontSizeMod.tooltip"));
row = new ArrayList<>();
row.add(unitTooltipFontSizeModLabel);
row.add(unitTooltipArmorMiniFontSizeModText);
comps.add(row);

addLineSpacer(comps);

JLabel unitTooltipSeenbyLabel = new JLabel(Messages.getString("CommonSettingsDialog.seenby.label"));
Expand Down Expand Up @@ -2241,7 +2247,7 @@ protected void cancelAction() {
unitTooltipArmorMiniDestroyedCharText.setText(GUIP.getUnitToolTipArmorMiniDestoryedChar());
unitTooltipArmorMiniCapArmorCharText.setText(GUIP.getUnitToolTipArmorMiniCapArmorChar());
unitTooltipArmorMiniUnitsPerBlockText.setText(String.format("%d", GUIP.getUnitToolTipArmorMiniUnitsPerBlock()));
unitTooltipArmorMiniFontSizeModText.setText(String.format("%d", GUIP.getUnitToolTipArmorMiniFontSizeMod()));
unitTooltipFontSizeModCbo.setSelectedItem(GUIP.getUnitToolTipFontSizeMod());

csbReportLinkColor.setColour(GUIP.getReportLinkColor());
csbReportSuccessColor.setColour(GUIP.getReportSuccessColor());
Expand Down Expand Up @@ -2732,7 +2738,7 @@ protected void okAction() {
logger.error(ex, "");
}
try {
GUIP.setUnitToolTipArmorMiniFontSize(Integer.parseInt(unitTooltipArmorMiniFontSizeModText.getText()));
GUIP.setUnitToolTipFontSize((String) unitTooltipFontSizeModCbo.getSelectedItem());
} catch (Exception ex) {
logger.error(ex, "");
}
Expand Down
12 changes: 6 additions & 6 deletions megamek/src/megamek/client/ui/swing/GUIPreferences.java
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ public class GUIPreferences extends PreferenceStoreProxy {
public static final String UNIT_TOOLTIP_ARMORMINI_COLOR_INTACT = "UnitToolTipArmorMiniColorIntact";
public static final String UNIT_TOOLTIP_ARMORMINI_COLOR_PARTIAL_DMG = "UnitToolTipArmorMiniColorPartialDmg";
public static final String UNIT_TOOLTIP_ARMORMINI_COLOR_DAMAGED = "UnitToolTipArmorMiniColorDamaged";
public static final String UNIT_TOOLTIP_ARMORMINI_FONT_SIZE_MOD = "UnitToolTipArmorMiniFrontSizeMod";
public static final String UNIT_TOOLTIP_FONT_SIZE_MOD = "UnitToolTipFrontSizeMod";

public static final String UNIT_TOOLTIP_FGCOLOR = "UnitToolTipFGColor";
public static final String UNIT_TOOLTIP_LIGHT_FGCOLOR = "UnitToolTipLightFGColor";
Expand Down Expand Up @@ -616,7 +616,7 @@ protected GUIPreferences() {
setDefault(UNIT_TOOLTIP_ARMORMINI_COLOR_INTACT, DEFAULT_MEDIUM_GREEN);
setDefault(UNIT_TOOLTIP_ARMORMINI_COLOR_PARTIAL_DMG, DEFAULT_MEDIUM_YELLOW);
setDefault(UNIT_TOOLTIP_ARMORMINI_COLOR_DAMAGED, DEFAULT_MEDIUM_DARK_RED);
store.setDefault(UNIT_TOOLTIP_ARMORMINI_FONT_SIZE_MOD, -2);
store.setDefault(UNIT_TOOLTIP_FONT_SIZE_MOD, "medium");
setDefault(UNIT_TOOLTIP_FGCOLOR, new Color(0xEEE6D9));
setDefault(UNIT_TOOLTIP_LIGHT_FGCOLOR, new Color(0x000000));
setDefault(UNIT_TOOLTIP_BUILDING_FGCOLOR, new Color(0x000000));
Expand Down Expand Up @@ -2934,8 +2934,8 @@ public int getUnitToolTipArmorMiniUnitsPerBlock() {
return getInt(UNIT_TOOLTIP_ARMORMINI_UNITS_PER_BLOCK);
}

public int getUnitToolTipArmorMiniFontSizeMod() {
return getInt(UNIT_TOOLTIP_ARMORMINI_FONT_SIZE_MOD);
public String getUnitToolTipFontSizeMod() {
return getString(UNIT_TOOLTIP_FONT_SIZE_MOD);
}

public Color getUnitToolTipFGColor() {
Expand Down Expand Up @@ -3146,8 +3146,8 @@ public void setUnitTooltipArmorMiniUnitsPerBlock(int i) {
store.setValue(UNIT_TOOLTIP_ARMORMINI_UNITS_PER_BLOCK, i);
}

public void setUnitToolTipArmorMiniFontSize(int i) {
store.setValue(UNIT_TOOLTIP_ARMORMINI_FONT_SIZE_MOD, i);
public void setUnitToolTipFontSize(String s) {
store.setValue(UNIT_TOOLTIP_FONT_SIZE_MOD, s);
}

public void setUnitToolTipFGColor(Color c) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,16 @@ public abstract class AbstractWreckSprite extends Sprite {
protected Rectangle modelRect;

protected int secondaryPos;

public AbstractWreckSprite(BoardView boardView1) {
super(boardView1);
}

@Override
public Rectangle getBounds() {
// Start with the hex and add the label
bounds = new Rectangle(0, 0, bv.hex_size.width, bv.hex_size.height);

// Move to board position, save this origin for correct drawing
Point hexOrigin = bounds.getLocation();
Point ePos;
Expand All @@ -65,6 +65,10 @@ public Rectangle getBounds() {
return bounds;
}

public Entity getEntity() {
return entity;
}

/**
* Creates the sprite for this entity. It is an extra pain to create
* transparent images in AWT.
Expand All @@ -74,71 +78,71 @@ public void prepare() {
// create image for buffer
image = ImageUtil.createAcceleratedImage(HexTileset.HEX_W, HexTileset.HEX_H);
Graphics2D graph = (Graphics2D) image.getGraphics();

// if the entity is underwater or would sink underwater, we want to make the wreckage translucent
// so it looks like it sunk
boolean entityIsUnderwater = (entity.relHeight() < 0) ||
((entity.relHeight() >= 0) && entity.getGame().getBoard().getHex(entity.getPosition()).containsTerrain(Terrains.WATER)) &&
!EntityWreckHelper.entityOnBridge(entity);

if (entityIsUnderwater) {
graph.setComposite(AlphaComposite.getInstance(
AlphaComposite.SRC_OVER, 0.35f));
}

// draw the 'destroyed decal' where appropriate
boolean displayDestroyedDecal = EntityWreckHelper.displayDestroyedDecal(entity);

if (displayDestroyedDecal) {
Image destroyed = bv.tileManager.bottomLayerWreckMarkerFor(entity, 0);
if (null != destroyed) {
graph.drawImage(destroyed, 0, 0, this);
}
}

// draw the 'fuel leak' decal where appropriate
boolean drawFuelLeak = EntityWreckHelper.displayFuelLeak(entity);

if (drawFuelLeak) {
Image fuelLeak = bv.tileManager.bottomLayerFuelLeakMarkerFor(entity);
if (null != fuelLeak) {
graph.drawImage(fuelLeak, 0, 0, this);
}
}

// draw the 'tires' or 'tracks' decal where appropriate
boolean drawMotiveWreckage = EntityWreckHelper.displayMotiveDamage(entity);

if (drawMotiveWreckage) {
Image motiveWreckage = bv.tileManager.bottomLayerMotiveMarkerFor(entity);
if (null != motiveWreckage) {
graph.drawImage(motiveWreckage, 0, 0, this);
}
}

// Draw wreck image, if we've got one.
Image wreck;

if (EntityWreckHelper.displayDevastation(entity)) {
// objects in space should not have craters
wreck = entity.getGame().getBoard().inSpace() ?
bv.tileManager.wreckMarkerFor(entity, secondaryPos) :
bv.tileManager.getCraterFor(entity, secondaryPos);
} else {
wreck = EntityWreckHelper.useExplicitWreckImage(entity) ?
wreck = EntityWreckHelper.useExplicitWreckImage(entity) ?
bv.tileManager.wreckMarkerFor(entity, secondaryPos) :
bv.tileManager.imageFor(entity, secondaryPos);
}

if (null != wreck) {
graph.drawImage(wreck, 0, 0, this);
}

if (entityIsUnderwater) {
graph.setComposite(AlphaComposite.getInstance(
AlphaComposite.SRC_OVER, 1.0f));
}

// create final image
image = bv.getScaledImage(image, false);
graph.dispose();
Expand All @@ -151,19 +155,19 @@ public void prepare() {
public boolean isInside(Point point) {
return false;
}

public Coords getPosition() {
if (secondaryPos < 0 || secondaryPos >= entity.getSecondaryPositions().size()) {
return entity.getPosition();
} else {
return entity.getSecondaryPositions().get(secondaryPos);
}
}

@Override
public StringBuffer getTooltip() {
StringBuffer result = new StringBuffer();
result.append(Messages.getString("BoardView1.Tooltip.Wreckof"));
result.append(Messages.getString("BoardView1.Tooltip.Wreckof") + " ");
result.append(entity.getChassis());
result.append(MessageFormat.format(" ({0})", entity.getOwner().getName()));
if (PreferenceManager.getClientPreferences().getShowUnitId()) {
Expand Down
6 changes: 3 additions & 3 deletions megamek/src/megamek/client/ui/swing/boardview/BoardView.java
Original file line number Diff line number Diff line change
Expand Up @@ -2288,7 +2288,7 @@ private void drawOrthograph(Coords c, Graphics boardGraph) {
}
}

boolean useIsometric() {
public boolean useIsometric() {
return drawIsometric;
}

Expand Down Expand Up @@ -5156,11 +5156,11 @@ FovHighlightingAndDarkening getFovHighlighting() {
return fovHighlightingAndDarkening;
}

ArrayList<WreckSprite> getWreckSprites() {
public ArrayList<WreckSprite> getWreckSprites() {
return wreckSprites;
}

ArrayList<IsometricWreckSprite> getIsoWreckSprites() {
public ArrayList<IsometricWreckSprite> getIsoWreckSprites() {
return isometricWreckSprites;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
/**
* A Sprite for a flare, as the name indicates.
*/
class FlareSprite extends Sprite {
public class FlareSprite extends Sprite {

private static final String FILENAME_FLARE_IMAGE = "flare.png";
private static final Image FLARE_IMAGE;
Expand Down Expand Up @@ -63,4 +63,4 @@ public void prepare() { }
public StringBuffer getTooltip() {
return new StringBuffer(Messages.getString("BoardView1.flare", flare.turnsToBurn));
}
}
}
Loading
Loading