Files
src
build.gradle
gradle.properties
manifest.kod
settings.gradle
Code
9 323
src/client/java/com/sasti/smp/pausemenu/SastiPauseMenuScreen.java
package com.sasti.smp.pausemenu;
import io.wispforest.owo.ui.base.BaseOwoScreen;
import io.wispforest.owo.ui.component.ButtonComponent;
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.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.options.OptionsScreen;
import net.minecraft.network.chat.Component;
import org.jetbrains.annotations.NotNull;
import java.util.List;
public final class SastiPauseMenuScreen extends BaseOwoScreen<FlowLayout> {
private static final int GOLD = 0xD7B15B;
private static final int MUTED = 0xA9A4A1;
private FlowLayout root;
private final SastiPauseMenuConfig config;
public SastiPauseMenuScreen() {
super(Component.literal("SASTI SMP"));
this.config = SastiPauseMenuConfig.load();
}
@Override
protected @NotNull OwoUIAdapter<FlowLayout> createAdapter() {
return OwoUIAdapter.create(this, UIContainers::verticalFlow);
}
@Override
protected void build(FlowLayout root) {
this.root = root;
root.alignment(HorizontalAlignment.CENTER, VerticalAlignment.CENTER);
root.surface((graphics, component) -> {
int x = component.x();
int y = component.y();
int width = component.width();
int height = component.height();
graphics.drawGradientRect(x, y, width, height, 0xEF070609, 0xE610080A, 0xEF050507, 0xEF090609);
graphics.fill(x, y, x + width, y + 2, 0xB8A12B35);
graphics.fill(x, y + height - 2, x + width, y + height, 0x806B4A22);
});
FlowLayout panel = UIContainers.verticalFlow(Sizing.fixed(320), Sizing.content());
panel.padding(Insets.of(14));
panel.gap(7);
panel.surface((graphics, component) -> {
int x = component.x();
int y = component.y();
int width = component.width();
int height = component.height();
graphics.drawGradientRect(x, y, width, height, 0xF0180D10, 0xF0120A0D, 0xF009090B, 0xF0120C0E);
graphics.drawRectOutline(x, y, width, height, 0xFFD7B15B);
graphics.drawRectOutline(x + 2, y + 2, width - 4, height - 4, 0x704B2323);
});
LabelComponent title = UIComponents.label(Component.literal("SASTI SMP"));
title.color(Color.ofRgb(GOLD));
title.shadow(true);
title.horizontalSizing(Sizing.fill(100));
title.horizontalTextAlignment(HorizontalAlignment.CENTER);
panel.child(title);
LabelComponent subtitle = UIComponents.label(Component.literal("COMMUNITY SERVER • PAUSE MENU"));
subtitle.color(Color.ofRgb(MUTED));
subtitle.horizontalSizing(Sizing.fill(100));
subtitle.horizontalTextAlignment(HorizontalAlignment.CENTER);
panel.child(subtitle);
panel.child(UIComponents.box(Sizing.fill(100), Sizing.fixed(1))
.fill(true)
.color(Color.ofArgb(0xBBD7B15B)));
panel.child(this.button("RESUME GAME", () -> Minecraft.getInstance().gui.setScreen(null)));
panel.child(this.button("SASTI SMP SERVER", () -> this.showInfo("SERVER INFORMATION", List.of(
"Server: " + this.config.serverName,
"Address: " + this.config.serverAddress
))));
panel.child(this.button("DISCORD", () -> this.showInfo("SASTI SMP DISCORD", List.of(
this.config.discordInvite
))));
panel.child(this.button("SETTINGS", () -> {
Minecraft minecraft = Minecraft.getInstance();
minecraft.gui.setScreen(new OptionsScreen(this, minecraft.options));
}));
panel.child(this.button("FEEDBACK", () -> this.showInfo("FEEDBACK", List.of(
this.config.feedbackUrl
))));
panel.child(this.button("QUIT GAME", () -> Minecraft.getInstance().stop()));
LabelComponent footer = UIComponents.label(Component.literal("A COMMUNITY BUILT TO LAST"));
footer.color(Color.ofRgb(0x817A75));
footer.horizontalSizing(Sizing.fill(100));
footer.horizontalTextAlignment(HorizontalAlignment.CENTER);
panel.child(footer);
root.child(panel);
}
private ButtonComponent button(String text, Runnable action) {
ButtonComponent button = UIComponents.button(Component.literal(text), component -> action.run());
button.renderer(ButtonComponent.Renderer.flat(0xFF281116, 0xFF54151D, 0xFF241B1D));
button.textShadow(false);
button.horizontalSizing(Sizing.fill(100));
return button;
}
private void showInfo(String title, List<String> lines) {
FlowLayout dialog = UIContainers.verticalFlow(Sizing.fixed(280), Sizing.content());
dialog.padding(Insets.of(12));
dialog.gap(8);
dialog.surface((graphics, component) -> {
int x = component.x();
int y = component.y();
int width = component.width();
int height = component.height();
graphics.fill(x, y, x + width, y + height, 0xF00B090A);
graphics.drawRectOutline(x, y, width, height, 0xFFD7B15B);
});
LabelComponent heading = UIComponents.label(Component.literal(title));
heading.color(Color.ofRgb(GOLD));
heading.shadow(true);
dialog.child(heading);
for (String line : lines) {
LabelComponent detail = UIComponents.label(Component.literal(line));
detail.color(Color.ofRgb(0xE8E2DC));
detail.maxWidth(252);
dialog.child(detail);
}
dialog.child(UIComponents.button(Component.literal("CLOSE"), button -> dialog.parent().remove()));
root.child(UIContainers.overlay(dialog).closeOnClick(false));
}
}