2025-01-16 12:24:21 +00:00
|
|
|
@tool
|
2024-12-23 01:29:31 +00:00
|
|
|
extends Node
|
|
|
|
|
2025-01-16 12:24:21 +00:00
|
|
|
var config: GlobalConfig:
|
|
|
|
set = _set_config
|
2024-12-30 13:19:10 +00:00
|
|
|
|
|
|
|
var timer = Timer.new()
|
|
|
|
|
2025-01-16 12:24:21 +00:00
|
|
|
|
2024-12-30 13:19:10 +00:00
|
|
|
func _ready() -> void:
|
|
|
|
timer.wait_time = 5
|
|
|
|
timer.one_shot = false
|
|
|
|
timer.timeout.connect(_on_timer_timeout)
|
|
|
|
add_child(timer)
|
|
|
|
timer.start()
|
|
|
|
|
|
|
|
|
2025-01-16 12:24:21 +00:00
|
|
|
func _set_config(val: GlobalConfig) -> void:
|
|
|
|
config = val
|
|
|
|
# set up window
|
|
|
|
if config.window_fullscreen:
|
|
|
|
get_window().mode = Window.MODE_FULLSCREEN
|
|
|
|
else:
|
|
|
|
get_window().mode = Window.MODE_WINDOWED
|
|
|
|
get_window().always_on_top = config.window_top
|
|
|
|
# set up sound
|
|
|
|
AudioServer.set_bus_volume_db(AudioServer.get_bus_index("Master"), config.db_master)
|
|
|
|
AudioServer.set_bus_volume_db(AudioServer.get_bus_index("game_sfx"), config.db_game_sfx)
|
|
|
|
AudioServer.set_bus_volume_db(AudioServer.get_bus_index("dialog"), config.db_dialog)
|
|
|
|
|
|
|
|
|
2024-12-30 13:19:10 +00:00
|
|
|
func _on_timer_timeout():
|
|
|
|
var archive = ArchiveManager.archive
|
|
|
|
if archive:
|
|
|
|
archive.game_seconds_all += 5
|
|
|
|
archive.game_seconds_current += 5
|
|
|
|
if config:
|
|
|
|
config.game_total_seconds += 5
|
|
|
|
|
|
|
|
|
|
|
|
func pack_current_time():
|
|
|
|
var packed_time = PackedTime.new()
|
|
|
|
packed_time.time = Time.get_datetime_string_from_system(false, true)
|
|
|
|
var archive = ArchiveManager.archive
|
|
|
|
if archive:
|
|
|
|
packed_time.chapter = archive.current_chapter
|
|
|
|
packed_time.section = archive.current_section
|
|
|
|
packed_time.game_archive_id = archive.archive_id
|
|
|
|
packed_time.game_seconds_all = archive.game_seconds_all
|
|
|
|
packed_time.game_seconds_current = archive.game_seconds_current
|
|
|
|
|
|
|
|
|
|
|
|
# for log use
|
|
|
|
func get_concise_timemark() -> String:
|
|
|
|
var archive = ArchiveManager.archive
|
|
|
|
if not archive:
|
|
|
|
return "r0_c0_s0 00:00:00"
|
|
|
|
var hour = archive.game_seconds_current / 3600 as int
|
|
|
|
var minute = (archive.game_seconds_current % 3600) / 60 as int
|
|
|
|
var second = archive.game_seconds_current % 60
|
|
|
|
return (
|
|
|
|
"r"
|
|
|
|
+ str(ArchiveManager.current_archive_id)
|
|
|
|
+ "_c"
|
|
|
|
+ str(archive.current_chapter)
|
|
|
|
+ "_s"
|
|
|
|
+ str(archive.current_section)
|
|
|
|
+ " "
|
|
|
|
+ str(hour)
|
|
|
|
+ ":"
|
|
|
|
+ str(minute)
|
|
|
|
+ ":"
|
|
|
|
+ str(second)
|
|
|
|
)
|