Merge pull request #6165 from TheHX/pr-tile-palette
Small usability improvements on the TileMap editor tile palette.
This commit is contained in:
commit
56fa741b7a
1 changed files with 27 additions and 10 deletions
|
@ -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();
|
||||
|
|
Loading…
Reference in a new issue