Merge pull request #21456 from MarianoGnu/tileset_editor
TileSet editor Fixes
This commit is contained in:
commit
9df5ddae29
|
@ -457,6 +457,7 @@ void TileMapEditor::_update_palette() {
|
|||
palette->select(0);
|
||||
}
|
||||
|
||||
if (sel_tile != TileMap::INVALID_CELL) {
|
||||
if ((manual_autotile && tileset->tile_get_tile_mode(sel_tile) == TileSet::AUTO_TILE) || tileset->tile_get_tile_mode(sel_tile) == TileSet::ATLAS_TILE) {
|
||||
|
||||
const Map<Vector2, uint16_t> &tiles = tileset->autotile_get_bitmask_map(sel_tile);
|
||||
|
@ -489,6 +490,7 @@ void TileMapEditor::_update_palette() {
|
|||
manual_palette->set_item_metadata(manual_palette->get_item_count() - 1, entries[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (manual_palette->get_item_count() > 0) {
|
||||
// Only show the manual palette if at least tile exists in it
|
||||
|
|
|
@ -1715,16 +1715,18 @@ void TileSetEditor::draw_polygon_shapes() {
|
|||
|
||||
Vector<Vector2> polygon;
|
||||
Vector<Color> colors;
|
||||
Vector2 anchor = WORKSPACE_MARGIN;
|
||||
anchor += tileset->tile_get_region(get_current_tile()).position;
|
||||
for (int j = 0; j < shape->get_polygon().size(); j++) {
|
||||
polygon.push_back(shape->get_polygon()[j]);
|
||||
polygon.push_back(shape->get_polygon()[j] + anchor);
|
||||
colors.push_back(c_bg);
|
||||
}
|
||||
workspace->draw_polygon(polygon, colors);
|
||||
|
||||
for (int j = 0; j < shape->get_polygon().size() - 1; j++) {
|
||||
workspace->draw_line(shape->get_polygon()[j], shape->get_polygon()[j + 1], c_border, 1, true);
|
||||
workspace->draw_line(shape->get_polygon()[j] + anchor, shape->get_polygon()[j + 1] + anchor, c_border, 1, true);
|
||||
}
|
||||
workspace->draw_line(shape->get_polygon()[shape->get_polygon().size() - 1], shape->get_polygon()[0], c_border, 1, true);
|
||||
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) {
|
||||
draw_handles = true;
|
||||
}
|
||||
|
@ -1788,10 +1790,11 @@ void TileSetEditor::draw_polygon_shapes() {
|
|||
|
||||
Vector<Vector2> polygon;
|
||||
Vector<Color> colors;
|
||||
|
||||
Vector2 anchor = WORKSPACE_MARGIN;
|
||||
anchor += tileset->tile_get_region(get_current_tile()).position;
|
||||
PoolVector<Vector2> vertices = shape->get_vertices();
|
||||
for (int j = 0; j < shape->get_polygon(0).size(); j++) {
|
||||
polygon.push_back(vertices[shape->get_polygon(0)[j]]);
|
||||
polygon.push_back(vertices[shape->get_polygon(0)[j]] + anchor);
|
||||
colors.push_back(c_bg);
|
||||
}
|
||||
workspace->draw_polygon(polygon, colors);
|
||||
|
@ -1799,7 +1802,7 @@ void TileSetEditor::draw_polygon_shapes() {
|
|||
if (shape->get_polygon_count() > 0) {
|
||||
PoolVector<Vector2> vertices = shape->get_vertices();
|
||||
for (int j = 0; j < shape->get_polygon(0).size() - 1; j++) {
|
||||
workspace->draw_line(vertices[shape->get_polygon(0)[j]], vertices[shape->get_polygon(0)[j + 1]], c_border, 1, true);
|
||||
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) {
|
||||
draw_handles = true;
|
||||
|
@ -1954,6 +1957,8 @@ void TileSetEditor::close_shape(const Vector2 &shape_anchor) {
|
|||
|
||||
void TileSetEditor::select_coord(const Vector2 &coord) {
|
||||
current_shape = PoolVector2Array();
|
||||
if (get_current_tile() == -1)
|
||||
return;
|
||||
Rect2 current_tile_region = tileset->tile_get_region(get_current_tile());
|
||||
current_tile_region.position += WORKSPACE_MARGIN;
|
||||
if (tileset->tile_get_tile_mode(get_current_tile()) == TileSet::SINGLE_TILE) {
|
||||
|
@ -2038,8 +2043,10 @@ Vector2 TileSetEditor::snap_point(const Vector2 &point) {
|
|||
anchor += tileset->tile_get_region(get_current_tile()).position;
|
||||
anchor += WORKSPACE_MARGIN;
|
||||
Rect2 region(anchor, tile_size);
|
||||
if (tileset->tile_get_tile_mode(get_current_tile()) == TileSet::SINGLE_TILE)
|
||||
if (tileset->tile_get_tile_mode(get_current_tile()) == TileSet::SINGLE_TILE) {
|
||||
region.position = tileset->tile_get_region(get_current_tile()).position + WORKSPACE_MARGIN;
|
||||
region.size = tileset->tile_get_region(get_current_tile()).size;
|
||||
}
|
||||
|
||||
if (tools[TOOL_GRID_SNAP]->is_pressed()) {
|
||||
p.x = Math::snap_scalar_seperation(snap_offset.x, snap_step.x, p.x, snap_separation.x);
|
||||
|
@ -2254,6 +2261,9 @@ bool TilesetEditorContext::_set(const StringName &p_name, const Variant &p_value
|
|||
tileset_editor->workspace_overlay->update();
|
||||
}
|
||||
return v;
|
||||
} else if (name == "tileset_script") {
|
||||
tileset->set_script(p_value);
|
||||
return true;
|
||||
}
|
||||
|
||||
tileset_editor->err_dialog->set_text(TTR("This property can't be changed."));
|
||||
|
@ -2302,6 +2312,9 @@ bool TilesetEditorContext::_get(const StringName &p_name, Variant &r_ret) const
|
|||
} else if (name == "selected_occlusion") {
|
||||
r_ret = tileset_editor->edited_occlusion_shape;
|
||||
v = true;
|
||||
} else if (name == "tileset_script") {
|
||||
r_ret = tileset->get_script();
|
||||
v = true;
|
||||
}
|
||||
return v;
|
||||
}
|
||||
|
@ -2346,6 +2359,9 @@ void TilesetEditorContext::_get_property_list(List<PropertyInfo> *p_list) const
|
|||
if (tileset_editor->edit_mode == TileSetEditor::EDITMODE_OCCLUSION && tileset_editor->edited_occlusion_shape.is_valid()) {
|
||||
p_list->push_back(PropertyInfo(Variant::OBJECT, "selected_occlusion", PROPERTY_HINT_RESOURCE_TYPE, tileset_editor->edited_occlusion_shape->get_class()));
|
||||
}
|
||||
if (!tileset.is_null()) {
|
||||
p_list->push_back(PropertyInfo(Variant::OBJECT, "tileset_script", PROPERTY_HINT_RESOURCE_TYPE, "Script"));
|
||||
}
|
||||
}
|
||||
|
||||
TilesetEditorContext::TilesetEditorContext(TileSetEditor *p_tileset_editor) {
|
||||
|
|
Loading…
Reference in New Issue