summaryrefslogtreecommitdiffstats
path: root/main
diff options
context:
space:
mode:
authorbruvzg <7645683+bruvzg@users.noreply.github.com>2023-03-21 13:08:46 +0200
committerbruvzg <7645683+bruvzg@users.noreply.github.com>2023-04-19 08:54:53 +0300
commit520a8d8ed2f8161c94ff9d32608212faef34df14 (patch)
treea23b4f08b9c61f89ee54da647b331fcb186077d1 /main
parent1b4b8934e080ec5300c78547527517f4a5b733e9 (diff)
downloadredot-engine-520a8d8ed2f8161c94ff9d32608212faef34df14.tar.gz
Add project manager / editor initial screen settings, implement DisplayServer.get_keyboard_focus_screen method.
Diffstat (limited to 'main')
-rw-r--r--main/main.cpp47
1 files changed, 47 insertions, 0 deletions
diff --git a/main/main.cpp b/main/main.cpp
index 3619815825..bc309219f4 100644
--- a/main/main.cpp
+++ b/main/main.cpp
@@ -1969,6 +1969,53 @@ Error Main::setup2(Thread::ID p_main_tid_override) {
#ifdef TOOLS_ENABLED
if (editor || project_manager || cmdline_tool) {
EditorPaths::create();
+
+ // Editor setting class is not available, load config directly.
+ 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());
+ String config_file_name = "editor_settings-" + itos(VERSION_MAJOR) + ".tres";
+ String config_file_path = EditorPaths::get_singleton()->get_config_dir().path_join(config_file_name);
+ if (dir->file_exists(config_file_name)) {
+ Error err;
+ Ref<FileAccess> f = FileAccess::open(config_file_path, FileAccess::READ, &err);
+ if (f.is_valid()) {
+ VariantParser::StreamFile stream;
+ stream.f = f;
+
+ String assign;
+ Variant value;
+ VariantParser::Tag next_tag;
+
+ int lines = 0;
+ String error_text;
+
+ while (true) {
+ assign = Variant();
+ next_tag.fields.clear();
+ next_tag.name = String();
+
+ err = VariantParser::parse_tag_assign_eof(&stream, lines, error_text, next_tag, assign, value, nullptr, true);
+ if (err == ERR_FILE_EOF) {
+ break;
+ }
+ if (err == OK && !assign.is_empty()) {
+ if (project_manager) {
+ if (assign == "interface/editor/project_manager_screen") {
+ init_screen = value;
+ break;
+ }
+ } else if (editor) {
+ if (assign == "interface/editor/editor_screen") {
+ init_screen = value;
+ break;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
if (found_project && EditorPaths::get_singleton()->is_self_contained()) {
if (ProjectSettings::get_singleton()->get_resource_path() == OS::get_singleton()->get_executable_path().get_base_dir()) {
ERR_PRINT("You are trying to run a self-contained editor at the same location as a project. This is not allowed, since editor files will mix with project files.");