aboutsummaryrefslogtreecommitdiff
path: root/GuiTest/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'GuiTest/src/main/java')
-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() {
+ }
+}