mirror of
https://github.com/JHDev2006/Super-Mario-Bros.-Remastered-Public.git
synced 2025-10-22 15:38:14 +00:00
made sub level transitions a bit smoother
This commit is contained in:
@@ -7,6 +7,8 @@ var level_thumbnail = null
|
||||
var level_id := ""
|
||||
var thumbnail_url := ""
|
||||
|
||||
var ratings := []
|
||||
|
||||
var difficulty := "Easy"
|
||||
var featured = false
|
||||
|
||||
@@ -38,10 +40,19 @@ func setup_visuals() -> void:
|
||||
print(difficulty)
|
||||
var difficulty_int = DIFFICULTY_TO_STAR_TRANSLATION[difficulty]
|
||||
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
|
||||
setup_rating_stars()
|
||||
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:
|
||||
if cached_thumbnails.has(level_id):
|
||||
%LevelIcon.texture = cached_thumbnails[level_id]
|
||||
@@ -53,6 +64,17 @@ func get_thumbnail() -> void:
|
||||
return
|
||||
$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:
|
||||
var image = Image.new()
|
||||
if thumbnail_url.contains(".webp"):
|
||||
|
Reference in New Issue
Block a user