Improve console

- [.gitignore] Include files ending in .import
- [src/console.gd] Replace "info.HelpTopic" with "ConsoleInfo.HelpTopic"
- [src/console.gd] Replace "info.ConsoleError" with "ConsoleInfo.ConsoleError"
- [src/console.gd] Make console invisible on startup
- [src/console.gd, src/console_info.gd] Add "get_slide" subcommand to command "pmana"
- [src/console.gd, src/console_info.gd] Add "navigate" command
- [src/console_info.gd] "CONFIG" and "PMANA" help topics now use correct syntax styling
This commit is contained in:
JeremyStar™ 2024-01-16 21:24:36 +01:00
parent 52cd448ff0
commit 73d6e889c5
4 changed files with 55 additions and 19 deletions

1
.gitignore vendored
View file

@ -1,2 +1,3 @@
.godot/
bin/
*.import

View file

@ -37,15 +37,20 @@ You can use these commands inside the debugging console:
<td>Displays information about certain topics</td>
<td>[topic: String = "INDEX"]</td>
</tr>
<tr>
<td>navigate</td>
<td>Navigates n slides forwards/backwards</td>
<td>&lt;n|n+|n-&gt;</td>
</tr>
<tr>
<td>config</td>
<td>Reads and writes to the in-memory configuration</td>
<td>[get &lt;key: String&gt;|set &lt;key: String&gt; &lt;value: Variant&gt;|list]</td>
<td>&lt;get &lt;key: String&gt;|set &lt;key: String&gt; &lt;value: Variant&gt;|list&gt;</td>
</tr>
<tr>
<td>pmana</td>
<td>Controls the Presentation Manager</td>
<td>[register &lt;version: int&gt; &lt;slides: int&gt; &lt;animations: bool&gt; &lt;quit_last_slide: bool&gt; &lt;controller: NodePath&lt;String&gt;&gt;|unregister|change_slide &lt;slide: int&gt; [no_animations: bool = false]|clear_viewport|hide_log|show_log]</td>
<td>&lt;register &lt;version: int&gt; &lt;slides: int&gt; &lt;animations: bool&gt; &lt;quit_last_slide: bool&gt; &lt;controller: NodePath&lt;String&gt;&gt;|unregister|change_slide &lt;slide: int&gt; [no_animations: bool = false]|get_slide|clear_viewport|hide_log|show_log&gt;</td>
</tr>
<tr>
<td>preader</td>

View file

