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:
parent
b9947393a5
commit
5f8c881c1c
@ -1,13 +1,13 @@
|
||||
[gd_scene load_steps=3 format=2]
|
||||
[gd_scene load_steps=5 format=2]
|
||||
|
||||
[ext_resource path="res://main.tres" type="Theme" id=1]
|
||||
[ext_resource path="res://script/debug/debug_menu.gd" type="Script" id=2]
|
||||
[ext_resource path="res://script/debug/In.gd" type="Script" id=3]
|
||||
[ext_resource path="res://script/debug/Out.gd" type="Script" id=4]
|
||||
|
||||
[node name="Debug" type="Control"]
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
margin_top = -360.0
|
||||
margin_bottom = -360.0
|
||||
theme = ExtResource( 1 )
|
||||
script = ExtResource( 2 )
|
||||
__meta__ = {
|
||||
@ -16,8 +16,6 @@ __meta__ = {
|
||||
|
||||
[node name="debug_canvas" type="CanvasLayer" parent="."]
|
||||
layer = 69
|
||||
offset = Vector2( 0, -360 )
|
||||
transform = Transform2D( 1, 0, 0, 1, 0, -360 )
|
||||
|
||||
[node name="VBoxContainer" type="VBoxContainer" parent="debug_canvas"]
|
||||
anchor_right = 1.0
|
||||
@ -36,8 +34,10 @@ rect_min_size = Vector2( 0, 144 )
|
||||
readonly = true
|
||||
syntax_highlighting = true
|
||||
fold_gutter = true
|
||||
smooth_scrolling = true
|
||||
wrap_enabled = true
|
||||
minimap_draw = true
|
||||
script = ExtResource( 4 )
|
||||
|
||||
[node name="LineEdit" type="LineEdit" parent="debug_canvas/VBoxContainer"]
|
||||
margin_top = 146.0
|
||||
@ -46,5 +46,8 @@ margin_bottom = 170.0
|
||||
max_length = 256
|
||||
placeholder_text = "By your command."
|
||||
caret_blink = true
|
||||
script = ExtResource( 3 )
|
||||
|
||||
[connection signal="clear_line" from="." to="debug_canvas/VBoxContainer/LineEdit" method="_on_Debug_clear_line"]
|
||||
[connection signal="print_text" from="." to="debug_canvas/VBoxContainer/TextEdit" method="_on_Debug_print_text"]
|
||||
[connection signal="text_entered" from="debug_canvas/VBoxContainer/LineEdit" to="." method="_on_LineEdit_text_entered"]
|
||||
|
9
godot_ship/script/debug/In.gd
Normal file
9
godot_ship/script/debug/In.gd
Normal file
@ -0,0 +1,9 @@
|
||||
extends LineEdit
|
||||
|
||||
|
||||
# Declare member variables here. Examples:
|
||||
# var a = 2
|
||||
# var b = "text"
|
||||
|
||||
func _on_Debug_clear_line():
|
||||
clear()
|
9
godot_ship/script/debug/LineEdit.gd
Normal file
9
godot_ship/script/debug/LineEdit.gd
Normal file
@ -0,0 +1,9 @@
|
||||
extends LineEdit
|
||||
|
||||
|
||||
# Declare member variables here. Examples:
|
||||
# var a = 2
|
||||
# var b = "text"
|
||||
|
||||
func _on_Debug_clear_line():
|
||||
clear()
|
10
godot_ship/script/debug/Out.gd
Normal file
10
godot_ship/script/debug/Out.gd
Normal 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)
|
@ -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())
|
||||
|
@ -28,12 +28,20 @@ func _ready():
|
||||
func _on_scene_start(scene):
|
||||
print ("_on_scene_start(",scene,")")
|
||||
match scene:
|
||||
"Singleplayer": add_child (gameplay.instance())
|
||||
"Multiplayer":
|
||||
"Singleplayer":
|
||||
add_child (gameplay.instance())
|
||||
return true
|
||||
"Multiplayer":
|
||||
add_child (gameplay.instance())
|
||||
# add_child (multiplayercontroller.instance())
|
||||
"Options": add_child (options.instance())
|
||||
"Title": add_child (title_screen.instance())
|
||||
return true
|
||||
"Options":
|
||||
add_child (options.instance())
|
||||
return true
|
||||
"Title":
|
||||
add_child (title_screen.instance())
|
||||
return true
|
||||
|
||||
|
||||
# Kills all child nodes with name matching `scene`
|
||||
func _on_scene_kill(scene):
|
||||
@ -42,6 +50,8 @@ func _on_scene_kill(scene):
|
||||
for i in range (c.size()):
|
||||
if c[i].name == scene:
|
||||
c[i].queue_free()
|
||||
return true
|
||||
return false
|
||||
|
||||
# Quits
|
||||
func _on_quit_request():
|
||||
|
Loading…
x
Reference in New Issue
Block a user