diff --git a/.gitignore b/.gitignore index ab0abeb..e169342 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ .godot/ bin/ +*.import diff --git a/docs/docs/reference/console.md b/docs/docs/reference/console.md index 726f6d1..adf41bb 100644 --- a/docs/docs/reference/console.md +++ b/docs/docs/reference/console.md @@ -37,15 +37,20 @@ You can use these commands inside the debugging console: Displays information about certain topics [topic: String = "INDEX"] + + navigate + Navigates n slides forwards/backwards + <n|n+|n-> + config Reads and writes to the in-memory configuration - [get <key: String>|set <key: String> <value: Variant>|list] + <get <key: String>|set <key: String> <value: Variant>|list> pmana Controls the Presentation Manager - [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] + <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> preader diff --git a/src/console.gd b/src/console.gd index b21f435..34b39ec 100644 --- a/src/console.gd +++ b/src/console.gd @@ -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: diff --git a/src/console_info.gd b/src/console_info.gd index 9c15e15..f566e74 100644 --- a/src/console_info.gd +++ b/src/console_info.gd @@ -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 + +Navigates n slides forwards or backwards.""" HelpTopic.CONFIG: - return """config [get |set |list] + return """config |set |list> Returns, lists or overwrites Presencode's configuration. Lives in memory and cannot be saved to persistent storage.""" HelpTopic.PMANA: - return """pmana [register >|unregister|change_slide [no_animations: bool = false]|clear_viewport|hide_log|show_log] + return """pmana >|unregister|change_slide [no_animations: bool = false]|get_slide|clear_viewport|hide_log|show_log> Calls functions belonging to the Presentation Manager.""" HelpTopic.PREADER: