fixed a little

This commit is contained in:
2026-07-11 12:30:16 +02:00
parent 652fe728e1
commit 476925c31b
7 changed files with 80 additions and 40 deletions
@@ -13,13 +13,14 @@ import java.nio.file.Path;
public class Config { public class Config {
public int fpsP = 6; public int fpsSize = 16;
public int fpsX = 1; public int fpsX = 1;
public int fpsY = 1; public int fpsY = 1;
public String lastModule = "FPS"; public String lastModule = "FPS";
public int keyX = 1; public int keyX = 1;
public int keyY = 1; public int keyY = 1;
public int keySize = 16;
private static final Gson GSON = new GsonBuilder().setPrettyPrinting().create(); private static final Gson GSON = new GsonBuilder().setPrettyPrinting().create();
private static final Path PATH = FabricLoader.getInstance() private static final Path PATH = FabricLoader.getInstance()
@@ -27,6 +28,7 @@ public class Config {
.resolve("citrus-dev.json"); .resolve("citrus-dev.json");
private static Config instance; private static Config instance;
public int fpsP = 4;
public static Config get() { public static Config get() {
if (instance == null) { if (instance == null) {
@@ -30,7 +30,14 @@ public class Module_FPS {
CONFIG.fpsX = x; CONFIG.fpsX = x;
CONFIG.fpsY = y; CONFIG.fpsY = y;
CONFIG.save(); CONFIG.save();
}
public static void setFpsPadding(int padding) {
CONFIG.fpsP = padding;
CONFIG.save();
if (fpsContainer == null) return;
fpsContainer.padding(Insets.of(padding));
} }
public static void register() { public static void register() {
@@ -1,5 +1,7 @@
package de.fullrisk.citrusDev.UI; package de.fullrisk.citrusDev.UI;
import de.fullrisk.citrusDev.UIHelper.ScalableLabel;
import de.fullrisk.citrusDev.UIHelper.ScaleValue;
import io.wispforest.owo.ui.component.LabelComponent; import io.wispforest.owo.ui.component.LabelComponent;
import io.wispforest.owo.ui.component.UIComponents; import io.wispforest.owo.ui.component.UIComponents;
import io.wispforest.owo.ui.container.FlowLayout; import io.wispforest.owo.ui.container.FlowLayout;
@@ -12,6 +14,8 @@ import net.minecraft.network.chat.Component;
import net.minecraft.resources.Identifier; import net.minecraft.resources.Identifier;
import de.fullrisk.citrusDev.Config; import de.fullrisk.citrusDev.Config;
import java.util.List;
public class Module_KeyStrokes { public class Module_KeyStrokes {
private static FlowLayout keyContainer; private static FlowLayout keyContainer;
@@ -19,7 +23,7 @@ public class Module_KeyStrokes {
private static FlowLayout bottomRow; private static FlowLayout bottomRow;
private static FlowLayout wBox, aBox, sBox, dBox; private static FlowLayout wBox, aBox, sBox, dBox;
private static LabelComponent wLabel, aLabel, sLabel, dLabel; private static ScalableLabel wLabel, aLabel, sLabel, dLabel; // was LabelComponent
static boolean toggle = true; static boolean toggle = true;
private static boolean shown = false; private static boolean shown = false;
@@ -36,8 +40,9 @@ public class Module_KeyStrokes {
private static final Surface GLASS_PANEL = Surface.blur(5f, 15f) private static final Surface GLASS_PANEL = Surface.blur(5f, 15f)
.and(Surface.flat(0x40FFFFFF)); .and(Surface.flat(0x40FFFFFF));
private static final int KEY_SIZE = 16; private static int keySize = 16; // was: private static final int KEY_SIZE = 16;
private static final int PRESSED_COLOR = 0xFF64de4b; private static FlowLayout leftSpacer, rightSpacer;
private static final int PRESSED_COLOR = 0x70FFFFFF;
private static final int IDLE_COLOR = 0x40FFFFFF; private static final int IDLE_COLOR = 0x40FFFFFF;
public static void setPosition(int x, int y) { public static void setPosition(int x, int y) {
@@ -52,22 +57,27 @@ public class Module_KeyStrokes {
public static void register() { public static void register() {
Hud.add(Identifier.fromNamespaceAndPath("citrus-dev", "keystrokes_display"), () -> { Hud.add(Identifier.fromNamespaceAndPath("citrus-dev", "keystrokes_display"), () -> {
if (keyContainer == null) { if (keyContainer == null) {
wLabel = UIComponents.label(Component.literal("W")); keySize = CONFIG.keySize > 0 ? CONFIG.keySize : 16; // load saved size, fallback to default
aLabel = UIComponents.label(Component.literal("A"));
sLabel = UIComponents.label(Component.literal("S")); wLabel = new ScalableLabel(Component.literal("W"));
dLabel = UIComponents.label(Component.literal("D")); aLabel = new ScalableLabel(Component.literal("A"));
sLabel = new ScalableLabel(Component.literal("S"));
dLabel = new ScalableLabel(Component.literal("D"));
wBox = makeKeyBox(wLabel); wBox = makeKeyBox(wLabel);
aBox = makeKeyBox(aLabel); aBox = makeKeyBox(aLabel);
sBox = makeKeyBox(sLabel); sBox = makeKeyBox(sLabel);
dBox = makeKeyBox(dLabel); dBox = makeKeyBox(dLabel);
leftSpacer = UIContainers.horizontalFlow(Sizing.fixed(keySize), Sizing.fixed(keySize));
rightSpacer = UIContainers.horizontalFlow(Sizing.fixed(keySize), Sizing.fixed(keySize));
topRow = UIContainers.horizontalFlow(Sizing.content(), Sizing.content()); topRow = UIContainers.horizontalFlow(Sizing.content(), Sizing.content());
topRow.gap(2); topRow.gap(2);
topRow.horizontalAlignment(HorizontalAlignment.CENTER); topRow.horizontalAlignment(HorizontalAlignment.CENTER);
topRow.child(UIContainers.horizontalFlow(Sizing.fixed(KEY_SIZE), Sizing.fixed(KEY_SIZE))); // spacer topRow.child(leftSpacer);
topRow.child(wBox); topRow.child(wBox);
topRow.child(UIContainers.horizontalFlow(Sizing.fixed(KEY_SIZE), Sizing.fixed(KEY_SIZE))); // spacer topRow.child(rightSpacer);
bottomRow = UIContainers.horizontalFlow(Sizing.content(), Sizing.content()); bottomRow = UIContainers.horizontalFlow(Sizing.content(), Sizing.content());
bottomRow.gap(2); bottomRow.gap(2);
@@ -88,22 +98,47 @@ public class Module_KeyStrokes {
}); });
} }
private static FlowLayout makeKeyBox(LabelComponent label) { private static FlowLayout makeKeyBox(ScalableLabel label) {
FlowLayout box = UIContainers.verticalFlow(Sizing.fixed(KEY_SIZE), Sizing.fixed(KEY_SIZE)); FlowLayout box = UIContainers.verticalFlow(Sizing.fixed(keySize), Sizing.fixed(keySize));
box.horizontalAlignment(HorizontalAlignment.CENTER); box.horizontalAlignment(HorizontalAlignment.CENTER);
box.verticalAlignment(VerticalAlignment.CENTER); box.verticalAlignment(VerticalAlignment.CENTER);
box.surface(Surface.flat(IDLE_COLOR)); box.surface(Surface.flat(IDLE_COLOR));
label.scale().set(new ScaleValue(labelScaleFor(keySize)));
box.child(label); box.child(label);
return box; return box;
} }
private static float labelScaleFor(int size) {
return size / 16f; // 16px box = 1.0x scale (matches the default keySize)
}
public static void setKeySize(int size) {
keySize = size;
CONFIG.keySize = size;
CONFIG.save();
if (wBox == null) return;
float labelScale = labelScaleFor(size);
for (FlowLayout box : List.of(wBox, aBox, sBox, dBox, leftSpacer, rightSpacer)) {
box.horizontalSizing(Sizing.fixed(size));
box.verticalSizing(Sizing.fixed(size));
}
for (ScalableLabel label : List.of(wLabel, aLabel, sLabel, dLabel)) {
label.scale().set(new ScaleValue(labelScale));
}
}
public static void tick() { public static void tick() {
if (keyContainer == null) return; if (keyContainer == null) return;
if (toggle && !shown) { if (toggle && !shown) {
keyContainer.clearChildren(); // <-- safety net against duplicate adds keyContainer.clearChildren(); // <-- safety net against duplicate adds
keyContainer.surface(GLASS_PANEL); // keyContainer.surface(GLASS_PANEL);
keyContainer.padding(Insets.of(Config.get().fpsP)); keyContainer.padding(Insets.of(4));
keyContainer.child(topRow); keyContainer.child(topRow);
keyContainer.child(bottomRow); keyContainer.child(bottomRow);
shown = true; shown = true;
@@ -377,20 +377,22 @@ public class MyScreen extends BaseOwoScreen<FlowLayout> {
new SettingsControls.ButtonState("L-BOTTOM", () -> Module_FPS.setPosition(1, 99)) new SettingsControls.ButtonState("L-BOTTOM", () -> Module_FPS.setPosition(1, 99))
); );
FlowLayout sizeSlider = SettingsControls.makeSlider( FlowLayout paddingSlider = SettingsControls.makeSlider(
FLAT, FLAT,
80, 80,
0.0, 20.0, 0.0, 15.0,
4.0, Config.get().fpsSize,
value -> (int) value + "px", value -> (int) value + "px",
value -> Module_FPS.fpsContainer.gap((int) value) value -> Module_FPS.setFpsPadding((int) value)
); );
int currentIndex = positionIndex(Config.get().fpsX, Config.get().fpsY); int currentIndex = positionIndex(Config.get().fpsX, Config.get().fpsY);
return List.of( return List.of(
new SettingRow("Position", SettingsControls.makeCyclingButton(GLASS_PANEL, positionStates, currentIndex)), new SettingRow("Position", SettingsControls.makeCyclingButton(GLASS_PANEL, positionStates, currentIndex)),
new SettingRow("Size", sizeSlider) new SettingRow("Size", paddingSlider)
); );
} }
@@ -405,10 +407,10 @@ public class MyScreen extends BaseOwoScreen<FlowLayout> {
FlowLayout sizeSlider = SettingsControls.makeSlider( FlowLayout sizeSlider = SettingsControls.makeSlider(
FLAT, FLAT,
80, 80,
0.0, 20.0, 10.0, 30.0,
4.0, Config.get().keySize,
value -> (int) value + "px", value -> (int) value + "px",
value -> {} // fixed: was Module_FPS.fpsContainer.gap(...) value -> Module_KeyStrokes.setKeySize((int) value)
); );
int currentIndex = positionIndex(Config.get().keyX, Config.get().keyY); int currentIndex = positionIndex(Config.get().keyX, Config.get().keyY);
@@ -110,7 +110,7 @@ public class QuestsPanel {
summaryRow.padding(Insets.of(3, 0, 2, 2)); summaryRow.padding(Insets.of(3, 0, 2, 2));
summaryRow.child(UIComponents.label( summaryRow.child(UIComponents.label(
Component.literal("Quests " + unlockedCount + "/" + quests.size()) Component.literal("quests " + unlockedCount + "/" + quests.size())
.withStyle(style -> style.withFont(new FontDescription.Resource(MyScreen.MC_FIVE)))) .withStyle(style -> style.withFont(new FontDescription.Resource(MyScreen.MC_FIVE))))
.color(Color.ofRgb(0xa3a3ac))); .color(Color.ofRgb(0xa3a3ac)));
@@ -152,10 +152,10 @@ public class QuestsPanel {
private static List<QuestData> quests() { private static List<QuestData> quests() {
return List.of( return List.of(
new QuestData("First Steps", "Play for 5 minutes", 300), new QuestData("first steps", "Play for 5 minutes", 300),
new QuestData("Getting Started", "Play for 30 minutes", 1800), new QuestData("getting started", "Play for 30 minutes", 1800),
new QuestData("Dedicated Player", "Play for 1 hour", 3600), new QuestData("dedicated player", "Play for 1 hour", 3600),
new QuestData("Veteran", "Play for 3 hours", 10800) new QuestData("veteran", "Play for 3 hours", 10800)
); );
} }
@@ -17,7 +17,6 @@ import org.lwjgl.glfw.GLFW;
public class CitrusDevClient implements ClientModInitializer { public class CitrusDevClient implements ClientModInitializer {
private static KeyMapping openScreenKey; private static KeyMapping openScreenKey;
private static KeyMapping openOverviewKey;
@Override @Override
public void onInitializeClient() { public void onInitializeClient() {
@@ -29,11 +28,6 @@ public class CitrusDevClient implements ClientModInitializer {
openScreenKey = KeyMappingHelper.registerKeyMapping(new KeyMapping( openScreenKey = KeyMappingHelper.registerKeyMapping(new KeyMapping(
"key.citrus-dev.open_screen", "key.citrus-dev.open_screen",
GLFW.GLFW_KEY_G,
category
));
openOverviewKey = KeyMappingHelper.registerKeyMapping(new KeyMapping(
"key.citrus-dev.open_ui",
GLFW.GLFW_KEY_RIGHT_SHIFT, GLFW.GLFW_KEY_RIGHT_SHIFT,
category category
)); ));
@@ -45,15 +39,15 @@ public class CitrusDevClient implements ClientModInitializer {
Module_FPS.tick(); Module_FPS.tick();
Module_KeyStrokes.tick(); Module_KeyStrokes.tick();
while (openScreenKey.consumeClick()) { while (openScreenKey.consumeClick()) {
client.setScreen(new MyScreen(null)); // always general tab if (client.player != null && client.player.isShiftKeyDown()) {
}
while (openOverviewKey.consumeClick()) {
String lastModule = Config.get().lastModule; String lastModule = Config.get().lastModule;
client.setScreen(new MyScreen(lastModule)); // switch no longer even needed client.setScreen(new MyScreen(lastModule)); // sneak + RShift: last module
} else {
client.setScreen(new MyScreen(null)); // RShift alone: general tab
}
} }
}); });
} }
} }