Files
src
build.gradle
gradle.properties
manifest.kod
settings.gradle
Code
10 307
src/client/java/com/kodari/totemsoundoptions/client/TotemSoundScreen.java
package com.kodari.totemsoundoptions.client;
import com.kodari.totemsoundoptions.config.TotemSoundConfig;
import io.wispforest.owo.ui.base.BaseOwoScreen;
import io.wispforest.owo.ui.component.ButtonComponent;
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.HorizontalAlignment;
import io.wispforest.owo.ui.core.Insets;
import io.wispforest.owo.ui.core.OwoUIAdapter;
import io.wispforest.owo.ui.core.Sizing;
import io.wispforest.owo.ui.core.Surface;
import io.wispforest.owo.ui.core.VerticalAlignment;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.text.Text;
public final class TotemSoundScreen extends BaseOwoScreen<FlowLayout> {
private final Screen parent;
public TotemSoundScreen(Screen parent) {
super(Text.literal("Totem Pop Sound"));
this.parent = parent;
}
@Override
protected OwoUIAdapter<FlowLayout> createAdapter() {
return OwoUIAdapter.create(this, UIContainers::verticalFlow);
}
@Override
protected void build(FlowLayout root) {
root.surface(Surface.VANILLA_TRANSLUCENT);
root.alignment(HorizontalAlignment.CENTER, VerticalAlignment.CENTER);
FlowLayout panel = UIContainers.verticalFlow(Sizing.fixed(240), Sizing.content());
panel.padding(Insets.of(8));
panel.gap(5);
panel.surface(Surface.DARK_PANEL);
panel.child(UIComponents.label(Text.literal("Choose a sound for a totem save")));
String selectedSound = TotemSoundConfig.selectedSound();
for (TotemSoundConfig.SoundChoice choice : TotemSoundConfig.CHOICES) {
String marker = choice.id().equals(selectedSound) ? " [Selected]" : "";
ButtonComponent button = UIComponents.button(Text.literal(choice.label() + marker), clicked -> {
TotemSoundConfig.select(choice.id());
MinecraftClient.getInstance().setScreen(this.parent);
});
button.horizontalSizing(Sizing.fill(100));
panel.child(button);
}
ButtonComponent backButton = UIComponents.button(Text.literal("Back"), clicked -> MinecraftClient.getInstance().setScreen(this.parent));
backButton.horizontalSizing(Sizing.fill(100));
panel.child(backButton);
root.child(panel);
}
}