many major changes, see store for details

- bump version to v0.4.0
- add theme support
- add high contrast and light themes
- remove settingcommand (broken)
- add icon variants for certain themes
- remove text shadows from interfaces other than the hud
This commit is contained in:
kawaiizenbo 2024-09-09 18:04:47 -07:00
parent 854ce7201c
commit bd5573c48f
38 changed files with 223 additions and 184 deletions

View file

@ -1,5 +1,6 @@
package me.kawaiizenbo.moonlight.ui;
import me.kawaiizenbo.moonlight.Moonlight;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.font.TextRenderer;
import net.minecraft.client.gui.DrawContext;
@ -10,14 +11,13 @@ public class SetScreenButton
{
String text;
Screen screen;
int x, y, color, width;
int x, y, width;
public SetScreenButton(String text, int x, int y, int color, Screen screen)
public SetScreenButton(String text, int x, int y, Screen screen)
{
this.text = text;
this.x = x;
this.y = y;
this.color = color;
this.screen = screen;
}
@ -26,8 +26,8 @@ public class SetScreenButton
this.x = x;
this.y = y;
width = textRenderer.getWidth(text);
drawContext.fill(x-1, y-1, x + width + 1, y + 10, hovered(mouseX, mouseY) ? 0x55FFFFFF : 0);
drawContext.drawText(textRenderer, Text.literal(text), x, y, color, true);
drawContext.fill(x-1, y-1, x + width + 1, y + 10, hovered(mouseX, mouseY) ? 0x22222222 : 0);
drawContext.drawText(textRenderer, Text.literal(text), x, y, Moonlight.THEME.headerText.getRGB(), false);
}
public boolean hovered(int mouseX, int mouseY)

View file

