summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorFranklin Sobrinho <franklin_gs@hotmail.com>2015-06-22 11:10:13 -0300
committerFranklin Sobrinho <franklin_gs@hotmail.com>2015-06-22 11:10:13 -0300
commit0159cecd6950a11853c243d09867ad20d8ac5cec (patch)
treed2534837930f35a3ed3edcbfade6847e59736e29 /tools
parentd68a33b47383d4c1e0c6cc501d33ce8ce4ed4e8d (diff)
Small fixes for Grid/Tile map editor palette
Diffstat (limited to 'tools')
-rw-r--r--tools/editor/plugins/tile_map_editor_plugin.cpp27
1 files changed, 14 insertions, 13 deletions
diff --git a/tools/editor/plugins/tile_map_editor_plugin.cpp b/tools/editor/plugins/tile_map_editor_plugin.cpp
index 7d5f2669aa..017a26441d 100644
--- a/tools/editor/plugins/tile_map_editor_plugin.cpp
+++ b/tools/editor/plugins/tile_map_editor_plugin.cpp
@@ -79,11 +79,11 @@ int TileMapEditor::get_selected_tile() const {
void TileMapEditor::set_selected_tile(int p_tile) {
for (int i = 0; i < palette->get_item_count(); i++) {
- if (palette->get_item_metadata(i).operator int() == p_tile) {
- palette->select(i,true);
- palette->ensure_current_is_visible();
- break;
- }
+ if (palette->get_item_metadata(i).operator int() == p_tile) {
+ palette->select(i,true);
+ palette->ensure_current_is_visible();
+ break;
+ }
}
}
@@ -170,16 +170,16 @@ void TileMapEditor::_update_palette() {
if (tex.is_valid()) {
Rect2 region = tileset->tile_get_region(E->get());
- if (region==Rect2()) {
- continue;
- }
-
- Image data = VS::get_singleton()->texture_get_data(tex->get_rid());
+ if (!region.has_no_area()) {
+ Image data = VS::get_singleton()->texture_get_data(tex->get_rid());
- Ref<ImageTexture> img = memnew( ImageTexture );
- img->create_from_image(data.get_rect(region));
+ Ref<ImageTexture> img = memnew( ImageTexture );
+ img->create_from_image(data.get_rect(region));
- palette->set_item_icon(palette->get_item_count()-1, img);
+ palette->set_item_icon(palette->get_item_count()-1, img);
+ } else {
+ palette->set_item_icon(palette->get_item_count()-1,tex);
+ }
}
if (tileset->tile_get_name(E->get())!="") {
@@ -187,6 +187,7 @@ void TileMapEditor::_update_palette() {
} else {
palette->set_item_text(palette->get_item_count()-1, "#"+itos(E->get()));
}
+
palette->set_item_metadata(palette->get_item_count()-1, E->get());
}
}