new clickgui, still need to add dragging
This commit is contained in:
parent
b58eedfb9c
commit
6e584de0e6
17 changed files with 129 additions and 46 deletions
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue