diff --git a/tiled_wall/tiled_wall_data.cpp b/tiled_wall/tiled_wall_data.cpp index 0dff2fe..0e4d318 100644 --- a/tiled_wall/tiled_wall_data.cpp +++ b/tiled_wall/tiled_wall_data.cpp @@ -51,46 +51,46 @@ void TiledWallData::set_snap_axis(const Vector3 &value) { _snap_axis = value; } -Ref TiledWallData::get_prop(const int index) const { - ERR_FAIL_INDEX_V(index, _props.size(), Ref()); +Ref TiledWallData::get_texture(const int index) const { + ERR_FAIL_INDEX_V(index, _textures.size(), Ref()); - return _props.get(index); + return _textures.get(index); } -void TiledWallData::set_prop(const int index, const Ref prop) { - ERR_FAIL_INDEX(index, _props.size()); +void TiledWallData::set_texture(const int index, const Ref prop) { + ERR_FAIL_INDEX(index, _textures.size()); - _props.set(index, prop); + _textures.set(index, prop); } -void TiledWallData::add_prop(const Ref prop) { - _props.push_back(prop); +void TiledWallData::add_texture(const Ref prop) { + _textures.push_back(prop); } -void TiledWallData::remove_prop(const int index) { - ERR_FAIL_INDEX(index, _props.size()); +void TiledWallData::remove_texture(const int index) { + ERR_FAIL_INDEX(index, _textures.size()); - _props.remove(index); + _textures.remove(index); } -int TiledWallData::get_prop_count() const { - return _props.size(); +int TiledWallData::get_texture_count() const { + return _textures.size(); } -Vector TiledWallData::get_props() { +Vector TiledWallData::get_textures() { Vector r; - for (int i = 0; i < _props.size(); i++) { + for (int i = 0; i < _textures.size(); i++) { #if VERSION_MAJOR < 4 - r.push_back(_props[i].get_ref_ptr()); + r.push_back(_textures[i].get_ref_ptr()); #else - r.push_back(_props[i]); + r.push_back(_textures[i]); #endif } return r; } -void TiledWallData::set_props(const Vector &props) { - _props.clear(); +void TiledWallData::set_textures(const Vector &props) { + _textures.clear(); for (int i = 0; i < props.size(); i++) { - Ref prop = Ref(props[i]); + Ref tex = Ref(props[i]); - _props.push_back(prop); + _textures.push_back(tex); } } @@ -98,9 +98,9 @@ void TiledWallData::set_props(const Vector &props) { void TiledWallData::add_textures_into(Ref texture_packer) { ERR_FAIL_COND(!texture_packer.is_valid()); - for (int i = 0; i < _props.size(); ++i) { + for (int i = 0; i < _textures.size(); ++i) { - Ref entry = _props.get(i); + Ref entry = _textures.get(i); if (entry.is_valid()) { texture_packer->add_texture(entry); @@ -128,10 +128,10 @@ void TiledWallData::copy_from(const Ref &prop_data) { _snap_to_mesh = prop_data->_snap_to_mesh; _snap_axis = prop_data->_snap_axis; - _props.clear(); + _textures.clear(); - for (int i = 0; i < prop_data->_props.size(); ++i) { - _props.push_back(prop_data->_props[i]); + for (int i = 0; i < prop_data->_textures.size(); ++i) { + _textures.push_back(prop_data->_textures[i]); } emit_changed(); @@ -144,7 +144,7 @@ TiledWallData::TiledWallData() { _snap_axis = Vector3(0, -1, 0); } TiledWallData::~TiledWallData() { - _props.clear(); + _textures.clear(); } void TiledWallData::_bind_methods() { @@ -156,16 +156,16 @@ void TiledWallData::_bind_methods() { ClassDB::bind_method(D_METHOD("set_snap_axis", "value"), &TiledWallData::set_snap_axis); ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "snap_axis"), "set_snap_axis", "get_snap_axis"); - ClassDB::bind_method(D_METHOD("get_prop", "index"), &TiledWallData::get_prop); - ClassDB::bind_method(D_METHOD("set_prop", "index", "spell"), &TiledWallData::set_prop); - ClassDB::bind_method(D_METHOD("add_prop", "prop"), &TiledWallData::add_prop); - ClassDB::bind_method(D_METHOD("remove_prop", "index"), &TiledWallData::remove_prop); + ClassDB::bind_method(D_METHOD("get_texture", "index"), &TiledWallData::get_texture); + ClassDB::bind_method(D_METHOD("set_texture", "index", "texture"), &TiledWallData::set_texture); + ClassDB::bind_method(D_METHOD("add_texture", "texture"), &TiledWallData::add_texture); + ClassDB::bind_method(D_METHOD("remove_texture", "index"), &TiledWallData::remove_texture); - ClassDB::bind_method(D_METHOD("get_prop_count"), &TiledWallData::get_prop_count); + ClassDB::bind_method(D_METHOD("get_texture_count"), &TiledWallData::get_texture_count); - ClassDB::bind_method(D_METHOD("get_props"), &TiledWallData::get_props); - ClassDB::bind_method(D_METHOD("set_props", "props"), &TiledWallData::set_props); - ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "props", PROPERTY_HINT_NONE, "17/17:Texture", PROPERTY_USAGE_DEFAULT, "Texture"), "set_props", "get_props"); + ClassDB::bind_method(D_METHOD("get_textures"), &TiledWallData::get_textures); + ClassDB::bind_method(D_METHOD("set_textures", "textures"), &TiledWallData::set_textures); + ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "textures", PROPERTY_HINT_NONE, "17/17:Texture", PROPERTY_USAGE_DEFAULT, "Texture"), "set_textures", "get_textures"); #if TEXTURE_PACKER_PRESENT ClassDB::bind_method(D_METHOD("add_textures_into", "texture_packer"), &TiledWallData::add_textures_into); diff --git a/tiled_wall/tiled_wall_data.h b/tiled_wall/tiled_wall_data.h index 87b21ee..a900207 100644 --- a/tiled_wall/tiled_wall_data.h +++ b/tiled_wall/tiled_wall_data.h @@ -59,15 +59,15 @@ public: Vector3 get_snap_axis() const; void set_snap_axis(const Vector3 &value); - Ref get_prop(const int index) const; - void set_prop(const int index, const Ref prop); - void add_prop(const Ref prop); - void remove_prop(const int index); + Ref get_texture(const int index) const; + void set_texture(const int index, const Ref prop); + void add_texture(const Ref prop); + void remove_texture(const int index); - int get_prop_count() const; + int get_texture_count() const; - Vector get_props(); - void set_props(const Vector &props); + Vector get_textures(); + void set_textures(const Vector &textures); #if TEXTURE_PACKER_PRESENT void add_textures_into(Ref texture_packer); @@ -92,7 +92,7 @@ private: bool _snap_to_mesh; Vector3 _snap_axis; - Vector> _props; + Vector> _textures; bool _is_room; PoolVector3Array _room_bounds;