diff --git a/addons/godotsteam/win64/~libgodotsteam.windows.template_debug.x86_64.dll b/addons/godotsteam/win64/~libgodotsteam.windows.template_debug.x86_64.dll deleted file mode 100644 index 2d345af..0000000 Binary files a/addons/godotsteam/win64/~libgodotsteam.windows.template_debug.x86_64.dll and /dev/null differ diff --git a/core/scene_manager/scene_manager.gd b/core/scene_manager/scene_manager.gd index 9dc8a9b..3b0ac16 100644 --- a/core/scene_manager/scene_manager.gd +++ b/core/scene_manager/scene_manager.gd @@ -1,57 +1,109 @@ extends CanvasLayer @export var config: SceneConfig + +@export_group("Transition Timings") +@export var fade_in_duration: float = 0.5 +@export var black_screen_duration: float = 1.0 +@export var fade_out_duration: float = 0.5 +@export var logo_fade_in_duration: float = 0.3 +@export var logo_fade_out_duration: float = 0.3 + +@export_group("Cozy Animation") +@export var sway_speed: float = 2.5 # Velocità dell'oscillazione (più alto = più veloce) +@export var max_sway_angle: float = 6.0 # Gradi massimi di inclinazione a destra/sinistra +@export var pulse_speed: float = 2.0 # Velocità del "respiro" +@export var pulse_amount: float = 0.015 # Quanto si ingrandisce/rimpicciolisce il logo + +@export_group("Shader Parameters") +@export var base_color: Color = Color.BLACK +@export var shape_tiling: float = 16.0 +@export var shape_rotation: float = 0.0 +@export var shape_scroll: Vector2 = Vector2.ZERO +@export var shape_feathering: float = 0.05 +@export var shape_treshold: float = 1.0 +@export var width: float = 0.5 + @onready var color_rect = $ColorRect @onready var loading_screen = $LoadingScreen -@export var transition_duration: float = 3 +@onready var logo = $LoadingScreen/Logo + const SHADER_PATH := "res://core/transition.gdshader" var transaction_material: ShaderMaterial +var time_passed: float = 0.0 +var initial_scale: Vector2 = Vector2.ONE +var scale_captured: bool = false + func _ready() -> void: _build_material() _update_resolution() get_viewport().size_changed.connect(_update_resolution) _set_factor(0.0) + + color_rect.z_index = 0 + loading_screen.z_index = 1 + color_rect.visible = false + loading_screen.visible = false + loading_screen.modulate.a = 0.0 + +func _process(delta: float) -> void: + if loading_screen.visible and logo and logo.visible: + # Cattura la scala originale (0.22) impostata nell'editor alla prima attivazione + if not scale_captured: + initial_scale = logo.scale + scale_captured = true + + time_passed += delta + + # 1. EFFETTO DONDOLIO (Usa il seno per oscillare morbidamente) + var target_rotation = sin(time_passed * sway_speed) * deg_to_rad(max_sway_angle) + logo.rotation = target_rotation + + # 2. EFFETTO RESPIRO (Modifica leggermente lo scale partendo da quello base) + var pulse = sin(time_passed * pulse_speed) * pulse_amount + logo.scale = initial_scale + Vector2(pulse, pulse) + else: + # Reset del timer quando la schermata si chiude per ripartire da zero la prossima volta + time_passed = 0.0 func _build_material() -> void: transaction_material = ShaderMaterial.new() transaction_material.shader = load(SHADER_PATH) - #directional gradient: bottom-left-> black; top-right -> white var g := Gradient.new() g.set_color(0, Color.BLACK) g.set_color(1, Color.WHITE) var grad_tex := GradientTexture2D.new() grad_tex.gradient = g grad_tex.fill = GradientTexture2D.FILL_LINEAR - grad_tex.fill_from = Vector2(0.0, 1.0) # bottom-left - grad_tex.fill_to = Vector2(1.0, 0.0) # top-right + grad_tex.fill_from = Vector2(0.0, 1.0) + grad_tex.fill_to = Vector2(1.0, 0.0) grad_tex.width = 256 grad_tex.height = 256 - #shape: sphere (white at the center, black around) var sg := Gradient.new() sg.set_color(0, Color.WHITE) sg.set_color(1, Color.BLACK) var shape_tex := GradientTexture2D.new() shape_tex.gradient = sg shape_tex.fill = GradientTexture2D.FILL_RADIAL - shape_tex.fill_from = Vector2(0.5, 0.5) # center - shape_tex.fill_to = Vector2(0.5, 0.0) # ray + shape_tex.fill_from = Vector2(0.5, 0.5) + shape_tex.fill_to = Vector2(0.5, 0.0) shape_tex.width = 64 shape_tex.height = 64 - transaction_material.set_shader_parameter("base_color", Color.BLACK) + transaction_material.set_shader_parameter("base_color", base_color) transaction_material.set_shader_parameter("gradient_texture", grad_tex) transaction_material.set_shader_parameter("gradient_fixed", false) transaction_material.set_shader_parameter("shape_texture", shape_tex) - transaction_material.set_shader_parameter("shape_tiling", 16.0) - transaction_material.set_shader_parameter("shape_rotation", 0.0) - transaction_material.set_shader_parameter("shape_scroll", Vector2.ZERO) - transaction_material.set_shader_parameter("shape_feathering", 0.05) - transaction_material.set_shader_parameter("shape_treshold", 1.0) # >=1 -> full at the end of the transation - transaction_material.set_shader_parameter("width", 0.5) + transaction_material.set_shader_parameter("shape_tiling", shape_tiling) + transaction_material.set_shader_parameter("shape_rotation", shape_rotation) + transaction_material.set_shader_parameter("shape_scroll", shape_scroll) + transaction_material.set_shader_parameter("shape_feathering", shape_feathering) + transaction_material.set_shader_parameter("shape_treshold", shape_treshold) + transaction_material.set_shader_parameter("width", width) color_rect.material = transaction_material @@ -76,7 +128,17 @@ func reveal(duration := 0.5) -> void: await t.finished color_rect.visible = false -func change_scene_with_standard_fade(scene_enum: SceneConfig.SceneName, duration: float = transition_duration, show_loading_label: bool = false) -> void: +func _setup_logo_safety() -> void: + if logo and logo.texture: + logo.visible = true + var texture_center = logo.texture.get_size() / 2 + + if logo.pivot_offset != texture_center: + var old_pivot = logo.pivot_offset + logo.pivot_offset = texture_center + logo.position -= (texture_center - old_pivot) * (Vector2.ONE - logo.scale) + +func change_scene_with_standard_fade(scene_enum: SceneConfig.SceneName, show_loading_label: bool = true) -> void: if not config or not config.scenes.has(scene_enum): return @@ -85,18 +147,31 @@ func change_scene_with_standard_fade(scene_enum: SceneConfig.SceneName, duration var target_scene: PackedScene = config.scenes[scene_enum] color_rect.mouse_filter = Control.MOUSE_FILTER_STOP - if show_loading_label: - loading_screen.visible = true - await cover(duration) + await cover(fade_in_duration) get_tree().change_scene_to_packed(target_scene) - await reveal(duration) - + if show_loading_label: + _setup_logo_safety() + loading_screen.modulate.a = 0.0 + loading_screen.visible = true + var tween_in = create_tween() + tween_in.tween_property(loading_screen, "modulate:a", 1.0, logo_fade_in_duration) + await tween_in.finished + + if black_screen_duration > 0.0: + await get_tree().create_timer(black_screen_duration).timeout + + if show_loading_label: + var tween_out = create_tween() + tween_out.tween_property(loading_screen, "modulate:a", 0.0, logo_fade_out_duration) + await tween_out.finished loading_screen.visible = false + + await reveal(fade_out_duration) color_rect.mouse_filter = Control.MOUSE_FILTER_IGNORE -func change_scene(scene_enum: SceneConfig.SceneName, duration: float = transition_duration, show_loading_label: bool = false) -> void: +func change_scene(scene_enum: SceneConfig.SceneName, show_loading_label: bool = true) -> void: if not config or not config.scenes.has(scene_enum): return @@ -105,17 +180,29 @@ func change_scene(scene_enum: SceneConfig.SceneName, duration: float = transitio var target_scene: PackedScene = config.scenes[scene_enum] color_rect.mouse_filter = Control.MOUSE_FILTER_STOP - if show_loading_label: - loading_screen.visible = true - await cover(duration) + await cover(fade_in_duration) get_tree().change_scene_to_packed(target_scene) - await reveal(duration) - + if show_loading_label: + _setup_logo_safety() + loading_screen.modulate.a = 0.0 + loading_screen.visible = true + var tween_in = create_tween() + tween_in.tween_property(loading_screen, "modulate:a", 1.0, logo_fade_in_duration) + await tween_in.finished + + if black_screen_duration > 0.0: + await get_tree().create_timer(black_screen_duration).timeout + + if show_loading_label: + var tween_out = create_tween() + tween_out.tween_property(loading_screen, "modulate:a", 0.0, logo_fade_out_duration) + await tween_out.finished loading_screen.visible = false + + await reveal(fade_out_duration) color_rect.mouse_filter = Control.MOUSE_FILTER_IGNORE func quit_game() -> void: get_tree().quit() - diff --git a/core/scene_manager/scene_manager.tscn b/core/scene_manager/scene_manager.tscn index b2efd4b..30d9df2 100644 --- a/core/scene_manager/scene_manager.tscn +++ b/core/scene_manager/scene_manager.tscn @@ -3,12 +3,16 @@ [ext_resource type="Script" uid="uid://bf1f2kp8ghtei" path="res://core/scene_manager/scene_manager.gd" id="1_7resu"] [ext_resource type="Resource" uid="uid://dr612tmciq8pg" path="res://core/scene_manager/scene_config.tres" id="2_vtdwt"] [ext_resource type="Theme" uid="uid://bg8megpn77mod" path="res://core/font/main_theme.tres" id="3_j173j"] +[ext_resource type="Texture2D" uid="uid://dlrq07g7w5gg8" path="res://core/splash_screen/tgcc_logo.png" id="4_k2alh"] [node name="SceneManager" type="CanvasLayer" unique_id=399843239] process_mode = 3 layer = 100 script = ExtResource("1_7resu") config = ExtResource("2_vtdwt") +fade_in_duration = 1.0 +black_screen_duration = 3.0 +fade_out_duration = 1.0 [node name="ColorRect" type="ColorRect" parent="." unique_id=1075660170] anchors_preset = 15 @@ -20,7 +24,6 @@ mouse_filter = 2 color = Color(0, 0, 0, 0) [node name="LoadingScreen" type="Control" parent="." unique_id=1075176512] -visible = false layout_mode = 3 anchors_preset = 15 anchor_right = 1.0 @@ -46,3 +49,19 @@ theme = ExtResource("3_j173j") theme_override_font_sizes/font_size = 32 text = "Loading..." uppercase = true + +[node name="Logo" type="TextureRect" parent="LoadingScreen" unique_id=425934742] +layout_mode = 1 +anchors_preset = 3 +anchor_left = 1.0 +anchor_top = 1.0 +anchor_right = 1.0 +anchor_bottom = 1.0 +offset_left = -233.0 +offset_top = -236.0 +offset_right = 791.0 +offset_bottom = 788.0 +grow_horizontal = 0 +grow_vertical = 0 +scale = Vector2(0.22, 0.22) +texture = ExtResource("4_k2alh") diff --git a/core/splash_screen/splash_screen.gd b/core/splash_screen/splash_screen.gd index 8480df0..6ed3ab7 100644 --- a/core/splash_screen/splash_screen.gd +++ b/core/splash_screen/splash_screen.gd @@ -1,17 +1,29 @@ extends Control + @export var main_menu_scene: PackedScene -@export var display_time: float = 2.0 -@export var fade_in_time: float = 0.5 +@export var initial_delay: float = 0.5 +@export var logo_fade_in_time: float = 1.0 +@export var logo_display_time: float = 2.0 +@export var logo_fade_out_time: float = 1.0 +@export var black_screen_delay: float = 0.5 + @onready var logo: Sprite2D = $ColorRect/JMPLogo func _ready() -> void: logo.modulate.a = 0.0 - await get_tree().create_timer(fade_in_time).timeout + await get_tree().create_timer(initial_delay).timeout - var tween := create_tween() - tween.tween_property(logo, "modulate:a", 1.0, fade_in_time).set_trans(Tween.TRANS_SINE).set_ease(Tween.EASE_OUT) + var tween_in := create_tween() + tween_in.tween_property(logo, "modulate:a", 1.0, logo_fade_in_time).set_trans(Tween.TRANS_SINE).set_ease(Tween.EASE_OUT) + await tween_in.finished - await get_tree().create_timer(display_time).timeout - #tween = create_tween() - #tween.tween_property(logo, "modulate:a", 0.0, fade_in_time).set_trans(Tween.TRANS_SINE).set_ease(Tween.EASE_OUT) - SceneManager.change_scene_with_standard_fade(SceneConfig.SceneName.MAIN_MENU, 0.5) + await get_tree().create_timer(logo_display_time).timeout + + var tween_out := create_tween() + tween_out.tween_property(logo, "modulate:a", 0.0, logo_fade_out_time).set_trans(Tween.TRANS_SINE).set_ease(Tween.EASE_IN) + await tween_out.finished + + # Aspetta lo schermo nero prima di caricare il menu principale + await get_tree().create_timer(black_screen_delay).timeout + + get_tree().change_scene_to_packed(main_menu_scene) diff --git a/core/splash_screen/splash_screen.tscn b/core/splash_screen/splash_screen.tscn index abc093e..23cade6 100644 --- a/core/splash_screen/splash_screen.tscn +++ b/core/splash_screen/splash_screen.tscn @@ -2,6 +2,7 @@ [ext_resource type="Script" uid="uid://ckj2pcoxi5j3" path="res://core/splash_screen/splash_screen.gd" id="1_elsnp"] [ext_resource type="Texture2D" uid="uid://dp3qxncy8u184" path="res://core/splash_screen/jmp_logo.png" id="1_jkpgl"] +[ext_resource type="PackedScene" uid="uid://btcpge7cj2041" path="res://core/main_menu/main_menu.tscn" id="2_qmlqp"] [node name="Control" type="Control" unique_id=163470013] layout_mode = 3 @@ -11,6 +12,8 @@ anchor_bottom = 1.0 grow_horizontal = 2 grow_vertical = 2 script = ExtResource("1_elsnp") +main_menu_scene = ExtResource("2_qmlqp") +logo_display_time = 1.25 [node name="ColorRect" type="ColorRect" parent="." unique_id=1599828641] layout_mode = 1 diff --git a/core/splash_screen/tgcc_logo.png b/core/splash_screen/tgcc_logo.png new file mode 100644 index 0000000..0069f3f Binary files /dev/null and b/core/splash_screen/tgcc_logo.png differ diff --git a/core/splash_screen/tgcc_logo.png.import b/core/splash_screen/tgcc_logo.png.import new file mode 100644 index 0000000..936f9e9 --- /dev/null +++ b/core/splash_screen/tgcc_logo.png.import @@ -0,0 +1,40 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://dlrq07g7w5gg8" +path="res://.godot/imported/tgcc_logo.png-31dd91a5ccff8eb02e16f9fd08dfa111.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://core/splash_screen/tgcc_logo.png" +dest_files=["res://.godot/imported/tgcc_logo.png-31dd91a5ccff8eb02e16f9fd08dfa111.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/uastc_level=0 +compress/rdo_quality_loss=0.0 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/channel_remap/red=0 +process/channel_remap/green=1 +process/channel_remap/blue=2 +process/channel_remap/alpha=3 +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1