From df61e5d9aa208fb46a11114d828c7edcb4fbb97c Mon Sep 17 00:00:00 2001 From: austinio7116 Date: Wed, 14 Mar 2018 23:05:07 +0000 Subject: [PATCH 1/7] Update to android to support 3/4 player games --- .../screens/constructed/LobbyScreen.java | 38 ++++++++++++++----- .../src/forge/screens/match/MatchScreen.java | 34 +++++++++++++++-- .../src/main/java/forge/match/GameLobby.java | 2 +- 3 files changed, 59 insertions(+), 15 deletions(-) diff --git a/forge-gui-mobile/src/forge/screens/constructed/LobbyScreen.java b/forge-gui-mobile/src/forge/screens/constructed/LobbyScreen.java index df77e2db75e..2096fad29e6 100644 --- a/forge-gui-mobile/src/forge/screens/constructed/LobbyScreen.java +++ b/forge-gui-mobile/src/forge/screens/constructed/LobbyScreen.java @@ -43,7 +43,7 @@ import forge.util.Utils; public abstract class LobbyScreen extends LaunchScreen implements ILobbyView { private static final ForgePreferences prefs = FModel.getPreferences(); private static final float PADDING = Utils.scale(5); - public static final int MAX_PLAYERS = 2; //8; //TODO: Support multiplayer + public static final int MAX_PLAYERS = 4; //8; //TODO: Support multiplayer private static final FSkinFont VARIANTS_FONT = FSkinFont.get(12); // General variables @@ -84,8 +84,6 @@ public abstract class LobbyScreen extends LaunchScreen implements ILobbyView { public LobbyScreen(String headerCaption, FPopupMenu menu, GameLobby lobby0) { super(headerCaption, menu); - initLobby(lobby0); - btnStart.setEnabled(false); //disable start button until decks loaded add(lblPlayers); @@ -99,13 +97,20 @@ public abstract class LobbyScreen extends LaunchScreen implements ILobbyView { @Override public void handleEvent(FEvent e) { int numPlayers = getNumPlayers(); + while(lobby.getNumberOfSlots()2) { + playerPanels.get(2).initialize(FPref.CONSTRUCTED_P3_DECK_STATE, FPref.COMMANDER_P3_DECK_STATE, FPref.TINY_LEADER_P3_DECK_STATE, DeckType.COLOR_DECK); + } + if(getNumPlayers()>3) { + playerPanels.get(3).initialize(FPref.CONSTRUCTED_P4_DECK_STATE, FPref.COMMANDER_P4_DECK_STATE, FPref.TINY_LEADER_P4_DECK_STATE, DeckType.COLOR_DECK); + } + /*playerPanels.get(4).initialize(FPref.CONSTRUCTED_P5_DECK_STATE, DeckType.COLOR_DECK); playerPanels.get(5).initialize(FPref.CONSTRUCTED_P6_DECK_STATE, DeckType.COLOR_DECK); playerPanels.get(6).initialize(FPref.CONSTRUCTED_P7_DECK_STATE, DeckType.COLOR_DECK); playerPanels.get(7).initialize(FPref.CONSTRUCTED_P8_DECK_STATE, DeckType.COLOR_DECK);*/ //TODO: Support multiplayer and improve performance of loading this screen by using background thread @@ -165,8 +174,8 @@ public abstract class LobbyScreen extends LaunchScreen implements ILobbyView { }); //disable player count for now until multiplayer supported - lblPlayers.setEnabled(false); - cbPlayerCount.setEnabled(false); + lblPlayers.setEnabled(true); + cbPlayerCount.setEnabled(true); } public GameLobby getLobby() { @@ -180,6 +189,9 @@ public abstract class LobbyScreen extends LaunchScreen implements ILobbyView { btnStart.setEnabled(hasControl); lblVariants.setEnabled(hasControl); cbVariants.setEnabled(hasControl); + while(lobby.getNumberOfSlots() playerPanels0) { @@ -84,6 +84,14 @@ public class MatchScreen extends FScreen { bottomPlayerPanel = playerPanels0.get(0); topPlayerPanel = playerPanels0.get(1); topPlayerPanel.setFlipped(true); + if(is3Player()||is4Player()){ + topPlayerPanel2 = playerPanels0.get(2); + topPlayerPanel2.setFlipped(true); + } + if(is4Player()){ + bottomPlayerPanel2 = playerPanels0.get(3); + } + bottomPlayerPrompt = add(new VPrompt("", "", new FEventHandler() { @@ -154,6 +162,14 @@ public class MatchScreen extends FScreen { } } + private boolean is4Player(){ + return playerPanels.keySet().size()==4; + } + + private boolean is3Player(){ + return playerPanels.keySet().size()==3; + } + private IGameController getGameController() { return MatchController.instance.getGameController(); } @@ -547,9 +563,19 @@ public class MatchScreen extends FScreen { topPlayerPanelHeight += VAvatar.HEIGHT; bottomPlayerPanelHeight += VAvatar.HEIGHT; } - - topPlayerPanel.setBounds(0, 0, visibleWidth, topPlayerPanelHeight); - bottomPlayerPanel.setBounds(0, totalHeight - bottomPlayerPanelHeight, visibleWidth, bottomPlayerPanelHeight); + if(is4Player()){ + topPlayerPanel.setBounds(0, 0, visibleWidth / 2f, topPlayerPanelHeight); + bottomPlayerPanel.setBounds(0, totalHeight - bottomPlayerPanelHeight, visibleWidth / 2f, bottomPlayerPanelHeight); + topPlayerPanel2.setBounds(visibleWidth / 2f, 0, visibleWidth / 2f, topPlayerPanelHeight); + bottomPlayerPanel2.setBounds(visibleWidth / 2f, totalHeight - bottomPlayerPanelHeight, visibleWidth / 2f, bottomPlayerPanelHeight); + }else if(is3Player()){ + topPlayerPanel.setBounds(0, 0, visibleWidth / 2f, topPlayerPanelHeight); + bottomPlayerPanel.setBounds(0, totalHeight - bottomPlayerPanelHeight, visibleWidth, bottomPlayerPanelHeight); + topPlayerPanel2.setBounds(visibleWidth / 2f, 0, visibleWidth / 2f, topPlayerPanelHeight); + }else{ + topPlayerPanel.setBounds(0, 0, visibleWidth, topPlayerPanelHeight); + bottomPlayerPanel.setBounds(0, totalHeight - bottomPlayerPanelHeight, visibleWidth / 2f, bottomPlayerPanelHeight); + } return new ScrollBounds(visibleWidth, totalHeight); } diff --git a/forge-gui/src/main/java/forge/match/GameLobby.java b/forge-gui/src/main/java/forge/match/GameLobby.java index b6a2369cc90..8f8fee20c09 100644 --- a/forge-gui/src/main/java/forge/match/GameLobby.java +++ b/forge-gui/src/main/java/forge/match/GameLobby.java @@ -177,7 +177,7 @@ public abstract class GameLobby implements IHasGameType { slot.setIsArchenemy(true); lastArchenemy = 0; } - updateView(false); + updateView(true); } private String randomName() { final List names = Lists.newArrayListWithCapacity(MAX_PLAYERS); From 2c15be8351edc04fd6bc8ce22310a5355cd6dcb9 Mon Sep 17 00:00:00 2001 From: austinio7116 Date: Thu, 15 Mar 2018 12:00:48 +0000 Subject: [PATCH 2/7] Alternative and better horizontal layout for 3/4 player games on Android --- .../forge/screens/match/MatchController.java | 36 +++++++- .../src/forge/screens/match/MatchScreen.java | 82 ++++++++++++++++++- .../forge/screens/match/views/VAvatar.java | 6 ++ .../screens/match/views/VPlayerPanel.java | 28 +++++-- 4 files changed, 139 insertions(+), 13 deletions(-) diff --git a/forge-gui-mobile/src/forge/screens/match/MatchController.java b/forge-gui-mobile/src/forge/screens/match/MatchController.java index 7cb5d4e9aba..93cc3e835e1 100644 --- a/forge-gui-mobile/src/forge/screens/match/MatchController.java +++ b/forge-gui-mobile/src/forge/screens/match/MatchController.java @@ -119,7 +119,7 @@ public class MatchController extends AbstractGuiGame { final List playerPanels = new ArrayList(); for (final PlayerView p : allPlayers) { final boolean isLocal = isLocalPlayer(p); - final VPlayerPanel playerPanel = new VPlayerPanel(p, isLocal || noHumans); + final VPlayerPanel playerPanel = new VPlayerPanel(p, isLocal || noHumans, allPlayers.size()); if (isLocal && !playerPanels.isEmpty()) { playerPanels.add(0, playerPanel); //ensure local player always first among player panels } @@ -359,7 +359,7 @@ public class MatchController extends AbstractGuiGame { private static void actuateMatchPreferences() { final ForgePreferences prefs = FModel.getPreferences(); - final VPhaseIndicator fvAi = view.getTopPlayerPanel().getPhaseIndicator(); + VPhaseIndicator fvAi = view.getTopPlayerPanel().getPhaseIndicator(); fvAi.getLabel(PhaseType.UPKEEP).setStopAtPhase(prefs.getPrefBoolean(FPref.PHASE_AI_UPKEEP)); fvAi.getLabel(PhaseType.DRAW).setStopAtPhase(prefs.getPrefBoolean(FPref.PHASE_AI_DRAW)); fvAi.getLabel(PhaseType.MAIN1).setStopAtPhase(prefs.getPrefBoolean(FPref.PHASE_AI_MAIN1)); @@ -373,6 +373,38 @@ public class MatchController extends AbstractGuiGame { fvAi.getLabel(PhaseType.END_OF_TURN).setStopAtPhase(prefs.getPrefBoolean(FPref.PHASE_AI_EOT)); fvAi.getLabel(PhaseType.CLEANUP).setStopAtPhase(prefs.getPrefBoolean(FPref.PHASE_AI_CLEANUP)); + if(view.getPlayerPanels().size()>2){ + fvAi = view.getTopPlayerPanel2().getPhaseIndicator(); + fvAi.getLabel(PhaseType.UPKEEP).setStopAtPhase(prefs.getPrefBoolean(FPref.PHASE_AI_UPKEEP)); + fvAi.getLabel(PhaseType.DRAW).setStopAtPhase(prefs.getPrefBoolean(FPref.PHASE_AI_DRAW)); + fvAi.getLabel(PhaseType.MAIN1).setStopAtPhase(prefs.getPrefBoolean(FPref.PHASE_AI_MAIN1)); + fvAi.getLabel(PhaseType.COMBAT_BEGIN).setStopAtPhase(prefs.getPrefBoolean(FPref.PHASE_AI_BEGINCOMBAT)); + fvAi.getLabel(PhaseType.COMBAT_DECLARE_ATTACKERS).setStopAtPhase(prefs.getPrefBoolean(FPref.PHASE_AI_DECLAREATTACKERS)); + fvAi.getLabel(PhaseType.COMBAT_DECLARE_BLOCKERS).setStopAtPhase(prefs.getPrefBoolean(FPref.PHASE_AI_DECLAREBLOCKERS)); + fvAi.getLabel(PhaseType.COMBAT_FIRST_STRIKE_DAMAGE).setStopAtPhase(prefs.getPrefBoolean(FPref.PHASE_AI_FIRSTSTRIKE)); + fvAi.getLabel(PhaseType.COMBAT_DAMAGE).setStopAtPhase(prefs.getPrefBoolean(FPref.PHASE_AI_COMBATDAMAGE)); + fvAi.getLabel(PhaseType.COMBAT_END).setStopAtPhase(prefs.getPrefBoolean(FPref.PHASE_AI_ENDCOMBAT)); + fvAi.getLabel(PhaseType.MAIN2).setStopAtPhase(prefs.getPrefBoolean(FPref.PHASE_AI_MAIN2)); + fvAi.getLabel(PhaseType.END_OF_TURN).setStopAtPhase(prefs.getPrefBoolean(FPref.PHASE_AI_EOT)); + fvAi.getLabel(PhaseType.CLEANUP).setStopAtPhase(prefs.getPrefBoolean(FPref.PHASE_AI_CLEANUP)); + } + + if(view.getPlayerPanels().size()>3){ + fvAi = view.getBottomPlayerPanel2().getPhaseIndicator(); + fvAi.getLabel(PhaseType.UPKEEP).setStopAtPhase(prefs.getPrefBoolean(FPref.PHASE_AI_UPKEEP)); + fvAi.getLabel(PhaseType.DRAW).setStopAtPhase(prefs.getPrefBoolean(FPref.PHASE_AI_DRAW)); + fvAi.getLabel(PhaseType.MAIN1).setStopAtPhase(prefs.getPrefBoolean(FPref.PHASE_AI_MAIN1)); + fvAi.getLabel(PhaseType.COMBAT_BEGIN).setStopAtPhase(prefs.getPrefBoolean(FPref.PHASE_AI_BEGINCOMBAT)); + fvAi.getLabel(PhaseType.COMBAT_DECLARE_ATTACKERS).setStopAtPhase(prefs.getPrefBoolean(FPref.PHASE_AI_DECLAREATTACKERS)); + fvAi.getLabel(PhaseType.COMBAT_DECLARE_BLOCKERS).setStopAtPhase(prefs.getPrefBoolean(FPref.PHASE_AI_DECLAREBLOCKERS)); + fvAi.getLabel(PhaseType.COMBAT_FIRST_STRIKE_DAMAGE).setStopAtPhase(prefs.getPrefBoolean(FPref.PHASE_AI_FIRSTSTRIKE)); + fvAi.getLabel(PhaseType.COMBAT_DAMAGE).setStopAtPhase(prefs.getPrefBoolean(FPref.PHASE_AI_COMBATDAMAGE)); + fvAi.getLabel(PhaseType.COMBAT_END).setStopAtPhase(prefs.getPrefBoolean(FPref.PHASE_AI_ENDCOMBAT)); + fvAi.getLabel(PhaseType.MAIN2).setStopAtPhase(prefs.getPrefBoolean(FPref.PHASE_AI_MAIN2)); + fvAi.getLabel(PhaseType.END_OF_TURN).setStopAtPhase(prefs.getPrefBoolean(FPref.PHASE_AI_EOT)); + fvAi.getLabel(PhaseType.CLEANUP).setStopAtPhase(prefs.getPrefBoolean(FPref.PHASE_AI_CLEANUP)); + } + final VPhaseIndicator fvHuman = view.getBottomPlayerPanel().getPhaseIndicator(); fvHuman.getLabel(PhaseType.UPKEEP).setStopAtPhase(prefs.getPrefBoolean(FPref.PHASE_HUMAN_UPKEEP)); fvHuman.getLabel(PhaseType.DRAW).setStopAtPhase(prefs.getPrefBoolean(FPref.PHASE_HUMAN_DRAW)); diff --git a/forge-gui-mobile/src/forge/screens/match/MatchScreen.java b/forge-gui-mobile/src/forge/screens/match/MatchScreen.java index 069aedf02d9..4c9c87a9a08 100644 --- a/forge-gui-mobile/src/forge/screens/match/MatchScreen.java +++ b/forge-gui-mobile/src/forge/screens/match/MatchScreen.java @@ -72,6 +72,7 @@ public class MatchScreen extends FScreen { private final VPrompt bottomPlayerPrompt, topPlayerPrompt; private VPlayerPanel bottomPlayerPanel, bottomPlayerPanel2, topPlayerPanel, topPlayerPanel2; private AbilityEffect activeEffect; + private final boolean horizontalMultiplayerLayout = true; public MatchScreen(List playerPanels0) { super(new FMenuBar()); @@ -90,6 +91,9 @@ public class MatchScreen extends FScreen { } if(is4Player()){ bottomPlayerPanel2 = playerPanels0.get(3); + if(horizontalMultiplayerLayout){ + bottomPlayerPanel2.setFlipped(true); + } } @@ -282,10 +286,18 @@ public class MatchScreen extends FScreen { return topPlayerPanel; } + public VPlayerPanel getTopPlayerPanel2() { + return topPlayerPanel2; + } + public VPlayerPanel getBottomPlayerPanel() { return bottomPlayerPanel; } + public VPlayerPanel getBottomPlayerPanel2() { + return bottomPlayerPanel2; + } + public Map getPlayerPanels() { return playerPanels; } @@ -529,9 +541,75 @@ public class MatchScreen extends FScreen { g.drawLine(1, BORDER_COLOR, 0, y, w, y); } } - @Override protected ScrollBounds layoutAndGetScrollBounds(float visibleWidth, float visibleHeight) { + if(horizontalMultiplayerLayout){ + return layoutAndGetScrollBoundsHorizontal(visibleWidth,visibleHeight); + }else{ + return layoutAndGetScrollBoundsVertical(visibleWidth,visibleHeight); + } + } + + protected ScrollBounds layoutAndGetScrollBoundsHorizontal(float visibleWidth, float visibleHeight) { + float totalHeight = visibleHeight + extraHeight; + float avatarHeight = VAvatar.HEIGHT; + if(is4Player() || is3Player()){ + avatarHeight *= 0.5f; + } + float playercount = getPlayerPanels().keySet().size(); + float totalCardRows = playercount * 2f; + + + //determine player panel heights based on visibility of zone displays + float topPlayerPanelHeight, bottomPlayerPanelHeight; + if (Forge.isLandscapeMode()) { + topPlayerPanelHeight = totalHeight / 2; + bottomPlayerPanelHeight = topPlayerPanelHeight; + } + else { + float cardRowsHeight = totalHeight - playercount * avatarHeight; + if (topPlayerPanel.getSelectedTab() == null) { + if (bottomPlayerPanel.getSelectedTab() != null) { + topPlayerPanelHeight = cardRowsHeight * 2f / (totalCardRows + 1f); + bottomPlayerPanelHeight = cardRowsHeight * 3f / (totalCardRows + 1f); + } + else { + topPlayerPanelHeight = cardRowsHeight * 2f / totalCardRows; + bottomPlayerPanelHeight = topPlayerPanelHeight; + } + } + else if (bottomPlayerPanel.getSelectedTab() == null) { + topPlayerPanelHeight = cardRowsHeight * 3f / (totalCardRows + 1f); + bottomPlayerPanelHeight = cardRowsHeight * 2f / (totalCardRows + 1f); + } + else { + topPlayerPanelHeight = cardRowsHeight * 2f / totalCardRows ; + bottomPlayerPanelHeight = topPlayerPanelHeight; + } + } + if(is4Player()){ + topPlayerPanelHeight += avatarHeight; + bottomPlayerPanelHeight += avatarHeight; + topPlayerPanel.setBounds(0, 0, visibleWidth, topPlayerPanelHeight); + bottomPlayerPanel.setBounds(0, totalHeight - bottomPlayerPanelHeight, visibleWidth, bottomPlayerPanelHeight); + topPlayerPanel2.setBounds(0, topPlayerPanelHeight , visibleWidth, topPlayerPanelHeight); + bottomPlayerPanel2.setBounds(0, topPlayerPanelHeight * 2f, visibleWidth, topPlayerPanelHeight); + }else if(is3Player()){ + topPlayerPanelHeight += avatarHeight; + bottomPlayerPanelHeight += avatarHeight; + topPlayerPanel.setBounds(0, 0, visibleWidth, topPlayerPanelHeight); + bottomPlayerPanel.setBounds(0, totalHeight - bottomPlayerPanelHeight, visibleWidth, bottomPlayerPanelHeight); + topPlayerPanel2.setBounds(0, topPlayerPanelHeight, visibleWidth, topPlayerPanelHeight); + }else{ + topPlayerPanelHeight += avatarHeight; + bottomPlayerPanelHeight += avatarHeight; + topPlayerPanel.setBounds(0, 0, visibleWidth, topPlayerPanelHeight); + bottomPlayerPanel.setBounds(0, totalHeight - bottomPlayerPanelHeight, visibleWidth, bottomPlayerPanelHeight); + } + return new ScrollBounds(visibleWidth, totalHeight); + } + + protected ScrollBounds layoutAndGetScrollBoundsVertical(float visibleWidth, float visibleHeight) { float totalHeight = visibleHeight + extraHeight; //determine player panel heights based on visibility of zone displays @@ -574,7 +652,7 @@ public class MatchScreen extends FScreen { topPlayerPanel2.setBounds(visibleWidth / 2f, 0, visibleWidth / 2f, topPlayerPanelHeight); }else{ topPlayerPanel.setBounds(0, 0, visibleWidth, topPlayerPanelHeight); - bottomPlayerPanel.setBounds(0, totalHeight - bottomPlayerPanelHeight, visibleWidth / 2f, bottomPlayerPanelHeight); + bottomPlayerPanel.setBounds(0, totalHeight - bottomPlayerPanelHeight, visibleWidth, bottomPlayerPanelHeight); } return new ScrollBounds(visibleWidth, totalHeight); } 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 4df8cd9e4dd..950034bd616 100644 --- a/forge-gui-mobile/src/forge/screens/match/views/VAvatar.java +++ b/forge-gui-mobile/src/forge/screens/match/views/VAvatar.java @@ -27,6 +27,12 @@ public class VAvatar extends FDisplayObject { setSize(WIDTH, HEIGHT); } + public VAvatar(PlayerView player0, float size) { + player = player0; + image = MatchController.getPlayerAvatar(player); + setSize(size, size); + } + @Override public boolean tap(float x, float y, int count) { ThreadUtil.invokeInGameThread(new Runnable() { //must invoke in game thread in case a dialog needs to be shown 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 c21345992ec..fa2e0581193 100644 --- a/forge-gui-mobile/src/forge/screens/match/views/VPlayerPanel.java +++ b/forge-gui-mobile/src/forge/screens/match/views/VPlayerPanel.java @@ -45,13 +45,21 @@ public class VPlayerPanel extends FContainer { private final Map zoneTabs = new HashMap(); private final List tabs = new ArrayList(); private InfoTab selectedTab; + private float avatarHeight = VAvatar.HEIGHT; + private float displayAreaHeightFactor = 1.0f; + private boolean forMultiPlayer = false; - public VPlayerPanel(PlayerView player0, boolean showHand) { + public VPlayerPanel(PlayerView player0, boolean showHand, int playerCount) { player = player0; phaseIndicator = add(new VPhaseIndicator()); + if(playerCount>2){ + forMultiPlayer=true; + avatarHeight *= 0.5f; + //displayAreaHeightFactor *= 0.7f; + } field = add(new VField(player)); - avatar = add(new VAvatar(player)); + avatar = add(new VAvatar(player, avatarHeight)); lblLife = add(new LifeLabel()); addZoneDisplay(ZoneType.Hand, FSkinImage.HAND); addZoneDisplay(ZoneType.Graveyard, FSkinImage.GRAVEYARD); @@ -205,18 +213,18 @@ public class VPlayerPanel extends FContainer { float h = phaseIndicator.getPreferredHeight(w); phaseIndicator.setBounds(x, height - h, w, h); - float y = height - VAvatar.HEIGHT; - float displayAreaHeight = y / 3; + float y = height - avatarHeight; + float displayAreaHeight = displayAreaHeightFactor * y / 3; y -= displayAreaHeight; for (InfoTab tab : tabs) { tab.displayArea.setBounds(0, y, width, displayAreaHeight); } - y = height - VAvatar.HEIGHT; + y = height - avatarHeight; avatar.setPosition(0, y); float lifeLabelWidth = LIFE_FONT.getBounds("99").width * 1.2f; //make just wide enough for 2-digit life totals - float infoLabelHeight = VAvatar.HEIGHT - phaseIndicator.getHeight(); + float infoLabelHeight = avatarHeight - phaseIndicator.getHeight(); lblLife.setBounds(x, y, lifeLabelWidth, infoLabelHeight); x += lifeLabelWidth; @@ -461,9 +469,11 @@ public class VPlayerPanel extends FContainer { else { g.startClip(-1, y, w + 2, yAcross - y); } - g.drawLine(1, MatchScreen.BORDER_COLOR, 0, yAcross, w, yAcross); - g.drawLine(1, MatchScreen.BORDER_COLOR, 0, y, 0, h); - g.drawLine(1, MatchScreen.BORDER_COLOR, w, y, w, h); + if(forMultiPlayer) { + g.drawLine(1, MatchScreen.BORDER_COLOR, 0, yAcross, w, yAcross); + g.drawLine(1, MatchScreen.BORDER_COLOR, 0, y, 0, h); + g.drawLine(1, MatchScreen.BORDER_COLOR, w, y, w, h); + } g.endClip(); } } From 17e6c65652626354e142489c858787315c657faa Mon Sep 17 00:00:00 2001 From: austinio7116 Date: Thu, 15 Mar 2018 19:56:17 +0000 Subject: [PATCH 3/7] Imrovements to layout of 3/4 player match view on android --- .../screens/constructed/LobbyScreen.java | 7 +- .../src/forge/screens/match/MatchScreen.java | 82 ++++++++----------- .../screens/match/views/VPlayerPanel.java | 12 ++- 3 files changed, 49 insertions(+), 52 deletions(-) diff --git a/forge-gui-mobile/src/forge/screens/constructed/LobbyScreen.java b/forge-gui-mobile/src/forge/screens/constructed/LobbyScreen.java index 2096fad29e6..68831ff0c69 100644 --- a/forge-gui-mobile/src/forge/screens/constructed/LobbyScreen.java +++ b/forge-gui-mobile/src/forge/screens/constructed/LobbyScreen.java @@ -43,7 +43,7 @@ import forge.util.Utils; public abstract class LobbyScreen extends LaunchScreen implements ILobbyView { private static final ForgePreferences prefs = FModel.getPreferences(); private static final float PADDING = Utils.scale(5); - public static final int MAX_PLAYERS = 4; //8; //TODO: Support multiplayer + public static final int MAX_PLAYERS = 4; private static final FSkinFont VARIANTS_FONT = FSkinFont.get(12); // General variables @@ -97,9 +97,12 @@ public abstract class LobbyScreen extends LaunchScreen implements ILobbyView { @Override public void handleEvent(FEvent e) { int numPlayers = getNumPlayers(); - while(lobby.getNumberOfSlots() getNumPlayers()){ + lobby.removeSlot(lobby.getNumberOfSlots()-1); + } for (int i = 0; i < MAX_PLAYERS; i++) { if(i playerPanels = Maps.newHashMap(); + private List playerPanelsList; private final VGameMenu gameMenu; private final VPlayers players; private final VLog log; @@ -95,6 +92,8 @@ public class MatchScreen extends FScreen { bottomPlayerPanel2.setFlipped(true); } } + playerPanelsList=playerPanels0; + Collections.reverse(playerPanelsList); bottomPlayerPrompt = add(new VPrompt("", "", @@ -527,18 +526,25 @@ public class MatchScreen extends FScreen { //field separator lines if (!Forge.isLandscapeMode()) { - if (topPlayerPanel.getSelectedTab() == null) { - y++; //ensure border goes all the way across under avatar + for (VPlayerPanel playerPanel: playerPanelsList){ + midField = playerPanel.getTop(); + y = midField - playerPanel.getField().getHeight(); + if(playerPanel.getSelectedTab() == null) { + y++; + } + g.drawLine(1, BORDER_COLOR, x, y, w, y); } - g.drawLine(1, BORDER_COLOR, 0, y, w, y); } - y = midField - 0.5f; - g.drawLine(1, BORDER_COLOR, x, y, w, y); + for (VPlayerPanel playerPanel: playerPanelsList){ + midField = playerPanel.getTop(); + y = midField - 0.5f; + g.drawLine(1, BORDER_COLOR, x, y, w, y); + } if (!Forge.isLandscapeMode()) { - y = midField + bottomPlayerPanel.getField().getHeight(); - g.drawLine(1, BORDER_COLOR, 0, y, w, y); + y = bottomPlayerPanel.getTop() + bottomPlayerPanel.getField().getHeight(); + g.drawLine(1, BORDER_COLOR, x, y, w, y); } } @Override @@ -568,47 +574,31 @@ public class MatchScreen extends FScreen { } else { float cardRowsHeight = totalHeight - playercount * avatarHeight; - if (topPlayerPanel.getSelectedTab() == null) { - if (bottomPlayerPanel.getSelectedTab() != null) { - topPlayerPanelHeight = cardRowsHeight * 2f / (totalCardRows + 1f); - bottomPlayerPanelHeight = cardRowsHeight * 3f / (totalCardRows + 1f); + totalCardRows=0; + for(VPlayerPanel playerPanel:playerPanelsList){ + if(playerPanel.getSelectedTab() != null){ + totalCardRows += 1; } - else { - topPlayerPanelHeight = cardRowsHeight * 2f / totalCardRows; - bottomPlayerPanelHeight = topPlayerPanelHeight; + totalCardRows += 2; + } + float y=0; + for(VPlayerPanel playerPanel:playerPanelsList){ + float panelHeight; + if(playerPanel.getSelectedTab() != null){ + panelHeight = cardRowsHeight * 3f / totalCardRows; + }else{ + panelHeight = cardRowsHeight * 2f / totalCardRows; } + panelHeight += avatarHeight; + playerPanel.setBounds(0, y, visibleWidth, panelHeight); + y=y+panelHeight; } - else if (bottomPlayerPanel.getSelectedTab() == null) { - topPlayerPanelHeight = cardRowsHeight * 3f / (totalCardRows + 1f); - bottomPlayerPanelHeight = cardRowsHeight * 2f / (totalCardRows + 1f); - } - else { - topPlayerPanelHeight = cardRowsHeight * 2f / totalCardRows ; - bottomPlayerPanelHeight = topPlayerPanelHeight; - } - } - if(is4Player()){ - topPlayerPanelHeight += avatarHeight; - bottomPlayerPanelHeight += avatarHeight; - topPlayerPanel.setBounds(0, 0, visibleWidth, topPlayerPanelHeight); - bottomPlayerPanel.setBounds(0, totalHeight - bottomPlayerPanelHeight, visibleWidth, bottomPlayerPanelHeight); - topPlayerPanel2.setBounds(0, topPlayerPanelHeight , visibleWidth, topPlayerPanelHeight); - bottomPlayerPanel2.setBounds(0, topPlayerPanelHeight * 2f, visibleWidth, topPlayerPanelHeight); - }else if(is3Player()){ - topPlayerPanelHeight += avatarHeight; - bottomPlayerPanelHeight += avatarHeight; - topPlayerPanel.setBounds(0, 0, visibleWidth, topPlayerPanelHeight); - bottomPlayerPanel.setBounds(0, totalHeight - bottomPlayerPanelHeight, visibleWidth, bottomPlayerPanelHeight); - topPlayerPanel2.setBounds(0, topPlayerPanelHeight, visibleWidth, topPlayerPanelHeight); - }else{ - topPlayerPanelHeight += avatarHeight; - bottomPlayerPanelHeight += avatarHeight; - topPlayerPanel.setBounds(0, 0, visibleWidth, topPlayerPanelHeight); - bottomPlayerPanel.setBounds(0, totalHeight - bottomPlayerPanelHeight, visibleWidth, bottomPlayerPanelHeight); + } return new ScrollBounds(visibleWidth, totalHeight); } + protected ScrollBounds layoutAndGetScrollBoundsVertical(float visibleWidth, float visibleHeight) { float totalHeight = visibleHeight + extraHeight; 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 fa2e0581193..170fe267eeb 100644 --- a/forge-gui-mobile/src/forge/screens/match/views/VPlayerPanel.java +++ b/forge-gui-mobile/src/forge/screens/match/views/VPlayerPanel.java @@ -208,9 +208,13 @@ public class VPlayerPanel extends FContainer { } //layout for bottom panel by default - float x = VAvatar.WIDTH; - float w = width - VAvatar.WIDTH; - float h = phaseIndicator.getPreferredHeight(w); + float x = avatarHeight; + float w = width - avatarHeight; + float indicatorScale = 1f; + if(avatarHeight Date: Thu, 15 Mar 2018 20:36:04 +0000 Subject: [PATCH 4/7] Android 3/4 player working in landscape mode too --- .../src/forge/screens/match/MatchScreen.java | 110 ++++-------------- 1 file changed, 20 insertions(+), 90 deletions(-) diff --git a/forge-gui-mobile/src/forge/screens/match/MatchScreen.java b/forge-gui-mobile/src/forge/screens/match/MatchScreen.java index 0e93b801d70..adece1580eb 100644 --- a/forge-gui-mobile/src/forge/screens/match/MatchScreen.java +++ b/forge-gui-mobile/src/forge/screens/match/MatchScreen.java @@ -69,7 +69,6 @@ public class MatchScreen extends FScreen { private final VPrompt bottomPlayerPrompt, topPlayerPrompt; private VPlayerPanel bottomPlayerPanel, bottomPlayerPanel2, topPlayerPanel, topPlayerPanel2; private AbilityEffect activeEffect; - private final boolean horizontalMultiplayerLayout = true; public MatchScreen(List playerPanels0) { super(new FMenuBar()); @@ -88,9 +87,7 @@ public class MatchScreen extends FScreen { } if(is4Player()){ bottomPlayerPanel2 = playerPanels0.get(3); - if(horizontalMultiplayerLayout){ - bottomPlayerPanel2.setFlipped(true); - } + bottomPlayerPanel2.setFlipped(true); } playerPanelsList=playerPanels0; Collections.reverse(playerPanelsList); @@ -547,102 +544,35 @@ public class MatchScreen extends FScreen { g.drawLine(1, BORDER_COLOR, x, y, w, y); } } - @Override - protected ScrollBounds layoutAndGetScrollBounds(float visibleWidth, float visibleHeight) { - if(horizontalMultiplayerLayout){ - return layoutAndGetScrollBoundsHorizontal(visibleWidth,visibleHeight); - }else{ - return layoutAndGetScrollBoundsVertical(visibleWidth,visibleHeight); - } - } - protected ScrollBounds layoutAndGetScrollBoundsHorizontal(float visibleWidth, float visibleHeight) { + protected ScrollBounds layoutAndGetScrollBounds(float visibleWidth, float visibleHeight) { float totalHeight = visibleHeight + extraHeight; float avatarHeight = VAvatar.HEIGHT; if(is4Player() || is3Player()){ avatarHeight *= 0.5f; } - float playercount = getPlayerPanels().keySet().size(); - float totalCardRows = playercount * 2f; - + float playerCount = getPlayerPanels().keySet().size(); //determine player panel heights based on visibility of zone displays - float topPlayerPanelHeight, bottomPlayerPanelHeight; - if (Forge.isLandscapeMode()) { - topPlayerPanelHeight = totalHeight / 2; - bottomPlayerPanelHeight = topPlayerPanelHeight; + float cardRowsHeight = totalHeight - playerCount * avatarHeight; + float totalCardRows=0; + for(VPlayerPanel playerPanel:playerPanelsList){ + if(playerPanel.getSelectedTab() != null){ + totalCardRows += 1; + } + totalCardRows += 2; } - else { - float cardRowsHeight = totalHeight - playercount * avatarHeight; - totalCardRows=0; - for(VPlayerPanel playerPanel:playerPanelsList){ - if(playerPanel.getSelectedTab() != null){ - totalCardRows += 1; - } - totalCardRows += 2; + float y=0; + for(VPlayerPanel playerPanel:playerPanelsList){ + float panelHeight; + if(playerPanel.getSelectedTab() != null){ + panelHeight = cardRowsHeight * 3f / totalCardRows; + }else{ + panelHeight = cardRowsHeight * 2f / totalCardRows; } - float y=0; - for(VPlayerPanel playerPanel:playerPanelsList){ - float panelHeight; - if(playerPanel.getSelectedTab() != null){ - panelHeight = cardRowsHeight * 3f / totalCardRows; - }else{ - panelHeight = cardRowsHeight * 2f / totalCardRows; - } - panelHeight += avatarHeight; - playerPanel.setBounds(0, y, visibleWidth, panelHeight); - y=y+panelHeight; - } - - } - return new ScrollBounds(visibleWidth, totalHeight); - } - - - protected ScrollBounds layoutAndGetScrollBoundsVertical(float visibleWidth, float visibleHeight) { - float totalHeight = visibleHeight + extraHeight; - - //determine player panel heights based on visibility of zone displays - float topPlayerPanelHeight, bottomPlayerPanelHeight; - if (Forge.isLandscapeMode()) { - topPlayerPanelHeight = totalHeight / 2; - bottomPlayerPanelHeight = topPlayerPanelHeight; - } - else { - float cardRowsHeight = totalHeight - 2 * VAvatar.HEIGHT; - if (topPlayerPanel.getSelectedTab() == null) { - if (bottomPlayerPanel.getSelectedTab() != null) { - topPlayerPanelHeight = cardRowsHeight * 2f / 5f; - bottomPlayerPanelHeight = cardRowsHeight * 3f / 5f; - } - else { - topPlayerPanelHeight = cardRowsHeight / 2f; - bottomPlayerPanelHeight = topPlayerPanelHeight; - } - } - else if (bottomPlayerPanel.getSelectedTab() == null) { - topPlayerPanelHeight = cardRowsHeight * 3f / 5f; - bottomPlayerPanelHeight = cardRowsHeight * 2f / 5f; - } - else { - topPlayerPanelHeight = cardRowsHeight / 2f; - bottomPlayerPanelHeight = topPlayerPanelHeight; - } - topPlayerPanelHeight += VAvatar.HEIGHT; - bottomPlayerPanelHeight += VAvatar.HEIGHT; - } - if(is4Player()){ - topPlayerPanel.setBounds(0, 0, visibleWidth / 2f, topPlayerPanelHeight); - bottomPlayerPanel.setBounds(0, totalHeight - bottomPlayerPanelHeight, visibleWidth / 2f, bottomPlayerPanelHeight); - topPlayerPanel2.setBounds(visibleWidth / 2f, 0, visibleWidth / 2f, topPlayerPanelHeight); - bottomPlayerPanel2.setBounds(visibleWidth / 2f, totalHeight - bottomPlayerPanelHeight, visibleWidth / 2f, bottomPlayerPanelHeight); - }else if(is3Player()){ - topPlayerPanel.setBounds(0, 0, visibleWidth / 2f, topPlayerPanelHeight); - bottomPlayerPanel.setBounds(0, totalHeight - bottomPlayerPanelHeight, visibleWidth, bottomPlayerPanelHeight); - topPlayerPanel2.setBounds(visibleWidth / 2f, 0, visibleWidth / 2f, topPlayerPanelHeight); - }else{ - topPlayerPanel.setBounds(0, 0, visibleWidth, topPlayerPanelHeight); - bottomPlayerPanel.setBounds(0, totalHeight - bottomPlayerPanelHeight, visibleWidth, bottomPlayerPanelHeight); + panelHeight += avatarHeight; + playerPanel.setBounds(0, y, visibleWidth, panelHeight); + y += panelHeight; } return new ScrollBounds(visibleWidth, totalHeight); } From 35245d5268e86384681f3950523bf14de20077da Mon Sep 17 00:00:00 2001 From: austinio7116 Date: Fri, 16 Mar 2018 08:24:51 +0000 Subject: [PATCH 5/7] Cleaned up 3/4 player android code - ensured top to bottom turn order. --- .../screens/constructed/LobbyScreen.java | 3 +- .../forge/screens/match/MatchController.java | 34 ++----------------- .../src/forge/screens/match/MatchScreen.java | 33 +++++++----------- 3 files changed, 15 insertions(+), 55 deletions(-) diff --git a/forge-gui-mobile/src/forge/screens/constructed/LobbyScreen.java b/forge-gui-mobile/src/forge/screens/constructed/LobbyScreen.java index 68831ff0c69..a41c249a296 100644 --- a/forge-gui-mobile/src/forge/screens/constructed/LobbyScreen.java +++ b/forge-gui-mobile/src/forge/screens/constructed/LobbyScreen.java @@ -165,7 +165,7 @@ public abstract class LobbyScreen extends LaunchScreen implements ILobbyView { /*playerPanels.get(4).initialize(FPref.CONSTRUCTED_P5_DECK_STATE, DeckType.COLOR_DECK); playerPanels.get(5).initialize(FPref.CONSTRUCTED_P6_DECK_STATE, DeckType.COLOR_DECK); playerPanels.get(6).initialize(FPref.CONSTRUCTED_P7_DECK_STATE, DeckType.COLOR_DECK); - playerPanels.get(7).initialize(FPref.CONSTRUCTED_P8_DECK_STATE, DeckType.COLOR_DECK);*/ //TODO: Support multiplayer and improve performance of loading this screen by using background thread + playerPanels.get(7).initialize(FPref.CONSTRUCTED_P8_DECK_STATE, DeckType.COLOR_DECK);*/ //TODO: Improve performance of loading this screen by using background thread FThreads.invokeInEdtLater(new Runnable() { @Override @@ -176,7 +176,6 @@ public abstract class LobbyScreen extends LaunchScreen implements ILobbyView { } }); - //disable player count for now until multiplayer supported lblPlayers.setEnabled(true); cbPlayerCount.setEnabled(true); } diff --git a/forge-gui-mobile/src/forge/screens/match/MatchController.java b/forge-gui-mobile/src/forge/screens/match/MatchController.java index 93cc3e835e1..0674a90c14e 100644 --- a/forge-gui-mobile/src/forge/screens/match/MatchController.java +++ b/forge-gui-mobile/src/forge/screens/match/MatchController.java @@ -359,38 +359,8 @@ public class MatchController extends AbstractGuiGame { private static void actuateMatchPreferences() { final ForgePreferences prefs = FModel.getPreferences(); - VPhaseIndicator fvAi = view.getTopPlayerPanel().getPhaseIndicator(); - fvAi.getLabel(PhaseType.UPKEEP).setStopAtPhase(prefs.getPrefBoolean(FPref.PHASE_AI_UPKEEP)); - fvAi.getLabel(PhaseType.DRAW).setStopAtPhase(prefs.getPrefBoolean(FPref.PHASE_AI_DRAW)); - fvAi.getLabel(PhaseType.MAIN1).setStopAtPhase(prefs.getPrefBoolean(FPref.PHASE_AI_MAIN1)); - fvAi.getLabel(PhaseType.COMBAT_BEGIN).setStopAtPhase(prefs.getPrefBoolean(FPref.PHASE_AI_BEGINCOMBAT)); - fvAi.getLabel(PhaseType.COMBAT_DECLARE_ATTACKERS).setStopAtPhase(prefs.getPrefBoolean(FPref.PHASE_AI_DECLAREATTACKERS)); - fvAi.getLabel(PhaseType.COMBAT_DECLARE_BLOCKERS).setStopAtPhase(prefs.getPrefBoolean(FPref.PHASE_AI_DECLAREBLOCKERS)); - fvAi.getLabel(PhaseType.COMBAT_FIRST_STRIKE_DAMAGE).setStopAtPhase(prefs.getPrefBoolean(FPref.PHASE_AI_FIRSTSTRIKE)); - fvAi.getLabel(PhaseType.COMBAT_DAMAGE).setStopAtPhase(prefs.getPrefBoolean(FPref.PHASE_AI_COMBATDAMAGE)); - fvAi.getLabel(PhaseType.COMBAT_END).setStopAtPhase(prefs.getPrefBoolean(FPref.PHASE_AI_ENDCOMBAT)); - fvAi.getLabel(PhaseType.MAIN2).setStopAtPhase(prefs.getPrefBoolean(FPref.PHASE_AI_MAIN2)); - fvAi.getLabel(PhaseType.END_OF_TURN).setStopAtPhase(prefs.getPrefBoolean(FPref.PHASE_AI_EOT)); - fvAi.getLabel(PhaseType.CLEANUP).setStopAtPhase(prefs.getPrefBoolean(FPref.PHASE_AI_CLEANUP)); - - if(view.getPlayerPanels().size()>2){ - fvAi = view.getTopPlayerPanel2().getPhaseIndicator(); - fvAi.getLabel(PhaseType.UPKEEP).setStopAtPhase(prefs.getPrefBoolean(FPref.PHASE_AI_UPKEEP)); - fvAi.getLabel(PhaseType.DRAW).setStopAtPhase(prefs.getPrefBoolean(FPref.PHASE_AI_DRAW)); - fvAi.getLabel(PhaseType.MAIN1).setStopAtPhase(prefs.getPrefBoolean(FPref.PHASE_AI_MAIN1)); - fvAi.getLabel(PhaseType.COMBAT_BEGIN).setStopAtPhase(prefs.getPrefBoolean(FPref.PHASE_AI_BEGINCOMBAT)); - fvAi.getLabel(PhaseType.COMBAT_DECLARE_ATTACKERS).setStopAtPhase(prefs.getPrefBoolean(FPref.PHASE_AI_DECLAREATTACKERS)); - fvAi.getLabel(PhaseType.COMBAT_DECLARE_BLOCKERS).setStopAtPhase(prefs.getPrefBoolean(FPref.PHASE_AI_DECLAREBLOCKERS)); - fvAi.getLabel(PhaseType.COMBAT_FIRST_STRIKE_DAMAGE).setStopAtPhase(prefs.getPrefBoolean(FPref.PHASE_AI_FIRSTSTRIKE)); - fvAi.getLabel(PhaseType.COMBAT_DAMAGE).setStopAtPhase(prefs.getPrefBoolean(FPref.PHASE_AI_COMBATDAMAGE)); - fvAi.getLabel(PhaseType.COMBAT_END).setStopAtPhase(prefs.getPrefBoolean(FPref.PHASE_AI_ENDCOMBAT)); - fvAi.getLabel(PhaseType.MAIN2).setStopAtPhase(prefs.getPrefBoolean(FPref.PHASE_AI_MAIN2)); - fvAi.getLabel(PhaseType.END_OF_TURN).setStopAtPhase(prefs.getPrefBoolean(FPref.PHASE_AI_EOT)); - fvAi.getLabel(PhaseType.CLEANUP).setStopAtPhase(prefs.getPrefBoolean(FPref.PHASE_AI_CLEANUP)); - } - - if(view.getPlayerPanels().size()>3){ - fvAi = view.getBottomPlayerPanel2().getPhaseIndicator(); + for (int i=0; i playerPanels0) { @@ -77,20 +77,15 @@ public class MatchScreen extends FScreen { for (VPlayerPanel playerPanel : playerPanels0) { playerPanels.put(playerPanel.getPlayer(), scroller.add(playerPanel)); + playerPanel.setFlipped(true); } bottomPlayerPanel = playerPanels0.get(0); + bottomPlayerPanel.setFlipped(false); topPlayerPanel = playerPanels0.get(1); - topPlayerPanel.setFlipped(true); - if(is3Player()||is4Player()){ - topPlayerPanel2 = playerPanels0.get(2); - topPlayerPanel2.setFlipped(true); - } - if(is4Player()){ - bottomPlayerPanel2 = playerPanels0.get(3); - bottomPlayerPanel2.setFlipped(true); - } playerPanelsList=playerPanels0; - Collections.reverse(playerPanelsList); + //reorder list so bottom player is at the end of the list ensuring top to bottom turn order + playerPanelsList.remove(bottomPlayerPanel); + playerPanelsList.add(bottomPlayerPanel); bottomPlayerPrompt = add(new VPrompt("", "", @@ -282,22 +277,18 @@ public class MatchScreen extends FScreen { return topPlayerPanel; } - public VPlayerPanel getTopPlayerPanel2() { - return topPlayerPanel2; - } - public VPlayerPanel getBottomPlayerPanel() { return bottomPlayerPanel; } - public VPlayerPanel getBottomPlayerPanel2() { - return bottomPlayerPanel2; - } - public Map getPlayerPanels() { return playerPanels; } + public List getPlayerPanelsList() { + return playerPanelsList; + } + @Override public void onClose(Callback canCloseCallback) { MatchController.writeMatchPreferences(); @@ -516,9 +507,9 @@ public class MatchScreen extends FScreen { @Override public void drawOverlay(Graphics g) { - float midField = topPlayerPanel.getBottom(); + float midField; float x = 0; - float y = midField - topPlayerPanel.getField().getHeight(); + float y; float w = getWidth(); //field separator lines From 94e255b198b96f61b9115bdba23b80fbbcc13152 Mon Sep 17 00:00:00 2001 From: austinio7116 Date: Mon, 19 Mar 2018 12:52:49 +0000 Subject: [PATCH 6/7] Fix for broken variants with new android multiplayer code --- forge-gui-mobile/src/forge/deck/FDeckChooser.java | 4 ++++ .../src/forge/screens/constructed/LobbyScreen.java | 5 ++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/forge-gui-mobile/src/forge/deck/FDeckChooser.java b/forge-gui-mobile/src/forge/deck/FDeckChooser.java index 85e2ec895d0..173a4d42114 100644 --- a/forge-gui-mobile/src/forge/deck/FDeckChooser.java +++ b/forge-gui-mobile/src/forge/deck/FDeckChooser.java @@ -815,6 +815,10 @@ public class FDeckChooser extends FScreen { /*if(selectedDeckType.equals(DeckType.STANDARD_CARDGEN_DECK)){ return DeckgenUtil.buildCardGenDeck(lstDecks.getSelectedItem().getName()); }*/ + //ensure a deck is selected first + if(lstDecks.getSelectedIndex() == -1){ + lstDecks.setSelectedIndex(0); + } DeckProxy proxy = lstDecks.getSelectedItem(); if (proxy == null) { return null; } return proxy.getDeck(); diff --git a/forge-gui-mobile/src/forge/screens/constructed/LobbyScreen.java b/forge-gui-mobile/src/forge/screens/constructed/LobbyScreen.java index a41c249a296..ca56725750b 100644 --- a/forge-gui-mobile/src/forge/screens/constructed/LobbyScreen.java +++ b/forge-gui-mobile/src/forge/screens/constructed/LobbyScreen.java @@ -223,7 +223,7 @@ public abstract class LobbyScreen extends LaunchScreen implements ILobbyView { } void updateLayoutForVariants() { - for (int i = 0; i < MAX_PLAYERS; i++) { + for (int i = 0; i < cbPlayerCount.getSelectedItem(); i++) { playerPanels.get(i).updateVariantControlsVisibility(); } playersScroll.revalidate(); @@ -461,12 +461,11 @@ public abstract class LobbyScreen extends LaunchScreen implements ILobbyView { @Override public void update(final boolean fullUpdate) { int playerCount = lobby.getNumberOfSlots(); - //cbPlayerCount.setSelectedItem(playerCount); updateVariantSelection(); final boolean allowNetworking = lobby.isAllowNetworking(); - for (int i = 0; i < MAX_PLAYERS; i++) { + for (int i = 0; i < cbPlayerCount.getSelectedItem(); i++) { final boolean hasPanel = i < playerPanels.size(); if (i < playerCount) { // visible panels From 951a5dc9787920f746eecb737ba7b58dd3fd5a05 Mon Sep 17 00:00:00 2001 From: austinio7116 Date: Tue, 20 Mar 2018 21:53:06 +0000 Subject: [PATCH 7/7] Enabled team combo box on android now that multiplayer is possible, also attempted to prevent hanging on conceding in multiplayer games - only working on android so far --- .../src/forge/screens/constructed/PlayerPanel.java | 2 +- forge-gui/src/main/java/forge/match/AbstractGuiGame.java | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/forge-gui-mobile/src/forge/screens/constructed/PlayerPanel.java b/forge-gui-mobile/src/forge/screens/constructed/PlayerPanel.java index 2cf13216378..8f8c33009d5 100644 --- a/forge-gui-mobile/src/forge/screens/constructed/PlayerPanel.java +++ b/forge-gui-mobile/src/forge/screens/constructed/PlayerPanel.java @@ -232,7 +232,7 @@ public class PlayerPanel extends FContainer { setMayControl(mayControl0); //disable team combo boxes for now - cbTeam.setEnabled(false); + cbTeam.setEnabled(true); } public void initialize(FPref savedStateSetting, FPref savedStateSettingCommander, FPref savedStateSettingTinyLeader, DeckType defaultDeckType) { diff --git a/forge-gui/src/main/java/forge/match/AbstractGuiGame.java b/forge-gui/src/main/java/forge/match/AbstractGuiGame.java index 90f2a700a0f..027b521fd78 100644 --- a/forge-gui/src/main/java/forge/match/AbstractGuiGame.java +++ b/forge-gui/src/main/java/forge/match/AbstractGuiGame.java @@ -238,7 +238,12 @@ public abstract class AbstractGuiGame implements IGuiGame, IMayViewCards { // Don't immediately close, wait for win/lose screen return false; } else { - return true; + for(PlayerView player: getLocalPlayers()){ + if(!player.isAI()){ + getGameController(player).nextGameDecision(NextGameDecision.QUIT); + } + } + return false; } } else if (spectator == null) { @@ -421,7 +426,7 @@ public abstract class AbstractGuiGame implements IGuiGame, IMayViewCards { * @return null if choices is missing, empty, or if the users' choices are * empty; otherwise, returns the first item in the List returned by * getChoices. - * @see #getChoices(String, int, int, Object...) + * @see #getChoices(String, int, int, List) */ @Override public T oneOrNone(final String message, final List choices) {