Files
src
build.gradle
gradle.properties
manifest.kod
settings.gradle
Code
17 287
src/client/java/dev/kodari/compactinterface/OptionsHubScreen.java
package dev.kodari.compactinterface;
import com.terraformersmc.modmenu.api.ModMenuApi;
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.Color;
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.Minecraft;
import net.minecraft.client.gui.screens.CreditsAndAttributionScreen;
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.client.gui.screens.options.AccessibilityOptionsScreen;
import net.minecraft.client.gui.screens.options.ChatOptionsScreen;
import net.minecraft.client.gui.screens.options.LanguageSelectScreen;
import net.minecraft.client.gui.screens.options.OptionsScreen;
import net.minecraft.client.gui.screens.options.SkinCustomizationScreen;
import net.minecraft.client.gui.screens.options.SoundOptionsScreen;
import net.minecraft.client.gui.screens.options.VideoSettingsScreen;
import net.minecraft.client.gui.screens.options.controls.ControlsScreen;
import net.minecraft.network.chat.Component;
import org.jetbrains.annotations.NotNull;
import java.util.function.Supplier;
public final class OptionsHubScreen extends BaseOwoScreen<FlowLayout> {
private final Screen parent;
public OptionsHubScreen(Screen parent) {
super(Component.translatable("options.title"));
this.parent = parent;
}
@Override
protected @NotNull OwoUIAdapter<FlowLayout> createAdapter() {
return OwoUIAdapter.create(this, UIContainers::verticalFlow);
}
@Override
protected void build(FlowLayout root) {
Minecraft mc = Minecraft.getInstance();
root.surface(Surface.flat(0xE0080C14));
root.alignment(HorizontalAlignment.CENTER, VerticalAlignment.CENTER);
FlowLayout panel = UIContainers.verticalFlow(Sizing.fixed(Math.max (120, Math.min(320, this.width - 16))), Sizing.fill(90));
panel.padding(Insets.of(12));
panel.gap(8);
panel.surface(Surface.flat(0xF01B2130).and(Surface.outline(0xFF405166)));
var heading = UIComponents.label(Component.translatable("options.title"));
heading.color(Color.ofRgb(0x4FD1C5));
heading.shadow(true);
panel.child(heading);
FlowLayout entries = UIContainers.verticalFlow(Sizing.fill(100), Sizing.content());
entries.gap(4);
entries.margins(Insets.right(5));
add(entries, "options.skinCustomisation", () -> new SkinCustomizationScreen(this, mc.options));
add(entries, "options.video", () -> new VideoSettingsScreen(this, mc, mc.options));
add(entries, "options.language", () -> new LanguageSelectScreen(this, mc.options, mc.getLanguageManager()));
add(entries, "options.sounds", () -> new SoundOptionsScreen(this, mc.options));
add(entries, "options.controls", () -> new ControlsScreen(this, mc.options));
add(entries, "options.chat", () -> new ChatOptionsScreen(this, mc.options));
add(entries, "options.accessibility", () -> new AccessibilityOptionsScreen(this, mc.options));
add(entries, "options.credits_and_attribution", () -> new CreditsAndAttributionScreen(this));
add(entries, "compact_interface.mods", () -> ModMenuApi.createModsScreen(this));
add(entries, "compact_interface.original_options", () -> new OptionsScreen(this, mc.options));
panel.child(UIContainers.verticalScroll(Sizing.fill(100), Sizing.expand(), entries));
ButtonComponent done = UIComponents.button(Component.translatable("gui.done"), button -> this.onClose());
done.renderer(ButtonComponent.Renderer.flat(0xFF284E53, 0xFF39737A, 0xFF30343D));
done.horizontalSizing(Sizing.fill(100));
panel.child(done);
root.child(panel);
}
private void add(FlowLayout entries, String key, Supplier<Screen> target) {
ButtonComponent button = UIComponents.button(Component.translatable(key), ignored -> Minecraft.getInstance().gui.setScreen(target.get()));
button.renderer(ButtonComponent.Renderer.flat(0xFF263346, 0xFF38536A, 0xFF30343D));
button.horizontalSizing(Sizing.fill(100));
entries.child(button);
}
@Override
public void onClose() {
Minecraft.getInstance().gui.setScreen(this.parent);
}
}