summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <rverschelde@gmail.com>2019-03-05 00:19:48 +0100
committerGitHub <noreply@github.com>2019-03-05 00:19:48 +0100
commit3aff78f53242df3a5541747e818ce4ac68219a16 (patch)
treeae6c36f51eabc5a9010044e1a9f45bb06846b12d
parent0952522e8b8fe59f36566001c02883e482c0096b (diff)
parent33406131c1bc0fd2d1664a31154d4f805b6dc76c (diff)
Merge pull request #26599 from MarianoGnu/fix_25817
TileSetEditor: Expose to the user OneWayCollision+Margin properties.
-rw-r--r--editor/plugins/tile_set_editor_plugin.cpp40
1 files changed, 40 insertions, 0 deletions
diff --git a/editor/plugins/tile_set_editor_plugin.cpp b/editor/plugins/tile_set_editor_plugin.cpp
index 75417d986c..e041c3d62e 100644
--- a/editor/plugins/tile_set_editor_plugin.cpp
+++ b/editor/plugins/tile_set_editor_plugin.cpp
@@ -3118,6 +3118,24 @@ bool TilesetEditorContext::_set(const StringName &p_name, const Variant &p_value
} else if (name == "tileset_script") {
tileset->set_script(p_value);
return true;
+ } else if (name == "selected_collision_one_way") {
+ Vector<TileSet::ShapeData> sd = tileset->tile_get_shapes(tileset_editor->get_current_tile());
+ for (int index = 0; index < sd.size(); index++) {
+ if (sd[index].shape == tileset_editor->edited_collision_shape) {
+ tileset->tile_set_shape_one_way(tileset_editor->get_current_tile(), index, p_value);
+ return true;
+ }
+ }
+ return false;
+ } else if (name == "selected_collision_one_way_margin") {
+ Vector<TileSet::ShapeData> sd = tileset->tile_get_shapes(tileset_editor->get_current_tile());
+ for (int index = 0; index < sd.size(); index++) {
+ if (sd[index].shape == tileset_editor->edited_collision_shape) {
+ tileset->tile_set_shape_one_way_margin(tileset_editor->get_current_tile(), index, p_value);
+ return true;
+ }
+ }
+ return false;
}
tileset_editor->err_dialog->set_text(TTR("This property can't be changed."));
@@ -3160,6 +3178,24 @@ bool TilesetEditorContext::_get(const StringName &p_name, Variant &r_ret) const
} else if (name == "selected_collision") {
r_ret = tileset_editor->edited_collision_shape;
v = true;
+ } else if (name == "selected_collision_one_way") {
+ Vector<TileSet::ShapeData> sd = tileset->tile_get_shapes(tileset_editor->get_current_tile());
+ for (int index = 0; index < sd.size(); index++) {
+ if (sd[index].shape == tileset_editor->edited_collision_shape) {
+ r_ret = sd[index].one_way_collision;
+ v = true;
+ break;
+ }
+ }
+ } else if (name == "selected_collision_one_way_margin") {
+ Vector<TileSet::ShapeData> sd = tileset->tile_get_shapes(tileset_editor->get_current_tile());
+ for (int index = 0; index < sd.size(); index++) {
+ if (sd[index].shape == tileset_editor->edited_collision_shape) {
+ r_ret = sd[index].one_way_collision_margin;
+ v = true;
+ break;
+ }
+ }
} else if (name == "selected_navigation") {
r_ret = tileset_editor->edited_navigation_shape;
v = true;
@@ -3206,6 +3242,10 @@ void TilesetEditorContext::_get_property_list(List<PropertyInfo> *p_list) const
}
if (tileset_editor->edit_mode == TileSetEditor::EDITMODE_COLLISION && tileset_editor->edited_collision_shape.is_valid()) {
p_list->push_back(PropertyInfo(Variant::OBJECT, "selected_collision", PROPERTY_HINT_RESOURCE_TYPE, tileset_editor->edited_collision_shape->get_class()));
+ if (tileset_editor->edited_collision_shape.is_valid()) {
+ p_list->push_back(PropertyInfo(Variant::BOOL, "selected_collision_one_way", PROPERTY_HINT_NONE));
+ p_list->push_back(PropertyInfo(Variant::REAL, "selected_collision_one_way_margin", PROPERTY_HINT_NONE));
+ }
}
if (tileset_editor->edit_mode == TileSetEditor::EDITMODE_NAVIGATION && tileset_editor->edited_navigation_shape.is_valid()) {
p_list->push_back(PropertyInfo(Variant::OBJECT, "selected_navigation", PROPERTY_HINT_RESOURCE_TYPE, tileset_editor->edited_navigation_shape->get_class()));