Give the title screen the shift menu's logo and wordmark, bring the menus up under it, and make the dock smaller with a settings item. Co-Authored-By: Claude Opus 5.5 <[email protected]>
127 lines
5.8 KiB
Java
127 lines
5.8 KiB
Java
package org.saturnclient.ui.screens;
|
|
|
|
import java.util.List;
|
|
|
|
import org.saturnclient.common.provider.Providers;
|
|
import org.saturnclient.common.ref.game.MinecraftClientRef.MinecraftScreen;
|
|
import org.saturnclient.config.AnimationConfig;
|
|
import org.saturnclient.config.Config;
|
|
import org.saturnclient.config.property.FloatProperty;
|
|
import org.saturnclient.config.Theme;
|
|
import org.saturnclient.ui.Element;
|
|
import org.saturnclient.ui.SaturnScreen;
|
|
import org.saturnclient.ui.anim.Fade;
|
|
import org.saturnclient.ui.anim.SlideFade;
|
|
import org.saturnclient.ui.anim.SlideY;
|
|
import org.saturnclient.ui.components.AccountChip;
|
|
import org.saturnclient.ui.components.Dock;
|
|
import org.saturnclient.ui.elements.AnimationStagger;
|
|
import org.saturnclient.ui.elements.Button;
|
|
import org.saturnclient.ui.elements.ImageTexture;
|
|
import org.saturnclient.ui.elements.Label;
|
|
import org.saturnclient.ui.resources.Fonts;
|
|
import org.saturnclient.ui.resources.Textures;
|
|
|
|
/**
|
|
* Saturn's title screen: the logo over the game's menus in the middle, and
|
|
* along the bottom the player, a dock of Saturn's screens and the version.
|
|
*/
|
|
public class TitleMenu extends SaturnScreen {
|
|
// The logo and wordmark as the shift menu has them: the wordmark over the logo's foot
|
|
private static final int LOGO = 98;
|
|
private static final int WORDMARK_WIDTH = 98;
|
|
private static final int WORDMARK_HEIGHT = 10;
|
|
private static final int WORDMARK_Y = 88;
|
|
/** From the logo's foot to the menus, close so they read as one block */
|
|
private static final int MENUS_GAP = 14;
|
|
private static final int COLUMN_WIDTH = 280;
|
|
private static final int BUTTON_HEIGHT = 36;
|
|
private static final int GAP = 8;
|
|
private static final int EDGE = 28;
|
|
private static final float VERSION_SCALE = 0.62f;
|
|
|
|
public TitleMenu() {
|
|
super("Title Menu");
|
|
}
|
|
|
|
@Override
|
|
protected FloatProperty getScaleSetting() {
|
|
return Config.titleScale;
|
|
}
|
|
|
|
@Override
|
|
public void ui() {
|
|
blurBackground = false;
|
|
|
|
// Logo and menus, centered together a little above the middle
|
|
int menusHeight = BUTTON_HEIGHT * 3 + GAP * 2;
|
|
int blockHeight = LOGO + MENUS_GAP + menusHeight;
|
|
int top = (height - blockHeight) / 2 - 20;
|
|
|
|
draw(new ImageTexture(Config.getLogo())
|
|
.dimensions(LOGO, LOGO)
|
|
.position((width - LOGO) / 2, top)
|
|
.animation(new SlideY(AnimationConfig.logo, -20)));
|
|
draw(new ImageTexture(Textures.LOGO_TEXT)
|
|
.dimensions(WORDMARK_WIDTH, WORDMARK_HEIGHT)
|
|
.position((width - WORDMARK_WIDTH) / 2, top + WORDMARK_Y)
|
|
.animation(new Fade(AnimationConfig.logo.duration.value)));
|
|
|
|
int rowHeight = BUTTON_HEIGHT + GAP;
|
|
int halfWidth = (COLUMN_WIDTH - GAP) / 2;
|
|
AnimationStagger menus = new AnimationStagger(AnimationConfig.mainMenu);
|
|
|
|
addMenuButton(menus, new Button("Singleplayer",
|
|
() -> Providers.saturn.getClient().setScreen(MinecraftScreen.SelectWorld))
|
|
.dimensions(COLUMN_WIDTH, BUTTON_HEIGHT).position(0, 0));
|
|
addMenuButton(menus, new Button("Multiplayer",
|
|
() -> Providers.saturn.getClient().setScreen(MinecraftScreen.Multiplayer))
|
|
.dimensions(COLUMN_WIDTH, BUTTON_HEIGHT).position(0, rowHeight));
|
|
addMenuButton(menus, new Button("Options",
|
|
() -> Providers.saturn.getClient().setScreen(MinecraftScreen.Options))
|
|
.dimensions(halfWidth, BUTTON_HEIGHT).position(0, rowHeight * 2));
|
|
addMenuButton(menus, new Button("Quit",
|
|
() -> Providers.saturn.getClient().scheduleStop())
|
|
.dimensions(halfWidth, BUTTON_HEIGHT).position(COLUMN_WIDTH - halfWidth, rowHeight * 2));
|
|
|
|
draw(menus.position((width - COLUMN_WIDTH) / 2, top + LOGO + MENUS_GAP));
|
|
|
|
// Along the bottom: the player, Saturn's screens, the version
|
|
draw(new AccountChip()
|
|
.position(EDGE, height - EDGE - AccountChip.HEIGHT)
|
|
.animation(new Fade(AnimationConfig.mainMenu)));
|
|
|
|
Dock dock = new Dock(List.of(
|
|
new Dock.Item(Textures.ICON_MODS, () -> Providers.saturn.getClient().setScreen(new ModMenu())),
|
|
new Dock.Item(Textures.ICON_COSMETICS,
|
|
() -> Providers.saturn.getClient().setScreen(new CosmeticsMenu())),
|
|
new Dock.Item(Textures.ICON_HUD_EDITOR,
|
|
() -> Providers.saturn.getClient().setScreen(new HudEditor())),
|
|
new Dock.Item(Textures.ICON_SETTINGS,
|
|
() -> Providers.saturn.getClient().setScreen(new ClientSettings()))));
|
|
draw(dock.position((width - dock.width) / 2, height - EDGE - Dock.HEIGHT)
|
|
.animation(new SlideFade(AnimationConfig.mainMenu, 12)));
|
|
|
|
String version = getVersionText();
|
|
int versionWidth = (int) (Fonts.getWidth(version, Theme.getBodyFont()) * VERSION_SCALE);
|
|
int versionHeight = (int) (Fonts.getHeight() * VERSION_SCALE);
|
|
draw(new Label(() -> version, VERSION_SCALE, Theme::getBodyFont, Theme::getMutedFg)
|
|
.position(width - EDGE - versionWidth, height - EDGE - (AccountChip.HEIGHT + versionHeight) / 2)
|
|
.animation(new Fade(AnimationConfig.mainMenu)));
|
|
}
|
|
|
|
/**
|
|
* "Saturn Client 0.1.0 · Minecraft 1.21.11", from the mod version
|
|
* "0.1.0+1.21.11".
|
|
*/
|
|
private static String getVersionText() {
|
|
String[] version = Providers.saturn.getModVersion().split("\\+", 2);
|
|
String text = "Saturn Client " + version[0];
|
|
return version.length > 1 ? text + " · Minecraft " + version[1] : text;
|
|
}
|
|
|
|
private static void addMenuButton(AnimationStagger stagger, Element button) {
|
|
stagger.draw(button.animation(new SlideFade(AnimationConfig.mainMenu, -10)));
|
|
}
|
|
}
|