made sub level transitions a bit smoother

This commit is contained in:
JHDev2006
2025-09-20 19:09:34 +01:00
parent 99066de39b
commit 4cc6e938fc
11 changed files with 2839 additions and 2708 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 179 B

View File

@@ -0,0 +1,40 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://35who743oaxe"
path="res://.godot/imported/LSSRatingStars.png-80e9249472623547495a480542a8eb0d.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://Assets/Sprites/UI/LSSRatingStars.png"
dest_files=["res://.godot/imported/LSSRatingStars.png-80e9249472623547495a480542a8eb0d.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

File diff suppressed because it is too large Load Diff

View File

@@ -49,6 +49,15 @@ theme_override_constants/separation = 0
layout_mode = 2 layout_mode = 2
size_flags_horizontal = 3 size_flags_horizontal = 3
[node name="Thumbnail" type="TextureRect" parent="MarginContainer/HBoxContainer/HSplitContainer/LeftHalf"]
unique_name_in_owner = true
custom_minimum_size = Vector2(32, 32)
layout_mode = 2
size_flags_horizontal = 0
size_flags_vertical = 4
expand_mode = 3
stretch_mode = 5
[node name="LevelIcon" type="NinePatchRect" parent="MarginContainer/HBoxContainer/HSplitContainer/LeftHalf"] [node name="LevelIcon" type="NinePatchRect" parent="MarginContainer/HBoxContainer/HSplitContainer/LeftHalf"]
unique_name_in_owner = true unique_name_in_owner = true
custom_minimum_size = Vector2(32, 32) custom_minimum_size = Vector2(32, 32)

View File

@@ -1,4 +1,4 @@
[gd_scene load_steps=14 format=3 uid="uid://cr2pku7fjkgpo"] [gd_scene load_steps=15 format=3 uid="uid://cr2pku7fjkgpo"]
[ext_resource type="StyleBox" uid="uid://comkghpj0djcl" path="res://Resources/UI/Panel.tres" id="1_1k7iw"] [ext_resource type="StyleBox" uid="uid://comkghpj0djcl" path="res://Resources/UI/Panel.tres" id="1_1k7iw"]
[ext_resource type="StyleBox" uid="uid://dlbdmqmnl30sq" path="res://Resources/UI/PanelSelected.tres" id="2_h6n8u"] [ext_resource type="StyleBox" uid="uid://dlbdmqmnl30sq" path="res://Resources/UI/PanelSelected.tres" id="2_h6n8u"]
@@ -6,6 +6,7 @@
[ext_resource type="Script" uid="uid://d63p6qr5a748" path="res://Scripts/UI/AutoScrollContainer.gd" id="5_ajmg3"] [ext_resource type="Script" uid="uid://d63p6qr5a748" path="res://Scripts/UI/AutoScrollContainer.gd" id="5_ajmg3"]
[ext_resource type="Texture2D" uid="uid://dmggnqp6esawy" path="res://Assets/Sprites/UI/DifficultyStars.png" id="6_m23pw"] [ext_resource type="Texture2D" uid="uid://dmggnqp6esawy" path="res://Assets/Sprites/UI/DifficultyStars.png" id="6_m23pw"]
[ext_resource type="Script" uid="uid://xem6lai3ufyj" path="res://Scripts/Classes/UI/PackNinePatch.gd" id="6_w0xci"] [ext_resource type="Script" uid="uid://xem6lai3ufyj" path="res://Scripts/Classes/UI/PackNinePatch.gd" id="6_w0xci"]
[ext_resource type="Texture2D" uid="uid://35who743oaxe" path="res://Assets/Sprites/UI/LSSRatingStars.png" id="7_1k7iw"]
[ext_resource type="Texture2D" uid="uid://dfeu75lbxfkim" path="res://Assets/Sprites/UI/GameStyles.png" id="7_scevv"] [ext_resource type="Texture2D" uid="uid://dfeu75lbxfkim" path="res://Assets/Sprites/UI/GameStyles.png" id="7_scevv"]
[ext_resource type="Script" uid="uid://cbal8ms2oe1ik" path="res://Scripts/Classes/Components/ResourceSetterNew.gd" id="8_vfnya"] [ext_resource type="Script" uid="uid://cbal8ms2oe1ik" path="res://Scripts/Classes/Components/ResourceSetterNew.gd" id="8_vfnya"]
[ext_resource type="JSON" path="res://Assets/Sprites/UI/Cursor.json" id="9_d0564"] [ext_resource type="JSON" path="res://Assets/Sprites/UI/Cursor.json" id="9_d0564"]
@@ -215,6 +216,56 @@ patch_margin_bottom = 8
script = ExtResource("6_w0xci") script = ExtResource("6_w0xci")
metadata/_custom_type_script = "uid://xem6lai3ufyj" metadata/_custom_type_script = "uid://xem6lai3ufyj"
[node name="RatingStars" type="HBoxContainer" parent="MarginContainer/HBoxContainer/HSplitContainer/VBoxContainer"]
unique_name_in_owner = true
layout_mode = 2
theme_override_constants/separation = 0
[node name="Star1" type="NinePatchRect" parent="MarginContainer/HBoxContainer/HSplitContainer/VBoxContainer/RatingStars"]
custom_minimum_size = Vector2(8, 0)
layout_mode = 2
texture = ExtResource("7_1k7iw")
region_rect = Rect2(0, 0, 8, 8)
patch_margin_bottom = 8
script = ExtResource("6_w0xci")
metadata/_custom_type_script = "uid://xem6lai3ufyj"
[node name="Star2" type="NinePatchRect" parent="MarginContainer/HBoxContainer/HSplitContainer/VBoxContainer/RatingStars"]
custom_minimum_size = Vector2(8, 0)
layout_mode = 2
texture = ExtResource("7_1k7iw")
region_rect = Rect2(0, 0, 8, 8)
patch_margin_bottom = 8
script = ExtResource("6_w0xci")
metadata/_custom_type_script = "uid://xem6lai3ufyj"
[node name="Star3" type="NinePatchRect" parent="MarginContainer/HBoxContainer/HSplitContainer/VBoxContainer/RatingStars"]
custom_minimum_size = Vector2(8, 0)
layout_mode = 2
texture = ExtResource("7_1k7iw")
region_rect = Rect2(0, 0, 8, 8)
patch_margin_bottom = 8
script = ExtResource("6_w0xci")
metadata/_custom_type_script = "uid://xem6lai3ufyj"
[node name="Star4" type="NinePatchRect" parent="MarginContainer/HBoxContainer/HSplitContainer/VBoxContainer/RatingStars"]
custom_minimum_size = Vector2(8, 0)
layout_mode = 2
texture = ExtResource("7_1k7iw")
region_rect = Rect2(0, 0, 8, 8)
patch_margin_bottom = 8
script = ExtResource("6_w0xci")
metadata/_custom_type_script = "uid://xem6lai3ufyj"
[node name="Star5" type="NinePatchRect" parent="MarginContainer/HBoxContainer/HSplitContainer/VBoxContainer/RatingStars"]
custom_minimum_size = Vector2(8, 0)
layout_mode = 2
texture = ExtResource("7_1k7iw")
region_rect = Rect2(0, 0, 8, 8)
patch_margin_bottom = 8
script = ExtResource("6_w0xci")
metadata/_custom_type_script = "uid://xem6lai3ufyj"
[node name="CampaignIcon" type="NinePatchRect" parent="MarginContainer/HBoxContainer/HSplitContainer/VBoxContainer"] [node name="CampaignIcon" type="NinePatchRect" parent="MarginContainer/HBoxContainer/HSplitContainer/VBoxContainer"]
unique_name_in_owner = true unique_name_in_owner = true
custom_minimum_size = Vector2(42, 16) custom_minimum_size = Vector2(42, 16)

View File

@@ -657,6 +657,7 @@ func transition_to_sublevel(sub_lvl_idx := 0) -> void:
LevelPersistance.reset_states() LevelPersistance.reset_states()
sub_level_id = sub_lvl_idx sub_level_id = sub_lvl_idx
$LevelLoader.load_level(sub_lvl_idx) $LevelLoader.load_level(sub_lvl_idx)
Global.do_fake_transition(0.1)
await get_tree().physics_frame await get_tree().physics_frame
if (play_pipe_transition or play_door_transition) and play_transition: if (play_pipe_transition or play_door_transition) and play_transition:
parse_tiles() parse_tiles()

View File

@@ -304,16 +304,16 @@ func transition_to_scene(scene_path := "") -> void:
func do_fake_transition() -> void: func do_fake_transition(duration := 0.2) -> void:
if fade_transition: if fade_transition:
$Transition/AnimationPlayer.play("FadeIn") $Transition/AnimationPlayer.play("FadeIn")
await $Transition/AnimationPlayer.animation_finished await $Transition/AnimationPlayer.animation_finished
await get_tree().create_timer(0.2, false).timeout await get_tree().create_timer(duration, false).timeout
$Transition/AnimationPlayer.play_backwards("FadeIn") $Transition/AnimationPlayer.play_backwards("FadeIn")
else: else:
%TransitionBlock.modulate.a = 1 %TransitionBlock.modulate.a = 1
$Transition.show() $Transition.show()
await get_tree().create_timer(0.25, false).timeout await get_tree().create_timer(duration + 0.05, false).timeout
$Transition.hide() $Transition.hide()
func freeze_screen() -> void: func freeze_screen() -> void:

View File

@@ -12,6 +12,7 @@ var game_style := "SMBLL"
var difficulty := 0 var difficulty := 0
var file_path := "" var file_path := ""
var is_downloaded := false var is_downloaded := false
var thumbnail: Texture = null
var level_id := "" var level_id := ""
var idx := 0 var idx := 0
@@ -55,9 +56,14 @@ func _ready() -> void:
update_visuals() update_visuals()
func update_visuals() -> void: func update_visuals() -> void:
if is_downloaded: if is_downloaded and FileAccess.file_exists("user://custom_levels/downloaded/thumbnails/" + level_id + ".png"):
%LevelIcon.texture = ImageTexture.create_from_image(Image.load_from_file("user://custom_levels/downloaded/thumbnails/" + level_id + ".png")) thumbnail = ImageTexture.create_from_image(Image.load_from_file("user://custom_levels/downloaded/thumbnails/" + level_id + ".png"))
%Thumbnail.texture = thumbnail
%LevelIcon.hide()
%Thumbnail.show()
else: else:
%Thumbnail.hide()
%LevelIcon.show()
%LevelIcon.texture = ResourceSetter.get_resource(ICON_TEXTURES[level_time]) %LevelIcon.texture = ResourceSetter.get_resource(ICON_TEXTURES[level_time])
%LevelIcon.region_rect = THEME_RECTS[level_theme] %LevelIcon.region_rect = THEME_RECTS[level_theme]

View File

@@ -52,19 +52,20 @@ func get_levels(path := "user://custom_levels") -> void:
continue continue
%LevelContainers.get_node("Label").hide() %LevelContainers.get_node("Label").hide()
var container = CUSTOM_LEVEL_CONTAINER.instantiate() var container = CUSTOM_LEVEL_CONTAINER.instantiate()
var file = FileAccess.open(path + "/" + i, FileAccess.READ) var file_path = path + "/" + i
var file = FileAccess.open(file_path, FileAccess.READ)
var json = JSON.parse_string(file.get_as_text()) var json = JSON.parse_string(file.get_as_text())
file.close() file.close()
var data = json["Levels"][0]["Data"].split("=") var data = json["Levels"][0]["Data"].split("=")
var info = json["Info"] var info = json["Info"]
container.is_downloaded = path.contains("/downloaded/") container.is_downloaded = path.contains("downloaded")
if container.is_downloaded: if container.is_downloaded:
container.level_id = path.get_file().replace(".lvl", "") container.level_id = file_path.get_file().replace(".lvl", "")
container.level_name = info["Name"] container.level_name = info["Name"]
container.level_author = info["Author"] container.level_author = info["Author"]
container.level_desc = info["Description"] container.level_desc = info["Description"]
container.idx = idx container.idx = idx
container.file_path = path + "/" + i container.file_path = file_path
container.level_theme = Level.THEME_IDXS[base64_charset.find(data[0])] container.level_theme = Level.THEME_IDXS[base64_charset.find(data[0])]
container.level_time = base64_charset.find(data[1]) container.level_time = base64_charset.find(data[1])
container.game_style = Global.CAMPAIGNS[base64_charset.find(data[3])] container.game_style = Global.CAMPAIGNS[base64_charset.find(data[3])]

View File

@@ -79,6 +79,7 @@ func spawn_containers() -> void:
container.level_author = i.author.username container.level_author = i.author.username
container.difficulty = i.difficulty container.difficulty = i.difficulty
container.level_id = i._id container.level_id = i._id
container.ratings = i.rates
container.level_selected.connect(show_info) container.level_selected.connect(show_info)
if i.has("thumbnail"): if i.has("thumbnail"):
if i.thumbnail != null: if i.thumbnail != null:

View File

@@ -7,6 +7,8 @@ var level_thumbnail = null
var level_id := "" var level_id := ""
var thumbnail_url := "" var thumbnail_url := ""
var ratings := []
var difficulty := "Easy" var difficulty := "Easy"
var featured = false var featured = false
@@ -38,10 +40,19 @@ func setup_visuals() -> void:
print(difficulty) print(difficulty)
var difficulty_int = DIFFICULTY_TO_STAR_TRANSLATION[difficulty] var difficulty_int = DIFFICULTY_TO_STAR_TRANSLATION[difficulty]
for i in %DifficultyStars.get_children(): for i in %DifficultyStars.get_children():
i.region_rect.position.x = 24 if idx > difficulty_int else [0, 0, 8, 8, 16][difficulty_int] i.region_rect.position.x = 32 if idx > difficulty_int else [0, 8, 8, 16, 24][difficulty_int]
idx += 1 idx += 1
setup_rating_stars()
get_thumbnail() get_thumbnail()
func setup_rating_stars() -> void:
var rating = calculate_rating()
var idx := 0
for i in %RatingStars.get_children():
i.region_rect.position.x = 16 if idx > rating else (0 if abs(idx - rating) >= 0.5 else 8)
idx += 1
func get_thumbnail() -> void: func get_thumbnail() -> void:
if cached_thumbnails.has(level_id): if cached_thumbnails.has(level_id):
%LevelIcon.texture = cached_thumbnails[level_id] %LevelIcon.texture = cached_thumbnails[level_id]
@@ -53,6 +64,17 @@ func get_thumbnail() -> void:
return return
$ThumbnailDownloader.request(thumbnail_url, [], HTTPClient.METHOD_GET) $ThumbnailDownloader.request(thumbnail_url, [], HTTPClient.METHOD_GET)
func calculate_rating() -> int:
var rating := -1.0
var total := 0
if ratings.is_empty():
return 0
for i in ratings:
total += i
rating = total / float(ratings.size())
print(rating)
return rating
func on_request_completed(result: int, response_code: int, headers: PackedStringArray, body: PackedByteArray) -> void: func on_request_completed(result: int, response_code: int, headers: PackedStringArray, body: PackedByteArray) -> void:
var image = Image.new() var image = Image.new()
if thumbnail_url.contains(".webp"): if thumbnail_url.contains(".webp"):