@ -2,8 +2,10 @@ package me.kawaiizenbo.moonlight.ui.clickgui;
import java.util.ArrayList;
import me.kawaiizenbo.moonlight.Moonlight;
import me.kawaiizenbo.moonlight.module.Category;
import me.kawaiizenbo.moonlight.module.ModuleManager;
import me.kawaiizenbo.moonlight.util.DrawUtils;
import me.kawaiizenbo.moonlight.module.Module;
import net.minecraft.client.font.TextRenderer;
import net.minecraft.client.gui.DrawContext;
@ -26,7 +28,7 @@ public class CategoryPane
this.y = initialY;
this.collapsed = collapsed;
moduleButtons = new ArrayList<ModuleButton>();
icon = Identifier.of("moonlight", category.name.toLowerCase());
icon = DrawUtils.getThemedGUIIcon(category.name.toLowerCase());
for (Module m : ModuleManager.INSTANCE.getModulesByCategory(category))
{
moduleButtons.add(new ModuleButton(m));
@ -42,10 +44,10 @@ public class CategoryPane
x = mouseX - startX;
y = mouseY - startY;
}
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.fill(x, y, x+width, collapsed ? y+16 : y+height, Moonlight.THEME.themedWindowBorders ? Moonlight.THEME.border.getRGB() : category.color);
//drawContext.fill(x+2, y+2, x+(width-2), y+14, hovered(mouseX, mouseY) ? Moonlight.THEME.hover.getRGB() : Moonlight.THEME.background.getRGB());
drawContext.drawGuiTexture(icon, x+2, y+2, 12, 12);
drawContext.drawText(textRenderer, category.name, x+16, y+4, 0xFFFFFFFF, false);
drawContext.drawText(textRenderer, category.name, x+16, y+4, Moonlight.THEME.headerText.getRGB(), false);
if (!collapsed)
{
int buttonYOffset = y+16;

View file

@ -5,6 +5,7 @@ import java.util.Map;
import me.kawaiizenbo.moonlight.Moonlight;
import me.kawaiizenbo.moonlight.module.Category;
import me.kawaiizenbo.moonlight.theme.Theme;
import me.kawaiizenbo.moonlight.util.MathUtils;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.gui.screen.Screen;
@ -35,6 +36,9 @@ public class ClickGUIScreen extends Screen
public void render(DrawContext drawContext, int mouseX, int mouseY, float delta)
{
this.renderBackground(drawContext, mouseX, mouseY, delta);
drawContext.fill(width-80, height-16, width, height, Moonlight.THEME.border.getRGB());
drawContext.fill(width-78, height-14, width-2, height-2, (mouseX > width-80 && mouseY > height-16) ? Moonlight.THEME.hover.getRGB() : Moonlight.THEME.background.getRGB());
drawContext.drawText(textRenderer, "Change Theme", width-75, height-12, Moonlight.THEME.text.getRGB(), false);
for (CategoryPane category : categoryPanes)
{
category.render(drawContext, mouseX, mouseY, delta, textRenderer);
@ -48,6 +52,12 @@ public class ClickGUIScreen extends Screen
{
category.mouseClicked((int) mouseX, (int) mouseY, button);
}
if (mouseX > width-80 && mouseY > height-16)
{
if (Moonlight.THEME_IDX >= Theme.THEME_LIST.length-1) Moonlight.THEME_IDX = 0;
else Moonlight.THEME_IDX++;
Moonlight.THEME = Theme.THEME_LIST[Moonlight.THEME_IDX];
}
return super.mouseClicked(mouseX, mouseY, button);
}

View file

@ -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;
@ -21,8 +22,8 @@ public class ModuleButton
{
this.x = x;
this.y = y;
drawContext.fill(x, y, x + width, y + height, hovered(mouseX, mouseY) ? 0xFF333333 : 0xFF222222);
drawContext.drawText(textRenderer, module.name, x+2, y+2, module.enabled ? 0x55FFFF : 0xFFFFFF, false);
drawContext.fill(x, y, x + width, y + height, hovered(mouseX, mouseY) ? Moonlight.THEME.hover.getRGB() : Moonlight.THEME.background.getRGB());
drawContext.drawText(textRenderer, module.name, x+2, y+2, module.enabled ? Moonlight.THEME.accent.getRGB() : Moonlight.THEME.text.getRGB(), false);
}
public boolean hovered(int mouseX, int mouseY)

View file

@ -1,5 +1,6 @@
package me.kawaiizenbo.moonlight.ui.clickgui;
import me.kawaiizenbo.moonlight.Moonlight;
import me.kawaiizenbo.moonlight.module.Module;
import me.kawaiizenbo.moonlight.module.settings.Setting;
import me.kawaiizenbo.moonlight.ui.SetScreenButton;
@ -21,8 +22,8 @@ public class SettingsScreen extends Screen
public SettingsScreen(Module module)
{
super(Text.literal("Settings"));
backButton = new SetScreenButton(ColorUtils.underline + "< Back", x+4, y+4, 0xFFFFFF, ClickGUIScreen.INSTANCE);
editButton = new SetScreenButton(ColorUtils.underline + "Edit", x+windowWidth-22, y+4, 0xFFFFFF, HUDEditorScreen.INSTANCE);
backButton = new SetScreenButton(ColorUtils.underline + "< Back", x+4, y+4, ClickGUIScreen.INSTANCE);
editButton = new SetScreenButton(ColorUtils.underline + "Edit", x+windowWidth-22, y+4, HUDEditorScreen.INSTANCE);
this.module = module;
}
@ -37,11 +38,12 @@ public class SettingsScreen extends Screen
x = mouseX - startX;
y = mouseY - startY;
}
drawContext.fill(x, y, x+windowWidth, y+windowHeight, 0xFF222222);
drawContext.fill(x, y, x+windowWidth, y+16, module.category.color);
drawContext.fill(x+2, y+2, x+(windowWidth-2), y+14, 0xFF222222);
drawContext.drawCenteredTextWithShadow(textRenderer, module.name, x+(windowWidth/2), y+4, 0xFFFFFF);
drawContext.drawText(textRenderer, module.description, x+8, y+24, 0xFFFFFF, true);
drawContext.fill(x, y, x+windowWidth, y+windowHeight, Moonlight.THEME.themedWindowBorders ? Moonlight.THEME.border.getRGB() : module.category.color);
drawContext.fill(x+2, y+2, x+windowWidth-2, y+windowHeight-2, Moonlight.THEME.background.getRGB());
drawContext.fill(x, y, x+windowWidth, y+16, Moonlight.THEME.themedWindowBorders ? Moonlight.THEME.border.getRGB() : module.category.color);
//drawContext.fill(x+2, y+2, x+(windowWidth-2), y+14, Moonlight.THEME.background.getRGB());
drawContext.drawText(textRenderer, module.name, x+((windowWidth/2)-(textRenderer.getWidth(module.name)/2)), y+4, Moonlight.THEME.headerText.getRGB(), false);
drawContext.drawText(textRenderer, module.description, x+8, y+24, Moonlight.THEME.text.getRGB(), false);
backButton.render(drawContext, textRenderer, mouseX, mouseY, x+4, y+4);
if (module.showEditButton) editButton.render(drawContext, textRenderer, mouseX, mouseY, x+windowWidth-22, y+4);
int yOffset = y+40;

View file

@ -2,6 +2,7 @@ package me.kawaiizenbo.moonlight.ui.hud;
import java.util.ArrayList;
import me.kawaiizenbo.moonlight.Moonlight;
import me.kawaiizenbo.moonlight.module.settings.Setting;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.font.TextRenderer;
@ -35,7 +36,7 @@ public abstract class HUDModule
x = mouseX - startX;
y = mouseY - startY;
}
drawContext.fill(x-1, y-1, x+width+1, y+height+1, enabled ? 0xFF55FFFF : 0xFF555555);
drawContext.fill(x-1, y-1, x+width+1, y+height+1, enabled ? Moonlight.THEME.accent.getRGB() : 0xFF555555);
drawContext.fill(x, y, x+width, y+height, 0xFF222222);
}
}

