WIP: adding loading and transition animations to main menu

This commit is contained in:
betalars 2024-10-06 11:40:42 +02:00
parent 4208ff368a
commit 23eedfd167
8 changed files with 347 additions and 107 deletions

View File

@ -18,6 +18,11 @@ layout_mode = 2
theme_type_variation = &"HeaderLarge"
text = "Gameplay Settings"
[node name="Label2" type="Label" parent="."]
layout_mode = 2
theme_type_variation = &"HeaderMedium"
text = "Gameplay Settings"
[node name="VBoxContainer" type="VBoxContainer" parent="."]
layout_mode = 2
@ -52,7 +57,7 @@ text = "Stream Overlay"
[node name="StreamOverlayPicker" type="OptionButton" parent="VBoxContainer/GridContainer"]
unique_name_in_owner = true
layout_mode = 2
tooltip_text = "Displays content note and currently playing music at a corner of the screen."
tooltip_text = "Displays content note and currently playing music at s corner of the screen."
selected = 0
item_count = 5
popup/item_0/text = "none"

View File

@ -1,6 +1,15 @@
extends Panel
signal load_scene(id: int)
var has_stage:
set(value):
value = has_stage
if is_node_ready():
new_game_button.disabled = not has_stage
continue_button.disabled = not has_stage
load_game_button.disabled = not has_stage
settings_button.disabled = not has_stage
quit_button.disabled = not has_stage
signal start_game(savegame: SaveGame)
signal open_settings(new_game: bool)
@ -9,19 +18,23 @@ signal open_settings(new_game: bool)
@onready var load_game_button: Button = $PanelContainer/LoadGameButton
@onready var settings_button: Button = $PanelContainer/SettingsButton
@onready var quit_button: Button = $PanelContainer/QuitButton
@onready var save_game_handle: Control = %SaveGameHandle
@onready var save_game_handle: SaveGameHandle = %SaveGameHandle
@export var save_game_exists: bool = false:
set(value):
save_game_exists = value
var await_new_game: bool = false
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
new_game_button.pressed.connect(func():
save_game_handle.show()
)
save_game_handle.picked.connect(_on_save_picked)
new_game_button.pressed.connect(_on_new_game_pressed)
continue_button
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta: float) -> void:
pass
func _on_new_game_pressed():
save_game_handle.pick_slot(true)
func _on_save_picked(save: SaveGame):
start_game.emit(save)

View File

@ -1,25 +1,47 @@
@tool
extends CenterContainer
class_name SaveGameHandle extends CenterContainer
@export var new_game: bool = false:
set(value):
new_game = value
signal picked(save_game: SaveGame)
var has_stage: bool = false:
set(stage):
has_stage = stage
visible = stage
save_buttons[0].grab_focus()
@export var save_1: SaveGame = SaveGame.new()
@export var save_2: SaveGame = SaveGame.new()
@export var save_3: SaveGame = SaveGame.new()
@export var saves: Array[SaveGame] = [SaveGame.new(), SaveGame.new(), SaveGame.new()]
var save_buttons: Array[SaveGameDisplay]
@export var update_display: bool:
set(value):
display()
var create_new_game: bool = false
func _ready() -> void:
display()
func display():
for child in get_children():
for child in save_buttons:
child.free()
add_child(SaveGameDisplay.new(save_1, 1))
add_child(SaveGameDisplay.new(save_2, 2))
add_child(SaveGameDisplay.new(save_3, 3))
save_buttons = []
for i in range(saves.size()):
var new_button := SaveGameDisplay.new(saves[i], i+1)
save_buttons.append(new_button)
add_child(new_button)
new_button.pressed.connect(func(): _on_game_picked(i))
func _on_game_picked(id: int):
if create_new_game:
if saves[id].current_room == 0:
picked.emit(id)
else:
$Popup.show()
else:
picked.emit(id)
func pick_slot(create_new_game: bool):
State.take_stage(self)
create_new_game = true

View File

