aboutsummaryrefslogtreecommitdiff
path: root/GuiTest
diff options
context:
space:
mode:
authorJuuz <6596629+Juuxel@users.noreply.github.com>2021-05-27 19:38:15 +0300
committerJuuz <6596629+Juuxel@users.noreply.github.com>2021-05-27 19:38:15 +0300
commitda554fce60f1cba794a9c062b3ded81caf1f57b9 (patch)
treebbb3c8cc374391856f44064074e2b7d709024be6 /GuiTest
parent24aec1403fc9e3f1868e66b90bc83dacdb07ca06 (diff)
downloadLibGui-da554fce60f1cba794a9c062b3ded81caf1f57b9.tar.gz
LibGui-da554fce60f1cba794a9c062b3ded81caf1f57b9.tar.bz2
LibGui-da554fce60f1cba794a9c062b3ded81caf1f57b9.zip
Replace bad 9patch with LibNinePatch, fix bug with ItemIcon
Also adds nicer tests with client-side commands. /libgui config: opens the config GUI without Mod Menu /libgui tab: opens a tab test GUI
Diffstat (limited to 'GuiTest')
-rw-r--r--GuiTest/src/main/java/io/github/cottonmc/test/client/LibGuiTestClient.java28
-rw-r--r--GuiTest/src/main/java/io/github/cottonmc/test/client/TabTestGui.java26
2 files changed, 52 insertions, 2 deletions
diff --git a/GuiTest/src/main/java/io/github/cottonmc/test/client/LibGuiTestClient.java b/GuiTest/src/main/java/io/github/cottonmc/test/client/LibGuiTestClient.java
index 65efe75..1780808 100644
--- a/GuiTest/src/main/java/io/github/cottonmc/test/client/LibGuiTestClient.java
+++ b/GuiTest/src/main/java/io/github/cottonmc/test/client/LibGuiTestClient.java
@@ -1,11 +1,17 @@
package io.github.cottonmc.test.client;
+import net.fabricmc.api.ClientModInitializer;
+import net.fabricmc.fabric.api.client.command.v1.ClientCommandManager;
+import net.fabricmc.fabric.api.client.screenhandler.v1.ScreenRegistry;
+
+import io.github.cottonmc.cotton.gui.client.CottonClientScreen;
import io.github.cottonmc.cotton.gui.client.CottonHud;
import io.github.cottonmc.cotton.gui.client.CottonInventoryScreen;
+import io.github.cottonmc.cotton.gui.impl.modmenu.ConfigGui;
import io.github.cottonmc.test.LibGuiTest;
import io.github.cottonmc.test.TestDescription;
-import net.fabricmc.api.ClientModInitializer;
-import net.fabricmc.fabric.api.client.screenhandler.v1.ScreenRegistry;
+
+import static net.fabricmc.fabric.api.client.command.v1.ClientCommandManager.literal;
public class LibGuiTestClient implements ClientModInitializer {
@@ -17,6 +23,24 @@ public class LibGuiTestClient implements ClientModInitializer {
);
CottonHud.INSTANCE.add(new WHudTest(), 10, -20, 10, 10);
+
+ ClientCommandManager.DISPATCHER.register(
+ literal("libgui")
+ .then(literal("config").executes(context -> {
+ var client = context.getSource().getClient();
+ client.send(() -> {
+ client.openScreen(new CottonClientScreen(new ConfigGui(client.currentScreen)));
+ });
+ return 0;
+ }))
+ .then(literal("tab").executes(context -> {
+ var client = context.getSource().getClient();
+ client.send(() -> {
+ client.openScreen(new CottonClientScreen(new TabTestGui()));
+ });
+ return 0;
+ }))
+ );
}
}
diff --git a/GuiTest/src/main/java/io/github/cottonmc/test/client/TabTestGui.java b/GuiTest/src/main/java/io/github/cottonmc/test/client/TabTestGui.java
new file mode 100644
index 0000000..6fa716d
--- /dev/null
+++ b/GuiTest/src/main/java/io/github/cottonmc/test/client/TabTestGui.java
@@ -0,0 +1,26 @@
+package io.github.cottonmc.test.client;
+
+import net.minecraft.item.Items;
+import net.minecraft.text.LiteralText;
+
+import io.github.cottonmc.cotton.gui.client.LightweightGuiDescription;
+import io.github.cottonmc.cotton.gui.impl.modmenu.WKirbSprite;
+import io.github.cottonmc.cotton.gui.widget.WLabel;
+import io.github.cottonmc.cotton.gui.widget.WTabPanel;
+import io.github.cottonmc.cotton.gui.widget.icon.ItemIcon;
+
+public class TabTestGui extends LightweightGuiDescription {
+ public TabTestGui() {
+ WTabPanel tabs = new WTabPanel();
+ tabs.add(new WKirbSprite(), builder -> builder.title(new LiteralText("Kirb")));
+ tabs.add(new WLabel(new LiteralText("just another tab")), builder -> builder.icon(new ItemIcon(Items.ANDESITE)));
+
+ tabs.setSize(7 * 18, 5 * 18);
+ setRootPanel(tabs);
+ getRootPanel().validate(this);
+ }
+
+ @Override
+ public void addPainters() {
+ }
+}