mirror of
https://github.com/JHDev2006/Super-Mario-Bros.-Remastered-Public.git
synced 2025-10-22 15:38:14 +00:00
Your current LSS Browsing data will be saved upon playing a custom level, and will return you to where you originally were, before play
This commit is contained in:
@@ -362,11 +362,11 @@ layout_mode = 2
|
|||||||
focus_mode = 0
|
focus_mode = 0
|
||||||
|
|
||||||
[node name="ScrollContainer" parent="BG/Border/Levels/VBoxContainer/LevelInfo/SelectedLevel/MarginContainer/HBoxContainer/HSplitContainer/LeftHalf/LevelInfo" index="0"]
|
[node name="ScrollContainer" parent="BG/Border/Levels/VBoxContainer/LevelInfo/SelectedLevel/MarginContainer/HBoxContainer/HSplitContainer/LeftHalf/LevelInfo" index="0"]
|
||||||
scroll_horizontal = 95
|
scroll_horizontal = 166
|
||||||
is_active = true
|
is_active = true
|
||||||
|
|
||||||
[node name="ScrollContainer2" parent="BG/Border/Levels/VBoxContainer/LevelInfo/SelectedLevel/MarginContainer/HBoxContainer/HSplitContainer/LeftHalf/LevelInfo" index="1"]
|
[node name="ScrollContainer2" parent="BG/Border/Levels/VBoxContainer/LevelInfo/SelectedLevel/MarginContainer/HBoxContainer/HSplitContainer/LeftHalf/LevelInfo" index="1"]
|
||||||
scroll_horizontal = 18
|
scroll_horizontal = 32
|
||||||
is_active = true
|
is_active = true
|
||||||
|
|
||||||
[node name="Panel" type="PanelContainer" parent="BG/Border/Levels/VBoxContainer/LevelInfo"]
|
[node name="Panel" type="PanelContainer" parent="BG/Border/Levels/VBoxContainer/LevelInfo"]
|
||||||
@@ -377,7 +377,7 @@ theme_override_styles/panel = ExtResource("8_psbt7")
|
|||||||
[node name="AutoScrollContainer" type="ScrollContainer" parent="BG/Border/Levels/VBoxContainer/LevelInfo/Panel"]
|
[node name="AutoScrollContainer" type="ScrollContainer" parent="BG/Border/Levels/VBoxContainer/LevelInfo/Panel"]
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
mouse_filter = 2
|
mouse_filter = 2
|
||||||
scroll_vertical = 58
|
scroll_vertical = 59
|
||||||
horizontal_scroll_mode = 3
|
horizontal_scroll_mode = 3
|
||||||
vertical_scroll_mode = 3
|
vertical_scroll_mode = 3
|
||||||
script = ExtResource("24_wf6nb")
|
script = ExtResource("24_wf6nb")
|
||||||
@@ -469,13 +469,15 @@ unique_name_in_owner = true
|
|||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
text = "EDITOR_MAIN_REFRESH"
|
text = "EDITOR_MAIN_REFRESH"
|
||||||
|
|
||||||
[node name="SelectableOptionLabel" parent="BG/Border/Levels/VBoxContainer/LSSBrowser/VBoxContainer" instance=ExtResource("22_13and")]
|
[node name="Sort" parent="BG/Border/Levels/VBoxContainer/LSSBrowser/VBoxContainer" instance=ExtResource("22_13and")]
|
||||||
|
unique_name_in_owner = true
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
title = "EDITOR_LSS_SORT"
|
title = "EDITOR_LSS_SORT"
|
||||||
values = Array[String](["EDITOR_LSS_SORT_FEATURED", "EDITOR_LSS_SORT_RECENT", "EDITOR_LSS_SORT_DOWNLOADS", "EDITOR_LSS_SORT_RATING"])
|
values = Array[String](["EDITOR_LSS_SORT_FEATURED", "EDITOR_LSS_SORT_RECENT", "EDITOR_LSS_SORT_DOWNLOADS", "EDITOR_LSS_SORT_RATING"])
|
||||||
add_colon = false
|
add_colon = false
|
||||||
|
|
||||||
[node name="Order" parent="BG/Border/Levels/VBoxContainer/LSSBrowser/VBoxContainer" instance=ExtResource("22_13and")]
|
[node name="Order" parent="BG/Border/Levels/VBoxContainer/LSSBrowser/VBoxContainer" instance=ExtResource("22_13and")]
|
||||||
|
unique_name_in_owner = true
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
title = "EDITOR_LSS_ORDER"
|
title = "EDITOR_LSS_ORDER"
|
||||||
values = Array[String](["EDITOR_LSS_ORDER_ASC", "EDITOR_LSS_ORDER_DEC"])
|
values = Array[String](["EDITOR_LSS_ORDER_ASC", "EDITOR_LSS_ORDER_DEC"])
|
||||||
@@ -563,12 +565,12 @@ layout_mode = 2
|
|||||||
focus_mode = 0
|
focus_mode = 0
|
||||||
|
|
||||||
[node name="ScrollContainer" parent="BG/Border/Levels/VBoxContainer/LSSLevelInfo/SelectedOnlineLevel/MarginContainer/HBoxContainer/HSplitContainer/LeftHalf/LevelInfo" index="0"]
|
[node name="ScrollContainer" parent="BG/Border/Levels/VBoxContainer/LSSLevelInfo/SelectedOnlineLevel/MarginContainer/HBoxContainer/HSplitContainer/LeftHalf/LevelInfo" index="0"]
|
||||||
scroll_horizontal = 66
|
scroll_horizontal = 24
|
||||||
is_active = true
|
is_active = true
|
||||||
auto_connect_focus = false
|
auto_connect_focus = false
|
||||||
|
|
||||||
[node name="ScrollContainer2" parent="BG/Border/Levels/VBoxContainer/LSSLevelInfo/SelectedOnlineLevel/MarginContainer/HBoxContainer/HSplitContainer/LeftHalf/LevelInfo" index="1"]
|
[node name="ScrollContainer2" parent="BG/Border/Levels/VBoxContainer/LSSLevelInfo/SelectedOnlineLevel/MarginContainer/HBoxContainer/HSplitContainer/LeftHalf/LevelInfo" index="1"]
|
||||||
scroll_horizontal = 18
|
scroll_horizontal = 32
|
||||||
is_active = true
|
is_active = true
|
||||||
auto_connect_focus = false
|
auto_connect_focus = false
|
||||||
|
|
||||||
@@ -581,7 +583,7 @@ theme_override_styles/panel = ExtResource("8_psbt7")
|
|||||||
[node name="AutoScrollContainer" type="ScrollContainer" parent="BG/Border/Levels/VBoxContainer/LSSLevelInfo/Panel"]
|
[node name="AutoScrollContainer" type="ScrollContainer" parent="BG/Border/Levels/VBoxContainer/LSSLevelInfo/Panel"]
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
mouse_filter = 0
|
mouse_filter = 0
|
||||||
scroll_vertical = 58
|
scroll_vertical = 59
|
||||||
horizontal_scroll_mode = 3
|
horizontal_scroll_mode = 3
|
||||||
script = ExtResource("24_wf6nb")
|
script = ExtResource("24_wf6nb")
|
||||||
direction = 1
|
direction = 1
|
||||||
@@ -685,13 +687,15 @@ focus_mode = 2
|
|||||||
[connection signal="level_selected" from="BG/Border/Levels/VBoxContainer/LSSBrowser" to="BG/Border/Levels/VBoxContainer/LSSLevelInfo" method="open"]
|
[connection signal="level_selected" from="BG/Border/Levels/VBoxContainer/LSSBrowser" to="BG/Border/Levels/VBoxContainer/LSSLevelInfo" method="open"]
|
||||||
[connection signal="level_selected" from="BG/Border/Levels/VBoxContainer/LSSBrowser" to="BG/Border/Levels/VBoxContainer/LSSBrowser" method="close" unbinds=1]
|
[connection signal="level_selected" from="BG/Border/Levels/VBoxContainer/LSSBrowser" to="BG/Border/Levels/VBoxContainer/LSSBrowser" method="close" unbinds=1]
|
||||||
[connection signal="pressed" from="BG/Border/Levels/VBoxContainer/LSSBrowser/VBoxContainer/RefreshList" to="BG/Border/Levels/VBoxContainer/LSSBrowser" method="grab_levels"]
|
[connection signal="pressed" from="BG/Border/Levels/VBoxContainer/LSSBrowser/VBoxContainer/RefreshList" to="BG/Border/Levels/VBoxContainer/LSSBrowser" method="grab_levels"]
|
||||||
[connection signal="value_changed" from="BG/Border/Levels/VBoxContainer/LSSBrowser/VBoxContainer/SelectableOptionLabel" to="BG/Border/Levels/VBoxContainer/LSSBrowser" method="set_filter"]
|
[connection signal="value_changed" from="BG/Border/Levels/VBoxContainer/LSSBrowser/VBoxContainer/Sort" to="BG/Border/Levels/VBoxContainer/LSSBrowser" method="set_filter"]
|
||||||
[connection signal="value_changed" from="BG/Border/Levels/VBoxContainer/LSSBrowser/VBoxContainer/Order" to="BG/Border/Levels/VBoxContainer/LSSBrowser" method="set_order"]
|
[connection signal="value_changed" from="BG/Border/Levels/VBoxContainer/LSSBrowser/VBoxContainer/Order" to="BG/Border/Levels/VBoxContainer/LSSBrowser" method="set_order"]
|
||||||
[connection signal="value_changed" from="BG/Border/Levels/VBoxContainer/LSSBrowser/VBoxContainer/Page" to="BG/Border/Levels/VBoxContainer/LSSBrowser" method="set_page"]
|
[connection signal="value_changed" from="BG/Border/Levels/VBoxContainer/LSSBrowser/VBoxContainer/Page" to="BG/Border/Levels/VBoxContainer/LSSBrowser" method="set_page"]
|
||||||
[connection signal="request_completed" from="BG/Border/Levels/VBoxContainer/LSSBrowser/HTTPRequest" to="BG/Border/Levels/VBoxContainer/LSSBrowser" method="level_list_retrieved"]
|
[connection signal="request_completed" from="BG/Border/Levels/VBoxContainer/LSSBrowser/HTTPRequest" to="BG/Border/Levels/VBoxContainer/LSSBrowser" method="level_list_retrieved"]
|
||||||
[connection signal="tree_exiting" from="BG/Border/Levels/VBoxContainer/LSSBrowser/HTTPRequest" to="BG/Border/Levels/VBoxContainer/LSSBrowser/HTTPRequest" method="cancel_request"]
|
[connection signal="tree_exiting" from="BG/Border/Levels/VBoxContainer/LSSBrowser/HTTPRequest" to="BG/Border/Levels/VBoxContainer/LSSBrowser/HTTPRequest" method="cancel_request"]
|
||||||
|
[connection signal="closed" from="BG/Border/Levels/VBoxContainer/LSSLevelInfo" to="." method="clear_saved_stuff"]
|
||||||
[connection signal="closed" from="BG/Border/Levels/VBoxContainer/LSSLevelInfo" to="BG/Border/Levels/VBoxContainer/LSSBrowser" method="open" binds= [false]]
|
[connection signal="closed" from="BG/Border/Levels/VBoxContainer/LSSLevelInfo" to="BG/Border/Levels/VBoxContainer/LSSBrowser" method="open" binds= [false]]
|
||||||
[connection signal="level_play" from="BG/Border/Levels/VBoxContainer/LSSLevelInfo" to="." method="play_level"]
|
[connection signal="level_play" from="BG/Border/Levels/VBoxContainer/LSSLevelInfo" to="." method="play_level"]
|
||||||
|
[connection signal="level_play" from="BG/Border/Levels/VBoxContainer/LSSLevelInfo" to="." method="lss_level_played"]
|
||||||
[connection signal="pressed" from="BG/Border/Levels/VBoxContainer/LSSLevelInfo/HBoxContainer/Download" to="BG/Border/Levels/VBoxContainer/LSSLevelInfo" method="download_level"]
|
[connection signal="pressed" from="BG/Border/Levels/VBoxContainer/LSSLevelInfo/HBoxContainer/Download" to="BG/Border/Levels/VBoxContainer/LSSLevelInfo" method="download_level"]
|
||||||
[connection signal="pressed" from="BG/Border/Levels/VBoxContainer/LSSLevelInfo/HBoxContainer/OnlinePlay" to="BG/Border/Levels/VBoxContainer/LSSLevelInfo" method="play_level"]
|
[connection signal="pressed" from="BG/Border/Levels/VBoxContainer/LSSLevelInfo/HBoxContainer/OnlinePlay" to="BG/Border/Levels/VBoxContainer/LSSLevelInfo" method="play_level"]
|
||||||
[connection signal="pressed" from="BG/Border/Levels/VBoxContainer/LSSLevelInfo/HBoxContainer/ViewOnLSS" to="BG/Border/Levels/VBoxContainer/LSSLevelInfo" method="open_lss"]
|
[connection signal="pressed" from="BG/Border/Levels/VBoxContainer/LSSLevelInfo/HBoxContainer/ViewOnLSS" to="BG/Border/Levels/VBoxContainer/LSSLevelInfo" method="open_lss"]
|
||||||
|
@@ -240,7 +240,6 @@ func cleanup() -> void:
|
|||||||
playing_level = !playing_level
|
playing_level = !playing_level
|
||||||
play_pipe_transition = false
|
play_pipe_transition = false
|
||||||
play_door_transition = false
|
play_door_transition = false
|
||||||
Door.unlocked_doors = []
|
|
||||||
LevelPersistance.reset_states()
|
LevelPersistance.reset_states()
|
||||||
KeyItem.total_collected = 0
|
KeyItem.total_collected = 0
|
||||||
Global.get_node("GameHUD").visible = playing_level
|
Global.get_node("GameHUD").visible = playing_level
|
||||||
@@ -656,7 +655,8 @@ func transition_to_sublevel(sub_lvl_idx := 0) -> void:
|
|||||||
level_file = $LevelSaver.save_level(level_name, level_author, level_desc, difficulty)
|
level_file = $LevelSaver.save_level(level_name, level_author, level_desc, difficulty)
|
||||||
LevelPersistance.reset_states()
|
LevelPersistance.reset_states()
|
||||||
sub_level_id = sub_lvl_idx
|
sub_level_id = sub_lvl_idx
|
||||||
$LevelLoader.load_level(sub_lvl_idx)
|
await $LevelLoader.load_level(sub_lvl_idx)
|
||||||
|
if Settings.file.visuals.transition_animation == 0:
|
||||||
Global.do_fake_transition(0.1)
|
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:
|
||||||
|
@@ -5,7 +5,10 @@ extends Node2D
|
|||||||
|
|
||||||
@export_enum("0", "1", "2", "3", "4") var sublevel_id := 0
|
@export_enum("0", "1", "2", "3", "4") var sublevel_id := 0
|
||||||
|
|
||||||
@export var locked := false
|
@export var locked := false:
|
||||||
|
set(value):
|
||||||
|
locked = value
|
||||||
|
pass
|
||||||
@export var start_locked := false
|
@export var start_locked := false
|
||||||
|
|
||||||
signal updated
|
signal updated
|
||||||
@@ -23,6 +26,7 @@ static var same_scene_exiting_door: Door = null
|
|||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
if start_locked:
|
if start_locked:
|
||||||
locked = true
|
locked = true
|
||||||
|
await get_tree().physics_frame
|
||||||
if locked:
|
if locked:
|
||||||
check_if_unlocked(false)
|
check_if_unlocked(false)
|
||||||
|
|
||||||
@@ -42,6 +46,7 @@ func _physics_process(_delta: float) -> void:
|
|||||||
|
|
||||||
func check_if_unlocked(do_animation := true) -> void:
|
func check_if_unlocked(do_animation := true) -> void:
|
||||||
if locked:
|
if locked:
|
||||||
|
print(unlocked_doors)
|
||||||
if unlocked_doors.has(door_id):
|
if unlocked_doors.has(door_id):
|
||||||
locked = false
|
locked = false
|
||||||
$Sprite.play("Idle")
|
$Sprite.play("Idle")
|
||||||
@@ -113,7 +118,6 @@ func player_enter(player: Player) -> void:
|
|||||||
else:
|
else:
|
||||||
same_scene_exiting_door = null
|
same_scene_exiting_door = null
|
||||||
Global.level_editor.transition_to_sublevel(sublevel_id)
|
Global.level_editor.transition_to_sublevel(sublevel_id)
|
||||||
$Sprite.play("Idle")
|
|
||||||
can_enter = true
|
can_enter = true
|
||||||
|
|
||||||
func freeze_player(player: Player) -> void:
|
func freeze_player(player: Player) -> void:
|
||||||
|
@@ -265,6 +265,7 @@ func reset_values() -> void:
|
|||||||
PlayerGhost.idx = 0
|
PlayerGhost.idx = 0
|
||||||
Checkpoint.passed = false
|
Checkpoint.passed = false
|
||||||
Checkpoint.sublevel_id = 0
|
Checkpoint.sublevel_id = 0
|
||||||
|
Door.unlocked_doors = []
|
||||||
Level.start_level_path = Level.get_scene_string(Global.world_num, Global.level_num)
|
Level.start_level_path = Level.get_scene_string(Global.world_num, Global.level_num)
|
||||||
LevelPersistance.reset_states()
|
LevelPersistance.reset_states()
|
||||||
Level.first_load = true
|
Level.first_load = true
|
||||||
|
@@ -8,6 +8,10 @@ static var has_entered := false
|
|||||||
var selected_lvl_idx := 0
|
var selected_lvl_idx := 0
|
||||||
const CUSTOM_LEVEL_PATH := "user://custom_levels/"
|
const CUSTOM_LEVEL_PATH := "user://custom_levels/"
|
||||||
const base64_charset := "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"
|
const base64_charset := "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"
|
||||||
|
static var page_number_save := -1
|
||||||
|
static var last_played_container = null
|
||||||
|
|
||||||
|
static var saved_search_values := [-1, -1, -1]
|
||||||
|
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
has_entered = true
|
has_entered = true
|
||||||
@@ -23,6 +27,28 @@ func _ready() -> void:
|
|||||||
AudioManager.stop_all_music()
|
AudioManager.stop_all_music()
|
||||||
Global.second_quest = false
|
Global.second_quest = false
|
||||||
%LevelList.open(true)
|
%LevelList.open(true)
|
||||||
|
await get_tree().process_frame
|
||||||
|
if last_played_container != null:
|
||||||
|
print(saved_search_values)
|
||||||
|
%LSSBrowser.setup_page_numbers()
|
||||||
|
%LSSBrowser.page_number = saved_search_values[0]
|
||||||
|
%Page.selected_index = saved_search_values[0] - 1
|
||||||
|
|
||||||
|
%LSSBrowser.filter = saved_search_values[1]
|
||||||
|
%Sort.selected_index = saved_search_values[1]
|
||||||
|
|
||||||
|
%LSSBrowser.order = saved_search_values[2]
|
||||||
|
%Order.selected_index = %LSSBrowser.order
|
||||||
|
|
||||||
|
%LSSLevelInfo.open(last_played_container)
|
||||||
|
await get_tree().process_frame
|
||||||
|
%LSSBrowser.grab_levels()
|
||||||
|
%LevelList.close()
|
||||||
|
|
||||||
|
func clear_saved_stuff() -> void:
|
||||||
|
%LSSLevelInfo.saved_stuff.clear()
|
||||||
|
saved_search_values = [-1, -1, -1]
|
||||||
|
%LSSBrowser.number_of_pages = -1
|
||||||
|
|
||||||
func _exit_tree() -> void:
|
func _exit_tree() -> void:
|
||||||
Global.get_node("GameHUD").show()
|
Global.get_node("GameHUD").show()
|
||||||
@@ -38,11 +64,13 @@ func new_level() -> void:
|
|||||||
Global.transition_to_scene("res://Scenes/Levels/LevelEditor.tscn")
|
Global.transition_to_scene("res://Scenes/Levels/LevelEditor.tscn")
|
||||||
|
|
||||||
func back_to_title_screen() -> void:
|
func back_to_title_screen() -> void:
|
||||||
|
clear_saved_stuff()
|
||||||
if Global.transitioning_scene:
|
if Global.transitioning_scene:
|
||||||
await Global.transition_finished
|
await Global.transition_finished
|
||||||
Global.transition_to_scene("res://Scenes/Levels/TitleScreen.tscn")
|
Global.transition_to_scene("res://Scenes/Levels/TitleScreen.tscn")
|
||||||
|
|
||||||
func edit_level() -> void:
|
func edit_level() -> void:
|
||||||
|
clear_saved_stuff()
|
||||||
Global.current_game_mode = Global.GameMode.LEVEL_EDITOR
|
Global.current_game_mode = Global.GameMode.LEVEL_EDITOR
|
||||||
LevelEditor.load_play = false
|
LevelEditor.load_play = false
|
||||||
Global.transition_to_scene("res://Scenes/Levels/LevelEditor.tscn")
|
Global.transition_to_scene("res://Scenes/Levels/LevelEditor.tscn")
|
||||||
@@ -56,6 +84,12 @@ func play_level() -> void:
|
|||||||
LevelTransition.level_to_transition_to = ("res://Scenes/Levels/LevelEditor.tscn")
|
LevelTransition.level_to_transition_to = ("res://Scenes/Levels/LevelEditor.tscn")
|
||||||
Global.transition_to_scene("res://Scenes/Levels/LevelTransition.tscn")
|
Global.transition_to_scene("res://Scenes/Levels/LevelTransition.tscn")
|
||||||
|
|
||||||
|
func lss_level_played() -> void:
|
||||||
|
last_played_container = %LSSLevelInfo.container_to_play.duplicate()
|
||||||
|
page_number_save = %LSSBrowser.page_number
|
||||||
|
saved_search_values[0] = %LSSBrowser.page_number
|
||||||
|
saved_search_values[1] = %LSSBrowser.filter
|
||||||
|
saved_search_values[2] = %LSSBrowser.order
|
||||||
|
|
||||||
func delete_level() -> void:
|
func delete_level() -> void:
|
||||||
DirAccess.remove_absolute(current_level_file)
|
DirAccess.remove_absolute(current_level_file)
|
||||||
|
@@ -14,7 +14,7 @@ signal level_edit
|
|||||||
|
|
||||||
func open(container: CustomLevelContainer = null) -> void:
|
func open(container: CustomLevelContainer = null) -> void:
|
||||||
if container != null:
|
if container != null:
|
||||||
for i in ["level_name", "level_author", "level_theme", "game_style", "level_time", "difficulty"]:
|
for i in ["level_name", "level_author", "level_theme", "game_style", "level_time", "difficulty", "is_downloaded", "level_id", "thumbnail"]:
|
||||||
%SelectedLevel.set(i, container.get(i))
|
%SelectedLevel.set(i, container.get(i))
|
||||||
%SelectedLevel.update_visuals()
|
%SelectedLevel.update_visuals()
|
||||||
LevelEditor.level_name = container.level_name
|
LevelEditor.level_name = container.level_name
|
||||||
|
@@ -13,7 +13,8 @@ const ONLINE_LEVEL_CONTAINER = preload("uid://cr2pku7fjkgpo")
|
|||||||
|
|
||||||
var filter = 0
|
var filter = 0
|
||||||
var selected_lvl_idx := -1
|
var selected_lvl_idx := -1
|
||||||
var sort := -1
|
var order := 0
|
||||||
|
static var number_of_pages := -1
|
||||||
|
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
set_process(false)
|
set_process(false)
|
||||||
@@ -49,7 +50,7 @@ func grab_levels() -> void:
|
|||||||
var filter_str = ["", "", "&sort=plays", "&sort=rating"][filter]
|
var filter_str = ["", "", "&sort=plays", "&sort=rating"][filter]
|
||||||
var get_type = ["featured?", "get?", "get?", "get?"][filter]
|
var get_type = ["featured?", "get?", "get?", "get?"][filter]
|
||||||
var page_str = "&page=" + str(page_number)
|
var page_str = "&page=" + str(page_number)
|
||||||
var url = LSS_URL + "/api/levels/filter/" + get_type + "game=" + str(Global.LSS_GAME_ID) + "&authors=1" + filter_str + page_str + "&sortType=" + str(sort)
|
var url = LSS_URL + "/api/levels/filter/" + get_type + "game=" + str(Global.LSS_GAME_ID) + "&authors=1" + filter_str + page_str + "&sortType=" + str(order)
|
||||||
http_request.request(url, [], HTTPClient.METHOD_GET)
|
http_request.request(url, [], HTTPClient.METHOD_GET)
|
||||||
|
|
||||||
func level_list_retrieved(result := 0, response_code := 0, headers: PackedStringArray = [], body: PackedByteArray = []) -> void:
|
func level_list_retrieved(result := 0, response_code := 0, headers: PackedStringArray = [], body: PackedByteArray = []) -> void:
|
||||||
@@ -63,10 +64,13 @@ func level_list_retrieved(result := 0, response_code := 0, headers: PackedString
|
|||||||
return
|
return
|
||||||
var json = JSON.parse_string(string)
|
var json = JSON.parse_string(string)
|
||||||
list = json
|
list = json
|
||||||
print(list)
|
|
||||||
spawn_containers()
|
spawn_containers()
|
||||||
%Page.values.clear()
|
%Page.values.clear()
|
||||||
for i in json.numberOfPages:
|
number_of_pages = json.numberOfPages
|
||||||
|
setup_page_numbers()
|
||||||
|
|
||||||
|
func setup_page_numbers() -> void:
|
||||||
|
for i in number_of_pages:
|
||||||
%Page.values.append(str(int(i + 1)))
|
%Page.values.append(str(int(i + 1)))
|
||||||
|
|
||||||
func spawn_containers() -> void:
|
func spawn_containers() -> void:
|
||||||
@@ -99,5 +103,5 @@ func set_page(page_idx := 0) -> void:
|
|||||||
grab_levels()
|
grab_levels()
|
||||||
|
|
||||||
func set_order(order_idx := 0) -> void:
|
func set_order(order_idx := 0) -> void:
|
||||||
sort = [-1, 1][order_idx]
|
order = [-1, 1][order_idx]
|
||||||
grab_levels()
|
grab_levels()
|
||||||
|
@@ -12,11 +12,16 @@ signal level_play
|
|||||||
|
|
||||||
var level_thumbnail = null
|
var level_thumbnail = null
|
||||||
|
|
||||||
|
var container_to_play: OnlineLevelContainer = null
|
||||||
|
|
||||||
|
static var saved_stuff := {}
|
||||||
|
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
set_process(false)
|
set_process(false)
|
||||||
|
|
||||||
func open(container: OnlineLevelContainer) -> void:
|
func open(container: OnlineLevelContainer) -> void:
|
||||||
has_downloaded = FileAccess.file_exists("user://custom_levels/downloaded/" + container.level_id + ".lvl")
|
container_to_play = container.duplicate()
|
||||||
|
has_downloaded = FileAccess.file_exists("user://custom_levels/downloaded/" + container.level_id + ".lvl") or saved_stuff.is_empty() == false
|
||||||
show()
|
show()
|
||||||
level_thumbnail = container.level_thumbnail
|
level_thumbnail = container.level_thumbnail
|
||||||
%Download.text = "DOWNLOAD"
|
%Download.text = "DOWNLOAD"
|
||||||
@@ -33,14 +38,18 @@ func setup_visuals(container: OnlineLevelContainer) -> void:
|
|||||||
$Panel/AutoScrollContainer.scroll_pos = 0
|
$Panel/AutoScrollContainer.scroll_pos = 0
|
||||||
$Panel/AutoScrollContainer.move_direction = -1
|
$Panel/AutoScrollContainer.move_direction = -1
|
||||||
%LSSDescription.text = "Fetching Description..."
|
%LSSDescription.text = "Fetching Description..."
|
||||||
%SelectedOnlineLevel.level_name = container.level_name
|
if saved_stuff.is_empty():
|
||||||
%SelectedOnlineLevel.level_author = container.level_author
|
|
||||||
%SelectedOnlineLevel.level_id = container.level_id
|
|
||||||
%SelectedOnlineLevel.thumbnail_url = container.thumbnail_url
|
|
||||||
%SelectedOnlineLevel.level_thumbnail = level_thumbnail
|
|
||||||
%SelectedOnlineLevel.difficulty = container.difficulty
|
|
||||||
%SelectedOnlineLevel.setup_visuals()
|
|
||||||
$Description.request(LEVEL_INFO_URL + container.level_id)
|
$Description.request(LEVEL_INFO_URL + container.level_id)
|
||||||
|
else:
|
||||||
|
%LSSDescription.text = saved_stuff.description
|
||||||
|
for i in ["level_name", "level_author", "level_id", "thumbnail_url", "level_thumbnail", "difficulty"]:
|
||||||
|
var value = null
|
||||||
|
if saved_stuff.has(i):
|
||||||
|
value = saved_stuff[i]
|
||||||
|
else: value = container.get(i)
|
||||||
|
%SelectedOnlineLevel.set(i, value)
|
||||||
|
saved_stuff[i] = value
|
||||||
|
%SelectedOnlineLevel.setup_visuals()
|
||||||
%Download.visible = not has_downloaded
|
%Download.visible = not has_downloaded
|
||||||
%OnlinePlay.visible = has_downloaded
|
%OnlinePlay.visible = has_downloaded
|
||||||
|
|
||||||
@@ -67,6 +76,7 @@ func on_request_completed(result: int, response_code: int, headers: PackedString
|
|||||||
var string = body.get_string_from_utf8()
|
var string = body.get_string_from_utf8()
|
||||||
var json = JSON.parse_string(string)
|
var json = JSON.parse_string(string)
|
||||||
%LSSDescription.text = Global.sanitize_string(json["level"]["description"])
|
%LSSDescription.text = Global.sanitize_string(json["level"]["description"])
|
||||||
|
saved_stuff.description = %LSSDescription.text
|
||||||
|
|
||||||
func level_downloaded(result: int, response_code: int, headers: PackedStringArray, body: PackedByteArray) -> void:
|
func level_downloaded(result: int, response_code: int, headers: PackedStringArray, body: PackedByteArray) -> void:
|
||||||
var string = body.get_string_from_utf8()
|
var string = body.get_string_from_utf8()
|
||||||
|
@@ -37,7 +37,6 @@ func setup_visuals() -> void:
|
|||||||
if featured:
|
if featured:
|
||||||
self_modulate = Color.YELLOW
|
self_modulate = Color.YELLOW
|
||||||
var idx := 0
|
var idx := 0
|
||||||
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 = 32 if idx > difficulty_int else [0, 8, 8, 16, 24][difficulty_int]
|
i.region_rect.position.x = 32 if idx > difficulty_int else [0, 8, 8, 16, 24][difficulty_int]
|
||||||
@@ -72,7 +71,6 @@ func calculate_rating() -> int:
|
|||||||
for i in ratings:
|
for i in ratings:
|
||||||
total += i
|
total += i
|
||||||
rating = total / float(ratings.size())
|
rating = total / float(ratings.size())
|
||||||
print(rating)
|
|
||||||
return 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:
|
||||||
|
Reference in New Issue
Block a user