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 client settings for report font #5321

Merged
merged 2 commits into from
Apr 20, 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
1 change: 1 addition & 0 deletions megamek/i18n/megamek/client/messages.properties
Original file line number Diff line number Diff line change
Expand Up @@ -1289,6 +1289,7 @@ CommonSettingsDialog.playersRemainingToShow=Number of Players remaining to show
CommonSettingsDialog.playersRemainingToShow.tooltip=set to 0 to turn off
CommonSettingsDialog.protoMechUnitCodes=ProtoMech unit codes:
CommonSettingsDialog.report=Report
CommonSettingsDialog.reportFontType=Report Font Type
CommonSettingsDialog.reportKeywords=Report Keywords
CommonSettingsDialog.reportPhases=Report Phases
CommonSettingsDialog.seenby.Player=Player
Expand Down
12 changes: 12 additions & 0 deletions megamek/src/megamek/client/ui/swing/CommonSettingsDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,7 @@ private <T> void moveElement(DefaultListModel<T> srcModel, int srcIndex, int trg
private ColourSelectorButton csbReportSuccessColor;
private ColourSelectorButton csbReportMissColor;
private ColourSelectorButton csbReportInfoColor;
private JComboBox<String> fontTypeChooserReportFont = new JComboBox<>();
private final JCheckBox showReportSprites = new JCheckBox(Messages.getString("CommonSettingsDialog.showReportSprites"));

private ColourSelectorButton csbUnitOverviewTextShadowColor;
Expand Down Expand Up @@ -1340,6 +1341,15 @@ private JPanel getReportPanel() {
row.add(csbReportInfoColor);
comps.add(row);

fontTypeChooserReportFont = new JComboBox<>(new Vector<>(FontHandler.getAvailableNonSymbolFonts()));
fontTypeChooserReportFont.setSelectedItem(GUIP.getReportFontType());

JLabel moveFontTypeLabel = new JLabel(Messages.getString("CommonSettingsDialog.reportFontType"));
row = new ArrayList<>();
row.add(moveFontTypeLabel);
row.add(fontTypeChooserReportFont);
comps.add(row);

comps.add(checkboxEntry(showReportSprites, null));
showReportSprites.setSelected(GUIP.getMiniReportShowSprites());

Expand Down Expand Up @@ -2048,6 +2058,7 @@ protected void cancelAction() {
csbReportSuccessColor.setColour(GUIP.getReportSuccessColor());
csbReportMissColor.setColour(GUIP.getReportMissColor());
csbReportInfoColor.setColour(GUIP.getReportInfoColor());
fontTypeChooserReportFont.setSelectedItem(GUIP.getReportFontType());
showReportSprites.setSelected(GUIP.getMiniReportShowSprites());

csbUnitOverviewTextShadowColor.setColour(GUIP.getUnitOverviewTextShadowColor());
Expand Down Expand Up @@ -2524,6 +2535,7 @@ protected void okAction() {
GUIP.setReportSuccessColor(csbReportSuccessColor.getColour());
GUIP.setReportMissColor(csbReportMissColor.getColour());
GUIP.setReportrInfoColo(csbReportInfoColor.getColour());
GUIP.setReportFontType(fontTypeChooserReportFont.getSelectedItem().toString());
GUIP.setMiniReportShowSprites(showReportSprites.isSelected());

GUIP.setUnitOverviewTextShadowColor(csbUnitOverviewTextShadowColor.getColour());
Expand Down
10 changes: 10 additions & 0 deletions megamek/src/megamek/client/ui/swing/GUIPreferences.java
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,7 @@ public class GUIPreferences extends PreferenceStoreProxy {
public static final String MINI_REPORT_COLOR_SUCCESS = "MiniReportColorSuccess";
public static final String MINI_REPORT_COLOR_MISS = "MiniReportColorMiss";
public static final String MINI_REPORT_COLOR_INFO = "MiniReportColorInfo";
public static final String MINI_REPORT_FONT_TYPE = "MiniReportFontType";
public static final String MINI_ROUND_REPORT_SPRITES = "MiniRoundReportSprites";

public static final String PLAYER_LIST_POS_X = "PlayerListPosX";
Expand Down Expand Up @@ -669,6 +670,7 @@ protected GUIPreferences() {
setDefault(MINI_REPORT_COLOR_SUCCESS, new Color(0x008000));
setDefault(MINI_REPORT_COLOR_MISS, new Color(0x808080));
setDefault(MINI_REPORT_COLOR_INFO, new Color(0x0000FF));
setDefault(MINI_REPORT_FONT_TYPE, "Segoe UI");
store.setDefault(MINI_ROUND_REPORT_SPRITES, true);

store.setDefault(PLAYER_LIST_ENABLED, true);
Expand Down Expand Up @@ -2808,6 +2810,10 @@ public Color getReportMissColor() {
public Color getReportInfoColor() {
return getColor(MINI_REPORT_COLOR_INFO);
}

public String getReportFontType() {
return getString(MINI_REPORT_FONT_TYPE);
}

public int getUnitToolTipSeenByResolution() {
return getInt(UNIT_TOOLTIP_SEENBYRESOLUTION);
Expand Down Expand Up @@ -2929,6 +2935,10 @@ public void setReportMissColor(Color color) {
public void setReportrInfoColo(Color color) {
store.setValue(MINI_REPORT_COLOR_INFO, getColorString(color));
}

public void setReportFontType(String font) {
store.setValue(MINI_REPORT_FONT_TYPE, font);
}

public Color getPlanetaryConditionsColorTitle() {
return getColor(PLANETARY_CONDITIONS_COLOR_TITLE);
Expand Down
2 changes: 2 additions & 0 deletions megamek/src/megamek/client/ui/swing/MiniReportDisplay.java
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,8 @@ public void preferenceChange(PreferenceChangeEvent e) {
adaptToGUIScale();
} else if (e.getName().equals(GUIPreferences.WARNING_COLOR)) {
adaptToGUIScale();
} else if (e.getName().equals(GUIPreferences.MINI_REPORT_FONT_TYPE)) {
adaptToGUIScale();
}
}
}
14 changes: 7 additions & 7 deletions megamek/src/megamek/common/Report.java
Original file line number Diff line number Diff line change
Expand Up @@ -696,16 +696,16 @@ public static void setupStylesheet(JTextPane pane) {
}

public static void setupStylesheet(StyleSheet styleSheet) {
Font font = UIManager.getFont("Label.font");
GUIPreferences GUIP = GUIPreferences.getInstance();
Font font = new Font(GUIP.getReportFontType(), Font.PLAIN, UIUtil.FONT_SCALE1);
int size = UIUtil.scaleForGUI(UIUtil.FONT_SCALE1);

GUIPreferences guip = GUIPreferences.getInstance();
styleSheet.addRule("pre { font-family: " + font.getFamily() + "; font-size: " + size + "pt; font-style:normal;}");
styleSheet.addRule("a { color: " + hexColor(guip.getReportLinkColor()) + " }");
styleSheet.addRule("span.warning { color: " + hexColor(guip.getWarningColor()) + " }");
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("a { color: " + hexColor(GUIP.getReportLinkColor()) + " }");
styleSheet.addRule("span.warning { color: " + hexColor(GUIP.getWarningColor()) + " }");
styleSheet.addRule("span.success { color: " + hexColor(GUIP.getReportSuccessColor()) + " }");
styleSheet.addRule("span.miss { color: " + hexColor(GUIP.getReportMissColor()) + " }");
styleSheet.addRule("span.info { color: " + hexColor(GUIP.getReportInfoColor()) + " }");
}

public String span(String name, String text) {
Expand Down
Loading