Update Start Button

This commit is contained in:
Anthony Calosa
2020-02-23 22:38:33 +08:00
parent 81c06f230a
commit eb039b3bdd
7 changed files with 30 additions and 4 deletions

View File

@@ -67,6 +67,7 @@ public class Forge implements ApplicationListener {
public static boolean enablePreloadExtendedArt = false; public static boolean enablePreloadExtendedArt = false;
public static String locale = "en-US"; public static String locale = "en-US";
public static boolean hdbuttons = false; public static boolean hdbuttons = false;
public static boolean hdstart = false;
public static ApplicationListener getApp(Clipboard clipboard0, IDeviceAdapter deviceAdapter0, String assetDir0, boolean value) { public static ApplicationListener getApp(Clipboard clipboard0, IDeviceAdapter deviceAdapter0, String assetDir0, boolean value) {
if (GuiBase.getInterface() == null) { if (GuiBase.getInterface() == null) {

View File

@@ -191,6 +191,7 @@ public class FSkin {
final FileHandle f9 = getDefaultSkinFile(ForgeConstants.SPRITE_SLEEVES2_FILE); final FileHandle f9 = getDefaultSkinFile(ForgeConstants.SPRITE_SLEEVES2_FILE);
final FileHandle f10 = getDefaultSkinFile(ForgeConstants.SPRITE_BORDER_FILE); final FileHandle f10 = getDefaultSkinFile(ForgeConstants.SPRITE_BORDER_FILE);
final FileHandle f11 = getSkinFile(ForgeConstants.SPRITE_BUTTONS_FILE); final FileHandle f11 = getSkinFile(ForgeConstants.SPRITE_BUTTONS_FILE);
final FileHandle f12 = getSkinFile(ForgeConstants.SPRITE_START_FILE);
try { try {
textures.put(f1.path(), new Texture(f1)); textures.put(f1.path(), new Texture(f1));
@@ -215,6 +216,12 @@ public class FSkin {
textures.put(f11.path(), tf11); textures.put(f11.path(), tf11);
Forge.hdbuttons = true; Forge.hdbuttons = true;
} else { Forge.hdbuttons = false; } //how to refresh buttons when a theme don't have hd buttons? } else { Forge.hdbuttons = false; } //how to refresh buttons when a theme don't have hd buttons?
if (f12.exists()) {
Texture tf12 = new Texture(f12, true);
tf12.setFilter(Texture.TextureFilter.MipMapLinearLinear, Texture.TextureFilter.Linear);
textures.put(f12.path(), tf12);
Forge.hdstart = true;
} else { Forge.hdstart = false; }
//update colors //update colors
for (final FSkinColor.Colors c : FSkinColor.Colors.values()) { for (final FSkinColor.Colors c : FSkinColor.Colors.values()) {
c.setColor(new Color(preferredIcons.getPixel(c.getX(), c.getY()))); c.setColor(new Color(preferredIcons.getPixel(c.getX(), c.getY())));

View File

@@ -229,6 +229,9 @@ public enum FSkinImage implements FImage {
BTN_DISABLED_CENTER (FSkinProp.IMG_BTN_DISABLED_CENTER, SourceFile.ICONS), BTN_DISABLED_CENTER (FSkinProp.IMG_BTN_DISABLED_CENTER, SourceFile.ICONS),
BTN_DISABLED_RIGHT (FSkinProp.IMG_BTN_DISABLED_RIGHT, SourceFile.ICONS), BTN_DISABLED_RIGHT (FSkinProp.IMG_BTN_DISABLED_RIGHT, SourceFile.ICONS),
//Hdbuttons //Hdbuttons
HDBTN_START_UP (FSkinProp.IMG_HDBTN_START_UP, SourceFile.BTNSTART),
HDBTN_START_OVER (FSkinProp.IMG_HDBTN_START_OVER, SourceFile.BTNSTART),
HDBTN_START_DOWN (FSkinProp.IMG_HDBTN_START_DOWN, SourceFile.BTNSTART),
HDBTN_UP_LEFT (FSkinProp.IMG_HDBTN_UP_LEFT, SourceFile.BUTTONS), HDBTN_UP_LEFT (FSkinProp.IMG_HDBTN_UP_LEFT, SourceFile.BUTTONS),
HDBTN_UP_CENTER (FSkinProp.IMG_HDBTN_UP_CENTER, SourceFile.BUTTONS), HDBTN_UP_CENTER (FSkinProp.IMG_HDBTN_UP_CENTER, SourceFile.BUTTONS),
HDBTN_UP_RIGHT (FSkinProp.IMG_HDBTN_UP_RIGHT, SourceFile.BUTTONS), HDBTN_UP_RIGHT (FSkinProp.IMG_HDBTN_UP_RIGHT, SourceFile.BUTTONS),
@@ -332,6 +335,7 @@ public enum FSkinImage implements FImage {
ABILITIES(ForgeConstants.SPRITE_ABILITY_FILE), ABILITIES(ForgeConstants.SPRITE_ABILITY_FILE),
BORDERS(ForgeConstants.SPRITE_BORDER_FILE), BORDERS(ForgeConstants.SPRITE_BORDER_FILE),
BUTTONS(ForgeConstants.SPRITE_BUTTONS_FILE), BUTTONS(ForgeConstants.SPRITE_BUTTONS_FILE),
BTNSTART(ForgeConstants.SPRITE_START_FILE),
MANAICONS(ForgeConstants.SPRITE_MANAICONS_FILE), MANAICONS(ForgeConstants.SPRITE_MANAICONS_FILE),
PLANAR_CONQUEST(ForgeConstants.SPRITE_PLANAR_CONQUEST_FILE); PLANAR_CONQUEST(ForgeConstants.SPRITE_PLANAR_CONQUEST_FILE);

View File

@@ -12,7 +12,7 @@ import forge.util.Utils;
public abstract class LaunchScreen extends FScreen { public abstract class LaunchScreen extends FScreen {
private static final float MAX_START_BUTTON_HEIGHT = 2 * Utils.AVG_FINGER_HEIGHT; private static final float MAX_START_BUTTON_HEIGHT = 2 * Utils.AVG_FINGER_HEIGHT;
private static final float START_BUTTON_RATIO = FSkinImage.BTN_START_UP.getWidth() / FSkinImage.BTN_START_UP.getHeight(); private float START_BUTTON_RATIO = 0.f;
private static final float PADDING = FOptionPane.PADDING; private static final float PADDING = FOptionPane.PADDING;
protected final StartButton btnStart = add(new StartButton()); protected final StartButton btnStart = add(new StartButton());
@@ -26,6 +26,11 @@ public abstract class LaunchScreen extends FScreen {
@Override @Override
protected final void doLayout(float startY, float width, float height) { protected final void doLayout(float startY, float width, float height) {
if (Forge.hdstart)
START_BUTTON_RATIO = FSkinImage.HDBTN_START_UP.getWidth() / FSkinImage.HDBTN_START_UP.getHeight();
else
START_BUTTON_RATIO = FSkinImage.BTN_START_UP.getWidth() / FSkinImage.BTN_START_UP.getHeight();
float buttonWidth = width - 2 * PADDING; float buttonWidth = width - 2 * PADDING;
float buttonHeight = buttonWidth / START_BUTTON_RATIO; float buttonHeight = buttonWidth / START_BUTTON_RATIO;
if (buttonHeight > MAX_START_BUTTON_HEIGHT) { if (buttonHeight > MAX_START_BUTTON_HEIGHT) {
@@ -72,8 +77,12 @@ public abstract class LaunchScreen extends FScreen {
@Override @Override
public void draw(Graphics g) { public void draw(Graphics g) {
g.drawImage(pressed ? FSkinImage.BTN_START_DOWN : FSkinImage.BTN_START_UP, if (Forge.hdstart)
g.drawImage(pressed ? FSkinImage.HDBTN_START_DOWN : FSkinImage.HDBTN_START_UP,
0, 0, getWidth(), getHeight()); 0, 0, getWidth(), getHeight());
else
g.drawImage(pressed ? FSkinImage.BTN_START_DOWN : FSkinImage.BTN_START_UP,
0, 0, getWidth(), getHeight());
//its must be enabled or you can't start any game modes //its must be enabled or you can't start any game modes
if (!Forge.isLoadingaMatch()) { if (!Forge.isLoadingaMatch()) {
if(!btnStart.isEnabled()) if(!btnStart.isEnabled())

Binary file not shown.

After

Width:  |  Height:  |  Size: 142 KiB

View File

@@ -285,6 +285,9 @@ public enum FSkinProp {
IMG_BTN_DISABLED_CENTER (new int[] {120, 200, 1, 40}, PropType.ICON), IMG_BTN_DISABLED_CENTER (new int[] {120, 200, 1, 40}, PropType.ICON),
IMG_BTN_DISABLED_RIGHT (new int[] {160, 200, 40, 40}, PropType.ICON), IMG_BTN_DISABLED_RIGHT (new int[] {160, 200, 40, 40}, PropType.ICON),
//hd buttons //hd buttons
IMG_HDBTN_START_UP (new int[] {2, 2, 588, 312}, PropType.BTNSTART),
IMG_HDBTN_START_OVER (new int[] {1183, 2, 588, 312}, PropType.BTNSTART),
IMG_HDBTN_START_DOWN (new int[] {593, 2, 588, 312}, PropType.BTNSTART),
IMG_HDBTN_UP_LEFT (new int[] {2, 2, 160, 165}, PropType.BUTTONS), IMG_HDBTN_UP_LEFT (new int[] {2, 2, 160, 165}, PropType.BUTTONS),
IMG_HDBTN_UP_CENTER (new int[] {162, 2, 1, 165}, PropType.BUTTONS), IMG_HDBTN_UP_CENTER (new int[] {162, 2, 1, 165}, PropType.BUTTONS),
IMG_HDBTN_UP_RIGHT (new int[] {322, 2, 160, 165}, PropType.BUTTONS), IMG_HDBTN_UP_RIGHT (new int[] {322, 2, 160, 165}, PropType.BUTTONS),
@@ -398,6 +401,7 @@ public enum FSkinProp {
ABILITY, ABILITY,
BORDERS, BORDERS,
BUTTONS, BUTTONS,
BTNSTART,
MANAICONS, MANAICONS,
PLANAR_CONQUEST, PLANAR_CONQUEST,
FAVICON FAVICON

View File

@@ -95,11 +95,12 @@ public final class ForgeConstants {
public static final String SPRITE_TROPHIES_FILE = "sprite_trophies.png"; public static final String SPRITE_TROPHIES_FILE = "sprite_trophies.png";
public static final String SPRITE_ABILITY_FILE = "sprite_ability.png"; public static final String SPRITE_ABILITY_FILE = "sprite_ability.png";
public static final String SPRITE_BORDER_FILE = "sprite_border.png"; public static final String SPRITE_BORDER_FILE = "sprite_border.png";
public static final String SPRITE_BUTTONS_FILE = "sprite_buttons.png"; public static final String SPRITE_BUTTONS_FILE = "sprite_buttons.png";
public static final String SPRITE_START_FILE = "sprite_start.png";
public static final String SPRITE_MANAICONS_FILE = "sprite_manaicons.png"; public static final String SPRITE_MANAICONS_FILE = "sprite_manaicons.png";
public static final String SPRITE_AVATARS_FILE = "sprite_avatars.png"; public static final String SPRITE_AVATARS_FILE = "sprite_avatars.png";
public static final String SPRITE_SLEEVES_FILE = "sprite_sleeves.png"; public static final String SPRITE_SLEEVES_FILE = "sprite_sleeves.png";
public static final String SPRITE_SLEEVES2_FILE = "sprite_sleeves2.png"; public static final String SPRITE_SLEEVES2_FILE = "sprite_sleeves2.png";
public static final String SPRITE_FAVICONS_FILE = "sprite_favicons.png"; public static final String SPRITE_FAVICONS_FILE = "sprite_favicons.png";
public static final String SPRITE_PLANAR_CONQUEST_FILE = "sprite_planar_conquest.png"; public static final String SPRITE_PLANAR_CONQUEST_FILE = "sprite_planar_conquest.png";
public static final String FONT_FILE = "font1.ttf"; public static final String FONT_FILE = "font1.ttf";