aboutsummaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/me/Danker/gui/CrystalHollowAddWaypointGui.java118
-rw-r--r--src/main/java/me/Danker/gui/CrystalHollowWaypointActionGui.java7
-rw-r--r--src/main/java/me/Danker/gui/CrystalHollowWaypointsGui.java9
3 files changed, 132 insertions, 2 deletions
diff --git a/src/main/java/me/Danker/gui/CrystalHollowAddWaypointGui.java b/src/main/java/me/Danker/gui/CrystalHollowAddWaypointGui.java
new file mode 100644
index 0000000..7bb26cf
--- /dev/null
+++ b/src/main/java/me/Danker/gui/CrystalHollowAddWaypointGui.java
@@ -0,0 +1,118 @@
+package me.Danker.gui;
+
+import me.Danker.features.CrystalHollowWaypoints;
+import me.Danker.handlers.TextRenderer;
+import net.minecraft.client.Minecraft;
+import net.minecraft.client.gui.GuiButton;
+import net.minecraft.client.gui.GuiScreen;
+import net.minecraft.client.gui.GuiTextField;
+import net.minecraft.client.gui.ScaledResolution;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.util.BlockPos;
+
+import java.io.IOException;
+
+public class CrystalHollowAddWaypointGui extends GuiScreen {
+
+ private GuiButton cancel;
+
+ private GuiTextField name;
+ private GuiButton curPos;
+ private GuiTextField x;
+ private GuiTextField y;
+ private GuiTextField z;
+ private GuiButton add;
+
+ @Override
+ public boolean doesGuiPauseGame() {
+ return false;
+ }
+
+ @Override
+ public void initGui() {
+ super.initGui();
+
+ ScaledResolution sr = new ScaledResolution(Minecraft.getMinecraft());
+ int height = sr.getScaledHeight();
+ int width = sr.getScaledWidth();
+
+ cancel = new GuiButton(0, 2, height - 30, 100, 20, "Cancel");
+
+ name = new GuiTextField(0, this.fontRendererObj, width / 2 - 100, (int) (height * 0.1), 200, 20);
+ curPos = new GuiButton(0, width / 2 - 50, (int) (height * 0.25), 100, 20, "Current Position");
+ x = new GuiTextField(0, this.fontRendererObj, width / 2 - 85, (int) (height * 0.4), 50, 20);
+ y = new GuiTextField(0, this.fontRendererObj, width / 2 - 25, (int) (height * 0.4), 50, 20);
+ z = new GuiTextField(0, this.fontRendererObj, width / 2 + 35, (int) (height * 0.4), 50, 20);
+ add = new GuiButton(0, width / 2 - 25, (int) (height * 0.6), 50, 20, "Add");
+
+ name.setVisible(true);
+ name.setEnabled(true);
+ x.setVisible(true);
+ x.setEnabled(true);
+ y.setVisible(true);
+ y.setEnabled(true);
+ z.setVisible(true);
+ z.setEnabled(true);
+
+ this.buttonList.add(cancel);
+ this.buttonList.add(curPos);
+ this.buttonList.add(add);
+ }
+
+ @Override
+ public void drawScreen(int mouseX, int mouseY, float partialTicks) {
+ this.drawDefaultBackground();
+ super.drawScreen(mouseX, mouseY, partialTicks);
+
+ name.drawTextBox();
+ x.drawTextBox();
+ y.drawTextBox();
+ z.drawTextBox();
+
+ new TextRenderer(mc, "X:", width / 2 - 85, (int) (height * 0.35), 1D);
+ new TextRenderer(mc, "Y:", width / 2 - 25, (int) (height * 0.35), 1D);
+ new TextRenderer(mc, "Z:", width / 2 + 35, (int) (height * 0.35), 1D);
+ }
+
+ @Override
+ public void actionPerformed(GuiButton button) {
+ EntityPlayer player = Minecraft.getMinecraft().thePlayer;
+
+ if (button == cancel) {
+ mc.displayGuiScreen(new CrystalHollowWaypointsGui(1));
+ } else if (button == curPos) {
+ x.setText(Integer.toString(player.getPosition().getX()));
+ y.setText(Integer.toString(player.getPosition().getY()));
+ z.setText(Integer.toString(player.getPosition().getZ()));
+ } else if (button == add) {
+ String loc = name.getText().length() == 0 ? Integer.toString(CrystalHollowWaypoints.waypoints.size()) : name.getText();
+ int xPos = x.getText().matches("[-]?\\d+") ? Integer.parseInt(x.getText()) : player.getPosition().getX();
+ int yPos = y.getText().matches("[-]?\\d+") ? Integer.parseInt(y.getText()) : player.getPosition().getY();
+ int zPos = z.getText().matches("[-]?\\d+") ? Integer.parseInt(z.getText()) : player.getPosition().getZ();
+
+ BlockPos pos = new BlockPos(xPos, yPos, zPos);
+ CrystalHollowWaypoints.waypoints.add(new CrystalHollowWaypoints.Waypoint(loc, pos));
+
+ mc.displayGuiScreen(new CrystalHollowWaypointsGui(1));
+ }
+ }
+
+ @Override
+ protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException {
+ super.mouseClicked(mouseX, mouseY, mouseButton);
+ name.mouseClicked(mouseX, mouseY, mouseButton);
+ x.mouseClicked(mouseX, mouseY, mouseButton);
+ y.mouseClicked(mouseX, mouseY, mouseButton);
+ z.mouseClicked(mouseX, mouseY, mouseButton);
+ }
+
+ @Override
+ protected void keyTyped(char typedChar, int keyCode) throws IOException {
+ super.keyTyped(typedChar, keyCode);
+ name.textboxKeyTyped(typedChar, keyCode);
+ x.textboxKeyTyped(typedChar, keyCode);
+ y.textboxKeyTyped(typedChar, keyCode);
+ z.textboxKeyTyped(typedChar, keyCode);
+ }
+
+}
diff --git a/src/main/java/me/Danker/gui/CrystalHollowWaypointActionGui.java b/src/main/java/me/Danker/gui/CrystalHollowWaypointActionGui.java
index d7f598d..1575c18 100644
--- a/src/main/java/me/Danker/gui/CrystalHollowWaypointActionGui.java
+++ b/src/main/java/me/Danker/gui/CrystalHollowWaypointActionGui.java
@@ -2,6 +2,7 @@ package me.Danker.gui;
import me.Danker.DankersSkyblockMod;
import me.Danker.features.CrystalHollowWaypoints;
+import me.Danker.handlers.TextRenderer;
import me.Danker.utils.Utils;
import net.minecraft.client.Minecraft;
import net.minecraft.client.entity.EntityPlayerSP;
@@ -59,6 +60,12 @@ public class CrystalHollowWaypointActionGui extends GuiScreen {
public void drawScreen(int mouseX, int mouseY, float partialTicks) {
this.drawDefaultBackground();
super.drawScreen(mouseX, mouseY, partialTicks);
+
+ CrystalHollowWaypoints.Waypoint waypoint = CrystalHollowWaypoints.waypoints.get(id);
+
+ String waypointText = waypoint.location + " @ " + waypoint.getPos();
+ int pageWidth = mc.fontRendererObj.getStringWidth(waypointText);
+ new TextRenderer(mc, waypointText, width / 2 - pageWidth / 2, 10, 1D);
}
@Override
diff --git a/src/main/java/me/Danker/gui/CrystalHollowWaypointsGui.java b/src/main/java/me/Danker/gui/CrystalHollowWaypointsGui.java
index 392f16b..de20cf1 100644
--- a/src/main/java/me/Danker/gui/CrystalHollowWaypointsGui.java
+++ b/src/main/java/me/Danker/gui/CrystalHollowWaypointsGui.java
@@ -18,14 +18,15 @@ import java.util.List;
public class CrystalHollowWaypointsGui extends GuiScreen {
- private int page;
- private List<GuiButton> allButtons = new ArrayList<>();
+ private final int page;
+ private final List<GuiButton> allButtons = new ArrayList<>();
private GuiButton goBack;
private GuiButton backPage;
private GuiButton nextPage;
private GuiButton sendDSM;
private GuiButton sendSBE;
+ private GuiButton add;
private FeatureButton crystalHollowWaypoints;
private FeatureButton crystalAutoWaypoints;
@@ -51,10 +52,12 @@ public class CrystalHollowWaypointsGui extends GuiScreen {
nextPage = new GuiButton(0, width / 2 + 20, (int) (height * 0.8), 80, 20, "Next >");
sendDSM = new GuiButton(0, 2, 10, 175, 20, "Send DSM Formatted Waypoints");
sendSBE = new GuiButton(0, 2, 40, 175, 20, "Send SBE Formatted Waypoints");
+ add = new GuiButton(0, 0, 0, "Add Waypoint");
crystalHollowWaypoints = new FeatureButton("Crystal Hollows Waypoints: " + Utils.getColouredBoolean(ToggleCommand.crystalHollowWaypoints), "Shows waypoints to various places in the Crystal Hollows.");
crystalAutoWaypoints = new FeatureButton("Auto Waypoints: " + Utils.getColouredBoolean(ToggleCommand.crystalAutoWaypoints), "Automatically creates waypoints when you visit a special place in the Crystal Hollows.");
allButtons.clear();
+ allButtons.add(add);
allButtons.add(crystalHollowWaypoints);
allButtons.add(crystalAutoWaypoints);
for (int i = 0; i < CrystalHollowWaypoints.waypoints.size(); i++) {
@@ -123,6 +126,8 @@ public class CrystalHollowWaypointsGui extends GuiScreen {
message.insert(0, "$SBECHWP:");
player.sendChatMessage(message.toString());
}
+ } else if (button == add) {
+ mc.displayGuiScreen(new CrystalHollowAddWaypointGui());
} else if (button == crystalHollowWaypoints) {
ToggleCommand.crystalHollowWaypoints = !ToggleCommand.crystalHollowWaypoints;
ConfigHandler.writeBooleanConfig("toggles", "CrystalHollowWaypoints", ToggleCommand.crystalHollowWaypoints);