mirror of
https://github.com/JHDev2006/Super-Mario-Bros.-Remastered-Public.git
synced 2025-10-22 07:28:14 +00:00
Add true portable mode (#259)
This commit is contained in:
@@ -6,10 +6,20 @@ extends Object
|
||||
|
||||
|
||||
# Path to the latest log file.
|
||||
const MOD_LOG_PATH := "user://logs/modloader.log"
|
||||
static var MOD_LOG_PATH = get_log_path()
|
||||
|
||||
const _LOG_NAME := "ModLoader:Log"
|
||||
|
||||
static func get_log_path() -> String:
|
||||
var exe_dir = OS.get_executable_path().get_base_dir()
|
||||
var portable_flag = exe_dir.path_join("portable.txt")
|
||||
if FileAccess.file_exists(portable_flag):
|
||||
var log_dir = exe_dir.path_join("config/logs")
|
||||
DirAccess.make_dir_recursive_absolute(log_dir)
|
||||
return log_dir.path_join("modloader.log")
|
||||
else:
|
||||
return "user://logs/modloader.log"
|
||||
|
||||
## Denotes the severity of a log entry
|
||||
enum VERBOSITY_LEVEL {
|
||||
ERROR, ## For errors and fatal errors
|
||||
|
@@ -7,8 +7,15 @@ extends Object
|
||||
const LOG_NAME := "ModLoader:UserProfile"
|
||||
|
||||
# The path where the Mod User Profiles data is stored.
|
||||
const FILE_PATH_USER_PROFILES := "user://mod_user_profiles.json"
|
||||
static var FILE_PATH_USER_PROFILES := get_profiles_path()
|
||||
|
||||
static func get_profiles_path() -> String:
|
||||
var exe_dir = OS.get_executable_path().get_base_dir()
|
||||
var portable_flag = exe_dir.path_join("portable.txt")
|
||||
if FileAccess.file_exists(portable_flag):
|
||||
return exe_dir.path_join("config/mod_user_profiles.json")
|
||||
else:
|
||||
return "user://mod_user_profiles.json"
|
||||
|
||||
# API profile functions
|
||||
# =============================================================================
|
||||
|
@@ -4,9 +4,16 @@ extends RefCounted
|
||||
|
||||
# This Class provides methods for caching data.
|
||||
|
||||
const CACHE_FILE_PATH = "user://mod_loader_cache.json"
|
||||
static var CACHE_FILE_PATH = get_cache_path()
|
||||
const LOG_NAME = "ModLoader:Cache"
|
||||
|
||||
static func get_cache_path() -> String:
|
||||
var exe_dir = OS.get_executable_path().get_base_dir()
|
||||
var portable_flag = exe_dir.path_join("portable.txt")
|
||||
if FileAccess.file_exists(portable_flag):
|
||||
return exe_dir.path_join("config/mod_loader_cache.json")
|
||||
else:
|
||||
return "user://mod_loader_cache.json"
|
||||
|
||||
# ModLoaderStore is passed as parameter so the cache data can be loaded on ModLoaderStore._init()
|
||||
static func init_cache(_ModLoaderStore) -> void:
|
||||
|
@@ -6,9 +6,24 @@ extends RefCounted
|
||||
# Currently all of the included functions are internal and should only be used by the mod loader itself.
|
||||
|
||||
const LOG_NAME := "ModLoader:Path"
|
||||
const MOD_CONFIG_DIR_PATH := "user://mod_configs"
|
||||
const MOD_CONFIG_DIR_PATH_OLD := "user://configs"
|
||||
static var MOD_CONFIG_DIR_PATH : String = get_modconfigs_path()
|
||||
static var MOD_CONFIG_DIR_PATH_OLD : String = get_modconfigs_path_old()
|
||||
|
||||
static func get_modconfigs_path() -> String:
|
||||
var exe_dir = OS.get_executable_path().get_base_dir()
|
||||
var portable_flag = exe_dir.path_join("portable.txt")
|
||||
if FileAccess.file_exists(portable_flag):
|
||||
return exe_dir.path_join("config/mod_configs")
|
||||
else:
|
||||
return "user://configs"
|
||||
|
||||
static func get_modconfigs_path_old() -> String:
|
||||
var exe_dir = OS.get_executable_path().get_base_dir()
|
||||
var portable_flag = exe_dir.path_join("portable.txt")
|
||||
if FileAccess.file_exists(portable_flag):
|
||||
return exe_dir.path_join("config/configs")
|
||||
else:
|
||||
return "user://configs"
|
||||
|
||||
# Get the path to a local folder. Primarily used to get the (packed) mods
|
||||
# folder, ie "res://mods" or the OS's equivalent, as well as the configs path
|
||||
|
@@ -3,7 +3,7 @@ class_name ModLoaderSetupLog
|
||||
|
||||
# Slimed down version of ModLoaderLog for the ModLoader Self Setup
|
||||
|
||||
const MOD_LOG_PATH := "user://logs/modloader.log"
|
||||
static var MOD_LOG_PATH := Global.config_path.path_join("logs/modloader.log")
|
||||
|
||||
enum VERBOSITY_LEVEL {
|
||||
ERROR,
|
||||
|
@@ -5,8 +5,7 @@ extends Node
|
||||
|
||||
# Global store for all Data the ModTool requires.
|
||||
|
||||
|
||||
const PATH_SAVE_FILE := "user://mod-tool-plugin-save.json"
|
||||
static var PATH_SAVE_FILE := Global.config_path.path_join("mod-tool-plugin-save.json")
|
||||
const PATH_TEMPLATES_DIR := "res://addons/mod_tool/templates/"
|
||||
|
||||
var editor_plugin: EditorPlugin
|
||||
@@ -96,7 +95,7 @@ func init(store: Dictionary) -> void:
|
||||
|
||||
func update_paths(new_name_mod_dir: String) -> void:
|
||||
path_mod_dir = "res://mods-unpacked/" + new_name_mod_dir
|
||||
path_temp_dir = "user://temp/" + new_name_mod_dir
|
||||
path_temp_dir = Global.config_path.path_join("temp/" + new_name_mod_dir)
|
||||
path_global_temp_dir = ProjectSettings.globalize_path(path_temp_dir)
|
||||
path_manifest = path_mod_dir + "/manifest.json"
|
||||
path_global_final_zip = "%s/%s.zip" % [path_global_export_dir, name_mod_dir]
|
||||
|
Reference in New Issue
Block a user