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
@@ -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() {
@@ -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;
@@ -377,20 +377,22 @@ public class MyScreen extends BaseOwoScreen<FlowLayout> {
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> {
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);
@@ -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<QuestData> 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)
);
}