Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change GUI to show floor name #38

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,13 @@ public void initGui() {
int y = ((this.height - this.ySize) / 2) + 130;
int id = 0;
for (Entry<Integer, ArrayList<String>> 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;
Expand All @@ -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){

}
Expand Down Expand Up @@ -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,
Expand Down