@ -301,36 +301,36 @@ unique_name_in_owner = true
layout_mode = 2
text = "save and apply"
[node name="Popup" type="Popup" parent="GridContainer/ConfirmButton"]
[node name="Popup" type="Popup" parent="."]
initial_position = 2
size = Vector2i(546, 123)
[node name="VBoxContainer" type="VBoxContainer" parent="GridContainer/ConfirmButton/Popup"]
[node name="VBoxContainer" type="VBoxContainer" parent="Popup"]
offset_left = 113.0
offset_right = 153.0
offset_bottom = 40.0
[node name="Label" type="Label" parent="GridContainer/ConfirmButton/Popup/VBoxContainer"]
[node name="Label" type="Label" parent="Popup/VBoxContainer"]
layout_mode = 2
text = "Settings have been modified.
Do you really want to leave without saving?"
horizontal_alignment = 1
[node name="HBoxContainer" type="HBoxContainer" parent="GridContainer/ConfirmButton/Popup/VBoxContainer"]
[node name="HBoxContainer" type="HBoxContainer" parent="Popup/VBoxContainer"]
layout_mode = 2
alignment = 1
[node name="ConfirmExit" type="Button" parent="GridContainer/ConfirmButton/Popup/VBoxContainer/HBoxContainer"]
[node name="ConfirmExit" type="Button" parent="Popup/VBoxContainer/HBoxContainer"]
unique_name_in_owner = true
layout_mode = 2
text = "leave"
[node name="ConfirmSave" type="Button" parent="GridContainer/ConfirmButton/Popup/VBoxContainer/HBoxContainer"]
[node name="ConfirmSave" type="Button" parent="Popup/VBoxContainer/HBoxContainer"]
unique_name_in_owner = true
layout_mode = 2
text = "save"
[node name="ConfirmAbort" type="Button" parent="GridContainer/ConfirmButton/Popup/VBoxContainer/HBoxContainer"]
[node name="ConfirmAbort" type="Button" parent="Popup/VBoxContainer/HBoxContainer"]
unique_name_in_owner = true
layout_mode = 2
text = "abort"

View File

@ -4,20 +4,18 @@ extends Node3D
@export_file(".tscn") var voluntary_room: String
@export_file(".tscn") var study_room: String
@onready var loading_player: AnimationPlayer = %MenuAnimationPlayer
@onready var loading_animation: AnimationTree = %MenuAnimationTree
var last_progress_state: float = 0
var current_loaded_room: Node3D
var currently_loading_room: String = "":
set(path):
if path != "":
ResourceLoader.load_threaded_request(path, "PackedScene")
loading_animation["parameters/conditions/loading_done"] = false
currently_loading_room = path
last_progress_state
loading_player.queue("loading")
else:
loading_player.queue("loading_done")
else:
loading_animation["parameters/conditions/loading_done"] = true
# Called when the node enters the scene tree for the first time.
func _ready():
@ -31,9 +29,6 @@ func _process(delta: float) -> void:
add_child(current_loaded_room)
move_child(current_loaded_room, 0)
currently_loading_room = ""
elif last_progress_state != progress[0]:
loading_player.seek(progress[0])
last_progress_state = progress[0]
func debug_youth():
get_child(1).hide()

File diff suppressed because one or more lines are too long

View File

