You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-06 12:20:30 +00:00
Style: Enforce braces around if blocks and loops
Using clang-tidy's `readability-braces-around-statements`. https://clang.llvm.org/extra/clang-tidy/checks/readability-braces-around-statements.html
This commit is contained in:
@@ -63,8 +63,9 @@ void TileSetEditor::_import_node(Node *p_node, Ref<TileSet> p_library) {
|
||||
Ref<Texture2D> normal_map = mi->get_normal_map();
|
||||
Ref<ShaderMaterial> material = mi->get_material();
|
||||
|
||||
if (texture.is_null())
|
||||
if (texture.is_null()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
int id = p_library->find_tile_by_name(mi->get_name());
|
||||
if (id < 0) {
|
||||
@@ -104,14 +105,17 @@ void TileSetEditor::_import_node(Node *p_node, Ref<TileSet> p_library) {
|
||||
for (int j = 0; j < mi->get_child_count(); j++) {
|
||||
Node *child2 = mi->get_child(j);
|
||||
|
||||
if (Object::cast_to<NavigationRegion2D>(child2))
|
||||
if (Object::cast_to<NavigationRegion2D>(child2)) {
|
||||
nav_poly = Object::cast_to<NavigationRegion2D>(child2)->get_navigation_polygon();
|
||||
}
|
||||
|
||||
if (Object::cast_to<LightOccluder2D>(child2))
|
||||
if (Object::cast_to<LightOccluder2D>(child2)) {
|
||||
occluder = Object::cast_to<LightOccluder2D>(child2)->get_occluder_polygon();
|
||||
}
|
||||
|
||||
if (!Object::cast_to<StaticBody2D>(child2))
|
||||
if (!Object::cast_to<StaticBody2D>(child2)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
found_collisions = true;
|
||||
|
||||
@@ -121,8 +125,9 @@ void TileSetEditor::_import_node(Node *p_node, Ref<TileSet> p_library) {
|
||||
sb->get_shape_owners(&shapes);
|
||||
|
||||
for (List<uint32_t>::Element *E = shapes.front(); E; E = E->next()) {
|
||||
if (sb->is_shape_owner_disabled(E->get()))
|
||||
if (sb->is_shape_owner_disabled(E->get())) {
|
||||
continue;
|
||||
}
|
||||
|
||||
Transform2D shape_transform = sb->get_transform() * sb->shape_owner_get_transform(E->get());
|
||||
bool one_way = sb->is_shape_owner_one_way_collision_enabled(E->get());
|
||||
@@ -154,8 +159,9 @@ void TileSetEditor::_import_node(Node *p_node, Ref<TileSet> p_library) {
|
||||
}
|
||||
|
||||
void TileSetEditor::_import_scene(Node *p_scene, Ref<TileSet> p_library, bool p_merge) {
|
||||
if (!p_merge)
|
||||
if (!p_merge) {
|
||||
p_library->clear();
|
||||
}
|
||||
|
||||
_import_node(p_scene, p_library);
|
||||
}
|
||||
@@ -176,11 +182,13 @@ Variant TileSetEditor::get_drag_data_fw(const Point2 &p_point, Control *p_from)
|
||||
bool TileSetEditor::can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) const {
|
||||
Dictionary d = p_data;
|
||||
|
||||
if (!d.has("type"))
|
||||
if (!d.has("type")) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (d.has("from") && (Object *)(d["from"]) == texture_list)
|
||||
if (d.has("from") && (Object *)(d["from"]) == texture_list) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (String(d["type"]) == "resource" && d.has("resource")) {
|
||||
RES r = d["resource"];
|
||||
@@ -195,8 +203,9 @@ bool TileSetEditor::can_drop_data_fw(const Point2 &p_point, const Variant &p_dat
|
||||
if (String(d["type"]) == "files") {
|
||||
Vector<String> files = d["files"];
|
||||
|
||||
if (files.size() == 0)
|
||||
if (files.size() == 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (int i = 0; i < files.size(); i++) {
|
||||
String file = files[i];
|
||||
@@ -213,21 +222,24 @@ bool TileSetEditor::can_drop_data_fw(const Point2 &p_point, const Variant &p_dat
|
||||
}
|
||||
|
||||
void TileSetEditor::drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) {
|
||||
if (!can_drop_data_fw(p_point, p_data, p_from))
|
||||
if (!can_drop_data_fw(p_point, p_data, p_from)) {
|
||||
return;
|
||||
}
|
||||
|
||||
Dictionary d = p_data;
|
||||
|
||||
if (!d.has("type"))
|
||||
if (!d.has("type")) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (String(d["type"]) == "resource" && d.has("resource")) {
|
||||
RES r = d["resource"];
|
||||
|
||||
Ref<Texture2D> texture = r;
|
||||
|
||||
if (texture.is_valid())
|
||||
if (texture.is_valid()) {
|
||||
add_texture(texture);
|
||||
}
|
||||
|
||||
if (texture_list->get_item_count() > 0) {
|
||||
update_texture_list_icon();
|
||||
@@ -622,8 +634,9 @@ TileSetEditor::TileSetEditor(EditorNode *p_editor) {
|
||||
}
|
||||
|
||||
TileSetEditor::~TileSetEditor() {
|
||||
if (helper)
|
||||
if (helper) {
|
||||
memdelete(helper);
|
||||
}
|
||||
}
|
||||
|
||||
void TileSetEditor::_on_tileset_toolbar_button_pressed(int p_index) {
|
||||
@@ -675,8 +688,9 @@ void TileSetEditor::_on_tileset_toolbar_confirm() {
|
||||
case TOOL_TILESET_CREATE_SCENE: {
|
||||
EditorNode *en = editor;
|
||||
Node *scene = en->get_edited_scene();
|
||||
if (!scene)
|
||||
if (!scene) {
|
||||
break;
|
||||
}
|
||||
|
||||
List<int> ids;
|
||||
tileset->get_tile_list(&ids);
|
||||
@@ -871,8 +885,9 @@ void TileSetEditor::_on_workspace_mode_changed(int p_workspace_mode) {
|
||||
}
|
||||
|
||||
void TileSetEditor::_on_workspace_draw() {
|
||||
if (tileset.is_null() || !get_current_texture().is_valid())
|
||||
if (tileset.is_null() || !get_current_texture().is_valid()) {
|
||||
return;
|
||||
}
|
||||
|
||||
const Color COLOR_AUTOTILE = Color(0.3, 0.6, 1);
|
||||
const Color COLOR_SINGLE = Color(1, 1, 0.3);
|
||||
@@ -1031,12 +1046,13 @@ void TileSetEditor::_on_workspace_draw() {
|
||||
Rect2i region = tileset->tile_get_region(t_id);
|
||||
region.position += WORKSPACE_MARGIN;
|
||||
Color c;
|
||||
if (tileset->tile_get_tile_mode(t_id) == TileSet::SINGLE_TILE)
|
||||
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)
|
||||
} 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)
|
||||
} else if (tileset->tile_get_tile_mode(t_id) == TileSet::ATLAS_TILE) {
|
||||
c = COLOR_ATLAS;
|
||||
}
|
||||
draw_tile_subdivision(t_id, COLOR_SUBDIVISION);
|
||||
workspace->draw_rect(region, c, false);
|
||||
}
|
||||
@@ -1047,39 +1063,43 @@ void TileSetEditor::_on_workspace_draw() {
|
||||
if (workspace_mode != WORKSPACE_EDIT) {
|
||||
Rect2i region = edited_region;
|
||||
Color c;
|
||||
if (workspace_mode == WORKSPACE_CREATE_SINGLE)
|
||||
if (workspace_mode == WORKSPACE_CREATE_SINGLE) {
|
||||
c = COLOR_SINGLE;
|
||||
else if (workspace_mode == WORKSPACE_CREATE_AUTOTILE)
|
||||
} else if (workspace_mode == WORKSPACE_CREATE_AUTOTILE) {
|
||||
c = COLOR_AUTOTILE;
|
||||
else if (workspace_mode == WORKSPACE_CREATE_ATLAS)
|
||||
} else if (workspace_mode == WORKSPACE_CREATE_ATLAS) {
|
||||
c = COLOR_ATLAS;
|
||||
}
|
||||
workspace->draw_rect(region, c, false);
|
||||
draw_edited_region_subdivision();
|
||||
} else {
|
||||
int t_id = get_current_tile();
|
||||
if (t_id < 0)
|
||||
if (t_id < 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
Rect2i region;
|
||||
if (draw_edited_region)
|
||||
if (draw_edited_region) {
|
||||
region = edited_region;
|
||||
else {
|
||||
} else {
|
||||
region = tileset->tile_get_region(t_id);
|
||||
region.position += WORKSPACE_MARGIN;
|
||||
}
|
||||
|
||||
if (draw_edited_region)
|
||||
if (draw_edited_region) {
|
||||
draw_edited_region_subdivision();
|
||||
else
|
||||
} else {
|
||||
draw_tile_subdivision(t_id, COLOR_SUBDIVISION);
|
||||
}
|
||||
|
||||
Color c;
|
||||
if (tileset->tile_get_tile_mode(t_id) == TileSet::SINGLE_TILE)
|
||||
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)
|
||||
} 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)
|
||||
} else if (tileset->tile_get_tile_mode(t_id) == TileSet::ATLAS_TILE) {
|
||||
c = COLOR_ATLAS;
|
||||
}
|
||||
workspace->draw_rect(region, c, false);
|
||||
}
|
||||
}
|
||||
@@ -1100,8 +1120,9 @@ void TileSetEditor::_on_workspace_process() {
|
||||
}
|
||||
|
||||
void TileSetEditor::_on_workspace_overlay_draw() {
|
||||
if (!tileset.is_valid() || !get_current_texture().is_valid())
|
||||
if (!tileset.is_valid() || !get_current_texture().is_valid()) {
|
||||
return;
|
||||
}
|
||||
|
||||
const Color COLOR_AUTOTILE = Color(0.266373, 0.565288, 0.988281);
|
||||
const Color COLOR_SINGLE = Color(0.988281, 0.909323, 0.266373);
|
||||
@@ -1113,19 +1134,21 @@ 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)
|
||||
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)
|
||||
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)
|
||||
} 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)
|
||||
} 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_theme_font("font", "Label");
|
||||
region.set_size(font->get_string_size(tile_id_name));
|
||||
@@ -1138,8 +1161,9 @@ void TileSetEditor::_on_workspace_overlay_draw() {
|
||||
}
|
||||
|
||||
int t_id = get_current_tile();
|
||||
if (t_id < 0)
|
||||
if (t_id < 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
Ref<Texture2D> handle = get_theme_icon("EditorHandle", "EditorIcons");
|
||||
if (draw_handles) {
|
||||
@@ -1175,8 +1199,9 @@ bool TileSetEditor::is_within_grabbing_distance_of_first_point(const Vector2 &p_
|
||||
}
|
||||
|
||||
void TileSetEditor::_on_workspace_input(const Ref<InputEvent> &p_ie) {
|
||||
if (tileset.is_null() || !get_current_texture().is_valid())
|
||||
if (tileset.is_null() || !get_current_texture().is_valid()) {
|
||||
return;
|
||||
}
|
||||
|
||||
static bool dragging;
|
||||
static bool erasing;
|
||||
@@ -1879,8 +1904,9 @@ void TileSetEditor::_on_tool_clicked(int p_tool) {
|
||||
}
|
||||
|
||||
void TileSetEditor::_on_priority_changed(float val) {
|
||||
if ((int)val == tileset->autotile_get_subtile_priority(get_current_tile(), edited_shape_coord))
|
||||
if ((int)val == tileset->autotile_get_subtile_priority(get_current_tile(), edited_shape_coord)) {
|
||||
return;
|
||||
}
|
||||
|
||||
undo_redo->create_action(TTR("Edit Tile Priority"));
|
||||
undo_redo->add_do_method(tileset.ptr(), "autotile_set_subtile_priority", get_current_tile(), edited_shape_coord, (int)val);
|
||||
@@ -1891,8 +1917,9 @@ void TileSetEditor::_on_priority_changed(float val) {
|
||||
}
|
||||
|
||||
void TileSetEditor::_on_z_index_changed(float val) {
|
||||
if ((int)val == tileset->autotile_get_z_index(get_current_tile(), edited_shape_coord))
|
||||
if ((int)val == tileset->autotile_get_z_index(get_current_tile(), edited_shape_coord)) {
|
||||
return;
|
||||
}
|
||||
|
||||
undo_redo->create_action(TTR("Edit Tile Z Index"));
|
||||
undo_redo->add_do_method(tileset.ptr(), "autotile_set_z_index", get_current_tile(), edited_shape_coord, (int)val);
|
||||
@@ -1948,8 +1975,9 @@ void TileSetEditor::_set_edited_shape_points(const Vector<Vector2> &points) {
|
||||
|
||||
void TileSetEditor::_update_tile_data() {
|
||||
current_tile_data.clear();
|
||||
if (get_current_tile() < 0)
|
||||
if (get_current_tile() < 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
Vector<TileSet::ShapeData> sd = tileset->tile_get_shapes(get_current_tile());
|
||||
if (tileset->tile_get_tile_mode(get_current_tile()) == TileSet::SINGLE_TILE) {
|
||||
@@ -2293,8 +2321,9 @@ void TileSetEditor::_set_snap_sep(Vector2 p_val) {
|
||||
}
|
||||
|
||||
void TileSetEditor::_validate_current_tile_id() {
|
||||
if (get_current_tile() >= 0 && !tileset->has_tile(get_current_tile()))
|
||||
if (get_current_tile() >= 0 && !tileset->has_tile(get_current_tile())) {
|
||||
set_current_tile(-1);
|
||||
}
|
||||
}
|
||||
|
||||
void TileSetEditor::_select_edited_shape_coord() {
|
||||
@@ -2386,14 +2415,18 @@ void TileSetEditor::draw_highlight_current_tile() {
|
||||
region = edited_region;
|
||||
}
|
||||
|
||||
if (region.position.y >= 0)
|
||||
if (region.position.y >= 0) {
|
||||
workspace->draw_rect(Rect2(0, 0, workspace->get_rect().size.x, region.position.y), shadow_color);
|
||||
if (region.position.x >= 0)
|
||||
}
|
||||
if (region.position.x >= 0) {
|
||||
workspace->draw_rect(Rect2(0, MAX(0, region.position.y), region.position.x, MIN(workspace->get_rect().size.y - region.position.y, MIN(region.size.y, region.position.y + region.size.y))), shadow_color);
|
||||
if (region.position.x + region.size.x <= workspace->get_rect().size.x)
|
||||
}
|
||||
if (region.position.x + region.size.x <= workspace->get_rect().size.x) {
|
||||
workspace->draw_rect(Rect2(region.position.x + region.size.x, MAX(0, region.position.y), workspace->get_rect().size.x - region.position.x - region.size.x, MIN(workspace->get_rect().size.y - region.position.y, MIN(region.size.y, region.position.y + region.size.y))), shadow_color);
|
||||
if (region.position.y + region.size.y <= workspace->get_rect().size.y)
|
||||
}
|
||||
if (region.position.y + region.size.y <= workspace->get_rect().size.y) {
|
||||
workspace->draw_rect(Rect2(0, region.position.y + region.size.y, workspace->get_rect().size.x, workspace->get_rect().size.y - region.size.y - region.position.y), shadow_color);
|
||||
}
|
||||
} else {
|
||||
workspace->draw_rect(Rect2(Point2(0, 0), workspace->get_rect().size), shadow_color);
|
||||
}
|
||||
@@ -2409,14 +2442,18 @@ void TileSetEditor::draw_highlight_subtile(Vector2 coord, const Vector<Vector2>
|
||||
coord += region.position;
|
||||
coord += WORKSPACE_MARGIN;
|
||||
|
||||
if (coord.y >= 0)
|
||||
if (coord.y >= 0) {
|
||||
workspace->draw_rect(Rect2(0, 0, workspace->get_rect().size.x, coord.y), shadow_color);
|
||||
if (coord.x >= 0)
|
||||
}
|
||||
if (coord.x >= 0) {
|
||||
workspace->draw_rect(Rect2(0, MAX(0, coord.y), coord.x, MIN(workspace->get_rect().size.y - coord.y, MIN(size.y, coord.y + size.y))), shadow_color);
|
||||
if (coord.x + size.x <= workspace->get_rect().size.x)
|
||||
}
|
||||
if (coord.x + size.x <= workspace->get_rect().size.x) {
|
||||
workspace->draw_rect(Rect2(coord.x + size.x, MAX(0, coord.y), workspace->get_rect().size.x - coord.x - size.x, MIN(workspace->get_rect().size.y - coord.y, MIN(size.y, coord.y + size.y))), shadow_color);
|
||||
if (coord.y + size.y <= workspace->get_rect().size.y)
|
||||
}
|
||||
if (coord.y + size.y <= workspace->get_rect().size.y) {
|
||||
workspace->draw_rect(Rect2(0, coord.y + size.y, workspace->get_rect().size.x, workspace->get_rect().size.y - size.y - coord.y), shadow_color);
|
||||
}
|
||||
|
||||
coord += Vector2(1, 1) / workspace->get_scale().x;
|
||||
workspace->draw_rect(Rect2(coord, size - Vector2(2, 2) / workspace->get_scale().x), Color(1, 0, 0), false);
|
||||
@@ -2550,8 +2587,9 @@ void TileSetEditor::draw_grid_snap() {
|
||||
|
||||
void TileSetEditor::draw_polygon_shapes() {
|
||||
int t_id = get_current_tile();
|
||||
if (t_id < 0)
|
||||
if (t_id < 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
switch (edit_mode) {
|
||||
case EDITMODE_COLLISION: {
|
||||
@@ -2607,8 +2645,9 @@ void TileSetEditor::draw_polygon_shapes() {
|
||||
}
|
||||
}
|
||||
|
||||
if (polygon.size() < 3)
|
||||
if (polygon.size() < 3) {
|
||||
continue;
|
||||
}
|
||||
|
||||
workspace->draw_polygon(polygon, colors);
|
||||
|
||||
@@ -2829,14 +2868,16 @@ void TileSetEditor::close_shape(const Vector2 &shape_anchor) {
|
||||
for (int i = 0; i < current_shape.size(); i++) {
|
||||
points.push_back(current_shape[i] - shape_anchor);
|
||||
|
||||
if (i != current_shape.size() - 1)
|
||||
if (i != current_shape.size() - 1) {
|
||||
p_total += ((current_shape[i + 1].x - current_shape[i].x) * (-current_shape[i + 1].y + (-current_shape[i].y)));
|
||||
else
|
||||
} else {
|
||||
p_total += ((current_shape[0].x - current_shape[i].x) * (-current_shape[0].y + (-current_shape[i].y)));
|
||||
}
|
||||
}
|
||||
|
||||
if (p_total < 0)
|
||||
if (p_total < 0) {
|
||||
points.invert();
|
||||
}
|
||||
|
||||
shape->set_points(points);
|
||||
|
||||
@@ -2851,10 +2892,11 @@ void TileSetEditor::close_shape(const Vector2 &shape_anchor) {
|
||||
}
|
||||
}
|
||||
undo_redo->add_do_method(tileset.ptr(), "tile_set_shapes", get_current_tile(), sd);
|
||||
if (tileset->tile_get_tile_mode(get_current_tile()) == TileSet::AUTO_TILE || tileset->tile_get_tile_mode(get_current_tile()) == TileSet::ATLAS_TILE)
|
||||
if (tileset->tile_get_tile_mode(get_current_tile()) == TileSet::AUTO_TILE || tileset->tile_get_tile_mode(get_current_tile()) == TileSet::ATLAS_TILE) {
|
||||
undo_redo->add_do_method(tileset.ptr(), "tile_add_shape", get_current_tile(), shape, Transform2D(), false, edited_shape_coord);
|
||||
else
|
||||
} else {
|
||||
undo_redo->add_do_method(tileset.ptr(), "tile_add_shape", get_current_tile(), shape, Transform2D());
|
||||
}
|
||||
tools[TOOL_SELECT]->set_pressed(true);
|
||||
undo_redo->add_do_method(this, "_select_edited_shape_coord");
|
||||
undo_redo->add_undo_method(this, "_select_edited_shape_coord");
|
||||
@@ -2923,17 +2965,21 @@ void TileSetEditor::close_shape(const Vector2 &shape_anchor) {
|
||||
void TileSetEditor::select_coord(const Vector2 &coord) {
|
||||
_update_tile_data();
|
||||
current_shape = PackedVector2Array();
|
||||
if (get_current_tile() == -1)
|
||||
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) {
|
||||
if (edited_collision_shape != tileset->tile_get_shape(get_current_tile(), 0))
|
||||
if (edited_collision_shape != tileset->tile_get_shape(get_current_tile(), 0)) {
|
||||
_set_edited_collision_shape(tileset->tile_get_shape(get_current_tile(), 0));
|
||||
if (edited_occlusion_shape != tileset->tile_get_light_occluder(get_current_tile()))
|
||||
}
|
||||
if (edited_occlusion_shape != tileset->tile_get_light_occluder(get_current_tile())) {
|
||||
edited_occlusion_shape = tileset->tile_get_light_occluder(get_current_tile());
|
||||
if (edited_navigation_shape != tileset->tile_get_navigation_polygon(get_current_tile()))
|
||||
}
|
||||
if (edited_navigation_shape != tileset->tile_get_navigation_polygon(get_current_tile())) {
|
||||
edited_navigation_shape = tileset->tile_get_navigation_polygon(get_current_tile());
|
||||
}
|
||||
|
||||
if (edit_mode == EDITMODE_COLLISION) {
|
||||
current_shape.resize(0);
|
||||
@@ -2965,18 +3011,22 @@ void TileSetEditor::select_coord(const Vector2 &coord) {
|
||||
bool found_collision_shape = false;
|
||||
for (int i = 0; i < sd.size(); i++) {
|
||||
if (sd[i].autotile_coord == coord) {
|
||||
if (edited_collision_shape != sd[i].shape)
|
||||
if (edited_collision_shape != sd[i].shape) {
|
||||
_set_edited_collision_shape(sd[i].shape);
|
||||
}
|
||||
found_collision_shape = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!found_collision_shape)
|
||||
if (!found_collision_shape) {
|
||||
_set_edited_collision_shape(Ref<ConvexPolygonShape2D>(nullptr));
|
||||
if (edited_occlusion_shape != tileset->autotile_get_light_occluder(get_current_tile(), coord))
|
||||
}
|
||||
if (edited_occlusion_shape != tileset->autotile_get_light_occluder(get_current_tile(), coord)) {
|
||||
edited_occlusion_shape = tileset->autotile_get_light_occluder(get_current_tile(), coord);
|
||||
if (edited_navigation_shape != tileset->autotile_get_navigation_polygon(get_current_tile(), coord))
|
||||
}
|
||||
if (edited_navigation_shape != tileset->autotile_get_navigation_polygon(get_current_tile(), coord)) {
|
||||
edited_navigation_shape = tileset->autotile_get_navigation_polygon(get_current_tile(), coord);
|
||||
}
|
||||
|
||||
int spacing = tileset->autotile_get_spacing(get_current_tile());
|
||||
Vector2 size = tileset->autotile_get_size(get_current_tile());
|
||||
@@ -3036,14 +3086,18 @@ Vector2 TileSetEditor::snap_point(const Vector2 &point) {
|
||||
p.y = Math::snap_scalar_separation(snap_offset.y, snap_step.y, p.y, snap_separation.y);
|
||||
}
|
||||
if (tools[SHAPE_KEEP_INSIDE_TILE]->is_pressed()) {
|
||||
if (p.x < region.position.x)
|
||||
if (p.x < region.position.x) {
|
||||
p.x = region.position.x;
|
||||
if (p.y < region.position.y)
|
||||
}
|
||||
if (p.y < region.position.y) {
|
||||
p.y = region.position.y;
|
||||
if (p.x > region.position.x + region.size.x)
|
||||
}
|
||||
if (p.x > region.position.x + region.size.x) {
|
||||
p.x = region.position.x + region.size.x;
|
||||
if (p.y > region.position.y + region.size.y)
|
||||
}
|
||||
if (p.y > region.position.y + region.size.y) {
|
||||
p.y = region.position.y + region.size.y;
|
||||
}
|
||||
}
|
||||
return p;
|
||||
}
|
||||
@@ -3091,8 +3145,9 @@ void TileSetEditor::update_texture_list() {
|
||||
|
||||
if (texture_list->get_item_count() > 0 && selected_texture.is_valid()) {
|
||||
texture_list->select(texture_list->find_metadata(selected_texture->get_rid()));
|
||||
if (texture_list->get_selected_items().size() > 0)
|
||||
if (texture_list->get_selected_items().size() > 0) {
|
||||
_on_texture_list_selected(texture_list->get_selected_items()[0]);
|
||||
}
|
||||
} else if (get_current_texture().is_valid()) {
|
||||
_on_texture_list_selected(texture_list->find_metadata(get_current_texture()->get_rid()));
|
||||
} else {
|
||||
@@ -3190,19 +3245,21 @@ void TileSetEditor::update_workspace_tile_mode() {
|
||||
tool_editmode[EDITMODE_PRIORITY]->hide();
|
||||
tool_editmode[EDITMODE_Z_INDEX]->hide();
|
||||
} else if (tileset->tile_get_tile_mode(get_current_tile()) == TileSet::AUTO_TILE) {
|
||||
if (edit_mode == EDITMODE_ICON)
|
||||
if (edit_mode == EDITMODE_ICON) {
|
||||
select_coord(tileset->autotile_get_icon_coordinate(get_current_tile()));
|
||||
else
|
||||
} else {
|
||||
_select_edited_shape_coord();
|
||||
}
|
||||
} else if (tileset->tile_get_tile_mode(get_current_tile()) == TileSet::ATLAS_TILE) {
|
||||
if (tool_editmode[EDITMODE_PRIORITY]->is_pressed() || tool_editmode[EDITMODE_BITMASK]->is_pressed()) {
|
||||
tool_editmode[EDITMODE_COLLISION]->set_pressed(true);
|
||||
edit_mode = EDITMODE_COLLISION;
|
||||
}
|
||||
if (edit_mode == EDITMODE_ICON)
|
||||
if (edit_mode == EDITMODE_ICON) {
|
||||
select_coord(tileset->autotile_get_icon_coordinate(get_current_tile()));
|
||||
else
|
||||
} else {
|
||||
_select_edited_shape_coord();
|
||||
}
|
||||
|
||||
tool_editmode[EDITMODE_BITMASK]->hide();
|
||||
}
|
||||
@@ -3275,10 +3332,11 @@ void TileSetEditor::set_current_tile(int p_id) {
|
||||
}
|
||||
|
||||
Ref<Texture2D> TileSetEditor::get_current_texture() {
|
||||
if (texture_list->get_selected_items().size() == 0)
|
||||
if (texture_list->get_selected_items().size() == 0) {
|
||||
return Ref<Texture2D>();
|
||||
else
|
||||
} else {
|
||||
return texture_map[texture_list->get_item_metadata(texture_list->get_selected_items()[0])];
|
||||
}
|
||||
}
|
||||
|
||||
void TilesetEditorContext::set_tileset(const Ref<TileSet> &p_tileset) {
|
||||
@@ -3309,8 +3367,9 @@ bool TilesetEditorContext::_set(const StringName &p_name, const Variant &p_value
|
||||
String name2 = p_name.operator String().right(5);
|
||||
bool v = false;
|
||||
|
||||
if (tileset_editor->get_current_tile() < 0 || tileset.is_null())
|
||||
if (tileset_editor->get_current_tile() < 0 || tileset.is_null()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (name2 == "autotile_bitmask_mode") {
|
||||
tileset->set(String::num(tileset_editor->get_current_tile(), 0) + "/autotile/bitmask_mode", p_value, &v);
|
||||
@@ -3371,10 +3430,12 @@ bool TilesetEditorContext::_get(const StringName &p_name, Variant &r_ret) const
|
||||
} else if (name.left(5) == "tile_") {
|
||||
name = name.right(5);
|
||||
|
||||
if (tileset_editor->get_current_tile() < 0 || tileset.is_null())
|
||||
if (tileset_editor->get_current_tile() < 0 || tileset.is_null()) {
|
||||
return false;
|
||||
if (!tileset->has_tile(tileset_editor->get_current_tile()))
|
||||
}
|
||||
if (!tileset->has_tile(tileset_editor->get_current_tile())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (name == "autotile_bitmask_mode") {
|
||||
r_ret = tileset->get(String::num(tileset_editor->get_current_tile(), 0) + "/autotile/bitmask_mode", &v);
|
||||
|
||||
Reference in New Issue
Block a user