View file

@ -1,5 +1,6 @@
package me.kawaiizenbo.moonlight.ui.hud.editor;
import me.kawaiizenbo.moonlight.Moonlight;
import me.kawaiizenbo.moonlight.ui.hud.HUDModule;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.font.TextRenderer;
@ -22,8 +23,8 @@ public class HUDModuleButton
{
this.x = x;
this.y = y;
drawContext.fill(x, y, x + width, y + height, hovered(mouseX, mouseY) ? 0xFF333333 : 0xFF222222);
drawContext.drawText(textRenderer, module.name, x+2, y+2, module.enabled ? 0x55FFFF : 0xFFFFFF, false);
drawContext.fill(x, y, x + width, y + height, hovered(mouseX, mouseY) ? Moonlight.THEME.hover.getRGB() : Moonlight.THEME.background.getRGB());
drawContext.drawText(textRenderer, module.name, x+2, y+2, module.enabled ? Moonlight.THEME.accent.getRGB() : Moonlight.THEME.text.getRGB(), false);
if (!module.settings.isEmpty()) drawContext.drawGuiTexture(Identifier.of("moonlight", "settings"), x+width-12, y, 12, 12);
}

View file

@ -2,11 +2,12 @@ package me.kawaiizenbo.moonlight.ui.hud.editor;
import java.util.ArrayList;
import me.kawaiizenbo.moonlight.Moonlight;
import me.kawaiizenbo.moonlight.ui.hud.HUDModule;
import me.kawaiizenbo.moonlight.ui.hud.HUDModuleManager;
import me.kawaiizenbo.moonlight.util.DrawUtils;
import net.minecraft.client.font.TextRenderer;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.util.Identifier;
public class HUDModuleList
{
@ -37,10 +38,10 @@ public class HUDModuleList
x = mouseX - startX;
y = mouseY - startY;
}
drawContext.fill(x, y, x+width, collapsed ? y+16 : y+height, 0xFF55FFFF);
drawContext.fill(x+2, y+2, x+(width-2), y+14, hovered(mouseX, mouseY) ? 0xFF333333 : 0xFF222222);
drawContext.drawGuiTexture(Identifier.of("moonlight", "hud"), x+2, y+2, 12, 12);
drawContext.drawText(textRenderer, "HUD Modules", x+16, y+4, 0xFFFFFFFF, false);
drawContext.fill(x, y, x+width, collapsed ? y+16 : y+height, Moonlight.THEME.themedWindowBorders ? Moonlight.THEME.border.getRGB() : Moonlight.THEME.accent.getRGB());
//drawContext.fill(x+2, y+2, x+(width-2), y+14, hovered(mouseX, mouseY) ? Moonlight.THEME.hover.getRGB() : Moonlight.THEME.background.getRGB());
drawContext.drawGuiTexture(DrawUtils.getThemedGUIIcon("hud"), x+2, y+2, 12, 12);
drawContext.drawText(textRenderer, "HUD Modules", x+16, y+4, Moonlight.THEME.headerText.getRGB(), false);
if (!collapsed)
{
int buttonYOffset = y+16;

View file

@ -1,5 +1,6 @@
package me.kawaiizenbo.moonlight.ui.hud.editor;
import me.kawaiizenbo.moonlight.Moonlight;
import me.kawaiizenbo.moonlight.module.settings.Setting;
import me.kawaiizenbo.moonlight.ui.SetScreenButton;
import me.kawaiizenbo.moonlight.ui.hud.HUDModule;
@ -20,7 +21,7 @@ public class HUDModuleSettingsScreen extends Screen
public HUDModuleSettingsScreen(HUDModule module)
{
super(Text.literal("Settings"));
backButton = new SetScreenButton(ColorUtils.underline + "< Back", x+4, y+4, 0xFFFFFF, HUDEditorScreen.INSTANCE);
backButton = new SetScreenButton(ColorUtils.underline + "< Back", x+4, y+4, HUDEditorScreen.INSTANCE);
this.module = module;
}
@ -35,10 +36,11 @@ public class HUDModuleSettingsScreen extends Screen
x = mouseX - startX;
y = mouseY - startY;
}
drawContext.fill(x, y, x+windowWidth, y+windowHeight, 0xFF222222);
drawContext.fill(x, y, x+windowWidth, y+16, 0xFF55FFFF);
drawContext.fill(x+2, y+2, x+(windowWidth-2), y+14, 0xFF222222);
drawContext.drawCenteredTextWithShadow(textRenderer, module.name, x+(windowWidth/2), y+4, 0xFFFFFF);
drawContext.fill(x, y, x+windowWidth, y+windowHeight, Moonlight.THEME.themedWindowBorders ? Moonlight.THEME.border.getRGB() : Moonlight.THEME.accent.getRGB());
drawContext.fill(x+2, y+2, x+windowWidth-2, y+windowHeight-2, Moonlight.THEME.background.getRGB());
drawContext.fill(x, y, x+windowWidth, y+16, Moonlight.THEME.themedWindowBorders ? Moonlight.THEME.border.getRGB() : Moonlight.THEME.accent.getRGB());
//drawContext.fill(x+2, y+2, x+(windowWidth-2), y+14, Moonlight.THEME.background.getRGB());
drawContext.drawText(textRenderer, module.name, x+((windowWidth/2)-(textRenderer.getWidth(module.name)/2)), y+4, Moonlight.THEME.headerText.getRGB(), false);
backButton.render(drawContext, textRenderer, mouseX, mouseY, x+4, y+4);
int yOffset = y+24;
for (Setting setting : module.settings)

