New mod ui
This commit is contained in:
@@ -10,11 +10,13 @@ import net.minecraft.util.Identifier;
|
||||
public abstract class Module {
|
||||
private final String name;
|
||||
private final String namespace;
|
||||
private final String description;
|
||||
private final ConfigManager configManager;
|
||||
|
||||
public Module(String name, String namespace, NamedProperty<?>... props) {
|
||||
public Module(String name, String namespace, String description, NamedProperty<?>... props) {
|
||||
this.name = name;
|
||||
this.namespace = namespace;
|
||||
this.description = description;
|
||||
|
||||
configManager = new ConfigManager(name);
|
||||
|
||||
@@ -23,9 +25,10 @@ public abstract class Module {
|
||||
}
|
||||
}
|
||||
|
||||
public Module(ConfigManager config, String name, String namespace) {
|
||||
public Module(ConfigManager config, String name, String namespace, String description) {
|
||||
this.name = name;
|
||||
this.namespace = namespace;
|
||||
this.description = description;
|
||||
|
||||
configManager = config;
|
||||
}
|
||||
@@ -48,4 +51,8 @@ public abstract class Module {
|
||||
public ConfigManager getConfig() {
|
||||
return configManager;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ public class AutoSprint extends Module {
|
||||
private static Property<Boolean> enabled = new Property<>(true);
|
||||
|
||||
public AutoSprint() {
|
||||
super("Auto Sprint", "sprint", enabled.named("Enabled"));
|
||||
super("Auto Sprint", "sprint", "Makes the player always sprint", enabled.named("Enabled"));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -13,7 +13,7 @@ public class Crosshair extends Module {
|
||||
public static Property<Boolean> range_indicator = new Property<>(false);
|
||||
|
||||
public Crosshair() {
|
||||
super("Crosshair", "crosshair", enabled.named("Enabled"), range_indicator.named("Range Indicator"));
|
||||
super("Crosshair", "crosshair", "Changes the crosshair if you're aiming at a entity", enabled.named("Enabled"), range_indicator.named("Range Indicator"));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,5 +1,37 @@
|
||||
package org.saturnclient.ui2.components;
|
||||
|
||||
public class SaturnModule {
|
||||
import org.saturnclient.modules.Module;
|
||||
import org.saturnclient.ui2.Element;
|
||||
import org.saturnclient.ui2.RenderContext;
|
||||
import org.saturnclient.ui2.RenderScope;
|
||||
|
||||
public class SaturnModule extends Element {
|
||||
private Module mod;
|
||||
|
||||
public SaturnModule(Module mod) {
|
||||
this.mod = mod;
|
||||
|
||||
this.width = 270;
|
||||
|
||||
this.height = 120;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(RenderScope renderScope, RenderContext ctx) {
|
||||
renderScope.drawRoundedRectangle(0, 0, width, height, 10, -16777216);
|
||||
|
||||
if (mod.isEnabled()) {
|
||||
renderScope.enableScissor(0, 0, 7, height);
|
||||
renderScope.drawRoundedRectangle(0, 0, 7 * 2, height, 10, -7643914);
|
||||
renderScope.disableScissor();
|
||||
}
|
||||
|
||||
renderScope.drawText(mod.getName(), 10 + 7, 10, true, -1);
|
||||
|
||||
renderScope.matrices.push();
|
||||
renderScope.matrices.translate(10 + 7, 30, 0);
|
||||
renderScope.matrices.scale(0.7f, 0.7f, 1.0f);
|
||||
renderScope.drawText(mod.getDescription(), 0, 0, false, 0xFFAAAAAA);
|
||||
renderScope.matrices.pop();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,10 +16,10 @@ public class Scroll extends Element {
|
||||
private static Property<Integer> scrollBarColor = theme.property("scrollbar-color", new Property<Integer>(0xFFFF0000));
|
||||
|
||||
private static Property<Integer> scrollBarRadius = theme.property("scrollbar-radius", new Property<Integer>(10));
|
||||
private static Property<Integer> scrollBarWidth = theme.property("scrollbar-radius", new Property<Integer>(10));
|
||||
private static Property<Integer> scrollBarWidth = theme.property("scrollbar-width", new Property<Integer>(5));
|
||||
private static Property<Integer> scrollBarPadding = theme.property("scrollbar-padding", new Property<Integer>(5));
|
||||
private static Property<Integer> cornerRadius = theme.property("corner-radius", new Property<Integer>(10));
|
||||
private static Property<Integer> padding = theme.property("padding", new Property<Integer>(10));
|
||||
private static Property<Integer> padding = theme.property("padding", new Property<Integer>(25));
|
||||
|
||||
public static Property<Integer> gap = theme.property("gap", new Property<Integer>(10));
|
||||
|
||||
|
||||
@@ -2,10 +2,8 @@ package org.saturnclient.ui2.screens;
|
||||
|
||||
import org.saturnclient.modules.ModManager;
|
||||
import org.saturnclient.modules.Module;
|
||||
import org.saturnclient.saturnclient.SaturnClient;
|
||||
import org.saturnclient.saturnclient.menus.ConfigEditor;
|
||||
import org.saturnclient.ui2.SaturnScreen;
|
||||
import org.saturnclient.ui2.elements.Button;
|
||||
import org.saturnclient.ui2.components.SaturnModule;
|
||||
import org.saturnclient.ui2.elements.Scroll;
|
||||
|
||||
public class ModMenu extends SaturnScreen {
|
||||
@@ -21,11 +19,9 @@ public class ModMenu extends SaturnScreen {
|
||||
int col = 0;
|
||||
|
||||
for (Module mod : ModManager.MODS) {
|
||||
scroll.draw(new Button(mod.getName(), () -> {
|
||||
SaturnClient.client.setScreen(new ConfigEditor(mod.getConfig()));
|
||||
}).dimensions(100, 50).position((100 + Scroll.gap.value) * col, (50 + Scroll.gap.value) * row));
|
||||
scroll.draw(new SaturnModule(mod).position((270 + Scroll.gap.value) * col, (120 + Scroll.gap.value) * row));
|
||||
|
||||
if (col == 3) {
|
||||
if (col == 2) {
|
||||
col = 0;
|
||||
row++;
|
||||
} else {
|
||||
@@ -33,6 +29,6 @@ public class ModMenu extends SaturnScreen {
|
||||
}
|
||||
}
|
||||
|
||||
draw(scroll.dimensions(400, 250).center(width, height));
|
||||
draw(scroll.dimensions(600, 350).center(width, height));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user