From c82111365b52fe4710a4192a16ca5df70510949d Mon Sep 17 00:00:00 2001 From: Juuz <6596629+Juuxel@users.noreply.github.com> Date: Sun, 26 Nov 2023 17:24:52 +0200 Subject: Add ghost item icons Closes #228. --- .../cottonmc/test/client/GhostIconTestGui.java | 26 ++++++++++++++++++++++ .../cottonmc/test/client/LibGuiTestClient.java | 1 + 2 files changed, 27 insertions(+) create mode 100644 src/testMod/java/io/github/cottonmc/test/client/GhostIconTestGui.java (limited to 'src/testMod/java/io') diff --git a/src/testMod/java/io/github/cottonmc/test/client/GhostIconTestGui.java b/src/testMod/java/io/github/cottonmc/test/client/GhostIconTestGui.java new file mode 100644 index 0000000..34c9737 --- /dev/null +++ b/src/testMod/java/io/github/cottonmc/test/client/GhostIconTestGui.java @@ -0,0 +1,26 @@ +package io.github.cottonmc.test.client; + +import net.minecraft.item.Items; +import net.minecraft.text.Text; + +import io.github.cottonmc.cotton.gui.client.LightweightGuiDescription; +import io.github.cottonmc.cotton.gui.widget.WButton; +import io.github.cottonmc.cotton.gui.widget.WGridPanel; +import io.github.cottonmc.cotton.gui.widget.WToggleButton; +import io.github.cottonmc.cotton.gui.widget.icon.ItemIcon; + +public class GhostIconTestGui extends LightweightGuiDescription { + public GhostIconTestGui() { + WGridPanel root = (WGridPanel) rootPanel; + root.setGaps(2, 2); + + ItemIcon icon = new ItemIcon(Items.CACTUS); + WButton button = new WButton(icon, Text.literal("Hello world")); + WToggleButton ghostToggle = new WToggleButton(Text.literal("Ghost")); + ghostToggle.setOnToggle(icon::setGhost); + + root.add(button, 0, 0, 5, 1); + root.add(ghostToggle, 0, 1, 5, 1); + root.validate(this); + } +} diff --git a/src/testMod/java/io/github/cottonmc/test/client/LibGuiTestClient.java b/src/testMod/java/io/github/cottonmc/test/client/LibGuiTestClient.java index aef04ed..0674761 100644 --- a/src/testMod/java/io/github/cottonmc/test/client/LibGuiTestClient.java +++ b/src/testMod/java/io/github/cottonmc/test/client/LibGuiTestClient.java @@ -71,6 +71,7 @@ public class LibGuiTestClient implements ClientModInitializer { .then(literal("texture").executes(openScreen(client -> new TextureTestGui()))) .then(literal("textalignment").executes(openScreen(client -> new TextAlignmentTestGui()))) .then(literal("list").executes(openScreen(client -> new ListTestGui()))) + .then(literal("ghosticon").executes(openScreen(client -> new GhostIconTestGui()))) )); } -- cgit