View file

@ -1,13 +1,9 @@
package me.kawaiizenbo.moonlight.ui.hud.modules;
import me.kawaiizenbo.moonlight.ui.hud.HUDModule;
import me.kawaiizenbo.moonlight.util.ColorUtils;
import me.kawaiizenbo.moonlight.util.MathUtils;
import net.minecraft.client.font.TextRenderer;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.render.item.ItemRenderer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.math.Vec3d;
public class ArmorDisplay extends HUDModule
{

View file

@ -1,5 +1,6 @@
package me.kawaiizenbo.moonlight.ui.hud.modules;
import me.kawaiizenbo.moonlight.Moonlight;
import me.kawaiizenbo.moonlight.ui.hud.HUDModule;
import me.kawaiizenbo.moonlight.util.ColorUtils;
import net.minecraft.client.font.TextRenderer;
@ -22,7 +23,7 @@ public class Coordinates extends HUDModule
drawContext.drawTextWithShadow(mc.textRenderer,
"X: " + ColorUtils.gray + String.format("%.1f", mc.player.getX()) + ColorUtils.reset +
" Y: " + ColorUtils.gray + String.format("%.1f", mc.player.getY()) + ColorUtils.reset +
" Z: " + ColorUtils.gray + String.format("%.1f", mc.player.getZ()), x, y, 0xFF55FFFF
" Z: " + ColorUtils.gray + String.format("%.1f", mc.player.getZ()), x, y, Moonlight.THEME.hudAccent.getRGB()
);
}
}

