Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
77 changes: 0 additions & 77 deletions addons/mod_loader/api/mod_manager.gd

This file was deleted.

105 changes: 0 additions & 105 deletions addons/mod_loader/internal/script_extension.gd
Original file line number Diff line number Diff line change
Expand Up @@ -154,108 +154,3 @@ static func _reload_vanilla_child_classes_for(script: Script) -> void:
for child_class in classes:
if child_class.base == _class.get_class():
load(child_class.path).reload()


# Used to remove a specific extension
static func remove_specific_extension_from_script(extension_path: String) -> void:
# Check path to file exists
if not _ModLoaderFile.file_exists(extension_path):
ModLoaderLog.error(
'The extension script path "%s" does not exist' % [extension_path], LOG_NAME
)
return

var extension_script: Script = ResourceLoader.load(extension_path)
var parent_script: Script = extension_script.get_base_script()
var parent_script_path: String = parent_script.resource_path

# Check if the script to reset has been extended
if not ModLoaderStore.saved_scripts.has(parent_script_path):
ModLoaderLog.error(
'The extension parent script path "%s" has not been extended' % [parent_script_path],
LOG_NAME
)
return

# Check if the script to reset has anything actually saved
# If we ever encounter this it means something went very wrong in extending
if not ModLoaderStore.saved_scripts[parent_script_path].size() > 0:
ModLoaderLog.error(
(
'The extension script path "%s" does not have the base script saved, this should never happen, if you encounter this please create an issue in the github repository'
% [parent_script_path]
),
LOG_NAME
)
return

var parent_script_extensions: Array = ModLoaderStore.saved_scripts[parent_script_path].duplicate()
parent_script_extensions.remove_at(0)

# Searching for the extension that we want to remove
var found_script_extension: Script = null
for script_extension in parent_script_extensions:
if script_extension.get_meta("extension_script_path") == extension_path:
found_script_extension = script_extension
break

if found_script_extension == null:
ModLoaderLog.error(
(
'The extension script path "%s" has not been found in the saved extension of the base script'
% [parent_script_path]
),
LOG_NAME
)
return
parent_script_extensions.erase(found_script_extension)

# Preparing the script to have all other extensions reapllied
_remove_all_extensions_from_script(parent_script_path)

# Reapplying all the extensions without the removed one
for script_extension in parent_script_extensions:
apply_extension(script_extension.get_meta("extension_script_path"))


# Used to fully reset the provided script to a state prior of any extension
static func _remove_all_extensions_from_script(parent_script_path: String) -> void:
# Check path to file exists
if not _ModLoaderFile.file_exists(parent_script_path):
ModLoaderLog.error(
'The parent script path "%s" does not exist' % [parent_script_path], LOG_NAME
)
return

# Check if the script to reset has been extended
if not ModLoaderStore.saved_scripts.has(parent_script_path):
ModLoaderLog.error(
'The parent script path "%s" has not been extended' % [parent_script_path], LOG_NAME
)
return

# Check if the script to reset has anything actually saved
# If we ever encounter this it means something went very wrong in extending
if not ModLoaderStore.saved_scripts[parent_script_path].size() > 0:
ModLoaderLog.error(
(
'The parent script path "%s" does not have the base script saved, \nthis should never happen, if you encounter this please create an issue in the github repository'
% [parent_script_path]
),
LOG_NAME
)
return

var parent_script: Script = ModLoaderStore.saved_scripts[parent_script_path][0]
parent_script.take_over_path(parent_script_path)

# Remove the script after it has been reset so we do not do it again
ModLoaderStore.saved_scripts.erase(parent_script_path)


# Used to remove all extensions that are of a specific mod
static func remove_all_extensions_of_mod(mod: ModData) -> void:
var _to_remove_extension_paths: Array = ModLoaderStore.saved_extension_paths[mod.manifest.get_mod_id()]
for extension_path in _to_remove_extension_paths:
remove_specific_extension_from_script(extension_path)
ModLoaderStore.saved_extension_paths.erase(mod.manifest.get_mod_id())
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,6 @@ list=Array[Dictionary]([{
"language": &"GDScript",
"path": "res://addons/mod_loader/api/mod.gd"
}, {
"base": &"RefCounted",
"class": &"ModLoaderModManager",
"icon": "",
"language": &"GDScript",
"path": "res://addons/mod_loader/api/mod_manager.gd"
}, {
"base": &"Resource",
"class": &"ModLoaderOptionsProfile",
"icon": "",
Expand Down