From fde28d1fea52112ba4eb03a91a15fe649638d416 Mon Sep 17 00:00:00 2001 From: Anthony Calosa Date: Wed, 28 Oct 2020 06:19:12 +0800 Subject: [PATCH] Add alternate preference for displaying life, experience, energy and poison counters --- forge-gui-mobile/src/forge/Forge.java | 2 + .../forge/screens/match/views/VAvatar.java | 4 + .../screens/match/views/VPlayerPanel.java | 73 ++++++++++++++----- .../forge/screens/settings/SettingsPage.java | 10 +++ forge-gui/res/languages/de-DE.properties | 2 + forge-gui/res/languages/en-US.properties | 2 + forge-gui/res/languages/es-ES.properties | 2 + forge-gui/res/languages/it-IT.properties | 2 + forge-gui/res/languages/zh-CN.properties | 2 + .../forge/properties/ForgePreferences.java | 1 + 10 files changed, 83 insertions(+), 17 deletions(-) diff --git a/forge-gui-mobile/src/forge/Forge.java b/forge-gui-mobile/src/forge/Forge.java index 882bf66d0dc..b3c1766f26b 100644 --- a/forge-gui-mobile/src/forge/Forge.java +++ b/forge-gui-mobile/src/forge/Forge.java @@ -64,6 +64,7 @@ public class Forge implements ApplicationListener { public static float heigtModifier = 0.0f; private static boolean isloadingaMatch = false; public static boolean showFPS = false; + public static boolean altPlayerLayout = false; public static boolean enableUIMask = false; public static boolean enablePreloadExtendedArt = false; public static String locale = "en-US"; @@ -123,6 +124,7 @@ public class Forge implements ApplicationListener { textureFiltering = prefs.getPrefBoolean(FPref.UI_LIBGDX_TEXTURE_FILTERING); showFPS = prefs.getPrefBoolean(FPref.UI_SHOW_FPS); + altPlayerLayout = prefs.getPrefBoolean(FPref.UI_ALT_PLAYERINFOLAYOUT); enableUIMask = prefs.getPrefBoolean(FPref.UI_ENABLE_BORDER_MASKING); enablePreloadExtendedArt = prefs.getPrefBoolean(FPref.UI_ENABLE_PRELOAD_EXTENDED_ART); locale = prefs.getPref(FPref.UI_LANGUAGE); diff --git a/forge-gui-mobile/src/forge/screens/match/views/VAvatar.java b/forge-gui-mobile/src/forge/screens/match/views/VAvatar.java index fed9fdb447f..4c28fcd56c8 100644 --- a/forge-gui-mobile/src/forge/screens/match/views/VAvatar.java +++ b/forge-gui-mobile/src/forge/screens/match/views/VAvatar.java @@ -4,6 +4,7 @@ import com.badlogic.gdx.graphics.Color; import com.badlogic.gdx.math.Vector2; import com.badlogic.gdx.utils.Align; +import forge.Forge; import forge.Graphics; import forge.assets.FImage; import forge.assets.FSkinFont; @@ -69,6 +70,9 @@ public class VAvatar extends FDisplayObject { float h = getHeight(); g.drawImage(image, 0, 0, w, h); + if (Forge.altPlayerLayout && Forge.isLandscapeMode()) + return; + //display XP in lower right corner of avatar int xp = player.getCounters(CounterEnumType.EXPERIENCE); if (xp > 0) { diff --git a/forge-gui-mobile/src/forge/screens/match/views/VPlayerPanel.java b/forge-gui-mobile/src/forge/screens/match/views/VPlayerPanel.java index 4ecb51acf9d..6caaa9b4b8c 100644 --- a/forge-gui-mobile/src/forge/screens/match/views/VPlayerPanel.java +++ b/forge-gui-mobile/src/forge/screens/match/views/VPlayerPanel.java @@ -6,6 +6,7 @@ import java.util.List; import java.util.Map; import com.badlogic.gdx.Gdx; +import com.badlogic.gdx.graphics.Color; import com.badlogic.gdx.utils.Align; import forge.Forge; @@ -30,6 +31,7 @@ import forge.util.Utils; public class VPlayerPanel extends FContainer { private static final FSkinFont LIFE_FONT = FSkinFont.get(18); private static final FSkinFont INFO_FONT = FSkinFont.get(12); + private static final FSkinFont INFO2_FONT = FSkinFont.get(14); private static final FSkinColor INFO_FORE_COLOR = FSkinColor.get(Colors.CLR_TEXT); private static final FSkinColor DISPLAY_AREA_BACK_COLOR = FSkinColor.get(Colors.CLR_INACTIVE).alphaColor(0.5f); private static final FSkinColor DELIRIUM_HIGHLIGHT = FSkinColor.get(Colors.CLR_PHASE_ACTIVE_ENABLED).alphaColor(0.5f); @@ -49,6 +51,7 @@ public class VPlayerPanel extends FContainer { private float avatarHeight = VAvatar.HEIGHT; private float displayAreaHeightFactor = 1.0f; private boolean forMultiPlayer = false; + public int adjustHeight = 1; public VPlayerPanel(PlayerView player0, boolean showHand, int playerCount) { player = player0; @@ -285,8 +288,14 @@ public class VPlayerPanel extends FContainer { float y = 0; avatar.setPosition(x, y); y += avatar.getHeight(); - lblLife.setBounds(x, y, avatar.getWidth(), LIFE_FONT.getLineHeight()); - y += lblLife.getHeight(); + + lblLife.setBounds(x, Forge.altPlayerLayout ? 0 : y, avatar.getWidth(), Forge.altPlayerLayout ? INFO_FONT.getLineHeight() : LIFE_FONT.getLineHeight()); + if (Forge.altPlayerLayout) { + if (adjustHeight > 2) + y += INFO_FONT.getLineHeight()/2; + } else + y += lblLife.getHeight(); + float infoTabWidth = avatar.getWidth(); float infoTabHeight = (height - y) / tabs.size(); for (InfoTab tab : tabs) { @@ -362,6 +371,7 @@ public class VPlayerPanel extends FContainer { private int life = player.getLife(); private int poisonCounters = player.getCounters(CounterEnumType.POISON); private int energyCounters = player.getCounters(CounterEnumType.ENERGY); + private int experienceCounters = player.getCounters(CounterEnumType.EXPERIENCE); private String lifeStr = String.valueOf(life); private LifeLabel() { @@ -389,6 +399,7 @@ public class VPlayerPanel extends FContainer { } energyCounters = player.getCounters(CounterEnumType.ENERGY); + experienceCounters = player.getCounters(CounterEnumType.EXPERIENCE); //when gui player loses life, vibrate device for a length of time based on amount of life lost if (vibrateDuration > 0 && MatchController.instance.isLocalPlayer(player) && @@ -406,22 +417,50 @@ public class VPlayerPanel extends FContainer { @Override public void draw(Graphics g) { - if (poisonCounters == 0 && energyCounters == 0) { - g.drawText(lifeStr, LIFE_FONT, INFO_FORE_COLOR, 0, 0, getWidth(), getHeight(), false, Align.center, true); - } - else { - float halfHeight = getHeight() / 2; - float textStart = halfHeight + Utils.scale(1); - float textWidth = getWidth() - textStart; - g.drawImage(FSkinImage.QUEST_LIFE, 0, 0, halfHeight, halfHeight); - g.drawText(lifeStr, INFO_FONT, INFO_FORE_COLOR, textStart, 0, textWidth, halfHeight, false, Align.center, true); - if (poisonCounters > 0) { //prioritize showing poison counters over energy counters - g.drawImage(FSkinImage.POISON, 0, halfHeight, halfHeight, halfHeight); - g.drawText(String.valueOf(poisonCounters), INFO_FONT, INFO_FORE_COLOR, textStart, halfHeight, textWidth, halfHeight, false, Align.center, true); + adjustHeight = 1; + if(Forge.altPlayerLayout && Forge.isLandscapeMode()) { + if (poisonCounters == 0 && energyCounters == 0 && experienceCounters == 0) { + g.drawOutlinedText(lifeStr, INFO2_FONT, INFO_FORE_COLOR.getColor(), Color.BLACK, 0, 0, getWidth(), getHeight(), false, Align.left, false); + } else { + float halfHeight = getHeight() / 2; + float textStart = halfHeight + Utils.scale(1); + float textWidth = getWidth() - textStart; + int mod = 1; + g.drawImage(FSkinImage.QUEST_LIFE, 0, 0, halfHeight, halfHeight); + g.drawOutlinedText(lifeStr, INFO_FONT, INFO_FORE_COLOR.getColor(), Color.BLACK, textStart, 0, textWidth, halfHeight, false, Align.left, false); + if (poisonCounters > 0) { + g.drawImage(FSkinImage.POISON, 0, halfHeight+2, halfHeight, halfHeight); + g.drawOutlinedText(String.valueOf(poisonCounters), INFO_FONT, INFO_FORE_COLOR.getColor(), Color.BLACK, textStart, halfHeight+2, textWidth, halfHeight, false, Align.left, false); + mod+=1; + } + if (energyCounters > 0) { + g.drawImage(FSkinImage.ENERGY, 0, (halfHeight*mod)+2, halfHeight, halfHeight); + g.drawOutlinedText(String.valueOf(energyCounters), INFO_FONT, INFO_FORE_COLOR.getColor(), Color.BLACK, textStart, (halfHeight*mod)+2, textWidth, halfHeight, false, Align.left, false); + mod+=1; + } + if (experienceCounters > 0) { + g.drawImage(FSkinImage.COMMANDER, 0, (halfHeight*mod)+2, halfHeight, halfHeight); + g.drawOutlinedText(String.valueOf(experienceCounters), INFO_FONT, INFO_FORE_COLOR.getColor(), Color.BLACK, textStart, (halfHeight*mod)+2, textWidth, halfHeight, false, Align.left, false); + mod+=1; + } + adjustHeight = (mod > 2) && (avatar.getHeight() < halfHeight*mod)? mod : 1; } - else { - g.drawImage(FSkinImage.ENERGY, 0, halfHeight, halfHeight, halfHeight); - g.drawText(String.valueOf(energyCounters), INFO_FONT, INFO_FORE_COLOR, textStart, halfHeight, textWidth, halfHeight, false, Align.center, true); + } else { + if (poisonCounters == 0 && energyCounters == 0) { + g.drawText(lifeStr, LIFE_FONT, INFO_FORE_COLOR, 0, 0, getWidth(), getHeight(), false, Align.center, true); + } else { + float halfHeight = getHeight() / 2; + float textStart = halfHeight + Utils.scale(1); + float textWidth = getWidth() - textStart; + g.drawImage(FSkinImage.QUEST_LIFE, 0, 0, halfHeight, halfHeight); + g.drawText(lifeStr, INFO_FONT, INFO_FORE_COLOR, textStart, 0, textWidth, halfHeight, false, Align.center, true); + if (poisonCounters > 0) { //prioritize showing poison counters over energy counters + g.drawImage(FSkinImage.POISON, 0, halfHeight, halfHeight, halfHeight); + g.drawText(String.valueOf(poisonCounters), INFO_FONT, INFO_FORE_COLOR, textStart, halfHeight, textWidth, halfHeight, false, Align.center, true); + } else { + g.drawImage(FSkinImage.ENERGY, 0, halfHeight, halfHeight, halfHeight); + g.drawText(String.valueOf(energyCounters), INFO_FONT, INFO_FORE_COLOR, textStart, halfHeight, textWidth, halfHeight, false, Align.center, true); + } } } } diff --git a/forge-gui-mobile/src/forge/screens/settings/SettingsPage.java b/forge-gui-mobile/src/forge/screens/settings/SettingsPage.java index 07ae5fe7f98..c55b92edbba 100644 --- a/forge-gui-mobile/src/forge/screens/settings/SettingsPage.java +++ b/forge-gui-mobile/src/forge/screens/settings/SettingsPage.java @@ -190,6 +190,16 @@ public class SettingsPage extends TabPage { localizer.getMessage("cbEscapeEndsTurn"), localizer.getMessage("nlEscapeEndsTurn")), 1); + lstSettings.addItem(new BooleanSetting(FPref.UI_ALT_PLAYERINFOLAYOUT, + localizer.getMessage("lblAltLifeDisplay"), + localizer.getMessage("nlAltLifeDisplay")){ + @Override + public void select() { + super.select(); + //update + Forge.altPlayerLayout = FModel.getPreferences().getPrefBoolean(FPref.UI_ALT_PLAYERINFOLAYOUT); + } + },1); //Random Deck Generation lstSettings.addItem(new BooleanSetting(FPref.DECKGEN_NOSMALL, diff --git a/forge-gui/res/languages/de-DE.properties b/forge-gui/res/languages/de-DE.properties index d2ea02c07c9..f93aa1839d8 100644 --- a/forge-gui/res/languages/de-DE.properties +++ b/forge-gui/res/languages/de-DE.properties @@ -113,6 +113,8 @@ cbpAutoYieldMode=Automatische Bestätigung cbpCounterDisplayType=Markeranzeige Art cbpCounterDisplayLocation=Markeranzeige Ort cbpGraveyardOrdering=Genaue Reihenfolge im Friedhof einhalten +lblAltLifeDisplay=Alternate Player Layout (Landscape Mode) +nlAltLifeDisplay=Enables alternate layout for displaying Player Life, Poison, Energy and Experience counters. Troubleshooting=Fehlerbehebung GeneralConfiguration=Allgemeine Einstellungen lblPlayerName=Spielername diff --git a/forge-gui/res/languages/en-US.properties b/forge-gui/res/languages/en-US.properties index 003cc5fdd1a..34539fa15c2 100644 --- a/forge-gui/res/languages/en-US.properties +++ b/forge-gui/res/languages/en-US.properties @@ -113,6 +113,8 @@ cbpAutoYieldMode=Auto-Yield cbpCounterDisplayType=Counter Display Type cbpCounterDisplayLocation=Counter Display Location cbpGraveyardOrdering=Allow Ordering Cards Put in Graveyard +lblAltLifeDisplay=Alternate Player Layout (Landscape Mode) +nlAltLifeDisplay=Enables alternate layout for displaying Player Life, Poison, Energy and Experience counters. Troubleshooting=Troubleshooting GeneralConfiguration=General Configuration lblPlayerName=Player Name diff --git a/forge-gui/res/languages/es-ES.properties b/forge-gui/res/languages/es-ES.properties index 7d13f02755e..9f69c518280 100644 --- a/forge-gui/res/languages/es-ES.properties +++ b/forge-gui/res/languages/es-ES.properties @@ -113,6 +113,8 @@ cbpAutoYieldMode=Auto-Ceder cbpCounterDisplayType=Estilo de los contadores cbpCounterDisplayLocation=Ubicación del contador cbpGraveyardOrdering=Permitir ordenar cartas puestas en el cementerio +lblAltLifeDisplay=Alternate Player Layout (Landscape Mode) +nlAltLifeDisplay=Enables alternate layout for displaying Player Life, Poison, Energy and Experience counters. Troubleshooting=Solución de problemas GeneralConfiguration=Configuración general lblPlayerName=Nombre Jugador diff --git a/forge-gui/res/languages/it-IT.properties b/forge-gui/res/languages/it-IT.properties index 27ff412e3cb..ab02bf062f0 100644 --- a/forge-gui/res/languages/it-IT.properties +++ b/forge-gui/res/languages/it-IT.properties @@ -113,6 +113,8 @@ cbpAutoYieldMode=Auto-Yield cbpCounterDisplayType=Tipo di display contatore cbpCounterDisplayLocation=Posizione display contatore cbpGraveyardOrdering=Consenti l''ordinazione di carte messe nel cimitero +lblAltLifeDisplay=Alternate Player Layout (Landscape Mode) +nlAltLifeDisplay=Enables alternate layout for displaying Player Life, Poison, Energy and Experience counters. Troubleshooting=Risoluzione dei problemi GeneralConfiguration=Configurazione generale lblPlayerName=Nome del giocatore diff --git a/forge-gui/res/languages/zh-CN.properties b/forge-gui/res/languages/zh-CN.properties index d311c8ab8aa..56a13df3643 100644 --- a/forge-gui/res/languages/zh-CN.properties +++ b/forge-gui/res/languages/zh-CN.properties @@ -113,6 +113,8 @@ cbpAutoYieldMode=自动让过 cbpCounterDisplayType=计数器显示类型 cbpCounterDisplayLocation=计数器显示区域 cbpGraveyardOrdering=允许指衍生物进入墓地 +lblAltLifeDisplay=Alternate Player Layout (Landscape Mode) +nlAltLifeDisplay=Enables alternate layout for displaying Player Life, Poison, Energy and Experience counters. Troubleshooting=故障排除 GeneralConfiguration=常规配置 lblPlayerName=玩家名称 diff --git a/forge-gui/src/main/java/forge/properties/ForgePreferences.java b/forge-gui/src/main/java/forge/properties/ForgePreferences.java index 679b2922e96..8526e1ace69 100644 --- a/forge-gui/src/main/java/forge/properties/ForgePreferences.java +++ b/forge-gui/src/main/java/forge/properties/ForgePreferences.java @@ -127,6 +127,7 @@ public class ForgePreferences extends PreferencesStore { UI_DISPLAY_CURRENT_COLORS(ForgeConstants.DISP_CURRENT_COLORS_NEVER), UI_FILTER_LANDS_BY_COLOR_IDENTITY("true"), UI_ALLOW_ESC_TO_END_TURN ("false"), + UI_ALT_PLAYERINFOLAYOUT ("false"), UI_PRESELECT_PREVIOUS_ABILITY_ORDER ("false"), UI_AUTO_YIELD_MODE (ForgeConstants.AUTO_YIELD_PER_ABILITY), UI_SHOW_STORM_COUNT_IN_PROMPT ("false"),