From 6038c72e86db2eed134a33e80934fb7058c9d1a1 Mon Sep 17 00:00:00 2001 From: Shaun Bennett Date: Thu, 13 Nov 2014 19:33:39 -0600 Subject: [PATCH] Add cleaner page for when there is only 1 team --- .../game/arcade/gui/page/SpectatorPage.java | 40 +++++++++++++++++-- 1 file changed, 36 insertions(+), 4 deletions(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gui/page/SpectatorPage.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gui/page/SpectatorPage.java index a37c7b4d3..591136d3c 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gui/page/SpectatorPage.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gui/page/SpectatorPage.java @@ -44,10 +44,37 @@ public class SpectatorPage extends ShopPageBase @Override protected void BuildPage() { - int currentRow = 0; int playerCount = _arcadeManager.GetGame().GetPlayers(true).size(); List teamList = _arcadeManager.GetGame().GetTeamList(); + if (teamList.size() == 1 && playerCount < 28) + buildSingleTeam(teamList.get(0), playerCount); + else + buildMultipleTeams(teamList, playerCount); + + } + + private void buildSingleTeam(GameTeam team, int playerCount) + { + setItem(13, getTeamItem(team, playerCount)); + + int slot = 19; + + for (Player other : team.GetPlayers(true)) + { + addPlayerItem(slot, team, other); + + if ((slot + 2) % 9 == 0) + slot += 3; + else + slot++; + } + } + + private void buildMultipleTeams(List teamList, int playerCount) + { + int currentRow = 0; + for (GameTeam team : teamList) { ArrayList teamPlayers = team.GetPlayers(true); @@ -74,9 +101,7 @@ public class SpectatorPage extends ShopPageBase if (slot >= getSize()) continue; - ItemStack playerItem = getPlayerItem(team, teamPlayers.get(playerIndex)); - ShopItem shopItem = new ShopItem(playerItem, other.getName(), other.getName(), 1, false, false); - AddButton(slot, shopItem, new SpectatorButton(_arcadeManager, Player, other)); + addPlayerItem(slot, team, other); } } @@ -88,6 +113,13 @@ public class SpectatorPage extends ShopPageBase } } + private void addPlayerItem(int slot, GameTeam team, Player other) + { + ItemStack playerItem = getPlayerItem(team, other); + ShopItem shopItem = new ShopItem(playerItem, other.getName(), other.getName(), 1, false, false); + AddButton(slot, shopItem, new SpectatorButton(_arcadeManager, Player, other)); + } + private ItemStack getTeamItem(GameTeam team, int playerCount) { ItemStack item = new ItemStack(Material.WOOL, 1, (short)0, UtilColor.chatColorToWoolData(team.GetColor()));