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/ .godot/
bin/ 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>Displays information about certain topics</td>
<td>[topic: String = "INDEX"]</td> <td>[topic: String = "INDEX"]</td>
</tr> </tr>
<tr>
<td>navigate</td>
<td>Navigates n slides forwards/backwards</td>
<td>&lt;n|n+|n-&gt;</td>
</tr>
<tr> <tr>
<td>config</td> <td>config</td>
<td>Reads and writes to the in-memory configuration</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>
<tr> <tr>
<td>pmana</td> <td>pmana</td>
<td>Controls the Presentation Manager</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>
<tr> <tr>
<td>preader</td> <td>preader</td>

View file

@ -45,6 +45,7 @@ var cursor_origin: Vector2 = Vector2(0, 0)
func _ready() -> void: func _ready() -> void:
logger.info("Initializing debug console") logger.info("Initializing debug console")
visible = false
position = Vector2(30, 30) position = Vector2(30, 30)
calculate_drag_area() calculate_drag_area()
# Setup window dragging # Setup window dragging
@ -136,11 +137,11 @@ func process_command(command: PackedStringArray) -> void:
match(command[0]): match(command[0]):
"clear": "clear":
match(command.size()): 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 = "" output.text = ""
"exit": "exit":
match(command.size()): 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"])) await process_command(PackedStringArray(["clear"]))
append_output("""[color=#d60532]Welcome to the Presencode debug console! 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()): match(command.size()):
1: exitcode = 0 1: exitcode = 0
2: exitcode = int(command[1]) 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) pmana.shutdown(exitcode)
"help": "help":
match(command.size()): match(command.size()):
1: append_output(info.get_help_topic(info.HelpTopic.INDEX)) 1: append_output(info.get_help_topic(ConsoleInfo.HelpTopic.INDEX))
2: 2:
match(command[1]): match(command[1]):
"index": append_output(info.get_help_topic(info.HelpTopic.INDEX)) "index": append_output(info.get_help_topic(ConsoleInfo.HelpTopic.INDEX))
"clear": append_output(info.get_help_topic(info.HelpTopic.CLEAR)) "clear": append_output(info.get_help_topic(ConsoleInfo.HelpTopic.CLEAR))
"exit": append_output(info.get_help_topic(info.HelpTopic.EXIT)) "exit": append_output(info.get_help_topic(ConsoleInfo.HelpTopic.EXIT))
"shutdown": append_output(info.get_help_topic(info.HelpTopic.SHUTDOWN)) "shutdown": append_output(info.get_help_topic(ConsoleInfo.HelpTopic.SHUTDOWN))
"help": append_output(info.get_help_topic(info.HelpTopic.HELP)) "help": append_output(info.get_help_topic(ConsoleInfo.HelpTopic.HELP))
"config": append_output(info.get_help_topic(info.HelpTopic.CONFIG)) "navigate": append_output(info.get_help_topic(ConsoleInfo.HelpTopic.NAVIGATE))
"pmana": append_output(info.get_help_topic(info.HelpTopic.PMANA)) "config": append_output(info.get_help_topic(ConsoleInfo.HelpTopic.CONFIG))
"preader": append_output(info.get_help_topic(info.HelpTopic.PREADER)) "pmana": append_output(info.get_help_topic(ConsoleInfo.HelpTopic.PMANA))
"arbitrary": append_output(info.get_help_topic(info.HelpTopic.ARBITRARY)) "preader": append_output(info.get_help_topic(ConsoleInfo.HelpTopic.PREADER))
_: append_output(info.get_error_string(info.ConsoleError.INVALID_HELP_TOPIC)) "arbitrary": append_output(info.get_help_topic(ConsoleInfo.HelpTopic.ARBITRARY))
_: append_output(info.get_error_string(info.ConsoleError.TOO_MANY_ARGUMENTS)) _: 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": "config":
match(command.size()): match(command.size()):
1: append_output(info.get_error_string(ConsoleInfo.ConsoleError.TOO_FEW_ARGUMENTS)) 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"})) 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.generate_internal_error("Invalid get_int() status number"))
_: append_output(info.get_error_string(ConsoleInfo.ConsoleError.TOO_MANY_ARGUMENTS)) _: 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": "clear_viewport":
if !pmana.registered: append_output(info.get_error_string(ConsoleInfo.ConsoleError.NO_CONTROLLER_REGISTERED)) if !pmana.registered: append_output(info.get_error_string(ConsoleInfo.ConsoleError.NO_CONTROLLER_REGISTERED))
else: else:

View file

@ -48,6 +48,7 @@ enum HelpTopic {
EXIT, EXIT,
SHUTDOWN, SHUTDOWN,
HELP, HELP,
NAVIGATE,
CONFIG, CONFIG,
PMANA, PMANA,
PREADER, PREADER,
@ -113,6 +114,7 @@ clear | Clears the console output
exit | Starts a fresh session exit | Starts a fresh session
shutdown | Shuts Presencode down shutdown | Shuts Presencode down
help | Displays information about certain topics help | Displays information about certain topics
navigate | Navigate n slides forwards/backwards
config | Reads and writes to the in-memory configuration config | Reads and writes to the in-memory configuration
pmana | Controls the Presentation Manager pmana | Controls the Presentation Manager
preader | Controls the Presentation Reader preader | Controls the Presentation Reader
@ -135,12 +137,16 @@ Shuts Presencode down, accepts a exitcode ranging from 0-255."""
return """help [topic: String = "INDEX"] return """help [topic: String = "INDEX"]
Displays useful information about commands.""" Displays useful information about commands."""
HelpTopic.NAVIGATE:
return """navigate <n|+n|-n>
Navigates n slides forwards or backwards."""
HelpTopic.CONFIG: 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.""" Returns, lists or overwrites Presencode's configuration. Lives in memory and cannot be saved to persistent storage."""
HelpTopic.PMANA: 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.""" Calls functions belonging to the Presentation Manager."""
HelpTopic.PREADER: HelpTopic.PREADER: