mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-15 18:28:00 +00:00
Improve scaling for higher resolutions
This commit is contained in:
@@ -8,17 +8,14 @@ import com.badlogic.gdx.files.FileHandle;
|
|||||||
import com.badlogic.gdx.graphics.g2d.BitmapFont;
|
import com.badlogic.gdx.graphics.g2d.BitmapFont;
|
||||||
import com.badlogic.gdx.graphics.g2d.freetype.FreeTypeFontGenerator;
|
import com.badlogic.gdx.graphics.g2d.freetype.FreeTypeFontGenerator;
|
||||||
|
|
||||||
|
import forge.util.Utils;
|
||||||
|
|
||||||
public class FSkinFont {
|
public class FSkinFont {
|
||||||
public static final int MIN_FONT_SIZE = 8;
|
public static final int MIN_FONT_SIZE = Math.round(8 / Utils.MAX_RATIO);
|
||||||
|
|
||||||
private static final String TTF_FILE = "font1.ttf";
|
private static final String TTF_FILE = "font1.ttf";
|
||||||
private static final int defaultFontSize = 12;
|
|
||||||
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() {
|
|
||||||
return get(defaultFontSize);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static FSkinFont get(final int size0) {
|
public static FSkinFont get(final int size0) {
|
||||||
FSkinFont skinFont = fonts.get(size0);
|
FSkinFont skinFont = fonts.get(size0);
|
||||||
if (skinFont == null) {
|
if (skinFont == null) {
|
||||||
@@ -51,7 +48,7 @@ public class FSkinFont {
|
|||||||
FileHandle ttfFile = Gdx.files.absolute(dir + TTF_FILE);
|
FileHandle ttfFile = Gdx.files.absolute(dir + TTF_FILE);
|
||||||
if (ttfFile.exists()) {
|
if (ttfFile.exists()) {
|
||||||
FreeTypeFontGenerator generator = new FreeTypeFontGenerator(ttfFile);
|
FreeTypeFontGenerator generator = new FreeTypeFontGenerator(ttfFile);
|
||||||
font = generator.generateFont(size);
|
font = generator.generateFont((int)Utils.scaleMax(size)); //scale font based on size
|
||||||
font.setUseIntegerPositions(true); //prevent parts of text getting cut off at times
|
font.setUseIntegerPositions(true); //prevent parts of text getting cut off at times
|
||||||
generator.dispose();
|
generator.dispose();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ import forge.screens.match.FControl;
|
|||||||
import forge.toolbox.FCardPanel;
|
import forge.toolbox.FCardPanel;
|
||||||
import forge.toolbox.FDialog;
|
import forge.toolbox.FDialog;
|
||||||
import forge.toolbox.FList;
|
import forge.toolbox.FList;
|
||||||
|
import forge.util.Utils;
|
||||||
|
|
||||||
public class CardRenderer {
|
public class CardRenderer {
|
||||||
private static final FSkinFont NAME_FONT = FSkinFont.get(16);
|
private static final FSkinFont NAME_FONT = FSkinFont.get(16);
|
||||||
@@ -37,8 +38,8 @@ public class CardRenderer {
|
|||||||
private static final float NAME_BOX_TINT = 0.2f;
|
private static final float NAME_BOX_TINT = 0.2f;
|
||||||
private static final float TEXT_BOX_TINT = 0.1f;
|
private static final float TEXT_BOX_TINT = 0.1f;
|
||||||
private static final float PT_BOX_TINT = 0.2f;
|
private static final float PT_BOX_TINT = 0.2f;
|
||||||
private static final float MANA_COST_PADDING = 3;
|
private static final float MANA_COST_PADDING = Utils.scaleMin(3);
|
||||||
private static final float SET_BOX_MARGIN = 1;
|
private static final float SET_BOX_MARGIN = Utils.scaleMin(1);
|
||||||
private static final float MANA_SYMBOL_SIZE = FSkinImage.MANA_1.getNearestHQWidth(2 * (NAME_FONT.getFont().getCapHeight() - MANA_COST_PADDING));
|
private static final float MANA_SYMBOL_SIZE = FSkinImage.MANA_1.getNearestHQWidth(2 * (NAME_FONT.getFont().getCapHeight() - MANA_COST_PADDING));
|
||||||
|
|
||||||
private static Color fromDetailColor(DetailColors detailColor) {
|
private static Color fromDetailColor(DetailColors detailColor) {
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ import forge.toolbox.FButton;
|
|||||||
import forge.toolbox.FComboBox;
|
import forge.toolbox.FComboBox;
|
||||||
import forge.toolbox.FEvent;
|
import forge.toolbox.FEvent;
|
||||||
import forge.toolbox.FEvent.FEventHandler;
|
import forge.toolbox.FEvent.FEventHandler;
|
||||||
|
import forge.util.Utils;
|
||||||
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
@@ -28,7 +29,7 @@ import java.util.Arrays;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class FDeckChooser extends FScreen {
|
public class FDeckChooser extends FScreen {
|
||||||
private static final float PADDING = 5;
|
private static final float PADDING = Utils.scaleMin(5);
|
||||||
|
|
||||||
private FComboBox<DeckType> cmbDeckTypes;
|
private FComboBox<DeckType> cmbDeckTypes;
|
||||||
private DeckType selectedDeckType;
|
private DeckType selectedDeckType;
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import forge.assets.FSkinFont;
|
|||||||
import forge.assets.FSkinColor.Colors;
|
import forge.assets.FSkinColor.Colors;
|
||||||
import forge.toolbox.FOptionPane;
|
import forge.toolbox.FOptionPane;
|
||||||
import forge.toolbox.FScrollPane;
|
import forge.toolbox.FScrollPane;
|
||||||
|
import forge.util.Utils;
|
||||||
|
|
||||||
public class BugReportDialog extends FOptionPane {
|
public class BugReportDialog extends FOptionPane {
|
||||||
private static boolean dialogShown;
|
private static boolean dialogShown;
|
||||||
@@ -69,7 +70,7 @@ public class BugReportDialog extends FOptionPane {
|
|||||||
private static final FSkinColor BACK_COLOR = FSkinColor.get(Colors.CLR_ZEBRA);
|
private static final FSkinColor BACK_COLOR = FSkinColor.get(Colors.CLR_ZEBRA);
|
||||||
private static final FSkinColor FORE_COLOR = FSkinColor.get(Colors.CLR_TEXT);
|
private static final FSkinColor FORE_COLOR = FSkinColor.get(Colors.CLR_TEXT);
|
||||||
private static final FSkinColor BORDER_COLOR = FSkinColor.get(Colors.CLR_BORDERS);
|
private static final FSkinColor BORDER_COLOR = FSkinColor.get(Colors.CLR_BORDERS);
|
||||||
private static final float PADDING = 3;
|
private static final float PADDING = Utils.scaleMin(3);
|
||||||
|
|
||||||
private final String text;
|
private final String text;
|
||||||
|
|
||||||
|
|||||||
@@ -8,10 +8,11 @@ import forge.toolbox.FContainer;
|
|||||||
import forge.toolbox.FDisplayObject;
|
import forge.toolbox.FDisplayObject;
|
||||||
import forge.toolbox.FTextField;
|
import forge.toolbox.FTextField;
|
||||||
import forge.util.LayoutHelper;
|
import forge.util.LayoutHelper;
|
||||||
|
import forge.util.Utils;
|
||||||
|
|
||||||
|
|
||||||
public abstract class ItemFilter<T extends InventoryItem> {
|
public abstract class ItemFilter<T extends InventoryItem> {
|
||||||
public static final float PADDING = 3;
|
public static final float PADDING = Utils.scaleY(3);
|
||||||
public static final int DEFAULT_FONT_SIZE = 11;
|
public static final int DEFAULT_FONT_SIZE = 11;
|
||||||
public static final float PANEL_HEIGHT = FTextField.getDefaultHeight(DEFAULT_FONT_SIZE) + PADDING;
|
public static final float PANEL_HEIGHT = FTextField.getDefaultHeight(DEFAULT_FONT_SIZE) + PADDING;
|
||||||
|
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ import forge.toolbox.FEvent;
|
|||||||
import forge.toolbox.FEvent.FEventHandler;
|
import forge.toolbox.FEvent.FEventHandler;
|
||||||
import forge.toolbox.FLabel;
|
import forge.toolbox.FLabel;
|
||||||
import forge.toolbox.FScrollPane;
|
import forge.toolbox.FScrollPane;
|
||||||
|
import forge.util.Utils;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
@@ -31,13 +32,13 @@ import com.badlogic.gdx.graphics.Texture;
|
|||||||
import com.badlogic.gdx.math.Vector2;
|
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 = 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 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 GROUP_HEADER_LINE_COLOR = GROUP_HEADER_FORE_COLOR.alphaColor(120);
|
private static final FSkinColor GROUP_HEADER_LINE_COLOR = GROUP_HEADER_FORE_COLOR.alphaColor(120);
|
||||||
private static final FSkinFont GROUP_HEADER_FONT = FSkinFont.get(12);
|
private static final FSkinFont GROUP_HEADER_FONT = FSkinFont.get(12);
|
||||||
private static final float GROUP_HEADER_HEIGHT = 19;
|
private static final float GROUP_HEADER_HEIGHT = Utils.scaleY(19);
|
||||||
private static final float GROUP_HEADER_GLYPH_WIDTH = 6;
|
private static final float GROUP_HEADER_GLYPH_WIDTH = Utils.scaleX(6);
|
||||||
private static final int MIN_COLUMN_COUNT = 1;
|
private static final int MIN_COLUMN_COUNT = 1;
|
||||||
private static final int MAX_COLUMN_COUNT = 10;
|
private static final int MAX_COLUMN_COUNT = 10;
|
||||||
|
|
||||||
|
|||||||
@@ -10,11 +10,12 @@ import forge.assets.FSkinFont;
|
|||||||
import forge.assets.FSkinColor.Colors;
|
import forge.assets.FSkinColor.Colors;
|
||||||
import forge.screens.FScreen;
|
import forge.screens.FScreen;
|
||||||
import forge.toolbox.FDisplayObject;
|
import forge.toolbox.FDisplayObject;
|
||||||
|
import forge.util.Utils;
|
||||||
|
|
||||||
public class FTooltip extends FDropDown {
|
public class FTooltip extends FDropDown {
|
||||||
private static final FSkinFont FONT = FSkinFont.get(12);
|
private static final FSkinFont FONT = FSkinFont.get(12);
|
||||||
private static final FSkinColor FORE_COLOR = FSkinColor.get(Colors.CLR_TEXT);
|
private static final FSkinColor FORE_COLOR = FSkinColor.get(Colors.CLR_TEXT);
|
||||||
private static final float PADDING = 5;
|
private static final float PADDING = Utils.scaleMin(5);
|
||||||
|
|
||||||
FDisplayObject owner;
|
FDisplayObject owner;
|
||||||
float x, y;
|
float x, y;
|
||||||
|
|||||||
@@ -123,7 +123,7 @@ public abstract class FScreen extends FContainer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static class BackIcon implements FImage {
|
private static class BackIcon implements FImage {
|
||||||
private static final float THICKNESS = 3;
|
private static final float THICKNESS = Utils.scaleMax(3);
|
||||||
private static final FSkinColor COLOR = FSkinColor.get(Colors.CLR_TEXT);
|
private static final FSkinColor COLOR = FSkinColor.get(Colors.CLR_TEXT);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ import forge.util.storage.IStorage;
|
|||||||
public class ConstructedScreen extends LaunchScreen {
|
public class ConstructedScreen extends LaunchScreen {
|
||||||
private static final FSkinColor PLAYER_BORDER_COLOR = FSkinColor.get(Colors.CLR_BORDERS).alphaColor(0.8f);
|
private static final FSkinColor PLAYER_BORDER_COLOR = FSkinColor.get(Colors.CLR_BORDERS).alphaColor(0.8f);
|
||||||
private static final ForgePreferences prefs = FModel.getPreferences();
|
private static final ForgePreferences prefs = FModel.getPreferences();
|
||||||
private static final float PADDING = 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 int VARIANTS_FONT_SIZE = 12;
|
||||||
|
|
||||||
|
|||||||
@@ -15,9 +15,10 @@ import forge.menu.FDropDown;
|
|||||||
import forge.model.FModel;
|
import forge.model.FModel;
|
||||||
import forge.properties.ForgePreferences.FPref;
|
import forge.properties.ForgePreferences.FPref;
|
||||||
import forge.toolbox.FDisplayObject;
|
import forge.toolbox.FDisplayObject;
|
||||||
|
import forge.util.Utils;
|
||||||
|
|
||||||
public class VLog extends FDropDown {
|
public class VLog extends FDropDown {
|
||||||
private static final float PADDING = 5;
|
private static final float PADDING = Utils.scaleMin(5);
|
||||||
private static final FSkinFont FONT = FSkinFont.get(11);
|
private static final FSkinFont FONT = FSkinFont.get(11);
|
||||||
private static final FSkinColor ALT_ROW_COLOR = FSkinColor.get(Colors.CLR_ZEBRA);
|
private static final FSkinColor ALT_ROW_COLOR = FSkinColor.get(Colors.CLR_ZEBRA);
|
||||||
private static final FSkinColor ROW_COLOR = ALT_ROW_COLOR.darker();
|
private static final FSkinColor ROW_COLOR = ALT_ROW_COLOR.darker();
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ import forge.util.Utils;
|
|||||||
public class VPrompt extends FContainer {
|
public class VPrompt extends FContainer {
|
||||||
public static final float HEIGHT = Utils.AVG_FINGER_HEIGHT;
|
public static final float HEIGHT = Utils.AVG_FINGER_HEIGHT;
|
||||||
public static final float BTN_WIDTH = HEIGHT * 1.5f;
|
public static final float BTN_WIDTH = HEIGHT * 1.5f;
|
||||||
public static final float PADDING = 2;
|
public static final float PADDING = Utils.scaleMin(2);
|
||||||
|
|
||||||
private static final FSkinColor BACK_COLOR = FSkinColor.get(Colors.CLR_THEME2);
|
private static final FSkinColor BACK_COLOR = FSkinColor.get(Colors.CLR_THEME2);
|
||||||
private static final FSkinColor FORE_COLOR = FSkinColor.get(Colors.CLR_TEXT);
|
private static final FSkinColor FORE_COLOR = FSkinColor.get(Colors.CLR_TEXT);
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ import forge.util.Utils;
|
|||||||
public class VStack extends FDropDown {
|
public class VStack extends FDropDown {
|
||||||
public static final float CARD_WIDTH = Utils.AVG_FINGER_WIDTH;
|
public static final float CARD_WIDTH = Utils.AVG_FINGER_WIDTH;
|
||||||
public static final float CARD_HEIGHT = Math.round(CARD_WIDTH * FCardPanel.ASPECT_RATIO);
|
public static final float CARD_HEIGHT = Math.round(CARD_WIDTH * FCardPanel.ASPECT_RATIO);
|
||||||
private static final float PADDING = 3;
|
private static final float PADDING = Utils.scaleMin(3);
|
||||||
private static final FSkinFont FONT = FSkinFont.get(11);
|
private static final FSkinFont FONT = FSkinFont.get(11);
|
||||||
private static final float ALPHA_COMPOSITE = 0.5f;
|
private static final float ALPHA_COMPOSITE = 0.5f;
|
||||||
private static final TextRenderer textRenderer = new TextRenderer(true);
|
private static final TextRenderer textRenderer = new TextRenderer(true);
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ import forge.toolbox.FLabel;
|
|||||||
import forge.toolbox.FOverlay;
|
import forge.toolbox.FOverlay;
|
||||||
import forge.toolbox.FPanel;
|
import forge.toolbox.FPanel;
|
||||||
import forge.toolbox.FTextArea;
|
import forge.toolbox.FTextArea;
|
||||||
|
import forge.util.Utils;
|
||||||
|
|
||||||
public class ViewWinLose extends FOverlay {
|
public class ViewWinLose extends FOverlay {
|
||||||
private static final float INSETS_FACTOR = 0.025f;
|
private static final float INSETS_FACTOR = 0.025f;
|
||||||
@@ -184,7 +185,7 @@ public class ViewWinLose extends FOverlay {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static class OutcomesPanel extends FContainer {
|
private static class OutcomesPanel extends FContainer {
|
||||||
private static final float LBL_HEIGHT = 20;
|
private static final float LBL_HEIGHT = Utils.scaleY(20);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void doLayout(float width, float height) {
|
protected void doLayout(float width, float height) {
|
||||||
|
|||||||
@@ -14,11 +14,12 @@ import forge.assets.FSkinImage;
|
|||||||
import forge.interfaces.IButton;
|
import forge.interfaces.IButton;
|
||||||
import forge.toolbox.FEvent.FEventHandler;
|
import forge.toolbox.FEvent.FEventHandler;
|
||||||
import forge.toolbox.FEvent.FEventType;
|
import forge.toolbox.FEvent.FEventType;
|
||||||
|
import forge.util.Utils;
|
||||||
|
|
||||||
public class FButton extends FDisplayObject implements IButton {
|
public class FButton extends FDisplayObject implements IButton {
|
||||||
private static final FSkinColor FORE_COLOR = FSkinColor.get(Colors.CLR_TEXT);
|
private static final FSkinColor FORE_COLOR = FSkinColor.get(Colors.CLR_TEXT);
|
||||||
private static final float DISABLED_COMPOSITE = 0.25f;
|
private static final float DISABLED_COMPOSITE = 0.25f;
|
||||||
private static final float PADDING = 10;
|
private static final float PADDING = Utils.scaleX(10);
|
||||||
|
|
||||||
private FSkinImage imgL, imgM, imgR;
|
private FSkinImage imgL, imgM, imgR;
|
||||||
private String text;
|
private String text;
|
||||||
|
|||||||
@@ -5,11 +5,12 @@ import com.badlogic.gdx.graphics.Texture;
|
|||||||
import forge.Forge.Graphics;
|
import forge.Forge.Graphics;
|
||||||
import forge.assets.ImageCache;
|
import forge.assets.ImageCache;
|
||||||
import forge.game.card.Card;
|
import forge.game.card.Card;
|
||||||
|
import forge.util.Utils;
|
||||||
|
|
||||||
public class FCardPanel extends FDisplayObject {
|
public class FCardPanel extends FDisplayObject {
|
||||||
public static final float TAPPED_ANGLE = -90;
|
public static final float TAPPED_ANGLE = -90;
|
||||||
public static final float ASPECT_RATIO = 3.5f / 2.5f;
|
public static final float ASPECT_RATIO = 3.5f / 2.5f;
|
||||||
public static final float PADDING = 2; //scale to leave vertical space between
|
public static final float PADDING = Utils.scaleMax(2); //scale to leave vertical space between
|
||||||
|
|
||||||
private Card card;
|
private Card card;
|
||||||
private boolean tapped;
|
private boolean tapped;
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ import forge.screens.FScreen;
|
|||||||
import forge.util.Utils;
|
import forge.util.Utils;
|
||||||
|
|
||||||
public class FList<E> extends FScrollPane implements Iterable<E> {
|
public class FList<E> extends FScrollPane implements Iterable<E> {
|
||||||
public static final float PADDING = 3;
|
public static final float PADDING = Utils.scaleMin(3);
|
||||||
public static final FSkinColor FORE_COLOR = FSkinColor.get(Colors.CLR_TEXT);
|
public static final FSkinColor FORE_COLOR = FSkinColor.get(Colors.CLR_TEXT);
|
||||||
public static final FSkinColor PRESSED_COLOR = FSkinColor.get(Colors.CLR_ACTIVE).alphaColor(0.9f);
|
public static final FSkinColor PRESSED_COLOR = FSkinColor.get(Colors.CLR_ACTIVE).alphaColor(0.9f);
|
||||||
public static final FSkinColor LINE_COLOR = FORE_COLOR.alphaColor(0.5f);
|
public static final FSkinColor LINE_COLOR = FORE_COLOR.alphaColor(0.5f);
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ public class FOptionPane extends FDialog {
|
|||||||
public static final FSkinImage WARNING_ICON = FSkinImage.WARNING;
|
public static final FSkinImage WARNING_ICON = FSkinImage.WARNING;
|
||||||
public static final FSkinImage ERROR_ICON = FSkinImage.ERROR;
|
public static final FSkinImage ERROR_ICON = FSkinImage.ERROR;
|
||||||
|
|
||||||
public static float PADDING = 10;
|
public static final float PADDING = Utils.scaleMin(10);
|
||||||
public static final float GAP_BELOW_BUTTONS = PADDING * 0.5f;
|
public static final float GAP_BELOW_BUTTONS = PADDING * 0.5f;
|
||||||
public static final float BUTTON_HEIGHT = Utils.AVG_FINGER_HEIGHT * 0.75f;
|
public static final float BUTTON_HEIGHT = Utils.AVG_FINGER_HEIGHT * 0.75f;
|
||||||
|
|
||||||
|
|||||||
@@ -11,10 +11,11 @@ import forge.assets.FSkinFont;
|
|||||||
import forge.assets.FSkinColor.Colors;
|
import forge.assets.FSkinColor.Colors;
|
||||||
import forge.toolbox.FEvent.FEventHandler;
|
import forge.toolbox.FEvent.FEventHandler;
|
||||||
import forge.toolbox.FEvent.FEventType;
|
import forge.toolbox.FEvent.FEventType;
|
||||||
|
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 int DEFAULT_FONT_SIZE = 14;
|
||||||
protected static final float PADDING = 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);
|
||||||
protected static final FSkinColor BACK_COLOR = FSkinColor.get(Colors.CLR_THEME2);
|
protected static final FSkinColor BACK_COLOR = FSkinColor.get(Colors.CLR_THEME2);
|
||||||
protected static final FSkinColor GHOST_TEXT_COLOR = FORE_COLOR.alphaColor(0.7f);
|
protected static final FSkinColor GHOST_TEXT_COLOR = FORE_COLOR.alphaColor(0.7f);
|
||||||
|
|||||||
@@ -8,14 +8,15 @@ import forge.assets.FSkinColor.Colors;
|
|||||||
import forge.assets.FSkinFont;
|
import forge.assets.FSkinFont;
|
||||||
import forge.toolbox.FEvent.FEventHandler;
|
import forge.toolbox.FEvent.FEventHandler;
|
||||||
import forge.toolbox.FEvent.FEventType;
|
import forge.toolbox.FEvent.FEventType;
|
||||||
|
import forge.util.Utils;
|
||||||
|
|
||||||
public class FToggleSwitch extends FDisplayObject {
|
public class FToggleSwitch extends FDisplayObject {
|
||||||
private static final FSkinColor ACTIVE_COLOR = FSkinColor.get(Colors.CLR_ACTIVE);
|
private static final FSkinColor ACTIVE_COLOR = FSkinColor.get(Colors.CLR_ACTIVE);
|
||||||
private static final FSkinColor PRESSED_COLOR = ACTIVE_COLOR.stepColor(-30);
|
private static final FSkinColor PRESSED_COLOR = ACTIVE_COLOR.stepColor(-30);
|
||||||
private static final FSkinColor INACTIVE_COLOR = FSkinColor.get(Colors.CLR_INACTIVE);
|
private static final FSkinColor INACTIVE_COLOR = FSkinColor.get(Colors.CLR_INACTIVE);
|
||||||
private static final FSkinColor FORE_COLOR = FSkinColor.get(Colors.CLR_TEXT);
|
private static final FSkinColor FORE_COLOR = FSkinColor.get(Colors.CLR_TEXT);
|
||||||
private static final float INSETS = 2;
|
private static final float INSETS = Utils.scaleMin(2);
|
||||||
private static final float PADDING = 3;
|
private static final float PADDING = Utils.scaleMin(3);
|
||||||
|
|
||||||
private FSkinFont font;
|
private FSkinFont font;
|
||||||
private final String offText, onText;
|
private final String offText, onText;
|
||||||
|
|||||||
@@ -3,12 +3,18 @@ package forge.util;
|
|||||||
import com.badlogic.gdx.Gdx;
|
import com.badlogic.gdx.Gdx;
|
||||||
|
|
||||||
public class Utils {
|
public class Utils {
|
||||||
private final static float ppcX = Gdx.graphics.getPpcX();
|
private static final float ppcX = Gdx.graphics.getPpcX();
|
||||||
private final static float ppcY = Gdx.graphics.getPpcY();
|
private static final float ppcY = Gdx.graphics.getPpcY();
|
||||||
private final static float AVG_FINGER_SIZE_CM = 1.1f;
|
private static final float AVG_FINGER_SIZE_CM = 1.1f;
|
||||||
|
public static final float AVG_FINGER_WIDTH = Math.round(cmToPixelsX(AVG_FINGER_SIZE_CM)); //round to nearest int to reduce floating point display issues
|
||||||
|
public static final float AVG_FINGER_HEIGHT = Math.round(cmToPixelsY(AVG_FINGER_SIZE_CM));
|
||||||
|
|
||||||
public final static float AVG_FINGER_WIDTH = Math.round(cmToPixelsX(AVG_FINGER_SIZE_CM)); //round to nearest int to reduce floating point display issues
|
public static final float BASE_WIDTH = 320f;
|
||||||
public final static float AVG_FINGER_HEIGHT = Math.round(cmToPixelsY(AVG_FINGER_SIZE_CM));
|
public static final float BASE_HEIGHT = 480f;
|
||||||
|
public static final float WIDTH_RATIO = ((float)Gdx.graphics.getWidth() / BASE_WIDTH);
|
||||||
|
public static final float HEIGHT_RATIO = ((float)Gdx.graphics.getHeight() / BASE_HEIGHT);
|
||||||
|
public static final float MIN_RATIO = Math.min(WIDTH_RATIO, HEIGHT_RATIO);
|
||||||
|
public static final float MAX_RATIO = Math.max(WIDTH_RATIO, HEIGHT_RATIO);
|
||||||
|
|
||||||
public static float cmToPixelsX(float cm) {
|
public static float cmToPixelsX(float cm) {
|
||||||
return ppcX * cm;
|
return ppcX * cm;
|
||||||
@@ -17,6 +23,22 @@ public class Utils {
|
|||||||
return ppcY * cm;
|
return ppcY * cm;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static float scaleX(float value) {
|
||||||
|
return Math.round(value * WIDTH_RATIO);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static float scaleY(float value) {
|
||||||
|
return Math.round(value * HEIGHT_RATIO);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static float scaleMin(float value) {
|
||||||
|
return Math.round(value * MIN_RATIO);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static float scaleMax(float value) {
|
||||||
|
return Math.round(value * MAX_RATIO);
|
||||||
|
}
|
||||||
|
|
||||||
public static long secondsToTimeSpan(float seconds) {
|
public static long secondsToTimeSpan(float seconds) {
|
||||||
return (long)(seconds * 1000000000l);
|
return (long)(seconds * 1000000000l);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user