Refactor font getting and setting

This commit is contained in:
drdev
2014-05-26 21:43:29 +00:00
parent 205a00690a
commit 8c2312bf07
28 changed files with 146 additions and 123 deletions

View File

@@ -952,7 +952,6 @@ public class Forge implements ApplicationListener {
} }
TextBounds textBounds; TextBounds textBounds;
int fontSize = font.getSize();
if (wrap) { if (wrap) {
textBounds = font.getWrappedBounds(text, w); textBounds = font.getWrappedBounds(text, w);
} }
@@ -963,8 +962,8 @@ public class Forge implements ApplicationListener {
boolean needClip = false; boolean needClip = false;
while (textBounds.width > w || textBounds.height > h) { while (textBounds.width > w || textBounds.height > h) {
if (fontSize > FSkinFont.MIN_FONT_SIZE) { //shrink font to fit if possible if (font.canShrink()) { //shrink font to fit if possible
font = FSkinFont.get(--fontSize); font = font.shrink();
if (wrap) { if (wrap) {
textBounds = font.getWrappedBounds(text, w); textBounds = font.getWrappedBounds(text, w);
} }

View File

@@ -23,17 +23,18 @@ import forge.FThreads;
import forge.util.Utils; import forge.util.Utils;
public class FSkinFont { public class FSkinFont {
public static final int MIN_FONT_SIZE = Math.round(8 / Utils.MAX_RATIO); private static final int MIN_FONT_SIZE = 8;
public static final int MAX_FONT_SIZE = Math.round(72 / Utils.MAX_RATIO); private static final int MAX_FONT_SIZE = 72;
private static final String TTF_FILE = "font1.ttf"; private static final String TTF_FILE = "font1.ttf";
private static final Map<Integer, FSkinFont> fonts = new HashMap<Integer, FSkinFont>(); private static final Map<Integer, FSkinFont> fonts = new HashMap<Integer, FSkinFont>();
public static FSkinFont get(final int size0) { public static FSkinFont get(final int unscaledSize) {
FSkinFont skinFont = fonts.get(size0); int fontSize0 = (int)Utils.scaleMax(unscaledSize);
FSkinFont skinFont = fonts.get(fontSize0);
if (skinFont == null) { if (skinFont == null) {
skinFont = new FSkinFont(size0); skinFont = new FSkinFont(fontSize0);
fonts.put(size0, skinFont); fonts.put(fontSize0, skinFont);
} }
return skinFont; return skinFont;
} }
@@ -61,18 +62,26 @@ public class FSkinFont {
} }
} }
private final int size; private final int fontSize;
private final float scale;
private BitmapFont font; private BitmapFont font;
private FSkinFont(final int size0) { private FSkinFont(int fontSize0) {
size = size0; if (fontSize0 < MIN_FONT_SIZE) {
scale = fontSize0 / MIN_FONT_SIZE;
fontSize0 = MIN_FONT_SIZE;
}
else if (fontSize0 > MAX_FONT_SIZE) {
scale = fontSize0 / MAX_FONT_SIZE;
fontSize0 = MAX_FONT_SIZE;
}
else {
scale = 1;
}
fontSize = fontSize0;
updateFont(); updateFont();
} }
public int getSize() {
return size;
}
// Expose methods from font that updates scale as needed // Expose methods from font that updates scale as needed
public TextBounds getBounds(CharSequence str) { public TextBounds getBounds(CharSequence str) {
return font.getBounds(str); return font.getBounds(str);
@@ -103,8 +112,15 @@ public class FSkinFont {
} }
} }
public boolean canShrink() {
return fontSize > MIN_FONT_SIZE;
}
public FSkinFont shrink() {
return get(fontSize - 1);
}
private void updateFont() { private void updateFont() {
int fontSize = (int)Utils.scaleMax(size);
String fontName = "f" + fontSize; String fontName = "f" + fontSize;
FileHandle fontFile = Gdx.files.absolute(FSkin.getFontDir() + fontName + ".fnt"); FileHandle fontFile = Gdx.files.absolute(FSkin.getFontDir() + fontName + ".fnt");
if (fontFile.exists()) { if (fontFile.exists()) {

View File

@@ -81,8 +81,8 @@ public class TextRenderer {
totalHeight = font.getCapHeight(); totalHeight = font.getCapHeight();
if (totalHeight > height) { if (totalHeight > height) {
//immediately try one font size smaller if no room for anything //immediately try one font size smaller if no room for anything
if (font.getSize() > FSkinFont.MIN_FONT_SIZE) { if (font.canShrink()) {
updatePieces(FSkinFont.get(font.getSize() - 1)); updatePieces(font.shrink());
return; return;
} }
needClip = true; needClip = true;
@@ -127,8 +127,8 @@ public class TextRenderer {
lineNum++; lineNum++;
if (totalHeight > height) { if (totalHeight > height) {
//try next font size down if out of space //try next font size down if out of space
if (font.getSize() > FSkinFont.MIN_FONT_SIZE) { if (font.canShrink()) {
updatePieces(FSkinFont.get(font.getSize() - 1)); updatePieces(font.shrink());
return; return;
} }
needClip = true; needClip = true;
@@ -159,8 +159,8 @@ public class TextRenderer {
lineNum++; lineNum++;
if (totalHeight > height) { if (totalHeight > height) {
//try next font size down if out of space //try next font size down if out of space
if (font.getSize() > FSkinFont.MIN_FONT_SIZE) { if (font.canShrink()) {
updatePieces(FSkinFont.get(font.getSize() - 1)); updatePieces(font.shrink());
return; return;
} }
needClip = true; needClip = true;
@@ -182,9 +182,9 @@ public class TextRenderer {
} }
} }
} }
else if (font.getSize() > FSkinFont.MIN_FONT_SIZE) { else if (font.canShrink()) {
//try next font size down if out of space //try next font size down if out of space
updatePieces(FSkinFont.get(font.getSize() - 1)); updatePieces(font.shrink());
return; return;
} }
else { else {
@@ -291,8 +291,8 @@ public class TextRenderer {
lineNum++; lineNum++;
if (totalHeight > height) { if (totalHeight > height) {
//try next font size down if out of space //try next font size down if out of space
if (font.getSize() > FSkinFont.MIN_FONT_SIZE) { if (font.canShrink()) {
updatePieces(FSkinFont.get(font.getSize() - 1)); updatePieces(font.shrink());
return; return;
} }
needClip = true; needClip = true;
@@ -349,17 +349,17 @@ public class TextRenderer {
lineNum++; lineNum++;
if (totalHeight > height) { if (totalHeight > height) {
//try next font size down if out of space //try next font size down if out of space
if (font.getSize() > FSkinFont.MIN_FONT_SIZE) { if (font.canShrink()) {
updatePieces(FSkinFont.get(font.getSize() - 1)); updatePieces(font.shrink());
return; return;
} }
needClip = true; needClip = true;
} }
} }
else { else {
if (font.getSize() > FSkinFont.MIN_FONT_SIZE) { if (font.canShrink()) {
//try next font size down if out of space //try next font size down if out of space
updatePieces(FSkinFont.get(font.getSize() - 1)); updatePieces(font.shrink());
return; return;
} }
needClip = true; needClip = true;

View File

@@ -295,7 +295,7 @@ public final class DeckManager extends ItemManager<DeckProxy> {
//draw path and main/side on second line //draw path and main/side on second line
x = FList.PADDING; x = FList.PADDING;
y += IMAGE_SIZE + FList.PADDING; y += IMAGE_SIZE + FList.PADDING;
font = FSkinFont.get(font.getSize() - 2); font = font.shrink().shrink();
float lineHeight = font.getLineHeight(); float lineHeight = font.getLineHeight();
int mainSize = deck.getMainSize(); int mainSize = deck.getMainSize();

View File

@@ -22,6 +22,7 @@ import com.google.common.base.Predicate;
import com.google.common.base.Predicates; import com.google.common.base.Predicates;
import com.google.common.collect.Iterables; import com.google.common.collect.Iterables;
import forge.assets.FSkinFont;
import forge.assets.FSkinImage; import forge.assets.FSkinImage;
import forge.item.InventoryItem; import forge.item.InventoryItem;
import forge.itemmanager.filters.ItemFilter; import forge.itemmanager.filters.ItemFilter;
@@ -71,7 +72,7 @@ public abstract class ItemManager<T extends InventoryItem> extends FContainer im
private final FLabel lblCaption = new FLabel.Builder() private final FLabel lblCaption = new FLabel.Builder()
.align(HAlignment.LEFT) .align(HAlignment.LEFT)
.fontSize(12) .font(FSkinFont.get(12))
.build(); .build();
private static final FSkinImage VIEW_OPTIONS_ICON = FSkinImage.SETTINGS; private static final FSkinImage VIEW_OPTIONS_ICON = FSkinImage.SETTINGS;

View File

@@ -48,7 +48,7 @@ public class CardSearchFilter extends TextSearchFilter<PaperCard> {
super.buildWidget(widget); super.buildWidget(widget);
cbSearchMode = new FComboBox<String>(); cbSearchMode = new FComboBox<String>();
cbSearchMode.setFontSize(txtSearch.getFontSize()); cbSearchMode.setFont(txtSearch.getFont());
cbSearchMode.addItem("in"); cbSearchMode.addItem("in");
cbSearchMode.addItem("not in"); cbSearchMode.addItem("not in");
cbSearchMode.setChangedHandler(new FEventHandler() { cbSearchMode.setChangedHandler(new FEventHandler() {
@@ -79,7 +79,7 @@ public class CardSearchFilter extends TextSearchFilter<PaperCard> {
} }
private FLabel addButton(Widget widget, String text) { private FLabel addButton(Widget widget, String text) {
FLabel button = new FLabel.Builder().text(text).fontSize(txtSearch.getFontSize()).align(HAlignment.CENTER) FLabel button = new FLabel.Builder().text(text).font(txtSearch.getFont()).align(HAlignment.CENTER)
.selectable().selected().command(new FEventHandler() { .selectable().selected().command(new FEventHandler() {
@Override @Override
public void handleEvent(FEvent e) { public void handleEvent(FEvent e) {

View File

@@ -2,6 +2,7 @@ package forge.itemmanager.filters;
import com.google.common.base.Predicate; import com.google.common.base.Predicate;
import forge.assets.FSkinFont;
import forge.item.InventoryItem; import forge.item.InventoryItem;
import forge.itemmanager.ItemManager; import forge.itemmanager.ItemManager;
import forge.toolbox.FContainer; import forge.toolbox.FContainer;
@@ -13,8 +14,8 @@ import forge.util.Utils;
public abstract class ItemFilter<T extends InventoryItem> { public abstract class ItemFilter<T extends InventoryItem> {
public static final float PADDING = Utils.scaleMax(3); public static final float PADDING = Utils.scaleMax(3);
public static final int DEFAULT_FONT_SIZE = 11; public static final FSkinFont DEFAULT_FONT = FSkinFont.get(11);
public static final float PANEL_HEIGHT = FTextField.getDefaultHeight(DEFAULT_FONT_SIZE) + PADDING; public static final float PANEL_HEIGHT = FTextField.getDefaultHeight(DEFAULT_FONT) + PADDING;
protected final ItemManager<? super T> itemManager; protected final ItemManager<? super T> itemManager;
private FilterPanel panel; private FilterPanel panel;

View File

@@ -2,6 +2,7 @@ package forge.itemmanager.filters;
import com.badlogic.gdx.graphics.g2d.BitmapFont.HAlignment; import com.badlogic.gdx.graphics.g2d.BitmapFont.HAlignment;
import forge.assets.FSkinFont;
import forge.item.InventoryItem; import forge.item.InventoryItem;
import forge.itemmanager.ItemManager; import forge.itemmanager.ItemManager;
import forge.menu.FTooltip; import forge.menu.FTooltip;
@@ -11,6 +12,8 @@ import forge.util.TextUtil;
public abstract class ListLabelFilter<T extends InventoryItem> extends ItemFilter<T> { public abstract class ListLabelFilter<T extends InventoryItem> extends ItemFilter<T> {
public static final FSkinFont LABEL_FONT = FSkinFont.get(12);
private ListLabel label; private ListLabel label;
protected ListLabelFilter(ItemManager<? super T> itemManager0) { protected ListLabelFilter(ItemManager<? super T> itemManager0) {
@@ -58,7 +61,7 @@ public abstract class ListLabelFilter<T extends InventoryItem> extends ItemFilte
private class ListLabel extends FLabel { private class ListLabel extends FLabel {
private ListLabel() { private ListLabel() {
super(new FLabel.Builder().align(HAlignment.LEFT).fontSize(12)); super(new FLabel.Builder().align(HAlignment.LEFT).font(LABEL_FONT));
} }
@Override @Override

View File

@@ -3,6 +3,7 @@ package forge.itemmanager.filters;
import com.google.common.base.Predicate; import com.google.common.base.Predicate;
import com.google.common.base.Predicates; import com.google.common.base.Predicates;
import forge.assets.FSkinFont;
import forge.item.InventoryItem; import forge.item.InventoryItem;
import forge.itemmanager.ItemManager; import forge.itemmanager.ItemManager;
import forge.itemmanager.SFilterUtil; import forge.itemmanager.SFilterUtil;
@@ -14,6 +15,7 @@ import forge.util.LayoutHelper;
public class TextSearchFilter<T extends InventoryItem> extends ItemFilter<T> { public class TextSearchFilter<T extends InventoryItem> extends ItemFilter<T> {
private static final FSkinFont FONT = FSkinFont.get(12);
protected FTextField txtSearch; protected FTextField txtSearch;
public TextSearchFilter(ItemManager<? super T> itemManager0) { public TextSearchFilter(ItemManager<? super T> itemManager0) {
@@ -56,7 +58,7 @@ public class TextSearchFilter<T extends InventoryItem> extends ItemFilter<T> {
@Override @Override
protected void buildWidget(Widget widget) { protected void buildWidget(Widget widget) {
txtSearch = new FTextField(); txtSearch = new FTextField();
txtSearch.setFontSize(ItemFilter.DEFAULT_FONT_SIZE + 1); txtSearch.setFont(FONT);
txtSearch.setGhostText("Search"); txtSearch.setGhostText("Search");
widget.add(txtSearch); widget.add(txtSearch);

View File

@@ -73,7 +73,7 @@ public abstract class ToggleButtonsFilter<T extends InventoryItem> extends ItemF
private ToggleButton(FImage icon) { private ToggleButton(FImage icon) {
super(new FLabel.Builder() super(new FLabel.Builder()
.icon(icon).fontSize(11).iconScaleFactor(0.9f) .icon(icon).font(ItemFilter.DEFAULT_FONT).iconScaleFactor(0.9f)
.align(HAlignment.CENTER) .align(HAlignment.CENTER)
.selectable(true).selected(true) .selectable(true).selected(true)
.command(new FEventHandler() { .command(new FEventHandler() {

View File

@@ -55,7 +55,7 @@ public abstract class ValueRangeFilter<T extends InventoryItem> extends ItemFilt
lowerBound = addSpinner(widget, true); lowerBound = addSpinner(widget, true);
String text = " <= " + this.getCaption() + " <= "; String text = " <= " + this.getCaption() + " <= ";
label = new FLabel.Builder().text(text).fontSize(12).build(); label = new FLabel.Builder().text(text).font(ListLabelFilter.LABEL_FONT).build();
widget.add(label); widget.add(label);
upperBound = addSpinner(widget, false); upperBound = addSpinner(widget, false);

View File

@@ -42,10 +42,11 @@ import com.badlogic.gdx.math.Vector2;
public class ImageView<T extends InventoryItem> extends ItemView<T> { public class ImageView<T extends InventoryItem> extends ItemView<T> {
private static final float PADDING = Utils.scaleMin(5); private static final float PADDING = Utils.scaleMin(5);
private static final float PILE_SPACING_Y = 0.1f; private static final float PILE_SPACING_Y = 0.1f;
private static final FSkinFont LABEL_FONT = FSkinFont.get(12);
private static final FSkinColor GROUP_HEADER_FORE_COLOR = FSkinColor.get(Colors.CLR_TEXT); private static final FSkinColor GROUP_HEADER_FORE_COLOR = FSkinColor.get(Colors.CLR_TEXT);
private static final FSkinColor OPTION_LABEL_COLOR = GROUP_HEADER_FORE_COLOR.alphaColor(0.7f); private static final FSkinColor OPTION_LABEL_COLOR = GROUP_HEADER_FORE_COLOR.alphaColor(0.7f);
private static final FSkinColor GROUP_HEADER_LINE_COLOR = GROUP_HEADER_FORE_COLOR.alphaColor(0.5f); private static final FSkinColor GROUP_HEADER_LINE_COLOR = GROUP_HEADER_FORE_COLOR.alphaColor(0.5f);
private static final FSkinFont GROUP_HEADER_FONT = FSkinFont.get(12); private static final FSkinFont GROUP_HEADER_FONT = LABEL_FONT;
private static final float GROUP_HEADER_HEIGHT = Utils.scaleY(19); private static final float GROUP_HEADER_HEIGHT = Utils.scaleY(19);
private static final float GROUP_HEADER_GLYPH_WIDTH = Utils.scaleX(6); private static final float GROUP_HEADER_GLYPH_WIDTH = Utils.scaleX(6);
private static final float GROUP_HEADER_LINE_THICKNESS = Utils.scaleY(1); private static final float GROUP_HEADER_LINE_THICKNESS = Utils.scaleY(1);
@@ -137,9 +138,9 @@ public class ImageView<T extends InventoryItem> extends ItemView<T> {
} }
} }
private final ExpandCollapseButton btnExpandCollapseAll = new ExpandCollapseButton(); private final ExpandCollapseButton btnExpandCollapseAll = new ExpandCollapseButton();
private final FLabel lblGroupBy = new FLabel.Builder().text("Groups:").fontSize(12).textColor(OPTION_LABEL_COLOR).build(); private final FLabel lblGroupBy = new FLabel.Builder().text("Groups:").font(LABEL_FONT).textColor(OPTION_LABEL_COLOR).build();
private final FComboBox<Object> cbGroupByOptions = new FComboBox<Object>(); private final FComboBox<Object> cbGroupByOptions = new FComboBox<Object>();
private final FLabel lblPileBy = new FLabel.Builder().text("Piles:").fontSize(12).textColor(OPTION_LABEL_COLOR).build(); private final FLabel lblPileBy = new FLabel.Builder().text("Piles:").font(LABEL_FONT).textColor(OPTION_LABEL_COLOR).build();
private final FComboBox<Object> cbPileByOptions = new FComboBox<Object>(); private final FComboBox<Object> cbPileByOptions = new FComboBox<Object>();
public ImageView(ItemManager<T> itemManager0, ItemManagerModel<T> model0) { public ImageView(ItemManager<T> itemManager0, ItemManagerModel<T> model0) {
@@ -182,8 +183,8 @@ public class ImageView<T extends InventoryItem> extends ItemView<T> {
} }
}); });
cbGroupByOptions.setFontSize(12); cbGroupByOptions.setFont(LABEL_FONT);
cbPileByOptions.setFontSize(12); cbPileByOptions.setFont(LABEL_FONT);
getPnlOptions().add(btnExpandCollapseAll); getPnlOptions().add(btnExpandCollapseAll);
getPnlOptions().add(lblGroupBy); getPnlOptions().add(lblGroupBy);
getPnlOptions().add(cbGroupByOptions); getPnlOptions().add(cbGroupByOptions);
@@ -398,7 +399,7 @@ public class ImageView<T extends InventoryItem> extends ItemView<T> {
protected float layoutOptionsPanel(float visibleWidth, float height) { protected float layoutOptionsPanel(float visibleWidth, float height) {
float padding = ItemFilter.PADDING; float padding = ItemFilter.PADDING;
float x = 0; float x = 0;
float h = FTextField.getDefaultHeight(ItemFilter.DEFAULT_FONT_SIZE); float h = FTextField.getDefaultHeight(ItemFilter.DEFAULT_FONT);
float y = (height - h) / 2; float y = (height - h) / 2;
btnExpandCollapseAll.setBounds(x, y, h, h); btnExpandCollapseAll.setBounds(x, y, h, h);
x += h + padding; x += h + padding;

View File

@@ -91,7 +91,7 @@ public final class ItemListView<T extends InventoryItem> extends ItemView<T> {
if (config.getShowUniqueCardsOption()) { if (config.getShowUniqueCardsOption()) {
final FCheckBox chkBox = new FCheckBox("Unique Cards Only", itemManager.getWantUnique()); final FCheckBox chkBox = new FCheckBox("Unique Cards Only", itemManager.getWantUnique());
chkBox.setFontSize(list.getFontSize()); chkBox.setFont(list.getFont());
chkBox.setCommand(new FEventHandler() { chkBox.setCommand(new FEventHandler() {
@Override @Override
public void handleEvent(FEvent e) { public void handleEvent(FEvent e) {
@@ -117,7 +117,7 @@ public final class ItemListView<T extends InventoryItem> extends ItemView<T> {
final FCheckBox chkBox = new FCheckBox(StringUtils.isEmpty(col.getShortName()) ? final FCheckBox chkBox = new FCheckBox(StringUtils.isEmpty(col.getShortName()) ?
col.getLongName() : col.getShortName(), col.isVisible()); col.getLongName() : col.getShortName(), col.isVisible());
chkBox.setFontSize(list.getFontSize()); chkBox.setFont(list.getFont());
chkBox.setCommand(new FEventHandler() { chkBox.setCommand(new FEventHandler() {
@Override @Override
public void handleEvent(FEvent e) { public void handleEvent(FEvent e) {
@@ -303,7 +303,7 @@ public final class ItemListView<T extends InventoryItem> extends ItemView<T> {
renderer.drawValue(g, value, font, foreColor, pressed, x + 1, y, w - 2, h); //x + 1 and w - 2 to account for left and right borders renderer.drawValue(g, value, font, foreColor, pressed, x + 1, y, w - 2, h); //x + 1 and w - 2 to account for left and right borders
} }
}); });
setFontSize(14); setFont(FSkinFont.get(14));
} }
public Iterable<ItemColumn> getCells() { public Iterable<ItemColumn> getCells() {

View File

@@ -7,6 +7,7 @@ import forge.Forge;
import forge.Forge.Graphics; import forge.Forge.Graphics;
import forge.assets.FImage; import forge.assets.FImage;
import forge.assets.FSkinColor; import forge.assets.FSkinColor;
import forge.assets.FSkinFont;
import forge.assets.FSkinColor.Colors; import forge.assets.FSkinColor.Colors;
import forge.assets.FSkinTexture; import forge.assets.FSkinTexture;
import forge.toolbox.FContainer; import forge.toolbox.FContainer;
@@ -22,6 +23,7 @@ public abstract class FScreen extends FContainer {
public static final FSkinColor HEADER_BACK_COLOR = HEADER_BTN_PRESSED_COLOR.stepColor(-80); public static final FSkinColor HEADER_BACK_COLOR = HEADER_BTN_PRESSED_COLOR.stepColor(-80);
public static final float HEADER_HEIGHT = Math.round(Utils.AVG_FINGER_HEIGHT * 0.8f); public static final float HEADER_HEIGHT = Math.round(Utils.AVG_FINGER_HEIGHT * 0.8f);
private static final FSkinFont HEADER_FONT = FSkinFont.get(16);
private final FLabel btnBack, lblHeader; private final FLabel btnBack, lblHeader;
@@ -38,7 +40,7 @@ public abstract class FScreen extends FContainer {
btnBack = null; btnBack = null;
} }
if (headerCaption != null) { if (headerCaption != null) {
lblHeader = add(new FLabel.Builder().text(headerCaption).fontSize(16).align(HAlignment.CENTER).build()); lblHeader = add(new FLabel.Builder().text(headerCaption).font(HEADER_FONT).align(HAlignment.CENTER).build());
} }
else { else {
lblHeader = null; lblHeader = null;

View File

@@ -55,16 +55,17 @@ public class ConstructedScreen extends LaunchScreen {
private static final ForgePreferences prefs = FModel.getPreferences(); private static final ForgePreferences prefs = FModel.getPreferences();
private static final float PADDING = Utils.scaleMin(5); private static final float PADDING = Utils.scaleMin(5);
private static final int MAX_PLAYERS = 8; private static final int MAX_PLAYERS = 8;
private static final int VARIANTS_FONT_SIZE = 12; private static final FSkinFont VARIANTS_FONT = FSkinFont.get(12);
private static final FSkinFont LABEL_FONT = FSkinFont.get(14);
// General variables // General variables
private final FLabel lblPlayers = new FLabel.Builder().text("Players:").fontSize(VARIANTS_FONT_SIZE).build(); private final FLabel lblPlayers = new FLabel.Builder().text("Players:").font(VARIANTS_FONT).build();
private final FComboBox<Integer> cbPlayerCount; private final FComboBox<Integer> cbPlayerCount;
private List<Integer> teams = new ArrayList<Integer>(MAX_PLAYERS); private List<Integer> teams = new ArrayList<Integer>(MAX_PLAYERS);
private List<Integer> archenemyTeams = new ArrayList<Integer>(MAX_PLAYERS); private List<Integer> archenemyTeams = new ArrayList<Integer>(MAX_PLAYERS);
// Variants frame and variables // Variants frame and variables
private final FLabel lblVariants = new FLabel.Builder().text("Variants:").fontSize(VARIANTS_FONT_SIZE).build(); private final FLabel lblVariants = new FLabel.Builder().text("Variants:").font(VARIANTS_FONT).build();
private final FComboBox<Object> cbVariants; private final FComboBox<Object> cbVariants;
private final Set<GameType> appliedVariants = new TreeSet<GameType>(); private final Set<GameType> appliedVariants = new TreeSet<GameType>();
@@ -102,7 +103,7 @@ public class ConstructedScreen extends LaunchScreen {
add(lblPlayers); add(lblPlayers);
cbPlayerCount = add(new FComboBox<Integer>()); cbPlayerCount = add(new FComboBox<Integer>());
cbPlayerCount.setFontSize(VARIANTS_FONT_SIZE); cbPlayerCount.setFont(VARIANTS_FONT);
for (int i = 2; i <= MAX_PLAYERS; i++) { for (int i = 2; i <= MAX_PLAYERS; i++) {
cbPlayerCount.addItem(i); cbPlayerCount.addItem(i);
} }
@@ -120,7 +121,7 @@ public class ConstructedScreen extends LaunchScreen {
add(lblVariants); add(lblVariants);
cbVariants = add(new FComboBox<Object>()); cbVariants = add(new FComboBox<Object>());
cbVariants.setFontSize(VARIANTS_FONT_SIZE); cbVariants.setFont(VARIANTS_FONT);
cbVariants.addItem("(None)"); cbVariants.addItem("(None)");
cbVariants.addItem(GameType.Vanguard); cbVariants.addItem(GameType.Vanguard);
cbVariants.addItem(GameType.Commander); cbVariants.addItem(GameType.Commander);
@@ -786,7 +787,7 @@ public class ConstructedScreen extends LaunchScreen {
} }
txtPlayerName.setText(name); txtPlayerName.setText(name);
txtPlayerName.setFontSize(14); txtPlayerName.setFont(LABEL_FONT);
txtPlayerName.setChangedHandler(nameChangedHandler); txtPlayerName.setChangedHandler(nameChangedHandler);
} }
@@ -890,7 +891,7 @@ public class ConstructedScreen extends LaunchScreen {
/** Adds a pre-styled FLabel component with the specified title. */ /** Adds a pre-styled FLabel component with the specified title. */
private FLabel newLabel(String title) { private FLabel newLabel(String title) {
return new FLabel.Builder().text(title).fontSize(14).align(HAlignment.RIGHT).build(); return new FLabel.Builder().text(title).font(LABEL_FONT).align(HAlignment.RIGHT).build();
} }
private List<Integer> getUsedAvatars() { private List<Integer> getUsedAvatars() {

View File

@@ -17,6 +17,7 @@
*/ */
package forge.screens.match.views; package forge.screens.match.views;
import forge.assets.FSkinFont;
import forge.assets.FSkinImage; import forge.assets.FSkinImage;
import forge.card.CardZoom; import forge.card.CardZoom;
import forge.game.GameEntity; import forge.game.GameEntity;
@@ -232,7 +233,7 @@ public class VAssignDamage extends FDialog {
} }
cardPanel = add(new AttDefCardPanel(fakeCard)); cardPanel = add(new AttDefCardPanel(fakeCard));
} }
label = add(new FLabel.Builder().text("0").fontSize(18).align(HAlignment.CENTER).build()); label = add(new FLabel.Builder().text("0").font(FSkinFont.get(18)).align(HAlignment.CENTER).build());
btnSubtract = add(new FLabel.ButtonBuilder().icon(FSkinImage.MINUS).command(new FEventHandler() { btnSubtract = add(new FLabel.ButtonBuilder().icon(FSkinImage.MINUS).command(new FEventHandler() {
@Override @Override
public void handleEvent(FEvent e) { public void handleEvent(FEvent e) {

View File

@@ -65,8 +65,8 @@ public class VPhaseIndicator extends FContainer {
for (PhaseLabel lbl : phaseLabels.values()) { for (PhaseLabel lbl : phaseLabels.values()) {
bounds = font.getBounds(lbl.caption); bounds = font.getBounds(lbl.caption);
if (bounds.width > w) { if (bounds.width > w) {
if (font.getSize() > FSkinFont.MIN_FONT_SIZE) { if (font.canShrink()) {
font = FSkinFont.get(font.getSize() - 1); font = font.shrink();
return _getPreferredHeight(w); return _getPreferredHeight(w);
} }
break; break;

View File

@@ -86,7 +86,7 @@ public class VStack extends FDropDown {
float width = totalWidth - 2 * PADDING; float width = totalWidth - 2 * PADDING;
if (stack.isEmpty()) { //show label if stack empty if (stack.isEmpty()) { //show label if stack empty
FLabel label = add(new FLabel.Builder().text("[Empty]").fontSize(FONT.getSize()).align(HAlignment.CENTER).build()); FLabel label = add(new FLabel.Builder().text("[Empty]").font(FONT).align(HAlignment.CENTER).build());
height = Math.round(label.getAutoSizeBounds().height) + 2 * PADDING; height = Math.round(label.getAutoSizeBounds().height) + 2 * PADDING;
label.setBounds(x, y, width, height); label.setBounds(x, y, width, height);

View File

@@ -25,6 +25,7 @@ import forge.GuiBase;
import forge.LobbyPlayer; import forge.LobbyPlayer;
import forge.assets.FSkinColor; import forge.assets.FSkinColor;
import forge.assets.FSkinColor.Colors; import forge.assets.FSkinColor.Colors;
import forge.assets.FSkinFont;
import forge.assets.FSkinImage; import forge.assets.FSkinImage;
import forge.deck.Deck; import forge.deck.Deck;
import forge.game.Game; import forge.game.Game;
@@ -102,9 +103,9 @@ public class GauntletWinLose extends ControlWinLose {
if (gd.getCompleted() == lstDecks.size()) { if (gd.getCompleted() == lstDecks.size()) {
lblGraphic = new FLabel.Builder() lblGraphic = new FLabel.Builder()
.icon(FSkinImage.QUEST_COIN).build(); .icon(FSkinImage.QUEST_COIN).build();
lblMessage1 = new FLabel.Builder().fontSize(24) lblMessage1 = new FLabel.Builder().font(FSkinFont.get(24))
.text("CONGRATULATIONS!").build(); .text("CONGRATULATIONS!").build();
lblMessage2 = new FLabel.Builder().fontSize(18) lblMessage2 = new FLabel.Builder().font(FSkinFont.get(18))
.text("You made it through the gauntlet!").build(); .text("You made it through the gauntlet!").build();
this.getView().getBtnContinue().setVisible(false); this.getView().getBtnContinue().setVisible(false);
@@ -132,9 +133,9 @@ public class GauntletWinLose extends ControlWinLose {
else { else {
lblGraphic = new FLabel.Builder() lblGraphic = new FLabel.Builder()
.icon(FSkinImage.QUEST_HEART).build(); .icon(FSkinImage.QUEST_HEART).build();
lblMessage1 = new FLabel.Builder().fontSize(24) lblMessage1 = new FLabel.Builder().font(FSkinFont.get(24))
.text("DEFEATED!").build(); .text("DEFEATED!").build();
lblMessage2 = new FLabel.Builder().fontSize(18) lblMessage2 = new FLabel.Builder().font(FSkinFont.get(18))
.text("You have failed to pass the gauntlet.").build(); .text("You have failed to pass the gauntlet.").build();
this.getView().getBtnContinue().setVisible(false); this.getView().getBtnContinue().setVisible(false);
@@ -153,7 +154,7 @@ public class GauntletWinLose extends ControlWinLose {
// Custom panel display // Custom panel display
final FLabel lblTitle = new FLabel.Builder().text("Gauntlet Progress") final FLabel lblTitle = new FLabel.Builder().text("Gauntlet Progress")
.align(HAlignment.CENTER).fontSize(18).build(); .align(HAlignment.CENTER).font(FSkinFont.get(18)).build();
final FPanel pnl = this.getView().getPnlCustom(); final FPanel pnl = this.getView().getPnlCustom();
pnl.setBackColor(FSkinColor.get(Colors.CLR_THEME2)); pnl.setBackColor(FSkinColor.get(Colors.CLR_THEME2));
@@ -161,7 +162,7 @@ public class GauntletWinLose extends ControlWinLose {
FLabel lblTemp; FLabel lblTemp;
for (int i = 0; i < len; i++) { for (int i = 0; i < len; i++) {
lblTemp = new FLabel.Builder().fontSize(14).build(); lblTemp = new FLabel.Builder().font(FSkinFont.get(14)).build();
if (i <= num) { if (i <= num) {
lblTemp.setTextColor(FSkinColor.getStandardColor(Color.GREEN).stepColor(20)); lblTemp.setTextColor(FSkinColor.getStandardColor(Color.GREEN).stepColor(20));

View File

@@ -20,6 +20,7 @@ package forge.screens.match.winlose;
import com.badlogic.gdx.graphics.g2d.BitmapFont.HAlignment; import com.badlogic.gdx.graphics.g2d.BitmapFont.HAlignment;
import forge.GuiBase; import forge.GuiBase;
import forge.assets.FSkinFont;
import forge.game.Game; import forge.game.Game;
import forge.limited.GauntletMini; import forge.limited.GauntletMini;
import forge.model.FModel; import forge.model.FModel;
@@ -109,9 +110,9 @@ public class LimitedWinLose extends ControlWinLose {
* @param String - the title to be displayed * @param String - the title to be displayed
*/ */
private void showTournamentInfo(final String newTitle) { private void showTournamentInfo(final String newTitle) {
final FLabel lblTitle = new FLabel.Builder().text(newTitle).fontSize(18).align(HAlignment.CENTER).build(); final FLabel lblTitle = new FLabel.Builder().text(newTitle).font(FSkinFont.get(18)).align(HAlignment.CENTER).build();
final FLabel lblSubTitle = new FLabel.Builder().text("Round: " + gauntlet.getCurrentRound() + "/" + gauntlet.getRounds()) final FLabel lblSubTitle = new FLabel.Builder().text("Round: " + gauntlet.getCurrentRound() + "/" + gauntlet.getRounds())
.align(HAlignment.CENTER).fontSize(17).build(); .align(HAlignment.CENTER).font(FSkinFont.get(17)).build();
this.getView().getPnlCustom().add(lblTitle); this.getView().getPnlCustom().add(lblTitle);
this.getView().getPnlCustom().add(lblSubTitle); this.getView().getPnlCustom().add(lblSubTitle);
} }

View File

@@ -5,6 +5,7 @@ import com.badlogic.gdx.graphics.g2d.BitmapFont.HAlignment;
import forge.Forge; import forge.Forge;
import forge.assets.FSkinColor; import forge.assets.FSkinColor;
import forge.assets.FSkinColor.Colors; import forge.assets.FSkinColor.Colors;
import forge.assets.FSkinFont;
import forge.game.Game; import forge.game.Game;
import forge.game.GameLog; import forge.game.GameLog;
import forge.game.GameLogEntry; import forge.game.GameLogEntry;
@@ -40,8 +41,8 @@ public class ViewWinLose extends FOverlay {
game = game0; game = game0;
lblTitle = add(new FLabel.Builder().fontSize(30).align(HAlignment.CENTER).build()); lblTitle = add(new FLabel.Builder().font(FSkinFont.get(30)).align(HAlignment.CENTER).build());
lblStats = add(new FLabel.Builder().fontSize(26).align(HAlignment.CENTER).build()); lblStats = add(new FLabel.Builder().font(FSkinFont.get(26)).align(HAlignment.CENTER).build());
pnlOutcomes = add(new OutcomesPanel()); pnlOutcomes = add(new OutcomesPanel());
pnlCustom = new FPanel(); pnlCustom = new FPanel();
@@ -81,7 +82,7 @@ public class ViewWinLose extends FOverlay {
btnQuit.setFontSize(22); btnQuit.setFontSize(22);
btnContinue.setEnabled(!game0.getMatch().isMatchOver()); btnContinue.setEnabled(!game0.getMatch().isMatchOver());
lblLog = add(new FLabel.Builder().text("Game Log").align(HAlignment.CENTER).fontSize(18).build()); lblLog = add(new FLabel.Builder().text("Game Log").align(HAlignment.CENTER).font(FSkinFont.get(18)).build());
txtLog = add(new FTextArea(game.getGameLog().getLogText(null).replace("[COMPUTER]", "[AI]")) { txtLog = add(new FTextArea(game.getGameLog().getLogText(null).replace("[COMPUTER]", "[AI]")) {
@Override @Override
public boolean tap(float x, float y, int count) { public boolean tap(float x, float y, int count) {
@@ -141,7 +142,7 @@ public class ViewWinLose extends FOverlay {
private void showGameOutcomeSummary() { private void showGameOutcomeSummary() {
GameLog log = game.getGameLog(); GameLog log = game.getGameLog();
for (GameLogEntry o : log.getLogEntriesExact(GameLogEntryType.GAME_OUTCOME)) { for (GameLogEntry o : log.getLogEntriesExact(GameLogEntryType.GAME_OUTCOME)) {
pnlOutcomes.add(new FLabel.Builder().text(o.message).fontSize(14).build()); pnlOutcomes.add(new FLabel.Builder().text(o.message).font(FSkinFont.get(14)).build());
} }
} }

View File

@@ -269,15 +269,15 @@ public class DualListBox<T> extends FDialog {
} }
private abstract class ItemRenderer { private abstract class ItemRenderer {
public abstract int getDefaultFontSize(); public abstract FSkinFont getDefaultFont();
public abstract float getItemHeight(); public abstract float getItemHeight();
public abstract boolean tap(T value, float x, float y, int count); public abstract boolean tap(T value, float x, float y, int count);
public abstract void drawValue(Graphics g, T value, FSkinFont font, FSkinColor foreColor, boolean pressed, float x, float y, float w, float h); public abstract void drawValue(Graphics g, T value, FSkinFont font, FSkinColor foreColor, boolean pressed, float x, float y, float w, float h);
} }
private class DefaultItemRenderer extends ItemRenderer { private class DefaultItemRenderer extends ItemRenderer {
@Override @Override
public int getDefaultFontSize() { public FSkinFont getDefaultFont() {
return 12; return FSkinFont.get(12);
} }
@Override @Override
@@ -300,8 +300,8 @@ public class DualListBox<T> extends FDialog {
private final TextRenderer textRenderer = new TextRenderer(true); private final TextRenderer textRenderer = new TextRenderer(true);
@Override @Override
public int getDefaultFontSize() { public FSkinFont getDefaultFont() {
return 12; return FSkinFont.get(12);
} }
@Override @Override
@@ -332,8 +332,8 @@ public class DualListBox<T> extends FDialog {
//special renderer for cards //special renderer for cards
private class CardItemRenderer extends ItemRenderer { private class CardItemRenderer extends ItemRenderer {
@Override @Override
public int getDefaultFontSize() { public FSkinFont getDefaultFont() {
return 14; return FSkinFont.get(14);
} }
@Override @Override
@@ -383,7 +383,7 @@ public class DualListBox<T> extends FDialog {
renderer.drawValue(g, value, font, foreColor, pressed, x, y, w, h); renderer.drawValue(g, value, font, foreColor, pressed, x, y, w, h);
} }
}); });
setFontSize(renderer.getDefaultFontSize()); setFont(renderer.getDefaultFont());
} }
//remove any selected indices outside item range //remove any selected indices outside item range

View File

@@ -4,6 +4,7 @@ import com.badlogic.gdx.graphics.g2d.BitmapFont.HAlignment;
import forge.Forge.Graphics; import forge.Forge.Graphics;
import forge.assets.FSkinColor; import forge.assets.FSkinColor;
import forge.assets.FSkinFont;
import forge.assets.FSkinImage; import forge.assets.FSkinImage;
import forge.assets.FSkinTexture; import forge.assets.FSkinTexture;
import forge.assets.FSkinColor.Colors; import forge.assets.FSkinColor.Colors;
@@ -11,6 +12,7 @@ import forge.screens.FScreen;
import forge.util.Utils; import forge.util.Utils;
public abstract class FDialog extends FOverlay { public abstract class FDialog extends FOverlay {
private static final FSkinFont TITLE_FONT = FSkinFont.get(12);
private static final FSkinColor TITLE_BACK_COLOR = FSkinColor.get(Colors.CLR_THEME2); private static final FSkinColor TITLE_BACK_COLOR = FSkinColor.get(Colors.CLR_THEME2);
private static final FSkinColor BORDER_COLOR = FSkinColor.get(Colors.CLR_BORDERS); private static final FSkinColor BORDER_COLOR = FSkinColor.get(Colors.CLR_BORDERS);
public static final float TITLE_HEIGHT = Math.round(Utils.AVG_FINGER_HEIGHT * 0.6f); public static final float TITLE_HEIGHT = Math.round(Utils.AVG_FINGER_HEIGHT * 0.6f);
@@ -95,7 +97,7 @@ public abstract class FDialog extends FOverlay {
private class Titlebar extends FLabel { private class Titlebar extends FLabel {
private Titlebar(String title) { private Titlebar(String title) {
super(new FLabel.Builder().text(title).icon(FSkinImage.FAVICON).fontSize(12).align(HAlignment.LEFT)); super(new FLabel.Builder().text(title).icon(FSkinImage.FAVICON).font(TITLE_FONT).align(HAlignment.LEFT));
} }
@Override @Override

View File

@@ -137,11 +137,8 @@ public class FGroupList<E> extends FScrollPane {
public FSkinFont getFont() { public FSkinFont getFont() {
return font; return font;
} }
public int getFontSize() { public void setFont(FSkinFont font0) {
return font.getSize(); font = font0;
}
public void setFontSize(int fontSize0) {
font = FSkinFont.get(fontSize0);
} }
@Override @Override

View File

@@ -18,7 +18,7 @@ public class FLabel extends FDisplayObject implements IButton {
public static class Builder { public static class Builder {
//========== Default values for FLabel are set here. //========== Default values for FLabel are set here.
private float bldIconScaleFactor = 0.8f; private float bldIconScaleFactor = 0.8f;
private int bldFontSize = 14; private FSkinFont bldFont = FSkinFont.get(14);
private float bldAlphaComposite = 0.7f; private float bldAlphaComposite = 0.7f;
private HAlignment bldAlignment = HAlignment.LEFT; private HAlignment bldAlignment = HAlignment.LEFT;
private Vector2 bldInsets = new Vector2(Utils.scaleX(3), Utils.scaleY(3)); private Vector2 bldInsets = new Vector2(Utils.scaleX(3), Utils.scaleY(3));
@@ -50,7 +50,7 @@ public class FLabel extends FDisplayObject implements IButton {
public Builder selected(final boolean b0) { this.bldSelected = b0; return this; } public Builder selected(final boolean b0) { this.bldSelected = b0; return this; }
public Builder selected() { selected(true); return this; } public Builder selected() { selected(true); return this; }
public Builder command(final FEventHandler c0) { this.bldCommand = c0; return this; } public Builder command(final FEventHandler c0) { this.bldCommand = c0; return this; }
public Builder fontSize(final int i0) { this.bldFontSize = i0; return this; } public Builder font(final FSkinFont f0) { this.bldFont = f0; return this; }
public Builder alphaComposite(final float a0) { this.bldAlphaComposite = a0; return this; } public Builder alphaComposite(final float a0) { this.bldAlphaComposite = a0; return this; }
public Builder enabled(final boolean b0) { this.bldEnabled = b0; return this; } public Builder enabled(final boolean b0) { this.bldEnabled = b0; return this; }
public Builder iconScaleAuto(final boolean b0) { this.bldIconScaleAuto = b0; return this; } public Builder iconScaleAuto(final boolean b0) { this.bldIconScaleAuto = b0; return this; }
@@ -93,7 +93,7 @@ public class FLabel extends FDisplayObject implements IButton {
// Call this using FLabel.Builder()... // Call this using FLabel.Builder()...
protected FLabel(final Builder b0) { protected FLabel(final Builder b0) {
iconScaleFactor = b0.bldIconScaleFactor; iconScaleFactor = b0.bldIconScaleFactor;
font = FSkinFont.get(b0.bldFontSize); font = b0.bldFont;
alphaComposite = b0.bldAlphaComposite; alphaComposite = b0.bldAlphaComposite;
alignment = b0.bldAlignment; alignment = b0.bldAlignment;
insets = b0.bldInsets; insets = b0.bldInsets;
@@ -131,8 +131,8 @@ public class FLabel extends FDisplayObject implements IButton {
textColor = textColor0; textColor = textColor0;
} }
public void setFontSize(int fontSize0) { public void setFont(FSkinFont font0) {
font = FSkinFont.get(fontSize0); font = font0;
} }
public FImage getIcon() { public FImage getIcon() {
@@ -282,10 +282,10 @@ public class FLabel extends FDisplayObject implements IButton {
x += dx; x += dx;
break; break;
} }
if (font.getSize() <= FSkinFont.MIN_FONT_SIZE) { if (!font.canShrink()) {
break; break;
} }
font = FSkinFont.get(font.getSize() - 1); font = font.shrink();
} }
} }
y += (h - iconHeight) / 2; y += (h - iconHeight) / 2;

View File

@@ -108,11 +108,8 @@ public class FList<E> extends FScrollPane implements Iterable<E> {
public FSkinFont getFont() { public FSkinFont getFont() {
return font; return font;
} }
public int getFontSize() { public void setFont(FSkinFont font0) {
return font.getSize(); font = font0;
}
public void setFontSize(int fontSize0) {
font = FSkinFont.get(fontSize0);
} }
@Override @Override

View File

@@ -14,7 +14,7 @@ import forge.toolbox.FEvent.FEventType;
import forge.util.Utils; import forge.util.Utils;
public class FTextField extends FDisplayObject { public class FTextField extends FDisplayObject {
private static final int DEFAULT_FONT_SIZE = 14; private static final FSkinFont DEFAULT_FONT = FSkinFont.get(14);
private static final float BORDER_THICKNESS = Utils.scaleX(1); private static final float BORDER_THICKNESS = Utils.scaleX(1);
protected static final float PADDING = Utils.scaleX(5); protected static final float PADDING = Utils.scaleX(5);
protected static final FSkinColor FORE_COLOR = FSkinColor.get(Colors.CLR_TEXT); protected static final FSkinColor FORE_COLOR = FSkinColor.get(Colors.CLR_TEXT);
@@ -24,10 +24,7 @@ public class FTextField extends FDisplayObject {
private FEventHandler changedHandler; private FEventHandler changedHandler;
public static float getDefaultHeight() { public static float getDefaultHeight() {
return getDefaultHeight(DEFAULT_FONT_SIZE); return getDefaultHeight(DEFAULT_FONT);
}
public static float getDefaultHeight(int fontSize) {
return getDefaultHeight(FSkinFont.get(fontSize));
} }
public static float getDefaultHeight(FSkinFont font0) { public static float getDefaultHeight(FSkinFont font0) {
return font0.getCapHeight() * 3; return font0.getCapHeight() * 3;
@@ -45,7 +42,7 @@ public class FTextField extends FDisplayObject {
public FTextField(String text0) { public FTextField(String text0) {
text = text0; text = text0;
ghostText = ""; ghostText = "";
setFontSize(DEFAULT_FONT_SIZE); setFont(DEFAULT_FONT);
alignment = HAlignment.LEFT; alignment = HAlignment.LEFT;
} }
@@ -103,11 +100,11 @@ public class FTextField extends FDisplayObject {
alignment = alignment0; alignment = alignment0;
} }
public int getFontSize() { public FSkinFont getFont() {
return font.getSize(); return font;
} }
public void setFontSize(int fontSize0) { public void setFont(FSkinFont font0) {
font = FSkinFont.get(fontSize0); font = font0;
setHeight(getDefaultHeight(font)); setHeight(getDefaultHeight(font));
} }

View File

@@ -97,7 +97,7 @@ public class ListChooser<T> extends FContainer {
maxChoices = maxChoices0; maxChoices = maxChoices0;
if (list.size() > 25) { //only show search field if more than 25 items if (list.size() > 25) { //only show search field if more than 25 items
txtSearch = add(new FTextField()); txtSearch = add(new FTextField());
txtSearch.setFontSize(12); txtSearch.setFont(FSkinFont.get(12));
txtSearch.setGhostText("Search"); txtSearch.setGhostText("Search");
txtSearch.setChangedHandler(new FEventHandler() { txtSearch.setChangedHandler(new FEventHandler() {
@Override @Override
@@ -216,15 +216,15 @@ public class ListChooser<T> extends FContainer {
} }
private abstract class ItemRenderer { private abstract class ItemRenderer {
public abstract int getDefaultFontSize(); public abstract FSkinFont getDefaultFont();
public abstract float getItemHeight(); public abstract float getItemHeight();
public abstract boolean tap(T value, float x, float y, int count); public abstract boolean tap(T value, float x, float y, int count);
public abstract void drawValue(Graphics g, T value, FSkinFont font, FSkinColor foreColor, boolean pressed, float x, float y, float w, float h); public abstract void drawValue(Graphics g, T value, FSkinFont font, FSkinColor foreColor, boolean pressed, float x, float y, float w, float h);
} }
private class DefaultItemRenderer extends ItemRenderer { private class DefaultItemRenderer extends ItemRenderer {
@Override @Override
public int getDefaultFontSize() { public FSkinFont getDefaultFont() {
return 12; return FSkinFont.get(12);
} }
@Override @Override
@@ -245,8 +245,8 @@ public class ListChooser<T> extends FContainer {
//special renderer for cards //special renderer for cards
private class PaperCardItemRenderer extends ItemRenderer { private class PaperCardItemRenderer extends ItemRenderer {
@Override @Override
public int getDefaultFontSize() { public FSkinFont getDefaultFont() {
return 14; return FSkinFont.get(14);
} }
@Override @Override
@@ -267,8 +267,8 @@ public class ListChooser<T> extends FContainer {
//special renderer for cards //special renderer for cards
private class CardItemRenderer extends ItemRenderer { private class CardItemRenderer extends ItemRenderer {
@Override @Override
public int getDefaultFontSize() { public FSkinFont getDefaultFont() {
return 14; return FSkinFont.get(14);
} }
@Override @Override
@@ -291,8 +291,8 @@ public class ListChooser<T> extends FContainer {
private final TextRenderer textRenderer = new TextRenderer(true); private final TextRenderer textRenderer = new TextRenderer(true);
@Override @Override
public int getDefaultFontSize() { public FSkinFont getDefaultFont() {
return 14; return FSkinFont.get(14);
} }
@Override @Override
@@ -322,8 +322,8 @@ public class ListChooser<T> extends FContainer {
} }
private class PlayerItemRenderer extends ItemRenderer { private class PlayerItemRenderer extends ItemRenderer {
@Override @Override
public int getDefaultFontSize() { public FSkinFont getDefaultFont() {
return 18; return FSkinFont.get(18);
} }
@Override @Override
@@ -407,7 +407,7 @@ public class ListChooser<T> extends FContainer {
renderer.drawValue(g, value, font, foreColor, pressed, x, y, w, h); renderer.drawValue(g, value, font, foreColor, pressed, x, y, w, h);
} }
}); });
setFontSize(renderer.getDefaultFontSize()); setFont(renderer.getDefaultFont());
} }
@Override @Override