Changed debug control to winodw

- Changed debug control into custom window dialog.
- Reworked "whereyoufrom" cheat
- Changed how the money cheat works
This commit is contained in:
Tony Bark 2021-05-20 22:16:43 -04:00
parent f6438a9bee
commit e86dd64b8b
5 changed files with 54 additions and 30 deletions

View file

@ -3,21 +3,28 @@
[ext_resource path="res://scripts/debug_console.gd" type="Script" id=1] [ext_resource path="res://scripts/debug_console.gd" type="Script" id=1]
[ext_resource path="res://scripts/command_handler.gd" type="Script" id=2] [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 pause_mode = 2
anchor_right = 1.0 anchor_left = 0.302734
margin_bottom = 113.0 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 ) script = ExtResource( 1 )
__meta__ = { __meta__ = {
"_edit_use_anchors_": false "_edit_use_anchors_": true
} }
[node name="CommandHandler" type="Node" parent="."] [node name="CommandHandler" type="Node" parent="."]
script = ExtResource( 2 ) script = ExtResource( 2 )
[node name="Output" type="TextEdit" parent="."] [node name="Output" type="TextEdit" parent="."]
anchor_right = 1.0 anchor_left = 0.0148515
anchor_bottom = 0.752212 anchor_top = 0.0372671
anchor_right = 0.987624
anchor_bottom = 0.751553
readonly = true readonly = true
wrap_enabled = true wrap_enabled = true
__meta__ = { __meta__ = {
@ -25,13 +32,26 @@ __meta__ = {
} }
[node name="Input" type="LineEdit" parent="."] [node name="Input" type="LineEdit" parent="."]
anchor_top = 0.787611 anchor_left = 0.0173267
anchor_right = 1.0 anchor_top = 0.801242
anchor_bottom = 1.0 anchor_right = 0.80198
anchor_bottom = 0.950311
caret_blink = true caret_blink = true
caret_blink_speed = 0.5 caret_blink_speed = 0.5
__meta__ = { __meta__ = {
"_edit_use_anchors_": true "_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="text_entered" from="Input" to="." method="_on_Input_text_entered"]
[connection signal="pressed" from="SubmitBtn" to="." method="_on_SubmitBtn_pressed"]

View file

@ -43,9 +43,9 @@ autostart = true
[node name="Controls" type="CanvasLayer" parent="."] [node name="Controls" type="CanvasLayer" parent="."]
[node name="Core" type="Control" parent="Controls"] [node name="Core" type="Control" parent="Controls"]
anchor_left = -0.00137095 anchor_left = -0.00268195
anchor_top = -0.000954026 anchor_top = -0.000954026
anchor_right = 0.998629 anchor_right = 0.997318
anchor_bottom = 0.999044 anchor_bottom = 0.999044
margin_left = -0.172424 margin_left = -0.172424
margin_top = 2.77234 margin_top = 2.77234
@ -57,11 +57,14 @@ __meta__ = {
} }
[node name="Console" parent="Controls/Core" instance=ExtResource( 21 )] [node name="Console" parent="Controls/Core" instance=ExtResource( 21 )]
visible = false anchor_left = 0.597656
anchor_left = 0.00585937 anchor_top = 0.0500001
anchor_right = 0.994141 anchor_right = 0.988281
anchor_bottom = 0.185 anchor_bottom = 0.300001
margin_right = 0.0
margin_bottom = 0.0 margin_bottom = 0.0
rect_min_size = Vector2( 400, 150 )
resizable = true
[node name="AdvsiorNotice" parent="Controls/Core" instance=ExtResource( 2 )] [node name="AdvsiorNotice" parent="Controls/Core" instance=ExtResource( 2 )]
avatar = ExtResource( 30 ) avatar = ExtResource( 30 )

View file

@ -8,13 +8,14 @@ enum {
} }
const valid_commands = [ const valid_commands = [
["motherlode", [null], ["money", [ARG_INT] ],
["whereyoufrom", [ARG_STRING]] ["whereyoufrom", [ARG_STRING] ]
]
] ]
func motherlode(): func money(value):
SimData.budget += 50000 SimData.budget += int(value)
return "Budget changed to " + str(value)
func whereyoufrom(city_name): func whereyoufrom(value):
SimData.city_name = city_name SimData.city_name = str(value)
return "Changed city name to: " + str(value)

View file

@ -8,6 +8,5 @@ func _ready():
advisor.show() advisor.show()
func _process(delta): func _process(delta):
if Input.is_action_just_released("ui_cheats"): if Input.is_action_pressed("ui_cheats"):
debug_console.show() debug_console.show()
get_tree().paused = true

View file

@ -1,4 +1,4 @@
extends Control extends WindowDialog
onready var input_box = $Input onready var input_box = $Input
onready var output_box = $Output onready var output_box = $Output
@ -28,8 +28,8 @@ func process_command(text: String):
for i in range(words.size()): for i in range(words.size()):
if not check_type(words[i], cmd[1][i]): if not check_type(words[i], cmd[1][i]):
output_text(str('Failure executing command "', cmd_word, '", parameter ', (i + 1), output_text(str('Failure executing command "', cmd_word,
' ("', words[i], '") is of the wrong type')) '", parameter ', (i + 1), ' ("', words[i], '") is of the wrong type'))
return return
output_text(command_handler.callv(cmd_word, words)) output_text(command_handler.callv(cmd_word, words))
@ -52,12 +52,13 @@ func check_type(string: String, type):
return false return false
func output_text(text): func output_text(text):
output_box.text = str(output_box.text + "\n", text) output_box.text = str(output_box.text + "\n", text)
func _on_Input_text_entered(new_text): func _on_Input_text_entered(new_text):
input_box.clear() input_box.clear()
process_command(new_text) process_command(new_text)
func _on_SubmitBtn_pressed():
input_box.clear()
process_command(input_box.text)