@ -45,6 +45,7 @@ var cursor_origin: Vector2 = Vector2(0, 0)
func _ready() -> void:
logger.info("Initializing debug console")
visible = false
position = Vector2(30, 30)
calculate_drag_area()
# Setup window dragging
@ -136,11 +137,11 @@ func process_command(command: PackedStringArray) -> void:
match(command[0]):
"clear":
match(command.size()):
_: append_output(info.get_error_string(info.ConsoleError.TOO_MANY_ARGUMENTS))
_: append_output(info.get_error_string(ConsoleInfo.ConsoleError.TOO_MANY_ARGUMENTS))
output.text = ""
"exit":
match(command.size()):
_: append_output(info.get_error_string(info.ConsoleError.TOO_MANY_ARGUMENTS))
_: append_output(info.get_error_string(ConsoleInfo.ConsoleError.TOO_MANY_ARGUMENTS))
await process_command(PackedStringArray(["clear"]))
append_output("""[color=#d60532]Welcome to the Presencode debug console!
@ -151,24 +152,43 @@ To get started, enter \"help\". To close the console, press the X button.[color=
match(command.size()):
1: exitcode = 0
2: exitcode = int(command[1])
_: append_output(info.get_error_string(info.ConsoleError.TOO_MANY_ARGUMENTS))
_: append_output(info.get_error_string(ConsoleInfo.ConsoleError.TOO_MANY_ARGUMENTS))
pmana.shutdown(exitcode)
"help":
match(command.size()):
1: append_output(info.get_help_topic(info.HelpTopic.INDEX))
1: append_output(info.get_help_topic(ConsoleInfo.HelpTopic.INDEX))
2:
match(command[1]):
"index": append_output(info.get_help_topic(info.HelpTopic.INDEX))
"clear": append_output(info.get_help_topic(info.HelpTopic.CLEAR))
"exit": append_output(info.get_help_topic(info.HelpTopic.EXIT))
"shutdown": append_output(info.get_help_topic(info.HelpTopic.SHUTDOWN))
"help": append_output(info.get_help_topic(info.HelpTopic.HELP))
"config": append_output(info.get_help_topic(info.HelpTopic.CONFIG))
"pmana": append_output(info.get_help_topic(info.HelpTopic.PMANA))
"preader": append_output(info.get_help_topic(info.HelpTopic.PREADER))
"arbitrary": append_output(info.get_help_topic(info.HelpTopic.ARBITRARY))
_: append_output(info.get_error_string(info.ConsoleError.INVALID_HELP_TOPIC))
_: append_output(info.get_error_string(info.ConsoleError.TOO_MANY_ARGUMENTS))
"index": append_output(info.get_help_topic(ConsoleInfo.HelpTopic.INDEX))
"clear": append_output(info.get_help_topic(ConsoleInfo.HelpTopic.CLEAR))
"exit": append_output(info.get_help_topic(ConsoleInfo.HelpTopic.EXIT))
"shutdown": append_output(info.get_help_topic(ConsoleInfo.HelpTopic.SHUTDOWN))
"help": append_output(info.get_help_topic(ConsoleInfo.HelpTopic.HELP))
"navigate": append_output(info.get_help_topic(ConsoleInfo.HelpTopic.NAVIGATE))
"config": append_output(info.get_help_topic(ConsoleInfo.HelpTopic.CONFIG))
"pmana": append_output(info.get_help_topic(ConsoleInfo.HelpTopic.PMANA))
"preader": append_output(info.get_help_topic(ConsoleInfo.HelpTopic.PREADER))
"arbitrary": append_output(info.get_help_topic(ConsoleInfo.HelpTopic.ARBITRARY))
_: append_output(info.get_error_string(ConsoleInfo.ConsoleError.INVALID_HELP_TOPIC))
_: append_output(info.get_error_string(ConsoleInfo.ConsoleError.TOO_MANY_ARGUMENTS))
"navigate":
match(command.size()):
1: append_output(info.get_error_string(ConsoleInfo.ConsoleError.TOO_FEW_ARGUMENTS))
2:
if !command[1].is_valid_int():
append_output(info.get_error_string(ConsoleInfo.ConsoleError.INVALID_ARGUMENT))
else:
var sign_: int = misc.get_sign(int(command[1]))
match(sign_):
+1:
pmana.change_slide(pmana.current_slide+int(command[1]))
append_output("Navigated " + command[1] + " slide(s) forwards.")
-1:
pmana.change_slide(pmana.current_slide+int(command[1]))
append_output("Navigated " + command[1] + " slide(s) backwards.")
0: append_output(info.get_error_string(ConsoleInfo.ConsoleError.INVALID_ARGUMENT))
_: append_output(info.generate_internal_error("Invalid sign \"" + str(sign_) + "\""))
_: append_output(info.get_error_string(ConsoleInfo.ConsoleError.TOO_MANY_ARGUMENTS))
"config":
match(command.size()):
1: append_output(info.get_error_string(ConsoleInfo.ConsoleError.TOO_FEW_ARGUMENTS))
@ -351,6 +371,10 @@ MISC_SHUTDOWN_INVISIBLE | bool | Toggles if the window should be made invisibl
1: append_output(info.get_error_string(ConsoleInfo.ConsoleError.INVALID_TYPE, {"expected_type": "int"}))
_: append_output(info.generate_internal_error("Invalid get_int() status number"))
_: append_output(info.get_error_string(ConsoleInfo.ConsoleError.TOO_MANY_ARGUMENTS))
"get_slide":
if !pmana.registered: append_output(info.get_error_string(ConsoleInfo.ConsoleError.NO_CONTROLLER_REGISTERED))
else:
append_output("The current slide id is [b]" + str(pmana.current_slide) + "[/b]")
"clear_viewport":
if !pmana.registered: append_output(info.get_error_string(ConsoleInfo.ConsoleError.NO_CONTROLLER_REGISTERED))
else:

View file

@ -48,6 +48,7 @@ enum HelpTopic {
EXIT,
SHUTDOWN,
HELP,
NAVIGATE,
CONFIG,
PMANA,
PREADER,
@ -113,6 +114,7 @@ clear | Clears the console output
exit | Starts a fresh session
shutdown | Shuts Presencode down
help | Displays information about certain topics
navigate | Navigate n slides forwards/backwards
config | Reads and writes to the in-memory configuration
pmana | Controls the Presentation Manager
preader | Controls the Presentation Reader
@ -135,12 +137,16 @@ Shuts Presencode down, accepts a exitcode ranging from 0-255."""
return """help [topic: String = "INDEX"]
Displays useful information about commands."""
HelpTopic.NAVIGATE:
return """navigate <n|+n|-n>
Navigates n slides forwards or backwards."""
HelpTopic.CONFIG:
return """config [get <key: String>|set <key: String> <value: Variant>|list]
return """config <get <key: String>|set <key: String> <value: Variant>|list>
Returns, lists or overwrites Presencode's configuration. Lives in memory and cannot be saved to persistent storage."""
HelpTopic.PMANA:
return """pmana [register <version: int> <slides: int> <animations: bool> <quit_last_slide: bool> <controller: NodePath<String>>|unregister|change_slide <slide: int> [no_animations: bool = false]|clear_viewport|hide_log|show_log]
return """pmana <register <version: int> <slides: int> <animations: bool> <quit_last_slide: bool> <controller: NodePath<String>>|unregister|change_slide <slide: int> [no_animations: bool = false]|get_slide|clear_viewport|hide_log|show_log>
Calls functions belonging to the Presentation Manager."""
HelpTopic.PREADER: