diff options
author | Franklin Sobrinho <franklin_gs@hotmail.com> | 2016-08-15 16:48:04 -0300 |
---|---|---|
committer | Franklin Sobrinho <franklin_gs@hotmail.com> | 2016-08-16 06:00:47 -0300 |
commit | 0fa26cd8506a17dd75d78168d9027b24e5d8da3f (patch) | |
tree | c3c6e6d9191991e5be3662963cfc70365353103d | |
parent | 91ba00b4163ceec83211b9445dd1a0900d71efe4 (diff) |
Small usability improvements on the TileMap editor tile palette.
* The column width changes with the zoom, now the icons don't overlap.
* Added a tile hsepation setting.
* Added a setting to show/hide tile names.
-rw-r--r-- | tools/editor/plugins/tile_map_editor_plugin.cpp | 37 |
1 files changed, 27 insertions, 10 deletions
diff --git a/tools/editor/plugins/tile_map_editor_plugin.cpp b/tools/editor/plugins/tile_map_editor_plugin.cpp index d686c37d1a..316077c5d5 100644 --- a/tools/editor/plugins/tile_map_editor_plugin.cpp +++ b/tools/editor/plugins/tile_map_editor_plugin.cpp @@ -34,6 +34,7 @@ #include "canvas_item_editor_plugin.h" #include "tools/editor/editor_settings.h" +#include "tools/editor/editor_scale.h" void TileMapEditor::_notification(int p_what) { @@ -50,6 +51,12 @@ void TileMapEditor::_notification(int p_what) { rotate_270->set_icon(get_icon("Rotate270","EditorIcons")); } break; + case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: { + + if (is_visible()) { + _update_palette(); + } + } break; } } @@ -205,16 +212,16 @@ void TileMapEditor::_update_palette() { if (tiles.empty()) return; + float min_size = EDITOR_DEF("tile_map/preview_size", 64); + min_size *= EDSCALE; + int hseparation = EDITOR_DEF("tile_map/palette_item_hseparation",8); + bool show_tile_names = bool(EDITOR_DEF("tile_map/show_tile_names", true)); - palette->set_max_columns(0); - palette->add_constant_override("hseparation", 6); + palette->add_constant_override("hseparation", hseparation*EDSCALE); + palette->add_constant_override("vseparation", 8*EDSCALE); - float min_size = EDITOR_DEF("tile_map/preview_size",64); palette->set_fixed_icon_size(Size2(min_size, min_size)); - palette->set_fixed_column_width(min_size*3/2); - palette->set_icon_mode(ItemList::ICON_MODE_TOP); - palette->set_max_text_lines(2); - + palette->set_fixed_column_width(min_size * MAX(size_slider->get_val(), 1)); String filter = search_box->get_text().strip_edges(); @@ -228,10 +235,14 @@ void TileMapEditor::_update_palette() { name = "#"+itos(E->get()); } - if (filter != "" && name.findn(filter) == -1) + if (filter != "" && !filter.is_subsequence_ofi(name)) continue; - palette->add_item(name); + if (show_tile_names) { + palette->add_item(name); + } else { + palette->add_item(String()); + } Ref<Texture> tex = tileset->tile_get_texture(E->get()); @@ -252,7 +263,7 @@ void TileMapEditor::_update_palette() { if (selected != -1) set_selected_tile(selected); else - palette->select(0, true); + palette->select(0); } void TileMapEditor::_pick_tile(const Point2& p_pos) { @@ -1348,6 +1359,9 @@ TileMapEditor::TileMapEditor(EditorNode *p_editor) { palette = memnew( ItemList ); palette->set_v_size_flags(SIZE_EXPAND_FILL); palette->set_custom_minimum_size(Size2(mw,0)); + palette->set_max_columns(0); + palette->set_icon_mode(ItemList::ICON_MODE_TOP); + palette->set_max_text_lines(2); add_child(palette); // Add menu items @@ -1458,6 +1472,9 @@ void TileMapEditorPlugin::make_visible(bool p_visible) { TileMapEditorPlugin::TileMapEditorPlugin(EditorNode *p_node) { EDITOR_DEF("tile_map/preview_size",64); + EDITOR_DEF("tile_map/palette_item_hseparation",8); + EDITOR_DEF("tile_map/show_tile_names", true); + tile_map_editor = memnew( TileMapEditor(p_node) ); add_control_to_container(CONTAINER_CANVAS_EDITOR_SIDE, tile_map_editor); tile_map_editor->hide(); |