@ -1,4 +1,4 @@
[gd_scene load_steps=19 format=3 uid="uid://b51wdql4mby47"]
[gd_scene load_steps=15 format=3 uid="uid://b51wdql4mby47"]
[ext_resource type="Theme" uid="uid://b056fn288p8ha" path="res://logic-scenes/themes/easy-handwriting.theme" id="1_2dg4n"]
[ext_resource type="Script" path="res://logic-scenes/main menu/main_menu.gd" id="2_rm576"]
@ -8,8 +8,6 @@
[ext_resource type="PackedScene" uid="uid://dxwqkxq6qjk7i" path="res://logic-scenes/main menu/gameplay_settings.tscn" id="6_p7ypt"]
[ext_resource type="PackedScene" uid="uid://chal0ioagspx0" path="res://logic-scenes/main menu/content_settings.tscn" id="7_pnd48"]
[ext_resource type="Script" path="res://logic-scenes/main menu/save_game_list.gd" id="8_o0cpj"]
[ext_resource type="Script" path="res://dev-util/savegame.gd" id="9_hb671"]
[ext_resource type="Texture2D" uid="uid://bk5ja14r7r6i4" path="res://import/interface-elements/empty_save_slot.png" id="10_v8xkt"]
[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_njt06"]
@ -247,53 +245,25 @@ _data = {
"vanish": SubResource("Animation_a3iyq")
}
[sub_resource type="Resource" id="Resource_7b5jk"]
script = ExtResource("9_hb671")
current_room = 0
mementos_complete = 0
thumbnail = ExtResource("10_v8xkt")
last_saved = {
"day": 30,
"dst": true,
"hour": 17,
"minute": 17,
"month": 9,
"second": 48,
"weekday": 1,
"year": 2024
}
[sub_resource type="GDScript" id="GDScript_mjmwc"]
script/source = "extends Popup
[sub_resource type="Resource" id="Resource_ew63c"]
script = ExtResource("9_hb671")
current_room = 0
mementos_complete = 0
thumbnail = ExtResource("10_v8xkt")
last_saved = {
"day": 30,
"dst": true,
"hour": 17,
"minute": 17,
"month": 9,
"second": 48,
"weekday": 1,
"year": 2024
}
var has_stage:bool = false:
set(value):
has_stage = value
visible = has_stage
if has_stage:
$VBoxContainer/ConfirmOverwrite.grab_focus()
[sub_resource type="Resource" id="Resource_nnc2y"]
script = ExtResource("9_hb671")
current_room = 0
mementos_complete = 0
thumbnail = ExtResource("10_v8xkt")
last_saved = {
"day": 30,
"dst": true,
"hour": 17,
"minute": 17,
"month": 9,
"second": 48,
"weekday": 1,
"year": 2024
}
func _ready() -> void:
$VBoxContainer/ConfirmOverwrite.pressed.connect()
func on_confirm_pressed():
get_parent()._on_deletion_confirmed()
func on_cancel_pressed():
State.leave_stage(self)
"
[node name="Main Menu" type="Panel"]
anchors_preset = 15
@ -424,6 +394,7 @@ metadata/_tab_index = 3
[node name="SaveGameHandle" type="CenterContainer" parent="."]
unique_name_in_owner = true
visible = false
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
@ -431,6 +402,23 @@ anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
script = ExtResource("8_o0cpj")
save_1 = SubResource("Resource_7b5jk")
save_2 = SubResource("Resource_ew63c")
save_3 = SubResource("Resource_nnc2y")
save_1 = null
save_2 = null
save_3 = null
[node name="Popup" type="Popup" parent="SaveGameHandle"]
script = SubResource("GDScript_mjmwc")
[node name="VBoxContainer" type="VBoxContainer" parent="SaveGameHandle/Popup"]
offset_right = 40.0
offset_bottom = 40.0
[node name="Label" type="Label" parent="SaveGameHandle/Popup/VBoxContainer"]
layout_mode = 2
text = "Slot is already occupied. Do you really want to overwrite it?"
[node name="ConfirmOverwrite" type="Button" parent="SaveGameHandle/Popup/VBoxContainer"]
layout_mode = 2
[node name="CancelOverwrite" type="Button" parent="SaveGameHandle/Popup/VBoxContainer"]
layout_mode = 2

50
src/setting.gd Normal file
View File

@ -0,0 +1,50 @@
@tool
class_name MenuSetting extends Resource
enum Receivers {
NONE,
NODEPATH,
SINGLETON,
AUDIO_SERVER,
CAMERA_SERVER,
DISPLAY_SERVER,
ENGINE,
IP_SETTINGS,
INPUT,
INPUT_MAP,
PHYSICS_2D,
PHYSICS_3D,
RENDERING_SERVER,
THEME_DB,
XR_SERVER
}
## The path to the Project Setting you are using. If it is a setting specific to your game, add it trough code or the Project Settings Panel.
@export_placeholder("i.e. application/config/name") var project_settings_path: String = ""
## Choose what gets changed in game when setting this value. None means the setting is ony meant to be applied after a reboot.
@export var change: Receivers = Receivers.NODEPATH:
set(value):
change = value
property_list_changed.emit()
## If you choose to change a custom node path, you can set it here.
@export_node_path() var nodepath: NodePath
## If you choose to change a singleton, you can set it's name here.
@export var singleton_name: StringName
## Path to the function you are setting.
@export_placeholder("\"set\" to change property") var attribute_path: String = ""
## extra attributes your call may need. Leave empty slot if variable is not meant to be at first index.
@export var extra_attributes: Array
func _validate_property(property: Dictionary) -> void:
if property.name == "nodepath" and change != Receivers.NODEPATH:
property.usage |= PROPERTY_USAGE_READ_ONLY
func get_connected_control() -> Control:
return Label.new()
func get_unonnected_control() -> Control:
var setting: Dictionary = ProjectSettings.get_setting_with_override(project_settings_path)
return Label.new()