You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-07 12:30:27 +00:00
Use minor version in EditorSettings file name
This commit is contained in:
@@ -989,6 +989,29 @@ EditorSettings *EditorSettings::get_singleton() {
|
|||||||
return singleton.ptr();
|
return singleton.ptr();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String EditorSettings::get_existing_settings_path() {
|
||||||
|
const String config_dir = EditorPaths::get_singleton()->get_config_dir();
|
||||||
|
int minor = VERSION_MINOR;
|
||||||
|
String filename;
|
||||||
|
|
||||||
|
do {
|
||||||
|
if (VERSION_MAJOR == 4 && minor < 3) {
|
||||||
|
// Minor version is used since 4.3, so special case to load older settings.
|
||||||
|
filename = vformat("editor_settings-%d.tres", VERSION_MAJOR);
|
||||||
|
minor = -1;
|
||||||
|
} else {
|
||||||
|
filename = vformat("editor_settings-%d.%d.tres", VERSION_MAJOR, minor);
|
||||||
|
minor--;
|
||||||
|
}
|
||||||
|
} while (minor >= 0 && !FileAccess::exists(config_dir.path_join(filename)));
|
||||||
|
return config_dir.path_join(filename);
|
||||||
|
}
|
||||||
|
|
||||||
|
String EditorSettings::get_newest_settings_path() {
|
||||||
|
const String config_file_name = vformat("editor_settings-%d.%d.tres", VERSION_MAJOR, VERSION_MINOR);
|
||||||
|
return EditorPaths::get_singleton()->get_config_dir().path_join(config_file_name);
|
||||||
|
}
|
||||||
|
|
||||||
void EditorSettings::create() {
|
void EditorSettings::create() {
|
||||||
// IMPORTANT: create() *must* create a valid EditorSettings singleton,
|
// IMPORTANT: create() *must* create a valid EditorSettings singleton,
|
||||||
// as the rest of the engine code will assume it. As such, it should never
|
// as the rest of the engine code will assume it. As such, it should never
|
||||||
@@ -1016,16 +1039,16 @@ void EditorSettings::create() {
|
|||||||
|
|
||||||
if (EditorPaths::get_singleton()->are_paths_valid()) {
|
if (EditorPaths::get_singleton()->are_paths_valid()) {
|
||||||
// Validate editor config file.
|
// Validate editor config file.
|
||||||
Ref<DirAccess> dir = DirAccess::open(EditorPaths::get_singleton()->get_config_dir());
|
ERR_FAIL_COND(!DirAccess::dir_exists_absolute(EditorPaths::get_singleton()->get_config_dir()));
|
||||||
ERR_FAIL_COND(dir.is_null());
|
|
||||||
|
|
||||||
String config_file_name = "editor_settings-" + itos(VERSION_MAJOR) + ".tres";
|
config_file_path = get_existing_settings_path();
|
||||||
config_file_path = EditorPaths::get_singleton()->get_config_dir().path_join(config_file_name);
|
if (!FileAccess::exists(config_file_path)) {
|
||||||
if (!dir->file_exists(config_file_name)) {
|
config_file_path = get_newest_settings_path();
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
singleton = ResourceLoader::load(config_file_path, "EditorSettings");
|
singleton = ResourceLoader::load(config_file_path, "EditorSettings");
|
||||||
|
singleton->set_path(get_newest_settings_path()); // Settings can be loaded from older version file, so make sure it's newest.
|
||||||
|
|
||||||
if (singleton.is_null()) {
|
if (singleton.is_null()) {
|
||||||
ERR_PRINT("Could not load editor settings from path: " + config_file_path);
|
ERR_PRINT("Could not load editor settings from path: " + config_file_path);
|
||||||
|
|||||||
@@ -124,6 +124,8 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
static EditorSettings *get_singleton();
|
static EditorSettings *get_singleton();
|
||||||
|
static String get_existing_settings_path();
|
||||||
|
static String get_newest_settings_path();
|
||||||
|
|
||||||
static void create();
|
static void create();
|
||||||
void setup_language();
|
void setup_language();
|
||||||
|
|||||||
@@ -2518,12 +2518,10 @@ Error Main::setup2() {
|
|||||||
|
|
||||||
// Editor setting class is not available, load config directly.
|
// Editor setting class is not available, load config directly.
|
||||||
if (!init_use_custom_screen && (editor || project_manager) && EditorPaths::get_singleton()->are_paths_valid()) {
|
if (!init_use_custom_screen && (editor || project_manager) && EditorPaths::get_singleton()->are_paths_valid()) {
|
||||||
Ref<DirAccess> dir = DirAccess::open(EditorPaths::get_singleton()->get_config_dir());
|
ERR_FAIL_COND_V(!DirAccess::dir_exists_absolute(EditorPaths::get_singleton()->get_config_dir()), FAILED);
|
||||||
ERR_FAIL_COND_V(dir.is_null(), FAILED);
|
|
||||||
|
|
||||||
String config_file_name = "editor_settings-" + itos(VERSION_MAJOR) + ".tres";
|
String config_file_path = EditorSettings::get_existing_settings_path();
|
||||||
String config_file_path = EditorPaths::get_singleton()->get_config_dir().path_join(config_file_name);
|
if (FileAccess::exists(config_file_path)) {
|
||||||
if (dir->file_exists(config_file_name)) {
|
|
||||||
Error err;
|
Error err;
|
||||||
Ref<FileAccess> f = FileAccess::open(config_file_path, FileAccess::READ, &err);
|
Ref<FileAccess> f = FileAccess::open(config_file_path, FileAccess::READ, &err);
|
||||||
if (f.is_valid()) {
|
if (f.is_valid()) {
|
||||||
|
|||||||
Reference in New Issue
Block a user