diff options
Diffstat (limited to 'editor')
-rw-r--r-- | editor/editor_help.cpp | 27 | ||||
-rw-r--r-- | editor/editor_help.h | 1 | ||||
-rw-r--r-- | editor/filesystem_dock.cpp | 18 | ||||
-rw-r--r-- | editor/plugins/animation_tree_editor_plugin.cpp | 2 | ||||
-rw-r--r-- | editor/plugins/script_editor_plugin.cpp | 22 | ||||
-rw-r--r-- | editor/plugins/script_editor_plugin.h | 12 | ||||
-rw-r--r-- | editor/plugins/script_text_editor.cpp | 46 | ||||
-rw-r--r-- | editor/plugins/script_text_editor.h | 7 | ||||
-rw-r--r-- | editor/plugins/tile_map_editor_plugin.cpp | 58 | ||||
-rw-r--r-- | editor/plugins/tile_map_editor_plugin.h | 2 | ||||
-rw-r--r-- | editor/scene_tree_dock.cpp | 1 |
11 files changed, 185 insertions, 11 deletions
diff --git a/editor/editor_help.cpp b/editor/editor_help.cpp index 7f76cf1af2..f3be02a8c7 100644 --- a/editor/editor_help.cpp +++ b/editor/editor_help.cpp @@ -1172,7 +1172,12 @@ Error EditorHelp::_goto_desc(const String &p_class, int p_vscr) { class_desc->push_indent(1); Vector<DocData::ConstantDoc> enum_list = E->get(); + Map<String, int> enumValuesContainer; + int enumStartingLine = enum_line[E->key()]; + for (int i = 0; i < enum_list.size(); i++) { + if (cd.name == "@GlobalScope") + enumValuesContainer[enum_list[i].name] = enumStartingLine; class_desc->push_font(doc_code_font); class_desc->push_color(headline_color); @@ -1200,6 +1205,9 @@ Error EditorHelp::_goto_desc(const String &p_class, int p_vscr) { class_desc->add_newline(); } + if (cd.name == "@GlobalScope") + enum_values_line[E->key()] = enumValuesContainer; + class_desc->pop(); class_desc->add_newline(); @@ -1485,21 +1493,32 @@ void EditorHelp::_help_callback(const String &p_topic) { if (method_line.has(name)) line = method_line[name]; } else if (what == "class_property") { - if (property_line.has(name)) line = property_line[name]; } else if (what == "class_enum") { - if (enum_line.has(name)) line = enum_line[name]; } else if (what == "class_theme_item") { - if (theme_property_line.has(name)) line = theme_property_line[name]; } else if (what == "class_constant") { - if (constant_line.has(name)) line = constant_line[name]; + } else if (what == "class_global") { + if (constant_line.has(name)) + line = constant_line[name]; + else { + Map<String, Map<String, int> >::Element *iter = enum_values_line.front(); + while (true) { + if (iter->value().has(name)) { + line = iter->value()[name]; + break; + } else if (iter == enum_values_line.back()) + break; + else + iter = iter->next(); + } + } } class_desc->call_deferred("scroll_to_line", line); diff --git a/editor/editor_help.h b/editor/editor_help.h index aa84aa611f..0f93e1b55b 100644 --- a/editor/editor_help.h +++ b/editor/editor_help.h @@ -152,6 +152,7 @@ class EditorHelp : public VBoxContainer { Map<String, int> theme_property_line; Map<String, int> constant_line; Map<String, int> enum_line; + Map<String, Map<String, int> > enum_values_line; int description_line; RichTextLabel *class_desc; diff --git a/editor/filesystem_dock.cpp b/editor/filesystem_dock.cpp index 9bfa50148f..d5783c9b1a 100644 --- a/editor/filesystem_dock.cpp +++ b/editor/filesystem_dock.cpp @@ -1034,8 +1034,19 @@ void FileSystemDock::_move_operation_confirm(const String &p_to_path) { void FileSystemDock::_file_option(int p_option) { switch (p_option) { case FILE_SHOW_IN_EXPLORER: { - String dir = ProjectSettings::get_singleton()->globalize_path(this->path); - OS::get_singleton()->shell_open(String("file://") + dir); + + String path = this->path; + + // first try to grab directory from selected file, so that it works for searched files + int idx = files->get_current(); + + if (idx >= 0 && idx < files->get_item_count()) { + path = files->get_item_metadata(idx); + path = path.get_base_dir(); + } + + path = ProjectSettings::get_singleton()->globalize_path(path); + OS::get_singleton()->shell_open(String("file://") + path); } break; case FILE_OPEN: { for (int i = 0; i < files->get_item_count(); i++) { @@ -1660,6 +1671,8 @@ void FileSystemDock::_files_gui_input(Ref<InputEvent> p_event) { _file_option(FILE_COPY_PATH); } else if (ED_IS_SHORTCUT("filesystem_dock/delete", p_event)) { _file_option(FILE_REMOVE); + } else if (ED_IS_SHORTCUT("filesystem_dock/rename", p_event)) { + _file_option(FILE_RENAME); } } } @@ -1770,6 +1783,7 @@ FileSystemDock::FileSystemDock(EditorNode *p_editor) { ED_SHORTCUT("filesystem_dock/copy_path", TTR("Copy Path"), KEY_MASK_CMD | KEY_C); ED_SHORTCUT("filesystem_dock/duplicate", TTR("Duplicate..."), KEY_MASK_CMD | KEY_D); ED_SHORTCUT("filesystem_dock/delete", TTR("Delete"), KEY_DELETE); + ED_SHORTCUT("filesystem_dock/rename", TTR("Rename")); HBoxContainer *toolbar_hbc = memnew(HBoxContainer); add_child(toolbar_hbc); diff --git a/editor/plugins/animation_tree_editor_plugin.cpp b/editor/plugins/animation_tree_editor_plugin.cpp index f0e186e4b0..37213c1866 100644 --- a/editor/plugins/animation_tree_editor_plugin.cpp +++ b/editor/plugins/animation_tree_editor_plugin.cpp @@ -756,6 +756,7 @@ void AnimationTreeEditor::_gui_input(Ref<InputEvent> p_event) { if (rclick_type == CLICK_INPUT_SLOT || rclick_type == CLICK_OUTPUT_SLOT) { node_popup->clear(); + node_popup->set_size(Size2(1, 1)); node_popup->add_item(TTR("Disconnect"), NODE_DISCONNECT); if (anim_tree->node_get_type(rclick_node) == AnimationTreePlayer::NODE_TRANSITION) { node_popup->add_item(TTR("Add Input"), NODE_ADD_INPUT); @@ -774,6 +775,7 @@ void AnimationTreeEditor::_gui_input(Ref<InputEvent> p_event) { if (rclick_type == CLICK_NODE) { node_popup->clear(); + node_popup->set_size(Size2(1, 1)); node_popup->add_item(TTR("Rename"), NODE_RENAME); node_popup->add_item(TTR("Remove"), NODE_ERASE); if (anim_tree->node_get_type(rclick_node) == AnimationTreePlayer::NODE_TRANSITION) diff --git a/editor/plugins/script_editor_plugin.cpp b/editor/plugins/script_editor_plugin.cpp index 09388870f1..2ce36ee8d5 100644 --- a/editor/plugins/script_editor_plugin.cpp +++ b/editor/plugins/script_editor_plugin.cpp @@ -1778,6 +1778,20 @@ bool ScriptEditor::edit(const Ref<Script> &p_script, int p_line, int p_col, bool } ERR_FAIL_COND_V(!se, false); + bool highlighter_set = false; + for (int i = 0; i < syntax_highlighters_func_count; i++) { + SyntaxHighlighter *highlighter = syntax_highlighters_funcs[i](); + se->add_syntax_highlighter(highlighter); + + if (!highlighter_set) { + List<String> languages = highlighter->get_supported_languages(); + if (languages.find(p_script->get_language()->get_name())) { + se->set_syntax_highlighter(highlighter); + highlighter_set = true; + } + } + } + tab_container->add_child(se); se->set_edited_script(p_script); se->set_tooltip_request_func("_get_debug_tooltip", this); @@ -2494,6 +2508,14 @@ void ScriptEditor::_open_script_request(const String &p_path) { } } +int ScriptEditor::syntax_highlighters_func_count = 0; +CreateSyntaxHighlighterFunc ScriptEditor::syntax_highlighters_funcs[ScriptEditor::SYNTAX_HIGHLIGHTER_FUNC_MAX]; + +void ScriptEditor::register_create_syntax_highlighter_function(CreateSyntaxHighlighterFunc p_func) { + ERR_FAIL_COND(syntax_highlighters_func_count == SYNTAX_HIGHLIGHTER_FUNC_MAX); + syntax_highlighters_funcs[syntax_highlighters_func_count++] = p_func; +} + int ScriptEditor::script_editor_func_count = 0; CreateScriptEditorFunc ScriptEditor::script_editor_funcs[ScriptEditor::SCRIPT_EDITOR_FUNC_MAX]; diff --git a/editor/plugins/script_editor_plugin.h b/editor/plugins/script_editor_plugin.h index bcc604d990..f947351089 100644 --- a/editor/plugins/script_editor_plugin.h +++ b/editor/plugins/script_editor_plugin.h @@ -80,6 +80,9 @@ protected: static void _bind_methods(); public: + virtual void add_syntax_highlighter(SyntaxHighlighter *p_highlighter) = 0; + virtual void set_syntax_highlighter(SyntaxHighlighter *p_highlighter) = 0; + virtual void apply_code() = 0; virtual Ref<Script> get_edited_script() const = 0; virtual Vector<String> get_functions() = 0; @@ -112,6 +115,7 @@ public: ScriptEditorBase() {} }; +typedef SyntaxHighlighter *(*CreateSyntaxHighlighterFunc)(); typedef ScriptEditorBase *(*CreateScriptEditorFunc)(const Ref<Script> &p_script); class EditorScriptCodeCompletionCache; @@ -214,12 +218,16 @@ class ScriptEditor : public PanelContainer { ToolButton *script_forward; enum { - SCRIPT_EDITOR_FUNC_MAX = 32 + SCRIPT_EDITOR_FUNC_MAX = 32, + SYNTAX_HIGHLIGHTER_FUNC_MAX = 32 }; static int script_editor_func_count; static CreateScriptEditorFunc script_editor_funcs[SCRIPT_EDITOR_FUNC_MAX]; + static int syntax_highlighters_func_count; + static CreateSyntaxHighlighterFunc syntax_highlighters_funcs[SYNTAX_HIGHLIGHTER_FUNC_MAX]; + struct ScriptHistory { Control *control; @@ -399,7 +407,9 @@ public: ScriptEditorDebugger *get_debugger() { return debugger; } void set_live_auto_reload_running_scripts(bool p_enabled); + static void register_create_syntax_highlighter_function(CreateSyntaxHighlighterFunc p_func); static void register_create_script_editor_function(CreateScriptEditorFunc p_func); + ScriptEditor(EditorNode *p_editor); ~ScriptEditor(); }; diff --git a/editor/plugins/script_text_editor.cpp b/editor/plugins/script_text_editor.cpp index c8ea2f79fe..711a313902 100644 --- a/editor/plugins/script_text_editor.cpp +++ b/editor/plugins/script_text_editor.cpp @@ -573,6 +573,7 @@ void ScriptTextEditor::set_edited_script(const Ref<Script> &p_script) { ERR_FAIL_COND(!script.is_null()); script = p_script; + _set_theme_for_script(); code_editor->get_text_edit()->set_text(script->get_source_code()); code_editor->get_text_edit()->clear_undo_history(); @@ -580,8 +581,6 @@ void ScriptTextEditor::set_edited_script(const Ref<Script> &p_script) { emit_signal("name_changed"); code_editor->update_line_and_column(); - - _set_theme_for_script(); } void ScriptTextEditor::_validate_script() { @@ -789,6 +788,26 @@ void ScriptTextEditor::_lookup_symbol(const String &p_symbol, int p_row, int p_c emit_signal("go_to_help", "class_method:" + result.class_name + ":" + result.class_member); } break; + case ScriptLanguage::LookupResult::RESULT_CLASS_ENUM: { + + StringName cname = result.class_name; + StringName success; + while (true) { + success = ClassDB::get_integer_constant_enum(cname, result.class_member, true); + if (success != StringName()) { + result.class_name = cname; + cname = ClassDB::get_parent_class(cname); + } else { + break; + } + } + + emit_signal("go_to_help", "class_enum:" + result.class_name + ":" + result.class_member); + + } break; + case ScriptLanguage::LookupResult::RESULT_CLASS_TBD_GLOBALSCOPE: { + emit_signal("go_to_help", "class_global:" + result.class_name + ":" + result.class_member); + } break; } } } @@ -1245,11 +1264,26 @@ void ScriptTextEditor::_edit_option(int p_op) { } } +void ScriptTextEditor::add_syntax_highlighter(SyntaxHighlighter *p_highlighter) { + highlighters[p_highlighter->get_name()] = p_highlighter; + highlighter_menu->get_popup()->add_item(p_highlighter->get_name()); +} + +void ScriptTextEditor::set_syntax_highlighter(SyntaxHighlighter *p_highlighter) { + TextEdit *te = code_editor->get_text_edit(); + te->_set_syntax_highlighting(p_highlighter); +} + +void ScriptTextEditor::_change_syntax_highlighter(int p_idx) { + set_syntax_highlighter(highlighters[highlighter_menu->get_popup()->get_item_text(p_idx)]); +} + void ScriptTextEditor::_bind_methods() { ClassDB::bind_method("_validate_script", &ScriptTextEditor::_validate_script); ClassDB::bind_method("_load_theme_settings", &ScriptTextEditor::_load_theme_settings); ClassDB::bind_method("_breakpoint_toggled", &ScriptTextEditor::_breakpoint_toggled); + ClassDB::bind_method("_change_syntax_highlighter", &ScriptTextEditor::_change_syntax_highlighter); ClassDB::bind_method("_edit_option", &ScriptTextEditor::_edit_option); ClassDB::bind_method("_goto_line", &ScriptTextEditor::_goto_line); ClassDB::bind_method("_lookup_symbol", &ScriptTextEditor::_lookup_symbol); @@ -1635,6 +1669,14 @@ ScriptTextEditor::ScriptTextEditor() { edit_hb->add_child(edit_menu); + highlighters["Standard"] = NULL; + + highlighter_menu = memnew(MenuButton); + highlighter_menu->set_text(TTR("Syntax Highlighter")); + highlighter_menu->get_popup()->add_item("Standard"); + highlighter_menu->get_popup()->connect("id_pressed", this, "_change_syntax_highlighter"); + edit_hb->add_child(highlighter_menu); + quick_open = memnew(ScriptEditorQuickOpen); add_child(quick_open); quick_open->connect("goto_line", this, "_goto_line"); diff --git a/editor/plugins/script_text_editor.h b/editor/plugins/script_text_editor.h index 22e8fbce25..eb52d2593a 100644 --- a/editor/plugins/script_text_editor.h +++ b/editor/plugins/script_text_editor.h @@ -49,6 +49,7 @@ class ScriptTextEditor : public ScriptEditorBase { HBoxContainer *edit_hb; MenuButton *edit_menu; + MenuButton *highlighter_menu; MenuButton *search_menu; PopupMenu *context_menu; @@ -125,6 +126,9 @@ protected: void _notification(int p_what); static void _bind_methods(); + Map<String, SyntaxHighlighter *> highlighters; + void _change_syntax_highlighter(int p_idx); + void _edit_option(int p_op); void _make_context_menu(bool p_selection, bool p_color, bool p_can_fold, bool p_is_folded); void _text_edit_gui_input(const Ref<InputEvent> &ev); @@ -145,6 +149,9 @@ protected: void drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from); public: + virtual void add_syntax_highlighter(SyntaxHighlighter *p_highlighter); + virtual void set_syntax_highlighter(SyntaxHighlighter *p_highlighter); + virtual void apply_code(); virtual Ref<Script> get_edited_script() const; virtual Vector<String> get_functions(); diff --git a/editor/plugins/tile_map_editor_plugin.cpp b/editor/plugins/tile_map_editor_plugin.cpp index c5c7272ed2..14c584fa35 100644 --- a/editor/plugins/tile_map_editor_plugin.cpp +++ b/editor/plugins/tile_map_editor_plugin.cpp @@ -78,6 +78,7 @@ void TileMapEditor::_notification(int p_what) { p->set_item_icon(p->get_item_index(OPTION_PAINTING), get_icon("Edit", "EditorIcons")); p->set_item_icon(p->get_item_index(OPTION_PICK_TILE), get_icon("ColorPick", "EditorIcons")); p->set_item_icon(p->get_item_index(OPTION_SELECT), get_icon("ToolSelect", "EditorIcons")); + p->set_item_icon(p->get_item_index(OPTION_MOVE), get_icon("ToolMove", "EditorIcons")); p->set_item_icon(p->get_item_index(OPTION_DUPLICATE), get_icon("Duplicate", "EditorIcons")); p->set_item_icon(p->get_item_index(OPTION_ERASE_SELECTION), get_icon("Remove", "EditorIcons")); @@ -156,6 +157,14 @@ void TileMapEditor::_menu_option(int p_option) { undo_redo->commit_action(); } break; + case OPTION_MOVE: { + + if (selection_active) { + _update_copydata(); + tool = TOOL_MOVING; + canvas_item_editor->update(); + } + } break; } } @@ -829,6 +838,29 @@ bool TileMapEditor::forward_gui_input(const Ref<InputEvent> &p_event) { copydata.clear(); canvas_item_editor->update(); + } else if (tool == TOOL_MOVING) { + + Point2 ofs = over_tile - rectangle.position; + + undo_redo->create_action(TTR("Move")); + undo_redo->add_undo_method(node, "set", "tile_data", node->get("tile_data")); + for (int i = rectangle.position.y; i <= rectangle.position.y + rectangle.size.y; i++) { + for (int j = rectangle.position.x; j <= rectangle.position.x + rectangle.size.x; j++) { + + _set_cell(Point2i(j, i), TileMap::INVALID_CELL, false, false, false); + } + } + for (List<TileData>::Element *E = copydata.front(); E; E = E->next()) { + + _set_cell(E->get().pos + ofs, E->get().cell, E->get().flip_h, E->get().flip_v, E->get().transpose); + } + undo_redo->add_do_method(node, "set", "tile_data", node->get("tile_data")); + undo_redo->commit_action(); + + copydata.clear(); + selection_active = false; + + canvas_item_editor->update(); } else if (tool == TOOL_SELECTING) { @@ -888,6 +920,16 @@ bool TileMapEditor::forward_gui_input(const Ref<InputEvent> &p_event) { return true; } + if (tool == TOOL_MOVING) { + + tool = TOOL_NONE; + copydata.clear(); + + canvas_item_editor->update(); + + return true; + } + if (tool == TOOL_NONE) { paint_undo.clear(); @@ -1095,7 +1137,7 @@ bool TileMapEditor::forward_gui_input(const Ref<InputEvent> &p_event) { if (k->get_scancode() == KEY_ESCAPE) { - if (tool == TOOL_DUPLICATING) + if (tool == TOOL_DUPLICATING || tool == TOOL_MOVING) copydata.clear(); else if (tool == TOOL_SELECTING || selection_active) selection_active = false; @@ -1150,6 +1192,14 @@ bool TileMapEditor::forward_gui_input(const Ref<InputEvent> &p_event) { return true; } } + if (ED_IS_SHORTCUT("tile_map_editor/move_selection", p_event)) { + if (selection_active) { + _update_copydata(); + tool = TOOL_MOVING; + canvas_item_editor->update(); + return true; + } + } if (ED_IS_SHORTCUT("tile_map_editor/find_tile", p_event)) { search_box->select_all(); search_box->grab_focus(); @@ -1159,18 +1209,21 @@ bool TileMapEditor::forward_gui_input(const Ref<InputEvent> &p_event) { if (ED_IS_SHORTCUT("tile_map_editor/mirror_x", p_event)) { flip_h = !flip_h; mirror_x->set_pressed(flip_h); + _update_transform_buttons(); canvas_item_editor->update(); return true; } if (ED_IS_SHORTCUT("tile_map_editor/mirror_y", p_event)) { flip_v = !flip_v; mirror_y->set_pressed(flip_v); + _update_transform_buttons(); canvas_item_editor->update(); return true; } if (ED_IS_SHORTCUT("tile_map_editor/transpose", p_event)) { transpose = !transpose; transp->set_pressed(transpose); + _update_transform_buttons(); canvas_item_editor->update(); return true; } @@ -1343,7 +1396,7 @@ void TileMapEditor::forward_draw_over_viewport(Control *p_overlay) { _draw_cell(id, Point2i(j, i), flip_h, flip_v, transpose, xform); } } - } else if (tool == TOOL_DUPLICATING) { + } else if (tool == TOOL_DUPLICATING || tool == TOOL_MOVING) { if (copydata.empty()) return; @@ -1590,6 +1643,7 @@ TileMapEditor::TileMapEditor(EditorNode *p_editor) { p->add_item(TTR("Pick Tile"), OPTION_PICK_TILE, KEY_CONTROL); p->add_separator(); p->add_shortcut(ED_SHORTCUT("tile_map_editor/select", TTR("Select"), KEY_MASK_CMD + KEY_B), OPTION_SELECT); + p->add_shortcut(ED_SHORTCUT("tile_map_editor/move_selection", TTR("Move Selection"), KEY_MASK_CMD + KEY_M), OPTION_MOVE); p->add_shortcut(ED_SHORTCUT("tile_map_editor/duplicate_selection", TTR("Duplicate Selection"), KEY_MASK_CMD + KEY_D), OPTION_DUPLICATE); p->add_shortcut(ED_GET_SHORTCUT("tile_map_editor/erase_selection"), OPTION_ERASE_SELECTION); p->add_separator(); diff --git a/editor/plugins/tile_map_editor_plugin.h b/editor/plugins/tile_map_editor_plugin.h index 2d582d030b..3257901c88 100644 --- a/editor/plugins/tile_map_editor_plugin.h +++ b/editor/plugins/tile_map_editor_plugin.h @@ -61,6 +61,7 @@ class TileMapEditor : public VBoxContainer { TOOL_BUCKET, TOOL_PICKING, TOOL_DUPLICATING, + TOOL_MOVING }; enum Options { @@ -72,6 +73,7 @@ class TileMapEditor : public VBoxContainer { OPTION_ERASE_SELECTION, OPTION_PAINTING, OPTION_FIX_INVALID, + OPTION_MOVE }; TileMap *node; diff --git a/editor/scene_tree_dock.cpp b/editor/scene_tree_dock.cpp index d5ec858c37..1644ae5b55 100644 --- a/editor/scene_tree_dock.cpp +++ b/editor/scene_tree_dock.cpp @@ -1794,6 +1794,7 @@ void SceneTreeDock::_tree_rmb(const Vector2 &p_menu_pos) { subresources.clear(); menu_subresources->clear(); + menu_subresources->set_size(Size2(1, 1)); _add_children_to_popup(selection.front()->get(), 0); if (menu->get_item_count() > 0) menu->add_separator(); |