diff options
Diffstat (limited to 'src/main/java/me/Danker')
-rw-r--r-- | src/main/java/me/Danker/gui/DisplayGui.java | 10 | ||||
-rw-r--r-- | src/main/java/me/Danker/gui/EditLocationsGui.java | 140 | ||||
-rw-r--r-- | src/main/java/me/Danker/gui/OnlySlayerGui.java | 8 | ||||
-rw-r--r-- | src/main/java/me/Danker/gui/buttons/LocationButton.java | 61 |
4 files changed, 163 insertions, 56 deletions
diff --git a/src/main/java/me/Danker/gui/DisplayGui.java b/src/main/java/me/Danker/gui/DisplayGui.java index d71f4b9..945dbc3 100644 --- a/src/main/java/me/Danker/gui/DisplayGui.java +++ b/src/main/java/me/Danker/gui/DisplayGui.java @@ -15,7 +15,7 @@ public class DisplayGui extends GuiScreen { private boolean addSession = false; private GuiButton goBack; - //private GuiButton editLocations; + private GuiButton editLocations; private GuiButton off; private GuiButton showSession; private GuiButton zombie; @@ -46,7 +46,7 @@ public class DisplayGui extends GuiScreen { int width = sr.getScaledWidth(); goBack = new GuiButton(0, 2, height - 30, 100, 20, "Go Back"); - //editLocations = new GuiButton(0, 2, height - 55, 100, 20, "Edit Locations"); + editLocations = new GuiButton(0, 2, height - 55, 100, 20, "Edit Locations"); showSession = new GuiButton(0, width / 2 - 100, (int) (height * 0.1), "Current Session Only: " + Utils.getColouredBoolean(addSession)); off = new GuiButton(0, width / 2 - 100, (int) (height * 0.2), "Off"); zombie = new GuiButton(0, width / 2 - 190, (int) (height * 0.3), 80, 20, "Zombie"); @@ -78,7 +78,7 @@ public class DisplayGui extends GuiScreen { this.buttonList.add(catacombsF4); this.buttonList.add(catacombsF5); this.buttonList.add(catacombsF6); - //this.buttonList.add(editLocations); + this.buttonList.add(editLocations); this.buttonList.add(goBack); } @@ -107,8 +107,8 @@ public class DisplayGui extends GuiScreen { public void actionPerformed(GuiButton button) { if (button == goBack) { TheMod.guiToOpen = "dankergui1"; - //} else if (button == editLocations) { - //TheMod.guiToOpen = "editlocations"; + } else if (button == editLocations) { + TheMod.guiToOpen = "editlocations"; } else if (button == showSession) { addSession = !addSession; showSession.displayString = "Current Session Only: " + Utils.getColouredBoolean(addSession); diff --git a/src/main/java/me/Danker/gui/EditLocationsGui.java b/src/main/java/me/Danker/gui/EditLocationsGui.java index 8cfed2d..8fbc4cb 100644 --- a/src/main/java/me/Danker/gui/EditLocationsGui.java +++ b/src/main/java/me/Danker/gui/EditLocationsGui.java @@ -2,18 +2,24 @@ package me.Danker.gui; import me.Danker.commands.MoveCommand; import me.Danker.commands.ScaleCommand; -import me.Danker.handlers.TextRenderer; +import me.Danker.gui.buttons.LocationButton; +import me.Danker.handlers.ConfigHandler; import me.Danker.utils.Utils; -import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiButton; import net.minecraft.client.gui.GuiScreen; import net.minecraft.util.EnumChatFormatting; public class EditLocationsGui extends GuiScreen { + private String moving = null; private int lastMouseX = -1; private int lastMouseY = -1; + private LocationButton display; + private LocationButton dungeonTimer; + private LocationButton coords; + private LocationButton skill50; + @Override public boolean doesGuiPauseGame() { return false; @@ -22,32 +28,9 @@ public class EditLocationsGui extends GuiScreen { @Override public void initGui() { super.initGui(); - } - - @Override - public void drawScreen(int mouseX, int mouseY, float partialTicks) { - this.drawDefaultBackground(); - - Minecraft mc = Minecraft.getMinecraft(); - - drawRect(MoveCommand.coordsXY[0] - 2, MoveCommand.coordsXY[1] - 2, (int) (MoveCommand.coordsXY[0] + (139 * ScaleCommand.coordsScale)), (int) (MoveCommand.coordsXY[1] + (12 * ScaleCommand.coordsScale)), 0x40D3D3D3); - new TextRenderer(mc, "74 / 14 / -26 (141.1 / 6.7)", MoveCommand.coordsXY[0], MoveCommand.coordsXY[1], ScaleCommand.coordsScale); - - String dungeonTimerText = EnumChatFormatting.GRAY + "Wither Doors:\n" + - EnumChatFormatting.DARK_RED + "Blood Open:\n" + - EnumChatFormatting.RED + "Watcher Clear:\n" + - EnumChatFormatting.BLUE + "Boss Clear:\n" + - EnumChatFormatting.YELLOW + "Deaths:\n" + - EnumChatFormatting.YELLOW + "Puzzle Fails:"; - String dungeonTimerNums = EnumChatFormatting.GRAY + "" + 5 + "\n" + - EnumChatFormatting.DARK_RED + Utils.getTimeBetween(0, 33) + "\n" + - EnumChatFormatting.RED + Utils.getTimeBetween(0, 129) + "\n" + - EnumChatFormatting.BLUE + Utils.getTimeBetween(0, 169) + "\n" + - EnumChatFormatting.YELLOW + 2 + "\n" + - EnumChatFormatting.YELLOW + 1; - drawRect(MoveCommand.dungeonTimerXY[0] - 2, MoveCommand.dungeonTimerXY[1] - 2, (int) (MoveCommand.dungeonTimerXY[0] + (112 * ScaleCommand.dungeonTimerScale)), (int) (MoveCommand.dungeonTimerXY[1] + (56 * ScaleCommand.dungeonTimerScale)), 0x40D3D3D3); - new TextRenderer(mc, dungeonTimerText, MoveCommand.dungeonTimerXY[0], MoveCommand.dungeonTimerXY[1], ScaleCommand.dungeonTimerScale); - new TextRenderer(mc, dungeonTimerNums, (int) (MoveCommand.dungeonTimerXY[0] + (80 * ScaleCommand.dungeonTimerScale)), MoveCommand.dungeonTimerXY[1], ScaleCommand.dungeonTimerScale); + // Ease of typing + MoveCommand moc = new MoveCommand(); + ScaleCommand sc = new ScaleCommand(); String displayText = EnumChatFormatting.GOLD + "Svens Killed:\n" + EnumChatFormatting.GREEN + "Wolf Teeth:\n" + @@ -71,42 +54,99 @@ public class EditLocationsGui extends GuiScreen { EnumChatFormatting.DARK_PURPLE + "5" + "\n" + EnumChatFormatting.AQUA + Utils.getTimeBetween(0, 2678400) + "\n" + EnumChatFormatting.AQUA + "5,000"; - drawRect(MoveCommand.displayXY[0] - 2, MoveCommand.displayXY[1] - 2, (int) (MoveCommand.displayXY[0] + (144 * ScaleCommand.displayScale)), (int) (MoveCommand.displayXY[1] + (100 * ScaleCommand.displayScale)), 0x40D3D3D3); - new TextRenderer(mc, displayText, MoveCommand.displayXY[0], MoveCommand.displayXY[1], ScaleCommand.displayScale); - new TextRenderer(mc, displayNums, (int) (MoveCommand.displayXY[0] + (110 * ScaleCommand.displayScale)), MoveCommand.displayXY[1], ScaleCommand.displayScale); - drawRect(MoveCommand.skill50XY[0] - 2, MoveCommand.skill50XY[1] - 2, (int) (MoveCommand.skill50XY[0] + (232 * ScaleCommand.skill50Scale)), (int) (MoveCommand.skill50XY[1] + (12 * ScaleCommand.skill50Scale)), 0x40D3D3D3); - new TextRenderer(mc, EnumChatFormatting.AQUA + "+3.5 Farming (28,882,117.7/55,172,425) 52.34%", MoveCommand.skill50XY[0], MoveCommand.skill50XY[1], ScaleCommand.skill50Scale); + String dungeonTimerText = EnumChatFormatting.GRAY + "Wither Doors:\n" + + EnumChatFormatting.DARK_RED + "Blood Open:\n" + + EnumChatFormatting.RED + "Watcher Clear:\n" + + EnumChatFormatting.BLUE + "Boss Clear:\n" + + EnumChatFormatting.YELLOW + "Deaths:\n" + + EnumChatFormatting.YELLOW + "Puzzle Fails:"; + String dungeonTimerNums = EnumChatFormatting.GRAY + "" + 5 + "\n" + + EnumChatFormatting.DARK_RED + Utils.getTimeBetween(0, 33) + "\n" + + EnumChatFormatting.RED + Utils.getTimeBetween(0, 129) + "\n" + + EnumChatFormatting.BLUE + Utils.getTimeBetween(0, 169) + "\n" + + EnumChatFormatting.YELLOW + 2 + "\n" + + EnumChatFormatting.YELLOW + 1; + display = new LocationButton(0, moc.displayXY[0], moc.displayXY[1], 145 * sc.displayScale, 102 * sc.displayScale, sc.displayScale, displayText, displayNums, 110); + dungeonTimer = new LocationButton(0, moc.dungeonTimerXY[0], moc.dungeonTimerXY[1], 113 * sc.dungeonTimerScale, 57 * sc.dungeonTimerScale, sc.dungeonTimerScale, dungeonTimerText, dungeonTimerNums, 80); + coords = new LocationButton(0, moc.coordsXY[0], moc.coordsXY[1], 141 * sc.coordsScale, 12 * sc.coordsScale, sc.coordsScale, "74 / 14 / -26 (141.1 / 6.7)", null, null); + skill50 = new LocationButton(0, moc.skill50XY[0], moc.skill50XY[1], 233 * sc.skill50Scale, 12 * sc.skill50Scale, sc.skill50Scale, EnumChatFormatting.AQUA + "+3.5 Farming (28,882,117.7/55,172,425) 52.34%", null, null); + + this.buttonList.add(coords); + this.buttonList.add(dungeonTimer); + this.buttonList.add(display); + this.buttonList.add(skill50); + } + + @Override + public void drawScreen(int mouseX, int mouseY, float partialTicks) { + this.drawDefaultBackground(); + mouseMoved(mouseX, mouseY); super.drawScreen(mouseX, mouseY, partialTicks); } - /*@Override - public void mouseClickMove(int mouseX, int mouseY, int clickedMouseButton, long timeSinceLastClick) { - super.mouseClickMove(mouseX, mouseY, clickedMouseButton, timeSinceLastClick); - - if (lastMouseX == -1) lastMouseX = mouseX; - if (lastMouseY == -1) lastMouseY = mouseY; - + private void mouseMoved(int mouseX, int mouseY) { int xMoved = mouseX - lastMouseX; int yMoved = mouseY - lastMouseY; - // Display - if (isInsideBox(MoveCommand.displayXY[0] - 2, MoveCommand.displayXY[1] - 2, (int) (MoveCommand.displayXY[0] + (144 * ScaleCommand.displayScale)), (int) (MoveCommand.displayXY[1] + (100 * ScaleCommand.displayScale)), mouseX, mouseY)) { - System.out.println("lastMouseX: " + lastMouseX + ", mouseX: " + mouseX + ", xMoved: " + xMoved); - MoveCommand.displayXY[0] += xMoved; - MoveCommand.displayXY[1] += yMoved; + if (moving != null) { + if (moving.equals("display")) { + MoveCommand.displayXY[0] += xMoved; + MoveCommand.displayXY[1] += yMoved; + display.xPosition = MoveCommand.displayXY[0]; + display.yPosition = MoveCommand.displayXY[1]; + } else if (moving.equals("dungeonTimer")) { + MoveCommand.dungeonTimerXY[0] += xMoved; + MoveCommand.dungeonTimerXY[1] += yMoved; + dungeonTimer.xPosition = MoveCommand.dungeonTimerXY[0]; + dungeonTimer.yPosition = MoveCommand.dungeonTimerXY[1]; + } else if (moving.equals("coords")) { + MoveCommand.coordsXY[0] += xMoved; + MoveCommand.coordsXY[1] += yMoved; + coords.xPosition = MoveCommand.coordsXY[0]; + coords.yPosition = MoveCommand.coordsXY[1]; + } else if (moving.equals("skill50")) { + MoveCommand.skill50XY[0] += xMoved; + MoveCommand.skill50XY[1] += yMoved; + skill50.xPosition = MoveCommand.skill50XY[0]; + skill50.yPosition = MoveCommand.skill50XY[1]; + } + this.buttonList.clear(); + initGui(); } lastMouseX = mouseX; lastMouseY = mouseY; } - boolean isInsideBox(int x1, int y1, int x2, int y2, int x, int y) { - if (x >= x1 && x <= x2 && y >= y1 && y <= y2) { - return true; + @Override + public void actionPerformed(GuiButton button) { + if (button instanceof LocationButton) { + if (button == display) { + moving = "display"; + } else if (button == dungeonTimer) { + moving = "dungeonTimer"; + } else if (button == coords) { + moving = "coords"; + } else if (button == skill50) { + moving = "skill50"; + } } - return false; - }*/ + } + + @Override + public void mouseReleased(int mouseX, int mouseY, int state) { + super.mouseReleased(mouseX, mouseY, state); + moving = null; + ConfigHandler.writeIntConfig("locations", "coordsX", MoveCommand.coordsXY[0]); + ConfigHandler.writeIntConfig("locations", "coordsY", MoveCommand.coordsXY[1]); + ConfigHandler.writeIntConfig("locations", "displayX", MoveCommand.displayXY[0]); + ConfigHandler.writeIntConfig("locations", "displayY", MoveCommand.displayXY[1]); + ConfigHandler.writeIntConfig("locations", "dungeonTimerX", MoveCommand.dungeonTimerXY[0]); + ConfigHandler.writeIntConfig("locations", "dungeonTimerY", MoveCommand.dungeonTimerXY[1]); + ConfigHandler.writeIntConfig("locations", "skill50X", MoveCommand.skill50XY[0]); + ConfigHandler.writeIntConfig("locations", "skill50Y", MoveCommand.skill50XY[1]); + } } diff --git a/src/main/java/me/Danker/gui/OnlySlayerGui.java b/src/main/java/me/Danker/gui/OnlySlayerGui.java index 0573777..c96bfd6 100644 --- a/src/main/java/me/Danker/gui/OnlySlayerGui.java +++ b/src/main/java/me/Danker/gui/OnlySlayerGui.java @@ -1,5 +1,6 @@ package me.Danker.gui; +import me.Danker.TheMod; import me.Danker.commands.BlockSlayerCommand; import me.Danker.handlers.ConfigHandler; import me.Danker.handlers.TextRenderer; @@ -13,6 +14,7 @@ public class OnlySlayerGui extends GuiScreen { private int onlyNumberInt = 4; private String onlyName = "Revenant Horror"; + private GuiButton goBack; private GuiButton off; private GuiButton zombie; private GuiButton spider; @@ -46,6 +48,7 @@ public class OnlySlayerGui extends GuiScreen { onlyNumberInt = 4; } + goBack = new GuiButton(0, 2, height - 30, 100, 20, "Go Back"); off = new GuiButton(0, width / 2 - 100, (int) (height * 0.3), "Off"); zombie = new GuiButton(0, width / 2 - 200, (int) (height * 0.4), 120, 20, "Zombie"); spider = new GuiButton(0, width / 2 - 60, (int) (height * 0.4), 120, 20, "Spider"); @@ -63,6 +66,7 @@ public class OnlySlayerGui extends GuiScreen { this.buttonList.add(two); this.buttonList.add(three); this.buttonList.add(four); + this.buttonList.add(goBack); } @Override @@ -84,7 +88,9 @@ public class OnlySlayerGui extends GuiScreen { @Override public void actionPerformed(GuiButton button) { - if (button == off) { + if (button == goBack) { + TheMod.guiToOpen = "dankergui1"; + } else if (button == off) { BlockSlayerCommand.onlySlayerName = ""; BlockSlayerCommand.onlySlayerNumber = ""; ConfigHandler.writeStringConfig("toggles", "BlockSlayer", ""); diff --git a/src/main/java/me/Danker/gui/buttons/LocationButton.java b/src/main/java/me/Danker/gui/buttons/LocationButton.java new file mode 100644 index 0000000..061f198 --- /dev/null +++ b/src/main/java/me/Danker/gui/buttons/LocationButton.java @@ -0,0 +1,61 @@ +package me.Danker.gui.buttons; + +import me.Danker.handlers.TextRenderer; +import net.minecraft.client.Minecraft; +import net.minecraft.client.audio.SoundHandler; +import net.minecraft.client.gui.GuiButton; + +public class LocationButton extends GuiButton { + + private int x; + private int y; + private double scale; + private String text; + private String text2; + private Integer text2Offset; + + public LocationButton(int buttonId, int x, int y, double width, double height, double scale, String text, String text2, Integer text2Offset) { + super(buttonId, x, y, text); + this.x = x; + this.y = y; + this.width = (int) width; + this.height = (int) height; + this.scale = scale; + this.text = text; + this.text2 = text2; + this.text2Offset = text2Offset; + } + + @Override + public void drawButton(Minecraft mc, int mouseX, int mouseY) { + String[] splitText; + if (text2 == null) { + splitText = text.split("\n"); + } else { + splitText = text2.split("\n"); + } + int index = 0; + int longestText = -1; + for (int i = 0; i < splitText.length; i++) { + int stringLength = mc.fontRendererObj.getStringWidth(splitText[i]); + if (stringLength > longestText) { + index = i; + longestText = stringLength; + } + } + + if (text2 == null) { + drawRect(x - 2, y - 2, (int) (x + longestText * scale + 3), (int) (y + (splitText.length * 9 + 3) * scale), 0x40D3D3D3); + } else { + drawRect(x - 2, y - 2, (int) (x + (longestText + text2Offset) * scale + 3), (int) (y + (splitText.length * 9 + 3) * scale), 0x40D3D3D3); + new TextRenderer(mc, text2, (int) (x + (text2Offset * scale)), y, scale); + } + new TextRenderer(mc, text, x, y, scale); + } + + @Override + public void playPressSound(SoundHandler soundHandler) { + + } + +} |