From b057e8d9af15e68f13023422c85374857546ea25 Mon Sep 17 00:00:00 2001 From: Relintai Date: Tue, 17 Aug 2021 02:24:32 +0200 Subject: [PATCH] Added a tiling type enum to TiledWallData. Also removed the now unused members and renamed a parameter. --- tiled_wall/tiled_wall_data.cpp | 39 ++++++++++++++++++++++------------ tiled_wall/tiled_wall_data.h | 24 +++++++++++++++------ 2 files changed, 42 insertions(+), 21 deletions(-) diff --git a/tiled_wall/tiled_wall_data.cpp b/tiled_wall/tiled_wall_data.cpp index cd5029f..41fe9a1 100644 --- a/tiled_wall/tiled_wall_data.cpp +++ b/tiled_wall/tiled_wall_data.cpp @@ -30,6 +30,15 @@ SOFTWARE. #define Shape Shape3D #endif +const String TiledWallData::BINDING_STRING_TILED_WALL_TILING_TYPE = "None,Horizontal,Vertical,Both"; + +TiledWallData::TiledWallTilingType TiledWallData::get_tiling_type() const { + return _tiling_type; +} +void TiledWallData::set_tiling_type(const TiledWallData::TiledWallTilingType value) { + _tiling_type = value; +} + Ref TiledWallData::get_texture(const int index) const { ERR_FAIL_INDEX_V(index, _textures.size(), Ref()); @@ -139,31 +148,24 @@ void TiledWallData::add_textures_into(Ref texture_packer) { } #endif -void TiledWallData::copy_from(const Ref &prop_data) { - _id = prop_data->_id; - _snap_to_mesh = prop_data->_snap_to_mesh; - _snap_axis = prop_data->_snap_axis; - +void TiledWallData::copy_from(const Ref &tiled_wall_data) { _textures.clear(); - for (int i = 0; i < prop_data->_textures.size(); ++i) { - _textures.push_back(prop_data->_textures[i]); + for (int i = 0; i < tiled_wall_data->_textures.size(); ++i) { + _textures.push_back(tiled_wall_data->_textures[i]); } _flavour_textures.clear(); - for (int i = 0; i < prop_data->_flavour_textures.size(); ++i) { - _flavour_textures.push_back(prop_data->_flavour_textures[i]); + for (int i = 0; i < tiled_wall_data->_flavour_textures.size(); ++i) { + _flavour_textures.push_back(tiled_wall_data->_flavour_textures[i]); } emit_changed(); } TiledWallData::TiledWallData() { - _id = 0; - _snap_to_mesh = false; - _is_room = false; - _snap_axis = Vector3(0, -1, 0); + _tiling_type = TILED_WALL_TILING_TYPE_NONE; } TiledWallData::~TiledWallData() { _textures.clear(); @@ -171,6 +173,10 @@ TiledWallData::~TiledWallData() { } void TiledWallData::_bind_methods() { + ClassDB::bind_method(D_METHOD("get_tiling_type"), &TiledWallData::get_tiling_type); + ClassDB::bind_method(D_METHOD("set_tiling_type", "texture"), &TiledWallData::set_tiling_type); + ADD_PROPERTY(PropertyInfo(Variant::INT, "tiling_type", PROPERTY_HINT_ENUM, "17/17:Texture"), "set_tiling_type", "get_tiling_type"); + //textures ClassDB::bind_method(D_METHOD("get_texture", "index"), &TiledWallData::get_texture); ClassDB::bind_method(D_METHOD("set_texture", "index", "texture"), &TiledWallData::set_texture); @@ -193,11 +199,16 @@ void TiledWallData::_bind_methods() { ClassDB::bind_method(D_METHOD("get_flavour_textures"), &TiledWallData::get_flavour_textures); ClassDB::bind_method(D_METHOD("set_flavour_textures", "textures"), &TiledWallData::set_flavour_textures); - ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "textures", PROPERTY_HINT_NONE, "17/17:Texture", PROPERTY_USAGE_DEFAULT, "Texture"), "set_flavour_textures", "get_flavour_textures"); + ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "flavour_textures", PROPERTY_HINT_NONE, "17/17:Texture", PROPERTY_USAGE_DEFAULT, "Texture"), "set_flavour_textures", "get_flavour_textures"); #if TEXTURE_PACKER_PRESENT ClassDB::bind_method(D_METHOD("add_textures_into", "texture_packer"), &TiledWallData::add_textures_into); #endif ClassDB::bind_method(D_METHOD("copy_from", "prop_data"), &TiledWallData::copy_from); + + BIND_ENUM_CONSTANT(TILED_WALL_TILING_TYPE_NONE); + BIND_ENUM_CONSTANT(TILED_WALL_TILING_TYPE_HORIZONTAL); + BIND_ENUM_CONSTANT(TILED_WALL_TILING_TYPE_VERTICAL); + BIND_ENUM_CONSTANT(TILED_WALL_TILING_TYPE_BOTH); } diff --git a/tiled_wall/tiled_wall_data.h b/tiled_wall/tiled_wall_data.h index 4470872..5cea813 100644 --- a/tiled_wall/tiled_wall_data.h +++ b/tiled_wall/tiled_wall_data.h @@ -50,6 +50,19 @@ class TiledWallData : public Resource { GDCLASS(TiledWallData, Resource); public: + enum TiledWallTilingType { + TILED_WALL_TILING_TYPE_NONE = 0, + TILED_WALL_TILING_TYPE_HORIZONTAL, + TILED_WALL_TILING_TYPE_VERTICAL, + TILED_WALL_TILING_TYPE_BOTH + }; + + static const String BINDING_STRING_TILED_WALL_TILING_TYPE; + +public: + TiledWallTilingType get_tiling_type() const; + void set_tiling_type(const TiledWallTilingType value); + //textures Ref get_texture(const int index) const; void set_texture(const int index, const Ref &texture); @@ -76,7 +89,7 @@ public: void add_textures_into(Ref texture_packer); #endif - void copy_from(const Ref &prop_data); + void copy_from(const Ref &tiled_wall_data); TiledWallData(); ~TiledWallData(); @@ -85,15 +98,12 @@ protected: static void _bind_methods(); private: - int _id; - bool _snap_to_mesh; - Vector3 _snap_axis; + TiledWallTilingType _tiling_type; Vector> _textures; Vector> _flavour_textures; - - bool _is_room; - PoolVector3Array _room_bounds; }; +VARIANT_ENUM_CAST(TiledWallData::TiledWallTilingType); + #endif