diff --git a/doc/classes/ItemList.xml b/doc/classes/ItemList.xml
index e4db5aeb849..01478877680 100644
--- a/doc/classes/ItemList.xml
+++ b/doc/classes/ItemList.xml
@@ -87,6 +87,15 @@
+
+
+
+
+
+
+ Returns a [Color] modulating item's icon at the specified index.
+
+
@@ -225,6 +234,17 @@
Set (or replace) icon of the item at the specified index.
+
+
+
+
+
+
+
+
+ Sets a modulating [Color] for item's icon at the specified index.
+
+
diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp
index 36ea90ed66d..b2017acc0a5 100644
--- a/editor/editor_node.cpp
+++ b/editor/editor_node.cpp
@@ -1227,29 +1227,25 @@ void EditorNode::_dialog_action(String p_file) {
} break;
case FILE_EXPORT_TILESET: {
- Ref ml;
- if (FileAccess::exists(p_file)) {
- ml = ResourceLoader::load(p_file, "TileSet");
+ Ref tileset;
+ if (FileAccess::exists(p_file) && file_export_lib_merge->is_pressed()) {
+ tileset = ResourceLoader::load(p_file, "TileSet");
- if (ml.is_null()) {
- if (file_export_lib_merge->is_pressed()) {
- current_option = -1;
- accept->get_ok()->set_text(TTR("I see.."));
- accept->set_text(TTR("Can't load TileSet for merging!"));
- accept->popup_centered_minsize();
- return;
- }
- } else if (!file_export_lib_merge->is_pressed()) {
- ml->clear();
+ if (tileset.is_null()) {
+ current_option = -1;
+ accept->get_ok()->set_text(TTR("I see.."));
+ accept->set_text(TTR("Can't load TileSet for merging!"));
+ accept->popup_centered_minsize();
+ return;
}
} else {
- ml = Ref(memnew(TileSet));
+ tileset = Ref(memnew(TileSet));
}
- TileSetEditor::update_library_file(editor_data.get_edited_scene_root(), ml, true);
+ TileSetEditor::update_library_file(editor_data.get_edited_scene_root(), tileset, true);
- Error err = ResourceSaver::save(p_file, ml);
+ Error err = ResourceSaver::save(p_file, tileset);
if (err) {
current_option = -1;
diff --git a/editor/plugins/tile_set_editor_plugin.cpp b/editor/plugins/tile_set_editor_plugin.cpp
index 2311439728a..41692e805f9 100644
--- a/editor/plugins/tile_set_editor_plugin.cpp
+++ b/editor/plugins/tile_set_editor_plugin.cpp
@@ -278,10 +278,11 @@ void TileSetEditor::_changed_callback(Object *p_changed, const char *p_prop) {
preview->set_region_rect(tileset->tile_get_region(get_current_tile()));
} else if (p_prop == StringName("name")) {
update_tile_list_icon();
- } else if (p_prop == StringName("texture") || p_prop == StringName("tile_mode")) {
+ } else if (p_prop == StringName("texture") || p_prop == StringName("modulate") || p_prop == StringName("tile_mode")) {
_on_tile_list_selected(get_current_tile());
workspace->update();
preview->set_texture(tileset->tile_get_texture(get_current_tile()));
+ preview->set_modulate(tileset->tile_get_modulate(get_current_tile()));
preview->set_region_rect(tileset->tile_get_region(get_current_tile()));
if (tileset->tile_get_tile_mode(get_current_tile()) == TileSet::AUTO_TILE)
property_editor->show();
@@ -578,6 +579,7 @@ void TileSetEditor::_on_tile_list_selected(int p_index) {
if (get_current_tile() >= 0) {
current_item_index = p_index;
preview->set_texture(tileset->tile_get_texture(get_current_tile()));
+ preview->set_modulate(tileset->tile_get_modulate(get_current_tile()));
preview->set_region_rect(tileset->tile_get_region(get_current_tile()));
workspace->set_custom_minimum_size(tileset->tile_get_region(get_current_tile()).size);
update_workspace_tile_mode();
@@ -1736,6 +1738,7 @@ void TileSetEditor::update_tile_list() {
region.position += pos;
}
tile_list->set_item_icon_region(tile_list->get_item_count() - 1, region);
+ tile_list->set_item_icon_modulate(tile_list->get_item_count() - 1, tileset->tile_get_modulate(E->get()));
}
if (tile_list->get_item_count() > 0 && selected_tile < tile_list->get_item_count()) {
tile_list->select(selected_tile);
@@ -1763,6 +1766,7 @@ void TileSetEditor::update_tile_list_icon() {
tile_list->set_item_metadata(current_idx, E->get());
tile_list->set_item_icon(current_idx, tileset->tile_get_texture(E->get()));
tile_list->set_item_icon_region(current_idx, region);
+ tile_list->set_item_icon_modulate(current_idx, tileset->tile_get_modulate(E->get()));
tile_list->set_item_text(current_idx, tileset->tile_get_name(E->get()));
current_idx += 1;
}
diff --git a/scene/gui/item_list.cpp b/scene/gui/item_list.cpp
index cc17e6bcd81..fa7c9e091e1 100644
--- a/scene/gui/item_list.cpp
+++ b/scene/gui/item_list.cpp
@@ -37,6 +37,7 @@ void ItemList::add_item(const String &p_item, const Ref &p_texture, boo
Item item;
item.icon = p_texture;
item.icon_region = Rect2i();
+ item.icon_modulate = Color(1, 1, 1, 1);
item.text = p_item;
item.selectable = p_selectable;
item.selected = false;
@@ -54,6 +55,7 @@ void ItemList::add_icon_item(const Ref &p_item, bool p_selectable) {
Item item;
item.icon = p_item;
item.icon_region = Rect2i();
+ item.icon_modulate = Color(1, 1, 1, 1);
//item.text=p_item;
item.selectable = p_selectable;
item.selected = false;
@@ -138,6 +140,21 @@ Rect2 ItemList::get_item_icon_region(int p_idx) const {
return items[p_idx].icon_region;
}
+void ItemList::set_item_icon_modulate(int p_idx, const Color &p_modulate) {
+
+ ERR_FAIL_INDEX(p_idx, items.size());
+
+ items[p_idx].icon_modulate = p_modulate;
+ update();
+}
+
+Color ItemList::get_item_icon_modulate(int p_idx) const {
+
+ ERR_FAIL_INDEX_V(p_idx, items.size(), Color());
+
+ return items[p_idx].icon_modulate;
+}
+
void ItemList::set_item_custom_bg_color(int p_idx, const Color &p_custom_bg_color) {
ERR_FAIL_INDEX(p_idx, items.size());
@@ -1045,7 +1062,7 @@ void ItemList::_notification(int p_what) {
draw_rect.size = adj.size;
}
- Color modulate = Color(1, 1, 1, 1);
+ Color modulate = items[i].icon_modulate;
if (items[i].disabled)
modulate.a *= 0.5;
@@ -1389,6 +1406,9 @@ void ItemList::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_item_icon_region", "idx", "rect"), &ItemList::set_item_icon_region);
ClassDB::bind_method(D_METHOD("get_item_icon_region", "idx"), &ItemList::get_item_icon_region);
+ ClassDB::bind_method(D_METHOD("set_item_icon_modulate", "idx", "modulate"), &ItemList::set_item_icon_modulate);
+ ClassDB::bind_method(D_METHOD("get_item_icon_modulate", "idx"), &ItemList::get_item_icon_modulate);
+
ClassDB::bind_method(D_METHOD("set_item_selectable", "idx", "selectable"), &ItemList::set_item_selectable);
ClassDB::bind_method(D_METHOD("is_item_selectable", "idx"), &ItemList::is_item_selectable);
diff --git a/scene/gui/item_list.h b/scene/gui/item_list.h
index 0fa0dd415b4..58771c17770 100644
--- a/scene/gui/item_list.h
+++ b/scene/gui/item_list.h
@@ -54,6 +54,7 @@ private:
Ref icon;
Rect2i icon_region;
+ Color icon_modulate;
Ref tag_icon;
String text;
bool selectable;
@@ -135,6 +136,9 @@ public:
void set_item_icon_region(int p_idx, const Rect2 &p_region);
Rect2 get_item_icon_region(int p_idx) const;
+ void set_item_icon_modulate(int p_idx, const Color &p_modulate);
+ Color get_item_icon_modulate(int p_idx) const;
+
void set_item_selectable(int p_idx, bool p_selectable);
bool is_item_selectable(int p_idx) const;
diff --git a/scene/resources/tile_set.cpp b/scene/resources/tile_set.cpp
index 4463f98b077..7fdc296bb41 100644
--- a/scene/resources/tile_set.cpp
+++ b/scene/resources/tile_set.cpp
@@ -347,6 +347,7 @@ void TileSet::tile_set_modulate(int p_id, const Color &p_modulate) {
ERR_FAIL_COND(!tile_map.has(p_id));
tile_map[p_id].modulate = p_modulate;
emit_changed();
+ _change_notify("modulate");
}
Color TileSet::tile_get_modulate(int p_id) const {