mirror of
https://github.com/Relintai/pandemonium_engine.git
synced 2025-01-22 09:07:17 +01:00
Work on fixing compile when layered tile maps are enabled.
This commit is contained in:
parent
13d0ac8d5d
commit
160374e539
@ -4,8 +4,8 @@
|
||||
Exposes a set of scenes as tiles for a [LayeredTileSet] resource.
|
||||
</brief_description>
|
||||
<description>
|
||||
When placed on a [LayeredTileMap], tiles from [LayeredTileSetScenesCollectionSource] will automatically instantiate an associated scene at the cell's position in the LayeredTileMap.
|
||||
Scenes are instantiated as children of the [LayeredTileMap] when it enters the tree. If you add/remove a scene tile in the [LayeredTileMap] that is already inside the tree, the [LayeredTileMap] will automatically instantiate/free the scene accordingly.
|
||||
When placed on a [LayeredTileMap], tiles from [LayeredTileSetScenesCollectionSource] will automatically instance an associated scene at the cell's position in the LayeredTileMap.
|
||||
Scenes are instanced as children of the [LayeredTileMap] when it enters the tree. If you add/remove a scene tile in the [LayeredTileMap] that is already inside the tree, the [LayeredTileMap] will automatically instance/free the scene accordingly.
|
||||
</description>
|
||||
<tutorials>
|
||||
</tutorials>
|
||||
|
@ -44,7 +44,7 @@ void AtlasMergingDialog::_property_changed(const StringName &p_property, const V
|
||||
}
|
||||
|
||||
void AtlasMergingDialog::_generate_merged(const Vector<Ref<LayeredTileSetAtlasSource>> &p_atlas_sources, int p_max_columns) {
|
||||
merged.instantiate();
|
||||
merged.instance();
|
||||
merged_mapping.clear();
|
||||
|
||||
if (p_atlas_sources.size() >= 2) {
|
||||
|
@ -593,7 +593,7 @@ void LayeredTileAtlasView::_notification(int p_what) {
|
||||
}
|
||||
|
||||
void LayeredTileAtlasView::_bind_methods() {
|
||||
ADD_SIGNAL(MethodInfo("transform_changed", PropertyInfo(Variant::FLOAT, "zoom"), PropertyInfo(Variant::VECTOR2, "scroll")));
|
||||
ADD_SIGNAL(MethodInfo("transform_changed", PropertyInfo(Variant::REAL, "zoom"), PropertyInfo(Variant::VECTOR2, "scroll")));
|
||||
}
|
||||
|
||||
LayeredTileAtlasView::LayeredTileAtlasView() {
|
||||
@ -622,7 +622,7 @@ LayeredTileAtlasView::LayeredTileAtlasView() {
|
||||
button_center_view->set_tooltip_text(TTR("Center View"));
|
||||
add_child(button_center_view);
|
||||
|
||||
panner.instantiate();
|
||||
panner.instance();
|
||||
panner->set_callbacks(callable_mp(this, &LayeredTileAtlasView::_pan_callback), callable_mp(this, &LayeredTileAtlasView::_zoom_callback));
|
||||
panner->set_enable_rmb(true);
|
||||
|
||||
|
@ -86,11 +86,11 @@ void LayeredTileDataEditor::_bind_methods() {
|
||||
|
||||
void LayeredTileDataEditor::set_tile_set(Ref<LayeredTileSet> p_tile_set) {
|
||||
if (tile_set.is_valid()) {
|
||||
tile_set->disconnect_changed(callable_mp(this, &LayeredTileDataEditor::_tile_set_changed_plan_update));
|
||||
tile_set->disconnect(CoreStringNames::get_singleton()->changed, callable_mp(this, &LayeredTileDataEditor::_tile_set_changed_plan_update));
|
||||
}
|
||||
tile_set = p_tile_set;
|
||||
if (tile_set.is_valid()) {
|
||||
tile_set->connect_changed(callable_mp(this, &LayeredTileDataEditor::_tile_set_changed_plan_update));
|
||||
tile_set->connect(CoreStringNames::get_singleton()->changed, callable_mp(this, &LayeredTileDataEditor::_tile_set_changed_plan_update));
|
||||
}
|
||||
_tile_set_changed_plan_update();
|
||||
}
|
||||
@ -405,7 +405,7 @@ void GenericTilePolygonEditor::_grab_polygon_segment_point(Vector2 p_pos, const
|
||||
const Vector<Vector2> &polygon = polygons[i];
|
||||
for (int j = 0; j < polygon.size(); j++) {
|
||||
Vector2 segment[2] = { polygon[j], polygon[(j + 1) % polygon.size()] };
|
||||
Vector2 closest_point = Geometry2D::get_closest_point_to_segment(point, segment);
|
||||
Vector2 closest_point = Geometry::get_closest_point_to_segment(point, segment);
|
||||
float distance = closest_point.distance_to(point);
|
||||
if (distance < grab_threshold / editor_zoom_widget->get_zoom() && distance < closest_distance) {
|
||||
r_polygon_index = i;
|
||||
@ -441,7 +441,7 @@ void GenericTilePolygonEditor::_snap_to_tile_shape(Point2 &r_point, float &r_cur
|
||||
if (!snapped) {
|
||||
for (int i = 0; i < polygon.size(); i++) {
|
||||
Point2 segment[2] = { polygon[i], polygon[(i + 1) % polygon.size()] };
|
||||
Point2 point = Geometry2D::get_closest_point_to_segment(r_point, segment);
|
||||
Point2 point = Geometry::get_closest_point_to_segment(r_point, segment);
|
||||
float distance = r_point.distance_to(point);
|
||||
if (distance < p_snap_dist && distance < r_current_snapped_dist) {
|
||||
snapped_point = point;
|
||||
@ -849,7 +849,7 @@ GenericTilePolygonEditor::GenericTilePolygonEditor() {
|
||||
toolbar = memnew(HBoxContainer);
|
||||
add_child(toolbar);
|
||||
|
||||
tools_button_group.instantiate();
|
||||
tools_button_group.instance();
|
||||
|
||||
button_expand = memnew(Button);
|
||||
button_expand->set_theme_type_variation("FlatButton");
|
||||
@ -1041,7 +1041,7 @@ void TileDataDefaultEditor::forward_painting_atlas_gui_input(LayeredTileAtlasVie
|
||||
Ref<InputEventMouseMotion> mm = p_event;
|
||||
if (mm.is_valid()) {
|
||||
if (drag_type == DRAG_TYPE_PAINT) {
|
||||
Vector<Vector2i> line = Geometry2D::bresenham_line(p_tile_atlas_view->get_atlas_tile_coords_at_pos(drag_last_pos, true), p_tile_atlas_view->get_atlas_tile_coords_at_pos(mm->get_position(), true));
|
||||
Vector<Vector2i> line = Geometry::bresenham_line(p_tile_atlas_view->get_atlas_tile_coords_at_pos(drag_last_pos, true), p_tile_atlas_view->get_atlas_tile_coords_at_pos(mm->get_position(), true));
|
||||
for (int i = 0; i < line.size(); i++) {
|
||||
Vector2i coords = p_tile_set_atlas_source->get_tile_at_coords(line[i]);
|
||||
if (coords != LayeredTileSetSource::INVALID_ATLAS_COORDS) {
|
||||
@ -1219,7 +1219,7 @@ void TileDataDefaultEditor::draw_over_tile(CanvasItem *p_canvas_item, Transform2
|
||||
String text;
|
||||
// Round floating point precision to 2 digits, as tiles don't have that much space.
|
||||
switch (value.get_type()) {
|
||||
case Variant::FLOAT:
|
||||
case Variant::REAL:
|
||||
text = vformat("%.2f", value);
|
||||
break;
|
||||
case Variant::VECTOR2:
|
||||
@ -1240,7 +1240,7 @@ void TileDataDefaultEditor::draw_over_tile(CanvasItem *p_canvas_item, Transform2
|
||||
color = selection_color;
|
||||
} else if (is_visible_in_tree()) {
|
||||
Variant painted_value = _get_painted_value();
|
||||
bool equal = (painted_value.get_type() == Variant::FLOAT && value.get_type() == Variant::FLOAT) ? Math::is_equal_approx(float(painted_value), float(value)) : painted_value == value;
|
||||
bool equal = (painted_value.get_type() == Variant::REAL && value.get_type() == Variant::REAL) ? Math::is_equal_approx(float(painted_value), float(value)) : painted_value == value;
|
||||
if (equal) {
|
||||
color = Color(0.7, 0.7, 0.7);
|
||||
}
|
||||
@ -1430,7 +1430,7 @@ void TileDataOcclusionShapeEditor::draw_over_tile(CanvasItem *p_canvas_item, Tra
|
||||
Variant TileDataOcclusionShapeEditor::_get_painted_value() {
|
||||
Ref<OccluderPolygon2D> occluder_polygon;
|
||||
if (polygon_editor->get_polygon_count() >= 1) {
|
||||
occluder_polygon.instantiate();
|
||||
occluder_polygon.instance();
|
||||
occluder_polygon->set_polygon(polygon_editor->get_polygon(0));
|
||||
}
|
||||
return occluder_polygon;
|
||||
@ -1531,7 +1531,7 @@ void TileDataCollisionEditor::_polygons_changed() {
|
||||
}
|
||||
|
||||
if (!property_editors.has(one_way_margin_property)) {
|
||||
EditorProperty *one_way_margin_property_editor = EditorInspectorDefaultPlugin::get_editor_for_property(dummy_object, Variant::FLOAT, one_way_margin_property, PROPERTY_HINT_NONE, "", PROPERTY_USAGE_DEFAULT);
|
||||
EditorProperty *one_way_margin_property_editor = EditorInspectorDefaultPlugin::get_editor_for_property(dummy_object, Variant::REAL, one_way_margin_property, PROPERTY_HINT_NONE, "", PROPERTY_USAGE_DEFAULT);
|
||||
one_way_margin_property_editor->set_object_and_property(dummy_object, one_way_margin_property);
|
||||
one_way_margin_property_editor->set_label(one_way_margin_property);
|
||||
one_way_margin_property_editor->connect("property_changed", callable_mp(this, &TileDataCollisionEditor::_property_value_changed).unbind(1));
|
||||
@ -1707,7 +1707,7 @@ TileDataCollisionEditor::TileDataCollisionEditor() {
|
||||
add_child(linear_velocity_editor);
|
||||
property_editors["linear_velocity"] = linear_velocity_editor;
|
||||
|
||||
EditorProperty *angular_velocity_editor = EditorInspectorDefaultPlugin::get_editor_for_property(dummy_object, Variant::FLOAT, "angular_velocity", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_DEFAULT);
|
||||
EditorProperty *angular_velocity_editor = EditorInspectorDefaultPlugin::get_editor_for_property(dummy_object, Variant::REAL, "angular_velocity", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_DEFAULT);
|
||||
angular_velocity_editor->set_object_and_property(dummy_object, "angular_velocity");
|
||||
angular_velocity_editor->set_label("angular_velocity");
|
||||
angular_velocity_editor->connect("property_changed", callable_mp(this, &TileDataCollisionEditor::_property_value_changed).unbind(1));
|
||||
@ -1864,7 +1864,7 @@ void TileDataTerrainsEditor::forward_draw_over_atlas(LayeredTileAtlasView *p_til
|
||||
color.push_back(Color(1.0, 1.0, 1.0, 0.5));
|
||||
|
||||
Vector<Vector2> polygon = tile_set->get_terrain_polygon(terrain_set);
|
||||
if (Geometry2D::is_point_in_polygon(xform.affine_inverse().xform(mouse_pos), polygon)) {
|
||||
if (Geometry::is_point_in_polygon(xform.affine_inverse().xform(mouse_pos), polygon)) {
|
||||
p_canvas_item->draw_set_transform_matrix(p_transform * xform);
|
||||
p_canvas_item->draw_polygon(polygon, color);
|
||||
}
|
||||
@ -1872,7 +1872,7 @@ void TileDataTerrainsEditor::forward_draw_over_atlas(LayeredTileAtlasView *p_til
|
||||
LayeredTileSet::CellNeighbor bit = LayeredTileSet::CellNeighbor(i);
|
||||
if (tile_set->is_valid_terrain_peering_bit(terrain_set, bit)) {
|
||||
polygon = tile_set->get_terrain_peering_bit_polygon(terrain_set, bit);
|
||||
if (Geometry2D::is_point_in_polygon(xform.affine_inverse().xform(mouse_pos), polygon)) {
|
||||
if (Geometry::is_point_in_polygon(xform.affine_inverse().xform(mouse_pos), polygon)) {
|
||||
p_canvas_item->draw_set_transform_matrix(p_transform * xform);
|
||||
p_canvas_item->draw_polygon(polygon, color);
|
||||
}
|
||||
@ -2003,7 +2003,7 @@ void TileDataTerrainsEditor::forward_draw_over_atlas(LayeredTileAtlasView *p_til
|
||||
for (int j = 0; j < polygon.size(); j++) {
|
||||
polygon.write[j] += position;
|
||||
}
|
||||
if (!Geometry2D::intersect_polygons(polygon, mouse_pos_rect_polygon).empty()) {
|
||||
if (!Geometry::intersect_polygons(polygon, mouse_pos_rect_polygon).empty()) {
|
||||
// Draw terrain.
|
||||
p_canvas_item->draw_polygon(polygon, color);
|
||||
}
|
||||
@ -2015,7 +2015,7 @@ void TileDataTerrainsEditor::forward_draw_over_atlas(LayeredTileAtlasView *p_til
|
||||
for (int j = 0; j < polygon.size(); j++) {
|
||||
polygon.write[j] += position;
|
||||
}
|
||||
if (!Geometry2D::intersect_polygons(polygon, mouse_pos_rect_polygon).empty()) {
|
||||
if (!Geometry::intersect_polygons(polygon, mouse_pos_rect_polygon).empty()) {
|
||||
// Draw bit.
|
||||
p_canvas_item->draw_polygon(polygon, color);
|
||||
}
|
||||
@ -2053,7 +2053,7 @@ void TileDataTerrainsEditor::forward_draw_over_alternatives(LayeredTileAtlasView
|
||||
color.push_back(Color(1.0, 1.0, 1.0, 0.5));
|
||||
|
||||
Vector<Vector2> polygon = tile_set->get_terrain_polygon(terrain_set);
|
||||
if (Geometry2D::is_point_in_polygon(xform.affine_inverse().xform(mouse_pos), polygon)) {
|
||||
if (Geometry::is_point_in_polygon(xform.affine_inverse().xform(mouse_pos), polygon)) {
|
||||
p_canvas_item->draw_set_transform_matrix(p_transform * xform);
|
||||
p_canvas_item->draw_polygon(polygon, color);
|
||||
}
|
||||
@ -2062,7 +2062,7 @@ void TileDataTerrainsEditor::forward_draw_over_alternatives(LayeredTileAtlasView
|
||||
LayeredTileSet::CellNeighbor bit = LayeredTileSet::CellNeighbor(i);
|
||||
if (tile_set->is_valid_terrain_peering_bit(terrain_set, bit)) {
|
||||
polygon = tile_set->get_terrain_peering_bit_polygon(terrain_set, bit);
|
||||
if (Geometry2D::is_point_in_polygon(xform.affine_inverse().xform(mouse_pos), polygon)) {
|
||||
if (Geometry::is_point_in_polygon(xform.affine_inverse().xform(mouse_pos), polygon)) {
|
||||
p_canvas_item->draw_set_transform_matrix(p_transform * xform);
|
||||
p_canvas_item->draw_polygon(polygon, color);
|
||||
}
|
||||
@ -2120,7 +2120,7 @@ void TileDataTerrainsEditor::forward_painting_atlas_gui_input(LayeredTileAtlasVi
|
||||
Ref<InputEventMouseMotion> mm = p_event;
|
||||
if (mm.is_valid()) {
|
||||
if (drag_type == DRAG_TYPE_PAINT_TERRAIN_SET) {
|
||||
Vector<Vector2i> line = Geometry2D::bresenham_line(p_tile_atlas_view->get_atlas_tile_coords_at_pos(drag_last_pos, true), p_tile_atlas_view->get_atlas_tile_coords_at_pos(mm->get_position(), true));
|
||||
Vector<Vector2i> line = Geometry::bresenham_line(p_tile_atlas_view->get_atlas_tile_coords_at_pos(drag_last_pos, true), p_tile_atlas_view->get_atlas_tile_coords_at_pos(mm->get_position(), true));
|
||||
for (int i = 0; i < line.size(); i++) {
|
||||
Vector2i coords = p_tile_set_atlas_source->get_tile_at_coords(line[i]);
|
||||
if (coords != LayeredTileSetSource::INVALID_ATLAS_COORDS) {
|
||||
@ -2154,7 +2154,7 @@ void TileDataTerrainsEditor::forward_painting_atlas_gui_input(LayeredTileAtlasVi
|
||||
} else if (drag_type == DRAG_TYPE_PAINT_TERRAIN_BITS) {
|
||||
int terrain_set = Dictionary(drag_painted_value)["terrain_set"];
|
||||
int terrain = Dictionary(drag_painted_value)["terrain"];
|
||||
Vector<Vector2i> line = Geometry2D::bresenham_line(p_tile_atlas_view->get_atlas_tile_coords_at_pos(drag_last_pos, true), p_tile_atlas_view->get_atlas_tile_coords_at_pos(mm->get_position(), true));
|
||||
Vector<Vector2i> line = Geometry::bresenham_line(p_tile_atlas_view->get_atlas_tile_coords_at_pos(drag_last_pos, true), p_tile_atlas_view->get_atlas_tile_coords_at_pos(mm->get_position(), true));
|
||||
for (int i = 0; i < line.size(); i++) {
|
||||
Vector2i coords = p_tile_set_atlas_source->get_tile_at_coords(line[i]);
|
||||
if (coords != LayeredTileSetSource::INVALID_ATLAS_COORDS) {
|
||||
@ -2184,14 +2184,14 @@ void TileDataTerrainsEditor::forward_painting_atlas_gui_input(LayeredTileAtlasVi
|
||||
Vector2i position = texture_region.get_center() + tile_data->get_texture_origin();
|
||||
|
||||
Vector<Vector2> polygon = tile_set->get_terrain_polygon(tile_data->get_terrain_set());
|
||||
if (Geometry2D::is_segment_intersecting_polygon(mm->get_position() - position, drag_last_pos - position, polygon)) {
|
||||
if (Geometry::is_segment_intersecting_polygon(mm->get_position() - position, drag_last_pos - position, polygon)) {
|
||||
tile_data->set_terrain(terrain);
|
||||
}
|
||||
for (int j = 0; j < LayeredTileSet::CELL_NEIGHBOR_MAX; j++) {
|
||||
LayeredTileSet::CellNeighbor bit = LayeredTileSet::CellNeighbor(j);
|
||||
if (tile_data->is_valid_terrain_peering_bit(bit)) {
|
||||
polygon = tile_set->get_terrain_peering_bit_polygon(tile_data->get_terrain_set(), bit);
|
||||
if (Geometry2D::is_segment_intersecting_polygon(mm->get_position() - position, drag_last_pos - position, polygon)) {
|
||||
if (Geometry::is_segment_intersecting_polygon(mm->get_position() - position, drag_last_pos - position, polygon)) {
|
||||
tile_data->set_terrain_peering_bit(bit, terrain);
|
||||
}
|
||||
}
|
||||
@ -2220,14 +2220,14 @@ void TileDataTerrainsEditor::forward_painting_atlas_gui_input(LayeredTileAtlasVi
|
||||
dummy_object->set("terrain", -1);
|
||||
|
||||
Vector<Vector2> polygon = tile_set->get_terrain_polygon(terrain_set);
|
||||
if (Geometry2D::is_point_in_polygon(mb->get_position() - position, polygon)) {
|
||||
if (Geometry::is_point_in_polygon(mb->get_position() - position, polygon)) {
|
||||
dummy_object->set("terrain", tile_data->get_terrain());
|
||||
}
|
||||
for (int i = 0; i < LayeredTileSet::CELL_NEIGHBOR_MAX; i++) {
|
||||
LayeredTileSet::CellNeighbor bit = LayeredTileSet::CellNeighbor(i);
|
||||
if (tile_set->is_valid_terrain_peering_bit(terrain_set, bit)) {
|
||||
polygon = tile_set->get_terrain_peering_bit_polygon(terrain_set, bit);
|
||||
if (Geometry2D::is_point_in_polygon(mb->get_position() - position, polygon)) {
|
||||
if (Geometry::is_point_in_polygon(mb->get_position() - position, polygon)) {
|
||||
dummy_object->set("terrain", tile_data->get_terrain_peering_bit(bit));
|
||||
}
|
||||
}
|
||||
@ -2333,14 +2333,14 @@ void TileDataTerrainsEditor::forward_painting_atlas_gui_input(LayeredTileAtlasVi
|
||||
Vector2i position = texture_region.get_center() + tile_data->get_texture_origin();
|
||||
|
||||
Vector<Vector2> polygon = tile_set->get_terrain_polygon(terrain_set);
|
||||
if (Geometry2D::is_point_in_polygon(mb->get_position() - position, polygon)) {
|
||||
if (Geometry::is_point_in_polygon(mb->get_position() - position, polygon)) {
|
||||
tile_data->set_terrain(terrain);
|
||||
}
|
||||
for (int i = 0; i < LayeredTileSet::CELL_NEIGHBOR_MAX; i++) {
|
||||
LayeredTileSet::CellNeighbor bit = LayeredTileSet::CellNeighbor(i);
|
||||
if (tile_set->is_valid_terrain_peering_bit(terrain_set, bit)) {
|
||||
polygon = tile_set->get_terrain_peering_bit_polygon(terrain_set, bit);
|
||||
if (Geometry2D::is_point_in_polygon(mb->get_position() - position, polygon)) {
|
||||
if (Geometry::is_point_in_polygon(mb->get_position() - position, polygon)) {
|
||||
tile_data->set_terrain_peering_bit(bit, terrain);
|
||||
}
|
||||
}
|
||||
@ -2483,7 +2483,7 @@ void TileDataTerrainsEditor::forward_painting_atlas_gui_input(LayeredTileAtlasVi
|
||||
for (int j = 0; j < polygon.size(); j++) {
|
||||
polygon.write[j] += position;
|
||||
}
|
||||
if (!Geometry2D::intersect_polygons(polygon, mouse_pos_rect_polygon).empty()) {
|
||||
if (!Geometry::intersect_polygons(polygon, mouse_pos_rect_polygon).empty()) {
|
||||
// Draw terrain.
|
||||
undo_redo->add_do_property(p_tile_set_atlas_source, vformat("%d:%d/%d/terrain", coords.x, coords.y, E.alternative_tile), terrain);
|
||||
undo_redo->add_undo_property(p_tile_set_atlas_source, vformat("%d:%d/%d/terrain", coords.x, coords.y, E.alternative_tile), tile_data->get_terrain());
|
||||
@ -2496,7 +2496,7 @@ void TileDataTerrainsEditor::forward_painting_atlas_gui_input(LayeredTileAtlasVi
|
||||
for (int j = 0; j < polygon.size(); j++) {
|
||||
polygon.write[j] += position;
|
||||
}
|
||||
if (!Geometry2D::intersect_polygons(polygon, mouse_pos_rect_polygon).empty()) {
|
||||
if (!Geometry::intersect_polygons(polygon, mouse_pos_rect_polygon).empty()) {
|
||||
// Draw bit.
|
||||
undo_redo->add_do_property(p_tile_set_atlas_source, vformat("%d:%d/%d/terrains_peering_bit/" + String(LayeredTileSet::CELL_NEIGHBOR_ENUM_TO_TEXT[i]), coords.x, coords.y, E.alternative_tile), terrain);
|
||||
undo_redo->add_undo_property(p_tile_set_atlas_source, vformat("%d:%d/%d/terrains_peering_bit/" + String(LayeredTileSet::CELL_NEIGHBOR_ENUM_TO_TEXT[i]), coords.x, coords.y, E.alternative_tile), tile_data->get_terrain_peering_bit(bit));
|
||||
@ -2580,7 +2580,7 @@ void TileDataTerrainsEditor::forward_painting_alternatives_gui_input(LayeredTile
|
||||
Vector2i position = texture_region.get_center() + tile_data->get_texture_origin();
|
||||
|
||||
Vector<Vector2> polygon = tile_set->get_terrain_polygon(tile_data->get_terrain_set());
|
||||
if (Geometry2D::is_segment_intersecting_polygon(mm->get_position() - position, drag_last_pos - position, polygon)) {
|
||||
if (Geometry::is_segment_intersecting_polygon(mm->get_position() - position, drag_last_pos - position, polygon)) {
|
||||
tile_data->set_terrain(terrain);
|
||||
}
|
||||
|
||||
@ -2588,7 +2588,7 @@ void TileDataTerrainsEditor::forward_painting_alternatives_gui_input(LayeredTile
|
||||
LayeredTileSet::CellNeighbor bit = LayeredTileSet::CellNeighbor(j);
|
||||
if (tile_data->is_valid_terrain_peering_bit(bit)) {
|
||||
polygon = tile_set->get_terrain_peering_bit_polygon(tile_data->get_terrain_set(), bit);
|
||||
if (Geometry2D::is_segment_intersecting_polygon(mm->get_position() - position, drag_last_pos - position, polygon)) {
|
||||
if (Geometry::is_segment_intersecting_polygon(mm->get_position() - position, drag_last_pos - position, polygon)) {
|
||||
tile_data->set_terrain_peering_bit(bit, terrain);
|
||||
}
|
||||
}
|
||||
@ -2618,7 +2618,7 @@ void TileDataTerrainsEditor::forward_painting_alternatives_gui_input(LayeredTile
|
||||
dummy_object->set("terrain", -1);
|
||||
|
||||
Vector<Vector2> polygon = tile_set->get_terrain_polygon(terrain_set);
|
||||
if (Geometry2D::is_point_in_polygon(mb->get_position() - position, polygon)) {
|
||||
if (Geometry::is_point_in_polygon(mb->get_position() - position, polygon)) {
|
||||
dummy_object->set("terrain", tile_data->get_terrain());
|
||||
}
|
||||
|
||||
@ -2626,7 +2626,7 @@ void TileDataTerrainsEditor::forward_painting_alternatives_gui_input(LayeredTile
|
||||
LayeredTileSet::CellNeighbor bit = LayeredTileSet::CellNeighbor(i);
|
||||
if (tile_set->is_valid_terrain_peering_bit(terrain_set, bit)) {
|
||||
polygon = tile_set->get_terrain_peering_bit_polygon(terrain_set, bit);
|
||||
if (Geometry2D::is_point_in_polygon(mb->get_position() - position, polygon)) {
|
||||
if (Geometry::is_point_in_polygon(mb->get_position() - position, polygon)) {
|
||||
dummy_object->set("terrain", tile_data->get_terrain_peering_bit(bit));
|
||||
}
|
||||
}
|
||||
@ -2706,14 +2706,14 @@ void TileDataTerrainsEditor::forward_painting_alternatives_gui_input(LayeredTile
|
||||
Vector2i position = texture_region.get_center() + tile_data->get_texture_origin();
|
||||
|
||||
Vector<Vector2> polygon = tile_set->get_terrain_polygon(terrain_set);
|
||||
if (Geometry2D::is_point_in_polygon(mb->get_position() - position, polygon)) {
|
||||
if (Geometry::is_point_in_polygon(mb->get_position() - position, polygon)) {
|
||||
tile_data->set_terrain(terrain);
|
||||
}
|
||||
for (int i = 0; i < LayeredTileSet::CELL_NEIGHBOR_MAX; i++) {
|
||||
LayeredTileSet::CellNeighbor bit = LayeredTileSet::CellNeighbor(i);
|
||||
if (tile_set->is_valid_terrain_peering_bit(terrain_set, bit)) {
|
||||
polygon = tile_set->get_terrain_peering_bit_polygon(terrain_set, bit);
|
||||
if (Geometry2D::is_point_in_polygon(mb->get_position() - position, polygon)) {
|
||||
if (Geometry::is_point_in_polygon(mb->get_position() - position, polygon)) {
|
||||
tile_data->set_terrain_peering_bit(bit, terrain);
|
||||
}
|
||||
}
|
||||
@ -2831,11 +2831,11 @@ TileDataTerrainsEditor::~TileDataTerrainsEditor() {
|
||||
|
||||
Variant TileDataNavigationEditor::_get_painted_value() {
|
||||
Ref<NavigationPolygon> nav_polygon;
|
||||
nav_polygon.instantiate();
|
||||
nav_polygon.instance();
|
||||
|
||||
if (polygon_editor->get_polygon_count() > 0) {
|
||||
Ref<NavigationMeshSourceGeometryData2D> source_geometry_data;
|
||||
source_geometry_data.instantiate();
|
||||
source_geometry_data.instance();
|
||||
for (int i = 0; i < polygon_editor->get_polygon_count(); i++) {
|
||||
Vector<Vector2> polygon = polygon_editor->get_polygon(i);
|
||||
nav_polygon->add_outline(polygon);
|
||||
|
@ -498,7 +498,7 @@ void LayeredTileMapLayerEditorTilesPlugin::_scenes_list_lmb_empty_clicked(const
|
||||
scene_tiles_list->deselect_all();
|
||||
tile_set_selection.clear();
|
||||
tile_map_selection.clear();
|
||||
selection_pattern.instantiate();
|
||||
selection_pattern.instance();
|
||||
_update_selection_pattern_from_tileset_tiles_selection();
|
||||
}
|
||||
|
||||
@ -548,7 +548,7 @@ bool LayeredTileMapLayerEditorTilesPlugin::forward_canvas_gui_input(const Ref<In
|
||||
if (ED_IS_SHORTCUT("tiles_editor/cut", p_event) || ED_IS_SHORTCUT("tiles_editor/copy", p_event)) {
|
||||
// Fill in the clipboard.
|
||||
if (!tile_map_selection.empty()) {
|
||||
tile_map_clipboard.instantiate();
|
||||
tile_map_clipboard.instance();
|
||||
PoolVector2iArray coords_array;
|
||||
for (const Vector2i &E : tile_map_selection) {
|
||||
coords_array.push_back(E);
|
||||
@ -1081,7 +1081,7 @@ HashMap<Vector2i, LayeredTileMapCell> LayeredTileMapLayerEditorTilesPlugin::_dra
|
||||
|
||||
// Get or create the pattern.
|
||||
Ref<LayeredTileMapPattern> erase_pattern;
|
||||
erase_pattern.instantiate();
|
||||
erase_pattern.instance();
|
||||
erase_pattern->set_cell(Vector2i(0, 0), LayeredTileSet::INVALID_SOURCE, LayeredTileSetSource::INVALID_ATLAS_COORDS, LayeredTileSetSource::INVALID_TILE_ALTERNATIVE);
|
||||
Ref<LayeredTileMapPattern> pattern = p_erase ? erase_pattern : selection_pattern;
|
||||
|
||||
@ -1134,7 +1134,7 @@ HashMap<Vector2i, LayeredTileMapCell> LayeredTileMapLayerEditorTilesPlugin::_dra
|
||||
|
||||
// Get or create the pattern.
|
||||
Ref<LayeredTileMapPattern> erase_pattern;
|
||||
erase_pattern.instantiate();
|
||||
erase_pattern.instance();
|
||||
erase_pattern->set_cell(Vector2i(0, 0), LayeredTileSet::INVALID_SOURCE, LayeredTileSetSource::INVALID_ATLAS_COORDS, LayeredTileSetSource::INVALID_TILE_ALTERNATIVE);
|
||||
Ref<LayeredTileMapPattern> pattern = p_erase ? erase_pattern : selection_pattern;
|
||||
|
||||
@ -1191,7 +1191,7 @@ HashMap<Vector2i, LayeredTileMapCell> LayeredTileMapLayerEditorTilesPlugin::_dra
|
||||
|
||||
// Get or create the pattern.
|
||||
Ref<LayeredTileMapPattern> erase_pattern;
|
||||
erase_pattern.instantiate();
|
||||
erase_pattern.instance();
|
||||
erase_pattern->set_cell(Vector2i(0, 0), LayeredTileSet::INVALID_SOURCE, LayeredTileSetSource::INVALID_ATLAS_COORDS, LayeredTileSetSource::INVALID_TILE_ALTERNATIVE);
|
||||
Ref<LayeredTileMapPattern> pattern = p_erase ? erase_pattern : selection_pattern;
|
||||
|
||||
@ -1508,7 +1508,7 @@ void LayeredTileMapLayerEditorTilesPlugin::_apply_transform(int p_type) {
|
||||
}
|
||||
|
||||
Ref<LayeredTileMapPattern> transformed_pattern;
|
||||
transformed_pattern.instantiate();
|
||||
transformed_pattern.instance();
|
||||
bool keep_shape = selection_pattern->get_size() == Vector2i(1, 1);
|
||||
|
||||
Vector2i size = selection_pattern->get_size();
|
||||
@ -1599,7 +1599,7 @@ void LayeredTileMapLayerEditorTilesPlugin::_update_fix_selected_and_hovered() {
|
||||
tile_set_selection.clear();
|
||||
patterns_item_list->deselect_all();
|
||||
tile_map_selection.clear();
|
||||
selection_pattern.instantiate();
|
||||
selection_pattern.instance();
|
||||
return;
|
||||
}
|
||||
Ref<LayeredTileSet> tile_set = edited_layer->get_effective_tile_set();
|
||||
@ -1610,7 +1610,7 @@ void LayeredTileMapLayerEditorTilesPlugin::_update_fix_selected_and_hovered() {
|
||||
tile_set_selection.clear();
|
||||
patterns_item_list->deselect_all();
|
||||
tile_map_selection.clear();
|
||||
selection_pattern.instantiate();
|
||||
selection_pattern.instance();
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1622,7 +1622,7 @@ void LayeredTileMapLayerEditorTilesPlugin::_update_fix_selected_and_hovered() {
|
||||
tile_set_selection.clear();
|
||||
patterns_item_list->deselect_all();
|
||||
tile_map_selection.clear();
|
||||
selection_pattern.instantiate();
|
||||
selection_pattern.instance();
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1694,7 +1694,7 @@ void LayeredTileMapLayerEditorTilesPlugin::_update_selection_pattern_from_tilema
|
||||
return;
|
||||
}
|
||||
|
||||
selection_pattern.instantiate();
|
||||
selection_pattern.instance();
|
||||
|
||||
PoolVector2iArray coords_array;
|
||||
for (const Vector2i &E : tile_map_selection) {
|
||||
@ -1719,7 +1719,7 @@ void LayeredTileMapLayerEditorTilesPlugin::_update_selection_pattern_from_tilese
|
||||
tile_map_selection.clear();
|
||||
|
||||
// Clear the selected pattern.
|
||||
selection_pattern.instantiate();
|
||||
selection_pattern.instance();
|
||||
|
||||
// Group per source.
|
||||
HashMap<int, List<const LayeredTileMapCell *>> per_source;
|
||||
@ -1793,7 +1793,7 @@ void LayeredTileMapLayerEditorTilesPlugin::_update_selection_pattern_from_tilese
|
||||
tile_map_selection.clear();
|
||||
|
||||
// Clear the selected pattern.
|
||||
selection_pattern.instantiate();
|
||||
selection_pattern.instance();
|
||||
|
||||
if (patterns_item_list->get_selected_items().size() >= 1) {
|
||||
selection_pattern = patterns_item_list->get_item_metadata(patterns_item_list->get_selected_items()[0]);
|
||||
@ -2172,7 +2172,7 @@ void LayeredTileMapLayerEditorTilesPlugin::edit(ObjectID p_tile_map_layer_id) {
|
||||
tile_set_selection.clear();
|
||||
patterns_item_list->deselect_all();
|
||||
tile_map_selection.clear();
|
||||
selection_pattern.instantiate();
|
||||
selection_pattern.instance();
|
||||
}
|
||||
|
||||
edited_tile_map_layer_id = p_tile_map_layer_id;
|
||||
@ -2191,15 +2191,15 @@ LayeredTileMapLayerEditorTilesPlugin::LayeredTileMapLayerEditorTilesPlugin() {
|
||||
ED_SHORTCUT("tiles_editor/delete", TTR("Delete"), Key::KEY_DELETE);
|
||||
|
||||
// --- Initialize references ---
|
||||
tile_map_clipboard.instantiate();
|
||||
selection_pattern.instantiate();
|
||||
tile_map_clipboard.instance();
|
||||
selection_pattern.instance();
|
||||
|
||||
// --- Toolbar ---
|
||||
toolbar = memnew(HBoxContainer);
|
||||
|
||||
HBoxContainer *tilemap_tiles_tools_buttons = memnew(HBoxContainer);
|
||||
|
||||
tool_buttons_group.instantiate();
|
||||
tool_buttons_group.instance();
|
||||
|
||||
select_tool_button = memnew(Button);
|
||||
select_tool_button->set_theme_type_variation("FlatButton");
|
||||
@ -3543,7 +3543,7 @@ LayeredTileMapLayerEditorTerrainsPlugin::LayeredTileMapLayerEditorTerrainsPlugin
|
||||
|
||||
HBoxContainer *tilemap_tiles_tools_buttons = memnew(HBoxContainer);
|
||||
|
||||
tool_buttons_group.instantiate();
|
||||
tool_buttons_group.instance();
|
||||
|
||||
paint_tool_button = memnew(Button);
|
||||
paint_tool_button->set_theme_type_variation("FlatButton");
|
||||
@ -3739,7 +3739,7 @@ Vector<Vector2i> LayeredTileMapLayerEditor::get_line(const LayeredTileMapLayer *
|
||||
ERR_FAIL_COND_V(tile_set.is_null(), Vector<Vector2i>());
|
||||
|
||||
if (tile_set->get_tile_shape() == LayeredTileSet::TILE_SHAPE_SQUARE) {
|
||||
return Geometry2D::bresenham_line(p_from_cell, p_to_cell);
|
||||
return Geometry::bresenham_line(p_from_cell, p_to_cell);
|
||||
} else {
|
||||
// Adapt the bresenham line algorithm to half-offset shapes.
|
||||
// See this blog post: http://zvold.blogspot.com/2010/01/bresenhams-line-drawing-algorithm-on_26.html
|
||||
|
@ -275,7 +275,7 @@ bool LayeredTileSetAtlasSourceEditor::LayeredAtlasTileProxyObject::_set(const St
|
||||
property_list_changed_notify();
|
||||
emit_signal(SNAME("changed"), "animation_separation");
|
||||
return true;
|
||||
} else if (components.size() == 2 && components[0].begins_with("animation_frame_") && components[0].trim_prefix("animation_frame_").is_valid_int()) {
|
||||
} else if (components.size() == 2 && components[0].begins_with("animation_frame_") && components[0].trim_prefix("animation_frame_").is_valid_integer()) {
|
||||
for (TileSelection tile : tiles) {
|
||||
int frame = components[0].trim_prefix("animation_frame_").to_int();
|
||||
if (frame < 0 || frame >= tile_set_atlas_source->get_tile_animation_frames_count(tile.tile)) {
|
||||
@ -367,7 +367,7 @@ bool LayeredTileSetAtlasSourceEditor::LayeredAtlasTileProxyObject::_get(const St
|
||||
} else if (p_name == "animation_frames_count") {
|
||||
r_ret = tile_set_atlas_source->get_tile_animation_frames_count(coords);
|
||||
return true;
|
||||
} else if (components.size() == 2 && components[0].begins_with("animation_frame_") && components[0].trim_prefix("animation_frame_").is_valid_int()) {
|
||||
} else if (components.size() == 2 && components[0].begins_with("animation_frame_") && components[0].trim_prefix("animation_frame_").is_valid_integer()) {
|
||||
int frame = components[0].trim_prefix("animation_frame_").to_int();
|
||||
if (components[1] == "duration") {
|
||||
if (frame < 0 || frame >= tile_set_atlas_source->get_tile_animation_frames_count(coords)) {
|
||||
@ -431,15 +431,15 @@ void LayeredTileSetAtlasSourceEditor::LayeredAtlasTileProxyObject::_get_property
|
||||
p_list->push_back(PropertyInfo(Variant::NIL, GNAME("Animation", "animation_"), PROPERTY_HINT_NONE, "animation_", PROPERTY_USAGE_GROUP));
|
||||
p_list->push_back(PropertyInfo(Variant::INT, PNAME("animation_columns")));
|
||||
p_list->push_back(PropertyInfo(Variant::VECTOR2I, PNAME("animation_separation")));
|
||||
p_list->push_back(PropertyInfo(Variant::FLOAT, PNAME("animation_speed")));
|
||||
p_list->push_back(PropertyInfo(Variant::REAL, PNAME("animation_speed")));
|
||||
p_list->push_back(PropertyInfo(Variant::INT, PNAME("animation_mode"), PROPERTY_HINT_ENUM, "Default,Random Start Times"));
|
||||
p_list->push_back(PropertyInfo(Variant::INT, PNAME("animation_frames_count"), PROPERTY_HINT_NONE, "", PROPERTY_USAGE_EDITOR | PROPERTY_USAGE_ARRAY, "Frames,animation_frame_"));
|
||||
// Not optimal, but returns value for the first tile. This is similar to what MultiNodeEdit does.
|
||||
if (tile_set_atlas_source->get_tile_animation_frames_count(tiles.front()->get().tile) == 1) {
|
||||
p_list->push_back(PropertyInfo(Variant::FLOAT, "animation_frame_0/duration", PROPERTY_HINT_NONE, "suffix:s", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_READ_ONLY));
|
||||
p_list->push_back(PropertyInfo(Variant::REAL, "animation_frame_0/duration", PROPERTY_HINT_NONE, "suffix:s", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_READ_ONLY));
|
||||
} else {
|
||||
for (int i = 0; i < tile_set_atlas_source->get_tile_animation_frames_count(tiles.front()->get().tile); i++) {
|
||||
p_list->push_back(PropertyInfo(Variant::FLOAT, vformat("animation_frame_%d/%s", i, PNAME("duration")), PROPERTY_HINT_NONE, "suffix:s"));
|
||||
p_list->push_back(PropertyInfo(Variant::REAL, vformat("animation_frame_%d/%s", i, PNAME("duration")), PROPERTY_HINT_NONE, "suffix:s"));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -730,7 +730,7 @@ void LayeredTileSetAtlasSourceEditor::_update_tile_data_editors() {
|
||||
if (!tile_data_editors.has("probability")) {
|
||||
TileDataDefaultEditor *tile_data_probability_editor = memnew(TileDataDefaultEditor());
|
||||
tile_data_probability_editor->hide();
|
||||
tile_data_probability_editor->setup_property_editor(Variant::FLOAT, "probability", "", 1.0);
|
||||
tile_data_probability_editor->setup_property_editor(Variant::REAL, "probability", "", 1.0);
|
||||
tile_data_probability_editor->connect("needs_redraw", callable_mp((CanvasItem *)tile_atlas_control_unscaled, &Control::queue_redraw));
|
||||
tile_data_probability_editor->connect("needs_redraw", callable_mp((CanvasItem *)alternative_tiles_control_unscaled, &Control::queue_redraw));
|
||||
tile_data_editors["probability"] = tile_data_probability_editor;
|
||||
@ -1104,7 +1104,7 @@ void LayeredTileSetAtlasSourceEditor::_tile_atlas_control_gui_input(const Ref<In
|
||||
last_base_tiles_coords = last_base_tiles_coords.max(Vector2i(0, 0)).min(grid_size - Vector2i(1, 1));
|
||||
new_base_tiles_coords = new_base_tiles_coords.max(Vector2i(0, 0)).min(grid_size - Vector2i(1, 1));
|
||||
|
||||
Vector<Point2i> line = Geometry2D::bresenham_line(last_base_tiles_coords, new_base_tiles_coords);
|
||||
Vector<Point2i> line = Geometry::bresenham_line(last_base_tiles_coords, new_base_tiles_coords);
|
||||
for (int i = 0; i < line.size(); i++) {
|
||||
if (tile_set_atlas_source->get_tile_at_coords(line[i]) == LayeredTileSetSource::INVALID_ATLAS_COORDS) {
|
||||
tile_set_atlas_source->create_tile(line[i]);
|
||||
@ -1119,7 +1119,7 @@ void LayeredTileSetAtlasSourceEditor::_tile_atlas_control_gui_input(const Ref<In
|
||||
last_base_tiles_coords = last_base_tiles_coords.max(Vector2i(0, 0)).min(grid_size - Vector2i(1, 1));
|
||||
new_base_tiles_coords = new_base_tiles_coords.max(Vector2i(0, 0)).min(grid_size - Vector2i(1, 1));
|
||||
|
||||
Vector<Point2i> line = Geometry2D::bresenham_line(last_base_tiles_coords, new_base_tiles_coords);
|
||||
Vector<Point2i> line = Geometry::bresenham_line(last_base_tiles_coords, new_base_tiles_coords);
|
||||
for (int i = 0; i < line.size(); i++) {
|
||||
Vector2i base_tile_coords = tile_set_atlas_source->get_tile_at_coords(line[i]);
|
||||
if (base_tile_coords != LayeredTileSetSource::INVALID_ATLAS_COORDS) {
|
||||
@ -1584,7 +1584,7 @@ HashMap<Vector2i, List<const PropertyInfo *>> LayeredTileSetAtlasSourceEditor::_
|
||||
Vector<String> components = String(E_property->get().name).split("/", true, 1);
|
||||
if (components.size() >= 1) {
|
||||
Vector<String> coord_arr = components[0].split(":");
|
||||
if (coord_arr.size() == 2 && coord_arr[0].is_valid_int() && coord_arr[1].is_valid_int()) {
|
||||
if (coord_arr.size() == 2 && coord_arr[0].is_valid_integer() && coord_arr[1].is_valid_integer()) {
|
||||
Vector2i coords = Vector2i(coord_arr[0].to_int(), coord_arr[1].to_int());
|
||||
per_tile[coords].push_back(&(E_property->get()));
|
||||
}
|
||||
@ -1634,7 +1634,7 @@ void LayeredTileSetAtlasSourceEditor::_menu_option(int p_option) {
|
||||
if (per_tile.has(selected.tile)) {
|
||||
for (List<const PropertyInfo *>::Element *E_property = per_tile[selected.tile].front(); E_property; E_property = E_property->next()) {
|
||||
Vector<String> components = E_property->get()->name.split("/", true, 2);
|
||||
if (components.size() >= 2 && components[1].is_valid_int() && components[1].to_int() == selected.alternative) {
|
||||
if (components.size() >= 2 && components[1].is_valid_integer() && components[1].to_int() == selected.alternative) {
|
||||
String property = E_property->get()->name;
|
||||
Variant value = tile_set_atlas_source->get(property);
|
||||
if (value.get_type() != Variant::NIL) {
|
||||
@ -2093,7 +2093,7 @@ void LayeredTileSetAtlasSourceEditor::_tile_alternatives_control_unscaled_draw()
|
||||
void LayeredTileSetAtlasSourceEditor::_tile_set_changed() {
|
||||
if (tile_set->get_source_count() == 0) {
|
||||
// No sources, so nothing to do here anymore.
|
||||
tile_set->disconnect_changed(callable_mp(this, &LayeredTileSetAtlasSourceEditor::_tile_set_changed));
|
||||
tile_set->disconnect(CoreStringNames::get_singleton()->changed, callable_mp(this, &LayeredTileSetAtlasSourceEditor::_tile_set_changed));
|
||||
tile_set = Ref<LayeredTileSet>();
|
||||
return;
|
||||
}
|
||||
@ -2177,13 +2177,13 @@ void LayeredTileSetAtlasSourceEditor::edit(Ref<LayeredTileSet> p_tile_set, Layer
|
||||
|
||||
// Remove listener for old objects.
|
||||
if (tile_set.is_valid()) {
|
||||
tile_set->disconnect_changed(callable_mp(this, &LayeredTileSetAtlasSourceEditor::_tile_set_changed));
|
||||
tile_set->disconnect(CoreStringNames::get_singleton()->changed, callable_mp(this, &LayeredTileSetAtlasSourceEditor::_tile_set_changed));
|
||||
}
|
||||
|
||||
if (tile_set_atlas_source) {
|
||||
tile_set_atlas_source->disconnect_changed(callable_mp(this, &LayeredTileSetAtlasSourceEditor::_update_source_texture));
|
||||
tile_set_atlas_source->disconnect(CoreStringNames::get_singleton()->changed, callable_mp(this, &LayeredTileSetAtlasSourceEditor::_update_source_texture));
|
||||
if (atlas_source_texture.is_valid()) {
|
||||
atlas_source_texture->disconnect_changed(callable_mp(this, &LayeredTileSetAtlasSourceEditor::_check_outside_tiles));
|
||||
atlas_source_texture->disconnect(CoreStringNames::get_singleton()->changed, callable_mp(this, &LayeredTileSetAtlasSourceEditor::_check_outside_tiles));
|
||||
atlas_source_texture = Ref<Texture>();
|
||||
}
|
||||
}
|
||||
@ -2200,11 +2200,11 @@ void LayeredTileSetAtlasSourceEditor::edit(Ref<LayeredTileSet> p_tile_set, Layer
|
||||
read_only = new_read_only_state;
|
||||
|
||||
if (tile_set.is_valid()) {
|
||||
tile_set->connect_changed(callable_mp(this, &LayeredTileSetAtlasSourceEditor::_tile_set_changed));
|
||||
tile_set->connect(CoreStringNames::get_singleton()->changed, callable_mp(this, &LayeredTileSetAtlasSourceEditor::_tile_set_changed));
|
||||
}
|
||||
|
||||
if (tile_set_atlas_source) {
|
||||
tile_set_atlas_source->connect_changed(callable_mp(this, &LayeredTileSetAtlasSourceEditor::_update_source_texture));
|
||||
tile_set_atlas_source->connect(CoreStringNames::get_singleton()->changed, callable_mp(this, &LayeredTileSetAtlasSourceEditor::_update_source_texture));
|
||||
_update_source_texture();
|
||||
}
|
||||
|
||||
@ -2243,7 +2243,7 @@ void LayeredTileSetAtlasSourceEditor::_update_source_texture() {
|
||||
}
|
||||
|
||||
if (atlas_source_texture.is_valid()) {
|
||||
atlas_source_texture->disconnect_changed(callable_mp(this, &LayeredTileSetAtlasSourceEditor::_check_outside_tiles));
|
||||
atlas_source_texture->disconnect(CoreStringNames::get_singleton()->changed, callable_mp(this, &LayeredTileSetAtlasSourceEditor::_check_outside_tiles));
|
||||
atlas_source_texture = Ref<Texture>();
|
||||
}
|
||||
|
||||
@ -2251,7 +2251,7 @@ void LayeredTileSetAtlasSourceEditor::_update_source_texture() {
|
||||
return;
|
||||
}
|
||||
atlas_source_texture = tile_set_atlas_source->get_texture();
|
||||
atlas_source_texture->connect_changed(callable_mp(this, &LayeredTileSetAtlasSourceEditor::_check_outside_tiles), CONNECT_DEFERRED);
|
||||
atlas_source_texture->connect(CoreStringNames::get_singleton()->changed, callable_mp(this, &LayeredTileSetAtlasSourceEditor::_check_outside_tiles), CONNECT_DEFERRED);
|
||||
_check_outside_tiles();
|
||||
}
|
||||
|
||||
@ -2510,7 +2510,7 @@ LayeredTileSetAtlasSourceEditor::LayeredTileSetAtlasSourceEditor() {
|
||||
add_child(middle_vbox_container);
|
||||
|
||||
// -- Toolbox --
|
||||
tools_button_group.instantiate();
|
||||
tools_button_group.instance();
|
||||
tools_button_group->connect("pressed", callable_mp(this, &LayeredTileSetAtlasSourceEditor::_update_fix_selected_and_hovered_tiles).unbind(1));
|
||||
tools_button_group->connect("pressed", callable_mp(this, &LayeredTileSetAtlasSourceEditor::_update_tile_id_label).unbind(1));
|
||||
tools_button_group->connect("pressed", callable_mp(this, &LayeredTileSetAtlasSourceEditor::_update_atlas_source_inspector).unbind(1));
|
||||
@ -2741,7 +2741,7 @@ LayeredTileSetAtlasSourceEditor::LayeredTileSetAtlasSourceEditor() {
|
||||
|
||||
// Inspector plugin.
|
||||
Ref<EditorInspectorPluginTileData> tile_data_inspector_plugin;
|
||||
tile_data_inspector_plugin.instantiate();
|
||||
tile_data_inspector_plugin.instance();
|
||||
EditorInspector::add_inspector_plugin(tile_data_inspector_plugin);
|
||||
}
|
||||
|
||||
@ -2752,7 +2752,7 @@ LayeredTileSetAtlasSourceEditor::~LayeredTileSetAtlasSourceEditor() {
|
||||
// Remove listener for old objects, so the LayeredTileSet doesn't
|
||||
// try to call the destroyed LayeredTileSetAtlasSourceEditor.
|
||||
if (tile_set.is_valid()) {
|
||||
tile_set->disconnect_changed(callable_mp(this, &LayeredTileSetAtlasSourceEditor::_tile_set_changed));
|
||||
tile_set->disconnect(CoreStringNames::get_singleton()->changed, callable_mp(this, &LayeredTileSetAtlasSourceEditor::_tile_set_changed));
|
||||
}
|
||||
}
|
||||
|
||||
@ -2774,18 +2774,18 @@ void EditorPropertyTilePolygon::_polygons_changed() {
|
||||
// Single OccluderPolygon2D.
|
||||
Ref<OccluderPolygon2D> occluder;
|
||||
if (generic_tile_polygon_editor->get_polygon_count() >= 1) {
|
||||
occluder.instantiate();
|
||||
occluder.instance();
|
||||
occluder->set_polygon(generic_tile_polygon_editor->get_polygon(0));
|
||||
}
|
||||
emit_changed(get_edited_property(), occluder);
|
||||
} else if (base_type == "NavigationPolygon") {
|
||||
Ref<NavigationPolygon> navigation_polygon;
|
||||
if (generic_tile_polygon_editor->get_polygon_count() >= 1) {
|
||||
navigation_polygon.instantiate();
|
||||
navigation_polygon.instance();
|
||||
|
||||
if (generic_tile_polygon_editor->get_polygon_count() > 0) {
|
||||
Ref<NavigationMeshSourceGeometryData2D> source_geometry_data;
|
||||
source_geometry_data.instantiate();
|
||||
source_geometry_data.instance();
|
||||
for (int i = 0; i < generic_tile_polygon_editor->get_polygon_count(); i++) {
|
||||
Vector<Vector2> polygon = generic_tile_polygon_editor->get_polygon(i);
|
||||
navigation_polygon->add_outline(polygon);
|
||||
@ -2899,7 +2899,7 @@ bool EditorInspectorPluginTileData::can_handle(Object *p_object) {
|
||||
|
||||
bool EditorInspectorPluginTileData::parse_property(Object *p_object, const Variant::Type p_type, const String &p_path, const PropertyHint p_hint, const String &p_hint_text, const BitField<PropertyUsageFlags> p_usage, const bool p_wide) {
|
||||
Vector<String> components = String(p_path).split("/", true, 2);
|
||||
if (components.size() == 2 && components[0].begins_with("occlusion_layer_") && components[0].trim_prefix("occlusion_layer_").is_valid_int()) {
|
||||
if (components.size() == 2 && components[0].begins_with("occlusion_layer_") && components[0].trim_prefix("occlusion_layer_").is_valid_integer()) {
|
||||
// Occlusion layers.
|
||||
int layer_index = components[0].trim_prefix("occlusion_layer_").to_int();
|
||||
ERR_FAIL_COND_V(layer_index < 0, false);
|
||||
@ -2909,7 +2909,7 @@ bool EditorInspectorPluginTileData::parse_property(Object *p_object, const Varia
|
||||
add_property_editor(p_path, ep);
|
||||
return true;
|
||||
}
|
||||
} else if (components.size() >= 2 && components[0].begins_with("physics_layer_") && components[0].trim_prefix("physics_layer_").is_valid_int()) {
|
||||
} else if (components.size() >= 2 && components[0].begins_with("physics_layer_") && components[0].trim_prefix("physics_layer_").is_valid_integer()) {
|
||||
// Physics layers.
|
||||
int layer_index = components[0].trim_prefix("physics_layer_").to_int();
|
||||
ERR_FAIL_COND_V(layer_index < 0, false);
|
||||
@ -2924,14 +2924,14 @@ bool EditorInspectorPluginTileData::parse_property(Object *p_object, const Varia
|
||||
}
|
||||
add_property_editor_for_multiple_properties("Polygons", properties, ep);
|
||||
return true;
|
||||
} else if (components.size() == 3 && components[1].begins_with("polygon_") && components[1].trim_prefix("polygon_").is_valid_int()) {
|
||||
} else if (components.size() == 3 && components[1].begins_with("polygon_") && components[1].trim_prefix("polygon_").is_valid_integer()) {
|
||||
int polygon_index = components[1].trim_prefix("polygon_").to_int();
|
||||
ERR_FAIL_COND_V(polygon_index < 0, false);
|
||||
if (components[2] == "points") {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
} else if (components.size() == 2 && components[0].begins_with("navigation_layer_") && components[0].trim_prefix("navigation_layer_").is_valid_int()) {
|
||||
} else if (components.size() == 2 && components[0].begins_with("navigation_layer_") && components[0].trim_prefix("navigation_layer_").is_valid_integer()) {
|
||||
// Navigation layers.
|
||||
int layer_index = components[0].trim_prefix("navigation_layer_").to_int();
|
||||
ERR_FAIL_COND_V(layer_index < 0, false);
|
||||
|
@ -479,7 +479,7 @@ void LayeredTileSetEditor::_move_tile_set_array_element(Object *p_undo_redo, Obj
|
||||
end = ed_tile_set->get_physics_layers_count();
|
||||
} else if (p_array_prefix == "terrain_set_") {
|
||||
end = ed_tile_set->get_terrain_sets_count();
|
||||
} else if (components.size() >= 2 && components[0].begins_with("terrain_set_") && components[0].trim_prefix("terrain_set_").is_valid_int() && components[1] == "terrain_") {
|
||||
} else if (components.size() >= 2 && components[0].begins_with("terrain_set_") && components[0].trim_prefix("terrain_set_").is_valid_integer() && components[1] == "terrain_") {
|
||||
int terrain_set = components[0].trim_prefix("terrain_set_").to_int();
|
||||
end = ed_tile_set->get_terrains_count(terrain_set);
|
||||
} else if (p_array_prefix == "navigation_layer_") {
|
||||
@ -520,7 +520,7 @@ void LayeredTileSetEditor::_move_tile_set_array_element(Object *p_undo_redo, Obj
|
||||
if (p_from_index < 0) {
|
||||
undo_redo_man->add_undo_method(ed_tile_set, "remove_terrain_set", p_to_pos < 0 ? ed_tile_set->get_terrain_sets_count() : p_to_pos);
|
||||
}
|
||||
} else if (components.size() >= 2 && components[0].begins_with("terrain_set_") && components[0].trim_prefix("terrain_set_").is_valid_int() && components[1] == "terrain_") {
|
||||
} else if (components.size() >= 2 && components[0].begins_with("terrain_set_") && components[0].trim_prefix("terrain_set_").is_valid_integer() && components[1] == "terrain_") {
|
||||
int terrain_set = components[0].trim_prefix("terrain_set_").to_int();
|
||||
if (p_from_index < 0) {
|
||||
undo_redo_man->add_undo_method(ed_tile_set, "remove_terrain", terrain_set, p_to_pos < 0 ? ed_tile_set->get_terrains_count(terrain_set) : p_to_pos);
|
||||
@ -594,7 +594,7 @@ void LayeredTileSetEditor::_move_tile_set_array_element(Object *p_undo_redo, Obj
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (components.size() >= 2 && components[0].begins_with("terrain_set_") && components[0].trim_prefix("terrain_set_").is_valid_int() && components[1] == "terrain_") {
|
||||
} else if (components.size() >= 2 && components[0].begins_with("terrain_set_") && components[0].trim_prefix("terrain_set_").is_valid_integer() && components[1] == "terrain_") {
|
||||
for (int terrain_index = 0; terrain_index < LayeredTileSet::CELL_NEIGHBOR_MAX; terrain_index++) {
|
||||
LayeredTileSet::CellNeighbor bit = LayeredTileSet::CellNeighbor(terrain_index);
|
||||
if (tile_data->is_valid_terrain_peering_bit(bit)) {
|
||||
@ -641,7 +641,7 @@ void LayeredTileSetEditor::_move_tile_set_array_element(Object *p_undo_redo, Obj
|
||||
} else {
|
||||
undo_redo_man->add_do_method(ed_tile_set, "move_terrain_set", p_from_index, p_to_pos);
|
||||
}
|
||||
} else if (components.size() >= 2 && components[0].begins_with("terrain_set_") && components[0].trim_prefix("terrain_set_").is_valid_int() && components[1] == "terrain_") {
|
||||
} else if (components.size() >= 2 && components[0].begins_with("terrain_set_") && components[0].trim_prefix("terrain_set_").is_valid_integer() && components[1] == "terrain_") {
|
||||
int terrain_set = components[0].trim_prefix("terrain_set_").to_int();
|
||||
if (p_from_index < 0) {
|
||||
undo_redo_man->add_do_method(ed_tile_set, "add_terrain", terrain_set, p_to_pos);
|
||||
@ -689,7 +689,7 @@ void LayeredTileSetEditor::_undo_redo_inspector_callback(Object *p_undo_redo, Ob
|
||||
TileData *tile_data = tas->get_tile_data(tile_id, alternative_id);
|
||||
ERR_FAIL_NULL(tile_data);
|
||||
|
||||
if (components.size() == 2 && components[0].begins_with("terrain_set_") && components[0].trim_prefix("terrain_set_").is_valid_int() && components[1] == "mode") {
|
||||
if (components.size() == 2 && components[0].begins_with("terrain_set_") && components[0].trim_prefix("terrain_set_").is_valid_integer() && components[1] == "mode") {
|
||||
ADD_UNDO(tile_data, "terrain_set");
|
||||
ADD_UNDO(tile_data, "terrain");
|
||||
for (int l = 0; l < LayeredTileSet::CELL_NEIGHBOR_MAX; l++) {
|
||||
@ -698,8 +698,8 @@ void LayeredTileSetEditor::_undo_redo_inspector_callback(Object *p_undo_redo, Ob
|
||||
ADD_UNDO(tile_data, "terrains_peering_bit/" + String(LayeredTileSet::CELL_NEIGHBOR_ENUM_TO_TEXT[l]));
|
||||
}
|
||||
}
|
||||
} else if (components.size() == 2 && components[0].begins_with("custom_data_layer_") && components[0].trim_prefix("custom_data_layer_").is_valid_int() && components[1] == "type") {
|
||||
int custom_data_layer = components[0].trim_prefix("custom_data_layer_").is_valid_int();
|
||||
} else if (components.size() == 2 && components[0].begins_with("custom_data_layer_") && components[0].trim_prefix("custom_data_layer_").is_valid_integer() && components[1] == "type") {
|
||||
int custom_data_layer = components[0].trim_prefix("custom_data_layer_").is_valid_integer();
|
||||
ADD_UNDO(tile_data, vformat("custom_data_%d", custom_data_layer));
|
||||
}
|
||||
}
|
||||
@ -722,7 +722,7 @@ void LayeredTileSetEditor::edit(Ref<LayeredTileSet> p_tile_set) {
|
||||
|
||||
// Remove listener.
|
||||
if (tile_set.is_valid()) {
|
||||
tile_set->disconnect_changed(callable_mp(this, &LayeredTileSetEditor::_tile_set_changed));
|
||||
tile_set->disconnect(CoreStringNames::get_singleton()->changed, callable_mp(this, &LayeredTileSetEditor::_tile_set_changed));
|
||||
}
|
||||
|
||||
// Change the edited object.
|
||||
@ -737,7 +737,7 @@ void LayeredTileSetEditor::edit(Ref<LayeredTileSet> p_tile_set) {
|
||||
sources_advanced_menu_button->set_disabled(read_only);
|
||||
source_sort_button->set_disabled(read_only);
|
||||
|
||||
tile_set->connect_changed(callable_mp(this, &LayeredTileSetEditor::_tile_set_changed));
|
||||
tile_set->connect(CoreStringNames::get_singleton()->changed, callable_mp(this, &LayeredTileSetEditor::_tile_set_changed));
|
||||
if (first_edit) {
|
||||
first_edit = false;
|
||||
_set_source_sort(EditorSettings::get_singleton()->get_project_metadata("editor_metadata", "tile_source_sort", 0));
|
||||
|
@ -417,7 +417,7 @@ void LayeredTileSetScenesCollectionSourceEditor::edit(Ref<LayeredTileSet> p_tile
|
||||
|
||||
// Remove listener for old objects.
|
||||
if (tile_set_scenes_collection_source) {
|
||||
tile_set_scenes_collection_source->disconnect_changed(callable_mp(this, &LayeredTileSetScenesCollectionSourceEditor::_tile_set_scenes_collection_source_changed));
|
||||
tile_set_scenes_collection_source->disconnect(CoreStringNames::get_singleton()->changed, callable_mp(this, &LayeredTileSetScenesCollectionSourceEditor::_tile_set_scenes_collection_source_changed));
|
||||
}
|
||||
|
||||
// Change the edited object.
|
||||
@ -437,7 +437,7 @@ void LayeredTileSetScenesCollectionSourceEditor::edit(Ref<LayeredTileSet> p_tile
|
||||
|
||||
// Add the listener again.
|
||||
if (tile_set_scenes_collection_source) {
|
||||
tile_set_scenes_collection_source->connect_changed(callable_mp(this, &LayeredTileSetScenesCollectionSourceEditor::_tile_set_scenes_collection_source_changed));
|
||||
tile_set_scenes_collection_source->connect(CoreStringNames::get_singleton()->changed, callable_mp(this, &LayeredTileSetScenesCollectionSourceEditor::_tile_set_scenes_collection_source_changed));
|
||||
}
|
||||
|
||||
// Update everything.
|
||||
|
@ -554,7 +554,7 @@ bool LayeredTileMap::_set(const StringName &p_name, const Variant &p_value) {
|
||||
return true;
|
||||
}
|
||||
#endif // DISABLE_DEPRECATED
|
||||
else if (components.size() == 2 && components[0].begins_with("layer_") && components[0].trim_prefix("layer_").is_valid_int()) {
|
||||
else if (components.size() == 2 && components[0].begins_with("layer_") && components[0].trim_prefix("layer_").is_valid_integer()) {
|
||||
int index = components[0].trim_prefix("layer_").to_int();
|
||||
if (index < 0) {
|
||||
return false;
|
||||
@ -619,7 +619,7 @@ bool LayeredTileMap::_get(const StringName &p_name, Variant &r_ret) const {
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
else if (components.size() == 2 && components[0].begins_with("layer_") && components[0].trim_prefix("layer_").is_valid_int()) {
|
||||
else if (components.size() == 2 && components[0].begins_with("layer_") && components[0].trim_prefix("layer_").is_valid_integer()) {
|
||||
int index = components[0].trim_prefix("layer_").to_int();
|
||||
if (index < 0 || index >= (int)layers.size()) {
|
||||
return false;
|
||||
|
@ -160,7 +160,7 @@ void LayeredTileMapLayer::_debug_quadrants_update_cell(CellData &r_cell_data, Se
|
||||
if (!debug_quadrant_map.has(quadrant_coords)) {
|
||||
// Create a new quadrant and add it to the quadrant map.
|
||||
Ref<DebugQuadrant> new_quadrant;
|
||||
new_quadrant.instantiate();
|
||||
new_quadrant.instance();
|
||||
new_quadrant->quadrant_coords = quadrant_coords;
|
||||
debug_quadrant_map[quadrant_coords] = new_quadrant;
|
||||
}
|
||||
@ -502,7 +502,7 @@ void LayeredTileMapLayer::_rendering_quadrants_update_cell(CellData &r_cell_data
|
||||
rendering_quadrant = rendering_quadrant_map[quadrant_coords];
|
||||
} else {
|
||||
// Create a new rendering quadrant.
|
||||
rendering_quadrant.instantiate();
|
||||
rendering_quadrant.instance();
|
||||
rendering_quadrant->quadrant_coords = quadrant_coords;
|
||||
rendering_quadrant->canvas_items_position = canvas_items_position;
|
||||
rendering_quadrant_map[quadrant_coords] = rendering_quadrant;
|
||||
@ -1271,7 +1271,7 @@ void LayeredTileMapLayer::_scenes_update_cell(CellData &r_cell_data) {
|
||||
if (scenes_collection_source) {
|
||||
Ref<PackedScene> packed_scene = scenes_collection_source->get_scene_tile_scene(c.alternative_tile);
|
||||
if (packed_scene.is_valid()) {
|
||||
Node *scene = packed_scene->instantiate();
|
||||
Node *scene = packed_scene->instance();
|
||||
Control *scene_as_control = Object::cast_to<Control>(scene);
|
||||
Node2D *scene_as_node2d = Object::cast_to<Node2D>(scene);
|
||||
if (scene_as_control) {
|
||||
@ -2346,7 +2346,7 @@ Ref<LayeredTileMapPattern> LayeredTileMapLayer::get_pattern(PoolVector2iArray p_
|
||||
ERR_FAIL_COND_V(!tile_set.is_valid(), nullptr);
|
||||
|
||||
Ref<LayeredTileMapPattern> output;
|
||||
output.instantiate();
|
||||
output.instance();
|
||||
if (p_coords_array.empty()) {
|
||||
return output;
|
||||
}
|
||||
|
@ -121,13 +121,13 @@ void LayeredTileMapLayerGroup::set_tileset(const Ref<LayeredTileSet> &p_tileset)
|
||||
|
||||
// Set the tileset, registering to its changes.
|
||||
if (tile_set.is_valid()) {
|
||||
tile_set->disconnect_changed(callable_mp(this, &LayeredTileMapLayerGroup::_tile_set_changed));
|
||||
tile_set->disconnect(CoreStringNames::get_singleton()->changed, callable_mp(this, &LayeredTileMapLayerGroup::_tile_set_changed));
|
||||
}
|
||||
|
||||
tile_set = p_tileset;
|
||||
|
||||
if (tile_set.is_valid()) {
|
||||
tile_set->connect_changed(callable_mp(this, &LayeredTileMapLayerGroup::_tile_set_changed));
|
||||
tile_set->connect(CoreStringNames::get_singleton()->changed, callable_mp(this, &LayeredTileMapLayerGroup::_tile_set_changed));
|
||||
}
|
||||
|
||||
for (int i = 0; i < get_child_count(); i++) {
|
||||
@ -144,6 +144,6 @@ Ref<LayeredTileSet> LayeredTileMapLayerGroup::get_tileset() const {
|
||||
|
||||
LayeredTileMapLayerGroup::~LayeredTileMapLayerGroup() {
|
||||
if (tile_set.is_valid()) {
|
||||
tile_set->disconnect_changed(callable_mp(this, &LayeredTileMapLayerGroup::_tile_set_changed));
|
||||
tile_set->disconnect(CoreStringNames::get_singleton()->changed, callable_mp(this, &LayeredTileMapLayerGroup::_tile_set_changed));
|
||||
}
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -530,7 +530,7 @@ public:
|
||||
|
||||
// Helpers
|
||||
Vector<Vector2> get_tile_shape_polygon() const;
|
||||
void draw_tile_shape(CanvasItem *p_canvas_item, Transform2D p_transform, Color p_color, bool p_filled = false, Ref<Texture> p_texture = Ref<Texture>()) const;
|
||||
void draw_tile_shape(CanvasItem *p_canvas_item, Transform2D p_transform, Color p_color, bool p_filled = false, Ref<Texture> p_texture = Ref<Texture>());
|
||||
|
||||
// Used by LayeredTileMap/LayeredTileMapLayer
|
||||
Vector2 map_to_local(const Vector2i &p_pos) const;
|
||||
@ -813,8 +813,8 @@ public:
|
||||
int get_next_scene_tile_id() const;
|
||||
};
|
||||
|
||||
class TileData : public Object {
|
||||
GDCLASS(TileData, Object);
|
||||
class LayeredTileData : public Object {
|
||||
GDCLASS(LayeredTileData, Object);
|
||||
|
||||
private:
|
||||
const LayeredTileSet *tile_set = nullptr;
|
||||
@ -909,7 +909,7 @@ public:
|
||||
bool is_allowing_transform() const;
|
||||
|
||||
// To duplicate a TileData object, needed for runtiume update.
|
||||
TileData *duplicate();
|
||||
LayeredTileData *duplicate();
|
||||
|
||||
// Rendering
|
||||
void set_flip_h(bool p_flip_h);
|
||||
|
Loading…
Reference in New Issue
Block a user