This commit is contained in:
2026-01-02 20:46:08 +01:00
parent 7f9c20ab7d
commit 335b1596af
3 changed files with 52 additions and 45 deletions

BIN
espacio.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 217 KiB

BIN
omg.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 199 KiB

View File

@@ -23,6 +23,7 @@ public class SddConfigScreen extends Screen {
private static final int ROW_WIDTH = 310; private static final int ROW_WIDTH = 310;
private static final int COLUMN_WIDTH = 150; private static final int COLUMN_WIDTH = 150;
private static final int COLUMN_GAP = 10; private static final int COLUMN_GAP = 10;
private static final int GROUP_GAP = 8;
private final Screen parent; private final Screen parent;
private final SddConfig cfg; private final SddConfig cfg;
@@ -30,7 +31,7 @@ public class SddConfigScreen extends Screen {
private SettingsList list; private SettingsList list;
public SddConfigScreen(Screen parent) { public SddConfigScreen(Screen parent) {
super(Text.literal("Smooth Double Doors Settings")); super(Text.literal("Smooth Double Doors - Settings"));
this.parent = parent; this.parent = parent;
this.cfg = SddConfigManager.get(); this.cfg = SddConfigManager.get();
} }
@@ -54,66 +55,55 @@ public class SddConfigScreen extends Screen {
list = layout.addBody(new SettingsList(this.client, this.width, layout)); list = layout.addBody(new SettingsList(this.client, this.width, layout));
list.addEntry(new SettingsEntry( list.addEntry(new SettingsEntry(
toggle(COLUMN_WIDTH, () -> "Doors | Use: " + (cfg.connectDoors ? "ON" : "OFF"), toggle(COLUMN_WIDTH, () -> "Double Doors: " + (cfg.connectDoors ? "ON" : "OFF"),
() -> cfg.connectDoors = !cfg.connectDoors), () -> cfg.connectDoors = !cfg.connectDoors),
toggle(COLUMN_WIDTH, () -> "Doors | Redstone: " + (cfg.redstoneDoubleDoors ? "ON" : "OFF"), toggle(COLUMN_WIDTH, () -> "Redstone Activable: " + (cfg.redstoneDoubleDoors ? "ON" : "OFF"),
() -> cfg.redstoneDoubleDoors = !cfg.redstoneDoubleDoors) () -> cfg.redstoneDoubleDoors = !cfg.redstoneDoubleDoors)
)); ));
list.addEntry(new SettingsEntry( list.addEntry(new SettingsEntry(
toggle(COLUMN_WIDTH, () -> "Traps | Use: " + (cfg.connectTrapdoors ? "ON" : "OFF"), toggle(COLUMN_WIDTH, () -> "Door Animation: " + (cfg.animateDoors ? "ON" : "OFF"),
() -> cfg.connectTrapdoors = !cfg.connectTrapdoors),
toggle(COLUMN_WIDTH, () -> "Traps | Redstone: " + (cfg.redstoneDoubleTrapdoors ? "ON" : "OFF"),
() -> cfg.redstoneDoubleTrapdoors = !cfg.redstoneDoubleTrapdoors)
));
list.addEntry(new SettingsEntry(
toggle(COLUMN_WIDTH, () -> "Gates | Use: " + (cfg.connectFenceGates ? "ON" : "OFF"),
() -> cfg.connectFenceGates = !cfg.connectFenceGates),
toggle(COLUMN_WIDTH, () -> "Gates | Redstone: " + (cfg.redstoneDoubleFenceGates ? "ON" : "OFF"),
() -> cfg.redstoneDoubleFenceGates = !cfg.redstoneDoubleFenceGates)
));
list.addEntry(new SettingsEntry(
toggle(ROW_WIDTH, () -> "Animation Doors: " + (cfg.animateDoors ? "ON" : "OFF"),
() -> cfg.animateDoors = !cfg.animateDoors), () -> cfg.animateDoors = !cfg.animateDoors),
null new SpeedSlider(COLUMN_WIDTH, "Animation Speed", cfg.doorSpeed, v -> {
));
list.addEntry(new SettingsEntry(
toggle(ROW_WIDTH, () -> "Animation Traps: " + (cfg.animateTrapdoors ? "ON" : "OFF"),
() -> cfg.animateTrapdoors = !cfg.animateTrapdoors),
null
));
list.addEntry(new SettingsEntry(
toggle(ROW_WIDTH, () -> "Animation Gates: " + (cfg.animateFenceGates ? "ON" : "OFF"),
() -> cfg.animateFenceGates = !cfg.animateFenceGates),
null
));
list.addEntry(new SettingsEntry(
new SpeedSlider(ROW_WIDTH, "Speed Doors", cfg.doorSpeed, v -> {
cfg.doorSpeed = v; cfg.doorSpeed = v;
SddConfigManager.save(); SddConfigManager.save();
}), })
null
)); ));
list.addEntry(new SettingsEntry( list.addEntry(new SettingsEntry(
new SpeedSlider(ROW_WIDTH, "Speed Traps", cfg.trapdoorSpeed, v -> { toggle(COLUMN_WIDTH, () -> "Double Trapdoors: " + (cfg.connectTrapdoors ? "ON" : "OFF"),
() -> cfg.connectTrapdoors = !cfg.connectTrapdoors),
toggle(COLUMN_WIDTH, () -> "Redstone Activable: " + (cfg.redstoneDoubleTrapdoors ? "ON" : "OFF"),
() -> cfg.redstoneDoubleTrapdoors = !cfg.redstoneDoubleTrapdoors),
GROUP_GAP
));
list.addEntry(new SettingsEntry(
toggle(COLUMN_WIDTH, () -> "Trapdoor Animation: " + (cfg.animateTrapdoors ? "ON" : "OFF"),
() -> cfg.animateTrapdoors = !cfg.animateTrapdoors),
new SpeedSlider(COLUMN_WIDTH, "Animation Speed", cfg.trapdoorSpeed, v -> {
cfg.trapdoorSpeed = v; cfg.trapdoorSpeed = v;
SddConfigManager.save(); SddConfigManager.save();
}), }),
null GROUP_GAP
)); ));
list.addEntry(new SettingsEntry( list.addEntry(new SettingsEntry(
new SpeedSlider(ROW_WIDTH, "Speed Gates", cfg.fenceGateSpeed, v -> { toggle(COLUMN_WIDTH, () -> "Double Fence Gates: " + (cfg.connectFenceGates ? "ON" : "OFF"),
() -> cfg.connectFenceGates = !cfg.connectFenceGates),
toggle(COLUMN_WIDTH, () -> "Redstone Activable: " + (cfg.redstoneDoubleFenceGates ? "ON" : "OFF"),
() -> cfg.redstoneDoubleFenceGates = !cfg.redstoneDoubleFenceGates),
GROUP_GAP * 2
));
list.addEntry(new SettingsEntry(
toggle(COLUMN_WIDTH, () -> "Fence Gate Animation: " + (cfg.animateFenceGates ? "ON" : "OFF"),
() -> cfg.animateFenceGates = !cfg.animateFenceGates),
new SpeedSlider(COLUMN_WIDTH, "Animation Speed", cfg.fenceGateSpeed, v -> {
cfg.fenceGateSpeed = v; cfg.fenceGateSpeed = v;
SddConfigManager.save(); SddConfigManager.save();
}), }),
null GROUP_GAP * 2
)); ));
} }
@@ -167,19 +157,35 @@ public class SddConfigScreen extends Screen {
private final ClickableWidget left; private final ClickableWidget left;
private final ClickableWidget right; private final ClickableWidget right;
private final List<ClickableWidget> widgets; private final List<ClickableWidget> widgets;
private final int topPadding;
SettingsEntry(ClickableWidget left, ClickableWidget right) { SettingsEntry(ClickableWidget left, ClickableWidget right) {
this(left, right, 0);
}
SettingsEntry(ClickableWidget left, ClickableWidget right, int topPadding) {
this.left = left; this.left = left;
this.right = right; this.right = right;
this.widgets = (right == null) ? List.of(left) : List.of(left, right); this.topPadding = topPadding;
if (left == null && right == null) {
this.widgets = List.of();
} else if (right == null) {
this.widgets = List.of(left);
} else {
this.widgets = List.of(left, right);
}
} }
@Override @Override
public void render(DrawContext context, int index, int y, int x, int entryWidth, int entryHeight, public void render(DrawContext context, int index, int y, int x, int entryWidth, int entryHeight,
int mouseX, int mouseY, boolean hovered, float delta) { int mouseX, int mouseY, boolean hovered, float delta) {
if (left == null && right == null) {
return;
}
if (right == null) { if (right == null) {
if (left == null) return;
left.setX(x); left.setX(x);
left.setY(y); left.setY(y + topPadding);
left.render(context, mouseX, mouseY, delta); left.render(context, mouseX, mouseY, delta);
return; return;
} }
@@ -187,9 +193,9 @@ public class SddConfigScreen extends Screen {
int leftX = x; int leftX = x;
int rightX = x + COLUMN_WIDTH + COLUMN_GAP; int rightX = x + COLUMN_WIDTH + COLUMN_GAP;
left.setX(leftX); left.setX(leftX);
left.setY(y); left.setY(y + topPadding);
right.setX(rightX); right.setX(rightX);
right.setY(y); right.setY(y + topPadding);
left.render(context, mouseX, mouseY, delta); left.render(context, mouseX, mouseY, delta);
right.render(context, mouseX, mouseY, delta); right.render(context, mouseX, mouseY, delta);
} }
@@ -205,6 +211,7 @@ public class SddConfigScreen extends Screen {
} }
} }
private static class SpeedSlider extends SliderWidget { private static class SpeedSlider extends SliderWidget {
private final String label; private final String label;
private final java.util.function.Consumer<Float> onApply; private final java.util.function.Consumer<Float> onApply;