diff --git a/src/main/java/org/saturnclient/cosmetics/Emotes.java b/src/main/java/org/saturnclient/cosmetics/Emotes.java new file mode 100644 index 0000000..bc0353b --- /dev/null +++ b/src/main/java/org/saturnclient/cosmetics/Emotes.java @@ -0,0 +1,17 @@ +package org.saturnclient.cosmetics; + +import java.util.ArrayList; +import java.util.List; + +public class Emotes { + public static List 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"); + } +} diff --git a/src/main/java/org/saturnclient/cosmetics/Hats.java b/src/main/java/org/saturnclient/cosmetics/Hats.java new file mode 100644 index 0000000..37a8f74 --- /dev/null +++ b/src/main/java/org/saturnclient/cosmetics/Hats.java @@ -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 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; + } + } +} diff --git a/src/main/java/org/saturnclient/ui/screens/EmoteWheel.java b/src/main/java/org/saturnclient/ui/screens/EmoteWheel.java new file mode 100644 index 0000000..1e10a31 --- /dev/null +++ b/src/main/java/org/saturnclient/ui/screens/EmoteWheel.java @@ -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; + } +} diff --git a/src/main/java/org/saturnclient/ui/screens/cosmetics/CloakMenu.java b/src/main/java/org/saturnclient/ui/screens/cosmetics/CloakMenu.java index 2c43b4f..73338b8 100644 --- a/src/main/java/org/saturnclient/ui/screens/cosmetics/CloakMenu.java +++ b/src/main/java/org/saturnclient/ui/screens/cosmetics/CloakMenu.java @@ -38,20 +38,20 @@ public class CloakMenu extends SaturnScreen { if (player != null) { // for (String cloak : Cloaks.availableCloaks) { - // stagger.draw( - // new CosmeticPreview( - // cloak == player.cloak, - // Textures.getCloakPreview(cloak), - // () -> Cloaks.setCloak(cloak)) - // .position((50 + g) * col, (111 + g) * row) - // .animation(new SlideY(AnimationConfig.cosmeticsMenu, 14))); + // stagger.draw( + // new CosmeticPreview( + // cloak == player.cloak, + // Textures.getCloakPreview(cloak), + // () -> Cloaks.setCloak(cloak)) + // .position((50 + g) * col, (111 + g) * row) + // .animation(new SlideY(AnimationConfig.cosmeticsMenu, 14))); - // if (col == 5) { - // col = 0; - // row++; - // } else { - // col++; - // } + // if (col == 5) { + // col = 0; + // row++; + // } else { + // col++; + // } // } } @@ -69,8 +69,7 @@ public class CloakMenu extends SaturnScreen { .animation(new Fade(500))); draw(new Sidebar(2, this.provider::close) - .centerOffset(width, height, -(scrollWidth / 2 + 20), 0) - .animation(new Fade(400))); + .centerOffset(width, height, -(scrollWidth / 2 + 20), 0)); draw(new TabMenu(0, new TabMenuComponent(Textures.CLOAK, () -> { diff --git a/src/main/java/org/saturnclient/ui/screens/cosmetics/HatMenu.java b/src/main/java/org/saturnclient/ui/screens/cosmetics/HatMenu.java index 982fde3..ac24d38 100644 --- a/src/main/java/org/saturnclient/ui/screens/cosmetics/HatMenu.java +++ b/src/main/java/org/saturnclient/ui/screens/cosmetics/HatMenu.java @@ -1,9 +1,9 @@ package org.saturnclient.ui.screens.cosmetics; import org.saturnclient.client.player.SaturnPlayer; -// import org.saturnclient.cosmetics.hat.Hats; import org.saturnclient.common.minecraft.MinecraftProvider; import org.saturnclient.config.AnimationConfig; +import org.saturnclient.cosmetics.Hats; import org.saturnclient.ui.SaturnScreen; import org.saturnclient.ui.anim.Fade; import org.saturnclient.ui.anim.SlideY; @@ -36,24 +36,23 @@ public class HatMenu extends SaturnScreen { AnimationStagger stagger = new AnimationStagger(AnimationConfig.cosmeticsMenu); 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( - // 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))); - - // if (col == 5) { - // col = 0; - // row++; - // } else { - // col++; - // } - // } + if (col == 5) { + col = 0; + row++; + } else { + col++; + } + } } scroll.draw(stagger); @@ -70,8 +69,7 @@ public class HatMenu extends SaturnScreen { .animation(new Fade(500))); draw(new Sidebar(2, this.provider::close) - .centerOffset(width, height, -(scrollWidth / 2 + 20), 0) - .animation(new Fade(400))); + .centerOffset(width, height, -(scrollWidth / 2 + 20), 0)); draw(new TabMenu(1, new TabMenuComponent(Textures.CLOAK, () -> { diff --git a/src/main/java/org/saturnclient/ui/screens/store/CloakStore.java b/src/main/java/org/saturnclient/ui/screens/store/CloakStore.java index 7091ff7..eef8406 100644 --- a/src/main/java/org/saturnclient/ui/screens/store/CloakStore.java +++ b/src/main/java/org/saturnclient/ui/screens/store/CloakStore.java @@ -98,8 +98,7 @@ public class CloakStore extends SaturnScreen { .centerOffset(width, height, 15, 0)); draw(new Sidebar(5, this.provider::close) - .centerOffset(width, height, -((scrollWidth - 30) / 2 + 20), 0) - .animation(new Fade(400))); + .centerOffset(width, height, -((scrollWidth - 30) / 2 + 20), 0)); draw(new TabMenu(0, new TabMenuComponent(Textures.CLOAK, () -> { diff --git a/src/main/java/org/saturnclient/ui/screens/store/HatStore.java b/src/main/java/org/saturnclient/ui/screens/store/HatStore.java index d9d7c08..f0fd11b 100644 --- a/src/main/java/org/saturnclient/ui/screens/store/HatStore.java +++ b/src/main/java/org/saturnclient/ui/screens/store/HatStore.java @@ -1,11 +1,11 @@ package org.saturnclient.ui.screens.store; -// import org.saturnclient.cosmetics.hat.Hats; import org.saturnclient.client.ServiceClient; import org.saturnclient.client.player.SaturnPlayer; import org.saturnclient.common.minecraft.MinecraftProvider; import org.saturnclient.config.AnimationConfig; import org.saturnclient.config.Theme; +import org.saturnclient.cosmetics.Hats; import org.saturnclient.ui.SaturnScreen; import org.saturnclient.ui.anim.Fade; import org.saturnclient.ui.anim.SlideY; @@ -50,44 +50,44 @@ public class HatStore extends SaturnScreen { AnimationStagger stagger = new AnimationStagger(AnimationConfig.cosmeticsMenu); if (player != null) { - // for (String hat : Hats.ALL_HATS) { - // if (!Hats.availableHats.contains(hat)) { + for (String hat : Hats.ALL_HATS) { + if (!Hats.availableHats.contains(hat)) { - // int x = (50 + gx) * col; - // int y = (50 + gy) * row; + int x = (50 + gx) * col; + int y = (50 + gy) * row; - // stagger.draw( - // new CosmeticPreview( - // hat == player.hat, - // Textures.getHatPreview(hat), - // () -> handlePurchase(hat)) - // .dimensions(50, 50) - // .position(x, y) - // .animation(new SlideY(AnimationConfig.cosmeticsMenu, 16))); + stagger.draw( + new CosmeticPreview( + hat == player.hat, + Textures.getHatPreview(hat), + () -> handlePurchase(hat)) + .dimensions(50, 50) + .position(x, y) + .animation(new SlideY(AnimationConfig.cosmeticsMenu, 16))); - // String t = "50"; + String t = "50"; - // stagger.draw( - // new Text(t) - // .position(x + Fonts.centerX(50, t, Theme.FONT.value), y + 53) - // .scale(0.5f) - // .animation(new Fade(400))); + stagger.draw( + new Text(t) + .position(x + Fonts.centerX(50, t, Theme.FONT.value), y + 53) + .scale(0.5f) + .animation(new Fade(400))); - // stagger.draw( - // new ImageTexture(Textures.COINS) - // .dimensions(16, 16) - // .position(x + Fonts.getWidth(t, Theme.FONT.value) + 4, y + 52) - // .scale(0.5f) - // .animation(new Fade(400))); + stagger.draw( + new ImageTexture(Textures.COINS) + .dimensions(16, 16) + .position(x + Fonts.getWidth(t, Theme.FONT.value) + 4, y + 52) + .scale(0.5f) + .animation(new Fade(400))); - // if (col == 8) { - // col = 0; - // row++; - // } else { - // col++; - // } - // } - // } + if (col == 8) { + col = 0; + row++; + } else { + col++; + } + } + } } scroll.draw(stagger); @@ -99,8 +99,7 @@ public class HatStore extends SaturnScreen { .centerOffset(width, height, 15, 0)); draw(new Sidebar(5, this.provider::close) - .centerOffset(width, height, -((scrollWidth - 30) / 2 + 20), 0) - .animation(new Fade(400))); + .centerOffset(width, height, -((scrollWidth - 30) / 2 + 20), 0)); draw(new TabMenu(1, new TabMenuComponent(Textures.CLOAK, () -> {