diff --git a/src/main/java/net/silentclient/client/Client.java b/src/main/java/net/silentclient/client/Client.java index 71bd4cf..ae00139 100644 --- a/src/main/java/net/silentclient/client/Client.java +++ b/src/main/java/net/silentclient/client/Client.java @@ -20,6 +20,7 @@ import net.silentclient.client.gui.font.SilentFontRenderer; import net.silentclient.client.gui.lite.GuiNews; import net.silentclient.client.gui.lite.LiteMainMenu; import net.silentclient.client.gui.lite.clickgui.ClickGUI; +import net.silentclient.client.gui.modmenu.ModMenu; import net.silentclient.client.gui.silentmainmenu.SilentMainMenu; import net.silentclient.client.gui.util.BackgroundPanorama; import net.silentclient.client.keybinds.KeyBindManager; @@ -421,7 +422,7 @@ public class Client { } } if(keyBindManager.CLICKGUI.isPressed()) { - Minecraft.getMinecraft().displayGuiScreen(new ClickGUI()); + Minecraft.getMinecraft().displayGuiScreen(Client.getInstance().getGlobalSettings().isLite() ? new ClickGUI() : new ModMenu()); } if(source.resolve() != PingSource.MULTIPLAYER_SCREEN) { diff --git a/src/main/java/net/silentclient/client/config/AddConfigModal.java b/src/main/java/net/silentclient/client/config/AddConfigModal.java index 0b08076..355386c 100644 --- a/src/main/java/net/silentclient/client/config/AddConfigModal.java +++ b/src/main/java/net/silentclient/client/config/AddConfigModal.java @@ -83,7 +83,6 @@ public class AddConfigModal extends SilentScreen { super.drawScreen(mouseX, mouseY, partialTicks); GlStateManager.popMatrix(); - NotificationManager.render(); } @Override diff --git a/src/main/java/net/silentclient/client/gui/ModalBase.java b/src/main/java/net/silentclient/client/gui/ModalBase.java index 875f925..51e0416 100644 --- a/src/main/java/net/silentclient/client/gui/ModalBase.java +++ b/src/main/java/net/silentclient/client/gui/ModalBase.java @@ -54,8 +54,6 @@ public class ModalBase extends GuiScreen { RenderUtils.drawRect(this.getContentX(), this.getContentY(), this.modalWidth, this.modalHeight, Theme.backgroundColor().getRGB()); Client.getInstance().getSilentFontRenderer().drawString(this.modalTitle, this.getContentX() + 3, this.getContentY() + 3, 14, SilentFontRenderer.FontType.TITLE); super.drawScreen(mouseX, mouseY, partialTicks); - - NotificationManager.render(); } public int getContentX() { diff --git a/src/main/java/net/silentclient/client/gui/elements/Checkbox.java b/src/main/java/net/silentclient/client/gui/elements/Checkbox.java index 157e8c7..b099bfd 100644 --- a/src/main/java/net/silentclient/client/gui/elements/Checkbox.java +++ b/src/main/java/net/silentclient/client/gui/elements/Checkbox.java @@ -10,11 +10,11 @@ import net.silentclient.client.gui.util.RenderUtil; import java.awt.*; public class Checkbox { - public static void render(int mouseX, int mouseY, int x, int y, String name, boolean selected) { + public static void render(int mouseX, int mouseY, float x, float y, String name, boolean selected) { render(mouseX, mouseY, x, y, name, selected, new DefaultCheckboxTheme()); } - public static void render(int mouseX, int mouseY, int x, int y, String name, boolean selected, ICheckboxTheme theme) { + public static void render(int mouseX, int mouseY, float x, float y, String name, boolean selected, ICheckboxTheme theme) { boolean hovered = Checkbox.isHovered(mouseX, mouseY, x, y); Color checkColor = selected ? theme.getSelectedColor() : theme.getColor(); RenderUtil.drawRoundedOutline(x, y, 9, 9, 9, 2, new Color(checkColor.getRed(), checkColor.getGreen(), checkColor.getBlue(), hovered ? 127 : 255).getRGB()); @@ -24,7 +24,7 @@ public class Checkbox { Client.getInstance().getSilentFontRenderer().drawString(name, x + 12, y + ((9 / 2) - (12 / 2)), 12, SilentFontRenderer.FontType.TITLE); } - public static boolean isHovered(int mouseX, int mouseY, int x, int y) { + public static boolean isHovered(int mouseX, int mouseY, float x, float y) { return MouseUtils.isInside(mouseX, mouseY, x, y, 9, 9); } } diff --git a/src/main/java/net/silentclient/client/gui/elements/Input.java b/src/main/java/net/silentclient/client/gui/elements/Input.java index 7708609..f414c0e 100644 --- a/src/main/java/net/silentclient/client/gui/elements/Input.java +++ b/src/main/java/net/silentclient/client/gui/elements/Input.java @@ -57,15 +57,15 @@ public class Input { this(name, Pattern .compile("^[\\w,\\s-]{0,20}+$"), 20); } - public void render(int mouseX, int mouseY, int x, int y, int width) { + public void render(int mouseX, int mouseY, float x, float y, int width) { this.render(mouseX, mouseY, x, y, width, false); } - public void render(int mouseX, int mouseY, int x, int y, int width, boolean small) { + public void render(int mouseX, int mouseY, float x, float y, int width, boolean small) { this.render(mouseX, mouseY, x, y, width, small, new DefaultInputTheme()); } - public void render(int mouseX, int mouseY, int x, int y, int width, boolean small, IInputTheme theme) { + public void render(int mouseX, int mouseY, float x, float y, int width, boolean small, IInputTheme theme) { int borderColor = theme.getBorderColor().getRGB(); if(MouseUtils.isInside(mouseX, mouseY, x, y, width, 20)) { borderColor = theme.getHoveredBorderColor().getRGB(); diff --git a/src/main/java/net/silentclient/client/gui/elements/StaticButton.java b/src/main/java/net/silentclient/client/gui/elements/StaticButton.java index 7c401ef..1f1ddb7 100644 --- a/src/main/java/net/silentclient/client/gui/elements/StaticButton.java +++ b/src/main/java/net/silentclient/client/gui/elements/StaticButton.java @@ -10,17 +10,17 @@ import net.silentclient.client.gui.theme.button.IButtonTheme; import net.silentclient.client.utils.ColorUtils; public class StaticButton { - public static void render(int xPosition, int yPosition, int width, int height, String displayString) + public static void render(float xPosition, float yPosition, int width, int height, String displayString) { StaticButton.render(xPosition, yPosition, width, height, displayString, false); } - public static void render(int xPosition, int yPosition, int width, int height, String displayString, boolean bold) + public static void render(float xPosition, float yPosition, int width, int height, String displayString, boolean bold) { StaticButton.render(xPosition, yPosition, width, height, displayString, bold, new DefaultButtonTheme()); } - public static void render(int xPosition, int yPosition, int width, int height, String displayString, boolean bold, IButtonTheme theme) + public static void render(float xPosition, float yPosition, int width, int height, String displayString, boolean bold, IButtonTheme theme) { GlStateManager.disableBlend(); ColorUtils.setColor(theme.getBackgroundColor().getRGB()); @@ -29,10 +29,10 @@ public class StaticButton { RenderUtil.drawRoundedOutline(xPosition, yPosition, width, height, 3, 1, theme.getBorderColor().getRGB()); ColorUtils.setColor(theme.getTextColor().getRGB()); - Client.getInstance().getSilentFontRenderer().drawCenteredString(displayString, xPosition + width / 2, yPosition + (height - (bold ? 8 : 10)) / 2, bold ? 8 : 10, bold ? SilentFontRenderer.FontType.HEADER : SilentFontRenderer.FontType.TITLE, width - (bold ? 8 : 10)); + Client.getInstance().getSilentFontRenderer().drawCenteredString(displayString, (int) (xPosition + width / 2), (int) (yPosition + (height - (bold ? 8 : 10)) / 2), bold ? 8 : 10, bold ? SilentFontRenderer.FontType.HEADER : SilentFontRenderer.FontType.TITLE, width - (bold ? 8 : 10)); } - public static boolean isHovered(int mouseX, int mouseY, int xPosition, int yPosition, int width, int height) { + public static boolean isHovered(int mouseX, int mouseY, float xPosition, float yPosition, int width, int height) { return MouseUtils.isInside(mouseX, mouseY, xPosition, yPosition, width, height); } } diff --git a/src/main/java/net/silentclient/client/gui/friends/AddFriendModal.java b/src/main/java/net/silentclient/client/gui/friends/AddFriendModal.java index 5c28058..3a46cef 100644 --- a/src/main/java/net/silentclient/client/gui/friends/AddFriendModal.java +++ b/src/main/java/net/silentclient/client/gui/friends/AddFriendModal.java @@ -16,6 +16,7 @@ import net.silentclient.client.gui.theme.Theme; import net.silentclient.client.utils.MenuBlurUtils; import net.silentclient.client.utils.NotificationUtils; import net.silentclient.client.utils.Requests; +import org.json.JSONObject; import org.lwjgl.input.Keyboard; import java.io.IOException; @@ -50,8 +51,8 @@ public class AddFriendModal extends SilentScreen { mc.displayGuiScreen(parentScreen); break; case 2: - if(this.silentInputs.get(0).getValue().length() != 0) { - String content = Requests.get("https://api.silentclient.net/friends/send_request"); + if(this.silentInputs.get(0).getValue().trim().length() != 0) { + String content = Requests.post("https://api.silentclient.net/friends/send_request", new JSONObject().put("username", this.silentInputs.get(0).getValue().trim()).toString()); if(content != null) { Client.getInstance().updateFriendsList(); mc.displayGuiScreen(parentScreen); @@ -82,7 +83,6 @@ public class AddFriendModal extends SilentScreen { super.drawScreen(mouseX, mouseY, partialTicks); GlStateManager.popMatrix(); - NotificationManager.render(); } @Override @@ -95,6 +95,7 @@ public class AddFriendModal extends SilentScreen { @Override public void onGuiClosed() { + super.onGuiClosed(); MenuBlurUtils.unloadBlur(); } diff --git a/src/main/java/net/silentclient/client/gui/friends/FriendsListOverlay.java b/src/main/java/net/silentclient/client/gui/friends/FriendsListOverlay.java index c9aabbf..cf4ce62 100644 --- a/src/main/java/net/silentclient/client/gui/friends/FriendsListOverlay.java +++ b/src/main/java/net/silentclient/client/gui/friends/FriendsListOverlay.java @@ -107,8 +107,6 @@ public class FriendsListOverlay extends GuiScreen { if(scrollY > height) { scrollAnimation.setAnimation((float) scrollY, 16); } - - NotificationManager.render(); } @Override diff --git a/src/main/java/net/silentclient/client/gui/hud/HUDConfigScreen.java b/src/main/java/net/silentclient/client/gui/hud/HUDConfigScreen.java index db26ed6..c733416 100644 --- a/src/main/java/net/silentclient/client/gui/hud/HUDConfigScreen.java +++ b/src/main/java/net/silentclient/client/gui/hud/HUDConfigScreen.java @@ -5,6 +5,8 @@ import java.io.IOException; import java.text.DecimalFormat; import net.silentclient.client.gui.elements.Button; +import net.silentclient.client.gui.lite.clickgui.ClickGUI; +import net.silentclient.client.gui.modmenu.ModMenu; import net.silentclient.client.utils.MenuBlurUtils; import net.silentclient.client.utils.MouseCursorHandler; import org.lwjgl.input.Keyboard; @@ -188,7 +190,7 @@ public class HUDConfigScreen extends GuiScreen { break; case 1: if(this.mod != null) { - mc.displayGuiScreen(new ModSettings(mod, this)); + mc.displayGuiScreen(Client.getInstance().getGlobalSettings().isLite() ? new ModSettings(mod, this) : new net.silentclient.client.gui.modmenu.ModSettings(mod, this)); } else { this.tutorial = true; this.mod = null; diff --git a/src/main/java/net/silentclient/client/gui/lite/LiteMainMenu.java b/src/main/java/net/silentclient/client/gui/lite/LiteMainMenu.java index 2a2726e..b291508 100644 --- a/src/main/java/net/silentclient/client/gui/lite/LiteMainMenu.java +++ b/src/main/java/net/silentclient/client/gui/lite/LiteMainMenu.java @@ -5,6 +5,7 @@ import java.net.URI; import java.util.Random; import net.minecraft.client.gui.*; +import net.minecraft.client.settings.GameSettings; import net.silentclient.client.gui.silentmainmenu.SilentMainMenu; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -143,7 +144,9 @@ public class LiteMainMenu extends GuiScreen implements GuiYesNoCallback this.buttonList.add(new IconButton(88, 4, 5, new ResourceLocation("silentclient/icons/news.png"))); this.buttonList.add(cosmetics = new IconButton(87, 26, 5, new ResourceLocation("silentclient/icons/settings/cosmetics.png"))); - this.buttonList.add(new IconButton(89, 48, 5, new ResourceLocation("silentclient/icons/back.png"))); + this.buttonList.add(new IconButton(991, 48, 5, new ResourceLocation("silentclient/icons/store_icon.png"))); + this.buttonList.add(new IconButton(992, 70, 5, new ResourceLocation("silentclient/icons/language.png"))); + this.buttonList.add(new IconButton(89, 92, 5, new ResourceLocation("silentclient/icons/back.png"))); if (this.mc.isDemo()) { this.addDemoButtons(j, 24); @@ -200,6 +203,22 @@ public class LiteMainMenu extends GuiScreen implements GuiYesNoCallback */ protected void actionPerformed(GuiButton button) throws IOException { + if(button.id == 991) { + try { + Class oclass = Class.forName("java.awt.Desktop"); + Object object = oclass.getMethod("getDesktop", new Class[0]).invoke((Object)null, new Object[0]); + oclass.getMethod("browse", new Class[] {URI.class}).invoke(object, new Object[] {new URI("https://store.silentclient.net/")}); + } catch (Throwable err) { + err.printStackTrace(); + } + return; + } + + if(button.id == 992) { + mc.displayGuiScreen(new GuiLanguage(this, new GameSettings(), mc.getLanguageManager())); + return; + } + if (button.id == 0) { this.mc.displayGuiScreen(new GuiOptions(this, this.mc.gameSettings)); diff --git a/src/main/java/net/silentclient/client/gui/lite/clickgui/ClickGUI.java b/src/main/java/net/silentclient/client/gui/lite/clickgui/ClickGUI.java index 53ca412..605e831 100644 --- a/src/main/java/net/silentclient/client/gui/lite/clickgui/ClickGUI.java +++ b/src/main/java/net/silentclient/client/gui/lite/clickgui/ClickGUI.java @@ -224,8 +224,6 @@ public class ClickGUI extends SilentScreen { GlUtils.stopScale(); GlStateManager.popMatrix(); - - NotificationManager.render(); } @Override diff --git a/src/main/java/net/silentclient/client/gui/lite/clickgui/ModSettings.java b/src/main/java/net/silentclient/client/gui/lite/clickgui/ModSettings.java index 03b5c95..c5ba2a2 100644 --- a/src/main/java/net/silentclient/client/gui/lite/clickgui/ModSettings.java +++ b/src/main/java/net/silentclient/client/gui/lite/clickgui/ModSettings.java @@ -116,7 +116,7 @@ public class ModSettings extends SilentScreen { GL11.glPushMatrix(); GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); - int settingY = (int) (y + 25 + scrollAnimation.getValue() + mod.customComponentHeight()); + int settingY = (int) (y + 25 + scrollAnimation.getValue() + mod.customComponentLiteHeight()); GL11.glPopMatrix(); @@ -136,7 +136,7 @@ public class ModSettings extends SilentScreen { } Client.getInstance().getSilentFontRenderer().drawString(mod.getName(), x + 100, (int) (y + 5) + scrollAnimation.getValue(), 14, SilentFontRenderer.FontType.TITLE); - mod.renderCustomComponent(x + 100, (int) (y + 25 + scrollAnimation.getValue()), width, height, mouseX, mouseY); + mod.renderCustomLiteComponent(x + 100, (int) (y + 25 + scrollAnimation.getValue()), width, height, mouseX, mouseY); int inputIndex = 0; for (Setting setting : Client.getInstance().getSettingsManager().getSettingByMod(mod)) { if(mod.getName() == "Crosshair" && Client.getInstance().getSettingsManager().getSettingByClass(CrosshairMod.class, "Preset Crosshair").getValBoolean() && setting.getName() != "Scale" && setting.getName() != "Crosshair Color" && setting.getName() != "Vanilla Blendering") { @@ -177,7 +177,7 @@ public class ModSettings extends SilentScreen { if (Slider.isDrag(mouseX, mouseY, x, settingY - 1, width) && (System.currentTimeMillis() - initTime) > 500) { double diff = setting.getMax() - setting.getMin(); - double mouse = MathHelper.clamp_double((mouseX - Slider.getLeft(x, width)) / 90D, 0, 1); + double mouse = MathHelper.clamp_double((mouseX - Slider.getLeft(x, width)) / 100D, 0, 1); double newVal = setting.getMin() + mouse * diff; if(newVal != setting.getValDouble()) { setting.setValDouble(newVal); @@ -210,12 +210,12 @@ public class ModSettings extends SilentScreen { scrollY = -((settingIndex - 14.1) * 38); } } - if(mod.customComponentHeight() > height - 30) { - if(scrollY > -((mod.customComponentHeight() - 13.5) * 38)) { + if(mod.customComponentLiteHeight() > height - 30) { + if(scrollY > -((mod.customComponentLiteHeight() - 13.5) * 38)) { scrollY -=12; } - if(scrollY < -((mod.customComponentHeight() - 15) * 38)) { - scrollY = -((mod.customComponentHeight() - 14.1) * 38); + if(scrollY < -((mod.customComponentLiteHeight() - 15) * 38)) { + scrollY = -((mod.customComponentLiteHeight() - 14.1) * 38); } } break; @@ -226,7 +226,7 @@ public class ModSettings extends SilentScreen { if(settingIndex > 13) { scrollY = 0; } - if(mod.customComponentHeight() > height - 30) { + if(mod.customComponentLiteHeight() > height - 30) { scrollY = 0; } } @@ -235,9 +235,7 @@ public class ModSettings extends SilentScreen { } scrollAnimation.setAnimation((float) scrollY, 16); - - NotificationManager.render(); - + if(ClickGUI.close) { ClickGUI.introAnimation.setDirection(Direction.BACKWARDS); if(ClickGUI.introAnimation.isDone(Direction.BACKWARDS)) { @@ -259,7 +257,7 @@ public class ModSettings extends SilentScreen { int x = (width / 2) - addX; int y = (height / 2) - addY; int width = addX * 2; - int settingY = (int) (y + 25 + scrollAnimation.getValue() + mod.customComponentHeight()); + int settingY = (int) (y + 25 + scrollAnimation.getValue() + mod.customComponentLiteHeight()); String category = ""; if(mod.getCategory() == ModCategory.MODS && MouseUtils.isInside(mouseX, mouseY, x + width - (10 + 8) - 15, y + 5 + scrollAnimation.getValue(), 10, 10)) { diff --git a/src/main/java/net/silentclient/client/gui/minecraft/GuiIngameMenu.java b/src/main/java/net/silentclient/client/gui/minecraft/GuiIngameMenu.java index 5a44c09..7d3fb2c 100644 --- a/src/main/java/net/silentclient/client/gui/minecraft/GuiIngameMenu.java +++ b/src/main/java/net/silentclient/client/gui/minecraft/GuiIngameMenu.java @@ -21,6 +21,7 @@ import net.silentclient.client.gui.GuiMultiplayerInGame; import net.silentclient.client.gui.lite.clickgui.ClickGUI; import net.silentclient.client.gui.friends.FriendsListOverlay; import net.silentclient.client.gui.hud.Watermark; +import net.silentclient.client.gui.modmenu.ModMenu; import net.silentclient.client.mods.ModCategory; import net.silentclient.client.mods.settings.GeneralMod; import net.silentclient.client.utils.MenuBlurUtils; @@ -122,7 +123,7 @@ public class GuiIngameMenu extends GuiScreen this.mc.displayGuiScreen(new GuiMultiplayerInGame(this)); break; case 8: - this.mc.displayGuiScreen(new ClickGUI(ModCategory.SETTINGS)); + this.mc.displayGuiScreen(Client.getInstance().getGlobalSettings().isLite() ? new ClickGUI(ModCategory.SETTINGS) : new ModMenu(ModCategory.SETTINGS)); break; case 9: Cosmetics.reload(this.mc.thePlayer); @@ -131,7 +132,7 @@ public class GuiIngameMenu extends GuiScreen this.mc.displayGuiScreen(new CosmeticsGui()); break; case 11: - this.mc.displayGuiScreen(new ClickGUI()); + this.mc.displayGuiScreen(Client.getInstance().getGlobalSettings().isLite() ? new ClickGUI() : new ModMenu()); break; case 12: this.mc.displayGuiScreen(new GuiShareToLan(this)); diff --git a/src/main/java/net/silentclient/client/gui/modmenu/ColorPicker.java b/src/main/java/net/silentclient/client/gui/modmenu/ColorPicker.java new file mode 100644 index 0000000..ec3bd6b --- /dev/null +++ b/src/main/java/net/silentclient/client/gui/modmenu/ColorPicker.java @@ -0,0 +1,185 @@ +package net.silentclient.client.gui.modmenu; + +import net.minecraft.client.gui.GuiButton; +import net.minecraft.client.gui.GuiScreen; +import net.minecraft.util.MathHelper; +import net.silentclient.client.Client; +import net.silentclient.client.gui.SilentScreen; +import net.silentclient.client.gui.elements.Button; +import net.silentclient.client.gui.elements.Checkbox; +import net.silentclient.client.gui.elements.Slider; +import net.silentclient.client.gui.lite.clickgui.utils.MouseUtils; +import net.silentclient.client.gui.lite.clickgui.utils.RenderUtils; +import net.silentclient.client.gui.theme.button.DefaultButtonTheme; +import net.silentclient.client.gui.theme.button.SelectedButtonTheme; +import net.silentclient.client.gui.util.RenderUtil; +import net.silentclient.client.mods.Mod; +import net.silentclient.client.mods.ModCategory; +import net.silentclient.client.mods.Setting; +import net.silentclient.client.utils.MenuBlurUtils; + +import java.awt.*; +import java.io.IOException; +import java.util.ArrayList; + +public class ColorPicker extends SilentScreen { + private long initTime; + private final Mod mod; + private final GuiScreen parentScreen; + private ArrayList colors = new ArrayList(); + private final String value; + + public ColorPicker(Mod mod, String value, GuiScreen parentScreen) { + if (mod == null) throw new IllegalArgumentException("Mod is null"); + + this.mod = mod; + this.parentScreen = parentScreen; + this.value = value; + } + + @Override + public void initGui() { + super.initGui(); + this.initTime = System.currentTimeMillis(); + this.buttonList.clear(); + this.silentInputs.clear(); + + MenuBlurUtils.loadBlur(); + + ModMenu.initBaseButtons(this.buttonList); + this.buttonList.add(new Button(1, 3, 26, 144, 15, "Back")); + this.buttonList.add(new Button(2, 3, this.height - 18, mod.getCategory() == ModCategory.MODS ? 70 : 144, 15, "Reset")); + if(mod.getCategory() == ModCategory.MODS) { + this.buttonList.add(new Button(3, 76, this.height - 18, 70, 15, mod.isEnabled() ? "Enabled" : "Disabled", false, mod.isEnabled() ? new SelectedButtonTheme() : new DefaultButtonTheme())); + } + + colors.clear(); + colors.add(new Color(255, 255, 255)); + colors.add(new Color(156, 157, 151)); + colors.add(new Color(71,79,82)); + colors.add(new Color(0, 0, 0)); + colors.add(new Color(255,216,61)); + colors.add(new Color(249,128,29)); + colors.add(new Color(176,46,38)); + colors.add(new Color(130,84,50)); + colors.add(new Color(128,199,31)); + colors.add(new Color(58,179,218)); + colors.add(new Color(22,156,157)); + colors.add(new Color(60,68,169)); + colors.add(new Color(243,140,170)); + colors.add(new Color(198,79,189)); + colors.add(new Color(137,50,183)); + } + + @Override + public void drawScreen(int mouseX, int mouseY, float partialTicks) { + super.drawDefaultBackground(); + Setting setting = Client.getInstance().getSettingsManager().getSettingByName(mod, this.value); + + ModMenu.drawOverlayListBase(height, "Choose a color"); + + super.drawScreen(mouseX, mouseY, partialTicks); + + ModMenu.trimContentStart(width, height); + float colorY = 66; + int colorX = 3; + int colorIndex = 0; + for(Color color : colors) { + RenderUtil.drawRoundedRect(colorX, colorY, 20, 20, 3, new Color(color.getRed(), color.getGreen(), color.getBlue(), setting.getOpacity()).getRGB()); + RenderUtil.drawRoundedOutline(colorX, colorY, 20, 20, 3, 2, new Color(0, 0, 0).getRGB()); + colorX += 25; + colorIndex += 1; + if(colorIndex == 6) { + colorIndex = 0; + colorX = 3; + colorY += 25; + } + } + + int settingHeight = 15; + colorY += settingHeight; + if(setting.isCanChangeOpacity()) { + colorY += settingHeight; + RegularSlider.render(3, colorY, 144, "Opacity", 255, setting.getOpacity()); + if (RegularSlider.isDrag(mouseX, mouseY, 3, colorY, 144) && (System.currentTimeMillis() - initTime) > 500) { + double diff = 255 - 0; + double mouse = MathHelper.clamp_double((mouseX - 3) / 100D, 0, 1); + double newVal = 0 + mouse * diff; + setting.setOpacity((int) newVal); + } + colorY += settingHeight; + } + + colorY += settingHeight; + + Checkbox.render(mouseX, mouseY, 3, colorY, "Chroma", setting.isChroma()); + + ModMenu.trimContentEnd(); + } + + @Override + protected void actionPerformed(GuiButton button) throws IOException { + super.actionPerformed(button); + ModMenu.clickBaseButtons(button, this); + + switch (button.id) { + case 1: + mc.displayGuiScreen(parentScreen); + break; + case 2: + mod.reset(false); + break; + case 3: + mod.toggle(); + button.displayString = mod.isEnabled() ? "Enabled" : "Disabled"; + if(button instanceof Button) { + ((Button) button).setTheme(mod.isEnabled() ? new SelectedButtonTheme() : new DefaultButtonTheme()); + } + break; + } + } + + @Override + protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException { + super.mouseClicked(mouseX, mouseY, mouseButton); + Setting setting = Client.getInstance().getSettingsManager().getSettingByName(mod, this.value); + float colorY = 66; + int colorX = 3; + int colorIndex = 0; + for(Color color : colors) { + if(MouseUtils.isInside(mouseX, mouseY, colorX, colorY, 20, 20)) { + setting.setValColor(color); + mc.displayGuiScreen(parentScreen); + } + colorX += 25; + colorIndex += 1; + if(colorIndex == 6) { + colorIndex = 0; + colorX = 3; + colorY += 25; + } + } + + int settingHeight = 15; + colorY += settingHeight; + if(setting.isCanChangeOpacity()) { + colorY += settingHeight * 2; + } + + colorY += settingHeight; + + if(Checkbox.isHovered(mouseX, mouseY, 3, colorY)) { + setting.setChroma(!setting.isChroma()); + mc.displayGuiScreen(parentScreen); + } + } + + @Override + public void onGuiClosed() { + super.onGuiClosed(); + if(mod.getName() == "Pack Tweaks" && mod.isEnabled()) { + mc.renderGlobal.loadRenderers(); + } + MenuBlurUtils.unloadBlur(); + } +} diff --git a/src/main/java/net/silentclient/client/gui/modmenu/ModMenu.java b/src/main/java/net/silentclient/client/gui/modmenu/ModMenu.java index 8bbd1e3..8fd34d3 100644 --- a/src/main/java/net/silentclient/client/gui/modmenu/ModMenu.java +++ b/src/main/java/net/silentclient/client/gui/modmenu/ModMenu.java @@ -1,13 +1,54 @@ package net.silentclient.client.gui.modmenu; +import com.google.common.io.Files; +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.client.renderer.GlStateManager; +import net.minecraft.util.ResourceLocation; +import net.minecraft.util.Util; +import net.silentclient.client.Client; +import net.silentclient.client.config.AddConfigModal; import net.silentclient.client.gui.SilentScreen; +import net.silentclient.client.gui.animation.SimpleAnimation; +import net.silentclient.client.gui.elements.Button; +import net.silentclient.client.gui.elements.Checkbox; +import net.silentclient.client.gui.elements.*; +import net.silentclient.client.gui.font.SilentFontRenderer; +import net.silentclient.client.gui.hud.HUDConfigScreen; +import net.silentclient.client.gui.lite.clickgui.utils.MouseUtils; +import net.silentclient.client.gui.lite.clickgui.utils.RenderUtils; +import net.silentclient.client.gui.theme.Theme; +import net.silentclient.client.gui.theme.button.DefaultButtonTheme; +import net.silentclient.client.gui.theme.button.SelectedButtonTheme; +import net.silentclient.client.gui.theme.switches.DefaultSwitchTheme; +import net.silentclient.client.gui.util.RenderUtil; +import net.silentclient.client.mods.Mod; import net.silentclient.client.mods.ModCategory; +import net.silentclient.client.mods.settings.GeneralMod; +import net.silentclient.client.utils.ColorUtils; +import net.silentclient.client.utils.MenuBlurUtils; +import net.silentclient.client.utils.Sounds; +import org.lwjgl.Sys; +import org.lwjgl.input.Mouse; +import org.lwjgl.opengl.GL11; +import java.awt.*; +import java.io.File; import java.io.IOException; +import java.net.URI; +import java.util.ArrayList; +import java.util.List; +import java.util.regex.Pattern; public class ModMenu extends SilentScreen { private ModCategory modCategory; + public static SimpleAnimation introAnimation; + private SimpleAnimation scrollAnimation = new SimpleAnimation(0.0F); + private float scrollY = 0; + public static boolean loaded; + private float scrollHeight = 0; public ModMenu() { this(ModCategory.MODS); @@ -15,25 +56,421 @@ public class ModMenu extends SilentScreen { public ModMenu(ModCategory category) { this.modCategory = category; + this.loaded = false; } @Override public void initGui() { super.initGui(); + if(!loaded) { + introAnimation = new SimpleAnimation(Client.getInstance().getSettingsManager().getSettingByClass(GeneralMod.class, "Menu Animations").getValBoolean() ? -150 : 0); + } + MenuBlurUtils.loadBlur(); + this.buttonList.clear(); + this.silentInputs.clear(); + + initBaseButtons(this.buttonList); + + this.buttonList.add(new Button(1, 3, 26, 46, 15, "Mods", false, modCategory == ModCategory.MODS ? new SelectedButtonTheme() : new DefaultButtonTheme())); + this.buttonList.add(new Button(2, 52, 26, 46, 15, "Settings", false, modCategory == ModCategory.SETTINGS ? new SelectedButtonTheme() : new DefaultButtonTheme())); + this.buttonList.add(new Button(3, 101, 26, 46, 15, "Configs", false, modCategory == ModCategory.CONFIGS ? new SelectedButtonTheme() : new DefaultButtonTheme())); + this.buttonList.add(new Button(4, 3, this.height - 18, 144, 15, "Premium", false, modCategory == ModCategory.PLUS ? new SelectedButtonTheme() : new DefaultButtonTheme())); + + this.buttonList.add(new Button(5, 3, 46, 61, 15, "New Config")); + this.buttonList.add(new Button(6, 67, 46, 61, 15, "Folder")); + + this.silentInputs.add(new Input("Search")); + this.silentInputs.add(new Input("Nametag Message", Pattern + .compile("^[~`!@#$%^&*()_+=[\\\\]\\\\\\\\\\\\{\\\\}|;':\\\",.\\\\/<>?a-zA-Z0-9-\\s]+$"), 40)); + + this.silentInputs.get(1).setValue(Client.getInstance().getAccount().getNametagMessage()); + } + + public static void initBaseButtons(List buttonList) { + buttonList.add(new IconButton(91, 132, 5, 15, 15, 9, 9, new ResourceLocation("silentclient/icons/exit.png"))); + buttonList.add(new IconButton(92, 132, 46, 15, 15, 9, 9, new ResourceLocation("silentclient/icons/pencil.png"))); + } + + public static void clickBaseButtons(GuiButton button, GuiScreen screen) { + switch (button.id) { + case 91: + Minecraft.getMinecraft().displayGuiScreen(null); + break; + case 92: + ModMenu.loaded = false; + Minecraft.getMinecraft().displayGuiScreen(new HUDConfigScreen(screen)); + break; + } + } + + public static void drawOverlayListBase(float height) { + drawOverlayListBase(height, null); + } + + public static void drawOverlayListBase(float height, String header) { + ModMenu.introAnimation.setAnimation(0, 30); + GlStateManager.translate(ModMenu.introAnimation.getValue(), 0, 0); + RenderUtils.drawRect(0, 0, 150, height, Theme.backgroundColor().getRGB()); + RenderUtil.drawImage(new ResourceLocation("silentclient/logos/logo.png"), 3, 3, 97.7F, 19); + if(header != null) { + Client.getInstance().getSilentFontRenderer().drawString(header, 3, 46, 14, SilentFontRenderer.FontType.TITLE); + } } @Override public void drawScreen(int mouseX, int mouseY, float partialTicks) { + if(ModMenu.introAnimation.getValue() == 0) { + ModMenu.loaded = true; + } + super.drawDefaultBackground(); + ModMenu.drawOverlayListBase(height, modCategory == ModCategory.PLUS ? "Premium" : null); + super.drawScreen(mouseX, mouseY, partialTicks); + + if(modCategory != ModCategory.CONFIGS && modCategory != ModCategory.PLUS) { + this.silentInputs.get(0).render(mouseX, mouseY, 3, 46, 127, true); + this.buttonList.get(6).visible = false; + this.buttonList.get(7).visible = false; + } else if(modCategory == ModCategory.CONFIGS) { + this.buttonList.get(6).visible = true; + this.buttonList.get(7).visible = true; + } else if(modCategory == ModCategory.PLUS) { + this.buttonList.get(6).visible = false; + this.buttonList.get(7).visible = false; + } + + trimContentStart(width, height); + if(modCategory != ModCategory.CONFIGS && modCategory != ModCategory.PLUS) { + float modY = 66 - scrollAnimation.getValue(); + + for(Mod mod : getMods()) { + if(mouseInContent(0, (int) modY, height) || mouseInContent(0, (int) (modY + 20), height)) { + boolean isHovered = mouseInContent(mouseX, mouseY, height) && MouseUtils.isInside(mouseX, mouseY, 3, modY, 144, 20) && !(modCategory == ModCategory.MODS && Switch.isHovered(mouseX, mouseY, 129, modY + 10 - 4)) && (Client.getInstance().getSettingsManager().getSettingByMod(mod).size() != 0 || mod.getName() == "Auto Text"); + if(isHovered) { + RenderUtil.drawRoundedRect(3, modY, 144, 20, 3, new Color(255, 255, 255, 30).getRGB()); + } + RenderUtil.drawRoundedOutline(3, modY, 144, 20, 3, 1, Theme.borderColor().getRGB()); + int modX = 6; + if(mod.getIcon() != null) { + RenderUtil.drawImage(new ResourceLocation(mod.getIcon()), modX, modY + 10 - 7, 14, 14); + modX += 19; + } + + Client.getInstance().getSilentFontRenderer().drawString(mod.getName(), modX, modY + 10 - 6, 12, SilentFontRenderer.FontType.TITLE); + + if(modCategory == ModCategory.MODS) { + Switch.render(mouseX, mouseY, 129, modY + 10 - 4, mod.switchAniamation, mod.isEnabled(), mod.isForceDisabled()); + } + } + + modY += 23; + } + this.scrollHeight = 66 + modY + scrollAnimation.getValue(); + } else if(modCategory == ModCategory.CONFIGS) { + float configY = 66 - scrollAnimation.getValue(); + RenderUtil.drawRoundedOutline(3, configY, 144, 20, 3, 2, new DefaultSwitchTheme().getSelectedBackgroundColor().getRGB()); + Client.getInstance().getSilentFontRenderer().drawString(Files.getNameWithoutExtension(Client.getInstance().configManager.configFile.getName()), 6, (int) configY + 10 - 6, 12, SilentFontRenderer.FontType.TITLE, 100); + configY += 23; + for(String config : Client.getInstance().getConfigManager().getConfigFiles()) { + if(config.equals(".config-settings.txt") || config.equals(".DS_Store") || Client.getInstance().configManager.configFile.getName().equals(config)) { + continue; + } + + boolean isHovered = mouseInContent(mouseX, mouseY, height) && MouseUtils.isInside(mouseX, mouseY, 3, configY, 144, 20); + if(isHovered) { + RenderUtil.drawRoundedRect(3, configY, 144, 20, 3, new Color(255, 255, 255, 30).getRGB()); + } + RenderUtil.drawRoundedOutline(3, configY, 144, 20, 3, 1, Theme.borderColor().getRGB()); + + Client.getInstance().getSilentFontRenderer().drawString(Files.getNameWithoutExtension(config), 6, (int) configY + 10 - 6, 12, SilentFontRenderer.FontType.TITLE, 90); + + RenderUtil.drawImage(new ResourceLocation("silentclient/icons/trash-icon.png"), 132, configY + 10 - 6, 12, 12); + + configY += 23; + } + this.scrollHeight = 66 + configY + scrollAnimation.getValue(); + } else if(modCategory == ModCategory.PLUS) { + float premiumY = 66 - scrollAnimation.getValue(); + GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); + if(!Client.getInstance().getAccount().isPlus()) { + Client.getInstance().getSilentFontRenderer().drawCenteredString("You're currently not Premium!", 150 / 2, (int) premiumY, 14, SilentFontRenderer.FontType.TITLE); + } else { + int days = Client.getInstance().getAccount().getPlusExpiration(); + Client.getInstance().getSilentFontRenderer().drawString(days != -1 ? days + " days left" : "Unknown Time Remaining", 3, (int) premiumY, 12, SilentFontRenderer.FontType.TITLE); + premiumY += 15; + RegularColorPicker.render(3, (int) premiumY, 144, "Chroma Bandana Color", Client.getInstance().getAccount().getBandanaColor() == 50 ? ColorUtils.getChromaColor(0, 0, 1).getRGB() : Client.getInstance().getAccount().getBandanaColor()); + premiumY += 15; + Client.getInstance().getSilentFontRenderer().drawString("Custom Capes", 3, premiumY, 12, SilentFontRenderer.FontType.TITLE); + StaticButton.render(150 - 3 - 65, (int) premiumY, 65, 12, Client.getInstance().getAccount().isPremiumPlus() ? "OPEN MENU" : "BUY PREMIUM+"); + premiumY += 15; + ColorUtils.setColor(new Color(255, 255, 255, 127).getRGB()); + Client.getInstance().getSilentFontRenderer().drawString("Nametag Message Settings:", 3, premiumY, 12, SilentFontRenderer.FontType.TITLE); + premiumY += 15; + ColorUtils.setColor(new Color(255, 255, 255, 255).getRGB()); + if(Client.getInstance().getAccount().isPremiumPlus()) { + Checkbox.render(mouseX, mouseY, 3, (int) premiumY, "Show Nametag Message", Client.getInstance().getAccount().showNametagMessage()); + premiumY += 15; + Client.getInstance().getSilentFontRenderer().drawString("Nametag Message:", 3, premiumY + 1, 12, SilentFontRenderer.FontType.TITLE); + premiumY += 15; + this.silentInputs.get(1).render(mouseX, mouseY, 3, (int) premiumY, 144, true); + premiumY += 20; + StaticButton.render(150 - 3 - 50, (int) premiumY, 50, 12, "Save"); + } else { + Client.getInstance().getSilentFontRenderer().drawString("You're currently not Premium+", 3, (int) premiumY, 12, SilentFontRenderer.FontType.TITLE); + } + } + this.scrollHeight = 66 + premiumY + scrollAnimation.getValue(); + } + trimContentEnd(); + + scrollAnimation.setAnimation(scrollY, 12); + } + + public static void trimContentStart(int width, int height) { + GL11.glPushMatrix(); + GL11.glEnable(GL11.GL_SCISSOR_TEST); + ScaledResolution r = new ScaledResolution(Minecraft.getMinecraft()); + int s = r.getScaleFactor(); + int listHeight = height - 66 - 21; + int translatedY = r.getScaledHeight() - 66 - listHeight; + GL11.glScissor(0 * s, translatedY * s, width * s, listHeight * s); + } + + public static void trimContentEnd() { + GL11.glDisable(GL11.GL_SCISSOR_TEST); + GL11.glPopMatrix(); + } + + @Override + public void handleMouseInput() throws IOException { + super.handleMouseInput(); + int dw = Mouse.getEventDWheel(); + double newScrollY = this.scrollY; + if(dw != 0) { + if (dw > 0) { + dw = -1; + } else { + dw = 1; + } + float amountScrolled = (float) (dw * 10); + if (newScrollY + amountScrolled > 0) + newScrollY += amountScrolled; + else + newScrollY = 0; + if(newScrollY < scrollHeight && scrollHeight > height - 25) { + this.scrollY = (float) newScrollY; + } + } } @Override protected void actionPerformed(GuiButton button) throws IOException { super.actionPerformed(button); + clickBaseButtons(button, this); + if(button instanceof Button) { + switch (button.id) { + case 1: + resetTabs((Button) button); + modCategory = ModCategory.MODS; + break; + case 2: + resetTabs((Button) button); + modCategory = ModCategory.SETTINGS; + break; + case 3: + resetTabs((Button) button); + modCategory = ModCategory.CONFIGS; + break; + case 4: + resetTabs((Button) button); + modCategory = ModCategory.PLUS; + break; + case 5: + mc.displayGuiScreen(new AddConfigModal(this)); + break; + case 6: + File file1 = Client.getInstance().dir; + String s = file1.getAbsolutePath(); + + if (Util.getOSType() == Util.EnumOS.OSX) { + try { + Client.logger.info(s); + Runtime.getRuntime().exec(new String[]{"/usr/bin/open", s}); + return; + } catch (IOException ioexception1) { + Client.logger.error((String) "Couldn\'t open file", (Throwable) ioexception1); + } + } else if (Util.getOSType() == Util.EnumOS.WINDOWS) { + String s1 = String.format("cmd.exe /C start \"Open file\" \"%s\"", new Object[]{s}); + + try { + Runtime.getRuntime().exec(s1); + return; + } catch (IOException ioexception) { + Client.logger.error((String) "Couldn\'t open file", (Throwable) ioexception); + } + } + + boolean flag = false; + + try { + Class oclass = Class.forName("java.awt.Desktop"); + Object object = oclass.getMethod("getDesktop", new Class[0]).invoke((Object) null, new Object[0]); + oclass.getMethod("browse", new Class[]{URI.class}).invoke(object, new Object[]{file1.toURI()}); + } catch (Throwable throwable) { + Client.logger.error("Couldn\'t open link", throwable); + flag = true; + } + + if (flag) { + Client.logger.info("Opening via system class!"); + Sys.openURL("file://" + s); + } + break; + } + } + } + + private void resetTabs(Button button) { + this.buttonList.forEach(oldButton -> { + if(oldButton instanceof Button) { + ((Button) oldButton).setTheme(new DefaultButtonTheme()); + } + }); + button.setTheme(new SelectedButtonTheme()); + this.scrollY = 0; + scrollAnimation.setValue(0); + } + + public static boolean mouseInContent(int mouseX, int mouseY, float height) { + return MouseUtils.isInside(mouseX, mouseY, 0, 66, 150, height - 66 - 21); } @Override protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException { super.mouseClicked(mouseX, mouseY, mouseButton); + + if(modCategory != ModCategory.CONFIGS && modCategory != ModCategory.PLUS) { + this.silentInputs.get(0).onClick(mouseX, mouseY, 3, 46, 127, true); + } + + if(!mouseInContent(mouseX, mouseY, height)) { + return; + } + + if(modCategory != ModCategory.CONFIGS && modCategory != ModCategory.PLUS) { + float modY = 66 - scrollAnimation.getValue(); + + for(Mod mod : getMods()) { + if(modCategory == ModCategory.MODS && Switch.isHovered(mouseX, mouseY, 129, modY + 10 - 4)) { + if(!mod.isForceDisabled()) { + Sounds.playButtonSound(); + mod.toggle(); + } + break; + } + + if(MouseUtils.isInside(mouseX, mouseY, 3, modY, 144, 20) && (Client.getInstance().getSettingsManager().getSettingByMod(mod).size() != 0 || mod.getName() == "Auto Text")) { + Sounds.playButtonSound(); + mc.displayGuiScreen(new ModSettings(mod, this)); + } + + modY += 23; + } + } else if(modCategory == ModCategory.CONFIGS) { + float configY = 66 - scrollAnimation.getValue(); + configY += 23; + this.scrollHeight += 20; + for(String config : Client.getInstance().getConfigManager().getConfigFiles()) { + if(config.equals(".config-settings.txt") || config.equals(".DS_Store") || Client.getInstance().configManager.configFile.getName().equals(config)) { + continue; + } + + if(MouseUtils.isInside(mouseX, mouseY, 132, configY + 10 - 6, 12, 12)) { + Client.getInstance().configManager.deleteConfig(config); + Sounds.playButtonSound(); + break; + } + + boolean isHovered = mouseInContent(mouseX, mouseY, height) && MouseUtils.isInside(mouseX, mouseY, 3, configY, 144, 20); + if(isHovered) { + Client.getInstance().configManager.loadConfig(config); + Sounds.playButtonSound(); + break; + } + + configY += 23; + this.scrollHeight += 20; + } + } else if(modCategory == ModCategory.PLUS && Client.getInstance().getAccount().isPlus()) { + float premiumY = 66 - scrollAnimation.getValue(); + premiumY += 15; + if(RegularColorPicker.isHovered(mouseX, mouseY, 3, (int) premiumY, 144)) { + // Color Picker + return; + } + premiumY += 15; + if(StaticButton.isHovered(mouseX, mouseY, 150 - 3 - 65, (int) premiumY, 65, 12)) { + Sounds.playButtonSound(); + try { + Class oclass = Class.forName("java.awt.Desktop"); + Object object = oclass.getMethod("getDesktop", new Class[0]).invoke((Object)null, new Object[0]); + oclass.getMethod("browse", new Class[] {URI.class}).invoke(object, new Object[] {new URI(Client.getInstance().getAccount().isPremiumPlus() ? "https://store.silentclient.net/premium/custom_cape" : "https://store.silentclient.net/premium")}); + } catch (Throwable err) { + err.printStackTrace(); + } + return; + } + premiumY += 30; + if(Client.getInstance().getAccount().isPremiumPlus()) { + if(Checkbox.isHovered(mouseX, mouseY, 3, (int) premiumY)) { + Client.getInstance().getAccount().setShowNametagMessage(!Client.getInstance().getAccount().showNametagMessage()); + return; + } + premiumY += 30; + this.silentInputs.get(1).onClick(mouseX, mouseY, 3, (int) premiumY, 144, true); + premiumY += 20; + if(StaticButton.isHovered(mouseX, mouseY, 150 - 3 - 50, (int) premiumY, 50, 12)) { + Client.getInstance().getAccount().setNametagMessage(this.silentInputs.get(1).getValue()); + } + } + } + } + + @Override + protected void keyTyped(char typedChar, int keyCode) throws IOException { + super.keyTyped(typedChar, keyCode); + if(modCategory != ModCategory.CONFIGS && modCategory != ModCategory.PLUS) { + this.silentInputs.get(0).onKeyTyped(typedChar, keyCode); + if(this.silentInputs.get(0).isFocused()) { + this.scrollY = 0; + scrollAnimation.setValue(0); + } + return; + } + + if(modCategory == ModCategory.PLUS) { + this.silentInputs.get(1).onKeyTyped(typedChar, keyCode); + } + } + + @Override + public boolean doesGuiPauseGame() { + return !(modCategory.equals(ModCategory.CONFIGS)); + } + + @Override + public void onGuiClosed() { + super.onGuiClosed(); + Client.getInstance().configManager.save(); + MenuBlurUtils.unloadBlur(); + } + + private ArrayList getMods() { + if(this.silentInputs.get(0).getValue().trim().equals("") || !modCategory.equals(ModCategory.MODS)) { + return Client.getInstance().getModInstances().getModByCategory(modCategory); + } + + return Client.getInstance().getModInstances().searchMods(this.silentInputs.get(0).getValue()); } } diff --git a/src/main/java/net/silentclient/client/gui/modmenu/ModSettings.java b/src/main/java/net/silentclient/client/gui/modmenu/ModSettings.java new file mode 100644 index 0000000..3b92b29 --- /dev/null +++ b/src/main/java/net/silentclient/client/gui/modmenu/ModSettings.java @@ -0,0 +1,323 @@ +package net.silentclient.client.gui.modmenu; + +import net.minecraft.client.gui.GuiButton; +import net.minecraft.client.gui.GuiScreen; +import net.minecraft.client.renderer.GlStateManager; +import net.minecraft.util.MathHelper; +import net.silentclient.client.Client; +import net.silentclient.client.gui.SilentScreen; +import net.silentclient.client.gui.animation.SimpleAnimation; +import net.silentclient.client.gui.elements.Button; +import net.silentclient.client.gui.elements.Checkbox; +import net.silentclient.client.gui.elements.Input; +import net.silentclient.client.gui.elements.StaticButton; +import net.silentclient.client.gui.font.SilentFontRenderer; +import net.silentclient.client.gui.theme.button.DefaultButtonTheme; +import net.silentclient.client.gui.theme.button.SelectedButtonTheme; +import net.silentclient.client.mods.Mod; +import net.silentclient.client.mods.ModCategory; +import net.silentclient.client.mods.Setting; +import net.silentclient.client.mods.render.CrosshairMod; +import net.silentclient.client.mods.world.TimeChangerMod; +import net.silentclient.client.utils.MenuBlurUtils; +import net.silentclient.client.utils.Sounds; +import org.lwjgl.input.Mouse; + +import java.io.IOException; +import java.net.URI; + +public class ModSettings extends SilentScreen { + private final Mod mod; + private final GuiScreen parentScreen; + private long initTime; + public double scrollY; + public static SimpleAnimation scrollAnimation = new SimpleAnimation(0.0F); + private float scrollHeight = 0; + + public ModSettings(Mod mod, GuiScreen parentScreen) { + if (mod == null) throw new IllegalArgumentException("Mod is null"); + + this.mod = mod; + this.parentScreen = parentScreen; + } + + + @Override + public void initGui() { + super.initGui(); + this.buttonList.clear(); + this.silentInputs.clear(); + this.initTime = System.currentTimeMillis(); + scrollY = 0; + scrollAnimation.setValue(0); + MenuBlurUtils.loadBlur(); + + ModMenu.initBaseButtons(this.buttonList); + + this.buttonList.add(new Button(1, 3, 26, 144, 15, "Back")); + this.buttonList.add(new Button(2, 3, this.height - 18, mod.getCategory() == ModCategory.MODS ? 70 : 144, 15, "Reset")); + if(mod.getCategory() == ModCategory.MODS) { + this.buttonList.add(new Button(3, 76, this.height - 18, 70, 15, mod.isEnabled() ? "Enabled" : "Disabled", false, mod.isEnabled() ? new SelectedButtonTheme() : new DefaultButtonTheme())); + } + + for (Setting setting : Client.getInstance().getSettingsManager().getSettingByMod(mod)) { + if(setting.isInput()) { + this.silentInputs.add(new Input(setting.getName(), setting.getValString())); + } + } + } + + @Override + public void drawScreen(int mouseX, int mouseY, float partialTicks) { + super.drawDefaultBackground(); + ModMenu.drawOverlayListBase(height, mod.getName()); + + super.drawScreen(mouseX, mouseY, partialTicks); + + ModMenu.trimContentStart(width, height); + float settingY = 66 - scrollAnimation.getValue(); + int inputIndex = 0; + + for (Setting setting : Client.getInstance().getSettingsManager().getSettingByMod(mod)) { + if(mod.getName() == "Crosshair" && Client.getInstance().getSettingsManager().getSettingByClass(CrosshairMod.class, "Preset Crosshair").getValBoolean() && setting.getName() != "Scale" && setting.getName() != "Crosshair Color" && setting.getName() != "Vanilla Blendering") { + continue; + } + if(mod.getName() == "Crosshair" && (setting.getName() == "Preset ID" || setting.getName() == "Preset Crosshair")) { + continue; + } + if(mod.getName() == "Crosshair" && setting.getName() == "Vanilla Blendering" && !Client.getInstance().getSettingsManager().getSettingByClass(CrosshairMod.class, "Preset Crosshair").getValBoolean()) { + continue; + } + GlStateManager.color(1, 1, 1, 1); + int settingHeight = 15; + if(setting.isInput()) { + Client.getInstance().getSilentFontRenderer().drawString(setting.getName(), 3, settingY, 12, SilentFontRenderer.FontType.TITLE); + if(setting.getName() == "Text After Value" && !Client.getInstance().getAccount().isPremiumPlus()) { + StaticButton.render(150 - 3 - 65, settingY, 65, 12, "BUY PREMIUM+"); + } else { + settingY += settingHeight; + this.silentInputs.get(inputIndex).render(mouseX, mouseY, 3, settingY, 144, true); + } + settingY += 5; + inputIndex++; + } + if (setting.isColor()) { + RegularColorPicker.render(3, settingY, 144, setting.getName(), setting.getValColor().getRGB()); + } + if (setting.isCheck()) { + Checkbox.render(mouseX, mouseY, 3, settingY, setting.getName(), setting.getValBoolean()); + } + + if(setting.isSlider()) { + RegularSlider.render(3, settingY, 144, setting.getName(), setting.getMax(), setting.getValDouble()); + + if(RegularSlider.isDrag(mouseX, mouseY, 3, settingY, 144) && (System.currentTimeMillis() - initTime) > 500) { + double diff = setting.getMax() - setting.getMin(); + double mouse = MathHelper.clamp_double((mouseX - 3) / 90D, 0, 1); + double newVal = setting.getMin() + mouse * diff; + if(newVal != setting.getValDouble()) { + setting.setValDouble(newVal); + mod.onChangeSettingValue(setting); + } + } + + settingY += 15; + } + + if(setting.isCombo()) { + RegularSelect.render(mouseX, mouseY, 3, settingY, 144, setting.getName(), setting.getValString()); + settingY += 15; + } + + settingY += settingHeight; + } + + this.scrollHeight = 66 + settingY + scrollAnimation.getValue(); + + ModMenu.trimContentEnd(); + + scrollAnimation.setAnimation((float) scrollY, 12); + } + + @Override + public void handleMouseInput() throws IOException { + super.handleMouseInput(); + int dw = Mouse.getEventDWheel(); + double newScrollY = this.scrollY; + if(dw != 0) { + if (dw > 0) { + dw = -1; + } else { + dw = 1; + } + float amountScrolled = (float) (dw * 10); + if (newScrollY + amountScrolled > 0) + newScrollY += amountScrolled; + else + newScrollY = 0; + Client.logger.info(String.format("newscroll: %s, scrollheight: %s, height: %s", newScrollY, scrollHeight, height)); + if(newScrollY < scrollHeight && scrollHeight > height) { + this.scrollY = (float) newScrollY; + } + } + } + + @Override + protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException { + super.mouseClicked(mouseX, mouseY, mouseButton); + + float settingY = 66 - scrollAnimation.getValue(); + int inputIndex = 0; + + for (Setting setting : Client.getInstance().getSettingsManager().getSettingByMod(mod)) { + if(mod.getName() == "Crosshair" && Client.getInstance().getSettingsManager().getSettingByClass(CrosshairMod.class, "Preset Crosshair").getValBoolean() && setting.getName() != "Scale" && setting.getName() != "Crosshair Color" && setting.getName() != "Vanilla Blendering") { + continue; + } + if(mod.getName() == "Crosshair" && (setting.getName() == "Preset ID" || setting.getName() == "Preset Crosshair")) { + continue; + } + if(mod.getName() == "Crosshair" && setting.getName() == "Vanilla Blendering" && !Client.getInstance().getSettingsManager().getSettingByClass(CrosshairMod.class, "Preset Crosshair").getValBoolean()) { + continue; + } + GlStateManager.color(1, 1, 1, 1); + int settingHeight = 15; + if(setting.isInput()) { + Client.getInstance().getSilentFontRenderer().drawString(setting.getName(), 3, settingY, 12, SilentFontRenderer.FontType.TITLE); + if(setting.getName() == "Text After Value" && !Client.getInstance().getAccount().isPremiumPlus()) { + if(StaticButton.isHovered(mouseX, mouseY, 150 - 3 - 65, settingY, 65, 12)) { + Sounds.playButtonSound(); + try { + Class oclass = Class.forName("java.awt.Desktop"); + Object object = oclass.getMethod("getDesktop", new Class[0]).invoke((Object)null, new Object[0]); + oclass.getMethod("browse", new Class[] {URI.class}).invoke(object, new Object[] {new URI("https://store.silentclient.net/premium")}); + } catch (Throwable err) { + err.printStackTrace(); + } + } + } else { + this.scrollHeight += 12; + settingY += settingHeight; + this.silentInputs.get(inputIndex).onClick(mouseX, mouseY, 3, (int) settingY, 144, true); + } + settingY += 5; + inputIndex++; + } + if (setting.isColor() && RegularColorPicker.isHovered(mouseX, mouseY, 3, (int) settingY, 144)) { + mc.displayGuiScreen(new ColorPicker(mod, setting.getName(), this)); + } + if (setting.isCheck()) { + if(Checkbox.isHovered(mouseX, mouseY, 3, settingY)) { + Sounds.playButtonSound(); + setting.setValBoolean(!setting.getValBoolean()); + } + } + + if(setting.isSlider()) { + settingY += 15; + } + + if(setting.isCombo()) { + int index = 0; + String curr = setting.getValString(); + String next = ""; + String prev = ""; + + for(int i=0;i (setting.getOptions().size() - 1)) { + next = setting.getOptions().get(0); + } else { + next = setting.getOptions().get(index + 1); + } + + if(!((index - 1) > (setting.getOptions().size() - 1)) && (index - 1) != -1) { + prev = setting.getOptions().get(index - 1); + } else { + prev = setting.getOptions().get(setting.getOptions().size() - 1); + } + + if(RegularSelect.prevHovered(mouseX, mouseY, 3, settingY)) { + Sounds.playButtonSound(); + setting.setValString(prev); + mod.onChangeSettingValue(setting); + } + + if(RegularSelect.nextHovered(mouseX, mouseY, 3, settingY, 144)) { + Sounds.playButtonSound(); + setting.setValString(next); + mod.onChangeSettingValue(setting); + } + settingY += 15; + } + + settingY += settingHeight; + } + } + + @Override + protected void actionPerformed(GuiButton button) throws IOException { + super.actionPerformed(button); + ModMenu.clickBaseButtons(button, this); + + switch (button.id) { + case 1: + mc.displayGuiScreen(parentScreen); + break; + case 2: + mod.reset(false); + break; + case 3: + mod.toggle(); + button.displayString = mod.isEnabled() ? "Enabled" : "Disabled"; + if(button instanceof Button) { + ((Button) button).setTheme(mod.isEnabled() ? new SelectedButtonTheme() : new DefaultButtonTheme()); + } + break; + } + } + + @Override + protected void keyTyped(char typedChar, int keyCode) throws IOException { + super.keyTyped(typedChar, keyCode); + + int inputIndex = 0; + + for (Setting setting : Client.getInstance().getSettingsManager().getSettingByMod(mod)) { + if (setting.isInput()) { + if(setting.getName() == "Text After Value" && !Client.getInstance().getAccount().isPremiumPlus()) { + inputIndex++; + continue; + } + this.silentInputs.get(inputIndex).onKeyTyped(typedChar, keyCode); + setting.setValString(this.silentInputs.get(inputIndex).getValue()); + inputIndex++; + } + } + } + + @Override + public void onGuiClosed() { + super.onGuiClosed(); + int inputIndex = 0; + for (Setting setting : Client.getInstance().getSettingsManager().getSettingByMod(mod)) { + if (setting.isInput()) { + if(setting.getName() == "Text After Value" && !Client.getInstance().getAccount().isPremiumPlus()) { + inputIndex++; + continue; + } + setting.setValString(this.silentInputs.get(inputIndex).getValue().length() != 0 ? this.silentInputs.get(inputIndex).getValue() : setting.defaultsval); + inputIndex++; + } + } + Client.getInstance().configManager.save(); + MenuBlurUtils.unloadBlur(); + } + + @Override + public boolean doesGuiPauseGame() { + return !(this.mod instanceof TimeChangerMod); + } +} diff --git a/src/main/java/net/silentclient/client/gui/modmenu/RegularColorPicker.java b/src/main/java/net/silentclient/client/gui/modmenu/RegularColorPicker.java new file mode 100644 index 0000000..b816c84 --- /dev/null +++ b/src/main/java/net/silentclient/client/gui/modmenu/RegularColorPicker.java @@ -0,0 +1,20 @@ +package net.silentclient.client.gui.modmenu; + +import net.silentclient.client.Client; +import net.silentclient.client.gui.font.SilentFontRenderer; +import net.silentclient.client.gui.lite.clickgui.utils.MouseUtils; +import net.silentclient.client.gui.util.RenderUtil; + +import java.awt.*; + +public class RegularColorPicker { + public static void render(float x, float y, int width, String name, int color) { + Client.getInstance().getSilentFontRenderer().drawString(name, x, y - 1, 12, SilentFontRenderer.FontType.TITLE); + RenderUtil.drawRoundedRect(x + width - 15, y + 2, 15, 9, 5, color); + RenderUtil.drawRoundedOutline(x + width - 15, y + 2, 15, 8, 5, 2, new Color(255, 255, 255).getRGB()); + } + + public static boolean isHovered(int mouseX, int mouseY, int x, int y, int width) { + return MouseUtils.isInside(mouseX, mouseY, x + width - 15, y + 2, 15, 9); + } +} diff --git a/src/main/java/net/silentclient/client/gui/modmenu/RegularSelect.java b/src/main/java/net/silentclient/client/gui/modmenu/RegularSelect.java new file mode 100644 index 0000000..585629c --- /dev/null +++ b/src/main/java/net/silentclient/client/gui/modmenu/RegularSelect.java @@ -0,0 +1,31 @@ +package net.silentclient.client.gui.modmenu; + +import net.silentclient.client.Client; +import net.silentclient.client.gui.font.SilentFontRenderer; +import net.silentclient.client.gui.lite.clickgui.utils.MouseUtils; +import net.silentclient.client.utils.ColorUtils; + +import java.awt.*; + +public class RegularSelect { + public static void render(int mouseX, int mouseY, float x, float y, int width, String name, String selected) { + boolean firstHovered = RegularSelect.prevHovered(mouseX, mouseY, x, y); + boolean twoHovered = RegularSelect.nextHovered(mouseX, mouseY, x, y, width); + Client.getInstance().getSilentFontRenderer().drawString(name, x, y, 12, SilentFontRenderer.FontType.TITLE); + ColorUtils.setColor(new Color(255, 255, 255, firstHovered ? 127 : 255).getRGB()); + Client.getInstance().getSilentFontRenderer().drawString("<", x, y + 15, 12, SilentFontRenderer.FontType.TITLE); + ColorUtils.setColor(new Color(255, 255, 255).getRGB()); + Client.getInstance().getSilentFontRenderer().drawCenteredString(selected, (int) (x + width / 2), (int) (y + 15), 12, SilentFontRenderer.FontType.TITLE); + ColorUtils.setColor(new Color(255, 255, 255, twoHovered ? 127 : 255).getRGB()); + Client.getInstance().getSilentFontRenderer().drawString(">", x + width - Client.getInstance().getSilentFontRenderer().getStringWidth(">", 12, SilentFontRenderer.FontType.TITLE), y + 15, 12, SilentFontRenderer.FontType.TITLE); + ColorUtils.setColor(new Color(255, 255, 255).getRGB()); + } + + public static boolean prevHovered(int mouseX, int mouseY, float x, float y) { + return MouseUtils.isInside(mouseX, mouseY, x, y + 12, Client.getInstance().getSilentFontRenderer().getStringWidth("<", 12, SilentFontRenderer.FontType.TITLE), 12); + } + + public static boolean nextHovered(int mouseX, int mouseY, float x, float y, int width) { + return MouseUtils.isInside(mouseX, mouseY, x + width - Client.getInstance().getSilentFontRenderer().getStringWidth(">", 12, SilentFontRenderer.FontType.TITLE), y + 15, Client.getInstance().getSilentFontRenderer().getStringWidth(">", 12, SilentFontRenderer.FontType.TITLE), 12); + } +} diff --git a/src/main/java/net/silentclient/client/gui/modmenu/RegularSlider.java b/src/main/java/net/silentclient/client/gui/modmenu/RegularSlider.java new file mode 100644 index 0000000..c7e2239 --- /dev/null +++ b/src/main/java/net/silentclient/client/gui/modmenu/RegularSlider.java @@ -0,0 +1,29 @@ +package net.silentclient.client.gui.modmenu; + +import net.silentclient.client.Client; +import net.silentclient.client.gui.font.SilentFontRenderer; +import net.silentclient.client.gui.lite.clickgui.utils.MouseUtils; +import net.silentclient.client.gui.lite.clickgui.utils.RenderUtils; +import net.silentclient.client.gui.util.RenderUtil; +import org.lwjgl.input.Mouse; + +import java.awt.*; +import java.text.DecimalFormat; + +public class RegularSlider { + public static void render(float x, float y, int width, String name, double max, double value) { + Client.getInstance().getSilentFontRenderer().drawString(name, x, y, 12, SilentFontRenderer.FontType.TITLE); + + RenderUtil.drawRoundedRect(x, y + 15, 100, 9, 3, Color.black.getRGB()); + if(value != 0) { + RenderUtil.drawRoundedRect(x, y + 15, 100F * (float) (value / max), 9, 3, -1); + } + + float textLeft = x + width - Client.getInstance().getSilentFontRenderer().getStringWidth(new DecimalFormat("0.00").format(value), 12, SilentFontRenderer.FontType.TITLE); + Client.getInstance().getSilentFontRenderer().drawString(new DecimalFormat("0.00").format(value), textLeft, y + 14, 12, SilentFontRenderer.FontType.TITLE); + } + + public static boolean isDrag(int mouseX, int mouseY, float x, float y, int width) { + return MouseUtils.isInside(mouseX, mouseY, x, y + 15, 100, 9) && Mouse.isButtonDown(0); + } +} diff --git a/src/main/java/net/silentclient/client/mixin/mixins/EntityRendererMixin.java b/src/main/java/net/silentclient/client/mixin/mixins/EntityRendererMixin.java index d5171e8..35875a1 100644 --- a/src/main/java/net/silentclient/client/mixin/mixins/EntityRendererMixin.java +++ b/src/main/java/net/silentclient/client/mixin/mixins/EntityRendererMixin.java @@ -16,6 +16,7 @@ import net.silentclient.client.event.impl.EventCameraRotation; import net.silentclient.client.event.impl.EventPlayerHeadRotation; import net.silentclient.client.event.impl.EventRender3D; import net.silentclient.client.event.impl.EventZoomFov; +import net.silentclient.client.gui.notification.NotificationManager; import net.silentclient.client.mixin.ducks.EntityRendererExt; import net.silentclient.client.mods.render.AnimationsMod; import net.silentclient.client.mods.render.NewMotionBlurMod; @@ -213,6 +214,11 @@ public abstract class EntityRendererMixin implements EntityRendererExt { } } + @Inject(method = "updateCameraAndRender", at = @At("TAIL")) + public void notificationRenderer(float partialTicks, long nanoTime, CallbackInfo ci) { + NotificationManager.render(); + } + @Inject(method = "renderHand", at = @At("HEAD")) public void swingProgress(float partialTicks, int xOffset, CallbackInfo ci) { if(mc.thePlayer != null && Client.getInstance().getModInstances().getOldAnimationsMod().isEnabled() && Client.getInstance().getSettingsManager().getSettingByClass(AnimationsMod.class, "1.7 Punching Animation").getValBoolean() diff --git a/src/main/java/net/silentclient/client/mixin/mixins/GuiInGameMixin.java b/src/main/java/net/silentclient/client/mixin/mixins/GuiInGameMixin.java index 2edf02b..39b600c 100644 --- a/src/main/java/net/silentclient/client/mixin/mixins/GuiInGameMixin.java +++ b/src/main/java/net/silentclient/client/mixin/mixins/GuiInGameMixin.java @@ -41,7 +41,6 @@ public abstract class GuiInGameMixin extends Gui { GlStateManager.enableTexture2D(); GlStateManager.disableBlend(); GlStateManager.disableAlpha(); - NotificationManager.render(); } @Inject(method = "renderTooltip", at = @At("HEAD")) diff --git a/src/main/java/net/silentclient/client/mods/Mod.java b/src/main/java/net/silentclient/client/mods/Mod.java index 8c43624..30cb4c1 100644 --- a/src/main/java/net/silentclient/client/mods/Mod.java +++ b/src/main/java/net/silentclient/client/mods/Mod.java @@ -6,13 +6,11 @@ import java.util.ArrayList; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.gui.GuiScreen; -import net.minecraft.util.ResourceLocation; import net.silentclient.client.Client; import net.silentclient.client.event.EventManager; import net.silentclient.client.gui.animation.SimpleAnimation; import net.silentclient.client.gui.hud.ScreenPosition; import net.silentclient.client.utils.MenuBlurUtils; -import net.silentclient.client.utils.NotificationUtils; import net.silentclient.client.utils.RawInputHandler; public class Mod implements IMod { @@ -173,14 +171,26 @@ public class Mod implements IMod { return toggled; } - public void renderCustomComponent(int x, int y, int width, int height, int mouseX, int mouseY) { + public void renderCustomLiteComponent(int x, int y, int width, int height, int mouseX, int mouseY) { return; } - public int customComponentWidth() { + public int customComponentLiteWidth() { return 0; } + public int customComponentLiteHeight() { + return 0; + } + + public void renderCustomComponent(int x, int y, int width, int height, int mouseX, int mouseY) { + return; + } + + public int customComponentWidth() { + return 0; + } + public int customComponentHeight() { return 0; } diff --git a/src/main/java/net/silentclient/client/mods/player/AutoTextMod.java b/src/main/java/net/silentclient/client/mods/player/AutoTextMod.java index ee353ab..a568641 100644 --- a/src/main/java/net/silentclient/client/mods/player/AutoTextMod.java +++ b/src/main/java/net/silentclient/client/mods/player/AutoTextMod.java @@ -40,13 +40,13 @@ public class AutoTextMod extends Mod { } @Override - public void renderCustomComponent(int x, int y, int width, int height, int mouseX, int mouseY) { + public void renderCustomLiteComponent(int x, int y, int width, int height, int mouseX, int mouseY) { CustomFontRenderer font = new CustomFontRenderer(); font.setRenderMode(CustomFontRenderer.RenderMode.CUSTOM); font.drawString("Macros:", x, y, -1, 14); - font.drawString("Create Macro", x + customComponentWidth() - font.getStringWidth("Create Macro", 12, SilentFontRenderer.FontType.TITLE) - 20, y, MouseUtils.isInside(mouseX, mouseY, x + customComponentWidth() - font.getStringWidth("Create Macro", 12, SilentFontRenderer.FontType.TITLE) - 20, y, font.getStringWidth("Create Macro", 12, SilentFontRenderer.FontType.TITLE), 12) ? new Color(255, 255, 255, 127).getRGB() : -1, 12); + font.drawString("Create Macro", x + customComponentLiteWidth() - font.getStringWidth("Create Macro", 12, SilentFontRenderer.FontType.TITLE) - 20, y, MouseUtils.isInside(mouseX, mouseY, x + customComponentLiteWidth() - font.getStringWidth("Create Macro", 12, SilentFontRenderer.FontType.TITLE) - 20, y, font.getStringWidth("Create Macro", 12, SilentFontRenderer.FontType.TITLE), 12) ? new Color(255, 255, 255, 127).getRGB() : -1, 12); int spacing = y + 20; @@ -61,12 +61,12 @@ public class AutoTextMod extends Mod { } @Override - public int customComponentHeight() { + public int customComponentLiteHeight() { return componentHeight; } @Override - public int customComponentWidth() { + public int customComponentLiteWidth() { return 290; } @@ -75,7 +75,7 @@ public class AutoTextMod extends Mod { CustomFontRenderer font = new CustomFontRenderer(); font.setRenderMode(CustomFontRenderer.RenderMode.CUSTOM); - if(MouseUtils.isInside(mouseX, mouseY, x + customComponentWidth() - font.getStringWidth("Create Macro", 12, SilentFontRenderer.FontType.TITLE) - 20, y, font.getStringWidth("Create Macro", 12, SilentFontRenderer.FontType.TITLE), 12)) { + if(MouseUtils.isInside(mouseX, mouseY, x + customComponentLiteWidth() - font.getStringWidth("Create Macro", 12, SilentFontRenderer.FontType.TITLE) - 20, y, font.getStringWidth("Create Macro", 12, SilentFontRenderer.FontType.TITLE), 12)) { mc.displayGuiScreen(new AutoTextAddCommandGui(screen)); } @@ -222,7 +222,6 @@ public class AutoTextMod extends Mod { super.drawScreen(mouseX, mouseY, partialTicks); GlStateManager.popMatrix(); - NotificationManager.render(); } @Override diff --git a/src/main/java/net/silentclient/client/mods/render/CrosshairMod.java b/src/main/java/net/silentclient/client/mods/render/CrosshairMod.java index 945ba32..4aec253 100644 --- a/src/main/java/net/silentclient/client/mods/render/CrosshairMod.java +++ b/src/main/java/net/silentclient/client/mods/render/CrosshairMod.java @@ -121,7 +121,7 @@ public class CrosshairMod extends Mod { } @Override - public int customComponentHeight() { + public int customComponentLiteHeight() { boolean preset = Client.getInstance().getSettingsManager().getSettingByClass(CrosshairMod.class, "Preset Crosshair").getValBoolean(); int height = 30; @@ -141,12 +141,12 @@ public class CrosshairMod extends Mod { } @Override - public int customComponentWidth() { + public int customComponentLiteWidth() { return componentWidth; } @Override - public void renderCustomComponent(int x, int y, int width, int height, int mouseX, int mouseY) { + public void renderCustomLiteComponent(int x, int y, int width, int height, int mouseX, int mouseY) { CustomFontRenderer font = new CustomFontRenderer(); font.setRenderMode(CustomFontRenderer.RenderMode.CUSTOM); GlStateManager.pushMatrix(); diff --git a/src/main/java/net/silentclient/client/utils/SilentSocket.java b/src/main/java/net/silentclient/client/utils/SilentSocket.java index 1f53904..5c9023d 100644 --- a/src/main/java/net/silentclient/client/utils/SilentSocket.java +++ b/src/main/java/net/silentclient/client/utils/SilentSocket.java @@ -30,74 +30,47 @@ public class SilentSocket { public SilentSocket(String server) throws URISyntaxException { _url = new URI(server); sock = IO.socket(_url); - connectListener = new Listener() { @Override - public void call(Object... arg0) { + connectListener = arg0 -> { Client.logger.info("Connected to Silent Socket!"); sock.emit("set_token", _token); - } }; - disconectListener = new Listener() { - @Override - public void call(Object... arg0) { - Client.logger.info("Disconnected from Silent Socket!"); + disconectListener = arg0 -> Client.logger.info("Disconnected from Silent Socket!"); + + notificationListener = arg0 -> { + try { + GsonBuilder builder = new GsonBuilder(); + Gson gson = builder.create(); + NotificationResponse response = gson.fromJson(arg0[0].toString(), NotificationResponse.class); + Client.logger.info("Received notification via API: " + arg0[0].toString()); + NotificationUtils.showNotification(response.getStatus(), response.getMessage()); + } catch (Exception err) { + Client.logger.catching(err); } }; - notificationListener = new Listener() { - - @Override - public void call(Object... arg0) { - Client.logger.info("notification"); - try { - GsonBuilder builder = new GsonBuilder(); - Gson gson = builder.create(); - NotificationResponse response = gson.fromJson((String)arg0[0].toString(), NotificationResponse.class); - if(Minecraft.getMinecraft().thePlayer != null) { - Client.logger.info("Received notification via API: " + (String)arg0[0].toString()); - NotificationUtils.showNotification(response.getStatus(), response.getMessage()); - } - } catch (Exception err) { - Client.logger.catching(err); + accountListener = arg0 -> { + try { + GsonBuilder builder = new GsonBuilder(); + Gson gson = builder.create(); + PlayerResponse response = gson.fromJson(arg0[0].toString(), PlayerResponse.class); + if(response.getAccount() != null) { + Client.logger.info("Received account via Websocket: " + response.getAccount().getUsername()); + Players.handleAccount(response.getAccount()); } + } catch (Exception err) { + Client.logger.catching(err); } }; - accountListener = new Listener() { - @Override - public void call(Object... arg0) { - try { - GsonBuilder builder = new GsonBuilder(); - Gson gson = builder.create(); - PlayerResponse response = gson.fromJson((String)arg0[0].toString(), PlayerResponse.class); - if(response.getAccount() != null) { - Client.logger.info("Received account via Websocket: " + response.getAccount().getUsername()); - Players.handleAccount(response.getAccount()); - } - } catch (Exception err) { - Client.logger.catching(err); - } - } - }; - - errorListener = new Listener() { - @Override - public void call(Object... arg0) { - Client.logger.error("Silent Socket Error!"); - } - }; + errorListener = arg0 -> Client.logger.error("Silent Socket Error!"); sock.on(Socket.EVENT_CONNECT, connectListener) .on(Socket.EVENT_DISCONNECT, disconectListener) .on(Socket.EVENT_ERROR, errorListener) .on("account", accountListener) .on("notification", notificationListener) - .on("update_information", new Listener() { - @Override - public void call(Object... arg0) { - Client.logger.info("User information updated: " + (String)arg0[0].toString()); - } - }); + .on("update_information", arg0 -> Client.logger.info("User information updated: " + arg0[0].toString())); } public Socket getSocket() { diff --git a/src/main/resources/assets/minecraft/silentclient/icons/pencil.png b/src/main/resources/assets/minecraft/silentclient/icons/pencil.png new file mode 100755 index 0000000..4e6cf10 Binary files /dev/null and b/src/main/resources/assets/minecraft/silentclient/icons/pencil.png differ