diff options
Diffstat (limited to 'tools/editor')
32 files changed, 1751 insertions, 874 deletions
diff --git a/tools/editor/code_editor.cpp b/tools/editor/code_editor.cpp index 2ed03a1858..685763cadb 100644 --- a/tools/editor/code_editor.cpp +++ b/tools/editor/code_editor.cpp @@ -618,7 +618,7 @@ CodeTextEditor::CodeTextEditor() { line_col = memnew( Label ); add_child(line_col); line_col->set_anchor_and_margin(MARGIN_LEFT,ANCHOR_END,135); - line_col->set_anchor_and_margin(MARGIN_TOP,ANCHOR_END,20); + line_col->set_anchor_and_margin(MARGIN_TOP,ANCHOR_END,15); line_col->set_anchor_and_margin(MARGIN_BOTTOM,ANCHOR_END,1); line_col->set_anchor_and_margin(MARGIN_RIGHT,ANCHOR_END,5); //line_col->set_align(Label::ALIGN_RIGHT); @@ -637,7 +637,7 @@ CodeTextEditor::CodeTextEditor() { error = memnew( Label ); add_child(error); error->set_anchor_and_margin(MARGIN_LEFT,ANCHOR_BEGIN,5); - error->set_anchor_and_margin(MARGIN_TOP,ANCHOR_END,20); + error->set_anchor_and_margin(MARGIN_TOP,ANCHOR_END,15); error->set_anchor_and_margin(MARGIN_BOTTOM,ANCHOR_END,1); error->set_anchor_and_margin(MARGIN_RIGHT,ANCHOR_END,130); error->hide(); diff --git a/tools/editor/editor_help.cpp b/tools/editor/editor_help.cpp index 46ed2194a8..4f44331b0b 100644 --- a/tools/editor/editor_help.cpp +++ b/tools/editor/editor_help.cpp @@ -300,9 +300,9 @@ void EditorHelpSearch::_bind_methods() { } -EditorHelpSearch::EditorHelpSearch(EditorNode *p_editor) { +EditorHelpSearch::EditorHelpSearch() { - editor=p_editor; + editor=EditorNode::get_singleton(); VBoxContainer *vbc = memnew( VBoxContainer ); add_child(vbc); set_child_rect(vbc); @@ -318,17 +318,138 @@ EditorHelpSearch::EditorHelpSearch(EditorNode *p_editor) { search_box->connect("input_event",this,"_sbox_input"); search_options = memnew( Tree ); vbc->add_margin_child("Matches:",search_options,true); - get_ok()->set_text("View"); + get_ok()->set_text("Open"); get_ok()->set_disabled(true); register_text_enter(search_box); set_hide_on_ok(false); search_options->connect("item_activated",this,"_confirmed"); set_title("Search Classes"); + // search_options->set_hide_root(true); } +///////////////////////////////// + +//////////////////////////////////// +/// ///////////////////////////////// + + + +void EditorHelpIndex::add_type(const String& p_type,HashMap<String,TreeItem*>& p_types,TreeItem *p_root) { + + if (p_types.has(p_type)) + return; +// if (!ObjectTypeDB::is_type(p_type,base) || p_type==base) +// return; + + String inherits=EditorHelp::get_doc_data()->class_list[p_type].inherits; + + TreeItem *parent=p_root; + + + if (inherits.length()) { + + if (!p_types.has(inherits)) { + + add_type(inherits,p_types,p_root); + } + + if (p_types.has(inherits) ) + parent=p_types[inherits]; + } + + TreeItem *item = class_list->create_item(parent); + item->set_metadata(0,p_type); + item->set_tooltip(0,EditorHelp::get_doc_data()->class_list[p_type].brief_description); + item->set_text(0,p_type); + + + if (has_icon(p_type,"EditorIcons")) { + + item->set_icon(0, get_icon(p_type,"EditorIcons")); + } + + p_types[p_type]=item; +} + + +void EditorHelpIndex::_tree_item_selected() { + + + TreeItem *s=class_list->get_selected(); + if (!s) + return; + + emit_signal("open_class",s->get_text(0)); + + hide(); + + //_goto_desc(s->get_text(0)); + +} + +void EditorHelpIndex::select_class(const String& p_class) { + + if (!tree_item_map.has(p_class)) + return; + tree_item_map[p_class]->select(0); + class_list->ensure_cursor_is_visible(); +} + +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); + connect("confirmed",this,"_tree_item_selected"); + + + for(Map<String,DocData::ClassDoc>::Element *E=EditorHelp::get_doc_data()->class_list.front();E;E=E->next()) { + + add_type(E->key(),tree_item_map,root); + } + + } +} + +void EditorHelpIndex::_bind_methods() { + + ObjectTypeDB::bind_method("_tree_item_selected",&EditorHelpIndex::_tree_item_selected); + ObjectTypeDB::bind_method("select_class",&EditorHelpIndex::select_class); + ADD_SIGNAL( MethodInfo("open_class")); +} + + + +EditorHelpIndex::EditorHelpIndex() { + + + VBoxContainer *vbc = memnew( VBoxContainer ); + add_child(vbc); + set_child_rect(vbc); + + class_list = memnew( Tree ); + 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"); +} + + + +///////////////////////////////// + +//////////////////////////////////// +/// ///////////////////////////////// DocData *EditorHelp::doc=NULL; void EditorHelp::_unhandled_key_input(const InputEvent& p_ev) { @@ -339,8 +460,6 @@ void EditorHelp::_unhandled_key_input(const InputEvent& p_ev) { search->grab_focus(); search->select_all(); - } else if (p_ev.key.mod.shift && p_ev.key.scancode==KEY_F1) { - class_search->popup(); } } @@ -351,17 +470,19 @@ void EditorHelp::_search(const String&) { String stext=search->get_text(); - bool keep = prev_search==stext && class_list->get_selected() && prev_search_page==class_list->get_selected()->get_text(0); + bool keep = prev_search==stext; - class_desc->search(stext, keep); + bool ret = class_desc->search(stext, keep); + if (!ret) { + class_desc->search(stext, false); + } prev_search=stext; - if (class_list->get_selected()) - prev_search_page=class_list->get_selected()->get_text(0); } +#if 0 void EditorHelp::_button_pressed(int p_idx) { if (p_idx==PAGE_CLASS_LIST) { @@ -399,16 +520,11 @@ void EditorHelp::_button_pressed(int p_idx) { } else if (p_idx==PAGE_SEARCH) { _search(""); - } else if (p_idx==CLASS_SEARCH) { - - class_search->popup(); } - - } - +#endif void EditorHelp::_class_list_select(const String& p_select) { @@ -417,16 +533,28 @@ void EditorHelp::_class_list_select(const String& p_select) { void EditorHelp::_class_desc_select(const String& p_select) { + + +// print_line("LINK: "+p_select); if (p_select.begins_with("#")) { - _goto_desc(p_select.substr(1,p_select.length())); + //_goto_desc(p_select.substr(1,p_select.length())); + emit_signal("go_to_help","class_name:"+p_select.substr(1,p_select.length())); return; } else if (p_select.begins_with("@")) { String m = p_select.substr(1,p_select.length()); - if (!method_line.has(m)) - return; - class_desc->scroll_to_line(method_line[m]); - return; + + if (m.find(".")!=-1) { + //must go somewhere else + + emit_signal("go_to_help","class_method:"+m.get_slice(".",0)+":"+m.get_slice(".",0)); + } else { + + if (!method_line.has(m)) + return; + class_desc->scroll_to_line(method_line[m]); + } + } @@ -449,68 +577,40 @@ void EditorHelp::_add_type(const String& p_type) { } -void EditorHelp::_update_history_buttons() { - - back->set_disabled(history_pos<2); - forward->set_disabled(history_pos>=history.size()); - -} - - void EditorHelp::_scroll_changed(double p_scroll) { if (scroll_locked) return; - int p = history_pos -1; - if (p<0 || p>=history.size()) - return; - if (class_desc->get_v_scroll()->is_hidden()) p_scroll=0; - history[p].scroll=p_scroll; + //history[p].scroll=p_scroll; } -Error EditorHelp::_goto_desc(const String& p_class,bool p_update_history,int p_vscr) { +Error EditorHelp::_goto_desc(const String& p_class,int p_vscr) { //ERR_FAIL_COND(!doc->class_list.has(p_class)); if (!doc->class_list.has(p_class)) return ERR_DOES_NOT_EXIST; - if (tree_item_map.has(p_class)) { + //if (tree_item_map.has(p_class)) { select_locked = true; - tree_item_map[p_class]->select(0); - class_list->ensure_cursor_is_visible(); - } + //} class_desc->show(); //tabs->set_current_tab(PAGE_CLASS_DESC); - edited_class->set_pressed(true); - class_list_button->set_pressed(false); description_line=0; - if (p_class==edited_class->get_text()) + if (p_class==edited_class) return OK; //already there scroll_locked=true; - if (p_update_history) { - - history.resize(history_pos); - history_pos++; - History h; - h.c=p_class; - h.scroll=0; - history.push_back(h); - _update_history_buttons(); - class_desc->get_v_scroll()->set_val(0); - } - class_desc->clear(); method_line.clear(); - edited_class->set_text(p_class); + edited_class=p_class; //edited_class->show(); @@ -925,10 +1025,7 @@ Error EditorHelp::_goto_desc(const String& p_class,bool p_update_history,int p_v } - if (!p_update_history) { - class_desc->get_v_scroll()->set_val(history[history_pos-1].scroll); - } scroll_locked=false; @@ -939,8 +1036,6 @@ void EditorHelp::_request_help(const String& p_string) { Error err = _goto_desc(p_string); if (err==OK) { editor->call("_editor_select",3); - } else { - class_search->popup(p_string); } //100 palabras } @@ -1209,315 +1304,158 @@ void EditorHelp::_add_text(const String& p_bbcode) { } -void EditorHelp::add_type(const String& p_type,HashMap<String,TreeItem*>& p_types,TreeItem *p_root) { - - if (p_types.has(p_type)) - return; -// if (!ObjectTypeDB::is_type(p_type,base) || p_type==base) -// return; - - String inherits=doc->class_list[p_type].inherits; - - TreeItem *parent=p_root; - if (inherits.length()) { +void EditorHelp::_update_doc() { - if (!p_types.has(inherits)) { - add_type(inherits,p_types,p_root); - } - if (p_types.has(inherits) ) - parent=p_types[inherits]; - } +} - TreeItem *item = class_list->create_item(parent); - item->set_metadata(0,p_type); - item->set_tooltip(0,doc->class_list[p_type].brief_description); - item->set_text(0,p_type); +void EditorHelp::generate_doc() { - if (has_icon(p_type,"EditorIcons")) { + doc = memnew( DocData ); + doc->generate(true); + DocData compdoc; + compdoc.load_compressed(_doc_data_compressed,_doc_data_compressed_size,_doc_data_uncompressed_size); + doc->merge_from(compdoc); //ensure all is up to date - item->set_icon(0, get_icon(p_type,"EditorIcons")); - } - p_types[p_type]=item; } +void EditorHelp::_notification(int p_what) { -void EditorHelp::_update_doc() { + switch(p_what) { + case NOTIFICATION_READY: { - class_list->clear(); - List<StringName> type_list; +// forward->set_icon(get_icon("Forward","EditorIcons")); +// back->set_icon(get_icon("Back","EditorIcons")); + _update_doc(); + editor->connect("request_help",this,"_request_help"); - tree_item_map.clear(); + } break; + } +} - TreeItem *root = class_list->create_item(); - class_list->set_hide_root(true); - List<StringName>::Element *I=type_list.front(); - for(Map<String,DocData::ClassDoc>::Element *E=doc->class_list.front();E;E=E->next()) { - add_type(E->key(),tree_item_map,root); - } +void EditorHelp::go_to_help(const String& p_help) { + _help_callback(p_help); } +void EditorHelp::go_to_class(const String& p_class,int p_scroll) { -void EditorHelp::generate_doc() { + _goto_desc(p_class,p_scroll); +} - doc = memnew( DocData ); - doc->generate(true); - DocData compdoc; - compdoc.load_compressed(_doc_data_compressed,_doc_data_compressed_size,_doc_data_uncompressed_size); - doc->merge_from(compdoc); //ensure all is up to date +void EditorHelp::popup_search() { + search_dialog->popup_centered(Size2(250,80)); + search->grab_focus(); } -void EditorHelp::_notification(int p_what) { +void EditorHelp::_search_cbk() { + _search(search->get_text()); +} - switch(p_what) { +String EditorHelp::get_class_name() { - case NOTIFICATION_READY: { + return edited_class; +} +void EditorHelp::search_again() { + _search(prev_search); +} - forward->set_icon(get_icon("Forward","EditorIcons")); - back->set_icon(get_icon("Back","EditorIcons")); - _update_doc(); - editor->connect("request_help",this,"_request_help"); +int EditorHelp::get_scroll() const { - } break; - } + return class_desc->get_v_scroll()->get_val(); } +void EditorHelp::set_scroll(int p_scroll) { -void EditorHelp::_tree_item_selected() { - if (select_locked) { - select_locked = false; - return; - } - TreeItem *s=class_list->get_selected(); - if (!s) - return; - select_locked=true; - _goto_desc(s->get_text(0)); - select_locked=false; + class_desc->get_v_scroll()->set_val(p_scroll); + } void EditorHelp::_bind_methods() { ObjectTypeDB::bind_method("_class_list_select",&EditorHelp::_class_list_select); ObjectTypeDB::bind_method("_class_desc_select",&EditorHelp::_class_desc_select); - ObjectTypeDB::bind_method("_button_pressed",&EditorHelp::_button_pressed); +// ObjectTypeDB::bind_method("_button_pressed",&EditorHelp::_button_pressed); ObjectTypeDB::bind_method("_scroll_changed",&EditorHelp::_scroll_changed); ObjectTypeDB::bind_method("_request_help",&EditorHelp::_request_help); ObjectTypeDB::bind_method("_unhandled_key_input",&EditorHelp::_unhandled_key_input); ObjectTypeDB::bind_method("_search",&EditorHelp::_search); - ObjectTypeDB::bind_method("_tree_item_selected",&EditorHelp::_tree_item_selected); + ObjectTypeDB::bind_method("_search_cbk",&EditorHelp::_search_cbk); + ObjectTypeDB::bind_method("_help_callback",&EditorHelp::_help_callback); + ADD_SIGNAL(MethodInfo("go_to_help")); + } -EditorHelp::EditorHelp(EditorNode *p_editor) { +EditorHelp::EditorHelp() { - editor=p_editor; + editor=EditorNode::get_singleton(); VBoxContainer *vbc = this; - HBoxContainer *panel_hb = memnew( HBoxContainer ); - - Button *b = memnew( Button ); - b->set_text("Class List"); - panel_hb->add_child(b); - vbc->add_child(panel_hb); - b->set_toggle_mode(true); - b->set_pressed(true); - b->connect("pressed",this,"_button_pressed",make_binds(PAGE_CLASS_LIST)); - class_list_button=b; - class_list_button->hide(); - - b = memnew( Button ); - b->set_text("Class"); - panel_hb->add_child(b); - edited_class=b; - edited_class->hide(); - b->set_toggle_mode(true); - b->connect("pressed",this,"_button_pressed",make_binds(PAGE_CLASS_DESC)); - - b = memnew( Button ); - b->set_text("Search in Classes"); - panel_hb->add_child(b); - b->connect("pressed",this,"_button_pressed",make_binds(CLASS_SEARCH)); - - Control *expand = memnew( Control ); - expand->set_h_size_flags(SIZE_EXPAND_FILL); - panel_hb->add_child(expand); - - b = memnew( Button ); - panel_hb->add_child(b); - back=b; - b->connect("pressed",this,"_button_pressed",make_binds(PAGE_CLASS_PREV)); - - b = memnew( Button ); - panel_hb->add_child(b); - forward=b; - b->connect("pressed",this,"_button_pressed",make_binds(PAGE_CLASS_NEXT)); - - Separator *hs = memnew( VSeparator ); - panel_hb->add_child(hs); - Control *ec = memnew( Control ); - ec->set_custom_minimum_size(Size2(200,1)); - panel_hb->add_child(ec); - search = memnew( LineEdit ); - ec->add_child(search); - search->set_area_as_parent_rect(); - search->connect("text_entered",this,"_search"); - - b = memnew( Button ); - b->set_text("Find"); - panel_hb->add_child(b); - b->connect("pressed",this,"_button_pressed",make_binds(PAGE_SEARCH)); - - hs = memnew( VSeparator ); - panel_hb->add_child(hs); - h_split = memnew( HSplitContainer ); - h_split->set_v_size_flags(SIZE_EXPAND_FILL); - - - vbc->add_child(h_split); - - class_list = memnew( Tree ); - h_split->add_child(class_list); //class_list->connect("meta_clicked",this,"_class_list_select"); //class_list->set_selection_enabled(true); { - PanelContainer *pc = memnew( PanelContainer ); + Panel *pc = memnew( Panel ); Ref<StyleBoxFlat> style( memnew( StyleBoxFlat ) ); style->set_bg_color( EditorSettings::get_singleton()->get("text_editor/background_color") ); - style->set_default_margin(MARGIN_LEFT,20); - style->set_default_margin(MARGIN_TOP,20); + pc->set_v_size_flags(SIZE_EXPAND_FILL); pc->add_style_override("panel", style); //get_stylebox("normal","TextEdit")); - h_split->add_child(pc); + vbc->add_child(pc); class_desc = memnew( RichTextLabel ); pc->add_child(class_desc); + class_desc->set_area_as_parent_rect(8); class_desc->connect("meta_clicked",this,"_class_desc_select"); } class_desc->get_v_scroll()->connect("value_changed",this,"_scroll_changed"); class_desc->set_selection_enabled(true); - editor=p_editor; - history_pos=0; + scroll_locked=false; select_locked=false; set_process_unhandled_key_input(true); - h_split->set_split_offset(200); - class_list->connect("cell_selected",this,"_tree_item_selected"); class_desc->hide(); - class_search = memnew( EditorHelpSearch(editor) ); - editor->get_gui_base()->add_child(class_search); - class_search->connect("go_to_help",this,"_help_callback"); -// prev_search_page=-1; -} - -EditorHelp::~EditorHelp() { - if (doc) - memdelete(doc); -} - - -void EditorHelpPlugin::edit(Object *p_object) { - - if (!p_object->cast_to<Script>()) - return; - - //editor_help->edit(p_object->cast_to<Script>()); -} - -bool EditorHelpPlugin::handles(Object *p_object) const { - - return false; -} - -void EditorHelpPlugin::make_visible(bool p_visible) { - - if (p_visible) { - editor_help->show(); - } else { - - editor_help->hide(); - } - -} - -void EditorHelpPlugin::selected_notify() { - - //editor_help->ensure_select_current(); -} - -Dictionary EditorHelpPlugin::get_state() const { - - return Dictionary(); -} - -void EditorHelpPlugin::set_state(const Dictionary& p_state) { - - //editor_help->set_state(p_state); -} -void EditorHelpPlugin::clear() { - - //editor_help->clear(); -} - -void EditorHelpPlugin::save_external_data() { - - //editor_help->save_external_data(); -} - -void EditorHelpPlugin::apply_changes() { - - //editor_help->apply_helps(); -} - -void EditorHelpPlugin::restore_global_state() { - - //if (bool(EDITOR_DEF("text_editor/restore_helps_on_load",true))) { -// editor_help->_load_files_state(); - //} - -} + search_dialog = memnew( ConfirmationDialog ); + add_child(search_dialog); + VBoxContainer *search_vb = memnew( VBoxContainer ); + search_dialog->add_child(search_vb); + search_dialog->set_child_rect(search_vb); + search = memnew( LineEdit ); + search_dialog->register_text_enter(search); + search_vb->add_margin_child("Search Text",search); + search_dialog->get_ok()->set_text("Find"); + search_dialog->connect("confirmed",this,"_search_cbk"); + search_dialog->set_hide_on_ok(false); + search_dialog->set_self_opacity(0.8); -void EditorHelpPlugin::save_global_state() { - //if (bool(EDITOR_DEF("text_editor/restore_helps_on_load",true))) { -// editor_help->_save_files_state(); -// } + /*class_search = memnew( EditorHelpSearch(editor) ); + editor->get_gui_base()->add_child(class_search); + class_search->connect("go_to_help",this,"_help_callback");*/ +// prev_search_page=-1; } - -EditorHelpPlugin::EditorHelpPlugin(EditorNode *p_node) { - - editor=p_node; - editor_help = memnew( EditorHelp(p_node) ); - editor->get_viewport()->add_child(editor_help); - editor_help->set_area_as_parent_rect(); - editor_help->hide(); - +EditorHelp::~EditorHelp() { } - -EditorHelpPlugin::~EditorHelpPlugin() -{ -} diff --git a/tools/editor/editor_help.h b/tools/editor/editor_help.h index d4066d076a..b5ee6eca6c 100644 --- a/tools/editor/editor_help.h +++ b/tools/editor/editor_help.h @@ -70,9 +70,29 @@ public: void popup(const String& p_term=""); - EditorHelpSearch(EditorNode *p_editor); + EditorHelpSearch(); }; +class EditorHelpIndex : public ConfirmationDialog { + OBJ_TYPE( EditorHelpIndex, ConfirmationDialog ); + + + Tree *class_list; + HashMap<String,TreeItem*> tree_item_map; + + void _tree_item_selected(); + void add_type(const String& p_type,HashMap<String,TreeItem*>& p_types,TreeItem *p_root); +protected: + + void _notification(int p_what); + static void _bind_methods(); + +public: + + void select_class(const String& p_class); + + EditorHelpIndex(); +}; class EditorHelp : public VBoxContainer { @@ -91,17 +111,11 @@ class EditorHelp : public VBoxContainer { }; - struct History { - String c; - int scroll; - }; - - Vector<History> history; - int history_pos; bool select_locked; String prev_search; - String prev_search_page; + + String edited_class; EditorNode *editor; Map<String,int> method_line; @@ -111,21 +125,17 @@ class EditorHelp : public VBoxContainer { Map<String,int> constant_line; int description_line; - Tree *class_list; RichTextLabel *class_desc; HSplitContainer *h_split; static DocData *doc; - Button *class_list_button; - Button *edited_class; - Button *back; - Button *forward; + + ConfirmationDialog *search_dialog; LineEdit *search; - String base_path; - HashMap<String,TreeItem*> tree_item_map; + String base_path; void _help_callback(const String& p_topic); @@ -133,25 +143,24 @@ class EditorHelp : public VBoxContainer { void _add_text(const String& p_text); bool scroll_locked; - void _button_pressed(int p_idx); + //void _button_pressed(int p_idx); void _add_type(const String& p_type); void _scroll_changed(double p_scroll); void _class_list_select(const String& p_select); void _class_desc_select(const String& p_select); - Error _goto_desc(const String& p_class,bool p_update_history=true,int p_vscr=-1); - void _update_history_buttons(); + Error _goto_desc(const String& p_class, int p_vscr=-1); + //void _update_history_buttons(); void _update_doc(); void _request_help(const String& p_string); void _search(const String& p_str); + void _search_cbk(); void _unhandled_key_input(const InputEvent& p_ev); - void add_type(const String& p_type,HashMap<String,TreeItem*>& p_types,TreeItem *p_root); - void _tree_item_selected(); - EditorHelpSearch *class_search; + protected: @@ -163,41 +172,25 @@ public: static void generate_doc(); static DocData *get_doc_data() { return doc; } - EditorHelp(EditorNode *p_editor=NULL); - ~EditorHelp(); -}; - - + void go_to_help(const String& p_help); + void go_to_class(const String& p_class,int p_scroll=0); -class EditorHelpPlugin : public EditorPlugin { + void popup_search(); + void search_again(); - OBJ_TYPE( EditorHelpPlugin, EditorPlugin ); + String get_class_name(); - EditorHelp *editor_help; - EditorNode *editor; -public: + void set_focused() { class_desc->grab_focus(); } - virtual String get_name() const { return "Help"; } - bool has_main_screen() const { return true; } - virtual void edit(Object *p_node); - virtual bool handles(Object *p_node) const; - virtual void make_visible(bool p_visible); - virtual void selected_notify(); + int get_scroll() const; + void set_scroll(int p_scroll); - Dictionary get_state() const; - virtual void set_state(const Dictionary& p_state); - virtual void clear(); - - virtual void save_external_data(); - virtual void apply_changes(); + EditorHelp(); + ~EditorHelp(); +}; - virtual void restore_global_state(); - virtual void save_global_state(); - EditorHelpPlugin(EditorNode *p_node); - ~EditorHelpPlugin(); -}; #endif // EDITOR_HELP_H diff --git a/tools/editor/editor_import_export.cpp b/tools/editor/editor_import_export.cpp index b13473e61c..e569485807 100644 --- a/tools/editor/editor_import_export.cpp +++ b/tools/editor/editor_import_export.cpp @@ -1706,6 +1706,17 @@ void EditorImportExport::load_config() { } } + if (cf->has_section("convert_samples")) { + + if (cf->has_section_key("convert_samples","max_hz")) + sample_action_max_hz=cf->get_value("convert_samples","max_hz"); + + if (cf->has_section_key("convert_samples","trim")) + sample_action_trim=cf->get_value("convert_samples","trim"); + } + + + } @@ -1816,6 +1827,14 @@ void EditorImportExport::save_config() { cf->set_value("script","encrypt_key",script_key); + switch(sample_action) { + case SAMPLE_ACTION_NONE: cf->set_value("convert_samples","action","none"); break; + case SAMPLE_ACTION_COMPRESS_RAM: cf->set_value("convert_samples","action","compress_ram"); break; + } + + cf->set_value("convert_samples","max_hz",sample_action_max_hz); + cf->set_value("convert_samples","trim",sample_action_trim); + cf->save("res://export.cfg"); } @@ -1841,6 +1860,35 @@ String EditorImportExport::script_get_encryption_key() const{ } +void EditorImportExport::sample_set_action(SampleAction p_action) { + + sample_action=p_action; +} + +EditorImportExport::SampleAction EditorImportExport::sample_get_action() const{ + + return sample_action; +} + +void EditorImportExport::sample_set_max_hz(int p_hz){ + + sample_action_max_hz=p_hz; +} +int EditorImportExport::sample_get_max_hz() const{ + + return sample_action_max_hz; +} + +void EditorImportExport::sample_set_trim(bool p_trim){ + + sample_action_trim=p_trim; +} +bool EditorImportExport::sample_get_trim() const{ + + return sample_action_trim; +} + + void EditorImportExport::_bind_methods() { ObjectTypeDB::bind_method(_MD("image_export_group_create"),&EditorImportExport::image_export_group_create); @@ -1868,8 +1916,13 @@ EditorImportExport::EditorImportExport() { image_formats.insert("png"); image_shrink=1; + script_action=SCRIPT_ACTION_COMPILE; + sample_action=SAMPLE_ACTION_NONE; + sample_action_max_hz=44100; + sample_action_trim=false; + } diff --git a/tools/editor/editor_import_export.h b/tools/editor/editor_import_export.h index 245adffbfd..1a3171e66b 100644 --- a/tools/editor/editor_import_export.h +++ b/tools/editor/editor_import_export.h @@ -245,6 +245,12 @@ public: SCRIPT_ACTION_ENCRYPT }; + enum SampleAction { + + SAMPLE_ACTION_NONE, + SAMPLE_ACTION_COMPRESS_RAM, + }; + protected: struct ImageGroup { @@ -274,6 +280,10 @@ protected: ScriptAction script_action; String script_key; + SampleAction sample_action; + int sample_action_max_hz; + bool sample_action_trim; + static EditorImportExport* singleton; static void _bind_methods(); @@ -343,6 +353,15 @@ public: void script_set_encryption_key(const String& p_key); String script_get_encryption_key() const; + void sample_set_action(SampleAction p_action); + SampleAction sample_get_action() const; + + void sample_set_max_hz(int p_hz); + int sample_get_max_hz() const; + + void sample_set_trim(bool p_trim); + bool sample_get_trim() const; + void load_config(); void save_config(); diff --git a/tools/editor/editor_log.cpp b/tools/editor/editor_log.cpp index 2d26490a8a..264117eecd 100644 --- a/tools/editor/editor_log.cpp +++ b/tools/editor/editor_log.cpp @@ -81,6 +81,7 @@ void EditorLog::_notification(int p_what) { log->add_color_override("default_color",get_color("font_color","Tree")); tb->set_normal_texture( get_icon("Collapse","EditorIcons")); tb->set_hover_texture( get_icon("CollapseHl","EditorIcons")); + //button->set_icon(get_icon("Console","EditorIcons")); } @@ -125,6 +126,7 @@ void EditorLog::add_message(const String& p_msg,bool p_error) { log->push_color(get_color("fg_error","Editor")); } else { button->set_icon(Ref<Texture>()); + } @@ -154,17 +156,20 @@ void EditorLog::_dragged(const Point2& p_ofs) { */ -ToolButton *EditorLog::get_button() { +Button *EditorLog::get_button() { return button; } void EditorLog::_flip_request() { - if (is_visible()) + if (is_visible()) { hide(); - else + button->show(); + } else { show(); + button->hide(); + } } void EditorLog::_undo_redo_cbk(void *p_self,const String& p_name) { @@ -200,7 +205,7 @@ EditorLog::EditorLog() { hb->add_child(title); - button = memnew( ToolButton ); + button = memnew( Button ); button->set_text_align(Button::ALIGN_LEFT); button->connect("pressed",this,"_flip_request"); button->set_focus_mode(FOCUS_NONE); diff --git a/tools/editor/editor_log.h b/tools/editor/editor_log.h index 6950ffa1a0..93044f9a2d 100644 --- a/tools/editor/editor_log.h +++ b/tools/editor/editor_log.h @@ -44,7 +44,7 @@ class EditorLog : public PanelContainer { OBJ_TYPE( EditorLog, PanelContainer ); - ToolButton *button; + Button *button; Button *clearbutton; Label *title; RichTextLabel *log; @@ -73,7 +73,7 @@ public: void add_message(const String& p_msg, bool p_error=false); void deinit(); - ToolButton *get_button(); + Button *get_button(); void clear(); EditorLog(); ~EditorLog(); diff --git a/tools/editor/editor_node.cpp b/tools/editor/editor_node.cpp index 34e2510791..5412211b28 100644 --- a/tools/editor/editor_node.cpp +++ b/tools/editor/editor_node.cpp @@ -111,6 +111,8 @@ EditorNode *EditorNode::singleton=NULL; void EditorNode::_update_scene_tabs() { + bool show_rb = EditorSettings::get_singleton()->get("global/show_script_in_scene_tabs"); + 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++) { @@ -133,7 +135,7 @@ 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); - if (editor_data.get_scene_root_script(i).is_valid()) { + if (show_rb && editor_data.get_scene_root_script(i).is_valid()) { scene_tabs->set_tab_right_button(i,script_icon); } @@ -163,13 +165,13 @@ void EditorNode::_unhandled_input(const InputEvent& p_event) { switch(p_event.key.scancode) { - case KEY_F1: + /*case KEY_F1: if (!p_event.key.mod.shift && !p_event.key.mod.command) _editor_select(3); - break; - case KEY_F2: _editor_select(0); break; - case KEY_F3: _editor_select(1); break; - case KEY_F4: _editor_select(2); break; + break;*/ + case KEY_F1: _editor_select(0); break; + case KEY_F2: _editor_select(1); break; + case KEY_F3: _editor_select(2); break; case KEY_F5: _menu_option_confirm((p_event.key.mod.control&&p_event.key.mod.shift)?RUN_PLAY_CUSTOM_SCENE:RUN_PLAY,true); break; case KEY_F6: _menu_option_confirm(RUN_PLAY_SCENE,true); break; case KEY_F7: _menu_option_confirm(RUN_PAUSE,true); break; @@ -1617,10 +1619,8 @@ void EditorNode::_edit_current() { for(int i=0;i<editor_table.size();i++) { - if (editor_table[i]==main_plugin) { - main_editor_tabs->set_current_tab(i); - break; - } + + main_editor_buttons[i]->set_pressed(editor_table[i]==main_plugin); } } @@ -2846,7 +2846,7 @@ Control* EditorNode::get_viewport() { void EditorNode::_editor_select(int p_which) { static bool selecting=false; - if (selecting) + if (selecting || changing_scene) return; selecting=true; @@ -2854,7 +2854,9 @@ void EditorNode::_editor_select(int p_which) { ERR_FAIL_INDEX(p_which,editor_table.size()); - main_editor_tabs->set_current_tab(p_which); + for(int i=0;i<main_editor_buttons.size();i++) { + main_editor_buttons[i]->set_pressed(i==p_which); + } selecting=false; @@ -2872,6 +2874,8 @@ void EditorNode::_editor_select(int p_which) { editor_plugin_screen=new_editor; editor_plugin_screen->make_visible(true); editor_plugin_screen->selected_notify(); + + } void EditorNode::add_editor_plugin(EditorPlugin *p_editor) { @@ -2879,7 +2883,12 @@ void EditorNode::add_editor_plugin(EditorPlugin *p_editor) { if (p_editor->has_main_screen()) { - singleton->main_editor_tabs->add_tab(p_editor->get_name()); + ToolButton *tb = memnew( ToolButton ); + tb->set_toggle_mode(true); + tb->connect("pressed",singleton,"_editor_select",varray(singleton->main_editor_buttons.size())); + tb->set_text(p_editor->get_name()); + singleton->main_editor_buttons.push_back(tb); + singleton->main_editor_button_vb->add_child(tb); singleton->editor_table.push_back(p_editor); } singleton->editor_data.add_editor_plugin( p_editor ); @@ -2891,16 +2900,18 @@ void EditorNode::remove_editor_plugin(EditorPlugin *p_editor) { if (p_editor->has_main_screen()) { - for(int i=0;i<singleton->main_editor_tabs->get_tab_count();i++) { + for(int i=0;i<singleton->main_editor_buttons.size();i++) { - if (p_editor->get_name()==singleton->main_editor_tabs->get_tab_title(i)) { + if (p_editor->get_name()==singleton->main_editor_buttons[i]->get_name()) { + + memdelete( singleton->main_editor_buttons[i] ); + singleton->main_editor_buttons.remove(i); - singleton->main_editor_tabs->remove_tab(i); break; } } - singleton->main_editor_tabs->add_tab(p_editor->get_name()); + //singleton->main_editor_tabs->add_tab(p_editor->get_name()); singleton->editor_table.erase(p_editor); } singleton->remove_child(p_editor); @@ -2946,6 +2957,20 @@ void EditorNode::_remove_edited_scene() { unsaved_cache=false; } } + +void EditorNode::_remove_scene(int index) { +// printf("Attempting to remove scene %d (current is %d)\n", index, editor_data.get_edited_scene()); + if (editor_data.get_edited_scene() == index) { + //Scene to remove is current scene + _remove_edited_scene(); + } + else { + // Scene to remove is not active scene."); + editor_data.remove_scene(index); + editor_data.get_undo_redo().clear_history(); + } +} + void EditorNode::set_edited_scene(Node *p_scene) { if (get_editor_data().get_edited_scene_root()) { @@ -3195,10 +3220,20 @@ Error EditorNode::save_optimized_copy(const String& p_scene,const String& p_pres } +int EditorNode::_get_current_main_editor() { + + for(int i=0;i<editor_table.size();i++) { + if (editor_table[i]==editor_plugin_screen) + return i; + } + + return 0; +} + Dictionary EditorNode::_get_main_scene_state() { Dictionary state; - state["main_tab"]=main_editor_tabs->get_current_tab(); + state["main_tab"]=_get_current_main_editor(); state["scene_tree_offset"]=scene_tree_dock->get_tree_editor()->get_scene_tree()->get_vscroll_bar()->get_val(); state["property_edit_offset"]=get_property_editor()->get_scene_tree()->get_vscroll_bar()->get_val(); state["saved_version"]=saved_version; @@ -3209,9 +3244,14 @@ Dictionary EditorNode::_get_main_scene_state() { void EditorNode::_set_main_scene_state(Dictionary p_state) { //print_line("set current 7 "); + changing_scene=false; +#if 0 if (p_state.has("main_tab")) { int idx = p_state["main_tab"]; + + + print_line("comes with tab: "+itos(idx)); int current=-1; for(int i=0;i<editor_table.size();i++) { if (editor_plugin_screen==editor_table[i]) { @@ -3220,12 +3260,41 @@ void EditorNode::_set_main_scene_state(Dictionary p_state) { } } + if (idx<2 && current<2) { //only set tab for 2D and 3D - _editor_select(p_state["main_tab"]); + _editor_select(idx); //print_line(" setting main tab: "+itos(p_state["main_tab"])); } } +#else + + if (get_edited_scene()) { + + int current=-1; + for(int i=0;i<editor_table.size();i++) { + if (editor_plugin_screen==editor_table[i]) { + current=i; + break; + } + } + + if (current<2) { + //use heuristic instead + + int n2d=0,n3d=0; + _find_node_types(get_edited_scene(),n2d,n3d); + if (n2d>n3d) { + _editor_select(0); + } else if (n3d>n2d) { + _editor_select(1); + + } + } + + } +#endif + if (p_state.has("scene_tree_offset")) scene_tree_dock->get_tree_editor()->get_scene_tree()->get_vscroll_bar()->set_val(p_state["scene_tree_offset"]); @@ -3234,6 +3303,12 @@ void EditorNode::_set_main_scene_state(Dictionary p_state) { //print_line("set current 8 "); + //this should only happen at the very end + + //changing_scene=true; //avoid script change from opening editor + ScriptEditor::get_singleton()->get_debugger()->update_live_edit_root(); + ScriptEditor::get_singleton()->set_scene_root_script( editor_data.get_scene_root_script(editor_data.get_edited_scene()) ); + //changing_scene=false; } @@ -3298,8 +3373,6 @@ void EditorNode::set_current_scene(int p_idx) { call_deferred("_set_main_scene_state",state); //do after everything else is done setting up //print_line("set current 6 "); - changing_scene=false; - ScriptEditor::get_singleton()->get_debugger()->update_live_edit_root(); } @@ -4390,12 +4463,7 @@ void EditorNode::_scene_tab_script_edited(int p_tab) { } void EditorNode::_scene_tab_closed(int p_tab) { - set_current_scene(p_tab); - bool p_confirmed = true; - if (unsaved_cache) - p_confirmed = false; - - _menu_option_confirm(FILE_CLOSE, p_confirmed); + _remove_scene(p_tab); _update_scene_tabs(); } @@ -4542,6 +4610,7 @@ EditorNode::EditorNode() { gui_base->add_child(main_vbox); main_vbox->set_area_as_parent_rect(8); +#if 0 PanelContainer *top_dark_panel = memnew( PanelContainer ); Ref<StyleBoxTexture> top_dark_sb; top_dark_sb.instance();; @@ -4557,21 +4626,14 @@ EditorNode::EditorNode() { VBoxContainer *top_dark_vb = memnew( VBoxContainer ); main_vbox->add_child(top_dark_panel); top_dark_panel->add_child(top_dark_vb); - +#endif menu_hb = memnew( HBoxContainer ); - top_dark_vb->add_child(menu_hb); + main_vbox->add_child(menu_hb); - scene_tabs=memnew( Tabs ); - scene_tabs->add_tab("unsaved"); - scene_tabs->set_tab_align(Tabs::ALIGN_CENTER); - scene_tabs->set_tab_close_display_policy(Tabs::SHOW_HOVER); - scene_tabs->connect("tab_changed",this,"_scene_tab_changed"); - scene_tabs->connect("right_button_pressed",this,"_scene_tab_script_edited"); - scene_tabs->connect("tab_close", this, "_scene_tab_closed"); - top_dark_vb->add_child(scene_tabs); +// top_dark_vb->add_child(scene_tabs); //left left_l_hsplit = memnew( HSplitContainer ); main_vbox->add_child(left_l_hsplit); @@ -4604,11 +4666,15 @@ EditorNode::EditorNode() { main_hsplit = memnew( HSplitContainer ); left_r_hsplit->add_child(main_hsplit); //main_split->set_v_size_flags(Control::SIZE_EXPAND_FILL); + VBoxContainer * center_vb = memnew( VBoxContainer); + main_hsplit->add_child(center_vb); + center_vb->set_h_size_flags(Control::SIZE_EXPAND_FILL); center_split = memnew( VSplitContainer ); - main_hsplit->add_child(center_split); - center_split->set_h_size_flags(Control::SIZE_EXPAND_FILL); + //main_hsplit->add_child(center_split); + center_split->set_v_size_flags(Control::SIZE_EXPAND_FILL); center_split->set_collapsed(false); + center_vb->add_child(center_split); right_hsplit = memnew( HSplitContainer ); main_hsplit->add_child(right_hsplit); @@ -4705,20 +4771,19 @@ EditorNode::EditorNode() { srt->add_constant_override("separation",0); - main_editor_tabs = memnew( Tabs ); +/* main_editor_tabs = memnew( Tabs ); main_editor_tabs->connect("tab_changed",this,"_editor_select"); main_editor_tabs->set_tab_close_display_policy(Tabs::SHOW_NEVER); - HBoxContainer *srth = memnew( HBoxContainer ); - srt->add_child( srth ); - Control *tec = memnew( Control ); - tec->set_custom_minimum_size(Size2(100,0)); - tec->set_h_size_flags(Control::SIZE_EXPAND_FILL); - srth->add_child(tec); - srth->add_child(main_editor_tabs); - tec = memnew( Control ); - tec->set_custom_minimum_size(Size2(100,0)); - srth->add_child(tec); - tec->set_h_size_flags(Control::SIZE_EXPAND_FILL); +*/ + scene_tabs=memnew( Tabs ); + scene_tabs->add_tab("unsaved"); + scene_tabs->set_tab_align(Tabs::ALIGN_CENTER); + scene_tabs->set_tab_close_display_policy(Tabs::SHOW_ACTIVE_ONLY); + scene_tabs->connect("tab_changed",this,"_scene_tab_changed"); + scene_tabs->connect("right_button_pressed",this,"_scene_tab_script_edited"); + scene_tabs->connect("tab_close", this, "_scene_tab_closed"); + + srt->add_child(scene_tabs); scene_root_parent = memnew( Panel ); @@ -4795,6 +4860,8 @@ EditorNode::EditorNode() { anim_close->set_pressed_texture( anim_close->get_icon("Close","EditorIcons")); + + PanelContainer *top_region = memnew( PanelContainer ); top_region->add_style_override("panel",gui_base->get_stylebox("hover","Button")); HBoxContainer *left_menu_hb = memnew( HBoxContainer ); @@ -4871,6 +4938,18 @@ EditorNode::EditorNode() { p->add_child(recent_scenes); recent_scenes->connect("item_pressed",this,"_open_recent_scene"); + { + Control *sp = memnew( Control ); + sp->set_custom_minimum_size(Size2(30,0)); + menu_hb->add_child(sp); + } + + PanelContainer *editor_region = memnew( PanelContainer ); + editor_region->add_style_override("panel",gui_base->get_stylebox("hover","Button")); + main_editor_button_vb = memnew( HBoxContainer ); + editor_region->add_child(main_editor_button_vb); + menu_hb->add_child(editor_region); + //menu_hb->add_spacer(); #if 0 node_menu = memnew( MenuButton ); @@ -5031,6 +5110,39 @@ EditorNode::EditorNode() { */ + progress_hb = memnew( BackgroundProgress ); + menu_hb->add_child(progress_hb); + + { + Control *sp = memnew( Control ); + sp->set_custom_minimum_size(Size2(30,0)); + menu_hb->add_child(sp); + } + + + PanelContainer *vu_cont = memnew( PanelContainer ); + vu_cont->add_style_override("panel",gui_base->get_stylebox("hover","Button")); + menu_hb->add_child(vu_cont); + + audio_vu = memnew( TextureProgress ); + CenterContainer *vu_cc = memnew( CenterContainer ); + vu_cc->add_child(audio_vu); + vu_cont->add_child(vu_cc); + audio_vu->set_under_texture(gui_base->get_icon("VuEmpty","EditorIcons")); + audio_vu->set_progress_texture(gui_base->get_icon("VuFull","EditorIcons")); + audio_vu->set_max(24); + audio_vu->set_min(-80); + audio_vu->set_step(0.01); + audio_vu->set_val(0); + + { + Control *sp = memnew( Control ); + sp->set_custom_minimum_size(Size2(30,0)); + menu_hb->add_child(sp); + } + + + top_region = memnew( PanelContainer ); top_region->add_style_override("panel",gui_base->get_stylebox("hover","Button")); HBoxContainer *right_menu_hb = memnew( HBoxContainer ); @@ -5062,6 +5174,15 @@ EditorNode::EditorNode() { sources_button->connect("pressed",this,"_menu_option",varray(SOURCES_REIMPORT)); sources_button->set_tooltip("Alerts when an external resource has changed."); + update_menu = memnew( MenuButton ); + update_menu->set_tooltip("Spins when the editor window repaints!"); + right_menu_hb->add_child(update_menu); + update_menu->set_icon(gui_base->get_icon("Progress1","EditorIcons")); + p=update_menu->get_popup(); + p->add_check_item("Update Always",SETTINGS_UPDATE_ALWAYS); + p->add_check_item("Update Changes",SETTINGS_UPDATE_CHANGES); + p->set_item_checked(1,true); + //sources_button->connect(); /* @@ -5164,6 +5285,7 @@ EditorNode::EditorNode() { editor_history_menu = memnew( MenuButton ); + editor_history_menu->set_tooltip("History of recently edited objects"); editor_history_menu->set_icon( gui_base->get_icon("History","EditorIcons")); prop_editor_hb->add_child(editor_history_menu); editor_history_menu->connect("about_to_show",this,"_prepare_history"); @@ -5215,6 +5337,8 @@ EditorNode::EditorNode() { log->connect("close_request",this,"_close_messages"); log->connect("show_request",this,"_show_messages"); //left_split->set_dragger_visible(false); + + old_split_ofs=0; @@ -5232,37 +5356,18 @@ EditorNode::EditorNode() { animation_editor->hide(); - PanelContainer *bottom_pc = memnew( PanelContainer ); - main_vbox->add_child(bottom_pc); + /*PanelContainer *bottom_pc = memnew( PanelContainer ); + srt->add_child(bottom_pc); bottom_hb = memnew( HBoxContainer ); - bottom_pc->add_child(bottom_hb); + bottom_pc->add_child(bottom_hb);*/ - bottom_hb->add_child( log->get_button() ); + center_vb->add_child( log->get_button() ); log->get_button()->set_h_size_flags(Control::SIZE_EXPAND_FILL); - progress_hb = memnew( BackgroundProgress ); - bottom_hb->add_child(progress_hb); + //progress_hb->set_h_size_flags(Control::SIZE_EXPAND_FILL); - audio_vu = memnew( TextureProgress ); - CenterContainer *vu_cc = memnew( CenterContainer ); - vu_cc->add_child(audio_vu); - bottom_hb->add_child(vu_cc); - audio_vu->set_under_texture(gui_base->get_icon("VuEmpty","EditorIcons")); - audio_vu->set_progress_texture(gui_base->get_icon("VuFull","EditorIcons")); - audio_vu->set_max(24); - audio_vu->set_min(-80); - audio_vu->set_step(0.01); - audio_vu->set_val(0); - update_menu = memnew( MenuButton ); - update_menu->set_tooltip("Spins when the editor window repaints!"); - bottom_hb->add_child(update_menu); - update_menu->set_icon(gui_base->get_icon("Progress1","EditorIcons")); - p=update_menu->get_popup(); - p->add_check_item("Update Always",SETTINGS_UPDATE_ALWAYS); - p->add_check_item("Update Changes",SETTINGS_UPDATE_CHANGES); - p->set_item_checked(1,true); /* animation_menu = memnew( ToolButton ); @@ -5479,11 +5584,11 @@ EditorNode::EditorNode() { editor_import_export->add_import_plugin( Ref<EditorTranslationImportPlugin>( memnew(EditorTranslationImportPlugin(this)))); editor_import_export->add_export_plugin( Ref<EditorTextureExportPlugin>( memnew(EditorTextureExportPlugin))); + editor_import_export->add_export_plugin( Ref<EditorSampleExportPlugin>( memnew(EditorSampleExportPlugin))); add_editor_plugin( memnew( CanvasItemEditorPlugin(this) ) ); add_editor_plugin( memnew( SpatialEditorPlugin(this) ) ); add_editor_plugin( memnew( ScriptEditorPlugin(this) ) ); - add_editor_plugin( memnew( EditorHelpPlugin(this) ) ); add_editor_plugin( memnew( AnimationPlayerEditorPlugin(this) ) ); add_editor_plugin( memnew( ShaderGraphEditorPlugin(this,true) ) ); add_editor_plugin( memnew( ShaderGraphEditorPlugin(this,false) ) ); @@ -5550,9 +5655,9 @@ EditorNode::EditorNode() { Globals::get_singleton()->set("debug/indicators_enabled",true); Globals::get_singleton()->set("render/room_cull_enabled",false); - theme->set_color("prop_category","Editor",Color::hex(0x403d41ff)); - theme->set_color("prop_section","Editor",Color::hex(0x383539ff)); - theme->set_color("prop_subsection","Editor",Color::hex(0x343135ff)); + theme->set_color("prop_category","Editor",Color::hex(0x3f3a44ff)); + theme->set_color("prop_section","Editor",Color::hex(0x35313aff)); + theme->set_color("prop_subsection","Editor",Color::hex(0x312e37ff)); theme->set_color("fg_selected","Editor",Color::html("ffbd8e8e")); theme->set_color("fg_error","Editor",Color::html("ffbd8e8e")); @@ -5659,6 +5764,7 @@ EditorNode::EditorNode() { EditorNode::~EditorNode() { + memdelete( EditorHelp::get_doc_data() ); memdelete(editor_selection); memdelete(file_server); EditorSettings::destroy(); diff --git a/tools/editor/editor_node.h b/tools/editor/editor_node.h index 978e8390dc..bd88e1a4b9 100644 --- a/tools/editor/editor_node.h +++ b/tools/editor/editor_node.h @@ -314,7 +314,9 @@ class EditorNode : public Node { CenterContainer *tabs_center; EditorQuickOpen *quick_open; EditorQuickOpen *quick_run; - Tabs *main_editor_tabs; + + HBoxContainer *main_editor_button_vb; + Vector<ToolButton*> main_editor_buttons; Vector<EditorPlugin*> editor_table; EditorReImportDialog *reimport_dialog; @@ -461,6 +463,7 @@ class EditorNode : public Node { void _cleanup_scene(); void _remove_edited_scene(); + void _remove_scene(int index); bool _find_and_save_resource(RES p_res,Map<RES,bool>& processed,int32_t flags); bool _find_and_save_edited_subresources(Object *obj,Map<RES,bool>& processed,int32_t flags); void _save_edited_subresources(Node* scene,Map<RES,bool>& processed,int32_t flags); @@ -507,6 +510,8 @@ class EditorNode : public Node { Dictionary _get_main_scene_state(); void _set_main_scene_state(Dictionary p_state); + int _get_current_main_editor(); + void _save_docks(); void _load_docks(); diff --git a/tools/editor/editor_settings.cpp b/tools/editor/editor_settings.cpp index 651b30c724..15de6e7266 100644 --- a/tools/editor/editor_settings.cpp +++ b/tools/editor/editor_settings.cpp @@ -447,7 +447,7 @@ void EditorSettings::_load_defaults() { hints["global/default_project_path"]=PropertyInfo(Variant::STRING,"global/default_project_path",PROPERTY_HINT_GLOBAL_DIR); set("global/default_project_export_path",""); hints["global/default_project_export_path"]=PropertyInfo(Variant::STRING,"global/default_project_export_path",PROPERTY_HINT_GLOBAL_DIR); - + set("global/show_script_in_scene_tabs",false); set("text_editor/background_color",Color::html("3b000000")); set("text_editor/text_color",Color::html("aaaaaa")); set("text_editor/text_selected_color",Color::html("000000")); diff --git a/tools/editor/icons/icon_back.png b/tools/editor/icons/icon_back.png Binary files differindex d60e3b2640..f7e507d92b 100644 --- a/tools/editor/icons/icon_back.png +++ b/tools/editor/icons/icon_back.png diff --git a/tools/editor/icons/icon_class_list.png b/tools/editor/icons/icon_class_list.png Binary files differnew file mode 100644 index 0000000000..fb756c0fe1 --- /dev/null +++ b/tools/editor/icons/icon_class_list.png diff --git a/tools/editor/icons/icon_forward.png b/tools/editor/icons/icon_forward.png Binary files differindex ca6838ae9e..14e8bc9a5a 100644 --- a/tools/editor/icons/icon_forward.png +++ b/tools/editor/icons/icon_forward.png diff --git a/tools/editor/icons/icon_godot.png b/tools/editor/icons/icon_godot.png Binary files differnew file mode 100644 index 0000000000..e80820fc10 --- /dev/null +++ b/tools/editor/icons/icon_godot.png diff --git a/tools/editor/icons/icon_help.png b/tools/editor/icons/icon_help.png Binary files differindex 3f4f8453a7..d2085589ae 100644 --- a/tools/editor/icons/icon_help.png +++ b/tools/editor/icons/icon_help.png diff --git a/tools/editor/icons/icon_multi_edit.png b/tools/editor/icons/icon_multi_edit.png Binary files differnew file mode 100644 index 0000000000..70faee3d6a --- /dev/null +++ b/tools/editor/icons/icon_multi_edit.png diff --git a/tools/editor/io_plugins/editor_atlas.cpp b/tools/editor/io_plugins/editor_atlas.cpp index 4a260a9a6f..7e9acd193d 100644 --- a/tools/editor/io_plugins/editor_atlas.cpp +++ b/tools/editor/io_plugins/editor_atlas.cpp @@ -27,7 +27,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "editor_atlas.h" - +#include "print_string.h" struct _EditorAtlasWorkRect { @@ -83,6 +83,7 @@ void EditorAtlas::fit(const Vector<Size2i>& p_rects,Vector<Point2i>& r_result, S //place them int ofs=0; int limit_h=0; + for(int j=0;j<wrects.size();j++) { @@ -100,6 +101,9 @@ void EditorAtlas::fit(const Vector<Size2i>& p_rects,Vector<Point2i>& r_result, S wrects[j].p.x=ofs; wrects[j].p.y=from_y; + + + int end_h = from_y+wrects[j].s.height; int end_w = ofs+wrects[j].s.width; if (ofs==0) @@ -116,7 +120,7 @@ void EditorAtlas::fit(const Vector<Size2i>& p_rects,Vector<Point2i>& r_result, S if (end_w > max_w) max_w=end_w; - if (ofs==0 || end_h>limit_h ) //while h limit not reched, keep stacking + //if (ofs==0 || end_h>limit_h ) //while h limit not reched, keep stacking ofs+=wrects[j].s.width; } @@ -136,8 +140,8 @@ void EditorAtlas::fit(const Vector<Size2i>& p_rects,Vector<Point2i>& r_result, S for(int i=0;i<results.size();i++) { - float h = nearest_power_of_2(results[i].max_h); - float w = nearest_power_of_2(results[i].max_w); + float h = results[i].max_h; + float w = results[i].max_w; float aspect = h>w ? h/w : w/h; if (aspect < best_aspect) { best=i; diff --git a/tools/editor/io_plugins/editor_sample_import_plugin.cpp b/tools/editor/io_plugins/editor_sample_import_plugin.cpp index 9298b35b3b..7888246956 100644 --- a/tools/editor/io_plugins/editor_sample_import_plugin.cpp +++ b/tools/editor/io_plugins/editor_sample_import_plugin.cpp @@ -35,6 +35,7 @@ #include "io/resource_saver.h" #include "os/file_access.h" #include "io/marshalls.h" +#include "tools/editor/editor_settings.h" class _EditorSampleImportOptions : public Object { @@ -156,7 +157,7 @@ public: edit_normalize=true; edit_loop=false; - compress_mode=COMPRESS_MODE_DISABLED; + compress_mode=COMPRESS_MODE_RAM; compress_bitrate=COMPRESS_128; } @@ -580,8 +581,7 @@ Error EditorSampleImportPlugin::import(const String& p_path, const Ref<ResourceI int compression = from->get_option("compress/mode"); bool force_mono = from->get_option("force/mono"); - if (compression==_EditorSampleImportOptions::COMPRESS_MODE_RAM) - force_mono=true; + if (force_mono && chans==2) { @@ -608,9 +608,47 @@ Error EditorSampleImportPlugin::import(const String& p_path, const Ref<ResourceI if ( compression == _EditorSampleImportOptions::COMPRESS_MODE_RAM) { dst_format=Sample::FORMAT_IMA_ADPCM; + if (chans==1) { + _compress_ima_adpcm(data,dst_data); + } else { + + print_line("INTERLEAAVE!"); + + + + //byte interleave + Vector<float> left; + Vector<float> right; + + int tlen = data.size()/2; + left.resize(tlen); + right.resize(tlen); + + for(int i=0;i<tlen;i++) { + left[i]=data[i*2+0]; + right[i]=data[i*2+1]; + } + + DVector<uint8_t> bleft; + DVector<uint8_t> bright; - _compress_ima_adpcm(data,dst_data); - print_line("compressing ima-adpcm, resulting buffersize is "+itos(dst_data.size())+" from "+itos(data.size())); + _compress_ima_adpcm(left,bleft); + _compress_ima_adpcm(right,bright); + + int dl = bleft.size(); + dst_data.resize( dl *2 ); + + DVector<uint8_t>::Write w=dst_data.write(); + DVector<uint8_t>::Read rl=bleft.read(); + DVector<uint8_t>::Read rr=bright.read(); + + for(int i=0;i<dl;i++) { + w[i*2+0]=rl[i]; + w[i*2+1]=rr[i]; + } + } + +// print_line("compressing ima-adpcm, resulting buffersize is "+itos(dst_data.size())+" from "+itos(data.size())); } else { @@ -781,9 +819,54 @@ void EditorSampleImportPlugin::_compress_ima_adpcm(const Vector<float>& p_data,D } + +EditorSampleImportPlugin* EditorSampleImportPlugin::singleton=NULL; + + + EditorSampleImportPlugin::EditorSampleImportPlugin(EditorNode* p_editor) { + singleton=this; dialog = memnew( EditorSampleImportDialog(this)); p_editor->get_gui_base()->add_child(dialog); } +Vector<uint8_t> EditorSampleExportPlugin::custom_export(String& p_path,const Ref<EditorExportPlatform> &p_platform) { + + + + if (EditorImportExport::get_singleton()->sample_get_action()==EditorImportExport::SAMPLE_ACTION_NONE || p_path.extension().to_lower()!="wav") { + + return Vector<uint8_t>(); + } + + Ref<ResourceImportMetadata> imd = memnew( ResourceImportMetadata ); + + imd->add_source(EditorImportPlugin::validate_source_path(p_path)); + + imd->set_option("force/8_bit",false); + imd->set_option("force/mono",false); + imd->set_option("force/max_rate",true); + imd->set_option("force/max_rate_hz",EditorImportExport::get_singleton()->sample_get_max_hz()); + imd->set_option("edit/trim",EditorImportExport::get_singleton()->sample_get_trim()); + imd->set_option("edit/normalize",false); + imd->set_option("edit/loop",false); + imd->set_option("compress/mode",1); + + String savepath = EditorSettings::get_singleton()->get_settings_path().plus_file("tmp/smpconv.smp"); + Error err = EditorSampleImportPlugin::singleton->import(savepath,imd); + + + ERR_FAIL_COND_V(err!=OK,Vector<uint8_t>()); + + p_path=p_path.basename()+".smp"; + return FileAccess::get_file_as_array(savepath); + +} + + +EditorSampleExportPlugin::EditorSampleExportPlugin() { + +} + + diff --git a/tools/editor/io_plugins/editor_sample_import_plugin.h b/tools/editor/io_plugins/editor_sample_import_plugin.h index 03a4d38ab3..89319affa0 100644 --- a/tools/editor/io_plugins/editor_sample_import_plugin.h +++ b/tools/editor/io_plugins/editor_sample_import_plugin.h @@ -43,6 +43,8 @@ class EditorSampleImportPlugin : public EditorImportPlugin { void _compress_ima_adpcm(const Vector<float>& p_data,DVector<uint8_t>& dst_data); public: + static EditorSampleImportPlugin *singleton; + virtual String get_name() const; virtual String get_visible_name() const; virtual void import_dialog(const String& p_from=""); @@ -52,4 +54,16 @@ public: EditorSampleImportPlugin(EditorNode* p_editor); }; +class EditorSampleExportPlugin : public EditorExportPlugin { + + OBJ_TYPE( EditorSampleExportPlugin, EditorExportPlugin); + + +public: + + virtual Vector<uint8_t> custom_export(String& p_path,const Ref<EditorExportPlatform> &p_platform); + + EditorSampleExportPlugin(); +}; + #endif // EDITOR_SAMPLE_IMPORT_PLUGIN_H diff --git a/tools/editor/io_plugins/editor_texture_import_plugin.h b/tools/editor/io_plugins/editor_texture_import_plugin.h index 78383d1d77..38fd671e9d 100644 --- a/tools/editor/io_plugins/editor_texture_import_plugin.h +++ b/tools/editor/io_plugins/editor_texture_import_plugin.h @@ -123,6 +123,7 @@ public: virtual Vector<uint8_t> custom_export(String& p_path,const Ref<EditorExportPlatform> &p_platform); EditorTextureExportPlugin(); }; + class EditorImportTextureOptions : public VBoxContainer { OBJ_TYPE( EditorImportTextureOptions, VBoxContainer ); diff --git a/tools/editor/plugins/collision_shape_2d_editor_plugin.cpp b/tools/editor/plugins/collision_shape_2d_editor_plugin.cpp index 62cf1b4acb..f56b9a2fd9 100644 --- a/tools/editor/plugins/collision_shape_2d_editor_plugin.cpp +++ b/tools/editor/plugins/collision_shape_2d_editor_plugin.cpp @@ -115,6 +115,18 @@ void CollisionShape2DEditor::set_handle(int idx, Point2& p_point) { } break; case LINE_SHAPE: { + if (idx<2) { + Ref<LineShape2D> line = node->get_shape(); + + if (idx==0){ + line->set_d(p_point.length()); + }else{ + line->set_normal(p_point/30.0); + } + + canvas_item_editor->get_viewport_control()->update(); + } + } break; @@ -200,6 +212,19 @@ void CollisionShape2DEditor::commit_handle(int idx, Variant& p_org) { } break; case LINE_SHAPE: { + Ref<LineShape2D> line = node->get_shape(); + + if (idx==0) { + undo_redo->add_do_method(line.ptr(),"set_d",line->get_d()); + undo_redo->add_do_method(c,"update"); + undo_redo->add_undo_method(line.ptr(),"set_d",p_org); + undo_redo->add_undo_method(c,"update"); + } else { + undo_redo->add_do_method(line.ptr(),"set_normal",line->get_normal()); + undo_redo->add_do_method(c,"update"); + undo_redo->add_undo_method(line.ptr(),"set_normal",p_org); + undo_redo->add_undo_method(c,"update"); + } } break; @@ -418,6 +443,14 @@ void CollisionShape2DEditor::_canvas_draw() { } break; case LINE_SHAPE: { + Ref<LineShape2D> shape = node->get_shape(); + + handles.resize(2); + handles[0] = shape->get_normal() * shape->get_d(); + handles[1] = shape->get_normal() * (shape->get_d() + 30.0); + + c->draw_texture(h,gt.xform(handles[0])-size); + c->draw_texture(h,gt.xform(handles[1])-size); } break; diff --git a/tools/editor/plugins/editor_preview_plugins.cpp b/tools/editor/plugins/editor_preview_plugins.cpp index c2b3ecfcda..5f52d4c3e7 100644 --- a/tools/editor/plugins/editor_preview_plugins.cpp +++ b/tools/editor/plugins/editor_preview_plugins.cpp @@ -491,8 +491,14 @@ Ref<Texture> EditorSamplePreviewPlugin::generate(const RES& p_from) { ima_adpcm.last_nibble++; const uint8_t *src_ptr=sdata; + int ofs = ima_adpcm.last_nibble>>1; + + if (stereo) + ofs*=2; + + nibble = (ima_adpcm.last_nibble&1)? - (src_ptr[ima_adpcm.last_nibble>>1]>>4):(src_ptr[ima_adpcm.last_nibble>>1]&0xF); + (src_ptr[ofs]>>4):(src_ptr[ofs]&0xF); step=_ima_adpcm_step_table[ima_adpcm.step_index]; ima_adpcm.step_index += _ima_adpcm_index_table[nibble]; diff --git a/tools/editor/plugins/sample_editor_plugin.cpp b/tools/editor/plugins/sample_editor_plugin.cpp index 31fa7246ae..d88f2adc73 100644 --- a/tools/editor/plugins/sample_editor_plugin.cpp +++ b/tools/editor/plugins/sample_editor_plugin.cpp @@ -156,8 +156,14 @@ void SampleEditor::generate_preview_texture(const Ref<Sample>& p_sample,Ref<Imag ima_adpcm.last_nibble++; const uint8_t *src_ptr=sdata; + int ofs = ima_adpcm.last_nibble>>1; + + if (stereo) + ofs*=2; + nibble = (ima_adpcm.last_nibble&1)? - (src_ptr[ima_adpcm.last_nibble>>1]>>4):(src_ptr[ima_adpcm.last_nibble>>1]&0xF); + (src_ptr[ofs]>>4):(src_ptr[ofs]&0xF); + step=_ima_adpcm_step_table[ima_adpcm.step_index]; ima_adpcm.step_index += _ima_adpcm_index_table[nibble]; diff --git a/tools/editor/plugins/script_editor_plugin.cpp b/tools/editor/plugins/script_editor_plugin.cpp index bd0f580a34..65ed420a51 100644 --- a/tools/editor/plugins/script_editor_plugin.cpp +++ b/tools/editor/plugins/script_editor_plugin.cpp @@ -572,28 +572,119 @@ void ScriptEditor::_goto_script_line(REF p_script,int p_line) { } + +void ScriptEditor::_update_history_arrows() { + + script_back->set_disabled( history_pos<=0 ); + script_forward->set_disabled( history_pos>=history.size()-1 ); +} + + +void ScriptEditor::_go_to_tab(int p_idx) { + + Node *cn = tab_container->get_child(p_idx); + if (!cn) + return; + Control *c = cn->cast_to<Control>(); + if (!c) + return; + + if (history_pos>=0 && history_pos<history.size() && history[history_pos].control==tab_container->get_current_tab_control()) { + + Node *n = tab_container->get_current_tab_control(); + + if (n->cast_to<ScriptTextEditor>()) { + + history[history_pos].scroll_pos=n->cast_to<ScriptTextEditor>()->get_text_edit()->get_v_scroll(); + history[history_pos].cursor_column=n->cast_to<ScriptTextEditor>()->get_text_edit()->cursor_get_column(); + history[history_pos].cursor_row=n->cast_to<ScriptTextEditor>()->get_text_edit()->cursor_get_line(); + } + if (n->cast_to<EditorHelp>()) { + + history[history_pos].scroll_pos=n->cast_to<EditorHelp>()->get_scroll(); + } + } + + history.resize(history_pos+1); + ScriptHistory sh; + sh.control=c; + sh.scroll_pos=0; + + history.push_back(sh); + history_pos++; + + + tab_container->set_current_tab(p_idx); + + c = tab_container->get_current_tab_control(); + + if (c->cast_to<ScriptTextEditor>()) { + + script_name_label->set_text(c->cast_to<ScriptTextEditor>()->get_name()); + script_icon->set_texture(c->cast_to<ScriptTextEditor>()->get_icon()); + if (is_visible()) + c->cast_to<ScriptTextEditor>()->get_text_edit()->grab_focus(); + } + if (c->cast_to<EditorHelp>()) { + + script_name_label->set_text(c->cast_to<EditorHelp>()->get_class_name()); + script_icon->set_texture(get_icon("Help","EditorIcons")); + if (is_visible()) + c->cast_to<EditorHelp>()->set_focused(); + } + + + + c->set_meta("__editor_pass",++edit_pass); + _update_history_arrows(); + _update_script_colors(); +} + void ScriptEditor::_close_current_tab() { int selected = tab_container->get_current_tab(); if (selected<0 || selected>=tab_container->get_child_count()) return; + Node *tselected = tab_container->get_child(selected); ScriptTextEditor *current = tab_container->get_child(selected)->cast_to<ScriptTextEditor>(); - if (!current) - return; + if (current) { + apply_scripts(); + } - apply_scripts(); + //remove from history + history.resize(history_pos+1); + + for(int i=0;i<history.size();i++) { + if (history[i].control==tselected) { + history.remove(i); + i--; + history_pos--; + } + } + + if (history_pos>=history.size()) { + history_pos=history.size()-1; + } int idx = tab_container->get_current_tab(); - memdelete(current); + memdelete(tselected); if (idx>=tab_container->get_child_count()) idx=tab_container->get_child_count()-1; if (idx>=0) { + + if (history_pos>=0) { + idx = history[history_pos].control->get_index(); + } tab_container->set_current_tab(idx); + //script_list->select(idx); } + _update_history_arrows(); + + _update_script_names(); EditorNode::get_singleton()->save_layout(); @@ -755,33 +846,15 @@ void ScriptEditor::swap_lines(TextEdit *tx, int line1, int line2) void ScriptEditor::_menu_option(int p_option) { - if (p_option==FILE_OPEN) { - editor->open_resource("Script"); - return; - } - int selected = tab_container->get_current_tab(); - if (selected<0 || selected>=tab_container->get_child_count()) - return; - - ScriptTextEditor *current = tab_container->get_child(selected)->cast_to<ScriptTextEditor>(); - if (!current) - return; - switch(p_option) { case FILE_NEW: { script_create_dialog->config("Node", ".gd"); script_create_dialog->popup_centered(Size2(300, 300)); } break; - case FILE_SAVE: { - if (!_test_script_times_on_disk()) - return; - editor->save_resource( current->get_edited_script() ); - - } break; - case FILE_SAVE_AS: { - - editor->save_resource_as( current->get_edited_script() ); + case FILE_OPEN: { + editor->open_resource("Script"); + return; } break; case FILE_SAVE_ALL: { @@ -806,387 +879,470 @@ void ScriptEditor::_menu_option(int p_option) { } break; - case EDIT_UNDO: { - current->get_text_edit()->undo(); - current->get_text_edit()->call_deferred("grab_focus"); - } break; - case EDIT_REDO: { - current->get_text_edit()->redo(); - current->get_text_edit()->call_deferred("grab_focus"); - } break; - case EDIT_CUT: { - - current->get_text_edit()->cut(); - current->get_text_edit()->call_deferred("grab_focus"); - } break; - case EDIT_COPY: { - current->get_text_edit()->copy(); - current->get_text_edit()->call_deferred("grab_focus"); - - } break; - case EDIT_PASTE: { - current->get_text_edit()->paste(); - current->get_text_edit()->call_deferred("grab_focus"); + case SEARCH_HELP: { + help_search_dialog->popup("current"); } break; - case EDIT_SELECT_ALL: { - - current->get_text_edit()->select_all(); - current->get_text_edit()->call_deferred("grab_focus"); + case SEARCH_CLASSES: { - } break; - case EDIT_MOVE_LINE_UP: { - - TextEdit *tx = current->get_text_edit(); - Ref<Script> scr = current->get_edited_script(); - if (scr.is_null()) - return; - - if (tx->is_selection_active()) - { - int from_line = tx->get_selection_from_line(); - int from_col = tx->get_selection_from_column(); - int to_line = tx->get_selection_to_line(); - int to_column = tx->get_selection_to_column(); - - for (int i = from_line; i <= to_line; i++) - { - int line_id = i; - int next_id = i - 1; - - if (line_id == 0 || next_id < 0) - return; - - swap_lines(tx, line_id, next_id); - } - int from_line_up = from_line > 0 ? from_line-1 : from_line; - int to_line_up = to_line > 0 ? to_line-1 : to_line; - tx->select(from_line_up, from_col, to_line_up, to_column); - } - else - { - int line_id = tx->cursor_get_line(); - int next_id = line_id - 1; - - if (line_id == 0 || next_id < 0) - return; - - swap_lines(tx, line_id, next_id); - } - tx->update(); - - } break; - case EDIT_MOVE_LINE_DOWN: { - - TextEdit *tx = current->get_text_edit(); - Ref<Script> scr = current->get_edited_script(); - if (scr.is_null()) - return; - - if (tx->is_selection_active()) - { - int from_line = tx->get_selection_from_line(); - int from_col = tx->get_selection_from_column(); - int to_line = tx->get_selection_to_line(); - int to_column = tx->get_selection_to_column(); - - for (int i = to_line; i >= from_line; i--) - { - int line_id = i; - int next_id = i + 1; - - if (line_id == tx->get_line_count()-1 || next_id > tx->get_line_count()) - return; - - swap_lines(tx, line_id, next_id); - } - int from_line_down = from_line < tx->get_line_count() ? from_line+1 : from_line; - int to_line_down = to_line < tx->get_line_count() ? to_line+1 : to_line; - tx->select(from_line_down, from_col, to_line_down, to_column); - } - else - { - int line_id = tx->cursor_get_line(); - int next_id = line_id + 1; - - if (line_id == tx->get_line_count()-1 || next_id > tx->get_line_count()) - return; - - swap_lines(tx, line_id, next_id); - } - tx->update(); - - } break; - case EDIT_INDENT_LEFT: { - - TextEdit *tx = current->get_text_edit(); - Ref<Script> scr = current->get_edited_script(); - if (scr.is_null()) - return; - - - if (tx->is_selection_active()) - { - int begin = tx->get_selection_from_line(); - int end = tx->get_selection_to_line(); - for (int i = begin; i <= end; i++) - { - String line_text = tx->get_line(i); - // begins with tab - if (line_text.begins_with("\t")) - { - line_text = line_text.substr(1, line_text.length()); - tx->set_line(i, line_text); - } - // begins with 4 spaces - else if (line_text.begins_with(" ")) - { - line_text = line_text.substr(4, line_text.length()); - tx->set_line(i, line_text); - } - } - } - else - { - int begin = tx->cursor_get_line(); - String line_text = tx->get_line(begin); - // begins with tab - if (line_text.begins_with("\t")) - { - line_text = line_text.substr(1, line_text.length()); - tx->set_line(begin, line_text); - } - // begins with 4 spaces - else if (line_text.begins_with(" ")) - { - line_text = line_text.substr(4, line_text.length()); - tx->set_line(begin, line_text); - } - } - tx->update(); - //tx->deselect(); - - } break; - case EDIT_INDENT_RIGHT: { - - TextEdit *tx = current->get_text_edit(); - Ref<Script> scr = current->get_edited_script(); - if (scr.is_null()) - return; - - if (tx->is_selection_active()) - { - int begin = tx->get_selection_from_line(); - int end = tx->get_selection_to_line(); - for (int i = begin; i <= end; i++) - { - String line_text = tx->get_line(i); - line_text = '\t' + line_text; - tx->set_line(i, line_text); - } - } - else - { - int begin = tx->cursor_get_line(); - String line_text = tx->get_line(begin); - line_text = '\t' + line_text; - tx->set_line(begin, line_text); - } - tx->update(); - //tx->deselect(); - - } break; - case EDIT_CLONE_DOWN: { - - TextEdit *tx = current->get_text_edit(); - Ref<Script> scr = current->get_edited_script(); - if (scr.is_null()) - return; - int line = tx->cursor_get_line(); - int next_line = line + 1; - - if (line == tx->get_line_count() || next_line > tx->get_line_count()) - return; - - String line_clone = tx->get_line(line); - tx->insert_at(line_clone, next_line); - tx->update(); - - } break; - case EDIT_TOGGLE_COMMENT: { - - TextEdit *tx = current->get_text_edit(); - Ref<Script> scr = current->get_edited_script(); - if (scr.is_null()) - return; - - - - if (tx->is_selection_active()) - { - int begin = tx->get_selection_from_line(); - int end = tx->get_selection_to_line(); - for (int i = begin; i <= end; i++) - { - String line_text = tx->get_line(i); - - if (line_text.begins_with("#")) - line_text = line_text.substr(1, line_text.length()); - else - line_text = "#" + line_text; - tx->set_line(i, line_text); - } - } - else - { - int begin = tx->cursor_get_line(); - String line_text = tx->get_line(begin); - - if (line_text.begins_with("#")) - line_text = line_text.substr(1, line_text.length()); - else - line_text = "#" + line_text; - tx->set_line(begin, line_text); - } - tx->update(); - //tx->deselect(); - - } break; - case EDIT_COMPLETE: { - - current->get_text_edit()->query_code_comple(); + if (tab_container->get_tab_count()==0) + break; - } break; - case EDIT_AUTO_INDENT: { + String current; - TextEdit *te = current->get_text_edit(); - String text = te->get_text(); - Ref<Script> scr = current->get_edited_script(); - if (scr.is_null()) - return; - int begin,end; - if (te->is_selection_active()) { - begin=te->get_selection_from_line(); - end=te->get_selection_to_line(); - } else { - begin=0; - end=te->get_line_count()-1; + EditorHelp *eh = tab_container->get_child( tab_container->get_current_tab() )->cast_to<EditorHelp>(); + if (eh) { + current=eh->get_class_name(); } - scr->get_language()->auto_indent_code(text,begin,end); - te->set_text(text); + help_index->popup_centered_ratio(0.6); + if (current!="") { + help_index->call_deferred("select_class",current); + } } break; - case SEARCH_FIND: { + case SEARCH_WEBSITE: { - find_replace_dialog->set_text_edit(current->get_text_edit()); - find_replace_dialog->popup_search(); + OS::get_singleton()->shell_open("http://www.godotengine.org/projects/godot-engine/wiki/Documentation#Tutorials"); } break; - case SEARCH_FIND_NEXT: { - find_replace_dialog->set_text_edit(current->get_text_edit()); - find_replace_dialog->search_next(); - } break; - case SEARCH_REPLACE: { + case WINDOW_NEXT: { - find_replace_dialog->set_text_edit(current->get_text_edit()); - find_replace_dialog->popup_replace(); + _history_forward(); } break; - case SEARCH_LOCATE_FUNCTION: { - - if (!current) - return; - quick_open->popup(current->get_functions()); + case WINDOW_PREV: { + _history_back(); } break; - case SEARCH_GOTO_LINE: { - goto_line_dialog->popup_find_line(current->get_text_edit()); - } break; - case DEBUG_TOGGLE_BREAKPOINT: { - int line=current->get_text_edit()->cursor_get_line(); - bool dobreak = !current->get_text_edit()->is_line_set_as_breakpoint(line); - current->get_text_edit()->set_line_as_breakpoint(line,dobreak); - get_debugger()->set_breakpoint(current->get_edited_script()->get_path(),line+1,dobreak); - } break; - case DEBUG_NEXT: { + } - if (debugger) - debugger->debug_next(); - } break; - case DEBUG_STEP: { - if (debugger) - debugger->debug_step(); + int selected = tab_container->get_current_tab(); + if (selected<0 || selected>=tab_container->get_child_count()) + return; - } break; - case DEBUG_BREAK: { + ScriptTextEditor *current = tab_container->get_child(selected)->cast_to<ScriptTextEditor>(); + if (current) { + + switch(p_option) { + case FILE_NEW: { + script_create_dialog->config("Node", ".gd"); + script_create_dialog->popup_centered(Size2(300, 300)); + } break; + case FILE_SAVE: { + if (!_test_script_times_on_disk()) + return; + editor->save_resource( current->get_edited_script() ); + + } break; + case FILE_SAVE_AS: { + + editor->save_resource_as( current->get_edited_script() ); + + } break; + case EDIT_UNDO: { + current->get_text_edit()->undo(); + current->get_text_edit()->call_deferred("grab_focus"); + } break; + case EDIT_REDO: { + current->get_text_edit()->redo(); + current->get_text_edit()->call_deferred("grab_focus"); + } break; + case EDIT_CUT: { + + current->get_text_edit()->cut(); + current->get_text_edit()->call_deferred("grab_focus"); + } break; + case EDIT_COPY: { + current->get_text_edit()->copy(); + current->get_text_edit()->call_deferred("grab_focus"); + + } break; + case EDIT_PASTE: { + current->get_text_edit()->paste(); + current->get_text_edit()->call_deferred("grab_focus"); + + } break; + case EDIT_SELECT_ALL: { + + current->get_text_edit()->select_all(); + current->get_text_edit()->call_deferred("grab_focus"); + + } break; + case EDIT_MOVE_LINE_UP: { + + TextEdit *tx = current->get_text_edit(); + Ref<Script> scr = current->get_edited_script(); + if (scr.is_null()) + return; + + if (tx->is_selection_active()) + { + int from_line = tx->get_selection_from_line(); + int from_col = tx->get_selection_from_column(); + int to_line = tx->get_selection_to_line(); + int to_column = tx->get_selection_to_column(); + + for (int i = from_line; i <= to_line; i++) + { + int line_id = i; + int next_id = i - 1; + + if (line_id == 0 || next_id < 0) + return; + + swap_lines(tx, line_id, next_id); + } + int from_line_up = from_line > 0 ? from_line-1 : from_line; + int to_line_up = to_line > 0 ? to_line-1 : to_line; + tx->select(from_line_up, from_col, to_line_up, to_column); + } + else + { + int line_id = tx->cursor_get_line(); + int next_id = line_id - 1; - if (debugger) - debugger->debug_break(); + if (line_id == 0 || next_id < 0) + return; - } break; - case DEBUG_CONTINUE: { + swap_lines(tx, line_id, next_id); + } + tx->update(); + + } break; + case EDIT_MOVE_LINE_DOWN: { + + TextEdit *tx = current->get_text_edit(); + Ref<Script> scr = current->get_edited_script(); + if (scr.is_null()) + return; + + if (tx->is_selection_active()) + { + int from_line = tx->get_selection_from_line(); + int from_col = tx->get_selection_from_column(); + int to_line = tx->get_selection_to_line(); + int to_column = tx->get_selection_to_column(); + + for (int i = to_line; i >= from_line; i--) + { + int line_id = i; + int next_id = i + 1; + + if (line_id == tx->get_line_count()-1 || next_id > tx->get_line_count()) + return; + + swap_lines(tx, line_id, next_id); + } + int from_line_down = from_line < tx->get_line_count() ? from_line+1 : from_line; + int to_line_down = to_line < tx->get_line_count() ? to_line+1 : to_line; + tx->select(from_line_down, from_col, to_line_down, to_column); + } + else + { + int line_id = tx->cursor_get_line(); + int next_id = line_id + 1; - if (debugger) - debugger->debug_continue(); + if (line_id == tx->get_line_count()-1 || next_id > tx->get_line_count()) + return; - } break; - case DEBUG_SHOW: { - if (debugger) { - bool visible = debug_menu->get_popup()->is_item_checked( debug_menu->get_popup()->get_item_index(DEBUG_SHOW) ); - debug_menu->get_popup()->set_item_checked( debug_menu->get_popup()->get_item_index(DEBUG_SHOW), !visible); - if (visible) - debugger->hide(); + swap_lines(tx, line_id, next_id); + } + tx->update(); + + } break; + case EDIT_INDENT_LEFT: { + + TextEdit *tx = current->get_text_edit(); + Ref<Script> scr = current->get_edited_script(); + if (scr.is_null()) + return; + + + if (tx->is_selection_active()) + { + int begin = tx->get_selection_from_line(); + int end = tx->get_selection_to_line(); + for (int i = begin; i <= end; i++) + { + String line_text = tx->get_line(i); + // begins with tab + if (line_text.begins_with("\t")) + { + line_text = line_text.substr(1, line_text.length()); + tx->set_line(i, line_text); + } + // begins with 4 spaces + else if (line_text.begins_with(" ")) + { + line_text = line_text.substr(4, line_text.length()); + tx->set_line(i, line_text); + } + } + } else - debugger->show(); - } - } break; - case HELP_CONTEXTUAL: { - String text = current->get_text_edit()->get_selection_text(); - if (text == "") - text = current->get_text_edit()->get_word_under_cursor(); - if (text != "") - editor->emit_signal("request_help", text); - } break; - case FILE_CLOSE: { - if (current->get_text_edit()->get_version()!=current->get_text_edit()->get_saved_version()) { - erase_tab_confirm->set_text("Close and save changes?\n\""+current->get_name()+"\""); - erase_tab_confirm->popup_centered_minsize(); - } else { - _close_current_tab(); - } - } break; - case WINDOW_MOVE_LEFT: { + { + int begin = tx->cursor_get_line(); + String line_text = tx->get_line(begin); + // begins with tab + if (line_text.begins_with("\t")) + { + line_text = line_text.substr(1, line_text.length()); + tx->set_line(begin, line_text); + } + // begins with 4 spaces + else if (line_text.begins_with(" ")) + { + line_text = line_text.substr(4, line_text.length()); + tx->set_line(begin, line_text); + } + } + tx->update(); + //tx->deselect(); + + } break; + case EDIT_INDENT_RIGHT: { + + TextEdit *tx = current->get_text_edit(); + Ref<Script> scr = current->get_edited_script(); + if (scr.is_null()) + return; + + if (tx->is_selection_active()) + { + int begin = tx->get_selection_from_line(); + int end = tx->get_selection_to_line(); + for (int i = begin; i <= end; i++) + { + String line_text = tx->get_line(i); + line_text = '\t' + line_text; + tx->set_line(i, line_text); + } + } + else + { + int begin = tx->cursor_get_line(); + String line_text = tx->get_line(begin); + line_text = '\t' + line_text; + tx->set_line(begin, line_text); + } + tx->update(); + //tx->deselect(); + + } break; + case EDIT_CLONE_DOWN: { + + TextEdit *tx = current->get_text_edit(); + Ref<Script> scr = current->get_edited_script(); + if (scr.is_null()) + return; + int line = tx->cursor_get_line(); + int next_line = line + 1; + + if (line == tx->get_line_count() || next_line > tx->get_line_count()) + return; + + String line_clone = tx->get_line(line); + tx->insert_at(line_clone, next_line); + tx->update(); + + } break; + case EDIT_TOGGLE_COMMENT: { + + TextEdit *tx = current->get_text_edit(); + Ref<Script> scr = current->get_edited_script(); + if (scr.is_null()) + return; + + + + if (tx->is_selection_active()) + { + int begin = tx->get_selection_from_line(); + int end = tx->get_selection_to_line(); + for (int i = begin; i <= end; i++) + { + String line_text = tx->get_line(i); + + if (line_text.begins_with("#")) + line_text = line_text.substr(1, line_text.length()); + else + line_text = "#" + line_text; + tx->set_line(i, line_text); + } + } + else + { + int begin = tx->cursor_get_line(); + String line_text = tx->get_line(begin); + + if (line_text.begins_with("#")) + line_text = line_text.substr(1, line_text.length()); + else + line_text = "#" + line_text; + tx->set_line(begin, line_text); + } + tx->update(); + //tx->deselect(); + + } break; + case EDIT_COMPLETE: { + + current->get_text_edit()->query_code_comple(); + + } break; + case EDIT_AUTO_INDENT: { + + TextEdit *te = current->get_text_edit(); + String text = te->get_text(); + Ref<Script> scr = current->get_edited_script(); + if (scr.is_null()) + return; + int begin,end; + if (te->is_selection_active()) { + begin=te->get_selection_from_line(); + end=te->get_selection_to_line(); + } else { + begin=0; + end=te->get_line_count()-1; + } + scr->get_language()->auto_indent_code(text,begin,end); + te->set_text(text); + + + } break; + case SEARCH_FIND: { + + find_replace_dialog->set_text_edit(current->get_text_edit()); + find_replace_dialog->popup_search(); + } break; + case SEARCH_FIND_NEXT: { + + find_replace_dialog->set_text_edit(current->get_text_edit()); + find_replace_dialog->search_next(); + } break; + case SEARCH_REPLACE: { + + find_replace_dialog->set_text_edit(current->get_text_edit()); + find_replace_dialog->popup_replace(); + } break; + case SEARCH_LOCATE_FUNCTION: { + + if (!current) + return; + quick_open->popup(current->get_functions()); + } break; + case SEARCH_GOTO_LINE: { + + goto_line_dialog->popup_find_line(current->get_text_edit()); + } break; + case DEBUG_TOGGLE_BREAKPOINT: { + int line=current->get_text_edit()->cursor_get_line(); + bool dobreak = !current->get_text_edit()->is_line_set_as_breakpoint(line); + current->get_text_edit()->set_line_as_breakpoint(line,dobreak); + get_debugger()->set_breakpoint(current->get_edited_script()->get_path(),line+1,dobreak); + } break; + case DEBUG_NEXT: { + + if (debugger) + debugger->debug_next(); + } break; + case DEBUG_STEP: { + + if (debugger) + debugger->debug_step(); + + } break; + case DEBUG_BREAK: { + + if (debugger) + debugger->debug_break(); + + } break; + case DEBUG_CONTINUE: { + + if (debugger) + debugger->debug_continue(); + + } break; + case DEBUG_SHOW: { + if (debugger) { + bool visible = debug_menu->get_popup()->is_item_checked( debug_menu->get_popup()->get_item_index(DEBUG_SHOW) ); + debug_menu->get_popup()->set_item_checked( debug_menu->get_popup()->get_item_index(DEBUG_SHOW), !visible); + if (visible) + debugger->hide(); + else + debugger->show(); + } + } break; + case HELP_CONTEXTUAL: { + String text = current->get_text_edit()->get_selection_text(); + if (text == "") + text = current->get_text_edit()->get_word_under_cursor(); + if (text != "") + help_search_dialog->popup(text); + } break; + case FILE_CLOSE: { + if (current->get_text_edit()->get_version()!=current->get_text_edit()->get_saved_version()) { + erase_tab_confirm->set_text("Close and save changes?\n\""+current->get_name()+"\""); + erase_tab_confirm->popup_centered_minsize(); + } else { + _close_current_tab(); + } + } break; + case WINDOW_MOVE_LEFT: { + + if (tab_container->get_current_tab()>0) { + tab_container->call_deferred("set_current_tab",tab_container->get_current_tab()-1); + script_list->call_deferred("select",tab_container->get_current_tab()-1); + tab_container->move_child(current,tab_container->get_current_tab()-1); + _update_script_names(); + } + } break; + case WINDOW_MOVE_RIGHT: { + + if (tab_container->get_current_tab()<tab_container->get_child_count()-1) { + tab_container->call_deferred("set_current_tab",tab_container->get_current_tab()+1); + script_list->call_deferred("select",tab_container->get_current_tab()+1); + tab_container->move_child(current,tab_container->get_current_tab()+1); + _update_script_names(); + } - if (tab_container->get_current_tab()>0) { - tab_container->call_deferred("set_current_tab",tab_container->get_current_tab()-1); - script_list->call_deferred("select",tab_container->get_current_tab()-1); - tab_container->move_child(current,tab_container->get_current_tab()-1); - _update_script_names(); - } - } break; - case WINDOW_MOVE_RIGHT: { - if (tab_container->get_current_tab()<tab_container->get_child_count()-1) { - tab_container->call_deferred("set_current_tab",tab_container->get_current_tab()+1); - script_list->call_deferred("select",tab_container->get_current_tab()+1); - tab_container->move_child(current,tab_container->get_current_tab()+1); - _update_script_names(); + } break; + + default: { + + if (p_option>=WINDOW_SELECT_BASE) { + + tab_container->set_current_tab(p_option-WINDOW_SELECT_BASE); + script_list->select(p_option-WINDOW_SELECT_BASE); + + } } + } + } + EditorHelp *help = tab_container->get_child(selected)->cast_to<EditorHelp>(); + if (help) { - } break; - default: { + switch(p_option) { - if (p_option>=WINDOW_SELECT_BASE) { + case SEARCH_FIND: { + help->popup_search(); + } break; + case SEARCH_FIND_NEXT: { + help->search_again(); + } break; + case FILE_CLOSE: { + _close_current_tab(); + } break; - tab_container->set_current_tab(p_option-WINDOW_SELECT_BASE); - script_list->select(p_option-WINDOW_SELECT_BASE); - } } } + } void ScriptEditor::_tab_changed(int p_which) { @@ -1217,6 +1373,14 @@ void ScriptEditor::_notification(int p_what) { } EditorSettings::get_singleton()->connect("settings_changed",this,"_editor_settings_changed"); + help_search->set_icon(get_icon("Help","EditorIcons")); + site_search->set_icon(get_icon("Godot","EditorIcons")); + class_search->set_icon(get_icon("ClassList","EditorIcons")); + + script_forward->set_icon(get_icon("Forward","EditorIcons")); + script_back->set_icon(get_icon("Back","EditorIcons")); + + } @@ -1346,7 +1510,7 @@ void ScriptEditor::set_state(const Dictionary& p_state) { } void ScriptEditor::clear() { - +#if 0 List<ScriptTextEditor*> stes; for(int i=0;i<tab_container->get_child_count();i++) { @@ -1371,7 +1535,7 @@ void ScriptEditor::clear() { script_list->select( script_list->find_metadata(idx) ); } - +#endif } @@ -1402,31 +1566,6 @@ void ScriptEditor::get_breakpoints(List<String> *p_breakpoints) { -void ScriptEditor::_bind_methods() { - - ObjectTypeDB::bind_method("_tab_changed",&ScriptEditor::_tab_changed); - ObjectTypeDB::bind_method("_menu_option",&ScriptEditor::_menu_option); - ObjectTypeDB::bind_method("_close_current_tab",&ScriptEditor::_close_current_tab); - ObjectTypeDB::bind_method("_editor_play",&ScriptEditor::_editor_play); - ObjectTypeDB::bind_method("_editor_pause",&ScriptEditor::_editor_pause); - ObjectTypeDB::bind_method("_editor_stop",&ScriptEditor::_editor_stop); - ObjectTypeDB::bind_method("_add_callback",&ScriptEditor::_add_callback); - ObjectTypeDB::bind_method("_reload_scripts",&ScriptEditor::_reload_scripts); - ObjectTypeDB::bind_method("_resave_scripts",&ScriptEditor::_resave_scripts); - ObjectTypeDB::bind_method("_res_saved_callback",&ScriptEditor::_res_saved_callback); - ObjectTypeDB::bind_method("_goto_script_line",&ScriptEditor::_goto_script_line); - ObjectTypeDB::bind_method("_goto_script_line2",&ScriptEditor::_goto_script_line2); - ObjectTypeDB::bind_method("_breaked",&ScriptEditor::_breaked); - ObjectTypeDB::bind_method("_show_debugger",&ScriptEditor::_show_debugger); - ObjectTypeDB::bind_method("_get_debug_tooltip",&ScriptEditor::_get_debug_tooltip); - ObjectTypeDB::bind_method("_autosave_scripts",&ScriptEditor::_autosave_scripts); - ObjectTypeDB::bind_method("_editor_settings_changed",&ScriptEditor::_editor_settings_changed); - ObjectTypeDB::bind_method("_update_script_names",&ScriptEditor::_update_script_names); - ObjectTypeDB::bind_method("_tree_changed",&ScriptEditor::_tree_changed); - ObjectTypeDB::bind_method("_script_selected",&ScriptEditor::_script_selected); - ObjectTypeDB::bind_method("_script_created",&ScriptEditor::_script_created); - ObjectTypeDB::bind_method("_script_split_dragged",&ScriptEditor::_script_split_dragged); -} void ScriptEditor::ensure_focus_current() { @@ -1448,7 +1587,8 @@ void ScriptEditor::ensure_focus_current() { void ScriptEditor::_script_selected(int p_idx) { grab_focus_block = !Input::get_singleton()->is_mouse_button_pressed(1); //amazing hack, simply amazing - tab_container->set_current_tab(script_list->get_item_metadata(p_idx)); + + _go_to_tab(script_list->get_item_metadata(p_idx)); grab_focus_block=false; } @@ -1457,16 +1597,38 @@ void ScriptEditor::ensure_select_current() { if (tab_container->get_child_count() && tab_container->get_current_tab()>=0) { - ScriptTextEditor *ste = tab_container->get_child(tab_container->get_current_tab())->cast_to<ScriptTextEditor>(); - if (!ste) - return; - Ref<Script> script = ste->get_edited_script(); + Node *current = tab_container->get_child(tab_container->get_current_tab()); + + + ScriptTextEditor *ste = current->cast_to<ScriptTextEditor>(); + if (ste) { + + Ref<Script> script = ste->get_edited_script(); + + if (!grab_focus_block && is_inside_tree()) + ste->get_text_edit()->grab_focus(); + + edit_menu->show(); + search_menu->show(); + script_search_menu->hide(); + + + } + + EditorHelp *eh = current->cast_to<EditorHelp>(); - if (!grab_focus_block && is_inside_tree()) - ste->get_text_edit()->grab_focus(); + if (eh) { + edit_menu->hide(); + search_menu->hide(); + script_search_menu->show(); + + } } + + + } void ScriptEditor::_find_scripts(Node* p_base, Node* p_current, Set<Ref<Script> > &used) { @@ -1485,6 +1647,57 @@ void ScriptEditor::_find_scripts(Node* p_base, Node* p_current, Set<Ref<Script> } +struct _ScriptEditorItemData { + + String name; + Ref<Texture> icon; + int index; + String tooltip; + bool used; + int category; + + + bool operator<(const _ScriptEditorItemData& id) const { + + return category==id.category?name.nocasecmp_to(id.name)<0:category<id.category; + } + +}; + + +void ScriptEditor::_update_script_colors() { + + bool enabled = EditorSettings::get_singleton()->get("text_editor/script_temperature_enabled"); + if (!enabled) + return; + + int hist_size = EditorSettings::get_singleton()->get("text_editor/script_temperature_history_size"); + Color hot_color=EditorSettings::get_singleton()->get("text_editor/script_temperature_hot_color"); + Color cold_color=EditorSettings::get_singleton()->get("text_editor/script_temperature_cold_color"); + + for(int i=0;i<script_list->get_item_count();i++) { + + int c = script_list->get_item_metadata(i); + Node *n = tab_container->get_child(c); + if (!n) + continue; + + script_list->set_item_custom_bg_color(i,Color(0,0,0,0)); + if (!n->has_meta("__editor_pass")) { + continue; + } + + int pass=n->get_meta("__editor_pass"); + int h = edit_pass - pass; + if (h>hist_size) { + continue; + } + float v = Math::ease((edit_pass-pass)/float_t(hist_size),0.4); + + + script_list->set_item_custom_bg_color(i,hot_color.linear_interpolate(cold_color,v)); + } +} void ScriptEditor::_update_script_names() { @@ -1496,31 +1709,75 @@ void ScriptEditor::_update_script_names() { } script_list->clear(); + bool split_script_help = EditorSettings::get_singleton()->get("text_editor/group_help_pages"); + + Vector<_ScriptEditorItemData> sedata; + for(int i=0;i<tab_container->get_child_count();i++) { + ScriptTextEditor *ste = tab_container->get_child(i)->cast_to<ScriptTextEditor>(); - if (!ste) - continue; + if (ste) { - String script = ste->get_name(); - Ref<Texture> icon = ste->get_icon(); - String path = ste->get_edited_script()->get_path(); - script_list->add_item(script,icon); + String name = ste->get_name(); + Ref<Texture> icon = ste->get_icon(); + String tooltip = ste->get_edited_script()->get_path(); - int index = script_list->get_item_count()-1; + _ScriptEditorItemData sd; + sd.icon=icon; + sd.name=name; + sd.tooltip=tooltip; + sd.index=i; + sd.used=used.has(ste->get_edited_script()); + sd.category=0; + + sedata.push_back(sd); + } - script_list->set_item_tooltip(index,path); - script_list->set_item_metadata(index,i); - if (used.has(ste->get_edited_script())) { + EditorHelp *eh = tab_container->get_child(i)->cast_to<EditorHelp>(); + if (eh) { + + String name = eh->get_class_name(); + Ref<Texture> icon = get_icon("Help","EditorIcons"); + String tooltip = name+" Class Reference"; + + _ScriptEditorItemData sd; + sd.icon=icon; + sd.name=name; + sd.tooltip=tooltip; + sd.index=i; + sd.used=false; + sd.category=split_script_help?1:0; + sedata.push_back(sd); + + } + + } + + sedata.sort(); + + for(int i=0;i<sedata.size();i++) { + + script_list->add_item(sedata[i].name,sedata[i].icon); + int index = script_list->get_item_count()-1; + script_list->set_item_tooltip(index,sedata[i].tooltip); + script_list->set_item_metadata(index,sedata[i].index); + if (sedata[i].used) { script_list->set_item_custom_bg_color(index,Color(88/255.0,88/255.0,60/255.0)); } - if (tab_container->get_current_tab()==index) { + if (tab_container->get_current_tab()==sedata[i].index) { script_list->select(index); + script_name_label->set_text(sedata[i].name); + script_icon->set_texture(sedata[i].icon); + } } - script_list->sort_items_by_text(); + _update_script_colors(); + + + } @@ -1531,6 +1788,8 @@ void ScriptEditor::edit(const Ref<Script>& p_script) { // see if already has it + bool open_dominant = EditorSettings::get_singleton()->get("text_editor/open_dominant_script_on_scene_change"); + if (p_script->get_path().is_resource_file() && bool(EditorSettings::get_singleton()->get("external_editor/use_external_editor"))) { String path = EditorSettings::get_singleton()->get("external_editor/exec_path"); @@ -1559,12 +1818,13 @@ void ScriptEditor::edit(const Ref<Script>& p_script) { if (ste->get_edited_script()==p_script) { - if (!EditorNode::get_singleton()->is_changing_scene()) { + if (open_dominant || !EditorNode::get_singleton()->is_changing_scene()) { if (tab_container->get_current_tab()!=i) { - tab_container->set_current_tab(i); + _go_to_tab(i); script_list->select( script_list->find_metadata(i) ); } - ste->get_text_edit()->grab_focus(); + if (is_visible()) + ste->get_text_edit()->grab_focus(); } return; } @@ -1576,7 +1836,8 @@ void ScriptEditor::edit(const Ref<Script>& p_script) { ste->set_edited_script(p_script); ste->get_text_edit()->set_tooltip_request_func(this,"_get_debug_tooltip",ste); tab_container->add_child(ste); - tab_container->set_current_tab(tab_container->get_tab_count()-1); + _go_to_tab(tab_container->get_tab_count()-1); + @@ -1675,7 +1936,7 @@ void ScriptEditor::_add_callback(Object *p_obj, const String& p_function, const ste->get_text_edit()->insert_text_at_cursor("\n\n"+func); } - tab_container->set_current_tab(i); + _go_to_tab(i); ste->get_text_edit()->cursor_set_line(pos); ste->get_text_edit()->cursor_set_column(1); @@ -1726,10 +1987,13 @@ void ScriptEditor::set_window_layout(Ref<ConfigFile> p_layout) { return; } - if (!p_layout->has_section_key("ScriptEditor","open_scripts")) + if (!p_layout->has_section_key("ScriptEditor","open_scripts") && !p_layout->has_section_key("ScriptEditor","open_help")) return; Array scripts = p_layout->get_value("ScriptEditor","open_scripts"); + Array helps; + if (p_layout->has_section_key("ScriptEditor","open_help")) + helps=p_layout->get_value("ScriptEditor","open_help"); restoring_layout=true; @@ -1742,6 +2006,18 @@ void ScriptEditor::set_window_layout(Ref<ConfigFile> p_layout) { } } + + for(int i=0;i<helps.size();i++) { + + String path = helps[i]; + _help_class_open(path); + } + + for(int i=0;i<tab_container->get_child_count();i++) { + tab_container->get_child(i)->set_meta("__editor_pass",Variant()); + } + + if (p_layout->has_section_key("ScriptEditor","split_offset")) { script_split->set_split_offset(p_layout->get_value("ScriptEditor","split_offset")); } @@ -1754,27 +2030,184 @@ void ScriptEditor::set_window_layout(Ref<ConfigFile> p_layout) { void ScriptEditor::get_window_layout(Ref<ConfigFile> p_layout) { Array scripts; + Array helps; for(int i=0;i<tab_container->get_child_count();i++) { ScriptTextEditor *ste = tab_container->get_child(i)->cast_to<ScriptTextEditor>(); - if (!ste) - continue; + if (ste) { - String path = ste->get_edited_script()->get_path(); - if (!path.is_resource_file()) - continue; + String path = ste->get_edited_script()->get_path(); + if (!path.is_resource_file()) + continue; + + scripts.push_back(path); + } + + EditorHelp *eh = tab_container->get_child(i)->cast_to<EditorHelp>(); + + if (eh) { + + helps.push_back(eh->get_class_name()); + } - scripts.push_back(path); } p_layout->set_value("ScriptEditor","open_scripts",scripts); + p_layout->set_value("ScriptEditor","open_help",helps); p_layout->set_value("ScriptEditor","split_offset",script_split->get_split_offset()); } +void ScriptEditor::_help_class_open(const String& p_class) { + + + for(int i=0;i<tab_container->get_child_count();i++) { + + EditorHelp *eh = tab_container->get_child(i)->cast_to<EditorHelp>(); + + if (eh && eh->get_class_name()==p_class) { + + _go_to_tab(i); + _update_script_names(); + return; + } + } + + EditorHelp * eh = memnew( EditorHelp ); + + + eh->set_name(p_class); + tab_container->add_child(eh); + _go_to_tab(tab_container->get_tab_count()-1); + eh->go_to_class(p_class,0); + eh->connect("go_to_help",this,"_help_class_goto"); + _update_script_names(); + +} + +void ScriptEditor::_help_class_goto(const String& p_desc) { + + + String cname=p_desc.get_slice(":",1); + + for(int i=0;i<tab_container->get_child_count();i++) { + + EditorHelp *eh = tab_container->get_child(i)->cast_to<EditorHelp>(); + + if (eh && eh->get_class_name()==cname) { + + _go_to_tab(i); + eh->go_to_help(p_desc); + _update_script_names(); + return; + } + } + + EditorHelp * eh = memnew( EditorHelp ); + + eh->set_name(cname); + tab_container->add_child(eh); + _go_to_tab(tab_container->get_tab_count()-1); + eh->go_to_help(p_desc); + eh->connect("go_to_help",this,"_help_class_goto"); + _update_script_names(); + +} + +void ScriptEditor::_update_history_pos(int p_new_pos) { + + Node *n = tab_container->get_current_tab_control(); + + if (n->cast_to<ScriptTextEditor>()) { + + history[history_pos].scroll_pos=n->cast_to<ScriptTextEditor>()->get_text_edit()->get_v_scroll(); + history[history_pos].cursor_column=n->cast_to<ScriptTextEditor>()->get_text_edit()->cursor_get_column(); + history[history_pos].cursor_row=n->cast_to<ScriptTextEditor>()->get_text_edit()->cursor_get_line(); + } + if (n->cast_to<EditorHelp>()) { + + history[history_pos].scroll_pos=n->cast_to<EditorHelp>()->get_scroll(); + } + + history_pos=p_new_pos; + tab_container->set_current_tab(history[history_pos].control->get_index()); + + n = history[history_pos].control; + + if (n->cast_to<ScriptTextEditor>()) { + + n->cast_to<ScriptTextEditor>()->get_text_edit()->set_v_scroll(history[history_pos].scroll_pos); + n->cast_to<ScriptTextEditor>()->get_text_edit()->cursor_set_column( history[history_pos].cursor_column ); + n->cast_to<ScriptTextEditor>()->get_text_edit()->cursor_set_line( history[history_pos].cursor_row ); + n->cast_to<ScriptTextEditor>()->get_text_edit()->grab_focus(); + } + + if (n->cast_to<EditorHelp>()) { + + n->cast_to<EditorHelp>()->set_scroll(history[history_pos].scroll_pos); + n->cast_to<EditorHelp>()->set_focused(); + } + + n->set_meta("__editor_pass",++edit_pass); + _update_script_names(); + _update_history_arrows(); + +} + +void ScriptEditor::_history_forward() { + + if (history_pos<history.size()-1) { + _update_history_pos(history_pos+1); + } +} + +void ScriptEditor::_history_back(){ + + if (history_pos>0) { + _update_history_pos(history_pos-1); + } + +} +void ScriptEditor::set_scene_root_script( Ref<Script> p_script ) { + + bool open_dominant = EditorSettings::get_singleton()->get("text_editor/open_dominant_script_on_scene_change"); + if (open_dominant && p_script.is_valid()) { + edit(p_script); + } +} + +void ScriptEditor::_bind_methods() { + + ObjectTypeDB::bind_method("_tab_changed",&ScriptEditor::_tab_changed); + ObjectTypeDB::bind_method("_menu_option",&ScriptEditor::_menu_option); + ObjectTypeDB::bind_method("_close_current_tab",&ScriptEditor::_close_current_tab); + ObjectTypeDB::bind_method("_editor_play",&ScriptEditor::_editor_play); + ObjectTypeDB::bind_method("_editor_pause",&ScriptEditor::_editor_pause); + ObjectTypeDB::bind_method("_editor_stop",&ScriptEditor::_editor_stop); + ObjectTypeDB::bind_method("_add_callback",&ScriptEditor::_add_callback); + ObjectTypeDB::bind_method("_reload_scripts",&ScriptEditor::_reload_scripts); + ObjectTypeDB::bind_method("_resave_scripts",&ScriptEditor::_resave_scripts); + ObjectTypeDB::bind_method("_res_saved_callback",&ScriptEditor::_res_saved_callback); + ObjectTypeDB::bind_method("_goto_script_line",&ScriptEditor::_goto_script_line); + ObjectTypeDB::bind_method("_goto_script_line2",&ScriptEditor::_goto_script_line2); + ObjectTypeDB::bind_method("_breaked",&ScriptEditor::_breaked); + ObjectTypeDB::bind_method("_show_debugger",&ScriptEditor::_show_debugger); + ObjectTypeDB::bind_method("_get_debug_tooltip",&ScriptEditor::_get_debug_tooltip); + ObjectTypeDB::bind_method("_autosave_scripts",&ScriptEditor::_autosave_scripts); + ObjectTypeDB::bind_method("_editor_settings_changed",&ScriptEditor::_editor_settings_changed); + ObjectTypeDB::bind_method("_update_script_names",&ScriptEditor::_update_script_names); + ObjectTypeDB::bind_method("_tree_changed",&ScriptEditor::_tree_changed); + ObjectTypeDB::bind_method("_script_selected",&ScriptEditor::_script_selected); + ObjectTypeDB::bind_method("_script_created",&ScriptEditor::_script_created); + ObjectTypeDB::bind_method("_script_split_dragged",&ScriptEditor::_script_split_dragged); + ObjectTypeDB::bind_method("_help_class_open",&ScriptEditor::_help_class_open); + ObjectTypeDB::bind_method("_help_class_goto",&ScriptEditor::_help_class_goto); + ObjectTypeDB::bind_method("_history_forward",&ScriptEditor::_history_forward); + ObjectTypeDB::bind_method("_history_back",&ScriptEditor::_history_back); +} ScriptEditor::ScriptEditor(EditorNode *p_editor) { @@ -1816,6 +2249,9 @@ ScriptEditor::ScriptEditor(EditorNode *p_editor) { file_menu->get_popup()->add_item("Save As..",FILE_SAVE_AS); file_menu->get_popup()->add_item("Save All",FILE_SAVE_ALL,KEY_MASK_CMD|KEY_MASK_SHIFT|KEY_S); file_menu->get_popup()->add_separator(); + file_menu->get_popup()->add_item("History Prev",WINDOW_PREV,KEY_MASK_CTRL|KEY_MASK_ALT|KEY_LEFT); + file_menu->get_popup()->add_item("History Next",WINDOW_NEXT,KEY_MASK_CTRL|KEY_MASK_ALT|KEY_RIGHT); + file_menu->get_popup()->add_separator(); file_menu->get_popup()->add_item("Close",FILE_CLOSE,KEY_MASK_CMD|KEY_W); file_menu->get_popup()->connect("item_pressed", this,"_menu_option"); @@ -1851,13 +2287,22 @@ ScriptEditor::ScriptEditor(EditorNode *p_editor) { menu_hb->add_child(search_menu); search_menu->set_text("Search"); search_menu->get_popup()->add_item("Find..",SEARCH_FIND,KEY_MASK_CMD|KEY_F); - search_menu->get_popup()->add_item("Find Next",SEARCH_FIND_NEXT,KEY_MASK_CMD|KEY_G); + search_menu->get_popup()->add_item("Find Next",SEARCH_FIND_NEXT,KEY_F3); search_menu->get_popup()->add_item("Replace..",SEARCH_REPLACE,KEY_MASK_CMD|KEY_R); search_menu->get_popup()->add_separator(); search_menu->get_popup()->add_item("Goto Function..",SEARCH_LOCATE_FUNCTION,KEY_MASK_SHIFT|KEY_MASK_CMD|KEY_F); search_menu->get_popup()->add_item("Goto Line..",SEARCH_GOTO_LINE,KEY_MASK_CMD|KEY_L); search_menu->get_popup()->connect("item_pressed", this,"_menu_option"); + script_search_menu = memnew( MenuButton ); + menu_hb->add_child(script_search_menu); + script_search_menu->set_text("Search"); + script_search_menu->get_popup()->add_item("Find..",SEARCH_FIND,KEY_MASK_CMD|KEY_F); + script_search_menu->get_popup()->add_item("Find Next",SEARCH_FIND_NEXT,KEY_F3); + script_search_menu->get_popup()->connect("item_pressed", this,"_menu_option"); + script_search_menu->hide(); + + debug_menu = memnew( MenuButton ); menu_hb->add_child(debug_menu); debug_menu->set_text("Debug"); @@ -1897,6 +2342,53 @@ ScriptEditor::ScriptEditor(EditorNode *p_editor) { help_menu->get_popup()->add_item("Contextual", HELP_CONTEXTUAL, KEY_MASK_SHIFT|KEY_F1); help_menu->get_popup()->connect("item_pressed", this,"_menu_option"); + menu_hb->add_spacer(); + + + script_icon = memnew( TextureFrame ); + menu_hb->add_child(script_icon); + script_name_label = memnew( Label ); + menu_hb->add_child(script_name_label); + + script_icon->hide(); + script_name_label->hide(); + + menu_hb->add_spacer(); + + site_search = memnew( ToolButton ); + site_search->set_text("Tutorials"); + site_search->connect("pressed",this,"_menu_option",varray(SEARCH_WEBSITE)); + menu_hb->add_child(site_search); + site_search->set_tooltip("Open http://www.godotengine.org at tutorials section."); + + class_search = memnew( ToolButton ); + class_search->set_text("Classes"); + class_search->connect("pressed",this,"_menu_option",varray(SEARCH_CLASSES)); + menu_hb->add_child(class_search); + class_search->set_tooltip("Search the class hierarchy."); + + help_search = memnew( ToolButton ); + help_search->set_text("Search Help"); + help_search->connect("pressed",this,"_menu_option",varray(SEARCH_HELP)); + menu_hb->add_child(help_search); + help_search->set_tooltip("Search the reference documentation."); + + menu_hb->add_child( memnew( VSeparator) ); + + script_back = memnew( ToolButton ); + script_back->connect("pressed",this,"_history_back"); + menu_hb->add_child(script_back); + script_back->set_disabled(true); + help_search->set_tooltip("Go to previous edited document."); + + script_forward = memnew( ToolButton ); + script_forward->connect("pressed",this,"_history_forward"); + menu_hb->add_child(script_forward); + script_forward->set_disabled(true); + help_search->set_tooltip("Go to next edited document."); + + + tab_container->connect("tab_changed", this,"_tab_changed"); find_replace_dialog = memnew(FindReplaceDialog); @@ -1959,8 +2451,20 @@ ScriptEditor::ScriptEditor(EditorNode *p_editor) { grab_focus_block=false; + help_search_dialog = memnew( EditorHelpSearch ); + add_child(help_search_dialog); + help_search_dialog->connect("go_to_help",this,"_help_class_goto"); + + + help_index = memnew( EditorHelpIndex ); + add_child(help_index); + help_index->connect("open_class",this,"_help_class_open"); + + history_pos=-1; // debugger_gui->hide(); + edit_pass=0; + } @@ -2062,8 +2566,14 @@ ScriptEditorPlugin::ScriptEditorPlugin(EditorNode *p_node) { script_editor->hide(); EDITOR_DEF("text_editor/auto_reload_changed_scripts",false); + EDITOR_DEF("text_editor/open_dominant_script_on_scene_change",true); EDITOR_DEF("external_editor/use_external_editor",false); EDITOR_DEF("external_editor/exec_path",""); + EDITOR_DEF("text_editor/script_temperature_enabled",true); + EDITOR_DEF("text_editor/script_temperature_history_size",15); + EDITOR_DEF("text_editor/script_temperature_hot_color",Color(1,0,0,0.3)); + EDITOR_DEF("text_editor/script_temperature_cold_color",Color(0,0,1,0.3)); + EDITOR_DEF("text_editor/group_help_pages",false); EditorSettings::get_singleton()->add_property_hint(PropertyInfo(Variant::STRING,"external_editor/exec_path",PROPERTY_HINT_GLOBAL_FILE)); EDITOR_DEF("external_editor/exec_flags",""); diff --git a/tools/editor/plugins/script_editor_plugin.h b/tools/editor/plugins/script_editor_plugin.h index e635a1974b..e755f570ef 100644 --- a/tools/editor/plugins/script_editor_plugin.h +++ b/tools/editor/plugins/script_editor_plugin.h @@ -41,6 +41,7 @@ #include "tools/editor/code_editor.h" #include "scene/gui/split_container.h" #include "scene/gui/item_list.h" +#include "tools/editor/editor_help.h" class ScriptEditorQuickOpen : public ConfirmationDialog { @@ -141,6 +142,9 @@ class ScriptEditor : public VBoxContainer { SEARCH_REPLACE, SEARCH_LOCATE_FUNCTION, SEARCH_GOTO_LINE, + SEARCH_HELP, + SEARCH_CLASSES, + SEARCH_WEBSITE, DEBUG_TOGGLE_BREAKPOINT, DEBUG_NEXT, DEBUG_STEP, @@ -150,6 +154,8 @@ class ScriptEditor : public VBoxContainer { HELP_CONTEXTUAL, WINDOW_MOVE_LEFT, WINDOW_MOVE_RIGHT, + WINDOW_NEXT, + WINDOW_PREV, WINDOW_SELECT_BASE=100 }; @@ -157,11 +163,17 @@ class ScriptEditor : public VBoxContainer { MenuButton *file_menu; MenuButton *edit_menu; MenuButton *search_menu; + MenuButton *script_search_menu; MenuButton *debug_menu; MenuButton *help_menu; Timer *autosave_timer; uint64_t idle; + Button *help_search; + Button *site_search; + Button *class_search; + EditorHelpSearch *help_search_dialog; + ItemList *script_list; HSplitContainer *script_split; TabContainer *tab_container; @@ -172,6 +184,27 @@ class ScriptEditor : public VBoxContainer { ScriptEditorDebugger* debugger; ToolButton *scripts_visible; + TextureFrame *script_icon; + Label *script_name_label; + + ToolButton *script_back; + ToolButton *script_forward; + + + struct ScriptHistory { + + Control *control; + int scroll_pos; + int cursor_column; + int cursor_row; + }; + + Vector<ScriptHistory> history; + int history_pos; + + + EditorHelpIndex *help_index; + void _tab_changed(int p_which); void _menu_option(int p_optin); @@ -201,6 +234,8 @@ class ScriptEditor : public VBoxContainer { void _editor_pause(); void _editor_stop(); + int edit_pass; + void _add_callback(Object *p_obj, const String& p_function, const StringArray& p_args); void _res_saved_callback(const Ref<Resource>& p_res); @@ -224,8 +259,20 @@ class ScriptEditor : public VBoxContainer { void _script_split_dragged(float); + + void _history_forward(); + void _history_back(); + bool waiting_update_names; + void _help_class_open(const String& p_class); + void _help_class_goto(const String& p_desc); + void _update_history_arrows(); + void _go_to_tab(int p_idx); + void _update_history_pos(int p_new_pos); + void _update_script_colors(); + + static ScriptEditor *script_editor; protected: void _notification(int p_what); @@ -253,6 +300,8 @@ public: void set_window_layout(Ref<ConfigFile> p_layout); void get_window_layout(Ref<ConfigFile> p_layout); + void set_scene_root_script( Ref<Script> p_script ); + ScriptEditorDebugger *get_debugger() { return debugger; } ScriptEditor(EditorNode *p_editor); diff --git a/tools/editor/plugins/tile_set_editor_plugin.cpp b/tools/editor/plugins/tile_set_editor_plugin.cpp index 39b0ef3c75..09115472a8 100644 --- a/tools/editor/plugins/tile_set_editor_plugin.cpp +++ b/tools/editor/plugins/tile_set_editor_plugin.cpp @@ -110,11 +110,15 @@ void TileSetEditor::_import_scene(Node *scene, Ref<TileSet> p_library, bool p_me if (!child2->cast_to<StaticBody2D>()) continue; StaticBody2D *sb = child2->cast_to<StaticBody2D>(); - if (sb->get_shape_count()==0) + int shape_count = sb->get_shape_count(); + if (shape_count==0) continue; - Ref<Shape2D> collision=sb->get_shape(0); - if (collision.is_valid()) { - collisions.push_back(collision); + for (int shape_index=0; shape_index<shape_count; ++shape_index) + { + Ref<Shape2D> collision=sb->get_shape(shape_index); + if (collision.is_valid()) { + collisions.push_back(collision); + } } } diff --git a/tools/editor/project_export.cpp b/tools/editor/project_export.cpp index 6003b976aa..30c7c9cfda 100644 --- a/tools/editor/project_export.cpp +++ b/tools/editor/project_export.cpp @@ -252,6 +252,13 @@ void ProjectExportDialog::_script_edited(Variant v) { } +void ProjectExportDialog::_sample_convert_edited(int what) { + EditorImportExport::get_singleton()->sample_set_action( EditorImportExport::SampleAction(sample_mode->get_selected())); + EditorImportExport::get_singleton()->sample_set_max_hz( sample_max_hz->get_val() ); + EditorImportExport::get_singleton()->sample_set_trim( sample_trim->is_pressed() ); + +} + void ProjectExportDialog::_notification(int p_what) { switch(p_what) { @@ -319,6 +326,15 @@ void ProjectExportDialog::_notification(int p_what) { _update_group(); _update_group_tree(); + sample_mode->select( EditorImportExport::get_singleton()->sample_get_action() ); + sample_max_hz->set_val( EditorImportExport::get_singleton()->sample_get_max_hz() ); + sample_trim->set_pressed( EditorImportExport::get_singleton()->sample_get_trim() ); + + sample_mode->connect("item_selected",this,"_sample_convert_edited"); + sample_max_hz->connect("value_changed",this,"_sample_convert_edited"); + sample_trim->connect("toggled",this,"_sample_convert_edited"); + + } break; case NOTIFICATION_EXIT_TREE: { @@ -1045,6 +1061,7 @@ void ProjectExportDialog::_bind_methods() { ObjectTypeDB::bind_method(_MD("_group_select_none"),&ProjectExportDialog::_group_select_none); ObjectTypeDB::bind_method(_MD("_script_edited"),&ProjectExportDialog::_script_edited); ObjectTypeDB::bind_method(_MD("_update_script"),&ProjectExportDialog::_update_script); + ObjectTypeDB::bind_method(_MD("_sample_convert_edited"),&ProjectExportDialog::_sample_convert_edited); ObjectTypeDB::bind_method(_MD("export_platform"),&ProjectExportDialog::export_platform); @@ -1316,6 +1333,22 @@ ProjectExportDialog::ProjectExportDialog(EditorNode *p_editor) { hbc->add_child(button_reload); */ + + sample_vbox = memnew( VBoxContainer ); + sample_vbox->set_name("Samples"); + sections->add_child(sample_vbox); + sample_mode = memnew( OptionButton ); + sample_vbox->add_margin_child("Sample Conversion Mode: (.wav files):",sample_mode); + sample_mode->add_item("Keep"); + sample_mode->add_item("Compress (RAM - IMA-ADPCM)"); + sample_max_hz = memnew( SpinBox ); + sample_max_hz->set_max(192000); + sample_max_hz->set_min(8000); + sample_vbox->add_margin_child("Sampling Rate Limit: (hz)",sample_max_hz); + sample_trim = memnew( CheckButton ); + sample_trim->set_text("Trim"); + sample_vbox->add_margin_child("Trailing Silence:",sample_trim); + script_vbox = memnew( VBoxContainer ); script_vbox->set_name("Script"); sections->add_child(script_vbox); diff --git a/tools/editor/project_export.h b/tools/editor/project_export.h index d85e688e58..2f824e5ff7 100644 --- a/tools/editor/project_export.h +++ b/tools/editor/project_export.h @@ -139,6 +139,10 @@ private: OptionButton *script_mode; LineEdit *script_key; + VBoxContainer *sample_vbox; + OptionButton *sample_mode; + SpinBox *sample_max_hz; + CheckButton *sample_trim; void _export_mode_changed(int p_idx); @@ -162,6 +166,8 @@ private: void _image_export_edited(int what); void _shrink_edited(float what); + void _sample_convert_edited(int what); + void _update_group_list(); void _select_group(const String& p_by_name); diff --git a/tools/editor/property_editor.cpp b/tools/editor/property_editor.cpp index 549a3f7ffb..d6eae51fbd 100644 --- a/tools/editor/property_editor.cpp +++ b/tools/editor/property_editor.cpp @@ -3514,6 +3514,7 @@ PropertyEditor::PropertyEditor() { tree->connect("button_pressed", this,"_edit_button"); custom_editor->connect("variant_changed", this,"_custom_editor_edited"); custom_editor->connect("resource_edit_request", this,"_resource_edit_request",make_binds(),CONNECT_DEFERRED); + tree->set_hide_folding(true); capitalize_paths=true; autoclear=false; diff --git a/tools/editor/scene_tree_dock.cpp b/tools/editor/scene_tree_dock.cpp index 510517de6f..08aa68d792 100644 --- a/tools/editor/scene_tree_dock.cpp +++ b/tools/editor/scene_tree_dock.cpp @@ -1088,7 +1088,8 @@ void SceneTreeDock::_delete_confirm() { void SceneTreeDock::_update_tool_buttons() { Node *sel = scene_tree->get_selected(); - bool disable = !sel || (sel!=edited_scene && sel->get_owner()!=edited_scene) || (edited_scene->get_scene_instance_state().is_valid() && edited_scene->get_scene_instance_state()->find_node_by_path(edited_scene->get_path_to(sel))>=0); + bool disable = !sel || (sel!=edited_scene && sel->get_owner()!=edited_scene); + disable = disable || (edited_scene->get_scene_inherited_state().is_valid() && edited_scene->get_scene_inherited_state()->find_node_by_path(edited_scene->get_path_to(sel))>=0); bool disable_root = disable || sel->get_parent()==scene_root; bool disable_edit = !sel; diff --git a/tools/editor/scene_tree_editor.cpp b/tools/editor/scene_tree_editor.cpp index 60395d5ff5..ac2f76acdc 100644 --- a/tools/editor/scene_tree_editor.cpp +++ b/tools/editor/scene_tree_editor.cpp @@ -649,20 +649,28 @@ void SceneTreeEditor::_rename_node(ObjectID p_node,const String& p_name) { void SceneTreeEditor::_renamed() { TreeItem *which=tree->get_edited(); - + ERR_FAIL_COND(!which); NodePath np = which->get_metadata(0); Node *n=get_node(np); ERR_FAIL_COND(!n); + String new_name=which->get_text(0); + if (new_name.find(".") != -1 || new_name.find("/") != -1) { + + error->set_text("Invalid node name, the following characters are not allowed:\n \".\", \"/\""); + error->popup_centered_minsize(); + new_name=n->get_name(); + } + if (!undo_redo) { - n->set_name( which->get_text(0) ); + n->set_name( new_name ); which->set_metadata(0,n->get_path()); emit_signal("node_renamed"); } else { undo_redo->create_action("Rename Node"); - emit_signal("node_prerename",n,which->get_text(0)); - undo_redo->add_do_method(this,"_rename_node",n->get_instance_ID(),which->get_text(0)); + emit_signal("node_prerename",n,new_name); + undo_redo->add_do_method(this,"_rename_node",n->get_instance_ID(),new_name); undo_redo->add_undo_method(this,"_rename_node",n->get_instance_ID(),n->get_name()); undo_redo->commit_action(); } diff --git a/tools/editor/script_editor_debugger.cpp b/tools/editor/script_editor_debugger.cpp index 8e0e7ddb49..60f2afa2c2 100644 --- a/tools/editor/script_editor_debugger.cpp +++ b/tools/editor/script_editor_debugger.cpp @@ -1376,7 +1376,6 @@ ScriptEditorDebugger::ScriptEditorDebugger(EditorNode *p_editor){ vmem_refresh->connect("pressed",this,"_video_mem_request"); MarginContainer *vmmc = memnew( MarginContainer ); - vmmc = memnew( MarginContainer ); vmem_tree = memnew( Tree ); vmem_tree->set_v_size_flags(SIZE_EXPAND_FILL); vmem_tree->set_h_size_flags(SIZE_EXPAND_FILL); |