Merge branch 'master' into 'master'

[Mobile] add Alternate Player Zone Layout (Landscape)

See merge request core-developers/forge!4658
This commit is contained in:
Anthony Calosa
2021-05-05 03:53:49 +00:00
15 changed files with 102 additions and 12 deletions

View File

@@ -68,6 +68,7 @@ public class Forge implements ApplicationListener {
private static boolean isloadingaMatch = false;
public static boolean showFPS = false;
public static boolean altPlayerLayout = false;
public static boolean altZoneTabs = false;
public static String enableUIMask = "Crop";
public static boolean enablePreloadExtendedArt = false;
public static boolean isTabletDevice = false;
@@ -136,6 +137,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);
altZoneTabs = prefs.getPrefBoolean(FPref.UI_ALT_PLAYERZONETABS);
enableUIMask = prefs.getPref(FPref.UI_ENABLE_BORDER_MASKING);
if (prefs.getPref(FPref.UI_ENABLE_BORDER_MASKING).equals("true")) //override old settings if not updated
enableUIMask = "Full";

View File

@@ -474,6 +474,11 @@ public class MatchController extends AbstractGuiGame {
//view = null;
}
public void resetPlayerPanels() {
if (view != null)
view.forceRevalidate();
}
private static void actuateMatchPreferences() {
final ForgePreferences prefs = FModel.getPreferences();

View File

@@ -535,6 +535,13 @@ public class MatchScreen extends FScreen {
}
}
public void forceRevalidate() {
for (VPlayerPanel playerPanel : getPlayerPanels().values()) {
playerPanel.revalidate(true);
}
}
public void updateZones(final Iterable<PlayerZoneUpdate> zonesToUpdate) {
for (final PlayerZoneUpdate update : zonesToUpdate) {
final PlayerView owner = update.getPlayer();

View File

@@ -70,7 +70,7 @@ public class VAvatar extends FDisplayObject {
float h = getHeight();
g.drawImage(image, 0, 0, w, h);
if (Forge.altPlayerLayout && Forge.isLandscapeMode())
if (Forge.altPlayerLayout && !Forge.altZoneTabs && Forge.isLandscapeMode())
return;
//display XP in lower right corner of avatar

View File

@@ -15,6 +15,7 @@ public class VField extends FContainer {
private final FieldRow row1, row2;
private boolean flipped;
private float commandZoneWidth;
private float fieldModifier;
public VField(PlayerView player0) {
player = player0;
@@ -162,6 +163,10 @@ public class VField extends FContainer {
commandZoneWidth = commandZoneWidth0;
}
void setFieldModifier(float fieldModifierWidth) {
fieldModifier = fieldModifierWidth;
}
@Override
public void clear() {
row1.clear(); //clear rows instead of removing the rows
@@ -180,8 +185,8 @@ public class VField extends FContainer {
y1 = 0;
y2 = cardSize;
}
row1.setBounds(0, y1, width, cardSize);
row2.setBounds(0, y2, width - commandZoneWidth, cardSize);
row1.setBounds(0, y1, width-fieldModifier, cardSize);
row2.setBounds(0, y2, (width - commandZoneWidth)-fieldModifier, cardSize);
}
public class FieldRow extends VCardDisplayArea {

View File

@@ -30,6 +30,7 @@ import forge.util.Utils;
public class VPlayerPanel extends FContainer {
private static final FSkinFont LIFE_FONT = FSkinFont.get(18);
private static final FSkinFont LIFE_FONT_ALT = FSkinFont.get(22);
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);
@@ -116,6 +117,18 @@ public class VPlayerPanel extends FContainer {
return null;
}
private boolean isAltZoneDisplay(InfoTab tab) {
if (tab.getIcon() == FSkinImage.HDHAND || tab.getIcon() == FSkinImage.HAND)
return true;
if (tab.getIcon() == FSkinImage.HDGRAVEYARD || tab.getIcon() == FSkinImage.GRAVEYARD)
return true;
if (tab.getIcon() == FSkinImage.HDLIBRARY || tab.getIcon() == FSkinImage.LIBRARY)
return true;
if (tab.getIcon() == FSkinImage.HDEXILE || tab.getIcon() == FSkinImage.EXILE)
return true;
return false;
}
public void setSelectedZone(ZoneType zoneType) {
setSelectedTab(zoneTabs.get(zoneType));
}
@@ -281,33 +294,51 @@ public class VPlayerPanel extends FContainer {
child.setTop(height - child.getBottom());
}
}
//this is used for landscape so set this to 0
field.setFieldModifier(0);
}
private void doLandscapeLayout(float width, float height) {
float x = 0;
float y = 0;
float yAlt = 0;
float avatarWidth = Forge.altZoneTabs ? avatar.getWidth() : 0;
avatar.setPosition(x, y);
y += avatar.getHeight();
lblLife.setBounds(x, Forge.altPlayerLayout ? 0 : y, avatar.getWidth(), Forge.altPlayerLayout ? INFO_FONT.getLineHeight() : LIFE_FONT.getLineHeight());
if (Forge.altPlayerLayout) {
lblLife.setBounds(x, (Forge.altPlayerLayout && !Forge.altZoneTabs) ? 0 : y, avatar.getWidth(), (Forge.altPlayerLayout && !Forge.altZoneTabs) ? INFO_FONT.getLineHeight() : Forge.altZoneTabs ? LIFE_FONT_ALT.getLineHeight() : LIFE_FONT.getLineHeight());
if (Forge.altPlayerLayout && !Forge.altZoneTabs) {
if (adjustHeight > 2)
y += INFO_FONT.getLineHeight()/2;
} else
y += lblLife.getHeight();
float infoTabWidth = avatar.getWidth();
float infoTabHeight = (height - y) / tabs.size();
int tabSize = !Forge.altZoneTabs ? tabs.size() : tabs.size() - 4;
float infoTabHeight = (height - y) / tabSize;
float infoTabHeightAlt = (height - yAlt) / 4;
for (InfoTab tab : tabs) {
if (!Forge.altZoneTabs) {
tab.setBounds(x, y, infoTabWidth, infoTabHeight);
y += infoTabHeight;
} else {
if (!isAltZoneDisplay(tab)) {
tab.setBounds(x, y, infoTabWidth, infoTabHeight);
y += infoTabHeight;
} else {
tab.setBounds(x+width-avatarWidth, yAlt, avatarWidth, infoTabHeightAlt);
yAlt += infoTabHeightAlt;
}
}
}
x = avatar.getRight();
phaseIndicator.resetFont();
phaseIndicator.setBounds(x, 0, avatar.getWidth() * 0.6f, height);
x += phaseIndicator.getWidth();
float fieldWidth = width - x;
float fieldWidth = width - x - avatarWidth;
float displayAreaWidth = height / FCardPanel.ASPECT_RATIO;
if (selectedTab != null) {
fieldWidth -= displayAreaWidth;
@@ -331,10 +362,15 @@ public class VPlayerPanel extends FContainer {
field.setBounds(x, 0, fieldWidth, height);
x = width - displayAreaWidth;
x = width - displayAreaWidth-avatarWidth;
for (InfoTab tab : tabs) {
tab.displayArea.setBounds(x, 0, displayAreaWidth, height);
}
if (!Forge.altZoneTabs)
field.setFieldModifier(0);
else
field.setFieldModifier(avatarWidth);
}
@Override
@@ -419,7 +455,7 @@ public class VPlayerPanel extends FContainer {
public void draw(Graphics g) {
adjustHeight = 1;
float divider = Gdx.app.getGraphics().getHeight() > 900 ? 1.2f : 2f;
if(Forge.altPlayerLayout && Forge.isLandscapeMode()) {
if(Forge.altPlayerLayout && !Forge.altZoneTabs && Forge.isLandscapeMode()) {
if (poisonCounters == 0 && energyCounters == 0 && experienceCounters == 0) {
g.fillRect(Color.DARK_GRAY, 0, 0, INFO2_FONT.getBounds(lifeStr).width+1, INFO2_FONT.getBounds(lifeStr).height+1);
g.drawText(lifeStr, INFO2_FONT, INFO_FORE_COLOR.getColor(), 0, 0, getWidth(), getHeight(), false, Align.left, false);
@@ -453,7 +489,7 @@ public class VPlayerPanel extends FContainer {
}
} else {
if (poisonCounters == 0 && energyCounters == 0) {
g.drawText(lifeStr, LIFE_FONT, INFO_FORE_COLOR, 0, 0, getWidth(), getHeight(), false, Align.center, true);
g.drawText(lifeStr, Forge.altZoneTabs ? LIFE_FONT_ALT : LIFE_FONT, INFO_FORE_COLOR, 0, 0, getWidth(), getHeight(), false, Align.center, true);
} else {
float halfHeight = getHeight() / 2;
float textStart = halfHeight + Utils.scale(1);

View File

@@ -27,6 +27,7 @@ import forge.screens.FScreen;
import forge.screens.TabPageScreen;
import forge.screens.TabPageScreen.TabPage;
import forge.screens.home.HomeScreen;
import forge.screens.match.MatchController;
import forge.sound.SoundSystem;
import forge.toolbox.FCheckBox;
import forge.toolbox.FGroupList;
@@ -248,6 +249,20 @@ public class SettingsPage extends TabPage<SettingsScreen> {
super.select();
//update
Forge.altPlayerLayout = FModel.getPreferences().getPrefBoolean(FPref.UI_ALT_PLAYERINFOLAYOUT);
if (MatchController.instance != null)
MatchController.instance.resetPlayerPanels();
}
},1);
lstSettings.addItem(new BooleanSetting(FPref.UI_ALT_PLAYERZONETABS,
localizer.getMessage("lblAltZoneTabs"),
localizer.getMessage("nlAltZoneTabs")){
@Override
public void select() {
super.select();
//update
Forge.altZoneTabs = FModel.getPreferences().getPrefBoolean(FPref.UI_ALT_PLAYERZONETABS);
if (MatchController.instance != null)
MatchController.instance.resetPlayerPanels();
}
},1);

View File

@@ -101,6 +101,13 @@ public abstract class FContainer extends FDisplayObject {
}
public void revalidate() {
revalidate(false);
}
public void revalidate(boolean forced) {
if (forced) {
doLayout(getWidth(), getHeight());
return;
}
float w = getWidth();
float h = getHeight();
if (w == 0 || h == 0) { return; } //don't revalidate if size not set yet

View File

@@ -117,6 +117,8 @@ cbpCounterDisplayLocation=Markeranzeige Ort
cbpGraveyardOrdering=Genaue Reihenfolge im Friedhof einhalten
lblAltLifeDisplay=Alternatives Spieler-Layout (Landscape-Modus)
nlAltLifeDisplay=Alternative Anzeige von Lebens-, Gift-, Energie- und Erfahrungspunkten.
lblAltZoneTabs=Alternate Player Zone Layout (Landscape Mode)
nlAltZoneTabs=Enables alternate layout for displaying Player Hand, Graveyard, Library and Exile zones.
lblPreferredArt=Bevorzugter Bildtyp
nlPreferredArt=Setzt die bevorzugte Art der Bilder.
Troubleshooting=Fehlerbehebung

View File

@@ -117,6 +117,8 @@ 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.
lblAltZoneTabs=Alternate Player Zone Layout (Landscape Mode)
nlAltZoneTabs=Enables alternate layout for displaying Player Hand, Graveyard, Library and Exile zones.
lblPreferredArt=Preferred Art
nlPreferredArt=Sets the preferred art for cards (RESTART REQUIRED).
Troubleshooting=Troubleshooting

View File

@@ -117,6 +117,8 @@ cbpCounterDisplayLocation=Ubicación del contador
cbpGraveyardOrdering=Permitir ordenar cartas puestas en el cementerio
lblAltLifeDisplay=Diseño alternativo de jugador (Modo apaisado)
nlAltLifeDisplay=Permite un diseño alternativo para mostrar los contadores de vida, veneno, energía y experiencia.
lblAltZoneTabs=Alternate Player Zone Layout (Landscape Mode)
nlAltZoneTabs=Enables alternate layout for displaying Player Hand, Graveyard, Library and Exile zones.
lblPreferredArt=Preferred Art
nlPreferredArt=Sets the preferred art for cards.
Troubleshooting=Solución de problemas

View File

@@ -117,6 +117,8 @@ 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.
lblAltZoneTabs=Alternate Player Zone Layout (Landscape Mode)
nlAltZoneTabs=Enables alternate layout for displaying Player Hand, Graveyard, Library and Exile zones.
lblPreferredArt=Preferred Art
nlPreferredArt=Sets the preferred art for cards.
Troubleshooting=Risoluzione dei problemi

View File

@@ -117,6 +117,8 @@ cbpCounterDisplayLocation=カウンター表示場所
cbpGraveyardOrdering=墓地に置かれるカードの順番指定を許可する
lblAltLifeDisplay=代替のプレイヤーレイアウト(ランドスケープモード時)
nlAltLifeDisplay=代替のレイアウトでプレイヤーライフ、毒、エネルギーと経験カウンターを表示する
lblAltZoneTabs=Alternate Player Zone Layout (Landscape Mode)
nlAltZoneTabs=Enables alternate layout for displaying Player Hand, Graveyard, Library and Exile zones.
lblPreferredArt=好むのアート
nlPreferredArt=カードの好むのアートを設定します。
Troubleshooting=トラブルシューティング

View File

@@ -117,6 +117,8 @@ cbpCounterDisplayLocation=计数器显示区域
cbpGraveyardOrdering=允许指衍生物进入墓地
lblAltLifeDisplay=备用牌手布局(横向模式)
nlAltLifeDisplay=启用备用牌手布局以显示玩家的生命以及中毒,能量和经验指示物。
lblAltZoneTabs=Alternate Player Zone Layout (Landscape Mode)
nlAltZoneTabs=Enables alternate layout for displaying Player Hand, Graveyard, Library and Exile zones.
lblPreferredArt=首选卡图
nlPreferredArt=设置牌张的首选卡图。
Troubleshooting=故障排除

View File

@@ -133,6 +133,7 @@ public class ForgePreferences extends PreferencesStore<ForgePreferences.FPref> {
UI_FILTER_LANDS_BY_COLOR_IDENTITY("true"),
UI_ALLOW_ESC_TO_END_TURN ("false"),
UI_ALT_PLAYERINFOLAYOUT ("false"),
UI_ALT_PLAYERZONETABS ("false"),
UI_PRESELECT_PREVIOUS_ABILITY_ORDER ("false"),
UI_AUTO_YIELD_MODE (ForgeConstants.AUTO_YIELD_PER_ABILITY),
UI_SHOW_STORM_COUNT_IN_PROMPT ("false"),