From 6173d3e9a45f17dc92318d11786c5631143808e5 Mon Sep 17 00:00:00 2001 From: tpart Date: Fri, 12 Jul 2024 00:49:30 +0200 Subject: Add hint system --- client/global.gd | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'client/global.gd') diff --git a/client/global.gd b/client/global.gd index 6584c1d9..38b228e3 100644 --- a/client/global.gd +++ b/client/global.gd @@ -24,7 +24,8 @@ signal using_joypad_change(using: bool) var default_profile := { "username": "Giovanni", "character": 0, - "last_server_url": "" + "last_server_url": "", + "hint_boost_seen": false } var languages := [tr("System default"), "en", "de"] var using_joypad := false @@ -203,6 +204,21 @@ func set_setting(key: String, value): push_error("Tried to set setting \"%s\", which does not yet exist (missing key)" % key) return settings[key].set_value(value) + save_settings() + +func get_profile(key: String): + if profile.has(key): + return profile[key] + else: + push_error("Tried to access profile setting \"%s\", which does not exist (missing key)" % key) + return null + +func set_profile(key: String, value): + if !profile.has(key): + push_error("Tried to set profile setting \"%s\", which does not yet exist (missing key)" % key) + return + profile[key] = value + save_profile() static func interpolate(current, target, dt): return target + (current - target) * exp(-dt) -- cgit v1.2.3-70-g09d2 From a9ee32b2e2126c622b23ae83329836faaacc7368 Mon Sep 17 00:00:00 2001 From: tpart Date: Fri, 12 Jul 2024 00:54:18 +0200 Subject: Add move hint; Increase display time of hints --- client/global.gd | 3 ++- client/menu/popup_message.gd | 4 ++++ client/menu/popup_message.tscn | 7 ++++++- 3 files changed, 12 insertions(+), 2 deletions(-) (limited to 'client/global.gd') diff --git a/client/global.gd b/client/global.gd index 38b228e3..cd1b5c8b 100644 --- a/client/global.gd +++ b/client/global.gd @@ -25,7 +25,8 @@ var default_profile := { "username": "Giovanni", "character": 0, "last_server_url": "", - "hint_boost_seen": false + "hint_move_seen": false, + "hint_boost_seen": false, } var languages := [tr("System default"), "en", "de"] var using_joypad := false diff --git a/client/menu/popup_message.gd b/client/menu/popup_message.gd index b0ead906..67b4d6ab 100644 --- a/client/menu/popup_message.gd +++ b/client/menu/popup_message.gd @@ -59,3 +59,7 @@ func _input(_event): func _on_boost_timeout(): if not Global.get_profile("hint_boost_seen") and not Global.get_setting("touch_controls"): display_hint_msg(tr("Press SHIFT/Controller B to boost")) + +func _on_move_timeout(): + if not Global.get_profile("hint_move_seen") and not Global.get_setting("touch_controls"): + display_hint_msg(tr("Use WASD/Controller left stick to move")) diff --git a/client/menu/popup_message.tscn b/client/menu/popup_message.tscn index 178f414b..32f54b1d 100644 --- a/client/menu/popup_message.tscn +++ b/client/menu/popup_message.tscn @@ -99,15 +99,20 @@ wait_time = 5.0 one_shot = true [node name="HintTimer" type="Timer" parent="."] -wait_time = 5.0 +wait_time = 10.0 one_shot = true [node name="HintTimers" type="Node" parent="."] +[node name="Move" type="Timer" parent="HintTimers"] +wait_time = 5.0 +one_shot = true + [node name="Boost" type="Timer" parent="HintTimers"] wait_time = 90.0 one_shot = true [connection signal="timeout" from="ServerTimer" to="." method="_on_server_timer_timeout"] [connection signal="timeout" from="HintTimer" to="." method="_on_hint_timer_timeout"] +[connection signal="timeout" from="HintTimers/Move" to="." method="_on_move_timeout"] [connection signal="timeout" from="HintTimers/Boost" to="." method="_on_boost_timeout"] -- cgit v1.2.3-70-g09d2 From 41f8c3c467bfeb51ec34c76b16c78145064e0af6 Mon Sep 17 00:00:00 2001 From: tpart Date: Fri, 12 Jul 2024 00:57:56 +0200 Subject: Add interact hint --- client/global.gd | 1 + client/menu/popup_message.gd | 4 ++++ client/menu/popup_message.tscn | 5 +++++ 3 files changed, 10 insertions(+) (limited to 'client/global.gd') diff --git a/client/global.gd b/client/global.gd index cd1b5c8b..b719890c 100644 --- a/client/global.gd +++ b/client/global.gd @@ -27,6 +27,7 @@ var default_profile := { "last_server_url": "", "hint_move_seen": false, "hint_boost_seen": false, + "hint_interact_seen": false } var languages := [tr("System default"), "en", "de"] var using_joypad := false diff --git a/client/menu/popup_message.gd b/client/menu/popup_message.gd index 67b4d6ab..b4afbf3c 100644 --- a/client/menu/popup_message.gd +++ b/client/menu/popup_message.gd @@ -63,3 +63,7 @@ func _on_boost_timeout(): func _on_move_timeout(): if not Global.get_profile("hint_move_seen") and not Global.get_setting("touch_controls"): display_hint_msg(tr("Use WASD/Controller left stick to move")) + +func _on_interact_timeout(): + if not Global.get_profile("hint_interact_seen") and not Global.get_setting("touch_controls"): + display_hint_msg(tr("Press SPACE/Controller A to pick up items and interact with tools")) diff --git a/client/menu/popup_message.tscn b/client/menu/popup_message.tscn index 32f54b1d..3eccfc2e 100644 --- a/client/menu/popup_message.tscn +++ b/client/menu/popup_message.tscn @@ -112,7 +112,12 @@ one_shot = true wait_time = 90.0 one_shot = true +[node name="Interact" type="Timer" parent="HintTimers"] +wait_time = 20.0 +one_shot = true + [connection signal="timeout" from="ServerTimer" to="." method="_on_server_timer_timeout"] [connection signal="timeout" from="HintTimer" to="." method="_on_hint_timer_timeout"] [connection signal="timeout" from="HintTimers/Move" to="." method="_on_move_timeout"] [connection signal="timeout" from="HintTimers/Boost" to="." method="_on_boost_timeout"] +[connection signal="timeout" from="HintTimers/Interact" to="." method="_on_interact_timeout"] -- cgit v1.2.3-70-g09d2 From 78186bdcb2f15f8ad00cb83ccaeb5273f328d41c Mon Sep 17 00:00:00 2001 From: tpart Date: Fri, 12 Jul 2024 01:20:10 +0200 Subject: Refactor hint system; Fix hint showing up multiple times --- client/global.gd | 17 ++++++++++------- client/menu/popup_message.gd | 18 ++++++++++++++---- 2 files changed, 24 insertions(+), 11 deletions(-) (limited to 'client/global.gd') diff --git a/client/global.gd b/client/global.gd index b719890c..0311910f 100644 --- a/client/global.gd +++ b/client/global.gd @@ -25,9 +25,10 @@ var default_profile := { "username": "Giovanni", "character": 0, "last_server_url": "", - "hint_move_seen": false, - "hint_boost_seen": false, - "hint_interact_seen": false + # HINTS: + "has_moved": false, + "has_boosted": false, + "has_interacted": false } var languages := [tr("System default"), "en", "de"] var using_joypad := false @@ -205,8 +206,9 @@ func set_setting(key: String, value): if !settings.has(key): push_error("Tried to set setting \"%s\", which does not yet exist (missing key)" % key) return - settings[key].set_value(value) - save_settings() + if get_setting(value) != value: + settings[key].set_value(value) + save_settings() func get_profile(key: String): if profile.has(key): @@ -219,8 +221,9 @@ func set_profile(key: String, value): if !profile.has(key): push_error("Tried to set profile setting \"%s\", which does not yet exist (missing key)" % key) return - profile[key] = value - save_profile() + if profile[key] != value: + profile[key] = value + save_profile() static func interpolate(current, target, dt): return target + (current - target) * exp(-dt) diff --git a/client/menu/popup_message.gd b/client/menu/popup_message.gd index b3654416..2b682343 100644 --- a/client/menu/popup_message.gd +++ b/client/menu/popup_message.gd @@ -54,21 +54,31 @@ func stop_game_hints(): func _input(_event): if Input.is_action_just_pressed("boost"): - Global.set_profile("hint_boost_seen", true) + Global.set_profile("has_boosted", true) + elif any_action_just_pressed(["forward", "backwards", "left", "right"]): + Global.set_profile("has_moved", true) + elif Input.is_action_just_pressed("interact"): + Global.set_profile("has_interacted", true) func _on_boost_timeout(): - if not Global.get_profile("hint_boost_seen") and not Global.get_setting("touch_controls"): + if not Global.get_profile("has_boosted") and not Global.get_setting("touch_controls"): display_hint_msg(tr("Press %s to boost") % display_keybind(tr("SHIFT"), "B")) func _on_move_timeout(): - if not Global.get_profile("hint_move_seen") and not Global.get_setting("touch_controls"): + if not Global.get_profile("has_moved") and not Global.get_setting("touch_controls"): display_hint_msg(tr("Use %s to move") % display_keybind("WASD", tr("left stick"))) func _on_interact_timeout(): - if not Global.get_profile("hint_interact_seen") and not Global.get_setting("touch_controls"): + if not Global.get_profile("has_interacted") and not Global.get_setting("touch_controls"): display_hint_msg(tr("Press %s to pick up items and interact with tools") % display_keybind(tr("SPACE"), "A")) func display_keybind(keyboard: String, joypad: String) -> String: if Global.using_joypad: return joypad + " (Joypad)" return keyboard + +func any_action_just_pressed(actions: Array) -> bool: + for a: String in actions: + if Input.is_action_just_pressed(a): + return true + return false -- cgit v1.2.3-70-g09d2 From 0f0c7713218dc9fc8beafdbe14785c11a0f61ea8 Mon Sep 17 00:00:00 2001 From: tpart Date: Fri, 12 Jul 2024 01:27:29 +0200 Subject: Add reset camera hint --- client/global.gd | 4 +++- client/menu/popup_message.gd | 23 ++++++++++++++++++----- client/menu/popup_message.tscn | 19 ++++++++++++------- 3 files changed, 33 insertions(+), 13 deletions(-) (limited to 'client/global.gd') diff --git a/client/global.gd b/client/global.gd index 0311910f..4a985e38 100644 --- a/client/global.gd +++ b/client/global.gd @@ -28,7 +28,9 @@ var default_profile := { # HINTS: "has_moved": false, "has_boosted": false, - "has_interacted": false + "has_interacted": false, + "has_rotated": false, + "has_reset": false } var languages := [tr("System default"), "en", "de"] var using_joypad := false diff --git a/client/menu/popup_message.gd b/client/menu/popup_message.gd index 2b682343..e70e1fef 100644 --- a/client/menu/popup_message.gd +++ b/client/menu/popup_message.gd @@ -25,7 +25,9 @@ class_name PopupMessage @onready var server_msg_label: Label = $VBox/ServerMessage/CenterContainer/Label @onready var hint_msg_label: Label = $VBox/HintMessage/CenterContainer/Label -@onready var hint_timers: Node = $HintTimers +@onready var auto_hint_timers: Node = $AutoHintTimers + +@onready var reset_timer = $Reset func display_server_msg(msg: String): server_msg.show() @@ -44,21 +46,27 @@ func _on_hint_timer_timeout(): hint_msg.hide() func start_game_hints(): - for c: Timer in hint_timers.get_children(): + for c: Timer in auto_hint_timers.get_children(): c.start() func stop_game_hints(): _on_hint_timer_timeout() - for c: Timer in hint_timers.get_children(): + for c: Timer in auto_hint_timers.get_children(): c.stop() func _input(_event): if Input.is_action_just_pressed("boost"): Global.set_profile("has_boosted", true) - elif any_action_just_pressed(["forward", "backwards", "left", "right"]): + if any_action_just_pressed(["forward", "backwards", "left", "right"]): Global.set_profile("has_moved", true) - elif Input.is_action_just_pressed("interact"): + if any_action_just_pressed(["rotate_left", "rotate_right", "rotate_up", "rotate_down"]): + if not Global.get_profile("has_reset"): + reset_timer.start() + Global.set_profile("has_rotated", true) + if Input.is_action_just_pressed("interact"): Global.set_profile("has_interacted", true) + if Input.is_action_just_pressed("reset"): + Global.set_profile("has_reset", true) func _on_boost_timeout(): if not Global.get_profile("has_boosted") and not Global.get_setting("touch_controls"): @@ -72,6 +80,10 @@ func _on_interact_timeout(): if not Global.get_profile("has_interacted") and not Global.get_setting("touch_controls"): display_hint_msg(tr("Press %s to pick up items and interact with tools") % display_keybind(tr("SPACE"), "A")) +func _on_reset_timeout(): + if not Global.get_profile("has_reset") and not Global.get_setting("touch_controls"): + display_hint_msg(tr("Press %s to reset the camera view") % display_keybind("R", "Y")) + func display_keybind(keyboard: String, joypad: String) -> String: if Global.using_joypad: return joypad + " (Joypad)" @@ -82,3 +94,4 @@ func any_action_just_pressed(actions: Array) -> bool: if Input.is_action_just_pressed(a): return true return false + diff --git a/client/menu/popup_message.tscn b/client/menu/popup_message.tscn index 3eccfc2e..37133847 100644 --- a/client/menu/popup_message.tscn +++ b/client/menu/popup_message.tscn @@ -102,22 +102,27 @@ one_shot = true wait_time = 10.0 one_shot = true -[node name="HintTimers" type="Node" parent="."] +[node name="AutoHintTimers" type="Node" parent="."] -[node name="Move" type="Timer" parent="HintTimers"] +[node name="Move" type="Timer" parent="AutoHintTimers"] wait_time = 5.0 one_shot = true -[node name="Boost" type="Timer" parent="HintTimers"] +[node name="Boost" type="Timer" parent="AutoHintTimers"] wait_time = 90.0 one_shot = true -[node name="Interact" type="Timer" parent="HintTimers"] +[node name="Interact" type="Timer" parent="AutoHintTimers"] wait_time = 20.0 one_shot = true +[node name="Reset" type="Timer" parent="."] +wait_time = 10.0 +one_shot = true + [connection signal="timeout" from="ServerTimer" to="." method="_on_server_timer_timeout"] [connection signal="timeout" from="HintTimer" to="." method="_on_hint_timer_timeout"] -[connection signal="timeout" from="HintTimers/Move" to="." method="_on_move_timeout"] -[connection signal="timeout" from="HintTimers/Boost" to="." method="_on_boost_timeout"] -[connection signal="timeout" from="HintTimers/Interact" to="." method="_on_interact_timeout"] +[connection signal="timeout" from="AutoHintTimers/Move" to="." method="_on_move_timeout"] +[connection signal="timeout" from="AutoHintTimers/Boost" to="." method="_on_boost_timeout"] +[connection signal="timeout" from="AutoHintTimers/Interact" to="." method="_on_interact_timeout"] +[connection signal="timeout" from="Reset" to="." method="_on_reset_timeout"] -- cgit v1.2.3-70-g09d2