Advertisement
Guest User

Untitled

a guest
Aug 12th, 2023
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.59 KB | None | 0 0
  1. package Ignite.gui.clickgui;
  2.  
  3. import Ignite.Ignite;
  4. import Ignite.gui.clickgui.elements.Button;
  5. import Ignite.modules.Module;
  6. import Ignite.modules.ModuleCategory;
  7. import Ignite.utils.render.RenderUtils;
  8. import com.google.common.collect.Lists;
  9. import net.minecraft.client.Minecraft;
  10. import net.minecraft.client.gui.Gui;
  11. import net.minecraft.client.gui.GuiScreen;
  12. import net.minecraft.client.gui.ScaledResolution;
  13. import net.minecraft.util.ResourceLocation;
  14. import org.lwjgl.input.Keyboard;
  15. import org.lwjgl.input.Mouse;
  16. import org.lwjgl.opengl.GL11;
  17.  
  18. import java.awt.*;
  19. import java.io.IOException;
  20. import java.util.List;
  21.  
  22. public class ClickGUI extends GuiScreen {
  23.  
  24. protected List<Button> categoryButtons = Lists.<Button>newArrayList();
  25. protected List<Button> modButtons = Lists.<Button>newArrayList();
  26.  
  27. @Override
  28. public void drawScreen(int mouseX, int mouseY, float partialTicks) {
  29. RenderUtils.drawRoundedRectangle(width / 2 - 700 / 2, height / 2 - (600 / 2 - 100), width / 2 - 700 / 2 + 700, height / 2 + (600 / 2 - 100), 20, new Color(28, 28, 28, 255).getRGB());
  30. RenderUtils.drawCustomImage(width / 2 - 800 / 2 + 120, height / 2 - (600 / 2 - 120), 85, 85, new ResourceLocation("/textures/gui/title/logo480.png"));
  31. for(Button button : categoryButtons){
  32. button.drawButton(mc,mouseX,mouseY,partialTicks);
  33. }
  34.  
  35. int wheel = Mouse.getDWheel();
  36. for (Button m : modButtons) {
  37. GL11.glEnable(GL11.GL_SCISSOR_TEST);
  38. this.glScissor((double) new ScaledResolution(Minecraft.getMinecraft()).getScaledWidth() / 2 - 205, (double) new ScaledResolution(Minecraft.getMinecraft()).getScaledHeight() / 2 - 118, (double) new ScaledResolution(Minecraft.getMinecraft()).getScaledWidth() / 2 + 205, 235);
  39. m.drawButton(mc,mouseX,mouseY,partialTicks);
  40. if (wheel < 0) {
  41. m.y -= 16;
  42. } else if (wheel > 0) {
  43. m.y += 16;
  44. }
  45. GL11.glDisable(GL11.GL_SCISSOR_TEST);
  46. }
  47. }
  48.  
  49. @Override
  50. public void initGui() {
  51. categoryButtons.add(new Button(width / 2 - 700 / 2 + 30, this.height / 2 - 60, 80, 25, "Combat", false));
  52. categoryButtons.add(new Button(width / 2 - 700 / 2 + 30, this.height / 2, 80, 25, "Visual", false));
  53. categoryButtons.add(new Button(width / 2 - 700 / 2 + 30, this.height / 2 + 60, 100, 25, "Miscellaneous", false));
  54. }
  55.  
  56. @Override
  57. protected void mouseClicked(int mouseX, int mouseY, int mouseButton) {
  58. if(mouseButton == 0) {
  59. for (Button button : categoryButtons) {
  60. if (button.mouseClicked(mouseX, mouseY, mouseButton)) {
  61. if (button.getButtonText().equalsIgnoreCase("combat")) {
  62. int yOffset = 0;
  63. modButtons.clear();
  64. for (Module m : Ignite.instance.getModulesInType(ModuleCategory.COMBAT)) {
  65. modButtons.add(new Button(width / 2 - 100, this.height / 2 - 110 + yOffset, 350, 40, m.name, true));
  66. yOffset += 50;
  67. }
  68. } else if (button.getButtonText().equalsIgnoreCase("visual")) {
  69. int yOffset = 0;
  70. modButtons.clear();
  71. for (Module m : Ignite.instance.getModulesInType(ModuleCategory.VISUAL)) {
  72. modButtons.add(new Button(width / 2 - 100, this.height / 2 - 110 + yOffset, 350, 40, m.name, true));
  73. yOffset += 50;
  74. }
  75. } else if (button.getButtonText().equalsIgnoreCase("miscellaneous")) {
  76. int yOffset = 0;
  77. modButtons.clear();
  78. for (Module m : Ignite.instance.getModulesInType(ModuleCategory.MISC)) {
  79. modButtons.add(new Button(width / 2 - 100, this.height / 2 - 110 + yOffset, 350, 40, m.name, true));
  80. yOffset += 50;
  81. }
  82. }
  83. }
  84. }
  85. for (Button button : modButtons) {
  86. if (button.mouseClicked(mouseX, mouseY, mouseButton)) {
  87. Ignite.getModuleByName(button.getButtonText()).toggle();
  88. }
  89. }
  90. } else if(mouseButton == 1) {
  91. for (Button button : modButtons) {
  92. if (button.mouseClicked(mouseX, mouseY, mouseButton)) {
  93. if (button.isExpandable())
  94. button.setExpanded(!button.isExpanded());
  95. }
  96. }
  97. }
  98. }
  99.  
  100. private void glScissor(double x, double y, double width, double height) {
  101.  
  102. y += height;
  103.  
  104. ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft());
  105.  
  106. Minecraft mc = Minecraft.getMinecraft();
  107.  
  108. GL11.glScissor((int) ((x * mc.displayWidth) / scaledResolution.getScaledWidth()),
  109. (int) (((scaledResolution.getScaledHeight() - y) * mc.displayHeight) / scaledResolution.getScaledHeight()),
  110. (int) (width * mc.displayWidth / scaledResolution.getScaledWidth()),
  111. (int) (height * mc.displayHeight / scaledResolution.getScaledHeight()));
  112. }
  113.  
  114. @Override
  115. protected void keyTyped(char typedChar, int keyCode) throws IOException {
  116. if(keyCode == Keyboard.KEY_ESCAPE || keyCode == Keyboard.KEY_RSHIFT){
  117. Ignite.getModuleByName("clickgui").toggle();
  118. }
  119. super.keyTyped(typedChar, keyCode);
  120. }
  121. }
  122.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement