diff --git a/godot_ship/scenes/Debug Menu.tscn b/godot_ship/scenes/Debug Menu.tscn index 3d235bf..fe579aa 100644 --- a/godot_ship/scenes/Debug Menu.tscn +++ b/godot_ship/scenes/Debug Menu.tscn @@ -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"] diff --git a/godot_ship/script/debug/In.gd b/godot_ship/script/debug/In.gd new file mode 100644 index 0000000..efdca27 --- /dev/null +++ b/godot_ship/script/debug/In.gd @@ -0,0 +1,9 @@ +extends LineEdit + + +# Declare member variables here. Examples: +# var a = 2 +# var b = "text" + +func _on_Debug_clear_line(): + clear() diff --git a/godot_ship/script/debug/LineEdit.gd b/godot_ship/script/debug/LineEdit.gd new file mode 100644 index 0000000..efdca27 --- /dev/null +++ b/godot_ship/script/debug/LineEdit.gd @@ -0,0 +1,9 @@ +extends LineEdit + + +# Declare member variables here. Examples: +# var a = 2 +# var b = "text" + +func _on_Debug_clear_line(): + clear() diff --git a/godot_ship/script/debug/Out.gd b/godot_ship/script/debug/Out.gd new file mode 100644 index 0000000..90681a6 --- /dev/null +++ b/godot_ship/script/debug/Out.gd @@ -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) diff --git a/godot_ship/script/debug/debug_menu.gd b/godot_ship/script/debug/debug_menu.gd index dde0a1a..9f14b13 100644 --- a/godot_ship/script/debug/debug_menu.gd +++ b/godot_ship/script/debug/debug_menu.gd @@ -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()) diff --git a/godot_ship/script/game/Main.gd b/godot_ship/script/game/Main.gd index 677fb4d..e98fe09 100644 --- a/godot_ship/script/game/Main.gd +++ b/godot_ship/script/game/Main.gd @@ -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():