mirror of
https://github.com/JohnBreaux/Boat-Battle.git
synced 2024-11-15 05:25:57 +00:00
Finish debug menu for the night.
This commit is contained in:
parent
2d1ada2588
commit
5e82efbe4c
@ -2,7 +2,7 @@ extends TextEdit
|
|||||||
|
|
||||||
# Called when the node enters the scene tree for the first time.
|
# Called when the node enters the scene tree for the first time.
|
||||||
func _ready():
|
func _ready():
|
||||||
MessageBus.connect("print_console", self, "_on_Debug_print_text")
|
var _errno = MessageBus.connect("print_console", self, "_on_Debug_print_text")
|
||||||
pass # Replace with function body.
|
pass # Replace with function body.
|
||||||
|
|
||||||
|
|
||||||
|
@ -16,23 +16,28 @@ var menu_hidden = Transform2D(Vector2(1,0), Vector2(0,1), Vector2(0,-170))
|
|||||||
var menu_active = Transform2D(Vector2(1,0), Vector2(0,1), Vector2(0, 0))
|
var menu_active = Transform2D(Vector2(1,0), Vector2(0,1), Vector2(0, 0))
|
||||||
|
|
||||||
# signals
|
# signals
|
||||||
signal clear_in
|
signal clear_in # clears the debug input
|
||||||
signal clear_out
|
signal clear_out # clears the debug output
|
||||||
signal print_text(text)
|
signal print_text(text) # Sends text for printing to the Out buffer
|
||||||
|
|
||||||
# Called when the node enters the scene tree for the first time.
|
# Called when the node enters the scene tree for the first time.
|
||||||
func _ready():
|
func _ready():
|
||||||
|
|
||||||
debug_canvas = get_node("debug_canvas")
|
debug_canvas = get_node("debug_canvas")
|
||||||
debug_transform = debug_canvas.get_transform()
|
debug_transform = debug_canvas.get_transform()
|
||||||
debug_output = get_node("debug_canvas/VBoxContainer/TextEdit")
|
debug_output = get_node("debug_canvas/VBoxContainer/TextEdit")
|
||||||
|
command_help([""])
|
||||||
|
|
||||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||||
func _process(delta):
|
func _process(delta):
|
||||||
if (debug_active && menu_position < 1):
|
if (debug_active && menu_position < 1):
|
||||||
|
# Move the menu down
|
||||||
menu_position += menu_velocity * delta;
|
menu_position += menu_velocity * delta;
|
||||||
|
$debug_canvas/VBoxContainer/LineEdit.grab_focus()
|
||||||
elif (!debug_active && menu_position > 0):
|
elif (!debug_active && menu_position > 0):
|
||||||
|
# Move the menu up
|
||||||
menu_position -= menu_velocity * delta;
|
menu_position -= menu_velocity * delta;
|
||||||
|
# Clear the input box
|
||||||
|
emit_signal("clear_in")
|
||||||
else:
|
else:
|
||||||
menu_position = round(menu_position)
|
menu_position = round(menu_position)
|
||||||
|
|
||||||
@ -42,6 +47,8 @@ func _input(event):
|
|||||||
if event.is_action_pressed("ui_debug"):
|
if event.is_action_pressed("ui_debug"):
|
||||||
# open debug menu
|
# open debug menu
|
||||||
debug_active = !debug_active;
|
debug_active = !debug_active;
|
||||||
|
# Hand the keyboard focus to the next valid focus
|
||||||
|
if (!debug_active): find_next_valid_focus().grab_focus()
|
||||||
|
|
||||||
func _on_LineEdit_text_entered(line):
|
func _on_LineEdit_text_entered(line):
|
||||||
emit_signal("clear_in")
|
emit_signal("clear_in")
|
||||||
@ -82,19 +89,22 @@ func command_start (command):
|
|||||||
|
|
||||||
# stop: Stops scene by name of root node.
|
# stop: Stops scene by name of root node.
|
||||||
func command_stop (command):
|
func command_stop (command):
|
||||||
if command.size() > 1 and command[1] != "Debug":
|
if command.size() > 1:
|
||||||
MessageBus.emit_signal("kill_scene", command[1])
|
if command[1] != "Debug":
|
||||||
debug_print_line("kill '" + command[1] + "'\n")
|
debug_print_line("kill '" + command[1] + "'\n")
|
||||||
|
MessageBus.emit_signal("kill_scene", command[1])
|
||||||
|
else:
|
||||||
|
debug_print_line("YOU DIDN'T SAY THE MAGIC WORD!\n")
|
||||||
else:
|
else:
|
||||||
debug_print_line("Usage: kill scene")
|
debug_print_line("Usage: kill scene")
|
||||||
|
|
||||||
# list: Lists names of active scenes (children of Root)
|
# list: Lists names of active scenes (children of Root)
|
||||||
func command_list (command):
|
func command_list (_command):
|
||||||
debug_print_line("list: ")
|
debug_print_line("list: ")
|
||||||
MessageBus.emit_signal("list_scenes")
|
MessageBus.emit_signal("list_scenes")
|
||||||
|
|
||||||
# restart: Kills the current tree and replants Root
|
# restart: Kills the current tree and replants Root
|
||||||
func command_restart (command):
|
func command_restart (_command):
|
||||||
MessageBus.emit_signal("return_to_title")
|
MessageBus.emit_signal("return_to_title")
|
||||||
|
|
||||||
# print: prints a message to the in-game debug console
|
# print: prints a message to the in-game debug console
|
||||||
@ -115,13 +125,16 @@ func command_emit (command):
|
|||||||
0: debug_print_line( "Usage: raw_emit signal [value]\n")
|
0: debug_print_line( "Usage: raw_emit signal [value]\n")
|
||||||
|
|
||||||
# clear: clears the debug output
|
# clear: clears the debug output
|
||||||
func command_clear (command):
|
func command_clear (_command):
|
||||||
emit_signal("clear_out");
|
emit_signal("clear_out");
|
||||||
|
|
||||||
|
func command_tree (_command):
|
||||||
|
pass
|
||||||
|
|
||||||
# help: Prints help dialogue
|
# help: Prints help dialogue
|
||||||
func command_help (command):
|
func command_help (command):
|
||||||
if (command.size() == 1):
|
if (command.size() == 1):
|
||||||
debug_print_line("Ship's Commander V0.1\n")
|
debug_print_line("Ship's Commander V 0.1\n")
|
||||||
debug_print_line("Valid commands:\nstart, stop, list, restart, print, emit, clear, help\n")
|
debug_print_line("Valid commands:\nstart, stop, list, restart, print, emit, clear, help\n")
|
||||||
else:
|
else:
|
||||||
debug_print_line(command[1])
|
debug_print_line(command[1])
|
||||||
@ -152,4 +165,4 @@ func command_help (command):
|
|||||||
debug_print_line("Prints information about a command.\n")
|
debug_print_line("Prints information about a command.\n")
|
||||||
_:
|
_:
|
||||||
debug_print_line(command[1] + "\nIsn't a valid command\n")
|
debug_print_line(command[1] + "\nIsn't a valid command\n")
|
||||||
debug_print_line("\n")
|
debug_print_line("\n")
|
||||||
|
@ -11,12 +11,13 @@ var debug_enabled = true
|
|||||||
# Called when the node enters the scene tree for the first time.
|
# Called when the node enters the scene tree for the first time.
|
||||||
func _ready():
|
func _ready():
|
||||||
# Connect to signals
|
# Connect to signals
|
||||||
MessageBus.connect("start_tcsn", self, "_on_scene_start_by_name")
|
var _errno = 0;
|
||||||
MessageBus.connect("change_scene", self, "_on_scene_start")
|
_errno += MessageBus.connect("start_tcsn", self, "_on_scene_start_by_name")
|
||||||
MessageBus.connect("kill_scene", self, "_on_scene_kill")
|
_errno += MessageBus.connect("change_scene", self, "_on_scene_start")
|
||||||
MessageBus.connect("list_scenes", self, "_on_scene_list")
|
_errno += MessageBus.connect("kill_scene", self, "_on_scene_kill")
|
||||||
MessageBus.connect("quit", self, "_on_quit_request")
|
_errno += MessageBus.connect("list_scenes", self, "_on_scene_list")
|
||||||
MessageBus.connect("return_to_title", self, "_on_title_request")
|
_errno += MessageBus.connect("quit", self, "_on_quit_request")
|
||||||
|
_errno += MessageBus.connect("return_to_title", self, "_on_title_request")
|
||||||
# Create the scenes
|
# Create the scenes
|
||||||
title_screen = preload("res://scenes/Title Screen.tscn")
|
title_screen = preload("res://scenes/Title Screen.tscn")
|
||||||
gameplay = preload("res://scenes/Gameplay.tscn")
|
gameplay = preload("res://scenes/Gameplay.tscn")
|
||||||
|
Loading…
Reference in New Issue
Block a user