# Hurry Curry! - a game about cooking # Copyright 2024 tpart # Copyright 2024 nokoe # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, version 3 of the License only. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . # extends MarginContainer class_name PopupMessage var is_ingame := false var is_joined := false @onready var server_msg = $VBox/ServerMessage @onready var hint_msg = $VBox/HintMessage @onready var server_msg_timer: Timer = $ServerTimer @onready var hint_msg_timer: Timer = $HintTimer @onready var server_msg_label: Label = $VBox/ServerMessage/CenterContainer/Label @onready var hint_msg_label: Label = $VBox/HintMessage/CenterContainer/Label @onready var auto_hint_timers: Node = $AutoHintTimers @onready var reset_timer = $Reset @onready var join_while_running_timer = $JoinWhileRunning @onready var game: Game = $"../Game" func _ready(): game.joined.connect( func player_joined(): is_joined = true update_state() ) game.left.connect( func player_joined(): is_joined = false update_state() ) func ingame(): is_ingame = true update_state() func lobby(): is_ingame = false update_state() func update_state(): if is_ingame and is_joined: start_game_hints() elif is_ingame: stop_game_hints() join_while_running_timer.start() else: stop_game_hints() func display_server_msg(msg: String): server_msg.show() server_msg_label.text = msg server_msg_timer.start() func _on_server_timer_timeout(): server_msg.hide() func display_hint_msg(msg: String): hint_msg.show() hint_msg_label.text = tr("Hint") + ": %s" % msg hint_msg_timer.start() func _on_hint_timer_timeout(): hint_msg.hide() func start_game_hints(): for c: Timer in auto_hint_timers.get_children(): c.start() func stop_game_hints(): _on_hint_timer_timeout() for c: Timer in auto_hint_timers.get_children(): c.stop() reset_timer.stop() join_while_running_timer.stop() func _input(_event): if Input.is_action_just_pressed("boost"): Global.set_hint("has_boosted", true) if any_action_just_pressed(["forward", "backwards", "left", "right"]): Global.set_hint("has_moved", true) if any_action_just_pressed(["rotate_left", "rotate_right", "rotate_up", "rotate_down"]): if not Global.get_hint("has_reset"): reset_timer.start() Global.set_hint("has_rotated", true) if any_action_just_pressed(["zoom_in", "zoom_out"]): Global.set_hint("has_zoomed", true) if Input.is_action_just_pressed("interact"): Global.set_hint("has_interacted", true) if Input.is_action_just_pressed("reset"): Global.set_hint("has_reset", true) func _on_boost_timeout(): if not Global.get_hint("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_hint("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_hint("has_interacted") and not Global.get_setting("touch_controls"): var keybind = display_keybind(tr("SPACE"), "A") display_hint_msg(tr("Press %s to pick up items and hold %s to interact with tools") % [keybind, keybind]) func _on_reset_timeout(): if not Global.get_hint("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 _on_zoom_timeout(): if not Global.get_hint("has_zoomed") and not Global.get_setting("touch_controls"): display_hint_msg(tr("Use %s to zoom in/out") % display_keybind(tr("PageUp/PageDown"), "LT/RT")) func display_keybind(keyboard: String, joypad: String, touch = null) -> String: if Global.using_joypad: return joypad + " (Joypad)" if touch != null: return touch 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 func _on_rotate_camera_timeout(): if not Global.get_hint("has_rotated") and not Global.get_setting("touch_controls"): display_hint_msg(tr("Use %s to rotate the camera view") % display_keybind(tr("arrow keys"), tr("right stick"))) func _on_nametags_timeout(): if not Global.get_hint("has_seen_nametags") and not Global.get_setting("usernames"): Global.set_hint("has_seen_nametags", true) display_hint_msg(tr("Username tags can be enabled/disabled in the settings")) func _on_join_while_running_timeout(): if not game.is_joined and not Global.get_hint("has_seen_join_while_running"): Global.set_hint("has_seen_join_while_running", true) display_hint_msg(tr("Press %s and click \"Join\" to join the game while it is running") % display_keybind(tr("ESCAPE"), tr("Menu button"))) func _on_performance_timeout() -> void: if not Global.get_hint("has_seen_performance") and Engine.get_frames_per_second() < DisplayServer.screen_get_refresh_rate() * 0.75: Global.set_hint("has_seen_performance", true) display_hint_msg(tr("Your framerate seems to be low. You can lower your graphics settings in the settings menu."))