From e86dd64b8b042fbabc10e67aa5f6b42435679806 Mon Sep 17 00:00:00 2001 From: Tony Bark <35226681+tonytins@users.noreply.github.com> Date: Thu, 20 May 2021 22:16:43 -0400 Subject: [PATCH] Changed debug control to winodw - Changed debug control into custom window dialog. - Reworked "whereyoufrom" cheat - Changed how the money cheat works --- scenes/DebugConsole.tscn | 38 +++++++++++++++++++++++++++++--------- scenes/game.tscn | 15 +++++++++------ scripts/command_handler.gd | 15 ++++++++------- scripts/core_gui.gd | 3 +-- scripts/debug_console.gd | 13 +++++++------ 5 files changed, 54 insertions(+), 30 deletions(-) diff --git a/scenes/DebugConsole.tscn b/scenes/DebugConsole.tscn index f423f6a..767c412 100644 --- a/scenes/DebugConsole.tscn +++ b/scenes/DebugConsole.tscn @@ -3,21 +3,28 @@ [ext_resource path="res://scripts/debug_console.gd" type="Script" id=1] [ext_resource path="res://scripts/command_handler.gd" type="Script" id=2] -[node name="DebugConsole" type="Control"] +[node name="DebugConsole" type="WindowDialog"] pause_mode = 2 -anchor_right = 1.0 -margin_bottom = 113.0 +anchor_left = 0.302734 +anchor_top = 0.365833 +anchor_right = 0.697266 +anchor_bottom = 0.634167 +margin_right = -4.0 +margin_bottom = -1.0 +window_title = "Console" script = ExtResource( 1 ) __meta__ = { -"_edit_use_anchors_": false +"_edit_use_anchors_": true } [node name="CommandHandler" type="Node" parent="."] script = ExtResource( 2 ) [node name="Output" type="TextEdit" parent="."] -anchor_right = 1.0 -anchor_bottom = 0.752212 +anchor_left = 0.0148515 +anchor_top = 0.0372671 +anchor_right = 0.987624 +anchor_bottom = 0.751553 readonly = true wrap_enabled = true __meta__ = { @@ -25,13 +32,26 @@ __meta__ = { } [node name="Input" type="LineEdit" parent="."] -anchor_top = 0.787611 -anchor_right = 1.0 -anchor_bottom = 1.0 +anchor_left = 0.0173267 +anchor_top = 0.801242 +anchor_right = 0.80198 +anchor_bottom = 0.950311 caret_blink = true caret_blink_speed = 0.5 __meta__ = { "_edit_use_anchors_": true } +[node name="SubmitBtn" type="Button" parent="."] +anchor_left = 0.824257 +anchor_top = 0.796624 +anchor_right = 0.985148 +anchor_bottom = 0.951903 +margin_top = 7.62939e-06 +text = "Submit" +__meta__ = { +"_edit_use_anchors_": true +} + [connection signal="text_entered" from="Input" to="." method="_on_Input_text_entered"] +[connection signal="pressed" from="SubmitBtn" to="." method="_on_SubmitBtn_pressed"] diff --git a/scenes/game.tscn b/scenes/game.tscn index 277e241..64e644a 100644 --- a/scenes/game.tscn +++ b/scenes/game.tscn @@ -43,9 +43,9 @@ autostart = true [node name="Controls" type="CanvasLayer" parent="."] [node name="Core" type="Control" parent="Controls"] -anchor_left = -0.00137095 +anchor_left = -0.00268195 anchor_top = -0.000954026 -anchor_right = 0.998629 +anchor_right = 0.997318 anchor_bottom = 0.999044 margin_left = -0.172424 margin_top = 2.77234 @@ -57,11 +57,14 @@ __meta__ = { } [node name="Console" parent="Controls/Core" instance=ExtResource( 21 )] -visible = false -anchor_left = 0.00585937 -anchor_right = 0.994141 -anchor_bottom = 0.185 +anchor_left = 0.597656 +anchor_top = 0.0500001 +anchor_right = 0.988281 +anchor_bottom = 0.300001 +margin_right = 0.0 margin_bottom = 0.0 +rect_min_size = Vector2( 400, 150 ) +resizable = true [node name="AdvsiorNotice" parent="Controls/Core" instance=ExtResource( 2 )] avatar = ExtResource( 30 ) diff --git a/scripts/command_handler.gd b/scripts/command_handler.gd index e3ab1bb..f8cc484 100644 --- a/scripts/command_handler.gd +++ b/scripts/command_handler.gd @@ -8,13 +8,14 @@ enum { } const valid_commands = [ - ["motherlode", [null], - ["whereyoufrom", [ARG_STRING]] - ] + ["money", [ARG_INT] ], + ["whereyoufrom", [ARG_STRING] ] ] -func motherlode(): - SimData.budget += 50000 +func money(value): + SimData.budget += int(value) + return "Budget changed to " + str(value) -func whereyoufrom(city_name): - SimData.city_name = city_name +func whereyoufrom(value): + SimData.city_name = str(value) + return "Changed city name to: " + str(value) diff --git a/scripts/core_gui.gd b/scripts/core_gui.gd index 831ef8e..d9dd5f3 100644 --- a/scripts/core_gui.gd +++ b/scripts/core_gui.gd @@ -8,6 +8,5 @@ func _ready(): advisor.show() func _process(delta): - if Input.is_action_just_released("ui_cheats"): + if Input.is_action_pressed("ui_cheats"): debug_console.show() - get_tree().paused = true diff --git a/scripts/debug_console.gd b/scripts/debug_console.gd index 8036df1..48c16ae 100644 --- a/scripts/debug_console.gd +++ b/scripts/debug_console.gd @@ -1,4 +1,4 @@ -extends Control +extends WindowDialog onready var input_box = $Input onready var output_box = $Output @@ -28,8 +28,8 @@ func process_command(text: String): for i in range(words.size()): if not check_type(words[i], cmd[1][i]): - output_text(str('Failure executing command "', cmd_word, '", parameter ', (i + 1), - ' ("', words[i], '") is of the wrong type')) + output_text(str('Failure executing command "', cmd_word, + '", parameter ', (i + 1), ' ("', words[i], '") is of the wrong type')) return output_text(command_handler.callv(cmd_word, words)) @@ -52,12 +52,13 @@ func check_type(string: String, type): return false - - - func output_text(text): output_box.text = str(output_box.text + "\n", text) func _on_Input_text_entered(new_text): input_box.clear() process_command(new_text) + +func _on_SubmitBtn_pressed(): + input_box.clear() + process_command(input_box.text)