aboutsummaryrefslogtreecommitdiff
path: root/src/testMod/java
diff options
context:
space:
mode:
Diffstat (limited to 'src/testMod/java')
-rw-r--r--src/testMod/java/io/github/cottonmc/test/GuiBlock.java37
-rw-r--r--src/testMod/java/io/github/cottonmc/test/GuiBlockEntity.java43
-rw-r--r--src/testMod/java/io/github/cottonmc/test/GuiItem.java55
-rw-r--r--src/testMod/java/io/github/cottonmc/test/ImplementedInventory.java213
-rw-r--r--src/testMod/java/io/github/cottonmc/test/LibGuiTest.java91
-rw-r--r--src/testMod/java/io/github/cottonmc/test/NoBlockInventoryBlock.java39
-rw-r--r--src/testMod/java/io/github/cottonmc/test/ReallySimpleDescription.java16
-rw-r--r--src/testMod/java/io/github/cottonmc/test/TestDescription.java78
-rw-r--r--src/testMod/java/io/github/cottonmc/test/TestItemDescription.java156
-rw-r--r--src/testMod/java/io/github/cottonmc/test/client/DarkModeTestGui.java49
-rw-r--r--src/testMod/java/io/github/cottonmc/test/client/GhostIconTestGui.java26
-rw-r--r--src/testMod/java/io/github/cottonmc/test/client/InsetsTestGui.java20
-rw-r--r--src/testMod/java/io/github/cottonmc/test/client/Issue182TestGui.java18
-rw-r--r--src/testMod/java/io/github/cottonmc/test/client/Issue196TestGui.java16
-rw-r--r--src/testMod/java/io/github/cottonmc/test/client/LibGuiTestClient.java89
-rw-r--r--src/testMod/java/io/github/cottonmc/test/client/ListTestGui.java137
-rw-r--r--src/testMod/java/io/github/cottonmc/test/client/PaddingTestGui.java35
-rw-r--r--src/testMod/java/io/github/cottonmc/test/client/ScrollBarTestGui.java65
-rw-r--r--src/testMod/java/io/github/cottonmc/test/client/ScrollingTestGui.java72
-rw-r--r--src/testMod/java/io/github/cottonmc/test/client/TabTestGui.java26
-rw-r--r--src/testMod/java/io/github/cottonmc/test/client/TestClientGui.java156
-rw-r--r--src/testMod/java/io/github/cottonmc/test/client/TextAlignmentTestGui.java75
-rw-r--r--src/testMod/java/io/github/cottonmc/test/client/TextFieldTestGui.java20
-rw-r--r--src/testMod/java/io/github/cottonmc/test/client/TextureTestGui.java94
-rw-r--r--src/testMod/java/io/github/cottonmc/test/client/TitleAlignmentTestGui.java35
-rw-r--r--src/testMod/java/io/github/cottonmc/test/client/WHudTest.java25
26 files changed, 0 insertions, 1686 deletions
diff --git a/src/testMod/java/io/github/cottonmc/test/GuiBlock.java b/src/testMod/java/io/github/cottonmc/test/GuiBlock.java
deleted file mode 100644
index 1b1666f..0000000
--- a/src/testMod/java/io/github/cottonmc/test/GuiBlock.java
+++ /dev/null
@@ -1,37 +0,0 @@
-package io.github.cottonmc.test;
-
-import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
-import net.minecraft.block.BlockRenderType;
-import net.minecraft.block.BlockState;
-import net.minecraft.block.BlockWithEntity;
-import net.minecraft.block.Blocks;
-import net.minecraft.block.entity.BlockEntity;
-import net.minecraft.entity.player.PlayerEntity;
-import net.minecraft.util.ActionResult;
-import net.minecraft.util.Hand;
-import net.minecraft.util.hit.BlockHitResult;
-import net.minecraft.util.math.BlockPos;
-import net.minecraft.world.World;
-
-public class GuiBlock extends BlockWithEntity {
-
- public GuiBlock() {
- super(FabricBlockSettings.copy(Blocks.IRON_BLOCK));
- }
-
- @Override
- public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hitResult) {
- player.openHandledScreen(state.createScreenHandlerFactory(world, pos));
- return ActionResult.SUCCESS;
- }
-
- @Override
- public BlockEntity createBlockEntity(BlockPos pos, BlockState state) {
- return new GuiBlockEntity(pos, state);
- }
-
- @Override
- public BlockRenderType getRenderType(BlockState state) {
- return BlockRenderType.MODEL;
- }
-}
diff --git a/src/testMod/java/io/github/cottonmc/test/GuiBlockEntity.java b/src/testMod/java/io/github/cottonmc/test/GuiBlockEntity.java
deleted file mode 100644
index 16e7e3f..0000000
--- a/src/testMod/java/io/github/cottonmc/test/GuiBlockEntity.java
+++ /dev/null
@@ -1,43 +0,0 @@
-package io.github.cottonmc.test;
-
-import net.minecraft.block.BlockState;
-import net.minecraft.block.entity.BlockEntity;
-import net.minecraft.entity.player.PlayerEntity;
-import net.minecraft.entity.player.PlayerInventory;
-import net.minecraft.item.ItemStack;
-import net.minecraft.screen.NamedScreenHandlerFactory;
-import net.minecraft.screen.ScreenHandler;
-import net.minecraft.screen.ScreenHandlerContext;
-import net.minecraft.text.Text;
-import net.minecraft.util.collection.DefaultedList;
-import net.minecraft.util.math.BlockPos;
-
-public class GuiBlockEntity extends BlockEntity implements ImplementedInventory, NamedScreenHandlerFactory {
- static final int INVENTORY_SIZE = 8;
-
- DefaultedList<ItemStack> items = DefaultedList.ofSize(INVENTORY_SIZE, ItemStack.EMPTY);
-
- public GuiBlockEntity(BlockPos pos, BlockState state) {
- super(LibGuiTest.GUI_BLOCKENTITY_TYPE, pos, state);
- }
-
- @Override
- public DefaultedList<ItemStack> getItems() {
- return items;
- }
-
- @Override
- public boolean canPlayerUse(PlayerEntity player) {
- return pos.isWithinDistance(player.getBlockPos(), 4.5);
- }
-
- @Override
- public Text getDisplayName() {
- return Text.literal("test title");
- }
-
- @Override
- public ScreenHandler createMenu(int syncId, PlayerInventory inv, PlayerEntity player) {
- return new TestDescription(LibGuiTest.GUI_SCREEN_HANDLER_TYPE, syncId, inv, ScreenHandlerContext.create(world, pos));
- }
-}
diff --git a/src/testMod/java/io/github/cottonmc/test/GuiItem.java b/src/testMod/java/io/github/cottonmc/test/GuiItem.java
deleted file mode 100644
index 27c8d5f..0000000
--- a/src/testMod/java/io/github/cottonmc/test/GuiItem.java
+++ /dev/null
@@ -1,55 +0,0 @@
-package io.github.cottonmc.test;
-
-import net.fabricmc.fabric.api.screenhandler.v1.ExtendedScreenHandlerFactory;
-import net.minecraft.entity.EquipmentSlot;
-import net.minecraft.entity.player.PlayerEntity;
-import net.minecraft.entity.player.PlayerInventory;
-import net.minecraft.inventory.StackReference;
-import net.minecraft.item.Item;
-import net.minecraft.item.ItemStack;
-import net.minecraft.network.PacketByteBuf;
-import net.minecraft.screen.NamedScreenHandlerFactory;
-import net.minecraft.screen.ScreenHandler;
-import net.minecraft.server.network.ServerPlayerEntity;
-import net.minecraft.text.Text;
-import net.minecraft.util.ActionResult;
-import net.minecraft.util.Hand;
-import net.minecraft.util.Rarity;
-import net.minecraft.util.TypedActionResult;
-import net.minecraft.world.World;
-
-public class GuiItem extends Item {
- public GuiItem() {
- super(new Item.Settings().rarity(Rarity.EPIC));
- }
-
- @Override
- public TypedActionResult<ItemStack> use(World world, PlayerEntity player, Hand hand) {
- player.openHandledScreen(createScreenHandlerFactory(player, hand));
- return new TypedActionResult<>(ActionResult.SUCCESS, player.getStackInHand(hand));
- }
-
- private NamedScreenHandlerFactory createScreenHandlerFactory(PlayerEntity player, Hand hand) {
- EquipmentSlot slot = switch (hand) {
- case MAIN_HAND -> EquipmentSlot.MAINHAND;
- case OFF_HAND -> EquipmentSlot.OFFHAND;
- };
- ItemStack stack = player.getStackInHand(hand);
- return new ExtendedScreenHandlerFactory() {
- @Override
- public Text getDisplayName() {
- return stack.getName();
- }
-
- @Override
- public ScreenHandler createMenu(int syncId, PlayerInventory playerInventory, PlayerEntity player) {
- return new TestItemDescription(syncId, playerInventory, StackReference.of(player, slot));
- }
-
- @Override
- public void writeScreenOpeningData(ServerPlayerEntity player, PacketByteBuf buf) {
- buf.writeEnumConstant(slot);
- }
- };
- }
-}
diff --git a/src/testMod/java/io/github/cottonmc/test/ImplementedInventory.java b/src/testMod/java/io/github/cottonmc/test/ImplementedInventory.java
deleted file mode 100644
index a1d3911..0000000
--- a/src/testMod/java/io/github/cottonmc/test/ImplementedInventory.java
+++ /dev/null
@@ -1,213 +0,0 @@
-package io.github.cottonmc.test;
-
-import net.minecraft.entity.player.PlayerEntity;
-import net.minecraft.inventory.Inventories;
-import net.minecraft.inventory.Inventory;
-import net.minecraft.inventory.SidedInventory;
-import net.minecraft.item.ItemStack;
-import net.minecraft.util.collection.DefaultedList;
-import net.minecraft.util.math.Direction;
-
-import java.util.List;
-
-/**
- * A simple {@code SidedInventory} implementation with only default methods + an item list getter.
- *
- * <h2>Reading and writing to tags</h2>
- * Use {@link Inventories#readNbt(net.minecraft.nbt.NbtCompound, DefaultedList)} and {@link Inventories#writeNbt(net.minecraft.nbt.NbtCompound, DefaultedList)}
- * on {@linkplain #getItems() the item list}.
- *
- * <p>License: <a href="https://creativecommons.org/publicdomain/zero/1.0/">CC0</a>
- *
- * @author Juuz
- */
-@FunctionalInterface
-public interface ImplementedInventory extends SidedInventory {
- /**
- * Gets the item list of this inventory.
- * Must return the same instance every time it's called.
- *
- * @return the item list
- */
- DefaultedList<ItemStack> getItems();
-
- // Creation
-
- /**
- * Creates an inventory from the item list.
- *
- * @param items the item list
- * @return a new inventory
- */
- static ImplementedInventory of(DefaultedList<ItemStack> items) {
- return () -> items;
- }
-
- /**
- * Creates a new inventory with the size.
- *
- * @param size the inventory size
- * @return a new inventory
- */
- static ImplementedInventory ofSize(int size) {
- return of(DefaultedList.ofSize(size, ItemStack.EMPTY));
- }
-
- // SidedInventory
-
- /**
- * Gets the available slots to automation on the side.
- *
- * <p>The default implementation returns an array of all slots.
- *
- * @param side the side
- * @return the available slots
- */
- @Override
- default int[] getAvailableSlots(Direction side) {
- int[] result = new int[getItems().size()];
- for (int i = 0; i < result.length; i++) {
- result[i] = i;
- }
-
- return result;
- }
-
- /**
- * Returns true if the stack can be inserted in the slot at the side.
- *
- * <p>The default implementation returns true.
- *
- * @param slot the slot
- * @param stack the stack
- * @param side the side
- * @return true if the stack can be inserted
- */
- @Override
- default boolean canInsert(int slot, ItemStack stack, Direction side) {
- return true;
- }
-
- /**
- * Returns true if the stack can be extracted from the slot at the side.
- *
- * <p>The default implementation returns true.
- *
- * @param slot the slot
- * @param stack the stack
- * @param side the side
- * @return true if the stack can be extracted
- */
- @Override
- default boolean canExtract(int slot, ItemStack stack, Direction side) {
- return true;
- }
-
- // Inventory
-
- /**
- * Returns the inventory size.
- *
- * <p>The default implementation returns the size of {@link #getItems()}.
- *
- * @return the inventory size
- */
- @Override
- default int size() {
- return getItems().size();
- }
-
- /**
- * @return true if this inventory has only empty stacks, false otherwise
- */
- @Override
- default boolean isEmpty() {
- for (int i = 0; i < size(); i++) {
- ItemStack stack = getStack(i);
- if (!stack.isEmpty()) {
- return false;
- }
- }
-
- return true;
- }
-
- /**
- * Gets the item in the slot.
- *
- * @param slot the slot
- * @return the item in the slot
- */
- @Override
- default ItemStack getStack(int slot) {
- return getItems().get(slot);
- }
-
- /**
- * Takes a stack of the size from the slot.
- *
- * <p>(default implementation) If there are less items in the slot than what are requested,
- * takes all items in that slot.
- *
- * @param slot the slot
- * @param count the item count
- * @return a stack
- */
- @Override
- default ItemStack removeStack(int slot, int count) {
- ItemStack result = Inventories.splitStack(getItems(), slot, count);
- if (!result.isEmpty()) {
- markDirty();
- }
-
- return result;
- }
-
- /**
- * Removes the current stack in the {@code slot} and returns it.
- *
- * <p>The default implementation uses {@link Inventories#removeStack(List, int)}
- *
- * @param slot the slot
- * @return the removed stack
- */
- @Override
- default ItemStack removeStack(int slot) {
- return Inventories.removeStack(getItems(), slot);
- }
-
- /**
- * Replaces the current stack in the {@code slot} with the provided stack.
- *
- * <p>If the stack is too big for this inventory ({@link Inventory#getMaxCountPerStack()} ()}),
- * it gets resized to this inventory's maximum amount.
- *
- * @param slot the slot
- * @param stack the stack
- */
- @Override
- default void setStack(int slot, ItemStack stack) {
- getItems().set(slot, stack);
- if (stack.getCount() > getMaxCountPerStack()) {
- stack.setCount(getMaxCountPerStack());
- }
- }
-
- /**
- * Clears {@linkplain #getItems() the item list}}.
- */
- @Override
- default void clear() {
- getItems().clear();
- }
-
- @Override
- default void markDirty() {
- // Override if you want behavior.
- }
-
- @Override
- default boolean canPlayerUse(PlayerEntity player) {
- return true;
- }
-}
diff --git a/src/testMod/java/io/github/cottonmc/test/LibGuiTest.java b/src/testMod/java/io/github/cottonmc/test/LibGuiTest.java
deleted file mode 100644
index 1d48daa..0000000
--- a/src/testMod/java/io/github/cottonmc/test/LibGuiTest.java
+++ /dev/null
@@ -1,91 +0,0 @@
-package io.github.cottonmc.test;
-
-import net.fabricmc.api.ModInitializer;
-import net.fabricmc.fabric.api.object.builder.v1.block.entity.FabricBlockEntityTypeBuilder;
-import net.fabricmc.fabric.api.screenhandler.v1.ExtendedScreenHandlerType;
-import net.fabricmc.loader.api.FabricLoader;
-import net.fabricmc.loader.api.ModContainer;
-import net.minecraft.block.AbstractBlock;
-import net.minecraft.block.Block;
-import net.minecraft.block.Blocks;
-import net.minecraft.block.entity.BlockEntityType;
-import net.minecraft.entity.EquipmentSlot;
-import net.minecraft.entity.player.PlayerInventory;
-import net.minecraft.inventory.StackReference;
-import net.minecraft.item.BlockItem;
-import net.minecraft.item.Item;
-import net.minecraft.registry.Registries;
-import net.minecraft.registry.Registry;
-import net.minecraft.resource.featuretoggle.FeatureFlags;
-import net.minecraft.resource.featuretoggle.FeatureSet;
-import net.minecraft.screen.ScreenHandlerContext;
-import net.minecraft.screen.ScreenHandlerType;
-import net.minecraft.util.Identifier;
-
-import java.io.IOException;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.util.Optional;
-
-public class LibGuiTest implements ModInitializer {
- public static final String MODID = "libgui-test";
-
- public static GuiBlock GUI_BLOCK;
- public static Block NO_BLOCK_INVENTORY_BLOCK;
- public static BlockItem GUI_BLOCK_ITEM;
- public static BlockEntityType<GuiBlockEntity> GUI_BLOCKENTITY_TYPE;
- public static ScreenHandlerType<TestDescription> GUI_SCREEN_HANDLER_TYPE;
- public static ScreenHandlerType<TestItemDescription> ITEM_SCREEN_HANDLER_TYPE;
- public static ScreenHandlerType<ReallySimpleDescription> REALLY_SIMPLE_SCREEN_HANDLER_TYPE;
-
- @Override
- public void onInitialize() {
- Registry.register(Registries.ITEM, new Identifier(MODID, "client_gui"), new GuiItem());
-
- GUI_BLOCK = new GuiBlock();
- Registry.register(Registries.BLOCK, new Identifier(MODID, "gui"), GUI_BLOCK);
- GUI_BLOCK_ITEM = new BlockItem(GUI_BLOCK, new Item.Settings());
- Registry.register(Registries.ITEM, new Identifier(MODID, "gui"), GUI_BLOCK_ITEM);
- NO_BLOCK_INVENTORY_BLOCK = new NoBlockInventoryBlock(AbstractBlock.Settings.copy(Blocks.STONE));
- Registry.register(Registries.BLOCK, new Identifier(MODID, "no_block_inventory"), NO_BLOCK_INVENTORY_BLOCK);
- Registry.register(Registries.ITEM, new Identifier(MODID, "no_block_inventory"), new BlockItem(NO_BLOCK_INVENTORY_BLOCK, new Item.Settings()));
- GUI_BLOCKENTITY_TYPE = FabricBlockEntityTypeBuilder.create(GuiBlockEntity::new, GUI_BLOCK).build(null);
- Registry.register(Registries.BLOCK_ENTITY_TYPE, new Identifier(MODID, "gui"), GUI_BLOCKENTITY_TYPE);
-
- GUI_SCREEN_HANDLER_TYPE = new ScreenHandlerType<>((int syncId, PlayerInventory inventory) -> {
- return new TestDescription(GUI_SCREEN_HANDLER_TYPE, syncId, inventory, ScreenHandlerContext.EMPTY);
- }, FeatureSet.of(FeatureFlags.VANILLA));
- Registry.register(Registries.SCREEN_HANDLER, new Identifier(MODID, "gui"), GUI_SCREEN_HANDLER_TYPE);
- ITEM_SCREEN_HANDLER_TYPE = new ExtendedScreenHandlerType<>((syncId, inventory, buf) -> {
- var equipmentSlot = buf.readEnumConstant(EquipmentSlot.class);
- StackReference handStack = StackReference.of(inventory.player, equipmentSlot);
- return new TestItemDescription(syncId, inventory, handStack);
- });
- Registry.register(Registries.SCREEN_HANDLER, new Identifier(MODID, "item_gui"), ITEM_SCREEN_HANDLER_TYPE);
-
- REALLY_SIMPLE_SCREEN_HANDLER_TYPE = new ScreenHandlerType<>(ReallySimpleDescription::new, FeatureSet.of(FeatureFlags.VANILLA));
- Registry.register(Registries.SCREEN_HANDLER, new Identifier(MODID, "really_simple"), REALLY_SIMPLE_SCREEN_HANDLER_TYPE);
-
- Optional<ModContainer> containerOpt = FabricLoader.getInstance().getModContainer("jankson");
- if (containerOpt.isPresent()) {
- ModContainer jankson = containerOpt.get();
- System.out.println("Jankson root path: "+jankson.getRootPath());
- try {
- Files.list(jankson.getRootPath()).forEach((path)->{
- path.getFileSystem().getFileStores().forEach((store)->{
- System.out.println(" Filestore: "+store.name());
- });
- System.out.println(" "+path.toAbsolutePath());
- });
- } catch (IOException e) {
- e.printStackTrace();
- }
- Path modJson = jankson.getPath("/fabric.mod.json");
- System.out.println("Jankson fabric.mod.json path: "+modJson);
- System.out.println(Files.exists(modJson) ? "Exists" : "Does Not Exist");
- } else {
- System.out.println("Container isn't present!");
- }
- }
-
-}
diff --git a/src/testMod/java/io/github/cottonmc/test/NoBlockInventoryBlock.java b/src/testMod/java/io/github/cottonmc/test/NoBlockInventoryBlock.java
deleted file mode 100644
index 2b784a6..0000000
--- a/src/testMod/java/io/github/cottonmc/test/NoBlockInventoryBlock.java
+++ /dev/null
@@ -1,39 +0,0 @@
-package io.github.cottonmc.test;
-
-import net.minecraft.block.Block;
-import net.minecraft.block.BlockState;
-import net.minecraft.entity.player.PlayerEntity;
-import net.minecraft.entity.player.PlayerInventory;
-import net.minecraft.screen.NamedScreenHandlerFactory;
-import net.minecraft.screen.ScreenHandler;
-import net.minecraft.text.Text;
-import net.minecraft.util.ActionResult;
-import net.minecraft.util.Hand;
-import net.minecraft.util.hit.BlockHitResult;
-import net.minecraft.util.math.BlockPos;
-import net.minecraft.world.World;
-
-import org.jetbrains.annotations.Nullable;
-
-public class NoBlockInventoryBlock extends Block implements NamedScreenHandlerFactory {
- public NoBlockInventoryBlock(Settings settings) {
- super(settings);
- }
-
- @Override
- public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit) {
- player.openHandledScreen(this);
- return world.isClient ? ActionResult.SUCCESS : ActionResult.CONSUME;
- }
-
- @Override
- public Text getDisplayName() {
- return getName();
- }
-
- @Nullable
- @Override
- public ScreenHandler createMenu(int syncId, PlayerInventory inv, PlayerEntity player) {
- return new ReallySimpleDescription(syncId, inv);
- }
-}
diff --git a/src/testMod/java/io/github/cottonmc/test/ReallySimpleDescription.java b/src/testMod/java/io/github/cottonmc/test/ReallySimpleDescription.java
deleted file mode 100644
index bcb9213..0000000
--- a/src/testMod/java/io/github/cottonmc/test/ReallySimpleDescription.java
+++ /dev/null
@@ -1,16 +0,0 @@
-package io.github.cottonmc.test;
-
-import net.minecraft.entity.player.PlayerInventory;
-
-import io.github.cottonmc.cotton.gui.SyncedGuiDescription;
-import io.github.cottonmc.cotton.gui.widget.WGridPanel;
-
-// A really simple GUI description that only contains a player inventory panel.
-public class ReallySimpleDescription extends SyncedGuiDescription {
- public ReallySimpleDescription(int syncId, PlayerInventory playerInventory) {
- super(LibGuiTest.REALLY_SIMPLE_SCREEN_HANDLER_TYPE, syncId, playerInventory);
- setTitleVisible(false);
- ((WGridPanel) getRootPanel()).add(createPlayerInventoryPanel(), 0, 0);
- getRootPanel().validate(this);
- }
-}
diff --git a/src/testMod/java/io/github/cottonmc/test/TestDescription.java b/src/testMod/java/io/github/cottonmc/test/TestDescription.java
deleted file mode 100644
index 7c24610..0000000
--- a/src/testMod/java/io/github/cottonmc/test/TestDescription.java
+++ /dev/null
@@ -1,78 +0,0 @@
-package io.github.cottonmc.test;
-
-import net.minecraft.entity.player.PlayerInventory;
-import net.minecraft.item.Items;
-import net.minecraft.screen.ScreenHandlerContext;
-import net.minecraft.screen.ScreenHandlerType;
-import net.minecraft.text.Text;
-import net.minecraft.util.Identifier;
-
-import io.github.cottonmc.cotton.gui.SyncedGuiDescription;
-import io.github.cottonmc.cotton.gui.networking.NetworkSide;
-import io.github.cottonmc.cotton.gui.networking.ScreenNetworking;
-import io.github.cottonmc.cotton.gui.widget.WButton;
-import io.github.cottonmc.cotton.gui.widget.WGridPanel;
-import io.github.cottonmc.cotton.gui.widget.WItemSlot;
-import io.github.cottonmc.cotton.gui.widget.WLabel;
-import io.github.cottonmc.cotton.gui.widget.WTextField;
-import io.github.cottonmc.cotton.gui.widget.WToggleButton;
-import io.github.cottonmc.cotton.gui.widget.data.Texture;
-import io.github.cottonmc.cotton.gui.widget.icon.TextureIcon;
-
-public class TestDescription extends SyncedGuiDescription {
- private static final Identifier TEST_MESSAGE = new Identifier("libgui", "test");
- private static final Identifier UNREGISTERED_ON_SERVER = new Identifier("libgui", "unregistered_on_server");
-
- public TestDescription(ScreenHandlerType<?> type, int syncId, PlayerInventory playerInventory, ScreenHandlerContext context) {
- super(type, syncId, playerInventory, getBlockInventory(context, GuiBlockEntity.INVENTORY_SIZE), null);
-
- WGridPanel root = (WGridPanel)this.getRootPanel();
-
- WItemSlot slot = WItemSlot.of(blockInventory, 0, 4, 1);
- root.add(slot, 0, 1);
-
- WButton buttonA = new WButton(Text.literal("Send Message"));
-
- buttonA.setOnClick(() -> {
- ScreenNetworking.of(this, NetworkSide.CLIENT).send(TEST_MESSAGE, buf -> {});
- ScreenNetworking.of(this, NetworkSide.CLIENT).send(UNREGISTERED_ON_SERVER, buf -> {});
- });
-
- root.add(buttonA, 0, 3, 4, 1);
-
- WButton buttonB = new WButton(Text.literal("Show Warnings"));
- buttonB.setOnClick(() -> slot.setIcon(new TextureIcon(new Identifier("libgui-test", "saddle.png"))));
-
- root.add(buttonB, 5, 3, 4, 1);
- TextureIcon testIcon = new TextureIcon(new Texture(new Identifier("libgui-test", "icon.png")));
- root.add(new WButton(testIcon, Text.literal("Button C")), 0, 5, 4, 1);
- root.add(new WButton(Text.literal("Button D")), 5, 5, 4, 1);
- root.add(new WTextField(Text.literal("Type something...")).setMaxLength(64), 0, 7, 5, 1);
-
- root.add(new WLabel(Text.literal("Large Glass-only output:")), 0, 9);
- WItemSlot glassOutputSlot = WItemSlot.outputOf(blockInventory, 0).setOutputFilter(stack -> stack.isOf(Items.GLASS));
- glassOutputSlot.setIcon(new TextureIcon(new Identifier("minecraft:textures/block/glass.png")));
- root.add(glassOutputSlot, 4, 9);
- WToggleButton glassIconToggle = new WToggleButton(Text.literal("Show glass icon only when empty?"));
- glassIconToggle.setOnToggle(glassOutputSlot::setIconOnlyPaintedForEmptySlots);
- root.add(glassIconToggle, 0, 10);
-
- root.add(WItemSlot.of(blockInventory, 7).setIcon(new TextureIcon(new Identifier("libgui-test", "saddle.png"))).setInputFilter(stack -> stack.isOf(Items.SADDLE)), 7, 10);
-
- root.add(createPlayerInventoryPanel(), 0, 11);
- System.out.println(root.toString());
-
- this.getRootPanel().validate(this);
-
- ScreenNetworking.of(this, NetworkSide.SERVER).receive(TEST_MESSAGE, buf -> {
- System.out.println("Received on the server!");
- });
-
- try {
- slot.onHidden();
- slot.onShown();
- } catch (Throwable t) {
- throw new AssertionError("ValidatedSlot.setVisible crashed", t);
- }
- }
-}
diff --git a/src/testMod/java/io/github/cottonmc/test/TestItemDescription.java b/src/testMod/java/io/github/cottonmc/test/TestItemDescription.java
deleted file mode 100644
index 45be514..0000000
--- a/src/testMod/java/io/github/cottonmc/test/TestItemDescription.java
+++ /dev/null
@@ -1,156 +0,0 @@
-package io.github.cottonmc.test;
-
-import net.fabricmc.api.EnvType;
-import net.fabricmc.api.Environment;
-import net.minecraft.client.gui.DrawContext;
-import net.minecraft.entity.player.PlayerInventory;
-import net.minecraft.inventory.StackReference;
-import net.minecraft.text.Text;
-import net.minecraft.util.Identifier;
-
-import io.github.cottonmc.cotton.gui.ItemSyncedGuiDescription;
-import io.github.cottonmc.cotton.gui.client.ScreenDrawing;
-import io.github.cottonmc.cotton.gui.widget.TooltipBuilder;
-import io.github.cottonmc.cotton.gui.widget.WGridPanel;
-import io.github.cottonmc.cotton.gui.widget.WLabel;
-import io.github.cottonmc.cotton.gui.widget.WSlider;
-import io.github.cottonmc.cotton.gui.widget.WTextField;
-import io.github.cottonmc.cotton.gui.widget.WTiledSprite;
-import io.github.cottonmc.cotton.gui.widget.WWidget;
-import io.github.cottonmc.cotton.gui.widget.data.Axis;
-import io.github.cottonmc.cotton.gui.widget.data.Color;
-import io.github.cottonmc.cotton.gui.widget.data.Insets;
-
-public class TestItemDescription extends ItemSyncedGuiDescription {
- private int r = 0;
- private int g = 0;
- private int b = 0;
-
- public TestItemDescription(int syncId, PlayerInventory playerInventory, StackReference owner) {
- super(LibGuiTest.ITEM_SCREEN_HANDLER_TYPE, syncId, playerInventory, owner);
- WGridPanel root = new WGridPanel(22);
- root.setInsets(Insets.ROOT_PANEL);
- this.setRootPanel(root);
- WLabel title = new WLabel(Text.literal("Client Test Gui"), WLabel.DEFAULT_TEXT_COLOR) {
- @Environment(EnvType.CLIENT)
- @Override
- public void addTooltip(TooltipBuilder tooltip) {
- tooltip.add(Text.literal("Radical!"));
- }
- };
- WTiledSprite wood = new WTiledSprite(
- 8, 8, // tile width and height
- 500, // animation speed
- new Identifier("minecraft:textures/block/birch_planks.png"),
- new Identifier("minecraft:textures/block/dark_oak_planks.png"),
- new Identifier("minecraft:textures/block/jungle_planks.png")
- );
- root.add(wood, 3, 3, 2, 2);
- root.add(title, 0, 0);
-
- WTextField text = new WTextField();
- text.setSuggestion(Text.literal("Search"));
- root.add(text, 0, 1, 8, 1);
- text.setSize(7*18, 20);
- /*
- ArrayList<String> data = new ArrayList<>();
- data.add("Wolfram Alpha");
- data.add("Strange Home");
- data.add("Nether Base");
- data.add("Death");
- data.add("Cake");
- data.add("Mushroom Island");
- data.add("A List Item");
- data.add("Notes");
- data.add("Slime Island");
-
- BiConsumer<String, PortalDestination> configurator = (String s, PortalDestination destination) -> {
- destination.label.setText(new LiteralText(s));
-
- int hash = s.hashCode();
- Identifier sprite = ((hash & 0x01) == 0) ? PORTAL1 : PORTAL2;
- destination.sprite.setImage(sprite);
-
- int cost = (hash >> 1) & 0x2FF;
- destination.cost.setText(new LiteralText(""+cost+" XP"));
- };
- WListPanel<String, PortalDestination> list = new WListPanel<String, PortalDestination>(data, PortalDestination.class, PortalDestination::new, configurator);
- list.setListItemHeight(2*18);
- list.setBackgroundPainter(PANEL);
- root.add(list, 0, 2, 7, 6);
-
- root.add(new WButton(new LiteralText("Teleport")), 3,8,4,1);*/
- WColorBox col = new WColorBox();
- root.add(col, 3,2,1,3);
-
- WSlider r = new WSlider(0, 100, Axis.VERTICAL);
- root.add(r, 0, 2, 1, 3);
- r.setValueChangeListener((i)->{
- this.r = i;
- updateCol(col);
- System.out.println("h: "+this.r+" s: "+this.g+ " l: "+this.b);
- System.out.println("col is now "+Integer.toHexString(col.color));
- });
- WSlider g = new WSlider(0, 100, Axis.VERTICAL);
- root.add(g, 1, 2, 1, 3);
- g.setValueChangeListener((i)->{
- this.g = i;
- updateCol(col);
- });
- WSlider b = new WSlider(0, 100, Axis.VERTICAL);
- root.add(b, 2, 2, 1, 3);
- b.setValueChangeListener((i)->{
- this.b = i;
- updateCol(col);
- });
-
- root.validate(this);
- }
- /*
- public static class PortalDestination extends WPlainPanel {
- WSprite sprite;
- WLabel label;
- WLabel cost;
-
- public PortalDestination() {
- sprite = new WSprite(new Identifier("libgui-test:portal"));
- this.add(sprite, 2, 2, 18, 18);
- label = new WLabel("Foo");
- this.add(label, 18+ 4, 2, 5*18, 18);
- cost = new WLabel("1000 Xp");
- this.add(cost, 2, 20, 6*18, 18);
-
- this.setSize(7*18, 2*18);
-
- this.setBackgroundPainter(PANEL); //Would fail on a serverside gui
- }
- }*/
-
- private void updateCol(WColorBox col) {
- Color.HSL hsl = new Color.HSL(r/100f, g/100f, b/100f);
- col.setColor(hsl.toRgb());
- }
-
- public static class WColorBox extends WWidget {
- protected int color = 0xFF_FFFFFF;
- public WColorBox() {}
-
- public WColorBox(int col) {
- this.color = col;
- }
-
- @Override
- public boolean canResize() {
- return true;
- }
-
- public void setColor(int col) {
- this.color = col;
- }
-
- @Override
- public void paint(DrawContext context, int x, int y, int mouseX, int mouseY) {
- ScreenDrawing.coloredRect(context, x, y, this.getWidth(), this.getHeight(), color);
- }
- }
-}
diff --git a/src/testMod/java/io/github/cottonmc/test/client/DarkModeTestGui.java b/src/testMod/java/io/github/cottonmc/test/client/DarkModeTestGui.java
deleted file mode 100644
index f9012d7..0000000
--- a/src/testMod/java/io/github/cottonmc/test/client/DarkModeTestGui.java
+++ /dev/null
@@ -1,49 +0,0 @@
-package io.github.cottonmc.test.client;
-
-import net.fabricmc.fabric.api.util.TriState;
-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.WDynamicLabel;
-import io.github.cottonmc.cotton.gui.widget.WGridPanel;
-import io.github.cottonmc.cotton.gui.widget.WLabel;
-import io.github.cottonmc.cotton.gui.widget.WLabeledSlider;
-import io.github.cottonmc.cotton.gui.widget.WScrollBar;
-import io.github.cottonmc.cotton.gui.widget.WSlider;
-import io.github.cottonmc.cotton.gui.widget.WText;
-import io.github.cottonmc.cotton.gui.widget.WToggleButton;
-import io.github.cottonmc.cotton.gui.widget.data.Axis;
-import io.github.cottonmc.cotton.gui.widget.data.Insets;
-
-public final class DarkModeTestGui extends LightweightGuiDescription {
- private boolean darkMode = false;
-
- public DarkModeTestGui() {
- var root = new WGridPanel(20);
- root.setInsets(Insets.ROOT_PANEL);
- root.setGaps(3, 3);
-
- root.add(new WButton(Text.literal("Button A")), 0, 0, 3, 1);
- root.add(new WButton(Text.literal("Button B")), 0, 1, 3, 1);
- root.add(new WText(Text.literal("Text")), 0, 2, 3, 1);
- root.add(new WLabeledSlider(1, 100, Text.literal("Slider A")), 3, 0, 3, 1);
- root.add(new WLabeledSlider(1, 100, Axis.VERTICAL, Text.literal("Slider B")), 6, 0, 1, 3);
- root.add(new WSlider(1, 100, Axis.HORIZONTAL), 3, 1, 3, 1);
- root.add(new WLabel(Text.literal("Label")), 3, 2, 3, 1);
- root.add(new WScrollBar(Axis.HORIZONTAL), 0, 3, 3, 1);
- root.add(new WDynamicLabel(() -> "Dynamic label: " + (darkMode ? "dark mode" : "light mode")),
- 3, 3, 3, 1);
- var toggle = new WToggleButton(Text.literal("Toggle button"));
- toggle.setOnToggle(on -> darkMode = on);
- root.add(toggle, 0, 4, 6, 1);
-
- root.validate(this);
- setRootPanel(root);
- }
-
- @Override
- public TriState isDarkMode() {
- return TriState.of(darkMode);
- }
-}
diff --git a/src/testMod/java/io/github/cottonmc/test/client/GhostIconTestGui.java b/src/testMod/java/io/github/cottonmc/test/client/GhostIconTestGui.java
deleted file mode 100644
index 34c9737..0000000
--- a/src/testMod/java/io/github/cottonmc/test/client/GhostIconTestGui.java
+++ /dev/null
@@ -1,26 +0,0 @@
-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/InsetsTestGui.java b/src/testMod/java/io/github/cottonmc/test/client/InsetsTestGui.java
deleted file mode 100644
index f89de7a..0000000
--- a/src/testMod/java/io/github/cottonmc/test/client/InsetsTestGui.java
+++ /dev/null
@@ -1,20 +0,0 @@
-package io.github.cottonmc.test.client;
-
-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.WLabel;
-import io.github.cottonmc.cotton.gui.widget.data.Insets;
-
-public class InsetsTestGui extends LightweightGuiDescription {
- public InsetsTestGui() {
- WGridPanel root = (WGridPanel) rootPanel;
-
- root.add(new WLabel(Text.literal("Insets demo")), 0, 0);
- root.add(new WButton(Text.literal("Default")).setOnClick(() -> root.setInsets(Insets.ROOT_PANEL)), 0, 1, 2, 1);
- root.add(new WButton(Text.literal("None")).setOnClick(() -> root.setInsets(Insets.NONE)), 2, 1, 2, 1);
- root.add(new WButton(Text.literal("Large")).setOnClick(() -> root.setInsets(new Insets(16))), 4, 1, 2, 1);
- }
-}
diff --git a/src/testMod/java/io/github/cottonmc/test/client/Issue182TestGui.java b/src/testMod/java/io/github/cottonmc/test/client/Issue182TestGui.java
deleted file mode 100644
index 5d4a739..0000000
--- a/src/testMod/java/io/github/cottonmc/test/client/Issue182TestGui.java
+++ /dev/null
@@ -1,18 +0,0 @@
-package io.github.cottonmc.test.client;
-
-import io.github.cottonmc.cotton.gui.client.LightweightGuiDescription;
-import io.github.cottonmc.cotton.gui.widget.WBox;
-import io.github.cottonmc.cotton.gui.widget.WTextField;
-import io.github.cottonmc.cotton.gui.widget.data.Axis;
-
-// Used for testing issue #182 (https://github.com/CottonMC/LibGui/issues/182):
-// Highlighting/selecting text in the top field makes the bottom one blue.
-public final class Issue182TestGui extends LightweightGuiDescription {
- public Issue182TestGui() {
- WBox root = new WBox(Axis.VERTICAL);
- root.add(new WTextField(), 100, 20);
- root.add(new WTextField(), 100, 20);
- setRootPanel(root);
- root.validate(this);
- }
-}
diff --git a/src/testMod/java/io/github/cottonmc/test/client/Issue196TestGui.java b/src/testMod/java/io/github/cottonmc/test/client/Issue196TestGui.java
deleted file mode 100644
index 6de8181..0000000
--- a/src/testMod/java/io/github/cottonmc/test/client/Issue196TestGui.java
+++ /dev/null
@@ -1,16 +0,0 @@
-package io.github.cottonmc.test.client;
-
-import net.minecraft.text.Text;
-
-import io.github.cottonmc.cotton.gui.client.LightweightGuiDescription;
-import io.github.cottonmc.cotton.gui.widget.WGridPanel;
-import io.github.cottonmc.cotton.gui.widget.WTextField;
-
-public final class Issue196TestGui extends LightweightGuiDescription {
- public Issue196TestGui() {
- WTextField textField = new WTextField(Text.literal("Select with tab and type text"));
- textField.setText("");
- ((WGridPanel) rootPanel).add(textField, 0, 0, 4, 1);
- rootPanel.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
deleted file mode 100644
index 0674761..0000000
--- a/src/testMod/java/io/github/cottonmc/test/client/LibGuiTestClient.java
+++ /dev/null
@@ -1,89 +0,0 @@
-package io.github.cottonmc.test.client;
-
-import com.mojang.brigadier.Command;
-import com.mojang.brigadier.arguments.IntegerArgumentType;
-import net.fabricmc.api.ClientModInitializer;
-import net.fabricmc.fabric.api.client.command.v2.ClientCommandRegistrationCallback;
-import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource;
-import net.minecraft.client.MinecraftClient;
-import net.minecraft.client.gui.screen.ingame.HandledScreens;
-import net.minecraft.screen.ScreenTexts;
-import net.minecraft.text.Text;
-
-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.client.LightweightGuiDescription;
-import io.github.cottonmc.cotton.gui.impl.modmenu.ConfigGui;
-import io.github.cottonmc.cotton.gui.widget.WLabel;
-import io.github.cottonmc.test.LibGuiTest;
-import io.github.cottonmc.test.ReallySimpleDescription;
-import io.github.cottonmc.test.TestDescription;
-import io.github.cottonmc.test.TestItemDescription;
-
-import java.util.function.Function;
-
-import static net.fabricmc.fabric.api.client.command.v2.ClientCommandManager.argument;
-import static net.fabricmc.fabric.api.client.command.v2.ClientCommandManager.literal;
-
-public class LibGuiTestClient implements ClientModInitializer {
-
- @Override
- public void onInitializeClient() {
- HandledScreens.<TestDescription, CottonInventoryScreen<TestDescription>>register(
- LibGuiTest.GUI_SCREEN_HANDLER_TYPE,
- CottonInventoryScreen::new
- );
-
- HandledScreens.<ReallySimpleDescription, CottonInventoryScreen<ReallySimpleDescription>>register(
- LibGuiTest.REALLY_SIMPLE_SCREEN_HANDLER_TYPE,
- CottonInventoryScreen::new
- );
-
- HandledScreens.<TestItemDescription, CottonInventoryScreen<TestItemDescription>>register(
- LibGuiTest.ITEM_SCREEN_HANDLER_TYPE,
- CottonInventoryScreen::new
- );
-
- CottonHud.add(new WHudTest(), 10, -20, 10, 10);
- CottonHud.add(new WLabel(Text.literal("Test label")), 10, -30, 10, 10);
-
- ClientCommandRegistrationCallback.EVENT.register((dispatcher, commandRegistryAccess) -> dispatcher.register(
- literal("libgui")
- .then(literal("config").executes(openScreen(client -> new ConfigGui(client.currentScreen))))
- .then(literal("tab").executes(openScreen(client -> new TabTestGui())))
- .then(literal("scrolling").executes(openScreen(client -> new ScrollingTestGui())))
- .then(literal("scrollbar").executes(openScreen(client -> new ScrollBarTestGui())))
- .then(literal("insets").executes(openScreen(client -> new InsetsTestGui())))
- .then(literal("textfield").executes(openScreen(client -> new TextFieldTestGui())))
- .then(literal("paddings")
- .then(argument("horizontal", IntegerArgumentType.integer(0))
- .then(argument("vertical", IntegerArgumentType.integer(0))
- .executes(context -> {
- var hori = IntegerArgumentType.getInteger(context, "horizontal");
- var vert = IntegerArgumentType.getInteger(context, "vertical");
- return openScreen(client -> new PaddingTestGui(hori, vert)).run(context);
- }))))
- .then(literal("#182").executes(openScreen(client -> new Issue182TestGui())))
- .then(literal("#196").executes(openScreen(client -> new Issue196TestGui())))
- .then(literal("darkmode").executes(openScreen(client -> new DarkModeTestGui())))
- .then(literal("titlealignment").executes(openScreen(Text.literal("test title"), client -> new TitleAlignmentTestGui())))
- .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())))
- ));
- }
-
- private static Command<FabricClientCommandSource> openScreen(Function<MinecraftClient, LightweightGuiDescription> screenFactory) {
- return openScreen(ScreenTexts.EMPTY, screenFactory);
- }
-
- private static Command<FabricClientCommandSource> openScreen(Text title, Function<MinecraftClient, LightweightGuiDescription> screenFactory) {
- return context -> {
- var client = context.getSource().getClient();
- client.send(() -> client.setScreen(new CottonClientScreen(title, screenFactory.apply(client))));
- return Command.SINGLE_SUCCESS;
- };
- }
-}
diff --git a/src/testMod/java/io/github/cottonmc/test/client/ListTestGui.java b/src/testMod/java/io/github/cottonmc/test/client/ListTestGui.java
deleted file mode 100644
index 42eb8b5..0000000
--- a/src/testMod/java/io/github/cottonmc/test/client/ListTestGui.java
+++ /dev/null
@@ -1,137 +0,0 @@
-package io.github.cottonmc.test.client;
-
-import net.minecraft.text.Text;
-import net.minecraft.util.Formatting;
-
-import io.github.cottonmc.cotton.gui.client.BackgroundPainter;
-import io.github.cottonmc.cotton.gui.client.LightweightGuiDescription;
-import io.github.cottonmc.cotton.gui.widget.WGridPanel;
-import io.github.cottonmc.cotton.gui.widget.WLabel;
-import io.github.cottonmc.cotton.gui.widget.WLabeledSlider;
-import io.github.cottonmc.cotton.gui.widget.WListPanel;
-import io.github.cottonmc.cotton.gui.widget.data.Axis;
-import io.github.cottonmc.cotton.gui.widget.data.Insets;
-
-import java.util.Arrays;
-import java.util.List;
-import java.util.Random;
-
-public class ListTestGui extends LightweightGuiDescription {
- private static final String[] LOREM = {
- "Eius",
- "architecto",
- "dolores",
- "in",
- "delectus",
- "omnis",
- "Exercitationem",
- "fugit",
- "dolorem",
- "sapiente",
- "impedit",
- "Occaecati",
- "consequatur",
- "omnis",
- "nam",
- "eveniet",
- "eius",
- "Eos",
- "quasi",
- "numquam",
- "placeat",
- "eaque",
- "sapiente",
- "Dolorum",
- "magnam",
- "eius",
- "labore",
- "voluptatem",
- "est",
- "voluptatem",
- "aut",
- "qui"
- };
-
- public ListTestGui() {
- WGridPanel root = (WGridPanel) rootPanel;
-
- List<Formatting> formattings = Arrays.stream(Formatting.values())
- .filter(Formatting::isColor)
- .toList();
- Random random = new Random();
- List<Text> data = Arrays.stream(LOREM)
- .<Text>map(s -> {
- Formatting formatting = formattings.get(random.nextInt(formattings.size()));
- return Text.literal(s).formatted(formatting, Formatting.BOLD);
- })
- .toList();
-
- WListPanel<Text, WLorem> listPanel = new WListPanel<>(data, WLorem::new, (text, widget) -> widget.label.setText(text));
- WLabeledSlider topSlider = new WLabeledSlider(0, 16, Axis.HORIZONTAL, Text.literal("Top insets"));
- WLabeledSlider bottomSlider = new WLabeledSlider(0, 16, Axis.HORIZONTAL, Text.literal("Bottom insets"));
- WLabeledSlider leftSlider = new WLabeledSlider(0, 16, Axis.HORIZONTAL, Text.literal("Left insets"));
- WLabeledSlider rightSlider = new WLabeledSlider(0, 16, Axis.HORIZONTAL, Text.literal("Right insets"));
- WLabeledSlider gapSlider = new WLabeledSlider(0, 16, Axis.VERTICAL, Text.literal("Gap"));
-
- topSlider.setValue(listPanel.getInsets().top());
- topSlider.setValueChangeListener(top -> {
- Insets insets = listPanel.getInsets();
- Insets newInsets = new Insets(top, insets.left(), insets.bottom(), insets.right());
- listPanel.setInsets(newInsets);
- listPanel.layout();
- });
-
- bottomSlider.setValue(listPanel.getInsets().bottom());
- bottomSlider.setValueChangeListener(bottom -> {
- Insets insets = listPanel.getInsets();
- Insets newInsets = new Insets(insets.top(), insets.left(), bottom, insets.right());
- listPanel.setInsets(newInsets);
- listPanel.layout();
- });
-
- leftSlider.setValue(listPanel.getInsets().left());
- leftSlider.setValueChangeListener(left -> {
- Insets insets = listPanel.getInsets();
- Insets newInsets = new Insets(insets.top(), left, insets.bottom(), insets.right());
- listPanel.setInsets(newInsets);
- listPanel.layout();
- });
-
- rightSlider.setValue(listPanel.getInsets().right());
- rightSlider.setValueChangeListener(right -> {
- Insets insets = listPanel.getInsets();
- Insets newInsets = new Insets(insets.top(), insets.left(), insets.bottom(), right);
- listPanel.setInsets(newInsets);
- listPanel.layout();
- });
-
- gapSlider.setValue(listPanel.getGap());
- gapSlider.setValueChangeListener(gap -> {
- listPanel.setGap(gap);
- listPanel.layout();
- });
-
- root.setGaps(2, 2);
- root.add(topSlider, 0, 0, 3, 1);
- root.add(bottomSlider, 3, 0, 3, 1);
- root.add(leftSlider, 0, 1, 3, 1);
- root.add(rightSlider, 3, 1, 3, 1);
- root.add(gapSlider, 6, 0, 1, 2);
- root.add(listPanel, 0, 2, 6, 6);
- root.validate(this);
- }
-
- private static class WLorem extends WGridPanel {
- private final WLabel label = new WLabel(Text.empty());
-
- private WLorem() {
- setInsets(Insets.ROOT_PANEL);
- add(label, 0, 0);
- }
-
- @Override
- public void addPainters() {
- setBackgroundPainter(BackgroundPainter.VANILLA);
- }
- }
-}
diff --git a/src/testMod/java/io/github/cottonmc/test/client/PaddingTestGui.java b/src/testMod/java/io/github/cottonmc/test/client/PaddingTestGui.java
deleted file mode 100644
index 9f5d790..0000000
--- a/src/testMod/java/io/github/cottonmc/test/client/PaddingTestGui.java
+++ /dev/null
@@ -1,35 +0,0 @@
-package io.github.cottonmc.test.client;
-
-import net.minecraft.text.Text;
-
-import io.github.cottonmc.cotton.gui.client.LightweightGuiDescription;
-import io.github.cottonmc.cotton.gui.widget.WGridPanel;
-import io.github.cottonmc.cotton.gui.widget.WLabel;
-import io.github.cottonmc.cotton.gui.widget.data.HorizontalAlignment;
-import io.github.cottonmc.cotton.gui.widget.data.Insets;
-import io.github.cottonmc.cotton.gui.widget.data.VerticalAlignment;
-import io.github.cottonmc.test.TestItemDescription;
-
-public class PaddingTestGui extends LightweightGuiDescription {
- public PaddingTestGui(int hori, int vert) {
- var root = new WGridPanel();
- root.setGaps(hori, vert);
- setRootPanel(root);
- root.setInsets(Insets.ROOT_PANEL);
-
- addBox(root, 0, 0, 2, 1);
- addBox(root, 0, 1, 1, 2);
- addBox(root, 1, 1, 1, 1);
- addBox(root, 1, 2, 1, 1);
-
- root.validate(this);
- }
-
- void addBox(WGridPanel root, int x, int y, int w, int h) {
- root.add(new TestItemDescription.WColorBox(0xffff0000), x, y, w, h);
- var l = new WLabel(Text.literal(w + "x" + h), 0xff00ffff);
- l.setVerticalAlignment(VerticalAlignment.CENTER);
- l.setHorizontalAlignment(HorizontalAlignment.CENTER);
- root.add(l, x, y, w, h);
- }
-}
diff --git a/src/testMod/java/io/github/cottonmc/test/client/ScrollBarTestGui.java b/src/testMod/java/io/github/cottonmc/test/client/ScrollBarTestGui.java
deleted file mode 100644
index 7c94a53..0000000
--- a/src/testMod/java/io/github/cottonmc/test/client/ScrollBarTestGui.java
+++ /dev/null
@@ -1,65 +0,0 @@
-package io.github.cottonmc.test.client;
-
-import net.fabricmc.fabric.api.util.TriState;
-import net.minecraft.text.Text;
-
-import io.github.cottonmc.cotton.gui.client.LightweightGuiDescription;
-import io.github.cottonmc.cotton.gui.widget.WLabel;
-import io.github.cottonmc.cotton.gui.widget.WPlainPanel;
-import io.github.cottonmc.cotton.gui.widget.WScrollBar;
-import io.github.cottonmc.cotton.gui.widget.WSlider;
-import io.github.cottonmc.cotton.gui.widget.WToggleButton;
-import io.github.cottonmc.cotton.gui.widget.data.Axis;
-import io.github.cottonmc.cotton.gui.widget.data.HorizontalAlignment;
-import io.github.cottonmc.cotton.gui.widget.data.Insets;
-import io.github.cottonmc.cotton.gui.widget.data.VerticalAlignment;
-
-public class ScrollBarTestGui extends LightweightGuiDescription {
- private boolean darkMode = false;
-
- public ScrollBarTestGui() {
- WPlainPanel root = new WPlainPanel();
- setRootPanel(root);
- root.setSize(256, 240);
- root.setInsets(Insets.ROOT_PANEL);
-
- WScrollBar scrollBarTop = new WScrollBar(Axis.HORIZONTAL);
- root.add(scrollBarTop, 0, 0, 256, 16);
-
- WScrollBar scrollBarDown = new WScrollBar(Axis.HORIZONTAL);
- root.add(scrollBarDown, 0, 240 - scrollBarDown.getHeight(), 256, 8);
-
- WScrollBar scrollBarLeft = new WScrollBar(Axis.VERTICAL);
- root.add(scrollBarLeft, 0, 18, 16, 202);
-
- WScrollBar scrollBarRight = new WScrollBar(Axis.VERTICAL);
- root.add(scrollBarRight, 248, 18, 8, 202);
-
- WLabel label = new WLabel(Text.of("Scrolling Speed: 4"));
- label.setHorizontalAlignment(HorizontalAlignment.CENTER);
- label.setVerticalAlignment(VerticalAlignment.CENTER);
- root.add(label, 32, 112, 192, 16);
-
- WSlider slider = new WSlider(1, 100, Axis.HORIZONTAL);
- slider.setDraggingFinishedListener(i -> {
- label.setText(Text.of("Scrolling Speed: " + i));
-
- scrollBarTop.setScrollingSpeed(i);
- scrollBarDown.setScrollingSpeed(i);
- scrollBarLeft.setScrollingSpeed(i);
- scrollBarRight.setScrollingSpeed(i);
- });
- root.add(slider, 78, 128, 100, 16);
-
- WToggleButton toggleButton = new WToggleButton();
- toggleButton.setOnToggle(on -> darkMode = on);
- root.add(toggleButton, 128 - (toggleButton.getWidth() / 2), 104 - (toggleButton.getHeight() / 2));
-
- root.validate(this);
- }
-
- @Override
- public TriState isDarkMode() {
- return TriState.of(darkMode);
- }
-}
diff --git a/src/testMod/java/io/github/cottonmc/test/client/ScrollingTestGui.java b/src/testMod/java/io/github/cottonmc/test/client/ScrollingTestGui.java
deleted file mode 100644
index af0d1e3..0000000
--- a/src/testMod/java/io/github/cottonmc/test/client/ScrollingTestGui.java
+++ /dev/null
@@ -1,72 +0,0 @@
-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.WBox;
-import io.github.cottonmc.cotton.gui.widget.WButton;
-import io.github.cottonmc.cotton.gui.widget.WGridPanel;
-import io.github.cottonmc.cotton.gui.widget.WLabel;
-import io.github.cottonmc.cotton.gui.widget.WLabeledSlider;
-import io.github.cottonmc.cotton.gui.widget.WScrollPanel;
-import io.github.cottonmc.cotton.gui.widget.data.Axis;
-import io.github.cottonmc.cotton.gui.widget.data.Insets;
-import io.github.cottonmc.cotton.gui.widget.data.VerticalAlignment;
-import io.github.cottonmc.cotton.gui.widget.icon.ItemIcon;
-
-public class ScrollingTestGui extends LightweightGuiDescription {
- public ScrollingTestGui() {
- WGridPanel root = (WGridPanel) rootPanel;
- WBox box = new WBox(Axis.VERTICAL);
- WScrollPanel scrollPanel = new WScrollPanel(box);
-
- for (int i = 0; i < 20; i++) {
- box.add(new WLabeledSlider(0, 10, Text.literal("Slider #" + i)));
- }
-
- box.add(new WButton(new ItemIcon(Items.APPLE)));
-
- WLabeledSlider topSlider = new WLabeledSlider(0, 16, Axis.HORIZONTAL, Text.literal("Top insets"));
- WLabeledSlider bottomSlider = new WLabeledSlider(0, 16, Axis.HORIZONTAL, Text.literal("Bottom insets"));
- WLabeledSlider leftSlider = new WLabeledSlider(0, 16, Axis.HORIZONTAL, Text.literal("Left insets"));
- WLabeledSlider rightSlider = new WLabeledSlider(0, 16, Axis.HORIZONTAL, Text.literal("Right insets"));
-
- topSlider.setValueChangeListener(top -> {
- Insets insets = scrollPanel.getInsets();
- Insets newInsets = new Insets(top, insets.left(), insets.bottom(), insets.right());
- scrollPanel.setInsets(newInsets);
- scrollPanel.layout();
- });
-
- bottomSlider.setValueChangeListener(bottom -> {
- Insets insets = scrollPanel.getInsets();
- Insets newInsets = new Insets(insets.top(), insets.left(), bottom, insets.right());
- scrollPanel.setInsets(newInsets);
- scrollPanel.layout();
- });
-
- leftSlider.setValueChangeListener(left -> {
- Insets insets = scrollPanel.getInsets();
- Insets newInsets = new Insets(insets.top(), left, insets.bottom(), insets.right());
- scrollPanel.setInsets(newInsets);
- scrollPanel.layout();
- });
-
- rightSlider.setValueChangeListener(right -> {
- Insets insets = scrollPanel.getInsets();
- Insets newInsets = new Insets(insets.top(), insets.left(), insets.bottom(), right);
- scrollPanel.setInsets(newInsets);
- scrollPanel.layout();
- });
-
- root.setGaps(2, 2);
- root.add(new WLabel(Text.literal("Scrolling test")).setVerticalAlignment(VerticalAlignment.CENTER), 0, 0, 6, 2);
- root.add(topSlider, 0, 2, 3, 1);
- root.add(bottomSlider, 3, 2, 3, 1);
- root.add(leftSlider, 0, 3, 3, 1);
- root.add(rightSlider, 3, 3, 3, 1);
- root.add(scrollPanel, 0, 4, 6, 3);
- root.validate(this);
- }
-}
diff --git a/src/testMod/java/io/github/cottonmc/test/client/TabTestGui.java b/src/testMod/java/io/github/cottonmc/test/client/TabTestGui.java
deleted file mode 100644
index 8ed93f9..0000000
--- a/src/testMod/java/io/github/cottonmc/test/client/TabTestGui.java
+++ /dev/null
@@ -1,26 +0,0 @@
-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.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(Text.literal("Kirb")));
- tabs.add(new WLabel(Text.literal("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() {
- }
-}
diff --git a/src/testMod/java/io/github/cottonmc/test/client/TestClientGui.java b/src/testMod/java/io/github/cottonmc/test/client/TestClientGui.java
deleted file mode 100644
index 7bc7ffb..0000000
--- a/src/testMod/java/io/github/cottonmc/test/client/TestClientGui.java
+++ /dev/null
@@ -1,156 +0,0 @@
-package io.github.cottonmc.test.client;
-
-import net.fabricmc.api.EnvType;
-import net.fabricmc.api.Environment;
-import net.minecraft.client.gui.DrawContext;
-import net.minecraft.text.Text;
-import net.minecraft.util.Identifier;
-
-import io.github.cottonmc.cotton.gui.client.LightweightGuiDescription;
-import io.github.cottonmc.cotton.gui.client.ScreenDrawing;
-import io.github.cottonmc.cotton.gui.widget.TooltipBuilder;
-import io.github.cottonmc.cotton.gui.widget.WGridPanel;
-import io.github.cottonmc.cotton.gui.widget.WLabel;
-import io.github.cottonmc.cotton.gui.widget.WSlider;
-import io.github.cottonmc.cotton.gui.widget.WTextField;
-import io.github.cottonmc.cotton.gui.widget.WTiledSprite;
-import io.github.cottonmc.cotton.gui.widget.WWidget;
-import io.github.cottonmc.cotton.gui.widget.data.Axis;
-import io.github.cottonmc.cotton.gui.widget.data.Color;
-import io.github.cottonmc.cotton.gui.widget.data.Insets;
-
-public class TestClientGui extends LightweightGuiDescription {
- //private static final Identifier PORTAL1 = new Identifier("libgui-test:portal.png");
- //private static final Identifier PORTAL2 = new Identifier("libgui-test:portal2.png");
-
- private int r = 0;
- private int g = 0;
- private int b = 0;
-
- public TestClientGui() {
- WGridPanel root = new WGridPanel(22);
- root.setInsets(Insets.ROOT_PANEL);
- this.setRootPanel(root);
- WLabel title = new WLabel(Text.literal("Client Test Gui"), WLabel.DEFAULT_TEXT_COLOR) {
- @Environment(EnvType.CLIENT)
- @Override
- public void addTooltip(TooltipBuilder tooltip) {
- tooltip.add(Text.literal("Radical!"));
- }
- };
- WTiledSprite wood = new WTiledSprite(
- 8, 8, // tile width and height
- 500, // animation speed
- new Identifier("minecraft:textures/block/birch_planks.png"),
- new Identifier("minecraft:textures/block/dark_oak_planks.png"),
- new Identifier("minecraft:textures/block/jungle_planks.png")
- );
- root.add(wood, 3, 3, 2, 2);
- root.add(title, 0, 0);
-
- WTextField text = new WTextField();
- text.setSuggestion(Text.literal("Search"));
- root.add(text, 0, 1, 8, 1);
- text.setSize(7*18, 20);
- /*
- ArrayList<String> data = new ArrayList<>();
- data.add("Wolfram Alpha");
- data.add("Strange Home");
- data.add("Nether Base");
- data.add("Death");
- data.add("Cake");
- data.add("Mushroom Island");
- data.add("A List Item");
- data.add("Notes");
- data.add("Slime Island");
-
- BiConsumer<String, PortalDestination> configurator = (String s, PortalDestination destination) -> {
- destination.label.setText(new LiteralText(s));
-
- int hash = s.hashCode();
- Identifier sprite = ((hash & 0x01) == 0) ? PORTAL1 : PORTAL2;
- destination.sprite.setImage(sprite);
-
- int cost = (hash >> 1) & 0x2FF;
- destination.cost.setText(new LiteralText(""+cost+" XP"));
- };
- WListPanel<String, PortalDestination> list = new WListPanel<String, PortalDestination>(data, PortalDestination.class, PortalDestination::new, configurator);
- list.setListItemHeight(2*18);
- list.setBackgroundPainter(PANEL);
- root.add(list, 0, 2, 7, 6);
-
- root.add(new WButton(new LiteralText("Teleport")), 3,8,4,1);*/
- WColorBox col = new WColorBox();
- root.add(col, 3,2,1,3);
-
- WSlider r = new WSlider(0, 100, Axis.VERTICAL);
- root.add(r, 0, 2, 1, 3);
- r.setValueChangeListener((i)->{
- this.r = i;
- updateCol(col);
- System.out.println("h: "+this.r+" s: "+this.g+ " l: "+this.b);
- System.out.println("col is now "+Integer.toHexString(col.color));
- });
- WSlider g = new WSlider(0, 100, Axis.VERTICAL);
- root.add(g, 1, 2, 1, 3);
- g.setValueChangeListener((i)->{
- this.g = i;
- updateCol(col);
- });
- WSlider b = new WSlider(0, 100, Axis.VERTICAL);
- root.add(b, 2, 2, 1, 3);
- b.setValueChangeListener((i)->{
- this.b = i;
- updateCol(col);
- });
-
- root.validate(this);
- }
- /*
- public static class PortalDestination extends WPlainPanel {
- WSprite sprite;
- WLabel label;
- WLabel cost;
-
- public PortalDestination() {
- sprite = new WSprite(new Identifier("libgui-test:portal"));
- this.add(sprite, 2, 2, 18, 18);
- label = new WLabel("Foo");
- this.add(label, 18+ 4, 2, 5*18, 18);
- cost = new WLabel("1000 Xp");
- this.add(cost, 2, 20, 6*18, 18);
-
- this.setSize(7*18, 2*18);
-
- this.setBackgroundPainter(PANEL); //Would fail on a serverside gui
- }
- }*/
-
- private void updateCol(WColorBox col) {
- Color.HSL hsl = new Color.HSL(r/100f, g/100f, b/100f);
- col.setColor(hsl.toRgb());
- }
-
- public static class WColorBox extends WWidget {
- protected int color = 0xFF_FFFFFF;
- public WColorBox() {}
-
- public WColorBox(int col) {
- this.color = col;
- }
-
- @Override
- public boolean canResize() {
- return true;
- }
-
- public void setColor(int col) {
- this.color = col;
- }
-
- @Override
- public void paint(DrawContext context, int x, int y, int mouseX, int mouseY) {
- ScreenDrawing.coloredRect(context, x, y, this.getWidth(), this.getHeight(), color);
- }
- }
-}
diff --git a/src/testMod/java/io/github/cottonmc/test/client/TextAlignmentTestGui.java b/src/testMod/java/io/github/cottonmc/test/client/TextAlignmentTestGui.java
deleted file mode 100644
index 600bf9f..0000000
--- a/src/testMod/java/io/github/cottonmc/test/client/TextAlignmentTestGui.java
+++ /dev/null
@@ -1,75 +0,0 @@
-package io.github.cottonmc.test.client;
-
-import net.minecraft.text.HoverEvent;
-import net.minecraft.text.MutableText;
-import net.minecraft.text.Text;
-import net.minecraft.util.Formatting;
-
-import io.github.cottonmc.cotton.gui.client.LightweightGuiDescription;
-import io.github.cottonmc.cotton.gui.widget.WGridPanel;
-import io.github.cottonmc.cotton.gui.widget.WLabel;
-import io.github.cottonmc.cotton.gui.widget.WLabeledSlider;
-import io.github.cottonmc.cotton.gui.widget.WTabPanel;
-import io.github.cottonmc.cotton.gui.widget.WText;
-import io.github.cottonmc.cotton.gui.widget.data.HorizontalAlignment;
-import io.github.cottonmc.cotton.gui.widget.data.Insets;
-import io.github.cottonmc.cotton.gui.widget.data.VerticalAlignment;
-
-import java.util.function.Consumer;
-import java.util.stream.IntStream;
-
-public final class TextAlignmentTestGui extends LightweightGuiDescription {
- public TextAlignmentTestGui() {
- WTabPanel tabPanel = new WTabPanel();
-
- WGridPanel labelPanel = new WGridPanel();
- labelPanel.setInsets(Insets.ROOT_PANEL);
- labelPanel.setGaps(0, 1);
- Text labelStyled = Text.literal("world")
- .styled(style -> style.withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, Text.of("test"))));
- Text labelText = Text.literal("hello, ").append(labelStyled);
- WLabel label = new WLabel(labelText);
- WLabeledSlider labelSliderH = forEnum(HorizontalAlignment.class, label::setHorizontalAlignment);
- WLabeledSlider labelSliderV = forEnum(VerticalAlignment.class, label::setVerticalAlignment);
- labelPanel.add(label, 0, 0, 5, 3);
- labelPanel.add(labelSliderH, 0, 3, 5, 1);
- labelPanel.add(labelSliderV, 0, 4, 5, 1);
-
- WGridPanel textPanel = new WGridPanel();
- textPanel.setInsets(Insets.ROOT_PANEL);
- textPanel.setGaps(0, 1);
- Text textText = IntStream.rangeClosed(1, 3)
- .mapToObj(line -> {
- Text textStyled = Text.literal("world").styled(style -> style
- .withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, Text.of("test")))
- .withColor(Formatting.values()[line + 9])
- );
- return Text.literal("hell" + "o".repeat(line * 3) + ", ").append(textStyled).append("\n");
- })
- .reduce(Text.empty(), MutableText::append);
- WText text = new WText(textText);
- WLabeledSlider textSliderH = forEnum(HorizontalAlignment.class, text::setHorizontalAlignment);
- WLabeledSlider textSliderV = forEnum(VerticalAlignment.class, text::setVerticalAlignment);
- textPanel.add(text, 0, 0, 5, 4);
- textPanel.add(textSliderH, 0, 4, 5, 1);
- textPanel.add(textSliderV, 0, 5, 5, 1);
-
- tabPanel.add(labelPanel, builder -> builder.title(Text.of("WLabel")));
- tabPanel.add(textPanel, builder -> builder.title(Text.of("WText")));
- setRootPanel(tabPanel);
- tabPanel.validate(this);
- }
-
- private static <E extends Enum<E>> WLabeledSlider forEnum(Class<E> type, Consumer<E> consumer) {
- E[] values = type.getEnumConstants();
- var slider = new WLabeledSlider(1, values.length);
- slider.setLabel(Text.of(type.getSimpleName() + ": " + values[0]));
- slider.setLabelUpdater(value -> Text.of(type.getSimpleName() + ": " + values[value - 1]));
- slider.setValueChangeListener(value -> consumer.accept(values[value - 1]));
- return slider;
- }
-
- @Override
- public void addPainters() {
- }
-}
diff --git a/src/testMod/java/io/github/cottonmc/test/client/TextFieldTestGui.java b/src/testMod/java/io/github/cottonmc/test/client/TextFieldTestGui.java
deleted file mode 100644
index ce2a7b6..0000000
--- a/src/testMod/java/io/github/cottonmc/test/client/TextFieldTestGui.java
+++ /dev/null
@@ -1,20 +0,0 @@
-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.WTextField;
-import io.github.cottonmc.cotton.gui.widget.icon.ItemIcon;
-
-public class TextFieldTestGui extends LightweightGuiDescription {
- public TextFieldTestGui() {
- WGridPanel grid = (WGridPanel) rootPanel;
- WTextField textField = new WTextField(Text.literal("Type something")).setMaxLength(Integer.MAX_VALUE);
- grid.add(textField, 0, 0, 6, 1);
- grid.add(new WButton(new ItemIcon(Items.BARRIER), Text.literal("Clear")).setOnClick(() -> textField.setText("")), 0, 2, 6, 1);
- rootPanel.validate(this);
- }
-}
diff --git a/src/testMod/java/io/github/cottonmc/test/client/TextureTestGui.java b/src/testMod/java/io/github/cottonmc/test/client/TextureTestGui.java
deleted file mode 100644
index 6925a3b..0000000
--- a/src/testMod/java/io/github/cottonmc/test/client/TextureTestGui.java
+++ /dev/null
@@ -1,94 +0,0 @@
-package io.github.cottonmc.test.client;
-
-import net.minecraft.text.Text;
-import net.minecraft.util.Identifier;
-
-import io.github.cottonmc.cotton.gui.client.LightweightGuiDescription;
-import io.github.cottonmc.cotton.gui.widget.WGridPanel;
-import io.github.cottonmc.cotton.gui.widget.WLabeledSlider;
-import io.github.cottonmc.cotton.gui.widget.WPanel;
-import io.github.cottonmc.cotton.gui.widget.WSlider;
-import io.github.cottonmc.cotton.gui.widget.WSprite;
-import io.github.cottonmc.cotton.gui.widget.WTabPanel;
-import io.github.cottonmc.cotton.gui.widget.data.Axis;
-import io.github.cottonmc.cotton.gui.widget.data.Insets;
-import io.github.cottonmc.cotton.gui.widget.data.Texture;
-import io.github.cottonmc.cotton.gui.widget.icon.TextureIcon;
-
-import java.util.function.IntConsumer;
-
-public class TextureTestGui extends LightweightGuiDescription {
- public TextureTestGui() {
- WTabPanel root = new WTabPanel();
-
- var panelSprite = new Texture(new Identifier("libgui:widget/panel_light"), Texture.Type.GUI_SPRITE);
- var panelTexture = new Texture(new Identifier("libgui:textures/gui/sprites/widget/panel_light.png"), Texture.Type.STANDALONE);
- var simpleSprite = new Texture(new Identifier("minecraft:icon/video_link"), Texture.Type.GUI_SPRITE);
-
- root.add(createPanel(panelSprite), tab -> tab.icon(new TextureIcon(panelSprite)).tooltip(Text.literal("Nine-slice sprite")));
- root.add(createPanel(simpleSprite), tab -> tab.icon(new TextureIcon(simpleSprite)).tooltip(Text.literal("Simple sprite")));
- root.add(createPanel(panelTexture), tab -> tab.icon(new TextureIcon(panelTexture)).tooltip(Text.literal("Standalone")));
- setRootPanel(root);
- root.validate(this);
- }
-
- @Override
- public void addPainters() {
- // Remove tab panel background
- }
-
- private WPanel createPanel(Texture texture) {
- WSprite sprite = new WSprite(texture);
-
- WLabeledSlider red = new WLabeledSlider(0, 255, Axis.HORIZONTAL, Text.literal("Red"));
- WLabeledSlider green = new WLabeledSlider(0, 255, Axis.HORIZONTAL, Text.literal("Green"));
- WLabeledSlider blue = new WLabeledSlider(0, 255, Axis.HORIZONTAL, Text.literal("Blue"));
- WLabeledSlider alpha = new WLabeledSlider(0, 255, Axis.HORIZONTAL, Text.literal("Alpha"));
-
- red.setValue(255);
- green.setValue(255);
- blue.setValue(255);
- alpha.setValue(255);
-
- WSlider u1 = new WSlider(0, 100, Axis.HORIZONTAL);
- WSlider u2 = new WSlider(0, 100, Axis.HORIZONTAL);
- WSlider v1 = new WSlider(0, 100, Axis.VERTICAL);
- WSlider v2 = new WSlider(0, 100, Axis.VERTICAL);
-
- u2.setValue(100);
- v2.setValue(100);
-
- IntConsumer tintListener = unused -> {
- sprite.setTint(blue.getValue() | (green.getValue() << 8) | (red.getValue() << 16) | (alpha.getValue() << 24));
- };
- red.setValueChangeListener(tintListener);
- green.setValueChangeListener(tintListener);
- blue.setValueChangeListener(tintListener);
- alpha.setValueChangeListener(tintListener);
-
- IntConsumer uvListener = unused -> {
- sprite.setUv(u1.getValue() * 0.01f, v1.getValue() * 0.01f, u2.getValue() * 0.01f, v2.getValue() * 0.01f);
- };
- u1.setValueChangeListener(uvListener);
- u2.setValueChangeListener(uvListener);
- v1.setValueChangeListener(uvListener);
- v2.setValueChangeListener(uvListener);
-
- WGridPanel panel = new WGridPanel(20);
- panel.setInsets(Insets.ROOT_PANEL);
- panel.setGaps(3, 3);
-
- panel.add(red, 0, 0, 3, 1);
- panel.add(green, 3, 0, 3, 1);
- panel.add(blue, 0, 1, 3, 1);
- panel.add(alpha, 3, 1, 3, 1);
-
- panel.add(u1, 2, 2, 4, 1);
- panel.add(u2, 2, 3, 4, 1);
- panel.add(v1, 0, 4, 1, 4);
- panel.add(v2, 1, 4, 1, 4);
-
- panel.add(sprite, 2, 4, 4, 4);
- return panel;
- }
-}
diff --git a/src/testMod/java/io/github/cottonmc/test/client/TitleAlignmentTestGui.java b/src/testMod/java/io/github/cottonmc/test/client/TitleAlignmentTestGui.java
deleted file mode 100644
index 46b3185..0000000
--- a/src/testMod/java/io/github/cottonmc/test/client/TitleAlignmentTestGui.java
+++ /dev/null
@@ -1,35 +0,0 @@
-package io.github.cottonmc.test.client;
-
-import net.minecraft.text.Text;
-
-import io.github.cottonmc.cotton.gui.client.LightweightGuiDescription;
-import io.github.cottonmc.cotton.gui.widget.WGridPanel;
-import io.github.cottonmc.cotton.gui.widget.WLabeledSlider;
-import io.github.cottonmc.cotton.gui.widget.data.HorizontalAlignment;
-
-public class TitleAlignmentTestGui extends LightweightGuiDescription {
- private static final HorizontalAlignment[] TITLE_ALIGNMENTS = {
- HorizontalAlignment.LEFT,
- HorizontalAlignment.CENTER,
- HorizontalAlignment.RIGHT
- };
- private HorizontalAlignment titleAlignment = HorizontalAlignment.LEFT;
-
- public TitleAlignmentTestGui() {
- WLabeledSlider titleSlider = new WLabeledSlider(0, TITLE_ALIGNMENTS.length - 1);
- titleSlider.setLabel(getLabel(HorizontalAlignment.LEFT));
- titleSlider.setLabelUpdater(value -> getLabel(TITLE_ALIGNMENTS[value]));
- titleSlider.setValueChangeListener(value -> titleAlignment = TITLE_ALIGNMENTS[value]);
- ((WGridPanel) rootPanel).add(titleSlider, 0, 1, 4, 1);
- rootPanel.validate(this);
- }
-
- private Text getLabel(HorizontalAlignment alignment) {
- return Text.literal(alignment.name());
- }
-
- @Override
- public HorizontalAlignment getTitleAlignment() {
- return titleAlignment;
- }
-}
diff --git a/src/testMod/java/io/github/cottonmc/test/client/WHudTest.java b/src/testMod/java/io/github/cottonmc/test/client/WHudTest.java
deleted file mode 100644
index 2f07c3a..0000000
--- a/src/testMod/java/io/github/cottonmc/test/client/WHudTest.java
+++ /dev/null
@@ -1,25 +0,0 @@
-package io.github.cottonmc.test.client;
-
-import net.fabricmc.api.EnvType;
-import net.fabricmc.api.Environment;
-import net.minecraft.client.gui.DrawContext;
-
-import io.github.cottonmc.cotton.gui.client.ScreenDrawing;
-import io.github.cottonmc.cotton.gui.widget.WWidget;
-import org.apache.logging.log4j.LogManager;
-import org.apache.logging.log4j.Logger;
-
-@Environment(EnvType.CLIENT)
-public class WHudTest extends WWidget {
- private static final Logger LOGGER = LogManager.getLogger();
-
- @Override
- public void paint(DrawContext context, int x, int y, int mouseX, int mouseY) {
- ScreenDrawing.coloredRect(context, x, y, width, height, 0xFF_00FF00);
- }
-
- @Override
- public void tick() {
- LOGGER.debug("tick!");
- }
-}