diff options
author | Clicks <58398364+CuzImClicks@users.noreply.github.com> | 2022-04-29 11:24:43 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-04-29 11:24:43 +0200 |
commit | 48253eddf00cf5d94ecc2eb6b63e7c490b3145be (patch) | |
tree | b74b3674eb12a168e3e93da1f3ff0119116c3411 /src/main/java/me/Danker/gui | |
parent | 5f6ce80319b21d53abbec15886f4e2fbd765f748 (diff) | |
parent | 36a30bd1a2097b6ab45c27bd248cbea4e292499f (diff) | |
download | SkyblockMod-48253eddf00cf5d94ecc2eb6b63e7c490b3145be.tar.gz SkyblockMod-48253eddf00cf5d94ecc2eb6b63e7c490b3145be.tar.bz2 SkyblockMod-48253eddf00cf5d94ecc2eb6b63e7c490b3145be.zip |
Merge branch 'development' into development
Diffstat (limited to 'src/main/java/me/Danker/gui')
9 files changed, 373 insertions, 20 deletions
diff --git a/src/main/java/me/Danker/gui/DankerGui.java b/src/main/java/me/Danker/gui/DankerGui.java index 95c0629..f4319a8 100644 --- a/src/main/java/me/Danker/gui/DankerGui.java +++ b/src/main/java/me/Danker/gui/DankerGui.java @@ -2,6 +2,7 @@ package me.Danker.gui; import me.Danker.commands.ToggleCommand; import me.Danker.gui.alerts.AlertsGui; +import me.Danker.gui.aliases.AliasesGui; import me.Danker.gui.buttons.FeatureButton; import me.Danker.gui.crystalhollowwaypoints.CrystalHollowWaypointsGui; import me.Danker.handlers.ConfigHandler; @@ -46,6 +47,7 @@ public class DankerGui extends GuiScreen { private GuiButton customMusic; private GuiButton crystalHollowWaypoints; private GuiButton alerts; + private GuiButton aliases; // Toggles private GuiButton gparty; private GuiButton coords; @@ -89,6 +91,7 @@ public class DankerGui extends GuiScreen { private GuiButton dungeonScore; private GuiButton hideArmour; private GuiButton autoJoinSkyblock; + private GuiButton firePillar; // Chat Messages private GuiButton sceptreMessages; private GuiButton midasStaffMessages; @@ -133,6 +136,7 @@ public class DankerGui extends GuiScreen { customMusic = new GuiButton(0, 0, 0, "Custom Music"); crystalHollowWaypoints = new GuiButton(0, 0, 0, "Crystal Hollows Waypoints"); alerts = new GuiButton(0, 0, 0, "Alerts"); + aliases = new GuiButton(0, 0, 0, "Aliases"); outlineText = new FeatureButton("Outline Displayed Text: " + Utils.getColouredBoolean(ToggleCommand.outlineTextToggled), "Adds bold outline to on-screen text."); pickBlock = new FeatureButton("Auto-Swap to Pick Block: " + Utils.getColouredBoolean(ToggleCommand.swapToPickBlockToggled), "Automatically changes left clicks to middle clicks.\nHelpful when lagging."); coords = new FeatureButton("Coordinate/Angle Display: " + Utils.getColouredBoolean(ToggleCommand.coordsToggled), "Displays coordinates and angle."); @@ -182,6 +186,7 @@ public class DankerGui extends GuiScreen { dungeonScore = new FeatureButton("Dungeon Score Display: " + Utils.getColouredBoolean(ToggleCommand.dungeonScore), "Displays an estimated dungeon score with secrets."); hideArmour = new FeatureButton("Hide Player Armour: " + Utils.getColouredBoolean(ToggleCommand.hideArmour), "Makes player armour invisible, showing their skin."); autoJoinSkyblock = new FeatureButton("Automatically Join Skyblock: " + Utils.getColouredBoolean(ToggleCommand.autoJoinSkyblock), "Automatically join Skyblock when you join Hypixel.\nYou have an addiction."); + firePillar = new FeatureButton("Fire Pillar Display: " + Utils.getColouredBoolean(ToggleCommand.firePillar), "Displays blaze fire pillar text on screen"); allButtons.clear(); allButtons.add(changeDisplay); @@ -192,6 +197,7 @@ public class DankerGui extends GuiScreen { allButtons.add(customMusic); allButtons.add(crystalHollowWaypoints); allButtons.add(alerts); + allButtons.add(aliases); allButtons.add(outlineText); allButtons.add(pickBlock); allButtons.add(coords); @@ -241,6 +247,7 @@ public class DankerGui extends GuiScreen { allButtons.add(dungeonScore); allButtons.add(hideArmour); allButtons.add(autoJoinSkyblock); + allButtons.add(firePillar); search.setText(initSearchText); search.setVisible(true); @@ -336,6 +343,8 @@ public class DankerGui extends GuiScreen { mc.displayGuiScreen(new CrystalHollowWaypointsGui(1)); } else if (button == alerts) { mc.displayGuiScreen(new AlertsGui(1)); + } else if (button == aliases) { + mc.displayGuiScreen(new AliasesGui(1)); } else if (button == outlineText) { ToggleCommand.outlineTextToggled = !ToggleCommand.outlineTextToggled; ConfigHandler.writeBooleanConfig("toggles", "OutlineText", ToggleCommand.outlineTextToggled); @@ -532,6 +541,10 @@ public class DankerGui extends GuiScreen { ToggleCommand.autoJoinSkyblock = !ToggleCommand.autoJoinSkyblock; ConfigHandler.writeBooleanConfig("toggles", "AutoJoinSkyblock", ToggleCommand.autoJoinSkyblock); autoJoinSkyblock.displayString = "Automatically Join Skyblock: " + Utils.getColouredBoolean(ToggleCommand.autoJoinSkyblock); + } else if (button == firePillar) { + ToggleCommand.firePillar = !ToggleCommand.firePillar; + ConfigHandler.writeBooleanConfig("toggles", "FirePillar", ToggleCommand.firePillar); + firePillar.displayString = "Fire Pillar Display: " + Utils.getColouredBoolean(ToggleCommand.firePillar); } } diff --git a/src/main/java/me/Danker/gui/EditLocationsGui.java b/src/main/java/me/Danker/gui/EditLocationsGui.java index b7f4b02..24f0908 100644 --- a/src/main/java/me/Danker/gui/EditLocationsGui.java +++ b/src/main/java/me/Danker/gui/EditLocationsGui.java @@ -33,6 +33,7 @@ public class EditLocationsGui extends GuiScreen { private LocationButton giantHP; private LocationButton abilityCooldown; private LocationButton dungeonScore; + private LocationButton firePillar; @Override public boolean doesGuiPauseGame() { @@ -120,18 +121,19 @@ public class EditLocationsGui extends GuiScreen { display = new LocationButton(MoveCommand.displayXY[0], MoveCommand.displayXY[1], ScaleCommand.displayScale, displayText, displayNums, 110); dungeonTimer = new LocationButton(MoveCommand.dungeonTimerXY[0], MoveCommand.dungeonTimerXY[1], ScaleCommand.dungeonTimerScale, dungeonTimerText, dungeonTimerNums, 80); - coords = new LocationButton(MoveCommand.coordsXY[0], MoveCommand.coordsXY[1], ScaleCommand.coordsScale, NoF3Coords.COORDS_COLOUR + "74 / 14 / -26 (141.1 / 6.7)", null, null); - skill50 = new LocationButton(MoveCommand.skill50XY[0], MoveCommand.skill50XY[1], ScaleCommand.skill50Scale, Skill50Display.SKILL_50_COLOUR + "+3.5 Farming (28,882,117.7/55,172,425) 52.34%", null, null); - lividHP = new LocationButton(MoveCommand.lividHpXY[0], MoveCommand.lividHpXY[1], ScaleCommand.lividHpScale, EnumChatFormatting.WHITE + "﴾ Livid " + EnumChatFormatting.YELLOW + "6.9M" + EnumChatFormatting.RED + "❤ " + EnumChatFormatting.WHITE + "﴿", null, null); - cakeTimer = new LocationButton(MoveCommand.cakeTimerXY[0], MoveCommand.cakeTimerXY[1] + 5, ScaleCommand.cakeTimerScale, CakeTimer.CAKE_COLOUR + " 11h16m", null, null); - skillTracker = new LocationButton(MoveCommand.skillTrackerXY[0], MoveCommand.skillTrackerXY[1], ScaleCommand.skillTrackerScale, skillTrackerText, null, null); - waterAnswer = new LocationButton(MoveCommand.waterAnswerXY[0], MoveCommand.waterAnswerXY[1], ScaleCommand.waterAnswerScale, waterAnswerText, null, null); - bonzoTimer = new LocationButton(MoveCommand.bonzoTimerXY[0], MoveCommand.bonzoTimerXY[1] + 5, ScaleCommand.bonzoTimerScale, BonzoMaskTimer.BONZO_COLOR + " 3m30s", null, null); - golemTimer = new LocationButton(MoveCommand.golemTimerXY[0], MoveCommand.golemTimerXY[1] + 5, ScaleCommand.golemTimerScale, GolemSpawningAlert.GOLEM_COLOUR + " 20s", null, null); - teammatesInRadius = new LocationButton(MoveCommand.teammatesInRadiusXY[0], MoveCommand.teammatesInRadiusXY[1], ScaleCommand.teammatesInRadiusScale, teammatesInRadiusText, null, null); - giantHP = new LocationButton(MoveCommand.giantHPXY[0], MoveCommand.giantHPXY[1], ScaleCommand.giantHPScale, giantHPText, null, null); - abilityCooldown = new LocationButton(MoveCommand.abilityCooldownsXY[0], MoveCommand.abilityCooldownsXY[1], ScaleCommand.abilityCooldownsScale, abilityCooldownText, null, null); + coords = new LocationButton(MoveCommand.coordsXY[0], MoveCommand.coordsXY[1], ScaleCommand.coordsScale, NoF3Coords.COORDS_COLOUR + "74 / 14 / -26 (141.1 / 6.7)"); + skill50 = new LocationButton(MoveCommand.skill50XY[0], MoveCommand.skill50XY[1], ScaleCommand.skill50Scale, Skill50Display.SKILL_50_COLOUR + "+3.5 Farming (28,882,117.7/55,172,425) 52.34%"); + lividHP = new LocationButton(MoveCommand.lividHpXY[0], MoveCommand.lividHpXY[1], ScaleCommand.lividHpScale, EnumChatFormatting.WHITE + "﴾ Livid " + EnumChatFormatting.YELLOW + "6.9M" + EnumChatFormatting.RED + "❤ " + EnumChatFormatting.WHITE + "﴿"); + cakeTimer = new LocationButton(MoveCommand.cakeTimerXY[0], MoveCommand.cakeTimerXY[1] + 5, ScaleCommand.cakeTimerScale, CakeTimer.CAKE_COLOUR + " 11h16m"); + skillTracker = new LocationButton(MoveCommand.skillTrackerXY[0], MoveCommand.skillTrackerXY[1], ScaleCommand.skillTrackerScale, skillTrackerText); + waterAnswer = new LocationButton(MoveCommand.waterAnswerXY[0], MoveCommand.waterAnswerXY[1], ScaleCommand.waterAnswerScale, waterAnswerText); + bonzoTimer = new LocationButton(MoveCommand.bonzoTimerXY[0], MoveCommand.bonzoTimerXY[1] + 5, ScaleCommand.bonzoTimerScale, BonzoMaskTimer.BONZO_COLOR + " 3m30s"); + golemTimer = new LocationButton(MoveCommand.golemTimerXY[0], MoveCommand.golemTimerXY[1] + 5, ScaleCommand.golemTimerScale, GolemSpawningAlert.GOLEM_COLOUR + " 20s"); + teammatesInRadius = new LocationButton(MoveCommand.teammatesInRadiusXY[0], MoveCommand.teammatesInRadiusXY[1], ScaleCommand.teammatesInRadiusScale, teammatesInRadiusText); + giantHP = new LocationButton(MoveCommand.giantHPXY[0], MoveCommand.giantHPXY[1], ScaleCommand.giantHPScale, giantHPText); + abilityCooldown = new LocationButton(MoveCommand.abilityCooldownsXY[0], MoveCommand.abilityCooldownsXY[1], ScaleCommand.abilityCooldownsScale, abilityCooldownText); dungeonScore = new LocationButton(MoveCommand.dungeonScoreXY[0], MoveCommand.dungeonScoreXY[1], ScaleCommand.dungeonScoreScale, dungeonScoreText, dungeonScoreNums, 80); + firePillar = new LocationButton(MoveCommand.firePillarXY[0], MoveCommand.firePillarXY[1], ScaleCommand.firePillarScale, EnumChatFormatting.GOLD + "3s " + EnumChatFormatting.RED + "8 hits"); this.buttonList.add(coords); this.buttonList.add(dungeonTimer); @@ -147,6 +149,7 @@ public class EditLocationsGui extends GuiScreen { this.buttonList.add(giantHP); this.buttonList.add(abilityCooldown); this.buttonList.add(dungeonScore); + this.buttonList.add(firePillar); } @Override @@ -267,6 +270,12 @@ public class EditLocationsGui extends GuiScreen { MoveCommand.dungeonScoreXY[1] += yMoved; dungeonScore.xPosition = MoveCommand.dungeonScoreXY[0]; dungeonScore.yPosition = MoveCommand.dungeonScoreXY[1]; + break; + case "firePillar": + MoveCommand.firePillarXY[0] += xMoved; + MoveCommand.firePillarXY[1] += yMoved; + firePillar.xPosition = MoveCommand.firePillarXY[0]; + firePillar.yPosition = MoveCommand.firePillarXY[1]; } this.buttonList.clear(); initGui(); @@ -307,6 +316,8 @@ public class EditLocationsGui extends GuiScreen { moving = "abilityCooldown"; } else if (button == dungeonScore) { moving = "dungeonScore"; + } else if (button == firePillar) { + moving = "firePillar"; } } } @@ -343,6 +354,8 @@ public class EditLocationsGui extends GuiScreen { ConfigHandler.writeIntConfig("locations", "abilityCooldownsY", MoveCommand.abilityCooldownsXY[1]); ConfigHandler.writeIntConfig("locations", "dungeonScoreX", MoveCommand.dungeonScoreXY[0]); ConfigHandler.writeIntConfig("locations", "dungeonScoreY", MoveCommand.dungeonScoreXY[1]); + ConfigHandler.writeIntConfig("locations", "firePillarX", MoveCommand.firePillarXY[0]); + ConfigHandler.writeIntConfig("locations", "firePillarY", MoveCommand.firePillarXY[1]); } } diff --git a/src/main/java/me/Danker/gui/alerts/AlertActionGui.java b/src/main/java/me/Danker/gui/alerts/AlertActionGui.java index 7a73f5a..4853ac1 100644 --- a/src/main/java/me/Danker/gui/alerts/AlertActionGui.java +++ b/src/main/java/me/Danker/gui/alerts/AlertActionGui.java @@ -60,9 +60,6 @@ public class AlertActionGui extends GuiScreen { Alerts.Alert alert = Alerts.alerts.get(id); RenderUtils.drawCenteredText(alert.alert, width, 10, 1D); - String alertText = alert.alert; - int textWidth = mc.fontRendererObj.getStringWidth(alertText); - new TextRenderer(mc, alertText, width / 2 - textWidth / 2, 10, 1D); } @Override @@ -80,12 +77,12 @@ public class AlertActionGui extends GuiScreen { mc.displayGuiScreen(new AlertAddGui(alert, id)); } else if (button == delete) { Alerts.alerts.remove(id); - Alerts.saveToFile(); + Alerts.save(); mc.displayGuiScreen(new AlertsGui(1)); return; } Alerts.alerts.set(id, alert); - Alerts.saveToFile(); + Alerts.save(); } } diff --git a/src/main/java/me/Danker/gui/alerts/AlertAddGui.java b/src/main/java/me/Danker/gui/alerts/AlertAddGui.java index 5f01d6d..304c77a 100644 --- a/src/main/java/me/Danker/gui/alerts/AlertAddGui.java +++ b/src/main/java/me/Danker/gui/alerts/AlertAddGui.java @@ -25,6 +25,7 @@ public class AlertAddGui extends GuiScreen { private GuiButton startsWith; private GuiButton contains; private GuiButton endsWith; + private GuiButton regex; private GuiButton everywhere; private GuiButton skyblock; private GuiButton dungeons; @@ -57,9 +58,10 @@ public class AlertAddGui extends GuiScreen { cancel = new GuiButton(0, 2, height - 30, 100, 20, "Cancel"); - startsWith = new GuiButton(0, width / 2 - 200, (int) (height * 0.2), 120, 20, "Starts With"); - contains = new GuiButton(0, width / 2 - 60, (int) (height * 0.2), 120, 20, "Contains"); - endsWith = new GuiButton(0, width / 2 + 80, (int) (height * 0.2), 120, 20, "Ends With"); + startsWith = new GuiButton(0, width / 2 - 260, (int) (height * 0.2), 120, 20, "Starts With"); + contains = new GuiButton(0, width / 2 - 130, (int) (height * 0.2), 120, 20, "Contains"); + endsWith = new GuiButton(0, width / 2 + 10, (int) (height * 0.2), 120, 20, "Ends With"); + regex = new GuiButton(0, width / 2 + 140, (int) (height * 0.2), 120, 20, "Regex"); everywhere = new GuiButton(0, width / 2 - 200, (int) (height * 0.3), 120, 20, "Everywhere"); skyblock = new GuiButton(0, width / 2 - 60, (int) (height * 0.3), 120, 20, "Skyblock"); dungeons = new GuiButton(0, width / 2 + 80, (int) (height * 0.3), 120, 20, "Dungeons"); @@ -80,13 +82,16 @@ public class AlertAddGui extends GuiScreen { message.setVisible(true); message.setEnabled(true); + message.setMaxStringLength(100); alert.setVisible(true); alert.setEnabled(true); + alert.setMaxStringLength(100); this.buttonList.add(cancel); this.buttonList.add(startsWith); this.buttonList.add(contains); this.buttonList.add(endsWith); + this.buttonList.add(regex); this.buttonList.add(everywhere); this.buttonList.add(skyblock); this.buttonList.add(dungeons); @@ -119,6 +124,8 @@ public class AlertAddGui extends GuiScreen { mode = "Contains"; } else if (button == endsWith) { mode = "Ends With"; + } else if (button == regex) { + mode = "Regex"; } else if (button == everywhere) { location = "Everywhere"; } else if (button == skyblock) { @@ -132,7 +139,7 @@ public class AlertAddGui extends GuiScreen { } else { Alerts.alerts.add(newAlert); } - Alerts.saveToFile(); + Alerts.save(); mc.displayGuiScreen(new AlertsGui(1)); } } diff --git a/src/main/java/me/Danker/gui/aliases/AliasesActionGui.java b/src/main/java/me/Danker/gui/aliases/AliasesActionGui.java new file mode 100644 index 0000000..d2c7a6a --- /dev/null +++ b/src/main/java/me/Danker/gui/aliases/AliasesActionGui.java @@ -0,0 +1,81 @@ +package me.Danker.gui.aliases; + +import me.Danker.features.ChatAliases; +import me.Danker.utils.RenderUtils; +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.client.gui.ScaledResolution; +import net.minecraft.util.EnumChatFormatting; + +public class AliasesActionGui extends GuiScreen { + + private final int id; + + private GuiButton goBack; + private GuiButton toggle; + private GuiButton edit; + private GuiButton delete; + + public AliasesActionGui(int id) { + this.id = id; + } + + @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(); + + ChatAliases.Alias alias = ChatAliases.aliases.get(id); + + goBack = new GuiButton(0, 2, height - 30, 100, 20, "Go Back"); + toggle = new GuiButton(0, width / 2 - 100, (int) (height * 0.1), "Enabled: " + Utils.getColouredBoolean(alias.toggled)); + edit = new GuiButton(0, width / 2 - 100, (int) (height * 0.2), "Edit >"); + delete = new GuiButton(0, width / 2 - 100, (int) (height * 0.8), EnumChatFormatting.RED + "Delete Alias"); + + this.buttonList.add(toggle); + this.buttonList.add(edit); + this.buttonList.add(delete); + this.buttonList.add(goBack); + } + + @Override + public void drawScreen(int mouseX, int mouseY, float partialTicks) { + this.drawDefaultBackground(); + super.drawScreen(mouseX, mouseY, partialTicks); + + ChatAliases.Alias alias = ChatAliases.aliases.get(id); + + RenderUtils.drawCenteredText(alias.text, width, 10, 1D); + } + + @Override + public void actionPerformed(GuiButton button) { + ChatAliases.Alias alias = ChatAliases.aliases.get(id); + if (button == goBack) { + mc.displayGuiScreen(new AliasesGui(1)); + } else if (button == toggle) { + alias.toggle(); + toggle.displayString = "Enabled: " + Utils.getColouredBoolean(alias.toggled); + } else if (button == edit) { + mc.displayGuiScreen(new AliasesAddGui(alias, id)); + } else if (button == delete) { + ChatAliases.aliases.remove(id); + ChatAliases.save(); + mc.displayGuiScreen(new AliasesGui(1)); + return; + } + ChatAliases.aliases.set(id, alias); + ChatAliases.save(); + } + +} diff --git a/src/main/java/me/Danker/gui/aliases/AliasesAddGui.java b/src/main/java/me/Danker/gui/aliases/AliasesAddGui.java new file mode 100644 index 0000000..610354a --- /dev/null +++ b/src/main/java/me/Danker/gui/aliases/AliasesAddGui.java @@ -0,0 +1,115 @@ +package me.Danker.gui.aliases; + +import me.Danker.features.ChatAliases; +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.minecraftforge.fml.client.config.GuiCheckBox; + +import java.io.IOException; + +public class AliasesAddGui extends GuiScreen { + + private boolean editing; + private ChatAliases.Alias base = null; + private int id; + + private GuiButton cancel; + + private GuiTextField text; + private GuiTextField alias; + private GuiCheckBox toggled; + private GuiButton add; + + public AliasesAddGui() {} + + public AliasesAddGui(ChatAliases.Alias alias, int id) { + editing = true; + base = alias; + this.id = id; + } + + @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"); + + + text = new GuiTextField(0, this.fontRendererObj, width / 2 - 100, (int) (height * 0.2), 200, 20); + alias = new GuiTextField(0, this.fontRendererObj, width / 2 - 100, (int) (height * 0.3), 200, 20); + toggled = new GuiCheckBox(0, width / 2 - 26, (int) (height * 0.4), "Toggled", true); + add = new GuiButton(0, width / 2 - 25, (int) (height * 0.8), 50, 20, "Add"); + + if (editing) { + text.setText(base.text); + alias.setText(base.alias); + toggled.setIsChecked(base.toggled); + } + + text.setVisible(true); + text.setEnabled(true); + alias.setVisible(true); + alias.setEnabled(true); + alias.setMaxStringLength(100); + + this.buttonList.add(cancel); + this.buttonList.add(toggled); + this.buttonList.add(add); + } + + @Override + public void drawScreen(int mouseX, int mouseY, float partialTicks) { + this.drawDefaultBackground(); + super.drawScreen(mouseX, mouseY, partialTicks); + + text.drawTextBox(); + alias.drawTextBox(); + + new TextRenderer(mc, "Text:", width / 2 - 135, (int) (height * 0.22), 1D); + new TextRenderer(mc, "Alias:", width / 2 - 137, (int) (height * 0.32), 1D); + } + + @Override + public void actionPerformed(GuiButton button) { + if (button == cancel) { + mc.displayGuiScreen(new AliasesGui(1)); + } else if (button == add) { + ChatAliases.Alias newAlias = new ChatAliases.Alias(text.getText(), alias.getText(), toggled.isChecked()); + if (editing) { + ChatAliases.aliases.set(id, newAlias); + } else { + ChatAliases.aliases.add(newAlias); + } + ChatAliases.save(); + mc.displayGuiScreen(new AliasesGui(1)); + } + } + + @Override + protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException { + super.mouseClicked(mouseX, mouseY, mouseButton); + text.mouseClicked(mouseX, mouseY, mouseButton); + alias.mouseClicked(mouseX, mouseY, mouseButton); + } + + @Override + protected void keyTyped(char typedChar, int keyCode) throws IOException { + super.keyTyped(typedChar, keyCode); + text.textboxKeyTyped(typedChar, keyCode); + alias.textboxKeyTyped(typedChar, keyCode); + } + +} diff --git a/src/main/java/me/Danker/gui/aliases/AliasesGui.java b/src/main/java/me/Danker/gui/aliases/AliasesGui.java new file mode 100644 index 0000000..f5b863a --- /dev/null +++ b/src/main/java/me/Danker/gui/aliases/AliasesGui.java @@ -0,0 +1,108 @@ +package me.Danker.gui.aliases; + +import me.Danker.commands.ToggleCommand; +import me.Danker.features.ChatAliases; +import me.Danker.gui.DankerGui; +import me.Danker.gui.buttons.FeatureButton; +import me.Danker.handlers.ConfigHandler; +import me.Danker.utils.RenderUtils; +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.client.gui.ScaledResolution; + +import java.util.ArrayList; +import java.util.List; + +public class AliasesGui extends GuiScreen { + + private final int page; + private final List<GuiButton> allButtons = new ArrayList<>(); + + private GuiButton goBack; + private GuiButton backPage; + private GuiButton nextPage; + private GuiButton add; + private GuiButton aliases; + + public AliasesGui(int page) { + this.page = page; + } + + @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(); + + goBack = new GuiButton(0, 2, height - 30, 100, 20, "Go Back"); + backPage = new GuiButton(0, width / 2 - 100, (int) (height * 0.8), 80, 20, "< Back"); + nextPage = new GuiButton(0, width / 2 + 20, (int) (height * 0.8), 80, 20, "Next >"); + aliases = new FeatureButton("Aliases: " + Utils.getColouredBoolean(ToggleCommand.aliases), "Replaces text in chat with an alias"); + add = new GuiButton(0, 0, 0, "Add Alias"); + + allButtons.clear(); + allButtons.add(aliases); + allButtons.add(add); + for (int i = 0; i < ChatAliases.aliases.size(); i++) { + ChatAliases.Alias alias = ChatAliases.aliases.get(i); + GuiButton button = new GuiButton(i, 0, 0, alias.text + " >"); + allButtons.add(button); + } + + reInit(); + } + + public void reInit() { + this.buttonList.clear(); + + for (int i = (page - 1) * 7, iteration = 0; iteration < 7 && i < allButtons.size(); i++, iteration++) { + GuiButton button = allButtons.get(i); + button.xPosition = width / 2 - 100; + button.yPosition = (int) (height * (0.1 * (iteration + 1))); + this.buttonList.add(button); + } + + if (page > 1) this.buttonList.add(backPage); + if (page < Math.ceil(allButtons.size() / 7D)) this.buttonList.add(nextPage); + + this.buttonList.add(goBack); + } + + @Override + public void drawScreen(int mouseX, int mouseY, float partialTicks) { + this.drawDefaultBackground(); + super.drawScreen(mouseX, mouseY, partialTicks); + + String pageText = "Page: " + page + "/" + (int) Math.ceil(allButtons.size() / 7D); + RenderUtils.drawCenteredText(pageText, width, 10, 1D); + } + + @Override + public void actionPerformed(GuiButton button) { + if (button == goBack) { + mc.displayGuiScreen(new DankerGui(1, "")); + } else if (button == nextPage) { + mc.displayGuiScreen(new AliasesGui(page + 1)); + } else if (button == backPage) { + mc.displayGuiScreen(new AliasesGui(page - 1)); + } else if (button == add) { + mc.displayGuiScreen(new AliasesAddGui()); + } else if (button == aliases) { + ToggleCommand.aliases = !ToggleCommand.aliases; + ConfigHandler.writeBooleanConfig("toggles", "Aliases", ToggleCommand.aliases); + aliases.displayString = "Aliases: " + Utils.getColouredBoolean(ToggleCommand.aliases); + } else { + mc.displayGuiScreen(new AliasesActionGui(button.id)); + } + } + +} diff --git a/src/main/java/me/Danker/gui/buttons/LocationButton.java b/src/main/java/me/Danker/gui/buttons/LocationButton.java index 8da1ab9..533bf83 100644 --- a/src/main/java/me/Danker/gui/buttons/LocationButton.java +++ b/src/main/java/me/Danker/gui/buttons/LocationButton.java @@ -44,6 +44,10 @@ public class LocationButton extends GuiButton { this.height = (int) ((splitText.length * 9 + 3) * scale); this.width = (int) ((this.longestText + offset + 3) * scale); } + + public LocationButton(int x, int y, double scale, String text) { + this(x, y, scale, text, null, null); + } @Override public void drawButton(Minecraft mc, int mouseX, int mouseY) { diff --git a/src/main/java/me/Danker/gui/crystalhollowwaypoints/CrystalHollowAddWaypointGui.java b/src/main/java/me/Danker/gui/crystalhollowwaypoints/CrystalHollowAddWaypointGui.java index df91f04..52c0fba 100644 --- a/src/main/java/me/Danker/gui/crystalhollowwaypoints/CrystalHollowAddWaypointGui.java +++ b/src/main/java/me/Danker/gui/crystalhollowwaypoints/CrystalHollowAddWaypointGui.java @@ -23,6 +23,18 @@ public class CrystalHollowAddWaypointGui extends GuiScreen { private GuiTextField z; private GuiButton add; + private int xPos = -1; + private int yPos = -1; + private int zPos = -1; + + public CrystalHollowAddWaypointGui() {} + + public CrystalHollowAddWaypointGui(int x, int y, int z) { + xPos = x; + yPos = y; + zPos = z; + } + @Override public boolean doesGuiPauseGame() { return false; @@ -49,10 +61,13 @@ public class CrystalHollowAddWaypointGui extends GuiScreen { name.setEnabled(true); x.setVisible(true); x.setEnabled(true); + if (xPos != -1) x.setText(xPos + ""); y.setVisible(true); y.setEnabled(true); + if (yPos != -1) y.setText(yPos + ""); z.setVisible(true); z.setEnabled(true); + if (zPos != -1) z.setText(zPos + ""); this.buttonList.add(cancel); this.buttonList.add(curPos); |