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);