Added Quests and Real Settings (yay)

This commit is contained in:
2026-07-11 10:46:47 +02:00
parent d3fc829dee
commit 652fe728e1
7 changed files with 392 additions and 77 deletions
@@ -0,0 +1,102 @@
package de.fullrisk.citrusDev.UIHelper;
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;
import net.minecraft.network.chat.FontDescription;
import net.minecraft.resources.Identifier;
import net.minecraft.sounds.SoundEvents;
public class ModuleRow {
/** Bridge to whatever boolean field actually holds the module's on/off state. */
public interface ToggleState {
boolean get();
void set(boolean value);
}
public static FlowLayout build(
Surface enabledSurface,
Surface disabledSurface,
Surface flatSurface,
Identifier icon,
int iconWidth,
int iconHeight,
Identifier titleFont,
String title,
String description,
ToggleState state,
Identifier settingsIcon,
Runnable onSettingsClick,
String enabledToastTitle,
String enabledToastMessage,
String disabledToastTitle,
String disabledToastMessage
) {
FlowLayout row = UIContainers.horizontalFlow(Sizing.content(), Sizing.content());
row.gap(8);
row.verticalAlignment(VerticalAlignment.TOP);
row.horizontalAlignment(HorizontalAlignment.CENTER);
row.padding(Insets.of(6));
row.horizontalSizing(Sizing.fixed(0));
row.verticalSizing(Sizing.fixed(0));
row.surface(state.get() ? enabledSurface : disabledSurface);
row.child(UIComponents.texture(icon, 0, 0, iconWidth, iconHeight, iconWidth, iconHeight))
.horizontalAlignment(HorizontalAlignment.LEFT)
.verticalAlignment(VerticalAlignment.CENTER);
FlowLayout textStack = UIContainers.verticalFlow(Sizing.content(), Sizing.content());
textStack.gap(2);
textStack.horizontalAlignment(HorizontalAlignment.LEFT);
textStack.verticalAlignment(VerticalAlignment.CENTER);
var titleLabel = UIComponents.label(
Component.literal(title)
.withStyle(style -> style.withFont(new FontDescription.Resource(titleFont)))
);
titleLabel.color(Color.ofRgb(state.get() ? 0xffffff : 0x797b86));
textStack.child(titleLabel);
textStack.child(UIComponents.label(Component.literal(description))
.color(Color.ofRgb(0xa3a3ac))
.maxWidth(130));
row.child(textStack);
row.child(UIComponents.spacer());
FlowLayout settingsButton = SettingsControls.makeSmallButton(flatSurface, settingsIcon, onSettingsClick);
row.child(settingsButton);
row.mouseEnter().subscribe(() -> row.surface(state.get() ? enabledSurface : disabledSurface));
row.mouseLeave().subscribe(() -> row.surface(state.get() ? enabledSurface : disabledSurface));
row.mouseDown().subscribe((click, doubled) -> {
boolean newState = !state.get();
state.set(newState);
titleLabel.color(Color.ofRgb(newState ? 0xffffff : 0x797b86));
row.surface(newState ? enabledSurface : disabledSurface);
if (newState) {
CitrusToast.show(enabledToastTitle, enabledToastMessage);
} else {
CitrusToast.show(disabledToastTitle, disabledToastMessage);
}
Minecraft.getInstance().getSoundManager().play(
SimpleSoundInstance.forUI(SoundEvents.UI_BUTTON_CLICK.value(), 2.0F, 2)
);
return true;
});
row.horizontalSizing().animate(150, Easing.CUBIC, Sizing.fixed(200)).forwards();
row.verticalSizing().animate(150, Easing.CUBIC, Sizing.fixed(35)).forwards();
return row;
}
}