2025-01-16 12:24:21 +00:00
|
|
|
extends Control
|
|
|
|
|
2025-06-17 05:01:19 +00:00
|
|
|
# var main_scene := preload("res://scene/main.tscn") as PackedScene
|
|
|
|
|
2025-01-16 12:24:21 +00:00
|
|
|
@onready var animation_root = $AnimationRoot as Control
|
2025-06-26 16:02:50 +00:00
|
|
|
@onready var sfx_click = %SfxClick as Sfx
|
2025-01-16 12:24:21 +00:00
|
|
|
@onready var newgame_btn = %NewGame as Button
|
|
|
|
@onready var resume_btn = %Resume as Button
|
|
|
|
@onready var quit_btn = %Quit as Button
|
2025-06-27 20:24:05 +00:00
|
|
|
@onready var mask = $Mask as ColorRect
|
2025-01-16 12:24:21 +00:00
|
|
|
|
|
|
|
|
|
|
|
func _ready():
|
|
|
|
if GlobalConfig.DEBUG:
|
|
|
|
print("Index Page Ready")
|
|
|
|
newgame_btn.pressed.connect(_on_newgame_pressed)
|
|
|
|
resume_btn.pressed.connect(_on_resume_pressed)
|
|
|
|
quit_btn.pressed.connect(_on_quit_pressed)
|
|
|
|
_check_resume_btn()
|
2025-06-27 20:24:05 +00:00
|
|
|
create_tween().tween_property(mask, "modulate:a", 0.0, 1.0)
|
2025-01-16 12:24:21 +00:00
|
|
|
|
|
|
|
|
|
|
|
func _check_resume_btn():
|
|
|
|
if not ArchiveManager.archives.has(1):
|
|
|
|
resume_btn.queue_free()
|
|
|
|
|
|
|
|
|
|
|
|
func _on_newgame_pressed():
|
2025-06-26 16:02:50 +00:00
|
|
|
sfx_click.global_play()
|
2025-01-16 12:24:21 +00:00
|
|
|
# 覆盖使用 1 号存档
|
|
|
|
ArchiveManager.create_and_use_new_archive(1)
|
2025-06-27 14:52:46 +00:00
|
|
|
_enter_main_scene(true)
|
2025-01-16 12:24:21 +00:00
|
|
|
|
|
|
|
|
|
|
|
func _on_resume_pressed():
|
2025-06-26 16:02:50 +00:00
|
|
|
sfx_click.global_play()
|
2025-01-16 12:24:21 +00:00
|
|
|
# 继续一号存档
|
|
|
|
if GlobalConfig.DEBUG:
|
|
|
|
print("Resume")
|
|
|
|
if ArchiveManager.archives.has(1):
|
2025-01-21 12:41:24 +00:00
|
|
|
# 设置 current_selected_archive_id 后,存档会自动加载
|
2025-01-16 12:24:21 +00:00
|
|
|
GlobalConfigManager.config.current_selected_archive_id = 1
|
|
|
|
else:
|
|
|
|
ArchiveManager.create_and_use_new_archive(1)
|
|
|
|
_enter_main_scene()
|
|
|
|
|
|
|
|
|
2025-06-27 14:52:46 +00:00
|
|
|
func _enter_main_scene(new_game := false):
|
|
|
|
# new game 时音量渐隐
|
|
|
|
var duraion = 0.0
|
|
|
|
if new_game:
|
|
|
|
duraion = 5.0
|
|
|
|
$BgmControl.stop(duraion)
|
2025-06-25 17:53:16 +00:00
|
|
|
SceneManager.enter_main_scene()
|
2025-01-16 12:24:21 +00:00
|
|
|
|
|
|
|
|
|
|
|
func _on_quit_pressed():
|
|
|
|
# 退出时点击音效将无法播放
|
2025-06-26 16:02:50 +00:00
|
|
|
#sfx_click.global_play()
|
2025-01-16 12:24:21 +00:00
|
|
|
SceneManager.quit_game()
|
|
|
|
|
|
|
|
|
|
|
|
func _unhandled_input(event: InputEvent) -> void:
|
|
|
|
if event.is_action_pressed("escape"):
|
|
|
|
get_viewport().set_input_as_handled()
|
2025-06-27 20:24:05 +00:00
|
|
|
SceneManager.show_settings()
|