1
0
mirror of https://github.com/JohnBreaux/Boat-Battle.git synced 2025-02-04 12:28:35 +00:00

Make debug menu fully functional, flesh out command bus.

This commit is contained in:
2021-10-20 03:18:06 -05:00
committed by John
parent b9947393a5
commit 5f8c881c1c
6 changed files with 74 additions and 18 deletions

View File

@@ -0,0 +1,9 @@
extends LineEdit
# Declare member variables here. Examples:
# var a = 2
# var b = "text"
func _on_Debug_clear_line():
clear()

View File

@@ -0,0 +1,9 @@
extends LineEdit
# Declare member variables here. Examples:
# var a = 2
# var b = "text"
func _on_Debug_clear_line():
clear()

View File

@@ -0,0 +1,10 @@
extends TextEdit
# Called when the node enters the scene tree for the first time.
func _ready():
MessageBus.connect("print_console", self, "_on_Debug_print_text")
pass # Replace with function body.
func _on_Debug_print_text(text):
insert_text_at_cursor(text)

View File

@@ -15,6 +15,10 @@ var menu_velocity = 4
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))
# signals
signal clear_line
signal print_text(text)
# Called when the node enters the scene tree for the first time.
func _ready():
@@ -33,31 +37,42 @@ func _process(delta):
debug_canvas.set_transform(menu_hidden.interpolate_with(menu_active, menu_position))
func _unhandled_input(event):
func _input(event):
if event.is_action_pressed("ui_debug"):
# open debug menu
debug_active = !debug_active;
func _on_LineEdit_text_entered(line):
emit_signal("clear_line")
debug_print_line("")
var command = line.split(' ', true, 1)
if command.size() > 0:
print("match ", command)
match command[0]:
"open":
"start":
if command.size() > 1:
MessageBus.emit_signal("change_scene", command[1])
debug_print_line("start '" + command[1] + "'\n".c_unescape())
else:
debug_print_line("Usage: open scene")
debug_print_line("Usage: start scene")
"kill":
if command.size() > 1:
if command.size() > 1 and command[1] != "Debug":
MessageBus.emit_signal("kill_scene", command[1])
debug_print_line("kill '" + command[1] + "'\n".c_unescape())
else:
debug_print_line("Usage: kill scene")
"restart":
MessageBus.emit_signal("return_to_title")
else:
pass
"print":
if command.size() > 1:
debug_print_line(command[1].c_unescape())
"raw_emit":
var mbus_signal = command[1].split(' ', true, 1)
match mbus_signal.size():
2: MessageBus.emit_signal(mbus_signal[0], mbus_signal[1])
1: MessageBus.emit_signal(mbus_signal[0])
0: debug_print_line( "Usage: raw_emit signal [value]\n")
_:
debug_print_line("BY YOUR COMMAND.\n")
func debug_print_line(string):
debug_output.set_line(debug_line, string)
debug_line += 1
emit_signal("print_text", string.c_unescape())