193 lines
6.5 KiB
GDScript
193 lines
6.5 KiB
GDScript
extends Node2D
|
|
|
|
|
|
@onready var vn_scene = preload("res://scenes/screens/visual_novel.tscn")
|
|
|
|
var licenses_scroll_bar = null
|
|
|
|
func advance_sfx():
|
|
if not FileGlobals.get_global_data("muted"):
|
|
#SoundManager.play("sfx_menu", "advance")
|
|
SoundManager.play_varied("sfx_menu", "advance", 1.0, FileGlobals.get_global_data("volume", 0.0))
|
|
|
|
# Called when the node enters the scene tree for the first time.
|
|
func _ready():
|
|
get_window().title = "Crossing Over"
|
|
if not FileGlobals.has_loaded:
|
|
await FileGlobals.loaded
|
|
if not MusicManager.has_loaded:
|
|
await MusicManager.loaded
|
|
if not SoundManager.has_loaded:
|
|
await SoundManager.loaded
|
|
|
|
$CanvasLayer/CreditsMenuControl/AnimatedBardSprite.play("default")
|
|
|
|
FileGlobals.new_game_save_file.clear()
|
|
|
|
if str(FileGlobals.get_global_data("answer")) == "42":
|
|
$AnimationPlayerBG.play("main_menu_02")
|
|
else:
|
|
$AnimationPlayerBG.play("main_menu_01")
|
|
%VolumeSlider.value = FileGlobals.get_global_data("volume", 0.0)
|
|
init_credits()
|
|
if FileGlobals.can_continue:
|
|
%Continue.visible = true
|
|
for file in FileGlobals.save_files:
|
|
if file.get("is_autosave"):
|
|
%ItemList.add_item(" Autosave | %s (%s)" % [file["name"], file["timestamp"]])
|
|
else:
|
|
%ItemList.add_item(" %s (%s)" % [file["name"], file["timestamp"]])
|
|
if FileGlobals.get_global_data("muted"):
|
|
mute()
|
|
else:
|
|
MusicManager.set_volume(%VolumeSlider.value)
|
|
MusicManager.play("main_menu", "fulminant_mm", 0.0)
|
|
$AnimationPlayer.play("reveal_main_menu")
|
|
%NewGameButton.grab_focus()
|
|
|
|
func _process(delta):
|
|
if $CanvasLayer/LicensesWindow.visible:
|
|
if Input.is_action_just_pressed("ui_accept") or Input.is_action_just_pressed("ui_cancel"):
|
|
advance_sfx()
|
|
$CanvasLayer/LicensesWindow.hide()
|
|
else:
|
|
var vertical_scroll = Input.get_vector("ui_left", "ui_right", "ui_up", "ui_down").y * delta * 1000
|
|
$CanvasLayer/LicensesWindow/RichTextLabel.get_v_scroll_bar().value += vertical_scroll
|
|
|
|
func mute():
|
|
MusicManager.set_volume(-80.0)
|
|
FileGlobals.set_global_data("muted", true)
|
|
%MuteTextureRect.texture = load("res://images/ui/speaker-x-mark.svg")
|
|
|
|
func unmute():
|
|
var volume = FileGlobals.get_global_data("volume", 0.0)
|
|
MusicManager.set_volume(FileGlobals.get_global_data("volume", 0.0))
|
|
FileGlobals.set_global_data("muted", false)
|
|
SoundManager.play_varied("sfx_menu", "advance", 1.0, volume)
|
|
%MuteTextureRect.texture = load("res://images/ui/speaker-wave.svg")
|
|
|
|
func init_credits():
|
|
%CreditsRichText.text = FileAccess.open("res://scenes/screens/credits.txt", FileAccess.READ).get_as_text()
|
|
#if OS.has_feature("debug") or str(FileGlobals.get_global_data("game_completed")) == "1":
|
|
if OS.has_feature("editor") or str(FileGlobals.get_global_data("game_completed")) == "1":
|
|
%CreditsRichText.append_text(FileAccess.open("res://scenes/screens/credits_bonus.txt", FileAccess.READ).get_as_text())
|
|
%PostGameButtons.visible = true
|
|
|
|
func show_licenses():
|
|
if not $CanvasLayer/LicensesWindow/RichTextLabel.text:
|
|
$CanvasLayer/LicensesWindow/RichTextLabel.text = FileAccess.open("res://licenses.txt", FileAccess.READ).get_as_text()
|
|
advance_sfx()
|
|
$CanvasLayer/LicensesWindow.show()
|
|
|
|
func start_new_game():
|
|
FileGlobals.current_load_source = FileGlobals.VNLoadSource.NEW_GAME
|
|
get_tree().change_scene_to_packed(vn_scene)
|
|
|
|
func _on_licenses_window_close_requested():
|
|
advance_sfx()
|
|
$CanvasLayer/LicensesWindow.hide()
|
|
|
|
func _on_mute_button_pressed():
|
|
if FileGlobals.get_global_data("muted"):
|
|
unmute()
|
|
else:
|
|
mute()
|
|
|
|
func _on_new_game_button_pressed():
|
|
advance_sfx()
|
|
start_new_game()
|
|
|
|
func _on_continue_button_pressed():
|
|
advance_sfx()
|
|
$CanvasLayer/ContinueMenuControl.visible = true
|
|
$CanvasLayer/ContinueMenuControl/ReturnToMainMenuButtonContainer/ReturnToMainMenuButton.grab_focus()
|
|
$CanvasLayer/MainMenuControl.visible = false
|
|
|
|
func _on_credits_button_pressed():
|
|
advance_sfx()
|
|
$CanvasLayer/CreditsMenuControl.visible = true
|
|
$CanvasLayer/CreditsMenuControl/ReturnToMainMenuButtonContainer/ReturnToMainMenuButton.grab_focus()
|
|
$CanvasLayer/MainMenuControl.visible = false
|
|
|
|
# Return to main menu
|
|
func _on_return_to_main_menu_from_continue():
|
|
$CanvasLayer/MainMenuControl/ButtonsMarginContainer/VBoxContainer/Continue/ContinueButton.grab_focus()
|
|
_on_return_to_main_menu()
|
|
|
|
func _on_return_to_main_menu_from_credits():
|
|
$CanvasLayer/MainMenuControl/ButtonsMarginContainer/VBoxContainer/Credits/CreditsButton.grab_focus()
|
|
_on_return_to_main_menu()
|
|
|
|
func _on_return_to_main_menu():
|
|
advance_sfx()
|
|
$CanvasLayer/MainMenuControl.visible = true
|
|
$CanvasLayer/CreditsMenuControl.visible = false
|
|
$CanvasLayer/ContinueMenuControl.visible = false
|
|
$CanvasLayer/LicensesWindow.hide()
|
|
|
|
func _on_credits_rich_text_meta_clicked(meta):
|
|
match meta:
|
|
"licenses":
|
|
show_licenses()
|
|
"bonus_music":
|
|
FileGlobals.new_game_save_file["current_vn"] = "bonus_music"
|
|
start_new_game()
|
|
"bonus_animation":
|
|
FileGlobals.new_game_save_file["current_vn"] = "bonus_animation"
|
|
advance_sfx()
|
|
start_new_game()
|
|
"bonus_fishing":
|
|
FileGlobals.new_game_save_file["current_vn"] = "bonus_fishing"
|
|
advance_sfx()
|
|
start_new_game()
|
|
_:
|
|
if meta.left(8) == "https://":
|
|
advance_sfx()
|
|
OS.shell_open(meta)
|
|
else:
|
|
push_warning("Unhandled [url] meta '%s'" % meta)
|
|
|
|
func _on_save_item_list_item_selected(index):
|
|
FileGlobals.current_load_file = FileGlobals.save_files[index]
|
|
if FileGlobals.current_load_file.get("is_autosave"):
|
|
FileGlobals.current_load_source = FileGlobals.VNLoadSource.FROM_AUTOSAVE
|
|
else:
|
|
FileGlobals.current_load_source = FileGlobals.VNLoadSource.FROM_MANUAL_SAVE
|
|
advance_sfx()
|
|
get_tree().change_scene_to_packed(vn_scene)
|
|
|
|
#func _on_load_save_button_focus_entered():
|
|
# if %LoadSaveButton.disabled:
|
|
# %LoadSaveButton.find_next_valid_focus().grab_focus()
|
|
#
|
|
#func _on_load_save_button_focus_exited():
|
|
# $AnimationPlayer.play("save_file_desselected")
|
|
# await $AnimationPlayer.animation_finished
|
|
#
|
|
#func _on_load_save_button_pressed():
|
|
# advance_sfx()
|
|
# get_tree().change_scene_to_packed(vn_scene)
|
|
|
|
func _on_website_button_pressed():
|
|
_on_credits_rich_text_meta_clicked("https://badmanners.xyz")
|
|
|
|
func _on_licenses_button_pressed():
|
|
if $CanvasLayer/LicensesWindow.visible:
|
|
advance_sfx()
|
|
$CanvasLayer/LicensesWindow.hide()
|
|
else:
|
|
show_licenses()
|
|
|
|
func _on_music_room_button_pressed():
|
|
_on_credits_rich_text_meta_clicked("bonus_music")
|
|
|
|
func _on_play_video_button_pressed():
|
|
_on_credits_rich_text_meta_clicked("bonus_animation")
|
|
|
|
func _on_fishing_minigame_button_pressed():
|
|
_on_credits_rich_text_meta_clicked("bonus_fishing")
|
|
|
|
func _on_volume_slider_value_changed(value):
|
|
FileGlobals.set_global_data("volume", value)
|
|
if not FileGlobals.get_global_data("muted", false):
|
|
MusicManager.set_volume(value)
|