Debug menu, reorganized game scene
This commit is contained in:
15
resources/console_commands/help_command.gd
Normal file
15
resources/console_commands/help_command.gd
Normal file
@@ -0,0 +1,15 @@
|
||||
class_name HelpCommand extends ConsoleCommand
|
||||
|
||||
func get_command_name() -> String:
|
||||
return "help"
|
||||
|
||||
func get_help_text() -> String:
|
||||
return "Lists all available commands"
|
||||
|
||||
func run(args: Array, context: Dictionary) -> String:
|
||||
var commands: Array = context["commands"]
|
||||
var lines: PackedStringArray = []
|
||||
for command: ConsoleCommand in commands:
|
||||
lines.append("%s - %s" % [command.get_command_name(), command.get_help_text()])
|
||||
lines.append("Any other input is evaluated as a GDScript expression.")
|
||||
return "\n".join(lines)
|
||||
1
resources/console_commands/help_command.gd.uid
Normal file
1
resources/console_commands/help_command.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://bvat5xgudptct
|
||||
14
resources/console_commands/list_scenes_command.gd
Normal file
14
resources/console_commands/list_scenes_command.gd
Normal file
@@ -0,0 +1,14 @@
|
||||
class_name ListScenesCommand extends ConsoleCommand
|
||||
|
||||
func get_command_name() -> String:
|
||||
return "list_scenes"
|
||||
|
||||
func get_help_text() -> String:
|
||||
return "Lists available scenes for swapping"
|
||||
|
||||
func run(args: Array, context: Dictionary) -> String:
|
||||
var registry: Array = context["scene_registry"]
|
||||
var lines: PackedStringArray = []
|
||||
for entry: Dictionary in registry:
|
||||
lines.append(entry["name"])
|
||||
return "\n".join(lines)
|
||||
1
resources/console_commands/list_scenes_command.gd.uid
Normal file
1
resources/console_commands/list_scenes_command.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://b51b3np7lxd3v
|
||||
21
resources/console_commands/swap_command.gd
Normal file
21
resources/console_commands/swap_command.gd
Normal file
@@ -0,0 +1,21 @@
|
||||
class_name SwapCommand extends ConsoleCommand
|
||||
|
||||
func get_command_name() -> String:
|
||||
return "swap"
|
||||
|
||||
func get_help_text() -> String:
|
||||
return "swap <name> - Swap to a scene by name (use list_scenes to see options)"
|
||||
|
||||
func run(args: Array, context: Dictionary) -> String:
|
||||
if args.size() == 0:
|
||||
return "Usage: swap <scene name>"
|
||||
|
||||
var search_name := " ".join(args).to_lower()
|
||||
var registry: Array = context["scene_registry"]
|
||||
for entry: Dictionary in registry:
|
||||
if entry["name"].to_lower() == search_name:
|
||||
var debug_menu: Node = context["debug_menu"]
|
||||
debug_menu.swap_scene(entry)
|
||||
return ""
|
||||
|
||||
return "Scene not found: %s" % search_name
|
||||
1
resources/console_commands/swap_command.gd.uid
Normal file
1
resources/console_commands/swap_command.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://b56j4uyjiaku1
|
||||
10
resources/resource_definitions/console_command.gd
Normal file
10
resources/resource_definitions/console_command.gd
Normal file
@@ -0,0 +1,10 @@
|
||||
class_name ConsoleCommand extends RefCounted
|
||||
|
||||
func get_command_name() -> String:
|
||||
return ""
|
||||
|
||||
func get_help_text() -> String:
|
||||
return ""
|
||||
|
||||
func run(args: Array, context: Dictionary) -> String:
|
||||
return ""
|
||||
1
resources/resource_definitions/console_command.gd.uid
Normal file
1
resources/resource_definitions/console_command.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://b2kk8l3kumxpr
|
||||
Reference in New Issue
Block a user