imported main menu scene addon

This commit is contained in:
2026-05-10 15:48:56 +02:00
parent 86d9f75161
commit 71c2850a34
458 changed files with 14881 additions and 0 deletions

View File

@@ -0,0 +1,11 @@
[gd_scene format=3 uid="uid://brhug56ihh06"]
[ext_resource type="PackedScene" path="res://addons/maaacks_game_template/base/nodes/loading_screen/loading_screen.tscn" id="1_akme8"]
[ext_resource type="Script" path="res://scenes/loading_screen/loading_screen.gd" id="2_kl30i"]
[node name="LevelLoadingScreen" unique_id=1716792690 instance=ExtResource("1_akme8")]
script = ExtResource("2_kl30i")
_in_progress = "Loading Level..."
_in_progress_waiting = "Still Loading Level..."
_in_progress_still_waiting = "Still Loading Level... (%d seconds)"
_complete = "Loading Level Complete!"

View File

@@ -0,0 +1 @@
extends LoadingScreen

View File

@@ -0,0 +1 @@
uid://ca3k1q1qyu51x

View File

@@ -0,0 +1,7 @@
[gd_scene format=3 uid="uid://cj6bp67uxoetc"]
[ext_resource type="PackedScene" path="res://addons/maaacks_game_template/base/nodes/loading_screen/loading_screen.tscn" id="1_a8kcw"]
[ext_resource type="Script" path="res://scenes/loading_screen/loading_screen.gd" id="2_53rj4"]
[node name="LoadingScreen" unique_id=179842335 instance=ExtResource("1_a8kcw")]
script = ExtResource("2_53rj4")

View File

@@ -0,0 +1,98 @@
extends LoadingScreen
## Loading Screen extension that pre-loads shaders before opening the next scene.
## Path to directory with the material shaders that should be pre-loaded.
@export_dir var _spatial_shader_material_dir : String
## Path to the scene that should trigger a shader pre-loading.
@export_file("*.tscn") var _cache_shaders_scene : String
## Mesh object that the material shaders should be applied to.
@export var _mesh : Mesh
@export_group("Advanced")
## Includes material scenes with extensions that match the strings.
@export var _matching_extensions : Array[String] = [".tres", ".material", ".res"]
## Excludes subfolders that match the strings.
@export var _ignore_subfolders : Array[String] = [".", ".."]
## Delay between loading each shader onto the mesh.
@export var _shader_delay_timer : float = 0.1
var _loading_shader_cache : bool = false
var _caching_progress : float = 0.0 :
set(value):
if value <= _caching_progress:
return
_caching_progress = value
update_total_loading_progress()
_reset_loading_stage()
func can_load_shader_cache() -> bool:
return not _spatial_shader_material_dir.is_empty() and \
not _cache_shaders_scene.is_empty() and \
SceneLoader.is_loading_scene(_cache_shaders_scene)
func update_total_loading_progress() -> void:
var partial_total := _scene_loading_progress
if can_load_shader_cache():
partial_total += _caching_progress
partial_total /= 2
_total_loading_progress = partial_total
func _set_scene_loading_complete() -> void:
super._set_scene_loading_complete()
if can_load_shader_cache() and not _loading_shader_cache:
_loading_shader_cache = true
_show_all_draw_passes_once()
if can_load_shader_cache() and _caching_progress < 1.0:
return
SceneLoader._background_loading = false
SceneLoader.set_process(true)
func _show_all_draw_passes_once() -> void:
var all_materials := _traverse_folders(_spatial_shader_material_dir)
var total_material_count := all_materials.size()
var cached_material_count := 0
for material_path in all_materials:
_load_material(material_path)
cached_material_count += 1
_caching_progress = float(cached_material_count) / total_material_count
if _shader_delay_timer > 0:
await(get_tree().create_timer(_shader_delay_timer).timeout)
func _traverse_folders(dir_path:String) -> PackedStringArray:
var material_list:PackedStringArray = []
if not dir_path.ends_with("/"):
dir_path += "/"
var dir := DirAccess.open(dir_path)
if not dir:
push_error("failed to access the path ", dir_path)
return []
if dir.list_dir_begin() != OK:
push_error("failed to access the path ", dir_path)
return []
var file_name := dir.get_next()
while file_name != "":
if not dir.current_is_dir():
var matches : bool = false
for extension in _matching_extensions:
if file_name.ends_with(extension):
matches = true
break
if matches:
material_list.append(dir_path + file_name)
else:
var subfolder_name := file_name
if not subfolder_name in _ignore_subfolders:
material_list.append_array(_traverse_folders(dir_path + subfolder_name))
file_name = dir.get_next()
return material_list
func _load_material(path:String) -> void:
var material_shower := MeshInstance3D.new()
material_shower.mesh = _mesh
var material := ResourceLoader.load(path) as Material
material_shower.set_surface_override_material(0, material)
%SpatialShaderTypeCaches.add_child(material_shower)
func _ready() -> void:
SceneLoader._background_loading = true

View File

@@ -0,0 +1 @@
uid://cg7lkm5qw226o

View File

@@ -0,0 +1,22 @@
[gd_scene format=3 uid="uid://26mrq3f5vqql"]
[ext_resource type="PackedScene" path="res://addons/maaacks_game_template/base/nodes/loading_screen/loading_screen.tscn" id="1_alqvd"]
[ext_resource type="Script" path="res://scenes/loading_screen/loading_screen_with_shader_caching.gd" id="2_n5fdm"]
[sub_resource type="QuadMesh" id="QuadMesh_klnwy"]
[node name="LoadingScreen" unique_id=1866533347 instance=ExtResource("1_alqvd")]
script = ExtResource("2_n5fdm")
_spatial_shader_material_dir = ""
_cache_shaders_scene = "res://scenes/game_scene/game_ui.tscn"
_mesh = SubResource("QuadMesh_klnwy")
_matching_extensions = Array[String]([".tres", ".material", ".res"])
_ignore_subfolders = Array[String]([".", ".."])
_shader_delay_timer = 0.1
[node name="SpatialShaderTypeCaches" type="Node3D" parent="." index="2" unique_id=634879644]
unique_name_in_owner = true
[node name="Camera3D" type="Camera3D" parent="SpatialShaderTypeCaches" index="0" unique_id=387206904]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1.408)
current = true