Files
pomchronicles/main_panel.gd
2025-07-31 20:01:51 -04:00

50 lines
1.5 KiB
GDScript

class_name GamePanel extends MarginContainer
const notice_template = preload("res://notice_panel.tscn")
const quest_progress_bar_template = preload("res://quest_progress_bar.tscn")
signal time_changed(time : float)
@onready var timer : Timer = $Timer
func _ready() -> void:
Game.panel = self
func _process(delta: float) -> void:
time_changed.emit(timer.time_left)
func add_quest_progress_bar(quest : Quest) -> void:
var qpb : QuestProgressBar = quest_progress_bar_template.instantiate()
qpb.setup(quest)
%QuestProgressList/VBoxContainer.add_child(qpb)
#TODO: Change the hero portrait to match
if quest.steps > 1:
for i in range(quest.steps-1):
qpb.add_waypoint(float(i) / quest.steps, quest.step_messages[i])
func switch_panel(active : bool) -> void:
%OpenShift.visible = active
%WorkingShift.visible = !active
func _on_end_shift_pressed() -> void:
Game.confirm_end_shift()
func _on_visitor_spawned(remaining : int, total : int) -> void:
update_visitor_count(total - remaining, total)
func connect_visitor_spawner(spawner : VisitorSpawner) -> void:
spawner.visitor_spawned.connect(_on_visitor_spawned)
update_visitor_count(spawner.total_visitors - spawner.visitors_remaining, spawner.total_visitors)
func update_visitor_count(current : int, total : int) -> void:
%OpenList/VisitorsLabel.text = "Visitors: %d/%d" % [current, total]
func notice(msg : String, time : float) -> void:
var ntc : NoticePanel = notice_template.instantiate()
%Notices.add_child(ntc)
ntc.message = msg
ntc.duration = time