diff options
author | tpart <tpart120@proton.me> | 2024-07-12 01:20:10 +0200 |
---|---|---|
committer | tpart <tpart120@proton.me> | 2024-07-12 01:20:10 +0200 |
commit | 78186bdcb2f15f8ad00cb83ccaeb5273f328d41c (patch) | |
tree | fdd97bc462d341672ea528f3ad6b2b390103177a | |
parent | ca482a7b052883bd1d830a88d104bab366eeadeb (diff) | |
download | hurrycurry-78186bdcb2f15f8ad00cb83ccaeb5273f328d41c.tar hurrycurry-78186bdcb2f15f8ad00cb83ccaeb5273f328d41c.tar.bz2 hurrycurry-78186bdcb2f15f8ad00cb83ccaeb5273f328d41c.tar.zst |
Refactor hint system; Fix hint showing up multiple times
-rw-r--r-- | client/global.gd | 17 | ||||
-rw-r--r-- | client/menu/popup_message.gd | 18 |
2 files changed, 24 insertions, 11 deletions
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 |