start of settings, slightly broken
This commit is contained in:
parent
411790540a
commit
0ebc2f3512
10 changed files with 206 additions and 8 deletions
43
src/main/java/me/kawaiizenbo/moonlight/ui/TextButton.java
Normal file
43
src/main/java/me/kawaiizenbo/moonlight/ui/TextButton.java
Normal file
|
@ -0,0 +1,43 @@
|
|||
package me.kawaiizenbo.moonlight.ui;
|
||||
|
||||
import me.kawaiizenbo.moonlight.ui.clickgui.ClickGUIScreen;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.font.TextRenderer;
|
||||
import net.minecraft.client.gui.DrawableHelper;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.minecraft.text.Text;
|
||||
|
||||
public class TextButton
|
||||
{
|
||||
String text;
|
||||
int x, y, color, width;
|
||||
|
||||
public TextButton(String text, int x, int y, int color)
|
||||
{
|
||||
this.text = text;
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.color = color;
|
||||
}
|
||||
|
||||
public void render(MatrixStack matrices, TextRenderer textRenderer, int mouseX, int mouseY)
|
||||
{
|
||||
width = textRenderer.getWidth(text);
|
||||
DrawableHelper.fill(matrices, x-1, y-1, x + width + 1, y + 10, hovered(mouseX, mouseY) ? 0xFF444444 : 0xFF222222);
|
||||
DrawableHelper.drawTextWithShadow(matrices, textRenderer, Text.literal(text), x, y, color);
|
||||
}
|
||||
|
||||
public boolean hovered(int mouseX, int mouseY)
|
||||
{
|
||||
return mouseX >= x && mouseX <= x + width && mouseY >= y && mouseY <= y + 10;
|
||||
}
|
||||
|
||||
public void mouseClicked(int mouseX, int mouseY)
|
||||
{
|
||||
if (hovered(mouseX, mouseY))
|
||||
{
|
||||
// i have no clue how to pass a method so this is kind of stupid
|
||||
MinecraftClient.getInstance().setScreen(ClickGUIScreen.INSTANCE);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,6 +1,7 @@
|
|||
package me.kawaiizenbo.moonlight.ui.altmanager;
|
||||
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.minecraft.text.Text;
|
||||
|
||||
public class AltManagerScreen extends Screen
|
||||
|
@ -11,5 +12,11 @@ public class AltManagerScreen extends Screen
|
|||
{
|
||||
super(Text.literal("Alt Manager"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(MatrixStack matrices, int mouseX, int mouseY, float delta)
|
||||
{
|
||||
renderBackgroundTexture(0);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -24,8 +24,8 @@ public class ClickGUIScreen extends Screen
|
|||
yOffset = 25;
|
||||
for (Module_ module : ModuleManager.INSTANCE.getModulesByCategory(category))
|
||||
{
|
||||
moduleButtons.add(new ModuleButton(module, 9+(module.category.ordinal()*65), yOffset));
|
||||
yOffset += 10;
|
||||
moduleButtons.add(new ModuleButton(module, 9+(module.category.ordinal()*70), yOffset));
|
||||
yOffset += 14;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -39,7 +39,7 @@ public class ClickGUIScreen extends Screen
|
|||
for (Category category : Category.values())
|
||||
{
|
||||
textRenderer.draw(matrices, category.name, categoryLabelXOffset, 10, 0xFFFFFF);
|
||||
categoryLabelXOffset += 65;
|
||||
categoryLabelXOffset += 70;
|
||||
}
|
||||
for (ModuleButton moduleButton : moduleButtons)
|
||||
{
|
||||
|
|
|
@ -17,15 +17,15 @@ public class ModuleButton
|
|||
this.module = module;
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.width = 60;
|
||||
this.height = 10;
|
||||
this.width = 70;
|
||||
this.height = 14;
|
||||
}
|
||||
|
||||
public void render(MatrixStack matrices, int mouseX, int mouseY)
|
||||
{
|
||||
TextRenderer textRenderer = mc.textRenderer;
|
||||
DrawableHelper.fill(matrices, x, y, x + width, y + height, hovered(mouseX, mouseY) ? 0xFF333333 : 0xFF222222);
|
||||
textRenderer.draw(matrices, module.name, x+1, y+1, module.enabled ? 0x55FFFF : 0xFFFFFF);
|
||||
textRenderer.draw(matrices, module.name, x+3, y+3, module.enabled ? 0x55FFFF : 0xFFFFFF);
|
||||
}
|
||||
|
||||
public boolean hovered(int mouseX, int mouseY)
|
||||
|
@ -37,7 +37,14 @@ public class ModuleButton
|
|||
{
|
||||
if (hovered(mouseX, mouseY))
|
||||
{
|
||||
module.toggle();
|
||||
if (button == 0)
|
||||
{
|
||||
module.toggle();
|
||||
}
|
||||
else if (button == 1)
|
||||
{
|
||||
MinecraftClient.getInstance().setScreen(new SettingsScreen(module));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,53 @@
|
|||
package me.kawaiizenbo.moonlight.ui.clickgui;
|
||||
|
||||
import me.kawaiizenbo.moonlight.module.Module_;
|
||||
import me.kawaiizenbo.moonlight.module.settings.Setting;
|
||||
import me.kawaiizenbo.moonlight.ui.TextButton;
|
||||
import me.kawaiizenbo.moonlight.util.ColorUtils;
|
||||
import net.minecraft.client.gui.DrawableHelper;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.minecraft.text.Text;
|
||||
|
||||
public class SettingsScreen extends Screen
|
||||
{
|
||||
private Module_ module;
|
||||
private TextButton backButton;
|
||||
|
||||
protected SettingsScreen(Module_ module)
|
||||
{
|
||||
super(Text.literal("Settings"));
|
||||
this.module = module;
|
||||
backButton = new TextButton(ColorUtils.underline + "< Back", 112, 32, 0xFFFFFF);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(MatrixStack matrices, int mouseX, int mouseY, float delta)
|
||||
{
|
||||
this.renderBackground(matrices);
|
||||
DrawableHelper.fill(matrices, (width/2)-112, (height/2)-96, (width/2)+112, (height/2)+96, 0xFF222222);
|
||||
DrawableHelper.drawCenteredText(matrices, textRenderer, module.name, width/2, 32, 0xFFFFFF);
|
||||
DrawableHelper.drawTextWithShadow(matrices, textRenderer, Text.literal(module.description), 112, 48, 0xFFFFFF);
|
||||
backButton.render(matrices, textRenderer, mouseX, mouseY);
|
||||
int yOffset = 64;
|
||||
for (Setting setting : module.settings)
|
||||
{
|
||||
setting.render(matrices, 117, yOffset, mouseX, mouseY);
|
||||
yOffset += 32;
|
||||
}
|
||||
// add keybind setting here eventually
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldPause()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean mouseClicked(double mouseX, double mouseY, int button)
|
||||
{
|
||||
backButton.mouseClicked((int)mouseX, (int)mouseY);
|
||||
return super.mouseClicked(mouseX, mouseY, button);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue