diff --git a/src/main/java/me/kawaiizenbo/moonlight/Moonlight.java b/src/main/java/me/kawaiizenbo/moonlight/Moonlight.java index 20ac472..87ed9cd 100644 --- a/src/main/java/me/kawaiizenbo/moonlight/Moonlight.java +++ b/src/main/java/me/kawaiizenbo/moonlight/Moonlight.java @@ -13,6 +13,8 @@ public class Moonlight implements ModInitializer public static final Logger LOGGER = LoggerFactory.getLogger("Moonlight"); public static final String clientTag = ColorUtils.aqua + "Moonlight Meadows"; public static final String versionTag = ColorUtils.magenta + "v0.dev"; + public static int uiColorA = 0xFF55FFFF; + public static int uiColor = 0x55FFFF; @Override public void onInitialize() diff --git a/src/main/java/me/kawaiizenbo/moonlight/module/Category.java b/src/main/java/me/kawaiizenbo/moonlight/module/Category.java index 6e6ec7f..8ef135e 100644 --- a/src/main/java/me/kawaiizenbo/moonlight/module/Category.java +++ b/src/main/java/me/kawaiizenbo/moonlight/module/Category.java @@ -2,17 +2,19 @@ package me.kawaiizenbo.moonlight.module; public enum Category { - COMBAT("Combat"), - MOVEMENT("Movement"), - RENDER("Render"), - WORLD("World"), - PLAYER("Player"), - CHAT("Chat"); + COMBAT("Combat", 0xFFFF5555), + MOVEMENT("Movement", 0xFFFF55FF), + RENDER("Render", 0xFF5555FF), + WORLD("World", 0xFF55FF55), + PLAYER("Player", 0xFFFFFFFF), + CHAT("Chat", 0xFFFFFF55); public String name; + public int color; - Category(String name) + Category(String name, int color) { this.name = name; + this.color = color; } } diff --git a/src/main/java/me/kawaiizenbo/moonlight/module/Module_.java b/src/main/java/me/kawaiizenbo/moonlight/module/Module_.java index 5645422..04b1340 100644 --- a/src/main/java/me/kawaiizenbo/moonlight/module/Module_.java +++ b/src/main/java/me/kawaiizenbo/moonlight/module/Module_.java @@ -27,6 +27,7 @@ public abstract class Module_ this.description = description; this.category = category; settings = new ArrayList<>(); + settings.add(showInModulesList); } public void onEnable() { ModulesListOverlay.INSTANCE.update(); } diff --git a/src/main/java/me/kawaiizenbo/moonlight/module/modules/HUDModule.java b/src/main/java/me/kawaiizenbo/moonlight/module/modules/HUDModule.java index 3ee192b..709ce70 100644 --- a/src/main/java/me/kawaiizenbo/moonlight/module/modules/HUDModule.java +++ b/src/main/java/me/kawaiizenbo/moonlight/module/modules/HUDModule.java @@ -1,5 +1,6 @@ package me.kawaiizenbo.moonlight.module.modules; +import me.kawaiizenbo.moonlight.Moonlight; import me.kawaiizenbo.moonlight.module.Category; import me.kawaiizenbo.moonlight.module.Module_; import me.kawaiizenbo.moonlight.module.settings.BooleanSetting; @@ -33,12 +34,18 @@ public class HUDModule extends Module_ { super.onEnable(); HUDOverlay.INSTANCE.showClientTag = clientTag.value; - HUDOverlay.INSTANCE.hudColor = + Moonlight.uiColorA = ColorUtils.rgbaToInt( (int)r.value, (int)g.value, (int)b.value, 255 ); + Moonlight.uiColor = + ColorUtils.rgbToInt( + (int)r.value, + (int)g.value, + (int)b.value + ); } } diff --git a/src/main/java/me/kawaiizenbo/moonlight/ui/HUDOverlay.java b/src/main/java/me/kawaiizenbo/moonlight/ui/HUDOverlay.java index b511c38..683a5d8 100644 --- a/src/main/java/me/kawaiizenbo/moonlight/ui/HUDOverlay.java +++ b/src/main/java/me/kawaiizenbo/moonlight/ui/HUDOverlay.java @@ -29,14 +29,16 @@ public class HUDOverlay if (mc.options.debugEnabled) return; // draw stats - drawContext.drawTextWithShadow(textRenderer, "FPS: " + ColorUtils.gray + mc.fpsDebugString.split(" ")[0], 2, 2, hudColor); - drawContext.drawTextWithShadow(textRenderer, "Ping: " + ColorUtils.gray + (mc.getNetworkHandler().getPlayerListEntry(mc.player.getUuid()) == null ? 0 : mc.getNetworkHandler().getPlayerListEntry(mc.player.getUuid()).getLatency()), 2, 12, hudColor); - drawContext.drawTextWithShadow(textRenderer, "Meters/s: " + ColorUtils.gray + MathUtils.round(moveSpeed(), 2), 2, scaledHeight - 20, hudColor); + drawContext.drawTextWithShadow(textRenderer, "FPS: " + ColorUtils.gray + mc.fpsDebugString.split(" ")[0], 2, 2, Moonlight.uiColorA); + drawContext.drawTextWithShadow(textRenderer, "Ping: " + ColorUtils.gray + (mc.getNetworkHandler().getPlayerListEntry(mc.player.getUuid()) == null ? 0 : mc.getNetworkHandler().getPlayerListEntry(mc.player.getUuid()).getLatency()), 2, 12, Moonlight.uiColorA); + drawContext.drawTextWithShadow(textRenderer, "Meters/s: " + ColorUtils.gray + MathUtils.round(moveSpeed(), 2), 2, scaledHeight - 20, Moonlight.uiColorA); // draw coordinates - drawContext.drawTextWithShadow(textRenderer, "X: " + ColorUtils.gray + MathUtils.round(mc.player.getX(), 1) + - ColorUtils.reset + " Y: " + ColorUtils.gray + MathUtils.round(mc.player.getY(), 1) + - ColorUtils.reset + " Z: " + ColorUtils.gray + MathUtils.round(mc.player.getZ(), 1), 2, scaledHeight - 10, hudColor); + drawContext.drawTextWithShadow(textRenderer, + "X: " + ColorUtils.gray + MathUtils.round(mc.player.getX(), 1) + ColorUtils.reset + + " Y: " + ColorUtils.gray + MathUtils.round(mc.player.getY(), 1) + ColorUtils.reset + + " Z: " + ColorUtils.gray + MathUtils.round(mc.player.getZ(), 1), 2, scaledHeight - 10, Moonlight.uiColorA + ); // draw client tag (if enabled) if (showClientTag) diff --git a/src/main/java/me/kawaiizenbo/moonlight/ui/ModulesListOverlay.java b/src/main/java/me/kawaiizenbo/moonlight/ui/ModulesListOverlay.java index c52dc4a..7410379 100644 --- a/src/main/java/me/kawaiizenbo/moonlight/ui/ModulesListOverlay.java +++ b/src/main/java/me/kawaiizenbo/moonlight/ui/ModulesListOverlay.java @@ -3,6 +3,7 @@ package me.kawaiizenbo.moonlight.ui; import java.util.ArrayList; import java.util.Comparator; +import me.kawaiizenbo.moonlight.Moonlight; import me.kawaiizenbo.moonlight.module.ModuleManager; import me.kawaiizenbo.moonlight.module.Module_; import net.minecraft.client.MinecraftClient; @@ -28,7 +29,7 @@ public class ModulesListOverlay if (!m.showInModulesList.value) continue; int nameWidth = textRenderer.getWidth(m.name); drawContext.fill(scaledWidth - nameWidth - 8, yOffset, scaledWidth, yOffset+12, 0x55222222); - drawContext.fill(scaledWidth - 2, yOffset, scaledWidth, yOffset+12, HUDOverlay.INSTANCE.hudColor); + drawContext.fill(scaledWidth - 2, yOffset, scaledWidth, yOffset+12, Moonlight.uiColorA); drawContext.drawText(textRenderer, m.name, scaledWidth - nameWidth - 4, yOffset + 2, 0xFFFFFFFF, false); yOffset += 12; } diff --git a/src/main/java/me/kawaiizenbo/moonlight/ui/clickgui/CategoryPane.java b/src/main/java/me/kawaiizenbo/moonlight/ui/clickgui/CategoryPane.java new file mode 100644 index 0000000..524a16c --- /dev/null +++ b/src/main/java/me/kawaiizenbo/moonlight/ui/clickgui/CategoryPane.java @@ -0,0 +1,68 @@ +package me.kawaiizenbo.moonlight.ui.clickgui; + +import java.util.ArrayList; + +import me.kawaiizenbo.moonlight.module.Category; +import me.kawaiizenbo.moonlight.module.ModuleManager; +import me.kawaiizenbo.moonlight.module.Module_; +import net.minecraft.client.MinecraftClient; +import net.minecraft.client.font.TextRenderer; +import net.minecraft.client.gui.DrawContext; + +public class CategoryPane +{ + private MinecraftClient mc = MinecraftClient.getInstance(); + private TextRenderer textRenderer = mc.textRenderer; + + public Category category; + public int x; + public int y; + private int height; + private int width = 96; + private boolean collapsed = false; + private ArrayList moduleButtons; + + public CategoryPane(Category category, int initialX, int initialY) + { + this.category = category; + this.x = initialX; + this.y = initialY; + int buttonYOffset = y+16; + moduleButtons = new ArrayList(); + for (Module_ m : ModuleManager.INSTANCE.getModulesByCategory(category)) + { + moduleButtons.add(new ModuleButton(m, x+2, buttonYOffset)); + buttonYOffset += 12; + } + if (moduleButtons.size() == 0) collapsed = true; + height = (moduleButtons.size()*12) + 18; + } + + public void render(DrawContext drawContext, int mouseX, int mouseY, float delta) + { + drawContext.fill(x, y, x+width, collapsed ? y+16 : y+height, category.color); + drawContext.fill(x+2, y+2, x+(width-2), y+14, hovered(mouseX, mouseY) ? 0xFF333333 : 0xFF222222); + drawContext.drawText(textRenderer, category.name, x+4, y+4, 0xFFFFFFFF, false); + if (!collapsed) + { + for (ModuleButton m : moduleButtons) + { + m.render(drawContext, mouseX, mouseY); + } + } + } + + public boolean hovered(int mouseX, int mouseY) + { + return mouseX >= x && mouseX <= x + width && mouseY >= y && mouseY <= y + height; + } + + public void mouseClicked(int mouseX, int mouseY, int button) + { + for (ModuleButton moduleButton : moduleButtons) + { + if (moduleButton.mouseClicked(mouseX, mouseY, button)) return; + } + if (hovered(mouseX, mouseY)) collapsed = !collapsed; + } +} diff --git a/src/main/java/me/kawaiizenbo/moonlight/ui/clickgui/ClickGUIScreen.java b/src/main/java/me/kawaiizenbo/moonlight/ui/clickgui/ClickGUIScreen.java index 275580c..c1d4847 100644 --- a/src/main/java/me/kawaiizenbo/moonlight/ui/clickgui/ClickGUIScreen.java +++ b/src/main/java/me/kawaiizenbo/moonlight/ui/clickgui/ClickGUIScreen.java @@ -3,56 +3,49 @@ package me.kawaiizenbo.moonlight.ui.clickgui; import java.util.ArrayList; import me.kawaiizenbo.moonlight.module.Category; -import me.kawaiizenbo.moonlight.module.ModuleManager; -import me.kawaiizenbo.moonlight.module.Module_; import net.minecraft.client.gui.DrawContext; import net.minecraft.client.gui.screen.Screen; import net.minecraft.text.Text; -public class ClickGUIScreen extends Screen +public class ClickGUIScreen extends Screen { - public static ClickGUIScreen INSTANCE = new ClickGUIScreen(); - public static ArrayList moduleButtons; + public static ClickGUIScreen INSTANCE = new ClickGUIScreen(); + public static ArrayList categoryPanes; public ClickGUIScreen() { super(Text.literal("ClickGUI")); - moduleButtons = new ArrayList<>(); - int yOffset; + int xOffset = 4; + int yOffset = 4; + categoryPanes = new ArrayList(); for (Category category : Category.values()) { - yOffset = 25; - for (Module_ module : ModuleManager.INSTANCE.getModulesByCategory(category)) + if (xOffset > 400) { - moduleButtons.add(new ModuleButton(module, 9+(module.category.ordinal()*70), yOffset)); - yOffset += 14; + xOffset = 4; + yOffset = 128; } + categoryPanes.add(new CategoryPane(category, xOffset, yOffset)); + xOffset += 100; } - } @Override public void render(DrawContext drawContext, int mouseX, int mouseY, float delta) { this.renderBackground(drawContext); - int categoryLabelXOffset = 10; - for (Category category : Category.values()) + for (CategoryPane category : categoryPanes) { - drawContext.drawText(textRenderer, category.name, categoryLabelXOffset, 10, 0xFFFFFF, false); - categoryLabelXOffset += 70; - } - for (ModuleButton moduleButton : moduleButtons) - { - moduleButton.render(drawContext, mouseX, mouseY); + category.render(drawContext, mouseX, mouseY, delta); } } @Override public boolean mouseClicked(double mouseX, double mouseY, int button) { - for (ModuleButton modButton : moduleButtons) + for (CategoryPane category : categoryPanes) { - modButton.mouseClicked((int) mouseX, (int) mouseY, button); + category.mouseClicked((int) mouseX, (int) mouseY, button); } return super.mouseClicked(mouseX, mouseY, button); } diff --git a/src/main/java/me/kawaiizenbo/moonlight/ui/clickgui/ModuleButton.java b/src/main/java/me/kawaiizenbo/moonlight/ui/clickgui/ModuleButton.java index bb147d3..a979cb5 100644 --- a/src/main/java/me/kawaiizenbo/moonlight/ui/clickgui/ModuleButton.java +++ b/src/main/java/me/kawaiizenbo/moonlight/ui/clickgui/ModuleButton.java @@ -1,5 +1,6 @@ package me.kawaiizenbo.moonlight.ui.clickgui; +import me.kawaiizenbo.moonlight.Moonlight; import me.kawaiizenbo.moonlight.module.Module_; import net.minecraft.client.MinecraftClient; import net.minecraft.client.font.TextRenderer; @@ -10,21 +11,21 @@ public class ModuleButton public Module_ module; public int x, y, width, height = 0; private MinecraftClient mc = MinecraftClient.getInstance(); + private TextRenderer textRenderer = mc.textRenderer; - public ModuleButton(Module_ module, int x, int y) + public ModuleButton(Module_ module, int initialX, int initialY) { this.module = module; - this.x = x; - this.y = y; - this.width = 70; - this.height = 14; + this.x = initialX; + this.y = initialY; + this.width = 92; + this.height = 12; } public void render(DrawContext drawContext, int mouseX, int mouseY) { - TextRenderer textRenderer = mc.textRenderer; drawContext.fill(x, y, x + width, y + height, hovered(mouseX, mouseY) ? 0xFF333333 : 0xFF222222); - drawContext.drawText(textRenderer, module.name, x+3, y+3, module.enabled ? 0x55FFFF : 0xFFFFFF, false); + drawContext.drawText(textRenderer, module.name, x+2, y+2, module.enabled ? Moonlight.uiColor : 0xFFFFFF, false); } public boolean hovered(int mouseX, int mouseY) @@ -32,7 +33,7 @@ public class ModuleButton return mouseX >= x && mouseX <= x + width && mouseY >= y && mouseY <= y + height; } - public void mouseClicked(int mouseX, int mouseY, int button) + public boolean mouseClicked(int mouseX, int mouseY, int button) { if (hovered(mouseX, mouseY)) { @@ -44,6 +45,8 @@ public class ModuleButton { MinecraftClient.getInstance().setScreen(new SettingsScreen(module)); } + return true; } + return false; } } diff --git a/src/main/java/me/kawaiizenbo/moonlight/ui/clickgui/SettingsScreen.java b/src/main/java/me/kawaiizenbo/moonlight/ui/clickgui/SettingsScreen.java index 3d8ab21..b4ecd4a 100644 --- a/src/main/java/me/kawaiizenbo/moonlight/ui/clickgui/SettingsScreen.java +++ b/src/main/java/me/kawaiizenbo/moonlight/ui/clickgui/SettingsScreen.java @@ -34,7 +34,6 @@ public class SettingsScreen extends Screen setting.render(drawContext, (width/2)-96, yOffset, mouseX, mouseY); yOffset += setting.height + 1; } - // add keybind setting here eventually } @Override diff --git a/src/main/java/me/kawaiizenbo/moonlight/util/ColorUtils.java b/src/main/java/me/kawaiizenbo/moonlight/util/ColorUtils.java index 8b966b0..03a0b4c 100644 --- a/src/main/java/me/kawaiizenbo/moonlight/util/ColorUtils.java +++ b/src/main/java/me/kawaiizenbo/moonlight/util/ColorUtils.java @@ -32,4 +32,9 @@ public class ColorUtils { return ((a&0x0ff)<<24)|((r&0x0ff)<<16)|((g&0x0ff)<<8)|(b&0x0ff); } + + public static int rgbToInt(int r, int g, int b) + { + return ((r&0x0ff)<<16)|((g&0x0ff)<<8)|(b&0x0ff); + } } diff --git a/src/main/resources/assets/moonlight/chat.png b/src/main/resources/assets/moonlight/chat.png new file mode 100644 index 0000000..87aadee Binary files /dev/null and b/src/main/resources/assets/moonlight/chat.png differ diff --git a/src/main/resources/assets/moonlight/combat.png b/src/main/resources/assets/moonlight/combat.png new file mode 100644 index 0000000..82fee53 Binary files /dev/null and b/src/main/resources/assets/moonlight/combat.png differ diff --git a/src/main/resources/assets/moonlight/movement.png b/src/main/resources/assets/moonlight/movement.png new file mode 100644 index 0000000..d58ea80 Binary files /dev/null and b/src/main/resources/assets/moonlight/movement.png differ diff --git a/src/main/resources/assets/moonlight/player.png b/src/main/resources/assets/moonlight/player.png new file mode 100644 index 0000000..4cabe2e Binary files /dev/null and b/src/main/resources/assets/moonlight/player.png differ diff --git a/src/main/resources/assets/moonlight/render.png b/src/main/resources/assets/moonlight/render.png new file mode 100644 index 0000000..08257ab Binary files /dev/null and b/src/main/resources/assets/moonlight/render.png differ diff --git a/src/main/resources/assets/moonlight/world.png b/src/main/resources/assets/moonlight/world.png new file mode 100644 index 0000000..e1bef72 Binary files /dev/null and b/src/main/resources/assets/moonlight/world.png differ