diff options
Diffstat (limited to 'editor')
-rw-r--r-- | editor/editor_node.cpp | 2 | ||||
-rw-r--r-- | editor/plugins/tile_map_editor_plugin.cpp | 49 | ||||
-rw-r--r-- | editor/property_editor.cpp | 2 | ||||
-rw-r--r-- | editor/scene_tree_editor.cpp | 1 |
4 files changed, 45 insertions, 9 deletions
diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index 18c16af5af..5b5f500178 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -5681,7 +5681,7 @@ EditorNode::EditorNode() { overridden_default_layout = -1; default_layout.instance(); default_layout->set_value(docks_section, "dock_3", TTR("FileSystem")); - default_layout->set_value(docks_section, "dock_5", TTR("Scene")); + default_layout->set_value(docks_section, "dock_5", TTR("Scene") + "," + TTR("Import")); default_layout->set_value(docks_section, "dock_6", TTR("Inspector") + "," + TTR("Node")); for (int i = 0; i < DOCK_SLOT_MAX / 2; i++) diff --git a/editor/plugins/tile_map_editor_plugin.cpp b/editor/plugins/tile_map_editor_plugin.cpp index 8cda9848bd..b80ce35d03 100644 --- a/editor/plugins/tile_map_editor_plugin.cpp +++ b/editor/plugins/tile_map_editor_plugin.cpp @@ -190,6 +190,19 @@ void TileMapEditor::_sbox_input(const InputEvent &p_ie) { } } +// Implementation detail of TileMapEditor::_update_palette(); +// in modern C++ this could have been inside its body +namespace { +struct _PaletteEntry { + int id; + String name; + + bool operator<(const _PaletteEntry &p_rhs) const { + return name < p_rhs.name; + } +}; +} + void TileMapEditor::_update_palette() { if (!node) @@ -212,6 +225,8 @@ void TileMapEditor::_update_palette() { min_size *= EDSCALE; int hseparation = EDITOR_DEF("editors/tile_map/palette_item_hseparation", 8); bool show_tile_names = bool(EDITOR_DEF("editors/tile_map/show_tile_names", true)); + bool show_tile_ids = bool(EDITOR_DEF("editors/tile_map/show_tile_ids", false)); + bool sort_by_name = bool(EDITOR_DEF("editors/tile_map/sort_tiles_by_name", true)); palette->add_constant_override("hseparation", hseparation * EDSCALE); palette->add_constant_override("vseparation", 8 * EDSCALE); @@ -221,12 +236,20 @@ void TileMapEditor::_update_palette() { String filter = search_box->get_text().strip_edges(); + Vector<_PaletteEntry> entries; + for (List<int>::Element *E = tiles.front(); E; E = E->next()) { - String name; + String name = tileset->tile_get_name(E->get()); - if (tileset->tile_get_name(E->get()) != "") { - name = itos(E->get()) + " - " + tileset->tile_get_name(E->get()); + if (name != "") { + if (show_tile_ids) { + if (sort_by_name) { + name = name + " - " + itos(E->get()); + } else { + name = itos(E->get()) + " - " + name; + } + } } else { name = "#" + itos(E->get()); } @@ -234,16 +257,26 @@ void TileMapEditor::_update_palette() { if (filter != "" && !filter.is_subsequence_ofi(name)) continue; + const _PaletteEntry entry = { E->get(), name }; + entries.push_back(entry); + } + + if (sort_by_name) { + entries.sort(); + } + + for (int i = 0; i < entries.size(); i++) { + if (show_tile_names) { - palette->add_item(name); + palette->add_item(entries[i].name); } else { palette->add_item(String()); } - Ref<Texture> tex = tileset->tile_get_texture(E->get()); + Ref<Texture> tex = tileset->tile_get_texture(entries[i].id); if (tex.is_valid()) { - Rect2 region = tileset->tile_get_region(E->get()); + Rect2 region = tileset->tile_get_region(entries[i].id); if (!region.has_no_area()) palette->set_item_icon_region(palette->get_item_count() - 1, region); @@ -251,7 +284,7 @@ void TileMapEditor::_update_palette() { palette->set_item_icon(palette->get_item_count() - 1, tex); } - palette->set_item_metadata(palette->get_item_count() - 1, E->get()); + palette->set_item_metadata(palette->get_item_count() - 1, entries[i].id); } palette->set_same_column_width(true); @@ -1563,6 +1596,8 @@ TileMapEditorPlugin::TileMapEditorPlugin(EditorNode *p_node) { EDITOR_DEF("editors/tile_map/preview_size", 64); EDITOR_DEF("editors/tile_map/palette_item_hseparation", 8); EDITOR_DEF("editors/tile_map/show_tile_names", true); + EDITOR_DEF("editors/tile_map/show_tile_ids", false); + EDITOR_DEF("editors/tile_map/sort_tiles_by_name", true); EDITOR_DEF("editors/tile_map/bucket_fill_preview", true); tile_map_editor = memnew(TileMapEditor(p_node)); diff --git a/editor/property_editor.cpp b/editor/property_editor.cpp index cc26769939..f2a79a2f47 100644 --- a/editor/property_editor.cpp +++ b/editor/property_editor.cpp @@ -3846,8 +3846,8 @@ void PropertyEditor::_item_edited() { } break; case Variant::BOOL: { - _edit_set(name, item->is_checked(1), refresh_all); item->set_tooltip(1, item->is_checked(1) ? "True" : "False"); + _edit_set(name, item->is_checked(1), refresh_all); } break; case Variant::INT: case Variant::REAL: { diff --git a/editor/scene_tree_editor.cpp b/editor/scene_tree_editor.cpp index 3310405ae9..5f0bc8841b 100644 --- a/editor/scene_tree_editor.cpp +++ b/editor/scene_tree_editor.cpp @@ -1113,6 +1113,7 @@ SceneTreeEditor::SceneTreeEditor(bool p_label, bool p_can_rename, bool p_can_ope tree->set_anchor(MARGIN_BOTTOM, ANCHOR_END); tree->set_begin(Point2(0, p_label ? 18 : 0)); tree->set_end(Point2(0, 0)); + tree->add_constant_override("button_margin", 0); add_child(tree); |