bare minimum function hud editor
This commit is contained in:
parent
9ab102a648
commit
31ecdd4f04
7 changed files with 154 additions and 3 deletions
|
@ -9,6 +9,7 @@ import me.kawaiizenbo.moonlight.module.ModuleManager;
|
|||
import me.kawaiizenbo.moonlight.module.modules.HUDEnabler;
|
||||
import me.kawaiizenbo.moonlight.ui.LegacyHUD;
|
||||
import me.kawaiizenbo.moonlight.ui.ModulesListOverlay;
|
||||
import me.kawaiizenbo.moonlight.ui.hud.HUDRenderer;
|
||||
import net.minecraft.client.gui.DrawContext;
|
||||
import net.minecraft.client.gui.hud.InGameHud;
|
||||
import net.minecraft.client.render.RenderTickCounter;
|
||||
|
@ -23,7 +24,7 @@ public class InGameHudMixin {
|
|||
if (hudModule.enabled)
|
||||
{
|
||||
if (hudModule.legacyHud.value) LegacyHUD.INSTANCE.render(drawContext, drawContext.getScaledWindowWidth(), drawContext.getScaledWindowHeight());
|
||||
// wip
|
||||
else HUDRenderer.INSTANCE.render(drawContext);
|
||||
}
|
||||
if (ModuleManager.INSTANCE.getModuleByName("ModulesList").enabled) ModulesListOverlay.INSTANCE.render(drawContext, drawContext.getScaledWindowWidth(), drawContext.getScaledWindowHeight());
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@ package me.kawaiizenbo.moonlight.ui.clickgui;
|
|||
import me.kawaiizenbo.moonlight.module.Module;
|
||||
import me.kawaiizenbo.moonlight.module.settings.Setting;
|
||||
import me.kawaiizenbo.moonlight.ui.SetScreenButton;
|
||||
import me.kawaiizenbo.moonlight.ui.hud.HUDEditorScreen;
|
||||
import me.kawaiizenbo.moonlight.ui.hud.editor.HUDEditorScreen;
|
||||
import me.kawaiizenbo.moonlight.util.ColorUtils;
|
||||
import net.minecraft.client.gui.DrawContext;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
|
@ -73,6 +73,7 @@ public class SettingsScreen extends Screen
|
|||
dragging = true;
|
||||
}
|
||||
backButton.mouseClicked((int)mouseX, (int)mouseY);
|
||||
editButton.mouseClicked((int)mouseX, (int)mouseY);
|
||||
for (Setting setting : module.settings)
|
||||
{
|
||||
setting.mouseClicked(mouseX, mouseY, button);
|
||||
|
|
54
src/main/java/me/kawaiizenbo/moonlight/ui/hud/HUDModule.java
Normal file
54
src/main/java/me/kawaiizenbo/moonlight/ui/hud/HUDModule.java
Normal file
|
@ -0,0 +1,54 @@
|
|||
package me.kawaiizenbo.moonlight.ui.hud;
|
||||
|
||||
import net.minecraft.client.font.TextRenderer;
|
||||
import net.minecraft.client.gui.DrawContext;
|
||||
|
||||
public class HUDModule
|
||||
{
|
||||
public int x, y, height, width;
|
||||
public String name;
|
||||
int startX, startY;
|
||||
boolean dragging = false;
|
||||
|
||||
public HUDModule(String name, int x, int y)
|
||||
{
|
||||
this.name = name;
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
}
|
||||
|
||||
public void render(DrawContext drawContext, int mouseX, int mouseY, TextRenderer textRenderer, boolean editMode)
|
||||
{
|
||||
if (editMode)
|
||||
{
|
||||
if (dragging)
|
||||
{
|
||||
x = mouseX - startX;
|
||||
y = mouseY - startY;
|
||||
}
|
||||
drawContext.fill(x-1, y-1, x+width+1, y+height+1, 0xFF55FFFF);
|
||||
drawContext.fill(x, y, x+width, y+height, 0xFF222222);
|
||||
}
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
if (hovered(mouseX, mouseY) && button == 0)
|
||||
{
|
||||
startX = (int)mouseX-x;
|
||||
startY = (int)mouseY-y;
|
||||
dragging = true;
|
||||
}
|
||||
}
|
||||
|
||||
public void mouseReleased(int mouseX, int mouseY, int button)
|
||||
{
|
||||
dragging = false;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,37 @@
|
|||
package me.kawaiizenbo.moonlight.ui.hud;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import me.kawaiizenbo.moonlight.ui.hud.modules.TestModuleHUD;
|
||||
|
||||
public class HUDModuleManager
|
||||
{
|
||||
public static HUDModuleManager INSTANCE = new HUDModuleManager();
|
||||
public ArrayList<HUDModule> modules = new ArrayList<>();
|
||||
|
||||
public HUDModuleManager()
|
||||
{
|
||||
registerModules(
|
||||
new TestModuleHUD(0, 0)
|
||||
);
|
||||
}
|
||||
|
||||
private void registerModules(HUDModule... modules)
|
||||
{
|
||||
for (HUDModule module : modules) {
|
||||
this.modules.add(module);
|
||||
}
|
||||
}
|
||||
|
||||
public HUDModule getModuleByName(String moduleName)
|
||||
{
|
||||
for(HUDModule module : modules)
|
||||
{
|
||||
if ((module.name.trim().equalsIgnoreCase(moduleName)))
|
||||
{
|
||||
return module;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
package me.kawaiizenbo.moonlight.ui.hud;
|
||||
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.gui.DrawContext;
|
||||
|
||||
public class HUDRenderer
|
||||
{
|
||||
public static HUDRenderer INSTANCE = new HUDRenderer();
|
||||
private MinecraftClient mc = MinecraftClient.getInstance();
|
||||
|
||||
public void render(DrawContext drawContext)
|
||||
{
|
||||
// do not draw if F3 enabled
|
||||
if (mc.getDebugHud().shouldShowDebugHud()) return;
|
||||
|
||||
for (HUDModule h : HUDModuleManager.INSTANCE.modules)
|
||||
{
|
||||
// mouse coords are not needed when not in edit mode
|
||||
h.render(drawContext, 0, 0, mc.textRenderer, false);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,5 +1,7 @@
|
|||
package me.kawaiizenbo.moonlight.ui.hud;
|
||||
package me.kawaiizenbo.moonlight.ui.hud.editor;
|
||||
|
||||
import me.kawaiizenbo.moonlight.ui.hud.HUDModule;
|
||||
import me.kawaiizenbo.moonlight.ui.hud.HUDModuleManager;
|
||||
import net.minecraft.client.gui.DrawContext;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
import net.minecraft.text.Text;
|
||||
|
@ -17,17 +19,29 @@ public class HUDEditorScreen extends Screen
|
|||
public void render(DrawContext drawContext, int mouseX, int mouseY, float delta)
|
||||
{
|
||||
this.renderBackground(drawContext, mouseX, mouseY, delta);
|
||||
for (HUDModule h : HUDModuleManager.INSTANCE.modules)
|
||||
{
|
||||
h.render(drawContext, mouseX, mouseY, textRenderer, true);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean mouseClicked(double mouseX, double mouseY, int button)
|
||||
{
|
||||
for (HUDModule h : HUDModuleManager.INSTANCE.modules)
|
||||
{
|
||||
h.mouseClicked((int)mouseX, (int)mouseY, button);
|
||||
}
|
||||
return super.mouseClicked(mouseX, mouseY, button);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean mouseReleased(double mouseX, double mouseY, int button)
|
||||
{
|
||||
for (HUDModule h : HUDModuleManager.INSTANCE.modules)
|
||||
{
|
||||
h.mouseReleased((int)mouseX, (int)mouseY, button);
|
||||
}
|
||||
return super.mouseReleased(mouseX, mouseY, button);
|
||||
}
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
package me.kawaiizenbo.moonlight.ui.hud.modules;
|
||||
|
||||
import me.kawaiizenbo.moonlight.ui.hud.HUDModule;
|
||||
import net.minecraft.client.font.TextRenderer;
|
||||
import net.minecraft.client.gui.DrawContext;
|
||||
|
||||
public class TestModuleHUD extends HUDModule
|
||||
{
|
||||
public TestModuleHUD(int x, int y)
|
||||
{
|
||||
super("Test HUD Module", x, y);
|
||||
this.width = 96;
|
||||
this.height = 12;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(DrawContext drawContext, int mouseX, int mouseY, TextRenderer textRenderer, boolean editMode)
|
||||
{
|
||||
super.render(drawContext, mouseX, mouseY, textRenderer, editMode);
|
||||
drawContext.drawText(textRenderer, "heloooooo", x, y, 0x55FFFF, false);
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue