Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Initial setup & a few base types * Scroll panels (not tested yet) * Buttons, enum util, better id handling, cleanups * Text support, `getTaggedObject` * Insets support * Labels and dynamic labels * Registration based system * Allow specifying GUI scripts as widgets * Proper `registerGuiElement` error checking * Cleaner insets handling * Cleanup button handling * Item elements * Debug handling rework/cleanup * Improve dynamic label error handling * Scroll panel scroll speed setters * Text field elements * Grid panels * Box elements * Slider elements * Progress bars * Improve texture parsing, minor cleanups * Cleaner icon format * Sprite elements * Fix texture/icon parsing no value handling * Toggle buttons * Cleaner path handling * Error handling & context fixups * No wildcard static imports * Minor cleanups to tab panel parsing * Plain panels: match naming for child widgets * Initial work on meta * Bar documentation * Document insets, textures, and icons * Finalize `gui` command * Box elements meta * Button meta, minor cleanups, remove event for now * Dynamic label element * Grid panel meta + minor rename for consistency * Item elements meta * Slider element meta * Labeled slider meta * Properly document slider context values * Label elements meta * Plain panel elements meta * Scroll panel elements meta * Sprite element meta docs * Tab panel element meta * Text element meta * Text field elements meta * Toggle buttons meta docs * Consistency * Bump LibGUI and other deps * Revert outdated `ItemTag` change * `getTaggedStringList`: support in-line `ListTag`s * `bar` -> `progress_bar` * Consistent box panel naming * Clearer dynamic label warning * Grid panels: `gap` -> `spacing` * Sliders: direction must match axis * Clarify slider dynamic label meta * `Item` element: `duration` -> `frame_duration` * UV handling: width & height instead of 2 points * Better gui script handling in screen event * `GUI` command: support closing * Why is `gui` `Holdable` * `SpriteElement`: `frame_time` -> `duration` * `TextFieldElement`: consistent naming * Fix `gui` command syntax * Meta fixup
- Loading branch information
Showing
26 changed files
with
1,758 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
80 changes: 62 additions & 18 deletions
80
src/main/java/com/denizenscript/clientizen/scripts/commands/GuiCommand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,80 @@ | ||
package com.denizenscript.clientizen.scripts.commands; | ||
|
||
import com.denizenscript.clientizen.scripts.containers.GuiScriptContainer; | ||
import com.denizenscript.clientizen.scripts.containers.gui.GuiScriptContainer; | ||
import com.denizenscript.clientizen.scripts.containers.gui.GuiScriptGuiDescription; | ||
import com.denizenscript.clientizen.scripts.containers.gui.GuiScriptScreen; | ||
import com.denizenscript.denizencore.exceptions.InvalidArgumentsRuntimeException; | ||
import com.denizenscript.denizencore.objects.core.ScriptTag; | ||
import com.denizenscript.denizencore.scripts.ScriptEntry; | ||
import com.denizenscript.denizencore.scripts.commands.AbstractCommand; | ||
import com.denizenscript.denizencore.scripts.commands.Holdable; | ||
import com.denizenscript.denizencore.scripts.commands.generator.ArgDefaultNull; | ||
import com.denizenscript.denizencore.scripts.commands.generator.ArgLinear; | ||
import com.denizenscript.denizencore.scripts.commands.generator.ArgName; | ||
import com.denizenscript.denizencore.utilities.debugging.Debug; | ||
import io.github.cottonmc.cotton.gui.widget.WPanel; | ||
import net.minecraft.client.MinecraftClient; | ||
|
||
public class GuiCommand extends AbstractCommand implements Holdable { | ||
public class GuiCommand extends AbstractCommand { | ||
|
||
// <--[command] | ||
// @Name gui | ||
// @Syntax gui [open <script>/close] | ||
// @Required 1 | ||
// @Maximum 2 | ||
// @Short Opens a GUI script into a GUI or closes a currently open one. | ||
// @Group GUI System | ||
// | ||
// @Description | ||
// Opens the GUI script specified as a GUI, or closes a currently open one. | ||
// The GUI script must have a panel of any kind as it's element to be opened (which can contain any other elements within it). | ||
// | ||
// @Tags | ||
// None | ||
// | ||
// @Usage | ||
// Opens a GUI script named "my_gui". | ||
// - gui open my_gui | ||
// | ||
// @Usage | ||
// Closes the currently open GUI. | ||
// - gui close | ||
// | ||
// --> | ||
|
||
public GuiCommand() { | ||
setName("gui"); | ||
setSyntax("gui [<script>]"); | ||
setRequiredArguments(1, 1); | ||
setSyntax("gui [open <script>/close]"); | ||
setRequiredArguments(1, 2); | ||
autoCompile(); | ||
} | ||
|
||
public static void autoExecute(ScriptEntry scriptEntry, | ||
@ArgLinear @ArgName("script") ScriptTag script) { | ||
if (script.getContainer() instanceof GuiScriptContainer gui) { | ||
/*SpruceScreen screen = new SpruceScreen(Text.literal("Test GUI screen")) { | ||
@Override | ||
public void addCustomTabCompletions(TabCompletionsBuilder tab) { | ||
tab.addScriptsOfType(GuiScriptContainer.class); | ||
} | ||
|
||
public enum Action {OPEN, CLOSE} | ||
|
||
@Override | ||
protected void init() { | ||
super.init(); | ||
addDrawableChild(new SpruceButtonWidget(Position.center(width, height), 150, 20, Text.literal(gui.buttonName), btn -> { | ||
client.player.sendMessage(Text.literal("hello"), false); | ||
})); | ||
public static void autoExecute(@ArgName("action") Action action, | ||
@ArgName("script") @ArgLinear @ArgDefaultNull ScriptTag script) { | ||
MinecraftClient client = MinecraftClient.getInstance(); | ||
switch (action) { | ||
case OPEN -> { | ||
if (script == null) { | ||
throw new InvalidArgumentsRuntimeException("Must specify a GUI script to open."); | ||
} | ||
if (!(script.getContainer() instanceof GuiScriptContainer guiScript)) { | ||
Debug.echoError("Invalid script '" + script.debuggable() + "<W>' specified: must be a GUI script."); | ||
return; | ||
} | ||
WPanel rootPanel = guiScript.createGUIRoot(); | ||
if (rootPanel == null) { | ||
Debug.echoError("GUI script '" + script.debuggable() + "<W>' is invalid."); | ||
return; | ||
} | ||
}; | ||
screen.init(MinecraftClient.getInstance(), 500, 500);*/ | ||
GuiScriptScreen screen = new GuiScriptScreen(new GuiScriptGuiDescription(rootPanel), guiScript); | ||
client.send(() -> client.setScreen(screen)); | ||
} | ||
case CLOSE -> client.send(() -> client.setScreen(null)); | ||
} | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
...ain/java/com/denizenscript/clientizen/scripts/containers/ClientizenContainerRegistry.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 0 additions & 14 deletions
14
src/main/java/com/denizenscript/clientizen/scripts/containers/GuiScriptContainer.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.