diff --git a/CodeGen/EnumsMigration/src/CKEnums.txt b/CodeGen/EnumsMigration/src/CKEnums.txt index cc03ee2..d5d840a 100644 --- a/CodeGen/EnumsMigration/src/CKEnums.txt +++ b/CodeGen/EnumsMigration/src/CKEnums.txt @@ -135,12 +135,6 @@ typedef enum CK_OBJECT_SHOWOPTION { CKHIERARCHICALHIDE =2 } CK_OBJECT_SHOWOPTION; -typedef enum CK_OBJECT_CANBEHIDE { - CKCANNOTHIDE =0, // the object cannot be hidden - CKCANHIDE =1, // the object can be hidden - CKCANHIERARCHICALHIDE =2 // the object can be hidden and hierarchically hidden -} CK_OBJECT_CANBEHIDE; - /*************************************************** {filename:CK_OBJECT_FLAGS} Summary: CKObject Flags diff --git a/LibCmo/CK2/CKEnums.hpp b/LibCmo/CK2/CKEnums.hpp index 17d1444..1b3c88e 100644 --- a/LibCmo/CK2/CKEnums.hpp +++ b/LibCmo/CK2/CKEnums.hpp @@ -144,11 +144,6 @@ namespace LibCmo::CK2 { CKSHOW = 0x1, CKHIERARCHICALHIDE = 0x2, }; - enum class CK_OBJECT_CANBEHIDE : CKDWORD { - CKCANNOTHIDE = 0, /**< the object cannot be hidden */ - CKCANHIDE = 1, /**< the object can be hidden */ - CKCANHIERARCHICALHIDE = 2, /**< the object can be hidden and hierarchically hidden */ - }; /** CKObject Flags @remark diff --git a/LibCmo/CK2/ObjImpls/CK3dEntity.cpp b/LibCmo/CK2/ObjImpls/CK3dEntity.cpp index 1503521..f245c7f 100644 --- a/LibCmo/CK2/ObjImpls/CK3dEntity.cpp +++ b/LibCmo/CK2/ObjImpls/CK3dEntity.cpp @@ -116,11 +116,13 @@ namespace LibCmo::CK2::ObjImpls { // copy visible data // process direct visible - // todo add if visible - // and set or unset VX_MOVEABLE_VISIBLE - + if (EnumsHelper::Has(m_ObjectFlags, CK_OBJECT_FLAGS::CK_OBJECT_VISIBLE)) { + EnumsHelper::Add(m_MoveableFlags, VxMath::VX_MOVEABLE_FLAGS::VX_MOVEABLE_VISIBLE); + } else { + EnumsHelper::Rm(m_MoveableFlags, VxMath::VX_MOVEABLE_FLAGS::VX_MOVEABLE_VISIBLE); + } // process indirect visible - if (EnumsHelper::Has(m_ObjectFlags, CK_OBJECT_FLAGS::CKBEHAVIORLINK_ACTIVATEDLASTFRAME)) { + if (EnumsHelper::Has(m_ObjectFlags, CK_OBJECT_FLAGS::CK_OBJECT_HIERACHICALHIDE)) { EnumsHelper::Add(m_MoveableFlags, VxMath::VX_MOVEABLE_FLAGS::VX_MOVEABLE_HIERARCHICALHIDE); } else { EnumsHelper::Rm(m_MoveableFlags, VxMath::VX_MOVEABLE_FLAGS::VX_MOVEABLE_HIERARCHICALHIDE); @@ -157,4 +159,29 @@ namespace LibCmo::CK2::ObjImpls { return true; } + void CK3dEntity::Show(CK_OBJECT_SHOWOPTION show) { + CKObject::Show(show); + + EnumsHelper::Rm(m_MoveableFlags, EnumsHelper::Merge({ + VxMath::VX_MOVEABLE_FLAGS::VX_MOVEABLE_VISIBLE, + VxMath::VX_MOVEABLE_FLAGS::VX_MOVEABLE_HIERARCHICALHIDE, + })); + switch (show) { + case CK_OBJECT_SHOWOPTION::CKSHOW: + EnumsHelper::Add(m_MoveableFlags, VxMath::VX_MOVEABLE_FLAGS::VX_MOVEABLE_VISIBLE); + break; + case CK_OBJECT_SHOWOPTION::CKHIERARCHICALHIDE: + EnumsHelper::Add(m_MoveableFlags, VxMath::VX_MOVEABLE_FLAGS::VX_MOVEABLE_HIERARCHICALHIDE); + break; + case CK_OBJECT_SHOWOPTION::CKHIDE: + break; + } + } + + bool CK3dEntity::IsVisible() const { + // MARK: originally there is a call to this->IsHiddenByParent. + // but we drop the support of parent, so we drop that condition. + return CKObject::IsVisible(); + } + } diff --git a/LibCmo/CK2/ObjImpls/CK3dEntity.hpp b/LibCmo/CK2/ObjImpls/CK3dEntity.hpp index 1d17630..49d4a3f 100644 --- a/LibCmo/CK2/ObjImpls/CK3dEntity.hpp +++ b/LibCmo/CK2/ObjImpls/CK3dEntity.hpp @@ -18,6 +18,10 @@ namespace LibCmo::CK2::ObjImpls { virtual bool Save(CKStateChunk* chunk, CKFileVisitor* file, CKDWORD flags) override; virtual bool Load(CKStateChunk* chunk, CKFileVisitor* file) override; //virtual void PostLoad() override; + + // it have special Show and IsVisible method + virtual void Show(CK_OBJECT_SHOWOPTION show = CK_OBJECT_SHOWOPTION::CKSHOW) override; + virtual bool IsVisible() const override; protected: XContainer::XObjectPointerArray m_PotentialMeshes; diff --git a/LibCmo/CK2/ObjImpls/CKGroup.cpp b/LibCmo/CK2/ObjImpls/CKGroup.cpp index 7aeef17..31279c1 100644 --- a/LibCmo/CK2/ObjImpls/CKGroup.cpp +++ b/LibCmo/CK2/ObjImpls/CKGroup.cpp @@ -54,6 +54,16 @@ namespace LibCmo::CK2::ObjImpls { return true; } + void CKGroup::Show(CK_OBJECT_SHOWOPTION show) { + CKObject::Show(show); + + // call Show for all sub object + for (auto& ptr : m_ObjectArray) { + if (ptr == nullptr) continue; + ptr->Show(show); + } + } + CKDWORD CKGroup::GetGroupIndex() { return m_GroupIndex; } diff --git a/LibCmo/CK2/ObjImpls/CKGroup.hpp b/LibCmo/CK2/ObjImpls/CKGroup.hpp index 7a3531a..6f526f7 100644 --- a/LibCmo/CK2/ObjImpls/CKGroup.hpp +++ b/LibCmo/CK2/ObjImpls/CKGroup.hpp @@ -19,6 +19,9 @@ namespace LibCmo::CK2::ObjImpls { virtual bool Load(CKStateChunk* chunk, CKFileVisitor* file) override; //virtual void PostLoad() override; + // it only have special Show method + virtual void Show(CK_OBJECT_SHOWOPTION show = CK_OBJECT_SHOWOPTION::CKSHOW) override; + CKDWORD GetGroupIndex(); // ===== Insert ===== diff --git a/LibCmo/CK2/ObjImpls/CKMesh.cpp b/LibCmo/CK2/ObjImpls/CKMesh.cpp index 64b4db5..ee2ead7 100644 --- a/LibCmo/CK2/ObjImpls/CKMesh.cpp +++ b/LibCmo/CK2/ObjImpls/CKMesh.cpp @@ -33,10 +33,7 @@ namespace LibCmo::CK2::ObjImpls { // read flag if (chunk->SeekIdentifier(CK_STATESAVEFLAGS_MESH::CK_STATESAVE_MESHFLAGS)) { - CKDWORD flags; - chunk->ReadStruct(flags); - - m_Flags = static_cast(flags); + chunk->ReadStruct(m_Flags); EnumsHelper::Mask(m_Flags, VxMath::VXMESH_FLAGS::VXMESH_ALLFLAGS); // I don't know why, just interpter the IDA code. @@ -226,6 +223,16 @@ namespace LibCmo::CK2::ObjImpls { return true; } + void CKMesh::Show(CK_OBJECT_SHOWOPTION show) { + CKObject::Show(show); + + if (show == CK_OBJECT_SHOWOPTION::CKSHOW) { + EnumsHelper::Add(m_Flags, VxMath::VXMESH_FLAGS::VXMESH_VISIBLE); + } else { + EnumsHelper::Rm(m_Flags, VxMath::VXMESH_FLAGS::VXMESH_VISIBLE); + } + } + #pragma region Misc Section void CKMesh::CleanMesh() { diff --git a/LibCmo/CK2/ObjImpls/CKMesh.hpp b/LibCmo/CK2/ObjImpls/CKMesh.hpp index 45535af..609d970 100644 --- a/LibCmo/CK2/ObjImpls/CKMesh.hpp +++ b/LibCmo/CK2/ObjImpls/CKMesh.hpp @@ -19,7 +19,10 @@ namespace LibCmo::CK2::ObjImpls { virtual bool Save(CKStateChunk* chunk, CKFileVisitor* file, CKDWORD flags) override; virtual bool Load(CKStateChunk* chunk, CKFileVisitor* file) override; //virtual void PostLoad() override; - + + // it only have special Show method + virtual void Show(CK_OBJECT_SHOWOPTION show = CK_OBJECT_SHOWOPTION::CKSHOW) override; + // ===== Misc Section ===== public: void CleanMesh(); diff --git a/LibCmo/CK2/ObjImpls/CKObject.cpp b/LibCmo/CK2/ObjImpls/CKObject.cpp index 58274ea..7bf4d5a 100644 --- a/LibCmo/CK2/ObjImpls/CKObject.cpp +++ b/LibCmo/CK2/ObjImpls/CKObject.cpp @@ -28,9 +28,6 @@ namespace LibCmo::CK2::ObjImpls { void CKObject::SetObjectFlags(CK_OBJECT_FLAGS flags) { m_ObjectFlags = flags; } - bool CKObject::IsHierarchicallyHide() const { - return EnumsHelper::Has(m_ObjectFlags, CK_OBJECT_FLAGS::CK_OBJECT_HIERACHICALHIDE); - } CKContext* CKObject::GetCKContext() const { return m_Context; } @@ -92,14 +89,6 @@ namespace LibCmo::CK2::ObjImpls { } } - bool CKObject::IsHiddenByParent() const { - return false; - } - - CK_OBJECT_CANBEHIDE CKObject::CanBeHide() const { - return CK_OBJECT_CANBEHIDE::CKCANNOTHIDE; - } - bool CKObject::IsVisible() const { return EnumsHelper::Has(m_ObjectFlags, CK_OBJECT_FLAGS::CK_OBJECT_VISIBLE); } diff --git a/LibCmo/CK2/ObjImpls/CKObject.hpp b/LibCmo/CK2/ObjImpls/CKObject.hpp index 2fdc721..897bceb 100644 --- a/LibCmo/CK2/ObjImpls/CKObject.hpp +++ b/LibCmo/CK2/ObjImpls/CKObject.hpp @@ -14,8 +14,6 @@ Implement as original meaning: - GetClassID() - Show() -- IsHiddenByParent() -- CanBeHide() - IsVisible() - CheckPreDeletion() @@ -27,6 +25,9 @@ No implement because don't care: - PrepareDependencies() - RemapDependencies() +- IsHiddenByParent() +- CanBeHide() + Implement moved into other location: - Copy(): Use CKObject::CKObject(CK_ID newid, const CKObject* obj) ctor and CKClassDesc to implement. - PreDelete(): Write in dtor. @@ -46,7 +47,6 @@ namespace LibCmo::CK2::ObjImpls { void SetName(CKSTRING u8_name); CK_OBJECT_FLAGS GetObjectFlags(void) const; void SetObjectFlags(CK_OBJECT_FLAGS flags); - bool IsHierarchicallyHide() const; CKContext* GetCKContext() const; virtual CK_CLASSID GetClassID(void) { @@ -73,27 +73,12 @@ namespace LibCmo::CK2::ObjImpls { */ virtual void Show(CK_OBJECT_SHOWOPTION show = CK_OBJECT_SHOWOPTION::CKSHOW); /** - * @brief Returns whether this object is hidden (and also hides its children). - * @return true if hierarchically hidden. + * @brief Returns whether this object is visible + * @return TRUE if the object is visible, FALSE otherwise * @remark - * + This methods returns if this object is hidden and also hides all its sub-hierarchy. - * + See CKObject::Show¡ì for more details on hierarchically hidden objects. + * + Only CKRenderObject and derived classes(CK2dEntity,CK3dEntity),CKMesh and CKGroup return relevant information about their visibility state. Other classes may return any values. + * + An object can return CKSHOW and still be hidden if its parent (see CK3dEntity::GetParent and CK2dEntity::GetParent) is hierarchically hidden (see CKObject::Show) */ - virtual bool IsHiddenByParent() const; - /** - * @brief Returns whether this object class allows it to be shown or hidden. - * @return 3 possible value according to its type. - * + CKCANNOTHIDE if the object cannot be hidden - * + CKCANHIDE if the object can be hidden - * + CKCANHIERARCHICALHIDE if the object can be hidden and hierarchically hidden - * @remark - * + This virtual function is mainly used by the Virtools interface to known if visibility flags have an impact on a specific object class. - * + CKRenderObject and derived classes,can be triggered as to be shown or hidden or hierarchically hidden and will return 2 to this function. - * + CKMesh and CKGroup can be triggered as to be shown or hidden and will return 1 to this function. - * + Other classes will return 0 which means CKObject::Show function will not have any impact on them. - - */ - virtual CK_OBJECT_CANBEHIDE CanBeHide() const; virtual bool IsVisible() const; protected: diff --git a/LibCmo/CK2/ObjImpls/CKRenderObject.cpp b/LibCmo/CK2/ObjImpls/CKRenderObject.cpp deleted file mode 100644 index b2d02a9..0000000 --- a/LibCmo/CK2/ObjImpls/CKRenderObject.cpp +++ /dev/null @@ -1,8 +0,0 @@ -#include "CKRenderObject.hpp" -#include "../CKStateChunk.hpp" - -namespace LibCmo::CK2::ObjImpls { - - // nothing to compile now - -} diff --git a/LibCmo/CK2/ObjImpls/CKRenderObject.hpp b/LibCmo/CK2/ObjImpls/CKRenderObject.hpp index 8e63757..f254302 100644 --- a/LibCmo/CK2/ObjImpls/CKRenderObject.hpp +++ b/LibCmo/CK2/ObjImpls/CKRenderObject.hpp @@ -16,11 +16,13 @@ namespace LibCmo::CK2::ObjImpls { virtual CK_CLASSID GetClassID(void) override { return CK_CLASSID::CKCID_RENDEROBJECT; } + // CKRenderObject do not implement any load/save functions //virtual void PreSave(CKFileVisitor* file, CKDWORD flags) override; //virtual bool Save(CKStateChunk* chunk, CKFileVisitor* file, CKDWORD flags) override; //virtual bool Load(CKStateChunk* chunk, CKFileVisitor* file) override; //virtual void PostLoad() override; + protected: }; diff --git a/LibCmo/CK2/ObjImpls/CKSceneObject.cpp b/LibCmo/CK2/ObjImpls/CKSceneObject.cpp deleted file mode 100644 index 7a8edd1..0000000 --- a/LibCmo/CK2/ObjImpls/CKSceneObject.cpp +++ /dev/null @@ -1,15 +0,0 @@ -#include "CKSceneObject.hpp" -#include "../CKStateChunk.hpp" - -namespace LibCmo::CK2::ObjImpls { - - //bool CKSceneObject::Save(CKStateChunk* chunk, CKFileVisitor* file, CKDWORD flags) { - // return false; - //} - - //bool CKSceneObject::Load(CKStateChunk* chunk, CKFileVisitor* file) { - // return false; - //} - -} - diff --git a/LibCmo/LibCmo.vcxproj b/LibCmo/LibCmo.vcxproj index 69b7aab..77557ff 100644 --- a/LibCmo/LibCmo.vcxproj +++ b/LibCmo/LibCmo.vcxproj @@ -192,8 +192,6 @@ - - diff --git a/LibCmo/LibCmo.vcxproj.filters b/LibCmo/LibCmo.vcxproj.filters index 71d8e40..bafe075 100644 --- a/LibCmo/LibCmo.vcxproj.filters +++ b/LibCmo/LibCmo.vcxproj.filters @@ -84,18 +84,12 @@ Sources\CK2 - - Sources\CK2\ObjImpls - Sources\CK2\ObjImpls Sources\CK2\ObjImpls - - Sources\CK2\ObjImpls - Sources\CK2\ObjImpls