diff options
Diffstat (limited to 'editor')
-rw-r--r-- | editor/editor_node.cpp | 34 | ||||
-rw-r--r-- | editor/editor_node.h | 3 | ||||
-rw-r--r-- | editor/editor_run.cpp | 4 | ||||
-rw-r--r-- | editor/project_manager.cpp | 59 | ||||
-rw-r--r-- | editor/project_manager.h | 1 |
5 files changed, 55 insertions, 46 deletions
diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index 2cc6bad2a9..86d4b76ee2 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -199,7 +199,7 @@ void EditorNode::_update_scene_tabs() { scene_tabs->add_tab(editor_data.get_scene_title(i) + (unsaved ? "(*)" : ""), icon); if (DisplayServer::get_singleton()->has_feature(DisplayServer::FEATURE_GLOBAL_MENU)) { - DisplayServer::get_singleton()->global_menu_add_item("_dock", editor_data.get_scene_title(i) + (unsaved ? "(*)" : ""), GLOBAL_SCENE, i); + DisplayServer::get_singleton()->global_menu_add_item("_dock", editor_data.get_scene_title(i) + (unsaved ? "(*)" : ""), callable_mp(this, &EditorNode::_global_menu_scene), i); } if (show_rb && editor_data.get_scene_root_script(i).is_valid()) { @@ -209,7 +209,7 @@ void EditorNode::_update_scene_tabs() { if (DisplayServer::get_singleton()->has_feature(DisplayServer::FEATURE_GLOBAL_MENU)) { DisplayServer::get_singleton()->global_menu_add_separator("_dock"); - DisplayServer::get_singleton()->global_menu_add_item("_dock", TTR("New Window"), GLOBAL_NEW_WINDOW, Variant()); + DisplayServer::get_singleton()->global_menu_add_item("_dock", TTR("New Window"), callable_mp(this, &EditorNode::_global_menu_new_window)); } scene_tabs->set_current_tab(editor_data.get_edited_scene()); @@ -378,7 +378,6 @@ void EditorNode::_notification(int p_what) { get_tree()->get_root()->set_as_audio_listener_2d(false); get_tree()->set_auto_accept_quit(false); get_tree()->get_root()->connect("files_dropped", callable_mp(this, &EditorNode::_dropped_files)); - get_tree()->connect("global_menu_action", callable_mp(this, &EditorNode::_global_menu_action)); /* DO NOT LOAD SCENES HERE, WAIT FOR FILE SCANNING AND REIMPORT TO COMPLETE */ } break; @@ -5105,21 +5104,19 @@ void EditorNode::remove_tool_menu_item(const String &p_name) { } } -void EditorNode::_global_menu_action(const Variant &p_id, const Variant &p_meta) { +void EditorNode::_global_menu_scene(const Variant &p_tag) { + int idx = (int)p_tag; + scene_tabs->set_current_tab(idx); +} - int id = (int)p_id; - if (id == GLOBAL_NEW_WINDOW) { - if (OS::get_singleton()->get_main_loop()) { - List<String> args; - args.push_back("-e"); - String exec = OS::get_singleton()->get_executable_path(); +void EditorNode::_global_menu_new_window(const Variant &p_tag) { + if (OS::get_singleton()->get_main_loop()) { + List<String> args; + args.push_back("-p"); + String exec = OS::get_singleton()->get_executable_path(); - OS::ProcessID pid = 0; - OS::get_singleton()->execute(exec, args, false, &pid); - } - } else if (id == GLOBAL_SCENE) { - int idx = (int)p_meta; - scene_tabs->set_current_tab(idx); + OS::ProcessID pid = 0; + OS::get_singleton()->execute(exec, args, false, &pid); } } @@ -5439,6 +5436,7 @@ void EditorNode::_bind_methods() { ClassDB::bind_method("_update_recent_scenes", &EditorNode::_update_recent_scenes); ClassDB::bind_method("_clear_undo_history", &EditorNode::_clear_undo_history); + ClassDB::bind_method("edit_item_resource", &EditorNode::edit_item_resource); ClassDB::bind_method(D_METHOD("get_gui_base"), &EditorNode::get_gui_base); @@ -5590,7 +5588,11 @@ EditorNode::EditorNode() { case 0: { // Try applying a suitable display scale automatically const int screen = DisplayServer::get_singleton()->window_get_current_screen(); +#ifdef OSX_ENABLED + editor_set_scale(DisplayServer::get_singleton()->screen_get_scale(screen)); +#else editor_set_scale(DisplayServer::get_singleton()->screen_get_dpi(screen) >= 192 && DisplayServer::get_singleton()->screen_get_size(screen).x > 2000 ? 2.0 : 1.0); +#endif } break; case 1: { diff --git a/editor/editor_node.h b/editor/editor_node.h index 88ebf4d475..21025f2a50 100644 --- a/editor/editor_node.h +++ b/editor/editor_node.h @@ -498,7 +498,8 @@ private: void _add_to_recent_scenes(const String &p_scene); void _update_recent_scenes(); void _open_recent_scene(int p_idx); - void _global_menu_action(const Variant &p_id, const Variant &p_meta); + void _global_menu_scene(const Variant &p_tag); + void _global_menu_new_window(const Variant &p_tag); void _dropped_files(const Vector<String> &p_files, int p_screen); void _add_dropped_files_recursive(const Vector<String> &p_files, String to_path); String _recent_scene; diff --git a/editor/editor_run.cpp b/editor/editor_run.cpp index 28eff94f36..b4ddb7ebfa 100644 --- a/editor/editor_run.cpp +++ b/editor/editor_run.cpp @@ -121,7 +121,9 @@ Error EditorRun::run(const String &p_scene, const String &p_custom_args, const L case 1: { // centered int display_scale = 1; #ifdef OSX_ENABLED - if (OS::get_singleton()->get_screen_dpi(screen) >= 192 && OS::get_singleton()->get_screen_size(screen).x > 2000) { + display_scale = DisplayServer::get_singleton()->screen_get_scale(screen); +#else + if (DisplayServer::get_singleton()->screen_get_dpi(screen) >= 192 && DisplayServer::get_singleton()->screen_get_size(screen).x > 2000) { display_scale = 2; } #endif diff --git a/editor/project_manager.cpp b/editor/project_manager.cpp index b4e4ed73f2..d3856cf778 100644 --- a/editor/project_manager.cpp +++ b/editor/project_manager.cpp @@ -1047,6 +1047,9 @@ public: ProjectList(); ~ProjectList(); + void _global_menu_new_window(const Variant &p_tag); + void _global_menu_open_project(const Variant &p_tag); + void update_dock_menu(); void load_projects(); void set_search_term(String p_search_term); @@ -1304,14 +1307,37 @@ void ProjectList::update_dock_menu() { } favs_added = 0; } - DisplayServer::get_singleton()->global_menu_add_item("_dock", _projects[i].project_name + " ( " + _projects[i].path + " )", GLOBAL_OPEN_PROJECT, Variant(_projects[i].path.plus_file("project.godot"))); + DisplayServer::get_singleton()->global_menu_add_item("_dock", _projects[i].project_name + " ( " + _projects[i].path + " )", callable_mp(this, &ProjectList::_global_menu_open_project), i); total_added++; } } if (total_added != 0) { DisplayServer::get_singleton()->global_menu_add_separator("_dock"); } - DisplayServer::get_singleton()->global_menu_add_item("_dock", TTR("New Window"), GLOBAL_NEW_WINDOW, Variant()); + DisplayServer::get_singleton()->global_menu_add_item("_dock", TTR("New Window"), callable_mp(this, &ProjectList::_global_menu_new_window)); +} + +void ProjectList::_global_menu_new_window(const Variant &p_tag) { + List<String> args; + args.push_back("-p"); + String exec = OS::get_singleton()->get_executable_path(); + + OS::ProcessID pid = 0; + OS::get_singleton()->execute(exec, args, false, &pid); +} + +void ProjectList::_global_menu_open_project(const Variant &p_tag) { + int idx = (int)p_tag; + + if (idx >= 0 && idx < _projects.size()) { + String conf = _projects[idx].path.plus_file("project.godot"); + List<String> args; + args.push_back(conf); + String exec = OS::get_singleton()->get_executable_path(); + + OS::ProcessID pid = 0; + OS::get_singleton()->execute(exec, args, false, &pid); + } } void ProjectList::create_project_item_control(int p_index) { @@ -2024,30 +2050,6 @@ void ProjectManager::_confirm_update_settings() { _open_selected_projects(); } -void ProjectManager::_global_menu_action(const Variant &p_id, const Variant &p_meta) { - - int id = (int)p_id; - if (id == ProjectList::GLOBAL_NEW_WINDOW) { - List<String> args; - args.push_back("-p"); - String exec = OS::get_singleton()->get_executable_path(); - - OS::ProcessID pid = 0; - OS::get_singleton()->execute(exec, args, false, &pid); - } else if (id == ProjectList::GLOBAL_OPEN_PROJECT) { - String conf = (String)p_meta; - - if (conf != String()) { - List<String> args; - args.push_back(conf); - String exec = OS::get_singleton()->get_executable_path(); - - OS::ProcessID pid = 0; - OS::get_singleton()->execute(exec, args, false, &pid); - } - } -} - void ProjectManager::_open_selected_projects() { const Set<String> &selected_list = _project_list->get_selected_project_keys(); @@ -2420,7 +2422,11 @@ ProjectManager::ProjectManager() { case 0: { // Try applying a suitable display scale automatically const int screen = DisplayServer::get_singleton()->window_get_current_screen(); +#ifdef OSX_ENABLED + editor_set_scale(DisplayServer::get_singleton()->screen_get_scale(screen)); +#else editor_set_scale(DisplayServer::get_singleton()->screen_get_dpi(screen) >= 192 && DisplayServer::get_singleton()->screen_get_size(screen).x > 2000 ? 2.0 : 1.0); +#endif } break; case 1: editor_set_scale(0.75); break; @@ -2696,7 +2702,6 @@ ProjectManager::ProjectManager() { } SceneTree::get_singleton()->get_root()->connect("files_dropped", callable_mp(this, &ProjectManager::_files_dropped)); - SceneTree::get_singleton()->connect("global_menu_action", callable_mp(this, &ProjectManager::_global_menu_action)); run_error_diag = memnew(AcceptDialog); gui_base->add_child(run_error_diag); diff --git a/editor/project_manager.h b/editor/project_manager.h index 8b9c769c59..6385000821 100644 --- a/editor/project_manager.h +++ b/editor/project_manager.h @@ -97,7 +97,6 @@ class ProjectManager : public Control { void _restart_confirm(); void _exit_dialog(); void _scan_begin(const String &p_base); - void _global_menu_action(const Variant &p_id, const Variant &p_meta); void _confirm_update_settings(); |