From 476925c31bfa8df5a6665957a6e344c50e54fd79 Mon Sep 17 00:00:00 2001 From: FullRisk Date: Sat, 11 Jul 2026 12:30:16 +0200 Subject: [PATCH] fixed a little --- .../java/de/fullrisk/citrusDev/Config.java | 4 +- .../de/fullrisk/citrusDev/UI/Module_FPS.java | 7 +++ .../citrusDev/UI/Module_KeyStrokes.java | 61 +++++++++++++++---- .../de/fullrisk/citrusDev/UI/MyScreen.java | 18 +++--- .../de/fullrisk/citrusDev/UI/QuestsPanel.java | 10 +-- .../citrusDev/client/CitrusDevClient.java | 20 +++--- .../{ => assets/citrus-dev/lang}/en_us.json | 0 7 files changed, 80 insertions(+), 40 deletions(-) rename src/main/resources/{ => assets/citrus-dev/lang}/en_us.json (100%) diff --git a/src/main/java/de/fullrisk/citrusDev/Config.java b/src/main/java/de/fullrisk/citrusDev/Config.java index 585a7a2..0cf68af 100644 --- a/src/main/java/de/fullrisk/citrusDev/Config.java +++ b/src/main/java/de/fullrisk/citrusDev/Config.java @@ -13,13 +13,14 @@ import java.nio.file.Path; public class Config { - public int fpsP = 6; + public int fpsSize = 16; public int fpsX = 1; public int fpsY = 1; public String lastModule = "FPS"; public int keyX = 1; public int keyY = 1; + public int keySize = 16; private static final Gson GSON = new GsonBuilder().setPrettyPrinting().create(); private static final Path PATH = FabricLoader.getInstance() @@ -27,6 +28,7 @@ public class Config { .resolve("citrus-dev.json"); private static Config instance; + public int fpsP = 4; public static Config get() { if (instance == null) { diff --git a/src/main/java/de/fullrisk/citrusDev/UI/Module_FPS.java b/src/main/java/de/fullrisk/citrusDev/UI/Module_FPS.java index 4105296..67969e1 100644 --- a/src/main/java/de/fullrisk/citrusDev/UI/Module_FPS.java +++ b/src/main/java/de/fullrisk/citrusDev/UI/Module_FPS.java @@ -30,7 +30,14 @@ public class Module_FPS { CONFIG.fpsX = x; CONFIG.fpsY = y; 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() { diff --git a/src/main/java/de/fullrisk/citrusDev/UI/Module_KeyStrokes.java b/src/main/java/de/fullrisk/citrusDev/UI/Module_KeyStrokes.java index a2be002..43682a0 100644 --- a/src/main/java/de/fullrisk/citrusDev/UI/Module_KeyStrokes.java +++ b/src/main/java/de/fullrisk/citrusDev/UI/Module_KeyStrokes.java @@ -1,5 +1,7 @@ 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.UIComponents; import io.wispforest.owo.ui.container.FlowLayout; @@ -12,6 +14,8 @@ import net.minecraft.network.chat.Component; import net.minecraft.resources.Identifier; import de.fullrisk.citrusDev.Config; +import java.util.List; + public class Module_KeyStrokes { private static FlowLayout keyContainer; @@ -19,7 +23,7 @@ public class Module_KeyStrokes { private static FlowLayout bottomRow; 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; private static boolean shown = false; @@ -36,8 +40,9 @@ public class Module_KeyStrokes { private static final Surface GLASS_PANEL = Surface.blur(5f, 15f) .and(Surface.flat(0x40FFFFFF)); - private static final int KEY_SIZE = 16; - private static final int PRESSED_COLOR = 0xFF64de4b; + private static int keySize = 16; // was: private static final int KEY_SIZE = 16; + private static FlowLayout leftSpacer, rightSpacer; + private static final int PRESSED_COLOR = 0x70FFFFFF; private static final int IDLE_COLOR = 0x40FFFFFF; public static void setPosition(int x, int y) { @@ -52,22 +57,27 @@ public class Module_KeyStrokes { public static void register() { Hud.add(Identifier.fromNamespaceAndPath("citrus-dev", "keystrokes_display"), () -> { if (keyContainer == null) { - wLabel = UIComponents.label(Component.literal("W")); - aLabel = UIComponents.label(Component.literal("A")); - sLabel = UIComponents.label(Component.literal("S")); - dLabel = UIComponents.label(Component.literal("D")); + keySize = CONFIG.keySize > 0 ? CONFIG.keySize : 16; // load saved size, fallback to default + + wLabel = new ScalableLabel(Component.literal("W")); + aLabel = new ScalableLabel(Component.literal("A")); + sLabel = new ScalableLabel(Component.literal("S")); + dLabel = new ScalableLabel(Component.literal("D")); wBox = makeKeyBox(wLabel); aBox = makeKeyBox(aLabel); sBox = makeKeyBox(sLabel); 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.gap(2); 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(UIContainers.horizontalFlow(Sizing.fixed(KEY_SIZE), Sizing.fixed(KEY_SIZE))); // spacer + topRow.child(rightSpacer); bottomRow = UIContainers.horizontalFlow(Sizing.content(), Sizing.content()); bottomRow.gap(2); @@ -88,22 +98,47 @@ public class Module_KeyStrokes { }); } - private static FlowLayout makeKeyBox(LabelComponent label) { - FlowLayout box = UIContainers.verticalFlow(Sizing.fixed(KEY_SIZE), Sizing.fixed(KEY_SIZE)); + private static FlowLayout makeKeyBox(ScalableLabel label) { + FlowLayout box = UIContainers.verticalFlow(Sizing.fixed(keySize), Sizing.fixed(keySize)); box.horizontalAlignment(HorizontalAlignment.CENTER); box.verticalAlignment(VerticalAlignment.CENTER); box.surface(Surface.flat(IDLE_COLOR)); + + label.scale().set(new ScaleValue(labelScaleFor(keySize))); box.child(label); 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() { if (keyContainer == null) return; if (toggle && !shown) { keyContainer.clearChildren(); // <-- safety net against duplicate adds - keyContainer.surface(GLASS_PANEL); - keyContainer.padding(Insets.of(Config.get().fpsP)); + // keyContainer.surface(GLASS_PANEL); + keyContainer.padding(Insets.of(4)); keyContainer.child(topRow); keyContainer.child(bottomRow); shown = true; diff --git a/src/main/java/de/fullrisk/citrusDev/UI/MyScreen.java b/src/main/java/de/fullrisk/citrusDev/UI/MyScreen.java index f8d2632..94390c1 100644 --- a/src/main/java/de/fullrisk/citrusDev/UI/MyScreen.java +++ b/src/main/java/de/fullrisk/citrusDev/UI/MyScreen.java @@ -377,20 +377,22 @@ public class MyScreen extends BaseOwoScreen { new SettingsControls.ButtonState("L-BOTTOM", () -> Module_FPS.setPosition(1, 99)) ); - FlowLayout sizeSlider = SettingsControls.makeSlider( + FlowLayout paddingSlider = SettingsControls.makeSlider( FLAT, 80, - 0.0, 20.0, - 4.0, + 0.0, 15.0, + Config.get().fpsSize, 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); return List.of( 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 sizeSlider = SettingsControls.makeSlider( FLAT, 80, - 0.0, 20.0, - 4.0, + 10.0, 30.0, + Config.get().keySize, 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); diff --git a/src/main/java/de/fullrisk/citrusDev/UI/QuestsPanel.java b/src/main/java/de/fullrisk/citrusDev/UI/QuestsPanel.java index a8cda9b..b4577ee 100644 --- a/src/main/java/de/fullrisk/citrusDev/UI/QuestsPanel.java +++ b/src/main/java/de/fullrisk/citrusDev/UI/QuestsPanel.java @@ -110,7 +110,7 @@ public class QuestsPanel { summaryRow.padding(Insets.of(3, 0, 2, 2)); 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)))) .color(Color.ofRgb(0xa3a3ac))); @@ -152,10 +152,10 @@ public class QuestsPanel { private static List quests() { return List.of( - new QuestData("First Steps", "Play for 5 minutes", 300), - new QuestData("Getting Started", "Play for 30 minutes", 1800), - new QuestData("Dedicated Player", "Play for 1 hour", 3600), - new QuestData("Veteran", "Play for 3 hours", 10800) + new QuestData("first steps", "Play for 5 minutes", 300), + new QuestData("getting started", "Play for 30 minutes", 1800), + new QuestData("dedicated player", "Play for 1 hour", 3600), + new QuestData("veteran", "Play for 3 hours", 10800) ); } diff --git a/src/main/java/de/fullrisk/citrusDev/client/CitrusDevClient.java b/src/main/java/de/fullrisk/citrusDev/client/CitrusDevClient.java index 243ecf8..398d1dc 100644 --- a/src/main/java/de/fullrisk/citrusDev/client/CitrusDevClient.java +++ b/src/main/java/de/fullrisk/citrusDev/client/CitrusDevClient.java @@ -17,7 +17,6 @@ import org.lwjgl.glfw.GLFW; public class CitrusDevClient implements ClientModInitializer { private static KeyMapping openScreenKey; - private static KeyMapping openOverviewKey; @Override public void onInitializeClient() { @@ -29,11 +28,6 @@ public class CitrusDevClient implements ClientModInitializer { openScreenKey = KeyMappingHelper.registerKeyMapping(new KeyMapping( "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, category )); @@ -45,15 +39,15 @@ public class CitrusDevClient implements ClientModInitializer { Module_FPS.tick(); Module_KeyStrokes.tick(); - while (openScreenKey.consumeClick()) { - client.setScreen(new MyScreen(null)); // always general tab - } - while (openOverviewKey.consumeClick()) { - String lastModule = Config.get().lastModule; - client.setScreen(new MyScreen(lastModule)); // switch no longer even needed + while (openScreenKey.consumeClick()) { + if (client.player != null && client.player.isShiftKeyDown()) { + String lastModule = Config.get().lastModule; + client.setScreen(new MyScreen(lastModule)); // sneak + RShift: last module + } else { + client.setScreen(new MyScreen(null)); // RShift alone: general tab + } } - }); } } \ No newline at end of file diff --git a/src/main/resources/en_us.json b/src/main/resources/assets/citrus-dev/lang/en_us.json similarity index 100% rename from src/main/resources/en_us.json rename to src/main/resources/assets/citrus-dev/lang/en_us.json