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..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,9 +45,13 @@ 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())); + 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 += 30; + x += 90; y = ((this.height - this.ySize) / 2) + 130; } else { y -= 30; @@ -61,7 +65,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 +98,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,