Add cleaner page for when there is only 1 team

This commit is contained in:
Shaun Bennett 2014-11-13 19:33:39 -06:00
parent ea8b8dca15
commit 6038c72e86

View File

@ -44,10 +44,37 @@ public class SpectatorPage extends ShopPageBase<CompassAddon, SpectatorShop>
@Override @Override
protected void BuildPage() protected void BuildPage()
{ {
int currentRow = 0;
int playerCount = _arcadeManager.GetGame().GetPlayers(true).size(); int playerCount = _arcadeManager.GetGame().GetPlayers(true).size();
List<GameTeam> teamList = _arcadeManager.GetGame().GetTeamList(); List<GameTeam> 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<GameTeam> teamList, int playerCount)
{
int currentRow = 0;
for (GameTeam team : teamList) for (GameTeam team : teamList)
{ {
ArrayList<Player> teamPlayers = team.GetPlayers(true); ArrayList<Player> teamPlayers = team.GetPlayers(true);
@ -74,9 +101,7 @@ public class SpectatorPage extends ShopPageBase<CompassAddon, SpectatorShop>
if (slot >= getSize()) if (slot >= getSize())
continue; continue;
ItemStack playerItem = getPlayerItem(team, teamPlayers.get(playerIndex)); addPlayerItem(slot, team, other);
ShopItem shopItem = new ShopItem(playerItem, other.getName(), other.getName(), 1, false, false);
AddButton(slot, shopItem, new SpectatorButton(_arcadeManager, Player, other));
} }
} }
@ -88,6 +113,13 @@ public class SpectatorPage extends ShopPageBase<CompassAddon, SpectatorShop>
} }
} }
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) private ItemStack getTeamItem(GameTeam team, int playerCount)
{ {
ItemStack item = new ItemStack(Material.WOOL, 1, (short)0, UtilColor.chatColorToWoolData(team.GetColor())); ItemStack item = new ItemStack(Material.WOOL, 1, (short)0, UtilColor.chatColorToWoolData(team.GetColor()));