diff options
Diffstat (limited to 'tools')
-rw-r--r-- | tools/editor/editor_help.cpp | 147 | ||||
-rw-r--r-- | tools/editor/editor_help.h | 9 | ||||
-rw-r--r-- | tools/editor/editor_node.cpp | 19 | ||||
-rw-r--r-- | tools/editor/plugins/script_editor_plugin.cpp | 2 | ||||
-rw-r--r-- | tools/editor/project_settings.cpp | 31 | ||||
-rw-r--r-- | tools/editor/property_editor.cpp | 69 | ||||
-rw-r--r-- | tools/editor/property_editor.h | 7 |
7 files changed, 225 insertions, 59 deletions
diff --git a/tools/editor/editor_help.cpp b/tools/editor/editor_help.cpp index 110e06f25b..238b2d1cb8 100644 --- a/tools/editor/editor_help.cpp +++ b/tools/editor/editor_help.cpp @@ -405,29 +405,98 @@ void EditorHelpIndex::select_class(const String& p_class) { class_list->ensure_cursor_is_visible(); } +void EditorHelpIndex::popup() { + + popup_centered_ratio(0.6); + + search_box->set_text(""); + _update_class_list(); +} + void EditorHelpIndex::_notification(int p_what) { if (p_what==NOTIFICATION_ENTER_TREE) { - class_list->clear(); - tree_item_map.clear(); - TreeItem *root = class_list->create_item(); - class_list->set_hide_root(true); + _update_class_list(); + connect("confirmed",this,"_tree_item_selected"); + } else if (p_what==NOTIFICATION_POST_POPUP) { + + search_box->call_deferred("grab_focus"); + } +} + +void EditorHelpIndex::_text_changed(const String& p_text) { - for(Map<String,DocData::ClassDoc>::Element *E=EditorHelp::get_doc_data()->class_list.front();E;E=E->next()) { + _update_class_list(); +} + +void EditorHelpIndex::_update_class_list() { + + class_list->clear(); + tree_item_map.clear(); + TreeItem *root = class_list->create_item(); + class_list->set_hide_root(true); + String filter = search_box->get_text().strip_edges(); + String to_select = ""; + for(Map<String,DocData::ClassDoc>::Element *E=EditorHelp::get_doc_data()->class_list.front();E;E=E->next()) { + + if (filter == "") { add_type(E->key(),tree_item_map,root); + } else { + + bool found = false; + String type = E->key(); + + while(type != "") { + if (type.findn(filter)!=-1) { + + if (to_select.empty()) { + to_select = type; + } + + found=true; + break; + } + + type = EditorHelp::get_doc_data()->class_list[type].inherits; + } + + if (found) { + add_type(E->key(),tree_item_map,root); + } } + } + if (tree_item_map.has(filter)) { + select_class(filter); + } else if (to_select != "") { + select_class(to_select); + } +} + + +void EditorHelpIndex::_sbox_input(const InputEvent& p_ie) { + + if (p_ie.type==InputEvent::KEY && ( + p_ie.key.scancode == KEY_UP || + p_ie.key.scancode == KEY_DOWN || + p_ie.key.scancode == KEY_PAGEUP || + p_ie.key.scancode == KEY_PAGEDOWN ) ) { + + class_list->call("_input_event",p_ie); + search_box->accept_event(); } } void EditorHelpIndex::_bind_methods() { ObjectTypeDB::bind_method("_tree_item_selected",&EditorHelpIndex::_tree_item_selected); + ObjectTypeDB::bind_method("_text_changed",&EditorHelpIndex::_text_changed); + ObjectTypeDB::bind_method("_sbox_input",&EditorHelpIndex::_sbox_input); ObjectTypeDB::bind_method("select_class",&EditorHelpIndex::select_class); ADD_SIGNAL( MethodInfo("open_class")); } @@ -436,19 +505,25 @@ void EditorHelpIndex::_bind_methods() { EditorHelpIndex::EditorHelpIndex() { - VBoxContainer *vbc = memnew( VBoxContainer ); add_child(vbc); set_child_rect(vbc); + search_box = memnew( LineEdit ); + vbc->add_margin_child("Search:", search_box); + search_box->set_h_size_flags(SIZE_EXPAND_FILL); + + register_text_enter(search_box); + + search_box->connect("text_changed", this, "_text_changed"); + search_box->connect("input_event", this, "_sbox_input"); + class_list = memnew( Tree ); - vbc->add_margin_child("Class List: ",class_list,true); + vbc->add_margin_child("Class List: ", class_list, true); class_list->set_v_size_flags(SIZE_EXPAND_FILL); - class_list->connect("item_activated",this,"_tree_item_selected"); - get_ok()->set_text("Open"); } @@ -650,14 +725,64 @@ Error EditorHelp::_goto_desc(const String& p_class,int p_vscr) { class_desc->add_text("Inherits: "); class_desc->pop(); class_desc->pop(); + + String inherits = cd.inherits; + class_desc->push_font(doc_font); - _add_type(cd.inherits); + + while (inherits != "") { + _add_type(inherits); + + inherits = doc->class_list[inherits].inherits; + + if (inherits != "") { + class_desc->add_text(" , "); + } + } + class_desc->pop(); class_desc->add_newline(); - class_desc->add_newline(); + } + + if (ObjectTypeDB::type_exists(cd.name)) { + bool found = false; + bool prev = false; + + for (Map<String,DocData::ClassDoc>::Element *E=doc->class_list.front();E;E=E->next()) { + + if (E->get().inherits == cd.name) { + + if (!found) { + class_desc->push_color(EditorSettings::get_singleton()->get("text_editor/keyword_color")); + class_desc->push_font(doc_title_font); + class_desc->add_text("Inherited by: "); + class_desc->pop(); + class_desc->pop(); + + found = true; + class_desc->push_font(doc_font); + } + + if (prev) { + + class_desc->add_text(" , "); + prev = false; + } + + _add_type(E->get().name); + prev = true; + } + } + + if (found) + class_desc->pop(); + + class_desc->add_newline(); } + class_desc->add_newline(); + if (cd.brief_description!="") { class_desc->push_color(EditorSettings::get_singleton()->get("text_editor/keyword_color")); diff --git a/tools/editor/editor_help.h b/tools/editor/editor_help.h index 059a7ae11d..f6dda9f545 100644 --- a/tools/editor/editor_help.h +++ b/tools/editor/editor_help.h @@ -77,11 +77,16 @@ public: class EditorHelpIndex : public ConfirmationDialog { OBJ_TYPE( EditorHelpIndex, ConfirmationDialog ); - + LineEdit *search_box; Tree *class_list; HashMap<String,TreeItem*> tree_item_map; void _tree_item_selected(); + void _text_changed(const String& p_text); + void _sbox_input(const InputEvent& p_ie); + + void _update_class_list(); + void add_type(const String& p_type,HashMap<String,TreeItem*>& p_types,TreeItem *p_root); protected: @@ -92,6 +97,8 @@ public: void select_class(const String& p_class); + void popup(); + EditorHelpIndex(); }; diff --git a/tools/editor/editor_node.cpp b/tools/editor/editor_node.cpp index 61d6d74d1e..24df4544ec 100644 --- a/tools/editor/editor_node.cpp +++ b/tools/editor/editor_node.cpp @@ -981,11 +981,6 @@ void EditorNode::_save_scene(String p_file) { editor_data.apply_changes_in_editors(); - if (editor_plugin_screen) { - scene->set_meta("__editor_plugin_screen__",editor_plugin_screen->get_name()); - } - - _set_scene_metadata(p_file); @@ -3692,26 +3687,12 @@ Error EditorNode::load_scene(const String& p_scene, bool p_ignore_broken_deps,bo */ editor_data.set_edited_scene_import_metadata( sdata->get_import_metadata() ); - // editor_data.get_undo_redo().clear_history(); saved_version=editor_data.get_undo_redo().get_version(); _update_title(); _update_scene_tabs(); _add_to_recent_scenes(lpath); - if (new_scene->has_meta("__editor_plugin_screen__")) { - - String editor = new_scene->get_meta("__editor_plugin_screen__"); - - for(int i=0;i<editor_table.size();i++) { - - if (editor_table[i]->get_name()==editor) { - _editor_select(i); - break; - } - } - } - prev_scene->set_disabled(previous_scenes.size()==0); opening_prev=false; diff --git a/tools/editor/plugins/script_editor_plugin.cpp b/tools/editor/plugins/script_editor_plugin.cpp index 474bafee69..e3dce0b36a 100644 --- a/tools/editor/plugins/script_editor_plugin.cpp +++ b/tools/editor/plugins/script_editor_plugin.cpp @@ -971,7 +971,7 @@ void ScriptEditor::_menu_option(int p_option) { } } - help_index->popup_centered_ratio(0.6); + help_index->popup(); if (current!="") { help_index->call_deferred("select_class",current); diff --git a/tools/editor/project_settings.cpp b/tools/editor/project_settings.cpp index 69e09d6053..bf7d8b190a 100644 --- a/tools/editor/project_settings.cpp +++ b/tools/editor/project_settings.cpp @@ -60,6 +60,8 @@ void ProjectSettings::_notification(int p_what) { if (p_what==NOTIFICATION_ENTER_TREE) { + globals_editor->edit(Globals::get_singleton()); + search_button->set_icon(get_icon("Zoom","EditorIcons")); clear_button->set_icon(get_icon("Close","EditorIcons")); @@ -566,8 +568,7 @@ void ProjectSettings::popup_project_settings() { //popup_centered(Size2(500,400)); popup_centered_ratio(); - globals_editor->edit(NULL); - globals_editor->edit(Globals::get_singleton()); + globals_editor->update_category_list(); _update_translations(); _update_autoload(); plugin_settings->update_plugins(); @@ -605,37 +606,45 @@ void ProjectSettings::_item_add() { case 3: value=""; break; } - String catname = category->get_text(); + String catname = category->get_text().strip_edges(); /*if (!catname.is_valid_identifier()) { message->set_text("Invalid Category.\nValid characters: a-z,A-Z,0-9 or _"); message->popup_centered(Size2(300,100)); return; }*/ - String propname = property->get_text(); + String propname = property->get_text().strip_edges(); /*if (!propname.is_valid_identifier()) { message->set_text("Invalid Property.\nValid characters: a-z,A-Z,0-9 or _"); message->popup_centered(Size2(300,100)); return; }*/ - String name = catname+"/"+propname; + String name = catname!="" ? catname+"/"+propname : propname; + Globals::get_singleton()->set(name,value); - globals_editor->edit(NULL); - globals_editor->edit(Globals::get_singleton()); + + globals_editor->set_current_section(catname); + globals_editor->update_category_list(); + + _settings_changed(); } void ProjectSettings::_item_del() { - String catname = category->get_text(); + String catname = category->get_text().strip_edges(); //ERR_FAIL_COND(!catname.is_valid_identifier()); - String propname = property->get_text(); + String propname = property->get_text().strip_edges(); //ERR_FAIL_COND(!propname.is_valid_identifier()); - String name = catname+"/"+propname; + String name = catname!="" ? catname+"/"+propname : propname; + Globals::get_singleton()->set(name,Variant()); - globals_editor->get_property_editor()->update_tree(); + globals_editor->set_current_section(catname); + globals_editor->update_category_list(); + + _settings_changed(); } void ProjectSettings::_action_adds(String) { diff --git a/tools/editor/property_editor.cpp b/tools/editor/property_editor.cpp index 303604c2fc..4e98ae9e90 100644 --- a/tools/editor/property_editor.cpp +++ b/tools/editor/property_editor.cpp @@ -3840,14 +3840,34 @@ void SectionedPropertyEditor::_section_selected(int p_which) { filter->set_section( sections->get_item_metadata(p_which) ); } +void SectionedPropertyEditor::set_current_section(const String& p_section) { + + int section_idx = sections->find_metadata(p_section); + + if (section_idx==sections->get_current()) + return; + + if (section_idx!=-1) { + sections->select(section_idx); + _section_selected(section_idx); + } else if (sections->get_item_count()) { + sections->select(0); + _section_selected(0); + } +} + String SectionedPropertyEditor::get_current_section() const { - return sections->get_item_metadata( sections->get_current() ); + if (sections->get_current()!=-1) + return sections->get_item_metadata( sections->get_current() ); + else + return ""; } String SectionedPropertyEditor::get_full_item_path(const String& p_item) { - String base = sections->get_item_metadata( sections->get_current() ); + String base = get_current_section(); + if (base!="") return base+"/"+p_item; else @@ -3856,17 +3876,44 @@ String SectionedPropertyEditor::get_full_item_path(const String& p_item) { void SectionedPropertyEditor::edit(Object* p_object) { - List<PropertyInfo> pinfo; - if (p_object) - p_object->get_property_list(&pinfo); + if (p_object) { + obj=p_object->get_instance_ID(); + update_category_list(); + } else { + sections->clear(); + } + + filter->set_edited(p_object); + editor->edit(filter); + + sections->select(0); + _section_selected(0); + +} + +void SectionedPropertyEditor::update_category_list() { + + String selected_category=get_current_section(); sections->clear(); + Object *o = ObjectDB::get_instance(obj); + + if (!o) + return; + + List<PropertyInfo> pinfo; + o->get_property_list(&pinfo); + Set<String> existing_sections; for (List<PropertyInfo>::Element *E=pinfo.front();E;E=E->next()) { PropertyInfo pi=E->get(); + if (pi.usage&PROPERTY_USAGE_CATEGORY) continue; + else if ( !(pi.usage&PROPERTY_USAGE_EDITOR) ) + continue; + if (pi.name.find(":")!=-1 || pi.name=="script/script") continue; int sp = pi.name.find("/"); @@ -3885,19 +3932,9 @@ void SectionedPropertyEditor::edit(Object* p_object) { sections->set_item_metadata(sections->get_item_count()-1,""); } } - - } - //sections->sort_items_by_text(); - - - filter->set_edited(p_object); - editor->edit(filter); - - sections->select(0); - _section_selected(0); - + set_current_section(selected_category); } PropertyEditor *SectionedPropertyEditor::get_property_editor() { diff --git a/tools/editor/property_editor.h b/tools/editor/property_editor.h index 63ad090901..83923cb237 100644 --- a/tools/editor/property_editor.h +++ b/tools/editor/property_editor.h @@ -257,6 +257,9 @@ class SectionedPropertyEditor : public HBoxContainer { OBJ_TYPE(SectionedPropertyEditor,HBoxContainer); + + ObjectID obj; + ItemList *sections; SectionedPropertyEditorFilter *filter; PropertyEditor *editor; @@ -270,8 +273,12 @@ public: PropertyEditor *get_property_editor(); void edit(Object* p_object); String get_full_item_path(const String& p_item); + + void set_current_section(const String& p_section); String get_current_section() const; + void update_category_list(); + SectionedPropertyEditor(); ~SectionedPropertyEditor(); }; |