Added Quests and Real Settings (yay)

This commit is contained in:
2026-07-11 10:46:47 +02:00
parent d3fc829dee
commit 652fe728e1
7 changed files with 392 additions and 77 deletions
@@ -56,6 +56,7 @@ public class MyScreen extends BaseOwoScreen<FlowLayout> {
private FlowLayout content;
private final String initialModule;
public MyScreen() {
this(null);
}
@@ -130,8 +131,8 @@ public class MyScreen extends BaseOwoScreen<FlowLayout> {
rootComponent.child(panel);
if ("FPS".equals(initialModule)) {
openModuleSettings("FPS", fpsModuleSettings());
if (initialModule != null) {
openModuleByKey(initialModule);
} else {
buildGeneralPanel(content);
}
@@ -249,72 +250,51 @@ public class MyScreen extends BaseOwoScreen<FlowLayout> {
}
private void buildGeneralPanel(FlowLayout content) {
FlowLayout iconButton = UIContainers.horizontalFlow(Sizing.content(), Sizing.content());
iconButton.gap(8);
iconButton.verticalAlignment(VerticalAlignment.TOP);
iconButton.horizontalAlignment(HorizontalAlignment.CENTER);
iconButton.padding(Insets.of(6));
iconButton.horizontalSizing(Sizing.fixed(0));
iconButton.verticalSizing(Sizing.fixed(0));
iconButton.surface(toggle ? GLASS_PANEL : DISABLED);
iconButton.child(UIComponents.texture(
Identifier.fromNamespaceAndPath("citrus-dev", "textures/icons/block_culling_file.png"),
0, 0, 18, 12, 18, 12
)).horizontalAlignment(HorizontalAlignment.LEFT)
.verticalAlignment(VerticalAlignment.CENTER);
FlowLayout textStack = UIContainers.verticalFlow(Sizing.content(), Sizing.content());
textStack.gap(2);
textStack.horizontalAlignment(HorizontalAlignment.LEFT);
textStack.verticalAlignment(VerticalAlignment.CENTER);
var fpsLabel = UIComponents.label(
Component.literal("FPS")
.withStyle(style -> style.withFont(new FontDescription.Resource(MC_FIVE)))
).color(Color.ofRgb(toggle ? 0xffffff : 0x797b86));
textStack.child(fpsLabel);
textStack.child(UIComponents.label(
Component.literal("Displays your FPS"))
.color(Color.ofRgb(0xa3a3ac))
.maxWidth(130)
);
iconButton.child(textStack);
iconButton.child(UIComponents.spacer());
FlowLayout settingsButton = SettingsControls.makeSmallButton(
FLAT,
FlowLayout fpsRow = ModuleRow.build(
GLASS_PANEL, DISABLED, FLAT,
Identifier.fromNamespaceAndPath("citrus-dev", "textures/icons/block_culling_file.png"),
18, 12,
MC_FIVE,
"FPS",
"Displays your FPS",
new ModuleRow.ToggleState() {
public boolean get() { return toggle; }
public void set(boolean value) { toggle = value; }
},
Identifier.fromNamespaceAndPath("citrus-dev", "textures/icons/settings.png"),
() -> {
Config.get().lastModule = "FPS";
Config.get().save();
openModuleSettings("FPS", fpsModuleSettings());
}
},
"Module Enabled", "FPS counter is now active",
"Module Disabled", "FPS counter is now inactive"
);
iconButton.child(settingsButton);
iconButton.mouseEnter().subscribe(() -> iconButton.surface(toggle ? GLASS_PANEL : DISABLED));
iconButton.mouseLeave().subscribe(() -> iconButton.surface(toggle ? GLASS_PANEL : DISABLED));
FlowLayout keyStrokesRow = ModuleRow.build(
GLASS_PANEL, DISABLED, FLAT,
Identifier.fromNamespaceAndPath("citrus-dev", "textures/icons/block_culling_file.png"),
18, 12,
MC_FIVE,
"Keystrokes",
"Current Key Presses",
new ModuleRow.ToggleState() {
public boolean get() { return Module_KeyStrokes.isEnabled(); }
public void set(boolean value) { Module_KeyStrokes.setEnabled(value); }
},
Identifier.fromNamespaceAndPath("citrus-dev", "textures/icons/settings.png"),
() -> {
Config.get().lastModule = "Key";
Config.get().save();
openModuleSettings("Key", keyStrokesSettings());
},
"Module Enabled", "Keystrokes is now active",
"Module Disabled", "KeyStrokes is now inactive"
);
content.child(keyStrokesRow);
content.child(fpsRow);
iconButton.mouseDown().subscribe((click, doubled) -> {
toggle = !toggle;
fpsLabel.color(Color.ofRgb(toggle ? 0xffffff : 0x797b86));
iconButton.surface(toggle ? GLASS_PANEL : DISABLED);
CitrusToast.show("Module Enabled", "FPS counter is now active");
Minecraft.getInstance().getSoundManager().play(
SimpleSoundInstance.forUI(SoundEvents.UI_BUTTON_CLICK.value(), 2.0F, 2)
);
return true;
});
iconButton.horizontalSizing().animate(150, Easing.CUBIC, Sizing.fixed(200)).forwards();
iconButton.verticalSizing().animate(150, Easing.CUBIC, Sizing.fixed(35)).forwards();
content.child(iconButton);
}
@@ -366,6 +346,14 @@ public class MyScreen extends BaseOwoScreen<FlowLayout> {
content.child(scrollArea);
}
private void openModuleByKey(String key) {
switch (key) {
case "FPS" -> openModuleSettings("FPS", fpsModuleSettings());
case "Key" -> openModuleSettings("Keystrokes", keyStrokesSettings());
default -> buildGeneralPanel(content);
}
}
private FlowLayout makeSettingRow(SettingRow setting) {
FlowLayout row = UIContainers.horizontalFlow(Sizing.fixed(CONTENT_WIDTH - 8), Sizing.fixed(16));
row.verticalAlignment(VerticalAlignment.CENTER);
@@ -398,12 +386,48 @@ public class MyScreen extends BaseOwoScreen<FlowLayout> {
value -> Module_FPS.fpsContainer.gap((int) value)
);
int currentIndex = positionIndex(Config.get().fpsX, Config.get().fpsY);
return List.of(
new SettingRow("Position", SettingsControls.makeCyclingButton(GLASS_PANEL, positionStates)),
new SettingRow("Position", SettingsControls.makeCyclingButton(GLASS_PANEL, positionStates, currentIndex)),
new SettingRow("Size", sizeSlider)
);
}
private List<SettingRow> keyStrokesSettings() {
List<SettingsControls.ButtonState> positionStates = List.of(
new SettingsControls.ButtonState("L-TOP", () -> Module_KeyStrokes.setPosition(1, 1)),
new SettingsControls.ButtonState("R-TOP", () -> Module_KeyStrokes.setPosition(99, 1)),
new SettingsControls.ButtonState("R-BOTTOM", () -> Module_KeyStrokes.setPosition(99, 99)),
new SettingsControls.ButtonState("L-BOTTOM", () -> Module_KeyStrokes.setPosition(1, 99))
);
FlowLayout sizeSlider = SettingsControls.makeSlider(
FLAT,
80,
0.0, 20.0,
4.0,
value -> (int) value + "px",
value -> {} // fixed: was Module_FPS.fpsContainer.gap(...)
);
int currentIndex = positionIndex(Config.get().keyX, Config.get().keyY);
return List.of(
new SettingRow("Position", SettingsControls.makeCyclingButton(GLASS_PANEL, positionStates, currentIndex)),
new SettingRow("Size", sizeSlider)
);
}
private int positionIndex(int x, int y) {
boolean right = x > 50;
boolean bottom = y > 50;
if (!right && !bottom) return 0; // L-TOP
if (right && !bottom) return 1; // R-TOP
if (right && bottom) return 2; // R-BOTTOM
return 3; // L-BOTTOM
}
@Override
public boolean isPauseScreen() {
return false;