|
@@ -242,6 +242,7 @@ void TileSetEditor::_bind_methods() {
|
|
|
ClassDB::bind_method("_name_dialog_confirm", &TileSetEditor::_name_dialog_confirm);
|
|
|
ClassDB::bind_method("_on_tile_list_selected", &TileSetEditor::_on_tile_list_selected);
|
|
|
ClassDB::bind_method("_on_edit_mode_changed", &TileSetEditor::_on_edit_mode_changed);
|
|
|
+ ClassDB::bind_method("_on_workspace_overlay_draw", &TileSetEditor::_on_workspace_overlay_draw);
|
|
|
ClassDB::bind_method("_on_workspace_draw", &TileSetEditor::_on_workspace_draw);
|
|
|
ClassDB::bind_method("_on_workspace_input", &TileSetEditor::_on_workspace_input);
|
|
|
ClassDB::bind_method("_on_tool_clicked", &TileSetEditor::_on_tool_clicked);
|
|
@@ -519,10 +520,15 @@ void TileSetEditor::initialize_bottom_editor() {
|
|
|
workspace_container = memnew(Control);
|
|
|
scroll->add_child(workspace_container);
|
|
|
|
|
|
+ workspace_overlay = memnew(Control);
|
|
|
+ workspace_overlay->connect("draw", this, "_on_workspace_overlay_draw");
|
|
|
+ workspace_container->add_child(workspace_overlay);
|
|
|
+
|
|
|
workspace = memnew(Control);
|
|
|
workspace->connect("draw", this, "_on_workspace_draw");
|
|
|
workspace->connect("gui_input", this, "_on_workspace_input");
|
|
|
- workspace_container->add_child(workspace);
|
|
|
+ workspace->set_draw_behind_parent(true);
|
|
|
+ workspace_overlay->add_child(workspace);
|
|
|
|
|
|
preview = memnew(Sprite);
|
|
|
workspace->add_child(preview);
|
|
@@ -558,6 +564,8 @@ TileSetEditor::TileSetEditor(EditorNode *p_editor) {
|
|
|
add_child(err_dialog);
|
|
|
err_dialog->set_title(TTR("Error"));
|
|
|
|
|
|
+ draw_handles = false;
|
|
|
+
|
|
|
initialize_bottom_editor();
|
|
|
}
|
|
|
|
|
@@ -739,9 +747,23 @@ void TileSetEditor::_on_workspace_draw() {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ workspace_overlay->update();
|
|
|
+}
|
|
|
+
|
|
|
+void TileSetEditor::_on_workspace_overlay_draw() {
|
|
|
+
|
|
|
+ int t_id = get_current_tile();
|
|
|
+ if (t_id < 0 || !draw_handles)
|
|
|
+ return;
|
|
|
+
|
|
|
+ Ref<Texture> handle = get_icon("EditorHandle", "EditorIcons");
|
|
|
+
|
|
|
+ for (int i = 0; i < current_shape.size(); i++) {
|
|
|
+ workspace_overlay->draw_texture(handle, current_shape[i] * workspace->get_scale().x - handle->get_size() * 0.5);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
-#define MIN_DISTANCE_SQUARED 10
|
|
|
+#define MIN_DISTANCE_SQUARED 6
|
|
|
void TileSetEditor::_on_workspace_input(const Ref<InputEvent> &p_ie) {
|
|
|
|
|
|
if (get_current_tile() >= 0 && !tileset.is_null()) {
|
|
@@ -1162,15 +1184,18 @@ void TileSetEditor::_on_tool_clicked(int p_tool) {
|
|
|
scale /= 2;
|
|
|
workspace->set_scale(Vector2(scale, scale));
|
|
|
workspace_container->set_custom_minimum_size(preview->get_region_rect().size * scale);
|
|
|
+ workspace_overlay->set_custom_minimum_size(preview->get_region_rect().size * scale);
|
|
|
}
|
|
|
} else if (p_tool == ZOOM_1) {
|
|
|
workspace->set_scale(Vector2(1, 1));
|
|
|
workspace_container->set_custom_minimum_size(preview->get_region_rect().size);
|
|
|
+ workspace_overlay->set_custom_minimum_size(preview->get_region_rect().size);
|
|
|
} else if (p_tool == ZOOM_IN) {
|
|
|
float scale = workspace->get_scale().x;
|
|
|
scale *= 2;
|
|
|
workspace->set_scale(Vector2(scale, scale));
|
|
|
workspace_container->set_custom_minimum_size(preview->get_region_rect().size * scale);
|
|
|
+ workspace_overlay->set_custom_minimum_size(preview->get_region_rect().size * scale);
|
|
|
} else if (p_tool == TOOL_SELECT) {
|
|
|
if (creating_shape) {
|
|
|
//Cancel Creation
|
|
@@ -1292,6 +1317,8 @@ void TileSetEditor::draw_polygon_shapes() {
|
|
|
if (t_id < 0)
|
|
|
return;
|
|
|
|
|
|
+ draw_handles = false;
|
|
|
+
|
|
|
switch (edit_mode) {
|
|
|
case EDITMODE_COLLISION: {
|
|
|
Vector<TileSet::ShapeData> sd = tileset->tile_get_shapes(t_id);
|
|
@@ -1339,9 +1366,7 @@ void TileSetEditor::draw_polygon_shapes() {
|
|
|
}
|
|
|
|
|
|
if (shape == edited_collision_shape) {
|
|
|
- for (int j = 0; j < current_shape.size(); j++) {
|
|
|
- workspace->draw_circle(current_shape[j], 8 / workspace->get_scale().x, Color(1, 0, 0, 0.7f));
|
|
|
- }
|
|
|
+ draw_handles = true;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -1367,9 +1392,7 @@ void TileSetEditor::draw_polygon_shapes() {
|
|
|
}
|
|
|
workspace->draw_line(shape->get_polygon()[shape->get_polygon().size() - 1], shape->get_polygon()[0], c_border, 1, true);
|
|
|
if (shape == edited_occlusion_shape) {
|
|
|
- for (int j = 0; j < current_shape.size(); j++) {
|
|
|
- workspace->draw_circle(current_shape[j], 8 / workspace->get_scale().x, Color(1, 0, 0));
|
|
|
- }
|
|
|
+ draw_handles = true;
|
|
|
}
|
|
|
}
|
|
|
} else {
|
|
@@ -1412,9 +1435,7 @@ void TileSetEditor::draw_polygon_shapes() {
|
|
|
}
|
|
|
workspace->draw_line(shape->get_polygon()[shape->get_polygon().size() - 1] + anchor, shape->get_polygon()[0] + anchor, c_border, 1, true);
|
|
|
if (shape == edited_occlusion_shape) {
|
|
|
- for (int j = 0; j < current_shape.size(); j++) {
|
|
|
- workspace->draw_circle(current_shape[j], 8 / workspace->get_scale().x, Color(1, 0, 0));
|
|
|
- }
|
|
|
+ draw_handles = true;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -1445,9 +1466,7 @@ void TileSetEditor::draw_polygon_shapes() {
|
|
|
workspace->draw_line(vertices[shape->get_polygon(0)[j]], vertices[shape->get_polygon(0)[j + 1]], c_border, 1, true);
|
|
|
}
|
|
|
if (shape == edited_navigation_shape) {
|
|
|
- for (int j = 0; j < current_shape.size(); j++) {
|
|
|
- workspace->draw_circle(current_shape[j], 8 / workspace->get_scale().x, Color(1, 0, 0));
|
|
|
- }
|
|
|
+ draw_handles = true;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -1494,9 +1513,7 @@ void TileSetEditor::draw_polygon_shapes() {
|
|
|
workspace->draw_line(vertices[shape->get_polygon(0)[j]] + anchor, vertices[shape->get_polygon(0)[j + 1]] + anchor, c_border, 1, true);
|
|
|
}
|
|
|
if (shape == edited_navigation_shape) {
|
|
|
- for (int j = 0; j < current_shape.size(); j++) {
|
|
|
- workspace->draw_circle(current_shape[j], 8 / workspace->get_scale().x, Color(1, 0, 0));
|
|
|
- }
|
|
|
+ draw_handles = true;
|
|
|
}
|
|
|
}
|
|
|
}
|