time_elapsed %TimeLabel show in OptionsMenu

auto_save_clock to save_options every 30 seconds
This commit is contained in:
Harmony Honey Monroe 2025-02-22 23:39:21 -05:00
parent 5b8c306b52
commit 19e8d01872
4 changed files with 37 additions and 1 deletions

View file

@ -75,6 +75,10 @@ var player_colors = [8, 0, 11, 13]
var preset_palettes = [[7, 13, 6, 3], [8, 0, 11, 13], [11, 7, 9, 0], [12, 1, 7, 5], [9, 8, 12, 3]]
var last_palette = -1
var time_elapsed := 0
var auto_save_clock := 0
var auto_save_time := 1800
func _ready():
print("Shared._ready(): ")
@ -206,6 +210,14 @@ func _input(event):
emit_signal("signal_gamepad")
func _physics_process(delta):
time_elapsed += 1
auto_save_clock += 1
if auto_save_clock > auto_save_time:
save_options()
auto_save_clock = 0
if is_level_select or is_in_game or is_creator:
save_clock += 1
@ -392,7 +404,9 @@ func save_options(path := options_path):
data["sfx"] = bus_volume[1]
data["music"] = bus_volume[2]
data["fullscreen"] = int(OS.window_fullscreen)
data["time"] = time_elapsed
print("save_options, path: ", path, " time: ", time_elapsed)
save_file(save_path + options_path, JSON.print(data, "\t"))
func load_options(path := options_path):
@ -411,6 +425,8 @@ func load_options(path := options_path):
set_bus_volume(2, v)
if dict.has("fullscreen"):
set_fullscreen(bool(dict["fullscreen"]))
if dict.has("time"):
time_elapsed = abs(int(dict["time"]))
func delete_slot(_slot := save_slot):
var dir = Directory.new()

View file

@ -54,7 +54,10 @@ func _input(event):
func make_list(arg):
if is_instance_valid(arg):
list_node = arg
list = arg.get_children()
list = []
for i in arg.get_children():
if !i.is_in_group("no_item"):
list.append(i)
func menu_input(event):
if !is_open or is_sub or open_clock > 0 or Wipe.is_wipe: return

View file

@ -3,3 +3,6 @@ extends Menu
func on_open():
if !is_open:
Shared.save_options()
func _physics_process(delta):
$"%TimeLabel".text = Shared.time_to_string(Shared.time_elapsed)

View file

@ -346,4 +346,18 @@ margin_right = 116.0
margin_bottom = 8.0
rect_min_size = Vector2( 8, 0 )
[node name="Time" type="HBoxContainer" parent="Center/Control/MenuItems" groups=["no_item"]]
margin_top = 96.0
margin_right = 116.0
margin_bottom = 101.0
[node name="TimeLabel" type="Label" parent="Center/Control/MenuItems/Time"]
unique_name_in_owner = true
margin_right = 116.0
margin_bottom = 5.0
size_flags_horizontal = 3
custom_fonts/font = SubResource( 2 )
text = "Touch Controls"
align = 1
[editable path="Center/Control/MenuItems/Music"]