Moved hats and emotes to common

This commit is contained in:
2026-03-07 18:19:25 +01:00
parent fd5a438292
commit 9c6deeb5c0
7 changed files with 226 additions and 72 deletions
@@ -0,0 +1,17 @@
package org.saturnclient.cosmetics;
import java.util.ArrayList;
import java.util.List;
public class Emotes {
public static List<String> availableEmotes = new ArrayList<>();
public static void initialize() {
availableEmotes.add("tpose");
availableEmotes.add("back_flip");
availableEmotes.add("facepalm");
availableEmotes.add("cry");
availableEmotes.add("giga_chad");
availableEmotes.add("front_flip");
}
}
@@ -0,0 +1,31 @@
package org.saturnclient.cosmetics;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import org.saturnclient.client.ServiceClient;
import org.saturnclient.client.player.SaturnPlayer;
public class Hats {
public static final String[] ALL_HATS = { "horns_black", "horns_white", "halo", "halo_black" };
public static List<String> availableHats = new ArrayList<>();
public static void initialize() {
availableHats.add(0, "");
}
public static void setHat(String hatName) {
if (availableHats.contains(hatName)) {
setHat(ServiceClient.uuid, hatName);
ServiceClient.setHat(hatName);
}
}
public static void setHat(UUID uuid, String hatName) {
SaturnPlayer player = SaturnPlayer.get(uuid);
if (player != null) {
player.hat = hatName;
}
}
}
@@ -0,0 +1,111 @@
package org.saturnclient.ui.screens;
import org.saturnclient.cosmetics.Emotes;
import org.saturnclient.client.ServiceClient;
import org.saturnclient.common.minecraft.bindings.SaturnClientBindings;
import org.saturnclient.config.AnimationConfig;
import org.saturnclient.config.Config;
import org.saturnclient.ui.SaturnScreen;
import org.saturnclient.ui.Utils;
import org.saturnclient.ui.anim.Fade;
import org.saturnclient.ui.anim.SlideY;
import org.saturnclient.ui.elements.AnimationStagger;
import org.saturnclient.ui.elements.ImageTexture;
import org.saturnclient.ui.elements.TextureButton;
import org.saturnclient.ui.resources.Textures;
public class EmoteWheel extends SaturnScreen {
int page = 1;
public EmoteWheel() {
super("Emote Wheel");
}
@Override
public void ui() {
int row = 0;
int col = 0;
// =============================
// Logo
// =============================
draw(new ImageTexture(Textures.LOGO_TEXT)
.dimensions(98, 10)
.centerOffset(width, height, 0, -105)
.animation(new Fade(AnimationConfig.logo.duration.value)));
draw(new ImageTexture(Config.getLogo())
.dimensions(98, 98)
.centerOffset(width, height, 0, -149)
.animation(new SlideY(AnimationConfig.logo, -20)));
// =============================
// Navigation Buttons
// =============================
draw(new TextureButton(Textures.LEFT, () -> {
if (page > 1) {
page--;
elements.clear();
ui();
}
}).dimensions(30, 30)
.centerOffset(width, height, -50, 105)
.animation(new Fade(500)));
draw(new TextureButton(Textures.RIGHT, () -> {
if ((page * 8) < Emotes.availableEmotes.size()) {
page++;
elements.clear();
ui();
}
}).dimensions(30, 30)
.centerOffset(width, height, 50, 105)
.animation(new Fade(500)));
// =============================
// Emote Grid (Staggered)
// =============================
AnimationStagger emoteStagger = new AnimationStagger(AnimationConfig.emoteWheel);
while (row < 3) {
int idx = (row * 3 + col) + ((page - 1) * 8);
if (row == 1 && col == 1) {
col++;
}
String emote = Utils.getOrNull(Emotes.availableEmotes, idx);
emoteStagger.draw(
new TextureButton(Textures.getEmotePreview(emote), () -> {
if (emote != null)
SaturnClientBindings.emotes().setEmote(ServiceClient.uuid, emote);
provider.close();
})
.dimensions(70, 70)
.centerOffset(width, height,
-80 + (col * 80),
-35 + (row * 80))
.animation(new SlideY(AnimationConfig.emoteWheel, 12)));
if (col < 2) {
col++;
} else {
col = 0;
row++;
}
}
draw(emoteStagger);
}
@Override
public boolean shouldPause() {
return false;
}
}
@@ -38,20 +38,20 @@ public class CloakMenu extends SaturnScreen {
if (player != null) { if (player != null) {
// for (String cloak : Cloaks.availableCloaks) { // for (String cloak : Cloaks.availableCloaks) {
// stagger.draw( // stagger.draw(
// new CosmeticPreview( // new CosmeticPreview(
// cloak == player.cloak, // cloak == player.cloak,
// Textures.getCloakPreview(cloak), // Textures.getCloakPreview(cloak),
// () -> Cloaks.setCloak(cloak)) // () -> Cloaks.setCloak(cloak))
// .position((50 + g) * col, (111 + g) * row) // .position((50 + g) * col, (111 + g) * row)
// .animation(new SlideY(AnimationConfig.cosmeticsMenu, 14))); // .animation(new SlideY(AnimationConfig.cosmeticsMenu, 14)));
// if (col == 5) { // if (col == 5) {
// col = 0; // col = 0;
// row++; // row++;
// } else { // } else {
// col++; // col++;
// } // }
// } // }
} }
@@ -69,8 +69,7 @@ public class CloakMenu extends SaturnScreen {
.animation(new Fade(500))); .animation(new Fade(500)));
draw(new Sidebar(2, this.provider::close) draw(new Sidebar(2, this.provider::close)
.centerOffset(width, height, -(scrollWidth / 2 + 20), 0) .centerOffset(width, height, -(scrollWidth / 2 + 20), 0));
.animation(new Fade(400)));
draw(new TabMenu(0, draw(new TabMenu(0,
new TabMenuComponent(Textures.CLOAK, () -> { new TabMenuComponent(Textures.CLOAK, () -> {
@@ -1,9 +1,9 @@
package org.saturnclient.ui.screens.cosmetics; package org.saturnclient.ui.screens.cosmetics;
import org.saturnclient.client.player.SaturnPlayer; import org.saturnclient.client.player.SaturnPlayer;
// import org.saturnclient.cosmetics.hat.Hats;
import org.saturnclient.common.minecraft.MinecraftProvider; import org.saturnclient.common.minecraft.MinecraftProvider;
import org.saturnclient.config.AnimationConfig; import org.saturnclient.config.AnimationConfig;
import org.saturnclient.cosmetics.Hats;
import org.saturnclient.ui.SaturnScreen; import org.saturnclient.ui.SaturnScreen;
import org.saturnclient.ui.anim.Fade; import org.saturnclient.ui.anim.Fade;
import org.saturnclient.ui.anim.SlideY; import org.saturnclient.ui.anim.SlideY;
@@ -36,24 +36,23 @@ public class HatMenu extends SaturnScreen {
AnimationStagger stagger = new AnimationStagger(AnimationConfig.cosmeticsMenu); AnimationStagger stagger = new AnimationStagger(AnimationConfig.cosmeticsMenu);
if (player != null) { if (player != null) {
// for (String hat : Hats.availableHats) { for (String hat : Hats.availableHats) {
stagger.draw(
new CosmeticPreview(
hat == player.hat,
Textures.getHatPreview(hat),
() -> Hats.setHat(hat))
.dimensions(50, 50)
.position((50 + g) * col, (50 + g) * row)
.animation(new SlideY(AnimationConfig.cosmeticsMenu, 14)));
// stagger.draw( if (col == 5) {
// new CosmeticPreview( col = 0;
// hat == player.hat, row++;
// Textures.getHatPreview(hat), } else {
// () -> Hats.setHat(hat)) col++;
// .dimensions(50, 50) }
// .position((50 + g) * col, (50 + g) * row) }
// .animation(new SlideY(AnimationConfig.cosmeticsMenu, 14)));
// if (col == 5) {
// col = 0;
// row++;
// } else {
// col++;
// }
// }
} }
scroll.draw(stagger); scroll.draw(stagger);
@@ -70,8 +69,7 @@ public class HatMenu extends SaturnScreen {
.animation(new Fade(500))); .animation(new Fade(500)));
draw(new Sidebar(2, this.provider::close) draw(new Sidebar(2, this.provider::close)
.centerOffset(width, height, -(scrollWidth / 2 + 20), 0) .centerOffset(width, height, -(scrollWidth / 2 + 20), 0));
.animation(new Fade(400)));
draw(new TabMenu(1, draw(new TabMenu(1,
new TabMenuComponent(Textures.CLOAK, () -> { new TabMenuComponent(Textures.CLOAK, () -> {
@@ -98,8 +98,7 @@ public class CloakStore extends SaturnScreen {
.centerOffset(width, height, 15, 0)); .centerOffset(width, height, 15, 0));
draw(new Sidebar(5, this.provider::close) draw(new Sidebar(5, this.provider::close)
.centerOffset(width, height, -((scrollWidth - 30) / 2 + 20), 0) .centerOffset(width, height, -((scrollWidth - 30) / 2 + 20), 0));
.animation(new Fade(400)));
draw(new TabMenu(0, draw(new TabMenu(0,
new TabMenuComponent(Textures.CLOAK, () -> { new TabMenuComponent(Textures.CLOAK, () -> {
@@ -1,11 +1,11 @@
package org.saturnclient.ui.screens.store; package org.saturnclient.ui.screens.store;
// import org.saturnclient.cosmetics.hat.Hats;
import org.saturnclient.client.ServiceClient; import org.saturnclient.client.ServiceClient;
import org.saturnclient.client.player.SaturnPlayer; import org.saturnclient.client.player.SaturnPlayer;
import org.saturnclient.common.minecraft.MinecraftProvider; import org.saturnclient.common.minecraft.MinecraftProvider;
import org.saturnclient.config.AnimationConfig; import org.saturnclient.config.AnimationConfig;
import org.saturnclient.config.Theme; import org.saturnclient.config.Theme;
import org.saturnclient.cosmetics.Hats;
import org.saturnclient.ui.SaturnScreen; import org.saturnclient.ui.SaturnScreen;
import org.saturnclient.ui.anim.Fade; import org.saturnclient.ui.anim.Fade;
import org.saturnclient.ui.anim.SlideY; import org.saturnclient.ui.anim.SlideY;
@@ -50,44 +50,44 @@ public class HatStore extends SaturnScreen {
AnimationStagger stagger = new AnimationStagger(AnimationConfig.cosmeticsMenu); AnimationStagger stagger = new AnimationStagger(AnimationConfig.cosmeticsMenu);
if (player != null) { if (player != null) {
// for (String hat : Hats.ALL_HATS) { for (String hat : Hats.ALL_HATS) {
// if (!Hats.availableHats.contains(hat)) { if (!Hats.availableHats.contains(hat)) {
// int x = (50 + gx) * col; int x = (50 + gx) * col;
// int y = (50 + gy) * row; int y = (50 + gy) * row;
// stagger.draw( stagger.draw(
// new CosmeticPreview( new CosmeticPreview(
// hat == player.hat, hat == player.hat,
// Textures.getHatPreview(hat), Textures.getHatPreview(hat),
// () -> handlePurchase(hat)) () -> handlePurchase(hat))
// .dimensions(50, 50) .dimensions(50, 50)
// .position(x, y) .position(x, y)
// .animation(new SlideY(AnimationConfig.cosmeticsMenu, 16))); .animation(new SlideY(AnimationConfig.cosmeticsMenu, 16)));
// String t = "50"; String t = "50";
// stagger.draw( stagger.draw(
// new Text(t) new Text(t)
// .position(x + Fonts.centerX(50, t, Theme.FONT.value), y + 53) .position(x + Fonts.centerX(50, t, Theme.FONT.value), y + 53)
// .scale(0.5f) .scale(0.5f)
// .animation(new Fade(400))); .animation(new Fade(400)));
// stagger.draw( stagger.draw(
// new ImageTexture(Textures.COINS) new ImageTexture(Textures.COINS)
// .dimensions(16, 16) .dimensions(16, 16)
// .position(x + Fonts.getWidth(t, Theme.FONT.value) + 4, y + 52) .position(x + Fonts.getWidth(t, Theme.FONT.value) + 4, y + 52)
// .scale(0.5f) .scale(0.5f)
// .animation(new Fade(400))); .animation(new Fade(400)));
// if (col == 8) { if (col == 8) {
// col = 0; col = 0;
// row++; row++;
// } else { } else {
// col++; col++;
// } }
// } }
// } }
} }
scroll.draw(stagger); scroll.draw(stagger);
@@ -99,8 +99,7 @@ public class HatStore extends SaturnScreen {
.centerOffset(width, height, 15, 0)); .centerOffset(width, height, 15, 0));
draw(new Sidebar(5, this.provider::close) draw(new Sidebar(5, this.provider::close)
.centerOffset(width, height, -((scrollWidth - 30) / 2 + 20), 0) .centerOffset(width, height, -((scrollWidth - 30) / 2 + 20), 0));
.animation(new Fade(400)));
draw(new TabMenu(1, draw(new TabMenu(1,
new TabMenuComponent(Textures.CLOAK, () -> { new TabMenuComponent(Textures.CLOAK, () -> {