diff options
Diffstat (limited to 'editor/plugins')
-rw-r--r-- | editor/plugins/script_text_editor.cpp | 89 | ||||
-rw-r--r-- | editor/plugins/script_text_editor.h | 5 | ||||
-rw-r--r-- | editor/plugins/tile_map_editor_plugin.cpp | 65 |
3 files changed, 130 insertions, 29 deletions
diff --git a/editor/plugins/script_text_editor.cpp b/editor/plugins/script_text_editor.cpp index f705970d79..2cfa759e3b 100644 --- a/editor/plugins/script_text_editor.cpp +++ b/editor/plugins/script_text_editor.cpp @@ -646,19 +646,20 @@ void ScriptTextEditor::_validate_script() { void ScriptTextEditor::_update_bookmark_list() { - bookmarks_menu->get_popup()->clear(); + bookmarks_menu->clear(); + bookmarks_menu->set_size(Size2(1, 1)); - bookmarks_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/toggle_bookmark"), BOOKMARK_TOGGLE); - bookmarks_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/remove_all_bookmarks"), BOOKMARK_REMOVE_ALL); - bookmarks_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/goto_next_bookmark"), BOOKMARK_GOTO_NEXT); - bookmarks_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/goto_previous_bookmark"), BOOKMARK_GOTO_PREV); + bookmarks_menu->add_shortcut(ED_GET_SHORTCUT("script_text_editor/toggle_bookmark"), BOOKMARK_TOGGLE); + bookmarks_menu->add_shortcut(ED_GET_SHORTCUT("script_text_editor/remove_all_bookmarks"), BOOKMARK_REMOVE_ALL); + bookmarks_menu->add_shortcut(ED_GET_SHORTCUT("script_text_editor/goto_next_bookmark"), BOOKMARK_GOTO_NEXT); + bookmarks_menu->add_shortcut(ED_GET_SHORTCUT("script_text_editor/goto_previous_bookmark"), BOOKMARK_GOTO_PREV); Array bookmark_list = code_editor->get_text_edit()->get_bookmarks_array(); if (bookmark_list.size() == 0) { return; } - bookmarks_menu->get_popup()->add_separator(); + bookmarks_menu->add_separator(); for (int i = 0; i < bookmark_list.size(); i++) { String line = code_editor->get_text_edit()->get_line(bookmark_list[i]).strip_edges(); @@ -667,17 +668,17 @@ void ScriptTextEditor::_update_bookmark_list() { line = line.substr(0, 50); } - bookmarks_menu->get_popup()->add_item(String::num((int)bookmark_list[i] + 1) + " - \"" + line + "\""); - bookmarks_menu->get_popup()->set_item_metadata(bookmarks_menu->get_popup()->get_item_count() - 1, bookmark_list[i]); + bookmarks_menu->add_item(String::num((int)bookmark_list[i] + 1) + " - \"" + line + "\""); + bookmarks_menu->set_item_metadata(bookmarks_menu->get_item_count() - 1, bookmark_list[i]); } } void ScriptTextEditor::_bookmark_item_pressed(int p_idx) { if (p_idx < 4) { // Any item before the separator. - _edit_option(bookmarks_menu->get_popup()->get_item_id(p_idx)); + _edit_option(bookmarks_menu->get_item_id(p_idx)); } else { - code_editor->goto_line(bookmarks_menu->get_popup()->get_item_metadata(p_idx)); + code_editor->goto_line(bookmarks_menu->get_item_metadata(p_idx)); } } @@ -792,6 +793,44 @@ void ScriptTextEditor::_code_complete_script(const String &p_code, List<String> } } +void ScriptTextEditor::_update_breakpoint_list() { + + breakpoints_menu->clear(); + breakpoints_menu->set_size(Size2(1, 1)); + + breakpoints_menu->add_shortcut(ED_GET_SHORTCUT("script_text_editor/toggle_breakpoint"), DEBUG_TOGGLE_BREAKPOINT); + breakpoints_menu->add_shortcut(ED_GET_SHORTCUT("script_text_editor/remove_all_breakpoints"), DEBUG_REMOVE_ALL_BREAKPOINTS); + breakpoints_menu->add_shortcut(ED_GET_SHORTCUT("script_text_editor/goto_next_breakpoint"), DEBUG_GOTO_NEXT_BREAKPOINT); + breakpoints_menu->add_shortcut(ED_GET_SHORTCUT("script_text_editor/goto_previous_breakpoint"), DEBUG_GOTO_PREV_BREAKPOINT); + + Array breakpoint_list = code_editor->get_text_edit()->get_breakpoints_array(); + if (breakpoint_list.size() == 0) { + return; + } + + breakpoints_menu->add_separator(); + + for (int i = 0; i < breakpoint_list.size(); i++) { + String line = code_editor->get_text_edit()->get_line(breakpoint_list[i]).strip_edges(); + // Limit the size of the line if too big. + if (line.length() > 50) { + line = line.substr(0, 50); + } + + breakpoints_menu->add_item(String::num((int)breakpoint_list[i] + 1) + " - \"" + line + "\""); + breakpoints_menu->set_item_metadata(breakpoints_menu->get_item_count() - 1, breakpoint_list[i]); + } +} + +void ScriptTextEditor::_breakpoint_item_pressed(int p_idx) { + + if (p_idx < 4) { // Any item before the separator. + _edit_option(breakpoints_menu->get_item_id(p_idx)); + } else { + code_editor->goto_line(breakpoints_menu->get_item_metadata(p_idx)); + } +} + void ScriptTextEditor::_breakpoint_toggled(int p_row) { ScriptEditor::get_singleton()->get_debugger()->set_breakpoint(script->get_path(), p_row + 1, code_editor->get_text_edit()->is_line_set_as_breakpoint(p_row)); @@ -1298,6 +1337,8 @@ void ScriptTextEditor::_bind_methods() { ClassDB::bind_method("_update_bookmark_list", &ScriptTextEditor::_update_bookmark_list); ClassDB::bind_method("_bookmark_item_pressed", &ScriptTextEditor::_bookmark_item_pressed); ClassDB::bind_method("_load_theme_settings", &ScriptTextEditor::_load_theme_settings); + ClassDB::bind_method("_update_breakpoint_list", &ScriptTextEditor::_update_breakpoint_list); + ClassDB::bind_method("_breakpoint_item_pressed", &ScriptTextEditor::_breakpoint_item_pressed); ClassDB::bind_method("_breakpoint_toggled", &ScriptTextEditor::_breakpoint_toggled); ClassDB::bind_method("_lookup_connections", &ScriptTextEditor::_lookup_connections); ClassDB::bind_method("_update_connected_methods", &ScriptTextEditor::_update_connected_methods); @@ -1705,11 +1746,6 @@ ScriptTextEditor::ScriptTextEditor() { edit_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/auto_indent"), EDIT_AUTO_INDENT); edit_menu->get_popup()->connect("id_pressed", this, "_edit_option"); edit_menu->get_popup()->add_separator(); - edit_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/toggle_breakpoint"), DEBUG_TOGGLE_BREAKPOINT); - edit_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/remove_all_breakpoints"), DEBUG_REMOVE_ALL_BREAKPOINTS); - edit_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/goto_next_breakpoint"), DEBUG_GOTO_NEXT_BREAKPOINT); - edit_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/goto_previous_breakpoint"), DEBUG_GOTO_PREV_BREAKPOINT); - edit_menu->get_popup()->add_separator(); PopupMenu *convert_case = memnew(PopupMenu); convert_case->set_name("convert_case"); @@ -1749,13 +1785,26 @@ ScriptTextEditor::ScriptTextEditor() { edit_hb->add_child(edit_menu); - bookmarks_menu = memnew(MenuButton); - edit_hb->add_child(bookmarks_menu); - bookmarks_menu->set_text(TTR("Bookmarks")); - bookmarks_menu->set_switch_on_hover(true); + MenuButton *goto_menu = memnew(MenuButton); + edit_hb->add_child(goto_menu); + goto_menu->set_text(TTR("Go To")); + goto_menu->set_switch_on_hover(true); + + bookmarks_menu = memnew(PopupMenu); + bookmarks_menu->set_name("Bookmarks"); + goto_menu->get_popup()->add_child(bookmarks_menu); + goto_menu->get_popup()->add_submenu_item(TTR("Bookmarks"), "Bookmarks"); _update_bookmark_list(); bookmarks_menu->connect("about_to_show", this, "_update_bookmark_list"); - bookmarks_menu->get_popup()->connect("index_pressed", this, "_bookmark_item_pressed"); + bookmarks_menu->connect("index_pressed", this, "_bookmark_item_pressed"); + + breakpoints_menu = memnew(PopupMenu); + breakpoints_menu->set_name("Breakpoints"); + goto_menu->get_popup()->add_child(breakpoints_menu); + goto_menu->get_popup()->add_submenu_item(TTR("Breakpoints"), "Breakpoints"); + _update_breakpoint_list(); + breakpoints_menu->connect("about_to_show", this, "_update_breakpoint_list"); + breakpoints_menu->connect("index_pressed", this, "_breakpoint_item_pressed"); quick_open = memnew(ScriptEditorQuickOpen); add_child(quick_open); diff --git a/editor/plugins/script_text_editor.h b/editor/plugins/script_text_editor.h index f83f1ea759..b53383b117 100644 --- a/editor/plugins/script_text_editor.h +++ b/editor/plugins/script_text_editor.h @@ -70,7 +70,8 @@ class ScriptTextEditor : public ScriptEditorBase { MenuButton *edit_menu; MenuButton *search_menu; - MenuButton *bookmarks_menu; + PopupMenu *bookmarks_menu; + PopupMenu *breakpoints_menu; PopupMenu *highlighter_menu; PopupMenu *context_menu; @@ -143,6 +144,8 @@ class ScriptTextEditor : public ScriptEditorBase { protected: static void _code_complete_scripts(void *p_ud, const String &p_code, List<String> *r_options, bool &r_force); + void _update_breakpoint_list(); + void _breakpoint_item_pressed(int p_idx); void _breakpoint_toggled(int p_row); void _validate_script(); // No longer virtual. diff --git a/editor/plugins/tile_map_editor_plugin.cpp b/editor/plugins/tile_map_editor_plugin.cpp index 6e47d82847..3735cceb15 100644 --- a/editor/plugins/tile_map_editor_plugin.cpp +++ b/editor/plugins/tile_map_editor_plugin.cpp @@ -782,8 +782,9 @@ void TileMapEditor::_draw_cell(Control *p_viewport, int p_cell, const Point2i &p r.position += (r.size + Vector2(spacing, spacing)) * offset; } Size2 sc = p_xform.get_scale(); - /* For a future CheckBox to Center Texture: - Size2 cell_size = node->get_cell_size(); */ + Size2 cell_size = node->get_cell_size(); + bool centered_texture = node->is_centered_textures_enabled(); + bool compatibility_mode_enabled = node->is_compatibility_mode_enabled(); Rect2 rect = Rect2(); rect.position = node->map_to_world(p_point) + node->get_cell_draw_offset(); @@ -793,13 +794,24 @@ void TileMapEditor::_draw_cell(Control *p_viewport, int p_cell, const Point2i &p rect.size = r.size; } + if (compatibility_mode_enabled && !centered_texture) { + if (rect.size.y > rect.size.x) { + if ((p_flip_h && (p_flip_v || p_transpose)) || (p_flip_v && !p_transpose)) + tile_ofs.y += rect.size.y - rect.size.x; + } else if (rect.size.y < rect.size.x) { + if ((p_flip_v && (p_flip_h || p_transpose)) || (p_flip_h && !p_transpose)) + tile_ofs.x += rect.size.x - rect.size.y; + } + } + if (p_transpose) { SWAP(tile_ofs.x, tile_ofs.y); - /* For a future CheckBox to Center Texture: - rect.position.x += cell_size.x / 2 - rect.size.y / 2; - rect.position.y += cell_size.y / 2 - rect.size.x / 2; - } else { - rect.position += cell_size / 2 - rect.size / 2; */ + if (centered_texture) { + rect.position.x += cell_size.x / 2 - rect.size.y / 2; + rect.position.y += cell_size.y / 2 - rect.size.x / 2; + } + } else if (centered_texture) { + rect.position += cell_size / 2 - rect.size / 2; } if (p_flip_h) { @@ -812,7 +824,44 @@ void TileMapEditor::_draw_cell(Control *p_viewport, int p_cell, const Point2i &p tile_ofs.y *= -1.0; } - rect.position += tile_ofs; + if (compatibility_mode_enabled && !centered_texture) { + if (node->get_tile_origin() == TileMap::TILE_ORIGIN_TOP_LEFT) { + + rect.position += tile_ofs; + } else if (node->get_tile_origin() == TileMap::TILE_ORIGIN_BOTTOM_LEFT) { + + rect.position += tile_ofs; + + if (p_transpose) { + if (p_flip_h) + rect.position.x -= cell_size.x; + else + rect.position.x += cell_size.x; + } else { + if (p_flip_v) + rect.position.y -= cell_size.y; + else + rect.position.y += cell_size.y; + } + + } else if (node->get_tile_origin() == TileMap::TILE_ORIGIN_CENTER) { + + rect.position += tile_ofs; + + if (p_flip_h) + rect.position.x -= cell_size.x / 2; + else + rect.position.x += cell_size.x / 2; + + if (p_flip_v) + rect.position.y -= cell_size.y / 2; + else + rect.position.y += cell_size.y / 2; + } + } else { + rect.position += tile_ofs; + } + rect.position = p_xform.xform(rect.position); rect.size *= sc; |