[macOS] Add methods to modify global and dock menus. Add ability to open multiple editor/project manager instances, recent/favourite project list to project manager dock menu and opened scene list to editor dock menu.
This commit is contained in:
@@ -135,6 +135,8 @@ void EditorNode::_update_scene_tabs() {
|
||||
|
||||
bool show_rb = EditorSettings::get_singleton()->get("interface/scene_tabs/show_script_button");
|
||||
|
||||
OS::get_singleton()->global_menu_clear("_dock");
|
||||
|
||||
scene_tabs->clear_tabs();
|
||||
Ref<Texture> script_icon = gui_base->get_icon("Script", "EditorIcons");
|
||||
for (int i = 0; i < editor_data.get_edited_scene_count(); i++) {
|
||||
@@ -149,11 +151,16 @@ void EditorNode::_update_scene_tabs() {
|
||||
bool unsaved = (i == current) ? saved_version != editor_data.get_undo_redo().get_version() : editor_data.get_scene_version(i) != 0;
|
||||
scene_tabs->add_tab(editor_data.get_scene_title(i) + (unsaved ? "(*)" : ""), icon);
|
||||
|
||||
OS::get_singleton()->global_menu_add_item("_dock", editor_data.get_scene_title(i) + (unsaved ? "(*)" : ""), GLOBAL_SCENE, i);
|
||||
|
||||
if (show_rb && editor_data.get_scene_root_script(i).is_valid()) {
|
||||
scene_tabs->set_tab_right_button(i, script_icon);
|
||||
}
|
||||
}
|
||||
|
||||
OS::get_singleton()->global_menu_add_separator("_dock");
|
||||
OS::get_singleton()->global_menu_add_item("_dock", TTR("New Window"), GLOBAL_NEW_WINDOW, Variant());
|
||||
|
||||
scene_tabs->set_current_tab(editor_data.get_edited_scene());
|
||||
|
||||
if (scene_tabs->get_offset_buttons_visible()) {
|
||||
@@ -290,6 +297,7 @@ 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()->connect("files_dropped", this, "_dropped_files");
|
||||
get_tree()->connect("global_menu_action", this, "_global_menu_action");
|
||||
|
||||
/* DO NOT LOAD SCENES HERE, WAIT FOR FILE SCANNING AND REIMPORT TO COMPLETE */
|
||||
} break;
|
||||
@@ -4941,6 +4949,23 @@ void EditorNode::remove_tool_menu_item(const String &p_name) {
|
||||
}
|
||||
}
|
||||
|
||||
void EditorNode::_global_menu_action(const Variant &p_id, const Variant &p_meta) {
|
||||
|
||||
int id = (int)p_id;
|
||||
if (id == GLOBAL_NEW_WINDOW) {
|
||||
if (OS::get_singleton()->get_main_loop()) {
|
||||
List<String> args;
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
void EditorNode::_dropped_files(const Vector<String> &p_files, int p_screen) {
|
||||
|
||||
String to_path = ProjectSettings::get_singleton()->globalize_path(get_filesystem_dock()->get_selected_path());
|
||||
@@ -5322,6 +5347,7 @@ void EditorNode::_bind_methods() {
|
||||
|
||||
ClassDB::bind_method("_clear_undo_history", &EditorNode::_clear_undo_history);
|
||||
ClassDB::bind_method("_dropped_files", &EditorNode::_dropped_files);
|
||||
ClassDB::bind_method(D_METHOD("_global_menu_action"), &EditorNode::_global_menu_action, DEFVAL(Variant()));
|
||||
ClassDB::bind_method("_toggle_distraction_free_mode", &EditorNode::_toggle_distraction_free_mode);
|
||||
ClassDB::bind_method("edit_item_resource", &EditorNode::edit_item_resource);
|
||||
|
||||
|
||||
@@ -207,6 +207,9 @@ private:
|
||||
|
||||
SET_VIDEO_DRIVER_SAVE_AND_RESTART,
|
||||
|
||||
GLOBAL_NEW_WINDOW,
|
||||
GLOBAL_SCENE,
|
||||
|
||||
IMPORT_PLUGIN_BASE = 100,
|
||||
|
||||
TOOL_MENU_BASE = 1000
|
||||
@@ -504,6 +507,7 @@ 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 _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;
|
||||
|
||||
@@ -946,6 +946,11 @@ public:
|
||||
static const char *SIGNAL_SELECTION_CHANGED;
|
||||
static const char *SIGNAL_PROJECT_ASK_OPEN;
|
||||
|
||||
enum MenuOptions {
|
||||
GLOBAL_NEW_WINDOW,
|
||||
GLOBAL_OPEN_PROJECT
|
||||
};
|
||||
|
||||
// Can often be passed by copy
|
||||
struct Item {
|
||||
String project_key;
|
||||
@@ -1181,6 +1186,7 @@ void ProjectList::load_projects() {
|
||||
_projects.clear();
|
||||
_last_clicked = "";
|
||||
_selected_project_keys.clear();
|
||||
OS::get_singleton()->global_menu_clear("_dock");
|
||||
|
||||
// Load data
|
||||
// TODO Would be nice to change how projects and favourites are stored... it complicates things a bit.
|
||||
@@ -1218,6 +1224,9 @@ void ProjectList::load_projects() {
|
||||
create_project_item_control(i);
|
||||
}
|
||||
|
||||
OS::get_singleton()->global_menu_add_separator("_dock");
|
||||
OS::get_singleton()->global_menu_add_item("_dock", TTR("New Window"), GLOBAL_NEW_WINDOW, Variant());
|
||||
|
||||
sort_projects();
|
||||
|
||||
set_v_scroll(0);
|
||||
@@ -1305,6 +1314,7 @@ void ProjectList::create_project_item_control(int p_index) {
|
||||
fpath->set_clip_text(true);
|
||||
|
||||
_scroll_children->add_child(hb);
|
||||
OS::get_singleton()->global_menu_add_item("_dock", item.project_name + " ( " + item.path + " )", GLOBAL_OPEN_PROJECT, Variant(item.path.plus_file("project.godot")));
|
||||
item.control = hb;
|
||||
}
|
||||
|
||||
@@ -1894,6 +1904,29 @@ 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;
|
||||
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();
|
||||
@@ -2236,6 +2269,7 @@ void ProjectManager::_bind_methods() {
|
||||
|
||||
ClassDB::bind_method("_open_selected_projects_ask", &ProjectManager::_open_selected_projects_ask);
|
||||
ClassDB::bind_method("_open_selected_projects", &ProjectManager::_open_selected_projects);
|
||||
ClassDB::bind_method(D_METHOD("_global_menu_action"), &ProjectManager::_global_menu_action, DEFVAL(Variant()));
|
||||
ClassDB::bind_method("_run_project", &ProjectManager::_run_project);
|
||||
ClassDB::bind_method("_run_project_confirm", &ProjectManager::_run_project_confirm);
|
||||
ClassDB::bind_method("_scan_projects", &ProjectManager::_scan_projects);
|
||||
@@ -2561,6 +2595,7 @@ ProjectManager::ProjectManager() {
|
||||
}
|
||||
|
||||
SceneTree::get_singleton()->connect("files_dropped", this, "_files_dropped");
|
||||
SceneTree::get_singleton()->connect("global_menu_action", this, "_global_menu_action");
|
||||
|
||||
run_error_diag = memnew(AcceptDialog);
|
||||
gui_base->add_child(run_error_diag);
|
||||
|
||||
@@ -43,6 +43,7 @@ class ProjectList;
|
||||
class ProjectListFilter;
|
||||
|
||||
class ProjectManager : public Control {
|
||||
|
||||
GDCLASS(ProjectManager, Control);
|
||||
|
||||
Button *erase_btn;
|
||||
@@ -96,6 +97,7 @@ 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();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user