summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Alexsander Silva Dias <michaelalexsander@protonmail.com>2019-04-15 15:35:48 -0300
committerGitHub <noreply@github.com>2019-04-15 15:35:48 -0300
commit55c759076349b55c6acf7592632f5f9523fe6ace (patch)
tree701cb3ca5dcb329c27c2f3f85143bd758ab18643
parent06e580f5ba801cf524b1d82753127a9992c7b907 (diff)
parentd2a76246871ed3595803a78ccbdd87ea86fa4cc7 (diff)
Merge pull request #27944 from YeldhamDev/tile_name_position_fix
Fix position of tile names in TileSet editor when zooming in/out
-rw-r--r--editor/plugins/tile_set_editor_plugin.cpp39
1 files changed, 20 insertions, 19 deletions
diff --git a/editor/plugins/tile_set_editor_plugin.cpp b/editor/plugins/tile_set_editor_plugin.cpp
index 03277159fc..8cf00cf67d 100644
--- a/editor/plugins/tile_set_editor_plugin.cpp
+++ b/editor/plugins/tile_set_editor_plugin.cpp
@@ -1038,25 +1038,26 @@ void TileSetEditor::_on_workspace_overlay_draw() {
tileset->get_tile_list(tiles);
for (List<int>::Element *E = tiles->front(); E; E = E->next()) {
int t_id = E->get();
- if (tileset->tile_get_texture(t_id)->get_rid() == current_texture_rid) {
- Rect2i region = tileset->tile_get_region(t_id);
- region.position += WORKSPACE_MARGIN;
- region.position *= workspace->get_scale().x;
- Color c;
- if (tileset->tile_get_tile_mode(t_id) == TileSet::SINGLE_TILE)
- c = COLOR_SINGLE;
- else if (tileset->tile_get_tile_mode(t_id) == TileSet::AUTO_TILE)
- c = COLOR_AUTOTILE;
- else if (tileset->tile_get_tile_mode(t_id) == TileSet::ATLAS_TILE)
- c = COLOR_ATLAS;
- String tile_id_name = String::num(t_id, 0) + ": " + tileset->tile_get_name(t_id);
- Ref<Font> font = get_font("font", "Label");
- region.set_size(font->get_string_size(tile_id_name));
- workspace_overlay->draw_rect(region, c);
- region.position.y += region.size.y - 2;
- c = Color(0.1, 0.1, 0.1);
- workspace_overlay->draw_string(font, region.position, tile_id_name, c);
- }
+ if (tileset->tile_get_texture(t_id)->get_rid() != current_texture_rid)
+ continue;
+
+ Rect2 region = tileset->tile_get_region(t_id);
+ region.position += WORKSPACE_MARGIN;
+ region.position *= workspace->get_scale().x;
+ Color c;
+ if (tileset->tile_get_tile_mode(t_id) == TileSet::SINGLE_TILE)
+ c = COLOR_SINGLE;
+ else if (tileset->tile_get_tile_mode(t_id) == TileSet::AUTO_TILE)
+ c = COLOR_AUTOTILE;
+ else if (tileset->tile_get_tile_mode(t_id) == TileSet::ATLAS_TILE)
+ c = COLOR_ATLAS;
+ String tile_id_name = String::num(t_id, 0) + ": " + tileset->tile_get_name(t_id);
+ Ref<Font> font = get_font("font", "Label");
+ region.set_size(font->get_string_size(tile_id_name));
+ workspace_overlay->draw_rect(region, c);
+ region.position.y += region.size.y - 2;
+ c = Color(0.1, 0.1, 0.1);
+ workspace_overlay->draw_string(font, region.position, tile_id_name, c);
}
}