diff --git a/LibCmo/CK2/ObjImpls/CKBeObject.cpp b/LibCmo/CK2/ObjImpls/CKBeObject.cpp new file mode 100644 index 0000000..032fb77 --- /dev/null +++ b/LibCmo/CK2/ObjImpls/CKBeObject.cpp @@ -0,0 +1,25 @@ +#include "CKSceneObject.hpp" +#include "../CKStateChunk.hpp" +#include "CKBeObject.hpp" + +namespace LibCmo::CK2::ObjImpls { + + bool CKBeObject::Save(CKStateChunk* chunk, CKFileVisitor* file, CKDWORD flags) { + bool suc = CKSceneObject::Save(chunk, file, flags); + if (!suc) return false; + + return true; + } + + bool CKBeObject::Load(CKStateChunk* chunk, CKFileVisitor* file) { + bool suc = CKSceneObject::Load(chunk, file); + if (!suc) return false; + + return true; + } + + bool CKBeObject::IsInGroup(CKGroup* group) { + return false; + } + +} \ No newline at end of file diff --git a/LibCmo/CK2/ObjImpls/CKBeObject.hpp b/LibCmo/CK2/ObjImpls/CKBeObject.hpp new file mode 100644 index 0000000..e6129b8 --- /dev/null +++ b/LibCmo/CK2/ObjImpls/CKBeObject.hpp @@ -0,0 +1,30 @@ +#pragma once + +#include "../../VTAll.hpp" +#include "CKSceneObject.hpp" + +namespace LibCmo::CK2::ObjImpls { + + class CKBeObject : public CKSceneObject { + public: + CKBeObject(CKContext* ctx, CK_ID ckid, CKSTRING name) : + CKSceneObject(ctx, ckid, name) + {} + virtual ~CKBeObject() {} + LIBCMO_DISABLE_COPY_MOVE(CKBeObject); + + virtual CK_CLASSID GetClassID(void) override { + return CK_CLASSID::CKCID_BEOBJECT; + } + //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; + + bool IsInGroup(CKGroup* group); + + protected: + XContainer::XBitArray m_Groups; + }; + +} \ No newline at end of file diff --git a/LibCmo/CK2/ObjImpls/CKGroup.cpp b/LibCmo/CK2/ObjImpls/CKGroup.cpp new file mode 100644 index 0000000..f95f27c --- /dev/null +++ b/LibCmo/CK2/ObjImpls/CKGroup.cpp @@ -0,0 +1,27 @@ +#include "CKSceneObject.hpp" +#include "../CKStateChunk.hpp" +#include "CKGroup.hpp" + +namespace LibCmo::CK2::ObjImpls { + + bool CKGroup::Save(CKStateChunk* chunk, CKFileVisitor* file, CKDWORD flags) { + return false; + } + + bool CKGroup::Load(CKStateChunk* chunk, CKFileVisitor* file) { + return false; + } + + CKDWORD CKGroup::GetGroupIndex() { + return m_GroupIndex; + } + + CKObject* CKGroup::GetObject(CKDWORD pos) { + return nullptr; + } + + CKDWORD CKGroup::GetObjectCount() { + return CKDWORD(); + } + +} diff --git a/LibCmo/CK2/ObjImpls/CKGroup.hpp b/LibCmo/CK2/ObjImpls/CKGroup.hpp new file mode 100644 index 0000000..97c50ae --- /dev/null +++ b/LibCmo/CK2/ObjImpls/CKGroup.hpp @@ -0,0 +1,53 @@ +#pragma once + +#include "../../VTAll.hpp" +#include "CKBeObject.hpp" + +namespace LibCmo::CK2::ObjImpls { + + class CKGroup : public CKBeObject { + public: + CKGroup(CKContext* ctx, CK_ID ckid, CKSTRING name) : + CKBeObject(ctx, ckid, name), + m_ObjectArray(), + m_GroupIndex() // todo: allocate group id + {} + virtual ~CKGroup() { + // todo: free allocated group id + } + LIBCMO_DISABLE_COPY_MOVE(CKGroup); + + virtual CK_CLASSID GetClassID(void) override { + return CK_CLASSID::CKCID_GROUP; + } + //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; + + CKDWORD GetGroupIndex(); + + // ===== Insert ===== + CKERROR AddObject(CKBeObject *o); + CKERROR AddObjectFront(CKBeObject *o); + CKERROR InsertObjectAt(CKBeObject *o, CKDWORD pos); + + // ===== Remove ===== + CKBeObject* RemoveObject(CKDWORD pos); + void RemoveObject(CKBeObject *obj); + void Clear(); + + // ===== Order ===== + void MoveObjectUp(CKBeObject *o); + void MoveObjectDown(CKBeObject *o); + + // ===== Access ===== + CKObject* GetObject(CKDWORD pos); + CKDWORD GetObjectCount(); + + protected: + XContainer::XObjectPointerArray m_ObjectArray; + CKDWORD m_GroupIndex; + }; + +} diff --git a/LibCmo/CK2/ObjImpls/CKObject.hpp b/LibCmo/CK2/ObjImpls/CKObject.hpp index e42282f..ca486d6 100644 --- a/LibCmo/CK2/ObjImpls/CKObject.hpp +++ b/LibCmo/CK2/ObjImpls/CKObject.hpp @@ -1,7 +1,6 @@ #pragma once -#include "../../VTUtils.hpp" -#include "../CKContext.hpp" +#include "../../VTAll.hpp" namespace LibCmo::CK2::ObjImpls { @@ -38,13 +37,12 @@ namespace LibCmo::CK2::ObjImpls { virtual CK_CLASSID GetClassID(void) { return CK_CLASSID::CKCID_OBJECT; } - virtual void PreSave(CKFileVisitor* file, CKDWORD flags); virtual bool Save(CKStateChunk* chunk, CKFileVisitor* file, CKDWORD flags); virtual bool Load(CKStateChunk* chunk, CKFileVisitor* file); virtual void PostLoad(); - private: + protected: CK_ID m_ID; TypeHelper::MKString m_Name; CK_OBJECT_FLAGS m_ObjectFlags; diff --git a/LibCmo/CK2/ObjImpls/CKSceneObject.cpp b/LibCmo/CK2/ObjImpls/CKSceneObject.cpp new file mode 100644 index 0000000..7a8edd1 --- /dev/null +++ b/LibCmo/CK2/ObjImpls/CKSceneObject.cpp @@ -0,0 +1,15 @@ +#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/CK2/ObjImpls/CKSceneObject.hpp b/LibCmo/CK2/ObjImpls/CKSceneObject.hpp new file mode 100644 index 0000000..0736888 --- /dev/null +++ b/LibCmo/CK2/ObjImpls/CKSceneObject.hpp @@ -0,0 +1,29 @@ +#pragma once + +#include "../../VTAll.hpp" +#include "CKObject.hpp" + +namespace LibCmo::CK2::ObjImpls { + + class CKSceneObject : public CKObject { + public: + CKSceneObject(CKContext* ctx, CK_ID ckid, CKSTRING name) : + CKObject(ctx, ckid, name), + m_Scenes() {} + virtual ~CKSceneObject() {} + LIBCMO_DISABLE_COPY_MOVE(CKSceneObject); + + virtual CK_CLASSID GetClassID(void) override { + return CK_CLASSID::CKCID_SCENEOBJECT; + } + // CKSceneObject do not override any RW 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: + XContainer::XBitArray m_Scenes; + }; + +} \ No newline at end of file diff --git a/LibCmo/LibCmo.vcxproj b/LibCmo/LibCmo.vcxproj index 7dd11d7..b9f9b18 100644 --- a/LibCmo/LibCmo.vcxproj +++ b/LibCmo/LibCmo.vcxproj @@ -180,7 +180,10 @@ + + + @@ -197,6 +200,9 @@ + + + diff --git a/LibCmo/LibCmo.vcxproj.filters b/LibCmo/LibCmo.vcxproj.filters index 3e36177..cad2ac9 100644 --- a/LibCmo/LibCmo.vcxproj.filters +++ b/LibCmo/LibCmo.vcxproj.filters @@ -78,6 +78,15 @@ Sources\CK2 + + Sources\CK2\ObjImpls + + + Sources\CK2\ObjImpls + + + Sources\CK2\ObjImpls + @@ -122,11 +131,20 @@ Headers - + Headers\CK2\ObjImpls - + Headers\CK2\MgrImpls + + Headers\CK2\ObjImpls + + + Headers\CK2\ObjImpls + + + Headers\CK2\ObjImpls + \ No newline at end of file diff --git a/LibCmo/VTEncoding.hpp b/LibCmo/VTEncoding.hpp index 91d986f..df8c085 100644 --- a/LibCmo/VTEncoding.hpp +++ b/LibCmo/VTEncoding.hpp @@ -7,6 +7,10 @@ #if defined(LIBCMO_OS_WIN32) #include #include +// disable annoy macro at the same time +#undef GetObject +#undef GetClassName +#undef LoadImage #else #include #endif diff --git a/LibCmo/VTUtils.hpp b/LibCmo/VTUtils.hpp index b185001..a26e2c2 100644 --- a/LibCmo/VTUtils.hpp +++ b/LibCmo/VTUtils.hpp @@ -39,6 +39,7 @@ #if defined(_WIN32) #define LIBCMO_OS_WIN32 +// disable annoy win32 macro #define WIN32_LEAN_AND_MEAN #define NOMINMAX #endif