mirror of
https://github.com/JHDev2006/Super-Mario-Bros.-Remastered-Public.git
synced 2025-10-22 15:38:14 +00:00
Add true portable mode (#259)
This commit is contained in:
@@ -26,7 +26,7 @@ func get_resource(resource: Resource) -> Resource:
|
||||
|
||||
if original_resource is Texture:
|
||||
var new_resource = null
|
||||
if path.contains("user://"):
|
||||
if path.contains(Global.config_path):
|
||||
new_resource = ImageTexture.create_from_image(Image.load_from_file(path))
|
||||
else:
|
||||
new_resource = load(path)
|
||||
@@ -64,7 +64,7 @@ func send_to_cache(resource_path := "", resource_to_cache: Resource = null) -> v
|
||||
|
||||
func get_resource_path(resource_path := "") -> String:
|
||||
for i in Settings.file.visuals.resource_packs:
|
||||
var test = resource_path.replace("res://Assets/", "user://resource_packs/" + i + "/")
|
||||
var test = resource_path.replace("res://Assets/", Global.config_path.path_join("resource_packs/" + i + "/"))
|
||||
if FileAccess.file_exists(test):
|
||||
return test
|
||||
return resource_path
|
||||
|
@@ -134,13 +134,13 @@ static func get_pure_resource_path(resource_path := "") -> String:
|
||||
if Settings.file.visuals.resource_packs.is_empty() == false:
|
||||
for i in Settings.file.visuals.resource_packs:
|
||||
var new_path = get_override_resource_path(resource_path, i)
|
||||
new_path = new_path.replace("user://custom_characters/", "user://resource_packs/" + new_path + "/Sprites/Players/CustomCharacters/")
|
||||
new_path = new_path.replace(Global.config_path.path_join("custom_characters"), Global.config_path.path_join("resource_packs/" + new_path + "/Sprites/Players/CustomCharacters/"))
|
||||
if FileAccess.file_exists(new_path):
|
||||
return new_path
|
||||
return resource_path
|
||||
|
||||
static func get_override_resource_path(resource_path := "", resource_pack := "") -> String:
|
||||
if resource_pack != "":
|
||||
return resource_path.replace("res://Assets", "user://resource_packs/" + resource_pack)
|
||||
return resource_path.replace("res://Assets", Global.config_path.path_join("resource_packs/" + resource_pack))
|
||||
else:
|
||||
return resource_path
|
||||
|
@@ -276,8 +276,8 @@ func get_config_file(resource_pack := "") -> void:
|
||||
print("resource pack to use: " + resource_pack)
|
||||
|
||||
func get_resource_pack_path(res_path := "", resource_pack := "") -> String:
|
||||
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/")
|
||||
var user_path := res_path.replace("res://Assets", Global.config_path.path_join("resource_packs/" + resource_pack))
|
||||
user_path = user_path.replace(Global.config_path.path_join("custom_characters"), Global.config_path.path_join("resource_packs/" + resource_pack + "/Sprites/Players/CustomCharacters/"))
|
||||
if FileAccess.file_exists(user_path):
|
||||
return user_path
|
||||
else:
|
||||
|
Reference in New Issue
Block a user