mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-17 11:18:01 +00:00
Add preferences for card text rendering
This commit is contained in:
@@ -155,6 +155,8 @@ public enum CSubmenuPreferences implements ICDoc {
|
||||
|
||||
lstControls.add(Pair.of(view.getCbCompactPrompt(), FPref.UI_COMPACT_PROMPT));
|
||||
lstControls.add(Pair.of(view.getCbHideReminderText(), FPref.UI_HIDE_REMINDER_TEXT));
|
||||
lstControls.add(Pair.of(view.getCbCardTextUseSansSerif(), FPref.UI_CARD_IMAGE_RENDER_USE_SANS_SERIF_FONT));
|
||||
lstControls.add(Pair.of(view.getCbCardTextHideReminder(), FPref.UI_CARD_IMAGE_RENDER_HIDE_REMINDER_TEXT));
|
||||
lstControls.add(Pair.of(view.getCbOpenPacksIndiv(), FPref.UI_OPEN_PACKS_INDIV));
|
||||
lstControls.add(Pair.of(view.getCbTokensInSeparateRow(), FPref.UI_TOKENS_IN_SEPARATE_ROW));
|
||||
lstControls.add(Pair.of(view.getCbStackCreatures(), FPref.UI_STACK_CREATURES));
|
||||
|
||||
@@ -115,6 +115,8 @@ public enum VSubmenuPreferences implements IVSubmenu<CSubmenuPreferences> {
|
||||
private final JCheckBox cbEscapeEndsTurn = new OptionsCheckBox(localizer.getMessage("cbEscapeEndsTurn"));
|
||||
private final JCheckBox cbPreselectPrevAbOrder = new OptionsCheckBox(localizer.getMessage("cbPreselectPrevAbOrder"));
|
||||
private final JCheckBox cbHideReminderText = new OptionsCheckBox(localizer.getMessage("cbHideReminderText"));
|
||||
private final JCheckBox cbCardTextUseSansSerif = new OptionsCheckBox(localizer.getMessage("lblCardTextUseSansSerif"));
|
||||
private final JCheckBox cbCardTextHideReminder = new OptionsCheckBox(localizer.getMessage("lblCardTextHideReminder"));
|
||||
private final JCheckBox cbOpenPacksIndiv = new OptionsCheckBox(localizer.getMessage("cbOpenPacksIndiv"));
|
||||
private final JCheckBox cbTokensInSeparateRow = new OptionsCheckBox(localizer.getMessage("cbTokensInSeparateRow"));
|
||||
private final JCheckBox cbStackCreatures = new OptionsCheckBox(localizer.getMessage("cbStackCreatures"));
|
||||
@@ -368,6 +370,12 @@ public enum VSubmenuPreferences implements IVSubmenu<CSubmenuPreferences> {
|
||||
pnlPrefs.add(cbHideReminderText, titleConstraints);
|
||||
pnlPrefs.add(new NoteLabel(localizer.getMessage("nlHideReminderText")), descriptionConstraints);
|
||||
|
||||
pnlPrefs.add(cbCardTextUseSansSerif, titleConstraints);
|
||||
pnlPrefs.add(new NoteLabel(localizer.getMessage("nlCardTextUseSansSerif")), descriptionConstraints);
|
||||
|
||||
pnlPrefs.add(cbCardTextHideReminder, titleConstraints);
|
||||
pnlPrefs.add(new NoteLabel(localizer.getMessage("nlCardTextHideReminder")), descriptionConstraints);
|
||||
|
||||
pnlPrefs.add(cbOpenPacksIndiv, titleConstraints);
|
||||
pnlPrefs.add(new NoteLabel(localizer.getMessage("nlOpenPacksIndiv")), descriptionConstraints);
|
||||
|
||||
@@ -847,6 +855,14 @@ public enum VSubmenuPreferences implements IVSubmenu<CSubmenuPreferences> {
|
||||
return cbHideReminderText;
|
||||
}
|
||||
|
||||
public JCheckBox getCbCardTextUseSansSerif() {
|
||||
return cbCardTextUseSansSerif;
|
||||
}
|
||||
|
||||
public final JCheckBox getCbCardTextHideReminder() {
|
||||
return cbCardTextHideReminder;
|
||||
}
|
||||
|
||||
public final JCheckBox getCbOpenPacksIndiv() {
|
||||
return cbOpenPacksIndiv;
|
||||
}
|
||||
|
||||
@@ -52,6 +52,7 @@ public class FCardImageRenderer {
|
||||
private static BreakIterator boundary;
|
||||
private static Pattern linebreakPattern;
|
||||
private static Pattern reminderPattern;
|
||||
private static Pattern reminderHidePattern;
|
||||
private static Pattern symbolPattern;
|
||||
private static Map<Font, Font[]> shrinkFonts;
|
||||
|
||||
@@ -60,6 +61,7 @@ public class FCardImageRenderer {
|
||||
boundary = BreakIterator.getLineInstance(locale);
|
||||
linebreakPattern = Pattern.compile("(\r\n\r\n)|(\n)");
|
||||
reminderPattern = Pattern.compile("\\((.+?)\\)");
|
||||
reminderHidePattern = Pattern.compile(" \\((.+?)\\)");
|
||||
symbolPattern = Pattern.compile("\\{([A-Z0-9]+)\\}|\\{([A-Z0-9]+)/([A-Z0-9]+)\\}");
|
||||
|
||||
NAME_FONT = new Font(Font.SERIF, Font.BOLD, 26);
|
||||
@@ -68,8 +70,13 @@ public class FCardImageRenderer {
|
||||
TEXT_FONT = new Font(Font.SANS_SERIF, Font.PLAIN, 24);
|
||||
REMINDER_FONT = new Font(Font.SANS_SERIF, Font.PLAIN, 22);
|
||||
} else {
|
||||
TEXT_FONT = new Font(Font.SERIF, Font.PLAIN, 24);
|
||||
REMINDER_FONT = new Font(Font.SERIF, Font.ITALIC, 24);
|
||||
if (FModel.getPreferences().getPrefBoolean(FPref.UI_CARD_IMAGE_RENDER_USE_SANS_SERIF_FONT)) {
|
||||
TEXT_FONT = new Font(Font.SANS_SERIF, Font.PLAIN, 24);
|
||||
REMINDER_FONT = new Font(Font.SANS_SERIF, Font.ITALIC, 24);
|
||||
} else {
|
||||
TEXT_FONT = new Font(Font.SERIF, Font.PLAIN, 24);
|
||||
REMINDER_FONT = new Font(Font.SERIF, Font.ITALIC, 24);
|
||||
}
|
||||
}
|
||||
PT_FONT = NAME_FONT;
|
||||
|
||||
@@ -966,10 +973,12 @@ public class FCardImageRenderer {
|
||||
}
|
||||
}
|
||||
|
||||
private static void drawTextBoxText(Graphics2D g, final String text, int x, int y, int w, int h, int flagPTBox) {
|
||||
private static void drawTextBoxText(Graphics2D g, String text, int x, int y, int w, int h, int flagPTBox) {
|
||||
boolean hasPTBox = (flagPTBox & 1) == 1;
|
||||
boolean isLevelup = (flagPTBox & 2) == 2;
|
||||
boolean isLevelBox = (flagPTBox & 4) == 4;
|
||||
if (FModel.getPreferences().getPrefBoolean(FPref.UI_CARD_IMAGE_RENDER_HIDE_REMINDER_TEXT))
|
||||
text = reminderHidePattern.matcher(text).replaceAll("");
|
||||
String [] paragraphs = isLevelBox ? text.split(" ") : linebreakPattern.split(text);
|
||||
List<Paragraph> pgList = new ArrayList<>();
|
||||
for (String pg : paragraphs) {
|
||||
|
||||
Reference in New Issue
Block a user