mirror of
https://github.com/JHDev2006/Super-Mario-Bros.-Remastered-Public.git
synced 2025-10-22 07:28:14 +00:00
fixed a bug where you couldnt have two config resource packs loaded at once
This commit is contained in:
@@ -28,6 +28,8 @@ var is_random := false
|
|||||||
|
|
||||||
signal updated
|
signal updated
|
||||||
|
|
||||||
|
var current_resource_pack := ""
|
||||||
|
|
||||||
@export var force_properties := {}
|
@export var force_properties := {}
|
||||||
var update_on_spawn := true
|
var update_on_spawn := true
|
||||||
|
|
||||||
@@ -70,8 +72,12 @@ func get_resource(json_file: JSON) -> Resource:
|
|||||||
var resource: Resource = null
|
var resource: Resource = null
|
||||||
var resource_path = json_file.resource_path
|
var resource_path = json_file.resource_path
|
||||||
config_to_use = {}
|
config_to_use = {}
|
||||||
|
current_resource_pack = ""
|
||||||
for i in Settings.file.visuals.resource_packs:
|
for i in Settings.file.visuals.resource_packs:
|
||||||
resource_path = get_resource_pack_path(resource_path, i)
|
var new_path = get_resource_pack_path(resource_path, i)
|
||||||
|
if resource_path != new_path or current_resource_pack == "":
|
||||||
|
current_resource_pack = i
|
||||||
|
resource_path = new_path
|
||||||
|
|
||||||
var source_json = JSON.parse_string(FileAccess.open(resource_path, FileAccess.READ).get_as_text())
|
var source_json = JSON.parse_string(FileAccess.open(resource_path, FileAccess.READ).get_as_text())
|
||||||
if source_json == null:
|
if source_json == null:
|
||||||
@@ -85,7 +91,6 @@ func get_resource(json_file: JSON) -> Resource:
|
|||||||
if json.get("source") is String:
|
if json.get("source") is String:
|
||||||
source_resource_path = json_file.resource_path.replace(json_file.resource_path.get_file(), json.source)
|
source_resource_path = json_file.resource_path.replace(json_file.resource_path.get_file(), json.source)
|
||||||
else:
|
else:
|
||||||
print(json)
|
|
||||||
Global.log_error("Error getting variations! " + resource_path)
|
Global.log_error("Error getting variations! " + resource_path)
|
||||||
return
|
return
|
||||||
for i in Settings.file.visuals.resource_packs:
|
for i in Settings.file.visuals.resource_packs:
|
||||||
@@ -136,7 +141,6 @@ func get_resource(json_file: JSON) -> Resource:
|
|||||||
var idx := 0
|
var idx := 0
|
||||||
for i in json.get("source"):
|
for i in json.get("source"):
|
||||||
var frame_path = ResourceSetter.get_pure_resource_path(json_file.resource_path.replace(json_file.resource_path.get_file(), i))
|
var frame_path = ResourceSetter.get_pure_resource_path(json_file.resource_path.replace(json_file.resource_path.get_file(), i))
|
||||||
print(frame_path)
|
|
||||||
resource.set_frame_texture(idx, load_image_from_path(frame_path))
|
resource.set_frame_texture(idx, load_image_from_path(frame_path))
|
||||||
idx += 1
|
idx += 1
|
||||||
else:
|
else:
|
||||||
@@ -172,6 +176,7 @@ func get_variation_json(json := {}) -> Dictionary:
|
|||||||
level_theme = force_properties.Theme
|
level_theme = force_properties.Theme
|
||||||
|
|
||||||
for i in json.keys().filter(func(key): return key.contains("config:")):
|
for i in json.keys().filter(func(key): return key.contains("config:")):
|
||||||
|
get_config_file(current_resource_pack)
|
||||||
if config_to_use != {}:
|
if config_to_use != {}:
|
||||||
var option_name = i.get_slice(":", 1)
|
var option_name = i.get_slice(":", 1)
|
||||||
if config_to_use.options.has(option_name):
|
if config_to_use.options.has(option_name):
|
||||||
@@ -261,15 +266,19 @@ func get_variation_json(json := {}) -> Dictionary:
|
|||||||
|
|
||||||
return json
|
return json
|
||||||
|
|
||||||
|
func get_config_file(resource_pack := "") -> void:
|
||||||
|
if FileAccess.file_exists("user://resource_packs/" + resource_pack + "/config.json"):
|
||||||
|
config_to_use = JSON.parse_string(FileAccess.open("user://resource_packs/" + resource_pack + "/config.json", FileAccess.READ).get_as_text())
|
||||||
|
if config_to_use == null:
|
||||||
|
Global.log_error("Error parsing Config File! (" + resource_pack + ")")
|
||||||
|
config_to_use = {}
|
||||||
|
else:
|
||||||
|
print("resource pack to use: " + resource_pack)
|
||||||
|
|
||||||
func get_resource_pack_path(res_path := "", resource_pack := "") -> String:
|
func get_resource_pack_path(res_path := "", resource_pack := "") -> String:
|
||||||
var user_path := res_path.replace("res://Assets", "user://resource_packs/" + resource_pack)
|
var user_path := res_path.replace("res://Assets", "user://resource_packs/" + resource_pack)
|
||||||
user_path = user_path.replace("user://custom_characters/", "user://resource_packs/" + resource_pack + "/Sprites/Players/CustomCharacters/")
|
user_path = user_path.replace("user://custom_characters/", "user://resource_packs/" + resource_pack + "/Sprites/Players/CustomCharacters/")
|
||||||
if FileAccess.file_exists(user_path):
|
if FileAccess.file_exists(user_path):
|
||||||
if FileAccess.file_exists("user://resource_packs/" + resource_pack + "/config.json"):
|
|
||||||
config_to_use = JSON.parse_string(FileAccess.open("user://resource_packs/" + resource_pack + "/config.json", FileAccess.READ).get_as_text())
|
|
||||||
if config_to_use == null:
|
|
||||||
Global.log_error("Error parsing Config File! (" + resource_pack + ")")
|
|
||||||
config_to_use = {}
|
|
||||||
return user_path
|
return user_path
|
||||||
else:
|
else:
|
||||||
return res_path
|
return res_path
|
||||||
|
Reference in New Issue
Block a user