JHRGB/HUD.gd

45 lines
1.4 KiB
GDScript

extends PanelContainer
var elapsed_time = 0.0 # Initialize a variable to keep track of elapsed time
# Called when the node enters the scene tree for the first time.
func _ready():
var popup_menu = $HBoxContainer/Right/File.get_popup()
popup_menu.connect("id_pressed", self._on_PopupMenu_id_pressed)
func _on_PopupMenu_id_pressed(id):
match id:
0:
$"../NewDialog".popup_centered()
1:
$"../LoadDialog".popup_centered()
2:
$"../SaveDialog".popup_centered()
4:
$"../SettingsWindow".popup()
5:
$"../StatsWindow".popup()
func _process(delta):
elapsed_time += delta # Increment the elapsed time by the frame's delta time
var hours = int(elapsed_time / 3600)
var minutes = int(elapsed_time / 60) % 60
var seconds = int(elapsed_time) % 60
var time_string = "%02d:%02d:%02d" % [hours, minutes, seconds] # Format time as H:M:S
var fps = Engine.get_frames_per_second() # Get the current FPS
$HBoxContainer/Debug.text = time_string+" "+str(fps) + " fps" # Combine FPS and runtime into one string
if %Map.controlling and is_instance_valid(%Map.controlling):
$HBoxContainer/Debug.text += " [H:"+str(%Map.controlling.health)+"]"
func _on_settings_window_close_requested():
print("close")
$"../SettingsWindow".hide()
func _on_control_stop_button_pressed():
%Map.controlling=null
func _on_kill_all_pressed():
for node in %Map.get_children():
if node is Player:
node.queue_free()