From fad0e050ef2da24447fd47769bb6dad9fe320290 Mon Sep 17 00:00:00 2001 From: noil Date: Tue, 29 Dec 2020 18:22:00 -0500 Subject: [PATCH] Adds option buttons to ModuleListComponent --- .../component/module/ModuleListComponent.java | 37 +++++++++++++----- .../textures/gear_wheel_modulelist.png | Bin 0 -> 5580 bytes 2 files changed, 28 insertions(+), 9 deletions(-) create mode 100644 src/main/resources/assets/seppukumod/textures/gear_wheel_modulelist.png diff --git a/src/main/java/me/rigamortis/seppuku/impl/gui/hud/component/module/ModuleListComponent.java b/src/main/java/me/rigamortis/seppuku/impl/gui/hud/component/module/ModuleListComponent.java index 3ea4daf..3097fdf 100644 --- a/src/main/java/me/rigamortis/seppuku/impl/gui/hud/component/module/ModuleListComponent.java +++ b/src/main/java/me/rigamortis/seppuku/impl/gui/hud/component/module/ModuleListComponent.java @@ -16,6 +16,7 @@ import net.minecraft.client.gui.ScaledResolution; import net.minecraft.client.renderer.GlStateManager; import net.minecraft.util.math.MathHelper; import org.apache.commons.lang3.StringUtils; +import org.lwjgl.Sys; import org.lwjgl.input.Keyboard; import org.lwjgl.input.Mouse; import org.lwjgl.opengl.GL11; @@ -47,6 +48,7 @@ public final class ModuleListComponent extends ResizableHudComponent { private final HudEditorModule hudEditorModule; private final Texture texture; + private final Texture gearTexture; private ToolTipComponent currentToolTip; private ModuleSettingsComponent currentSettings; @@ -57,6 +59,7 @@ public final class ModuleListComponent extends ResizableHudComponent { this.originalName = StringUtils.capitalize(type.name().toLowerCase()); this.hudEditorModule = (HudEditorModule) Seppuku.INSTANCE.getModuleManager().find(HudEditorModule.class); this.texture = new Texture("module-" + type.name().toLowerCase() + ".png"); + this.gearTexture = new Texture("gear_wheel_modulelist.png"); this.setSnappable(false); this.setLocked(true); @@ -87,7 +90,6 @@ public final class ModuleListComponent extends ResizableHudComponent { this.setDragging(false); } - // clamp max width & height if (this.isResizeDragging()) { if (this.getH() > this.getTotalHeight()) { @@ -154,17 +156,28 @@ public final class ModuleListComponent extends ResizableHudComponent { } else { this.title = this.originalName; for (Module module : Seppuku.INSTANCE.getModuleManager().getModuleList(this.type)) { - RenderUtil.drawRect(this.getX() + BORDER + TEXT_GAP, this.getY() + offsetY + BORDER + TEXT_GAP - this.scroll, this.getX() + BORDER + TEXT_GAP + this.getW() - BORDER - SCROLL_WIDTH - BORDER - 2, this.getY() + offsetY + BORDER + TEXT_GAP + mc.fontRenderer.FONT_HEIGHT - this.scroll, module.isEnabled() ? 0x451B002A : 0x451F1C22); + // draw module button bg + RenderUtil.drawRect(this.getX() + BORDER + TEXT_GAP, this.getY() + offsetY + BORDER + TEXT_GAP - this.scroll, this.getX() + BORDER + TEXT_GAP + (module.getValueList().size() != 0 ? this.getW() - 10 : this.getW()) - BORDER - SCROLL_WIDTH - BORDER - 2, this.getY() + offsetY + BORDER + TEXT_GAP + mc.fontRenderer.FONT_HEIGHT - this.scroll, module.isEnabled() ? 0x453B005F : 0x451F1C22); - if (module.getValueList().size() != 0) { - RenderUtil.drawLine(this.getX() + BORDER + TEXT_GAP + this.getW() - BORDER - SCROLL_WIDTH - BORDER - 4, this.getY() + offsetY + BORDER + TEXT_GAP - this.scroll + 1, this.getX() + BORDER + TEXT_GAP + this.getW() - BORDER - SCROLL_WIDTH - BORDER - 4, this.getY() + offsetY + BORDER + TEXT_GAP + mc.fontRenderer.FONT_HEIGHT - this.scroll - 1, 1f, 0x45909090); + final boolean insideModule = mouseX >= (this.getX() + BORDER) && mouseX <= (this.getX() + this.getW() - BORDER - SCROLL_WIDTH - 1) && mouseY >= (this.getY() + BORDER + mc.fontRenderer.FONT_HEIGHT + 1 + offsetY - this.scroll - mc.fontRenderer.FONT_HEIGHT + 1) && mouseY <= (this.getY() + BORDER + (mc.fontRenderer.FONT_HEIGHT) + 1 + offsetY - this.scroll); + if (module.getValueList().size() != 0) { // draw options line + final boolean isHoveringOptions = mouseX >= (this.getX() + this.getW() - BORDER - SCROLL_WIDTH - 12) && mouseX <= (this.getX() + this.getW() - BORDER - SCROLL_WIDTH - 2) && mouseY >= (this.getY() + BORDER + mc.fontRenderer.FONT_HEIGHT + 1 + offsetY - this.scroll - mc.fontRenderer.FONT_HEIGHT + 1) && mouseY <= (this.getY() + BORDER + (mc.fontRenderer.FONT_HEIGHT) + 1 + offsetY - this.scroll); + // draw bg behind gear + RenderUtil.drawRect(this.getX() + BORDER + TEXT_GAP + this.getW() - BORDER - SCROLL_WIDTH - BORDER - 12, this.getY() + offsetY + BORDER + TEXT_GAP - this.scroll, this.getX() + BORDER + TEXT_GAP + this.getW() - BORDER - SCROLL_WIDTH - BORDER - 2, this.getY() + offsetY + BORDER + TEXT_GAP + mc.fontRenderer.FONT_HEIGHT - this.scroll, 0x45202020); + // draw gear + this.gearTexture.bind(); + this.gearTexture.render(this.getX() + BORDER + TEXT_GAP + this.getW() - BORDER - SCROLL_WIDTH - BORDER - 11, this.getY() + offsetY + BORDER + TEXT_GAP - this.scroll, 8, 8); + if (insideModule && isHoveringOptions) { // draw options line hover gradient + RenderUtil.drawGradientRect(this.getX() + BORDER + TEXT_GAP + this.getW() - BORDER - SCROLL_WIDTH - BORDER - 12, this.getY() + offsetY + BORDER + TEXT_GAP - this.scroll, this.getX() + BORDER + TEXT_GAP + this.getW() - BORDER - SCROLL_WIDTH - BORDER - 2, this.getY() + offsetY + BORDER + TEXT_GAP + mc.fontRenderer.FONT_HEIGHT - this.scroll, 0x50909090, 0x00101010); + } } - - final boolean insideModule = mouseX >= (this.getX() + BORDER) && mouseX <= (this.getX() + this.getW() - BORDER - SCROLL_WIDTH) && mouseY >= (this.getY() + BORDER + mc.fontRenderer.FONT_HEIGHT + 1 + offsetY - this.scroll - mc.fontRenderer.FONT_HEIGHT + 1) && mouseY <= (this.getY() + BORDER + (mc.fontRenderer.FONT_HEIGHT) + 1 + offsetY - this.scroll); - if (insideModule) { + if (insideModule) { // draw hover gradient RenderUtil.drawGradientRect(this.getX() + BORDER + TEXT_GAP, this.getY() + offsetY + BORDER + TEXT_GAP - this.scroll, this.getX() + BORDER + TEXT_GAP + this.getW() - BORDER - SCROLL_WIDTH - BORDER - 2, this.getY() + offsetY + BORDER + TEXT_GAP + mc.fontRenderer.FONT_HEIGHT - this.scroll, 0x30909090, 0x00101010); } + + // draw module name mc.fontRenderer.drawStringWithShadow(module.getDisplayName(), this.getX() + BORDER + TEXT_GAP + 1, this.getY() + offsetY + BORDER + TEXT_GAP - this.scroll, module.isEnabled() ? 0xFFC255FF : 0xFF7A6E80); + offsetY += mc.fontRenderer.FONT_HEIGHT + TEXT_GAP; } } @@ -230,11 +243,17 @@ public final class ModuleListComponent extends ResizableHudComponent { } else { int offsetY = BORDER; for (Module module : Seppuku.INSTANCE.getModuleManager().getModuleList(this.type)) { - final boolean insideComponent = mouseX >= (this.getX() + BORDER) && mouseX <= (this.getX() + this.getW() - BORDER - SCROLL_WIDTH) && mouseY >= (this.getY() + BORDER + mc.fontRenderer.FONT_HEIGHT + 1 + offsetY - this.scroll) && mouseY <= (this.getY() + BORDER + (mc.fontRenderer.FONT_HEIGHT * 2) + 1 + offsetY - this.scroll); + final boolean insideComponent = mouseX >= (this.getX() + BORDER) && mouseX <= (this.getX() + this.getW() - BORDER - SCROLL_WIDTH - 1) && mouseY >= (this.getY() + BORDER + mc.fontRenderer.FONT_HEIGHT + 1 + offsetY - this.scroll) && mouseY <= (this.getY() + BORDER + (mc.fontRenderer.FONT_HEIGHT * 2) + 1 + offsetY - this.scroll); if (insideComponent) { switch (button) { case 0: - module.toggle(); + if (mouseX >= (this.getX() + this.getW() - BORDER - SCROLL_WIDTH - 12) && mouseX <= (this.getX() + this.getW() - BORDER - SCROLL_WIDTH - 1)) { + this.currentSettings = new ModuleSettingsComponent(module, this); + this.setOldScroll(this.getScroll()); + this.setScroll(0); + } else { + module.toggle(); + } this.setDragging(false); break; case 1: diff --git a/src/main/resources/assets/seppukumod/textures/gear_wheel_modulelist.png b/src/main/resources/assets/seppukumod/textures/gear_wheel_modulelist.png new file mode 100644 index 0000000000000000000000000000000000000000..a2673f25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