aboutsummaryrefslogtreecommitdiff
path: root/tools/editor/plugins/tile_map_editor_plugin.cpp
diff options
context:
space:
mode:
authorJuan Linietsky2015-03-09 02:34:56 -0300
committerJuan Linietsky2015-03-09 02:34:56 -0300
commit09489e3a78de39bb4d8690f3c65f8a5e7a56a95e (patch)
treeb6207118763b8f1ec81c9d5b7e483813363253c2 /tools/editor/plugins/tile_map_editor_plugin.cpp
parent2c2894ceb674927a35d2798b3e63adabdb020077 (diff)
downloadgodot-09489e3a78de39bb4d8690f3c65f8a5e7a56a95e.tar.gz
godot-09489e3a78de39bb4d8690f3c65f8a5e7a56a95e.tar.zst
godot-09489e3a78de39bb4d8690f3c65f8a5e7a56a95e.zip
Diffstat (limited to 'tools/editor/plugins/tile_map_editor_plugin.cpp')
-rw-r--r--tools/editor/plugins/tile_map_editor_plugin.cpp40
1 files changed, 37 insertions, 3 deletions
diff --git a/tools/editor/plugins/tile_map_editor_plugin.cpp b/tools/editor/plugins/tile_map_editor_plugin.cpp
index 47727a00c..79e43f901 100644
--- a/tools/editor/plugins/tile_map_editor_plugin.cpp
+++ b/tools/editor/plugins/tile_map_editor_plugin.cpp
@@ -640,19 +640,53 @@ void TileMapEditor::_canvas_draw() {
Ref<Texture> t = ts->tile_get_texture(st);
if (t.is_valid()) {
- Vector2 from = xform.xform(ts->tile_get_texture_offset(st)+node->map_to_world(over_tile)+node->get_cell_draw_offset());
+ Vector2 from = node->map_to_world(over_tile)+node->get_cell_draw_offset();
Rect2 r = ts->tile_get_region(st);
Size2 sc = xform.get_scale();
if (mirror_x->is_pressed())
sc.x*=-1.0;
if (mirror_y->is_pressed())
sc.y*=-1.0;
+
+ Rect2 rect;
+ if (r==Rect2()) {
+ rect=Rect2(from,t->get_size());
+ } else {
+
+ rect=Rect2(from,r.get_size());
+ }
+
+
+ if (node->get_tile_origin()==TileMap::TILE_ORIGIN_TOP_LEFT) {
+ rect.pos+=ts->tile_get_texture_offset(st);
+
+ } else if (node->get_tile_origin()==TileMap::TILE_ORIGIN_CENTER) {
+ rect.pos+=node->get_cell_size()/2;
+ Vector2 s = r.size;
+
+ Vector2 center = (s/2) - ts->tile_get_texture_offset(st);
+
+
+ if (mirror_x->is_pressed())
+ rect.pos.x-=s.x-center.x;
+ else
+ rect.pos.x-=center.x;
+
+ if (mirror_y->is_pressed())
+ rect.pos.y-=s.y-center.y;
+ else
+ rect.pos.y-=center.y;
+ }
+
+ rect.pos=xform.xform(rect.pos);
+ rect.size*=sc;
+
if (r==Rect2()) {
- canvas_item_editor->draw_texture_rect(t,Rect2(from,t->get_size()*sc),false,Color(1,1,1,0.5),transpose->is_pressed());
+ canvas_item_editor->draw_texture_rect(t,rect,false,Color(1,1,1,0.5),transpose->is_pressed());
} else {
- canvas_item_editor->draw_texture_rect_region(t,Rect2(from,r.get_size()*sc),r,Color(1,1,1,0.5),transpose->is_pressed());
+ canvas_item_editor->draw_texture_rect_region(t,rect,r,Color(1,1,1,0.5),transpose->is_pressed());
}
}
}