35 lines
1.3 KiB
GDScript
35 lines
1.3 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_centered()
|
|
|
|
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) and %Map.controlling==self:
|
|
$HBoxContainer/Debug.text += str(%Map.controlling.health) # Combine FPS and runtime into one string
|
|
|
|
func _on_settings_window_close_requested():
|
|
print("close")
|
|
$"../SettingsWindow".hide()
|