Merge pull request #15525 from YeldhamDev/recent_scenes_changes
Small changes to the "Recent Scenes" menu
This commit is contained in:
commit
6e4106ace6
1 changed files with 22 additions and 31 deletions
|
@ -339,7 +339,7 @@ void EditorNode::_notification(int p_what) {
|
||||||
if (ScriptEditor::get_singleton()->get_debugger()->is_visible())
|
if (ScriptEditor::get_singleton()->get_debugger()->is_visible())
|
||||||
bottom_panel->add_style_override("panel", gui_base->get_stylebox("BottomPanelDebuggerOverride", "EditorStyles"));
|
bottom_panel->add_style_override("panel", gui_base->get_stylebox("BottomPanelDebuggerOverride", "EditorStyles"));
|
||||||
|
|
||||||
//_update_icons
|
// update_icons
|
||||||
for (int i = 0; i < singleton->main_editor_buttons.size(); i++) {
|
for (int i = 0; i < singleton->main_editor_buttons.size(); i++) {
|
||||||
Ref<Texture> icon = singleton->main_editor_buttons[i]->get_icon();
|
Ref<Texture> icon = singleton->main_editor_buttons[i]->get_icon();
|
||||||
|
|
||||||
|
@ -709,7 +709,7 @@ void EditorNode::_dialog_display_load_error(String p_file, Error p_error) {
|
||||||
|
|
||||||
case ERR_CANT_OPEN: {
|
case ERR_CANT_OPEN: {
|
||||||
|
|
||||||
accept->set_text(vformat(TTR("Can't open '%s'."), p_file.get_file()));
|
accept->set_text(vformat(TTR("Can't open '%s'. The file could have been moved or deleted."), p_file.get_file()));
|
||||||
} break;
|
} break;
|
||||||
case ERR_PARSE_ERROR: {
|
case ERR_PARSE_ERROR: {
|
||||||
|
|
||||||
|
@ -1110,7 +1110,7 @@ void EditorNode::_dialog_action(String p_file) {
|
||||||
if (res.is_null()) {
|
if (res.is_null()) {
|
||||||
|
|
||||||
current_option = -1;
|
current_option = -1;
|
||||||
accept->get_ok()->set_text("ok :(");
|
accept->get_ok()->set_text("Ugh");
|
||||||
accept->set_text(TTR("Failed to load resource."));
|
accept->set_text(TTR("Failed to load resource."));
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
|
@ -1145,6 +1145,7 @@ void EditorNode::_dialog_action(String p_file) {
|
||||||
|
|
||||||
_save_default_environment();
|
_save_default_environment();
|
||||||
_save_scene_with_preview(p_file, scene_idx);
|
_save_scene_with_preview(p_file, scene_idx);
|
||||||
|
_add_to_recent_scenes(p_file);
|
||||||
|
|
||||||
if (scene_idx != -1)
|
if (scene_idx != -1)
|
||||||
_discard_changes();
|
_discard_changes();
|
||||||
|
@ -1919,7 +1920,6 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) {
|
||||||
if (!scene) {
|
if (!scene) {
|
||||||
|
|
||||||
current_option = -1;
|
current_option = -1;
|
||||||
//confirmation->get_cancel()->hide();
|
|
||||||
accept->get_ok()->set_text(TTR("I see.."));
|
accept->get_ok()->set_text(TTR("I see.."));
|
||||||
accept->set_text(TTR("This operation can't be done without a tree root."));
|
accept->set_text(TTR("This operation can't be done without a tree root."));
|
||||||
accept->popup_centered_minsize();
|
accept->popup_centered_minsize();
|
||||||
|
@ -1937,7 +1937,6 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) {
|
||||||
file->add_filter("*." + extensions[i] + " ; " + extensions[i].to_upper());
|
file->add_filter("*." + extensions[i] + " ; " + extensions[i].to_upper());
|
||||||
}
|
}
|
||||||
|
|
||||||
//file->set_current_path(current_path);
|
|
||||||
if (scene->get_filename() != "") {
|
if (scene->get_filename() != "") {
|
||||||
file->set_current_path(scene->get_filename());
|
file->set_current_path(scene->get_filename());
|
||||||
if (extensions.size()) {
|
if (extensions.size()) {
|
||||||
|
@ -1987,7 +1986,6 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) {
|
||||||
if (!editor_data.get_edited_scene_root()) {
|
if (!editor_data.get_edited_scene_root()) {
|
||||||
|
|
||||||
current_option = -1;
|
current_option = -1;
|
||||||
//confirmation->get_cancel()->hide();
|
|
||||||
accept->get_ok()->set_text(TTR("I see.."));
|
accept->get_ok()->set_text(TTR("I see.."));
|
||||||
accept->set_text(TTR("This operation can't be done without a scene."));
|
accept->set_text(TTR("This operation can't be done without a scene."));
|
||||||
accept->popup_centered_minsize();
|
accept->popup_centered_minsize();
|
||||||
|
@ -2036,8 +2034,6 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) {
|
||||||
} break;
|
} break;
|
||||||
case FILE_IMPORT_SUBSCENE: {
|
case FILE_IMPORT_SUBSCENE: {
|
||||||
|
|
||||||
//import_subscene->popup_centered_ratio();
|
|
||||||
|
|
||||||
if (!editor_data.get_edited_scene_root()) {
|
if (!editor_data.get_edited_scene_root()) {
|
||||||
|
|
||||||
current_option = -1;
|
current_option = -1;
|
||||||
|
@ -2056,7 +2052,6 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) {
|
||||||
if (unsaved_cache && !p_confirmed) {
|
if (unsaved_cache && !p_confirmed) {
|
||||||
|
|
||||||
confirmation->get_ok()->set_text(TTR("Open"));
|
confirmation->get_ok()->set_text(TTR("Open"));
|
||||||
//confirmation->get_cancel()->show();
|
|
||||||
confirmation->set_text(TTR("Current scene not saved. Open anyway?"));
|
confirmation->set_text(TTR("Current scene not saved. Open anyway?"));
|
||||||
confirmation->popup_centered_minsize();
|
confirmation->popup_centered_minsize();
|
||||||
break;
|
break;
|
||||||
|
@ -3240,48 +3235,47 @@ void EditorNode::_show_messages() {
|
||||||
|
|
||||||
void EditorNode::_add_to_recent_scenes(const String &p_scene) {
|
void EditorNode::_add_to_recent_scenes(const String &p_scene) {
|
||||||
|
|
||||||
String base = "_" + ProjectSettings::get_singleton()->get_resource_path().replace("\\", "::").replace("/", "::");
|
Array rc = EditorSettings::get_singleton()->get_project_metadata("recent_files", "scenes", Array());
|
||||||
Vector<String> rc = EDITOR_DEF(base + "/_recent_scenes", Array());
|
if (rc.find(p_scene) != -1)
|
||||||
String name = p_scene;
|
rc.erase(p_scene);
|
||||||
name = name.replace("res://", "");
|
rc.push_front(p_scene);
|
||||||
if (rc.find(name) != -1)
|
|
||||||
rc.erase(name);
|
|
||||||
rc.insert(0, name);
|
|
||||||
if (rc.size() > 10)
|
if (rc.size() > 10)
|
||||||
rc.resize(10);
|
rc.resize(10);
|
||||||
|
|
||||||
EditorSettings::get_singleton()->set(base + "/_recent_scenes", rc);
|
EditorSettings::get_singleton()->set_project_metadata("recent_files", "scenes", rc);
|
||||||
EditorSettings::get_singleton()->save();
|
|
||||||
_update_recent_scenes();
|
_update_recent_scenes();
|
||||||
}
|
}
|
||||||
|
|
||||||
void EditorNode::_open_recent_scene(int p_idx) {
|
void EditorNode::_open_recent_scene(int p_idx) {
|
||||||
|
|
||||||
String base = "_" + ProjectSettings::get_singleton()->get_resource_path().replace("\\", "::").replace("/", "::");
|
|
||||||
|
|
||||||
if (p_idx == recent_scenes->get_item_count() - 1) {
|
if (p_idx == recent_scenes->get_item_count() - 1) {
|
||||||
|
|
||||||
EditorSettings::get_singleton()->erase(base + "/_recent_scenes");
|
EditorSettings::get_singleton()->set_project_metadata("recent_files", "scenes", Array());
|
||||||
call_deferred("_update_recent_scenes");
|
call_deferred("_update_recent_scenes");
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
Vector<String> rc = EDITOR_DEF(base + "/_recent_scenes", Array());
|
Array rc = EditorSettings::get_singleton()->get_project_metadata("recent_files", "scenes", Array());
|
||||||
ERR_FAIL_INDEX(p_idx, rc.size());
|
ERR_FAIL_INDEX(p_idx, rc.size());
|
||||||
|
|
||||||
String path = "res://" + rc[p_idx];
|
if (load_scene(rc[p_idx]) != OK) {
|
||||||
load_scene(path);
|
|
||||||
|
rc.remove(p_idx);
|
||||||
|
EditorSettings::get_singleton()->set_project_metadata("recent_files", "scenes", rc);
|
||||||
|
_update_recent_scenes();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void EditorNode::_update_recent_scenes() {
|
void EditorNode::_update_recent_scenes() {
|
||||||
|
|
||||||
String base = "_" + ProjectSettings::get_singleton()->get_resource_path().replace("\\", "::").replace("/", "::");
|
Array rc = EditorSettings::get_singleton()->get_project_metadata("recent_files", "scenes", Array());
|
||||||
Vector<String> rc = EDITOR_DEF(base + "/_recent_scenes", Array());
|
|
||||||
recent_scenes->clear();
|
recent_scenes->clear();
|
||||||
|
|
||||||
|
String path;
|
||||||
for (int i = 0; i < rc.size(); i++) {
|
for (int i = 0; i < rc.size(); i++) {
|
||||||
|
|
||||||
recent_scenes->add_item(rc[i], i);
|
path = rc[i];
|
||||||
|
recent_scenes->add_item(path.replace("res://", ""), i);
|
||||||
}
|
}
|
||||||
|
|
||||||
recent_scenes->add_separator();
|
recent_scenes->add_separator();
|
||||||
|
@ -5118,7 +5112,6 @@ EditorNode::EditorNode() {
|
||||||
gui_base->add_child(dependency_fixer);
|
gui_base->add_child(dependency_fixer);
|
||||||
|
|
||||||
settings_config_dialog = memnew(EditorSettingsDialog);
|
settings_config_dialog = memnew(EditorSettingsDialog);
|
||||||
// settings_config_dialog->add_style_override("panel", gui_base->get_stylebox("EditorSettingsDialog", "EditorStyles"));
|
|
||||||
gui_base->add_child(settings_config_dialog);
|
gui_base->add_child(settings_config_dialog);
|
||||||
|
|
||||||
project_settings = memnew(ProjectSettingsEditor(&editor_data));
|
project_settings = memnew(ProjectSettingsEditor(&editor_data));
|
||||||
|
@ -5192,7 +5185,6 @@ EditorNode::EditorNode() {
|
||||||
p->add_item(TTR("Project Settings"), RUN_SETTINGS);
|
p->add_item(TTR("Project Settings"), RUN_SETTINGS);
|
||||||
p->add_separator();
|
p->add_separator();
|
||||||
p->connect("id_pressed", this, "_menu_option");
|
p->connect("id_pressed", this, "_menu_option");
|
||||||
//p->add_item(TTR("Run Script"), FILE_RUN_SCRIPT, KEY_MASK_SHIFT + KEY_MASK_CMD + KEY_R);
|
|
||||||
p->add_item(TTR("Export"), FILE_EXPORT_PROJECT);
|
p->add_item(TTR("Export"), FILE_EXPORT_PROJECT);
|
||||||
|
|
||||||
PopupMenu *tool_menu = memnew(PopupMenu);
|
PopupMenu *tool_menu = memnew(PopupMenu);
|
||||||
|
@ -5283,7 +5275,6 @@ EditorNode::EditorNode() {
|
||||||
menu_hb->add_child(play_cc);
|
menu_hb->add_child(play_cc);
|
||||||
|
|
||||||
play_button_panel = memnew(PanelContainer);
|
play_button_panel = memnew(PanelContainer);
|
||||||
// play_button_panel->add_style_override("panel", gui_base->get_stylebox("PlayButtonPanel", "EditorStyles"));
|
|
||||||
play_cc->add_child(play_button_panel);
|
play_cc->add_child(play_button_panel);
|
||||||
|
|
||||||
HBoxContainer *play_hb = memnew(HBoxContainer);
|
HBoxContainer *play_hb = memnew(HBoxContainer);
|
||||||
|
|
Loading…
Reference in a new issue