View file

@ -1,5 +1,6 @@
package me.kawaiizenbo.moonlight.ui.hud.modules;
import me.kawaiizenbo.moonlight.Moonlight;
import me.kawaiizenbo.moonlight.ui.hud.HUDModule;
import me.kawaiizenbo.moonlight.util.ColorUtils;
import net.minecraft.client.font.TextRenderer;
@ -19,6 +20,6 @@ public class FPS extends HUDModule
public void render(DrawContext drawContext, int mouseX, int mouseY, TextRenderer textRenderer, boolean editMode, boolean enabled)
{
super.render(drawContext, mouseX, mouseY, textRenderer, editMode, enabled);
drawContext.drawTextWithShadow(mc.textRenderer, "FPS: " + ColorUtils.gray + mc.fpsDebugString.split(" ")[0], x, y, 0xFF55FFFF);
drawContext.drawTextWithShadow(mc.textRenderer, "FPS: " + ColorUtils.gray + mc.fpsDebugString.split(" ")[0], x, y, Moonlight.THEME.hudAccent.getRGB());
}
}

View file

@ -1,5 +1,6 @@
package me.kawaiizenbo.moonlight.ui.hud.modules;
import me.kawaiizenbo.moonlight.Moonlight;
import me.kawaiizenbo.moonlight.ui.hud.HUDModule;
import me.kawaiizenbo.moonlight.util.ColorUtils;
import me.kawaiizenbo.moonlight.util.MathUtils;
@ -21,7 +22,7 @@ public class MovementSpeed extends HUDModule
public void render(DrawContext drawContext, int mouseX, int mouseY, TextRenderer textRenderer, boolean editMode, boolean enabled)
{
super.render(drawContext, mouseX, mouseY, textRenderer, editMode, enabled);
drawContext.drawTextWithShadow(mc.textRenderer, "Meters/s: " + ColorUtils.gray + MathUtils.round(moveSpeed(), 2), x, y, 0xFF55FFFF);
drawContext.drawTextWithShadow(mc.textRenderer, "Meters/s: " + ColorUtils.gray + MathUtils.round(moveSpeed(), 2), x, y, Moonlight.THEME.hudAccent.getRGB());
}
private double moveSpeed()

View file

@ -1,5 +1,6 @@
package me.kawaiizenbo.moonlight.ui.hud.modules;
import me.kawaiizenbo.moonlight.Moonlight;
import me.kawaiizenbo.moonlight.ui.hud.HUDModule;
import me.kawaiizenbo.moonlight.util.ColorUtils;
import net.minecraft.client.font.TextRenderer;
@ -19,6 +20,6 @@ public class Ping extends HUDModule
public void render(DrawContext drawContext, int mouseX, int mouseY, TextRenderer textRenderer, boolean editMode, boolean enabled)
{
super.render(drawContext, mouseX, mouseY, textRenderer, editMode, enabled);
drawContext.drawTextWithShadow(mc.textRenderer, "Ping: " + ColorUtils.gray + (mc.getNetworkHandler().getPlayerListEntry(mc.player.getUuid()) == null ? 0 : mc.getNetworkHandler().getPlayerListEntry(mc.player.getUuid()).getLatency()), x, y, 0xFF55FFFF);
drawContext.drawTextWithShadow(mc.textRenderer, "Ping: " + ColorUtils.gray + (mc.getNetworkHandler().getPlayerListEntry(mc.player.getUuid()) == null ? 0 : mc.getNetworkHandler().getPlayerListEntry(mc.player.getUuid()).getLatency()), x, y, Moonlight.THEME.hudAccent.getRGB());
}
}

View file

@ -1,14 +1,10 @@
package me.kawaiizenbo.moonlight.ui.hud.modules;
import me.kawaiizenbo.moonlight.ui.hud.HUDModule;
import me.kawaiizenbo.moonlight.util.ColorUtils;
import me.kawaiizenbo.moonlight.util.MathUtils;
import net.minecraft.client.font.TextRenderer;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.render.item.ItemRenderer;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.util.math.Vec3d;
public class TotemCounter extends HUDModule
{