From e056beb62b73dd26368fd6470c2e802feab9a32a Mon Sep 17 00:00:00 2001 From: Scott Barbour Date: Tue, 18 Nov 2014 02:04:40 -0600 Subject: [PATCH 1/2] Change GUI to show floor name --- .../presentation/gui/GuiFloorButton.java | 17 +++++++++++++++++ .../presentation/gui/GuiFloorSelection.java | 19 +++++++++++++------ 2 files changed, 30 insertions(+), 6 deletions(-) create mode 100644 src/main/java/net/slimevoid/dynamictransport/client/presentation/gui/GuiFloorButton.java diff --git a/src/main/java/net/slimevoid/dynamictransport/client/presentation/gui/GuiFloorButton.java b/src/main/java/net/slimevoid/dynamictransport/client/presentation/gui/GuiFloorButton.java new file mode 100644 index 0000000..6e1b778 --- /dev/null +++ b/src/main/java/net/slimevoid/dynamictransport/client/presentation/gui/GuiFloorButton.java @@ -0,0 +1,17 @@ +package net.slimevoid.dynamictransport.client.presentation.gui; + +import net.minecraft.client.gui.GuiButton; + +public class GuiFloorButton extends GuiButton { + + private String floorLevel; + + public GuiFloorButton(int id, int x, int y, int width, int height, String floorLevel, String floorName) { + super(id,x,y,width,height,floorName); + this.floorLevel = floorLevel; + } + + public String getFloorLevel() { + return this.floorLevel; + } +} diff --git a/src/main/java/net/slimevoid/dynamictransport/client/presentation/gui/GuiFloorSelection.java b/src/main/java/net/slimevoid/dynamictransport/client/presentation/gui/GuiFloorSelection.java index 88f01ee..9060e30 100644 --- a/src/main/java/net/slimevoid/dynamictransport/client/presentation/gui/GuiFloorSelection.java +++ b/src/main/java/net/slimevoid/dynamictransport/client/presentation/gui/GuiFloorSelection.java @@ -45,9 +45,9 @@ public void initGui() { int y = ((this.height - this.ySize) / 2) + 130; int id = 0; for (Entry> set : floorList.entrySet()) { - this.buttonList.add(new GuiButton(id++, x, y, 20, 20, set.getKey().toString())); + this.buttonList.add(new GuiFloorButton(id++, x, y, 80, 20, set.getKey().toString(), set.getValue().get(0))); if (y < ((this.height - this.ySize) / 2) + 30) { - x += 30; + x += 90; y = ((this.height - this.ySize) / 2) + 130; } else { y -= 30; @@ -61,7 +61,7 @@ public void initGui() { @Override protected void drawGuiContainerForegroundLayer(int i, int j){ for (Object x : buttonList) { - GuiButton set = (GuiButton)x; + GuiFloorButton set = (GuiFloorButton)x; if (i >= set.xPosition && j >= set.yPosition && i < set.xPosition + 20 && j < set.yPosition + 20){ } @@ -94,15 +94,22 @@ protected void drawGuiContainerBackgroundLayer(float f, int i, int j) { } @Override - protected void actionPerformed(GuiButton guibutton) { + protected void actionPerformed(GuiButton button) { + GuiFloorButton guibutton; + if (button instanceof GuiFloorButton) { + guibutton = (GuiFloorButton) button; + } else { + System.out.println("Something went wrong!"); + return; + } String floorName = ""; - for(String name :marker.getFloorList().get(Integer.parseInt(guibutton.displayString))){ + for(String name :marker.getFloorList().get(Integer.parseInt(guibutton.getFloorLevel()))){ floorName = name + ", "; } if (floorName.length() > 0) { floorName = floorName.substring(0,floorName.length() - 2); } - PacketLib.sendFloorSelection(guibutton.displayString, + PacketLib.sendFloorSelection(guibutton.getFloorLevel(), floorName, this.marker.xCoord, this.marker.yCoord, From 63fe81e5befff41683a26b1773314ce2b79ab71c Mon Sep 17 00:00:00 2001 From: Scott Barbour Date: Tue, 18 Nov 2014 02:34:33 -0600 Subject: [PATCH 2/2] Use Y level (as was the case for all buttons previously) if the floor is unnamed. --- .../client/presentation/gui/GuiFloorSelection.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main/java/net/slimevoid/dynamictransport/client/presentation/gui/GuiFloorSelection.java b/src/main/java/net/slimevoid/dynamictransport/client/presentation/gui/GuiFloorSelection.java index 9060e30..511b9f9 100644 --- a/src/main/java/net/slimevoid/dynamictransport/client/presentation/gui/GuiFloorSelection.java +++ b/src/main/java/net/slimevoid/dynamictransport/client/presentation/gui/GuiFloorSelection.java @@ -45,7 +45,11 @@ public void initGui() { int y = ((this.height - this.ySize) / 2) + 130; int id = 0; for (Entry> set : floorList.entrySet()) { - this.buttonList.add(new GuiFloorButton(id++, x, y, 80, 20, set.getKey().toString(), set.getValue().get(0))); + String floorName = set.getKey().toString(); + if (set.getValue().size() > 0) { + floorName = set.getValue().get(0); + } + this.buttonList.add(new GuiFloorButton(id++, x, y, 80, 20, set.getKey().toString(), floorName)); if (y < ((this.height - this.ySize) / 2) + 30) { x += 90; y = ((this.height - this.ySize) / 2) + 130;