2026-07-05 21:14:50 +02:00
|
|
|
package de.fullrisk.citrusDev.UI;
|
|
|
|
|
|
|
|
|
|
import io.wispforest.owo.ui.base.BaseOwoScreen;
|
|
|
|
|
import io.wispforest.owo.ui.component.LabelComponent;
|
|
|
|
|
import io.wispforest.owo.ui.component.UIComponents;
|
|
|
|
|
import io.wispforest.owo.ui.container.FlowLayout;
|
|
|
|
|
import io.wispforest.owo.ui.container.UIContainers;
|
|
|
|
|
import io.wispforest.owo.ui.core.*;
|
|
|
|
|
import net.minecraft.client.Minecraft;
|
|
|
|
|
import net.minecraft.client.resources.sounds.SimpleSoundInstance;
|
|
|
|
|
import net.minecraft.network.chat.Component;
|
2026-07-06 20:59:35 +02:00
|
|
|
import net.minecraft.resources.Identifier;
|
2026-07-05 21:14:50 +02:00
|
|
|
import net.minecraft.sounds.SoundEvents;
|
|
|
|
|
import de.fullrisk.citrusDev.UIHelper.ScalableLabel;
|
|
|
|
|
import de.fullrisk.citrusDev.UIHelper.ScalableButton;
|
|
|
|
|
import de.fullrisk.citrusDev.UIHelper.ScaleValue;
|
|
|
|
|
|
|
|
|
|
public class MyScreen extends BaseOwoScreen<FlowLayout> {
|
|
|
|
|
|
2026-07-06 20:59:35 +02:00
|
|
|
private static final Identifier MC_FIVE = Identifier.fromNamespaceAndPath("citrus-dev", "minecraft_five");
|
|
|
|
|
|
2026-07-05 21:14:50 +02:00
|
|
|
public MyScreen() {
|
|
|
|
|
super(Component.literal("Citrus Dev"));
|
|
|
|
|
Minecraft.getInstance().getSoundManager().play(
|
|
|
|
|
SimpleSoundInstance.forUI(SoundEvents.UI_TOAST_IN, 1.5F, 2)
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
protected OwoUIAdapter<FlowLayout> createAdapter() {
|
|
|
|
|
return OwoUIAdapter.create(this, UIContainers::verticalFlow);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
protected void build(FlowLayout rootComponent) {
|
|
|
|
|
rootComponent.gap(0);
|
|
|
|
|
rootComponent
|
|
|
|
|
.horizontalAlignment(HorizontalAlignment.CENTER)
|
|
|
|
|
.verticalAlignment(VerticalAlignment.CENTER);
|
|
|
|
|
|
|
|
|
|
// ----- Main panel (now a horizontal container: sidebar | divider | content) -----
|
|
|
|
|
FlowLayout panel = UIContainers.horizontalFlow(Sizing.content(), Sizing.content());
|
|
|
|
|
panel.gap(0);
|
|
|
|
|
panel.padding(Insets.of(2));
|
|
|
|
|
|
|
|
|
|
panel.horizontalAlignment(HorizontalAlignment.CENTER);
|
|
|
|
|
panel.verticalAlignment(VerticalAlignment.CENTER);
|
|
|
|
|
panel.horizontalSizing(Sizing.fixed(0));
|
|
|
|
|
panel.verticalSizing(Sizing.fixed(0));
|
|
|
|
|
panel.horizontalSizing().animate(300, Easing.CUBIC, Sizing.fixed(250)).forwards();
|
|
|
|
|
panel.verticalSizing().animate(300, Easing.CUBIC, Sizing.fixed(150)).forwards();
|
|
|
|
|
|
|
|
|
|
// inner content area, accounting for panel's 2px padding on each side
|
|
|
|
|
int innerHeight = 150 - 4; // 146
|
|
|
|
|
int sidebarWidth = 34;
|
|
|
|
|
int dividerWidth = 1;
|
|
|
|
|
int contentWidth = 250 - 4 - sidebarWidth - dividerWidth; // 211
|
|
|
|
|
|
|
|
|
|
// ----- Sidebar -----
|
|
|
|
|
FlowLayout sidebar = UIContainers.verticalFlow(Sizing.fixed(sidebarWidth), Sizing.fixed(innerHeight));
|
|
|
|
|
sidebar.horizontalAlignment(HorizontalAlignment.CENTER);
|
2026-07-06 18:52:02 +02:00
|
|
|
sidebar.verticalAlignment(VerticalAlignment.TOP);
|
2026-07-05 21:14:50 +02:00
|
|
|
sidebar.padding(Insets.of(4));
|
|
|
|
|
sidebar.gap(2);
|
|
|
|
|
|
|
|
|
|
var sidebarButton = new ScalableButton(Component.literal("+"), btn -> {
|
|
|
|
|
Minecraft.getInstance().getSoundManager().play(
|
|
|
|
|
SimpleSoundInstance.forUI(SoundEvents.UI_BUTTON_CLICK.value(), 2.0F, 2)
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
0x80FFFFFF, // base fill
|
|
|
|
|
0xA0FFFFFF, // hovered fill
|
|
|
|
|
0xFFFFFFFF, // base outline
|
|
|
|
|
0xFFFFFFFF, // hovered outline
|
|
|
|
|
1 // outline width
|
|
|
|
|
);
|
|
|
|
|
sidebarButton.horizontalSizing(Sizing.fixed(20));
|
|
|
|
|
sidebarButton.verticalSizing(Sizing.fixed(20));
|
|
|
|
|
sidebarButton.scale().animate(300, Easing.CUBIC, new ScaleValue(1f)).forwards();
|
|
|
|
|
|
2026-07-06 18:52:02 +02:00
|
|
|
var friendsButton = new ScalableButton(Component.literal("-"), btn -> {
|
|
|
|
|
Minecraft.getInstance().getSoundManager().play(
|
|
|
|
|
SimpleSoundInstance.forUI(SoundEvents.UI_BUTTON_CLICK.value(), 2.0F, 2)
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
0x80FFFFFF, // base fill
|
|
|
|
|
0xA0FFFFFF, // hovered fill
|
|
|
|
|
0xFFFFFFFF, // base outline
|
|
|
|
|
0xFFFFFFFF, // hovered outline
|
|
|
|
|
1 // outline width
|
|
|
|
|
);
|
|
|
|
|
friendsButton.horizontalSizing(Sizing.fixed(20));
|
|
|
|
|
friendsButton.verticalSizing(Sizing.fixed(20));
|
|
|
|
|
friendsButton.scale().animate(300, Easing.CUBIC, new ScaleValue(1f)).forwards();
|
|
|
|
|
|
2026-07-06 20:59:35 +02:00
|
|
|
// --- Sidebar Button Animations (Pop-in) ---
|
|
|
|
|
sidebarButton.scale().set(new ScaleValue(0f));
|
|
|
|
|
sidebarButton.scale().animate(400, Easing.CUBIC, new ScaleValue(1f)).forwards();
|
|
|
|
|
|
|
|
|
|
friendsButton.scale().set(new ScaleValue(0f));
|
|
|
|
|
friendsButton.scale().animate(430, Easing.CUBIC, new ScaleValue(1f)).forwards();
|
|
|
|
|
|
|
|
|
|
// --- Sidebar Button Hover Interactions ---
|
|
|
|
|
sidebarButton.mouseEnter().subscribe(() -> sidebarButton.scale().animate(120, Easing.CUBIC, new ScaleValue(1.1f)).forwards());
|
|
|
|
|
sidebarButton.mouseLeave().subscribe(() -> sidebarButton.scale().animate(120, Easing.CUBIC, new ScaleValue(1.0f)).forwards());
|
|
|
|
|
|
|
|
|
|
friendsButton.mouseEnter().subscribe(() -> friendsButton.scale().animate(120, Easing.CUBIC, new ScaleValue(1.1f)).forwards());
|
|
|
|
|
friendsButton.mouseLeave().subscribe(() -> friendsButton.scale().animate(120, Easing.CUBIC, new ScaleValue(1.0f)).forwards());
|
|
|
|
|
|
2026-07-06 18:52:02 +02:00
|
|
|
sidebar.child(friendsButton);
|
2026-07-05 21:14:50 +02:00
|
|
|
sidebar.child(sidebarButton);
|
|
|
|
|
panel.child(sidebar);
|
|
|
|
|
|
|
|
|
|
// ----- Divider -----
|
|
|
|
|
FlowLayout divider = UIContainers.verticalFlow(Sizing.fixed(dividerWidth), Sizing.fixed(innerHeight));
|
|
|
|
|
divider.surface(Surface.flat(0x80FFFFFF)); // subtle line, matches glass aesthetic
|
|
|
|
|
panel.child(divider);
|
|
|
|
|
|
|
|
|
|
// ----- Content column (header, button, version) -----
|
|
|
|
|
FlowLayout content = UIContainers.verticalFlow(Sizing.fixed(contentWidth), Sizing.fixed(innerHeight));
|
|
|
|
|
content.gap(6);
|
|
|
|
|
content.horizontalAlignment(HorizontalAlignment.CENTER);
|
|
|
|
|
content.verticalAlignment(VerticalAlignment.CENTER);
|
|
|
|
|
panel.child(content);
|
|
|
|
|
|
|
|
|
|
var header = new ScalableLabel(Component.literal("Citrus Dev"));
|
|
|
|
|
content.child(header);
|
|
|
|
|
|
|
|
|
|
var header_button = new ScalableButton(Component.literal("Click me"), btn -> {
|
|
|
|
|
btn.setMessage(Component.literal("Clicked!"));
|
|
|
|
|
Minecraft.getInstance().getSoundManager().play(
|
|
|
|
|
SimpleSoundInstance.forUI(SoundEvents.UI_BUTTON_CLICK.value(), 2.0F, 2)
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
0x80FFFFFF, // base fill
|
|
|
|
|
0xA0FFFFFF, // hovered fill
|
|
|
|
|
0xFFFFFFFF, // base outline
|
|
|
|
|
0xFFFFFFFF, // hovered outline
|
|
|
|
|
1 // outline width
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
header_button.scale().animate(300, Easing.CUBIC, new ScaleValue(1f)).forwards();
|
|
|
|
|
header_button.margins(Insets.top(6));
|
|
|
|
|
content.child(header_button);
|
|
|
|
|
header.scale().animate(300, Easing.CUBIC, new ScaleValue(2f)).forwards();
|
|
|
|
|
|
|
|
|
|
Surface glassPanel = Surface.blur(5f, 15f)
|
|
|
|
|
.and(Surface.flat(0x40FFFFFF))
|
|
|
|
|
.and(Surface.outline(0xFFFFFFFF));
|
|
|
|
|
|
|
|
|
|
panel.surface(glassPanel);
|
|
|
|
|
|
|
|
|
|
var version = new ScalableLabel(Component.literal("Citrus-Dev v2.0"));
|
|
|
|
|
version.horizontalTextAlignment(HorizontalAlignment.RIGHT);
|
|
|
|
|
version.verticalTextAlignment(VerticalAlignment.BOTTOM);
|
|
|
|
|
version.horizontalSizing(Sizing.fixed(202));
|
|
|
|
|
version.verticalSizing(Sizing.fixed(12));
|
2026-07-06 20:59:35 +02:00
|
|
|
version.positioning(Positioning.relative(125, 100)); // bottom-right corner of `panel`
|
2026-07-05 21:14:50 +02:00
|
|
|
|
|
|
|
|
version.scale().set(new ScaleValue(0.7f));
|
|
|
|
|
|
|
|
|
|
panel.child(version);
|
|
|
|
|
|
|
|
|
|
rootComponent.child(panel);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public boolean isPauseScreen() {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|