libcmo21/LibCmo/CK2/ObjImpls/CKObject.hpp

94 lines
3.1 KiB
C++
Raw Permalink Normal View History

2023-08-23 16:04:58 +08:00
#pragma once
#include "../../VTInternal.hpp"
2023-08-23 16:04:58 +08:00
2023-09-04 22:58:53 +08:00
/**
CKObject virtual functions implementations help
Implement as original meaning:
- PreSave()
- Save()
- Load()
- PostLoad()
- GetClassID()
- Show()
- IsVisible()
- PreDelete()
2023-09-20 10:49:32 +08:00
- CheckPreDeletion()
- CheckPostDeletion()
2023-09-04 22:58:53 +08:00
No implement because don't care:
- GetMemoryOccupation()
- IsObjectUsed()
- PrepareDependencies()
- RemapDependencies()
2023-09-20 13:13:08 +08:00
- IsHiddenByParent()
- CanBeHide()
2023-09-04 22:58:53 +08:00
Implement moved into other location:
- Copy(): Use CKObject::CKObject(CK_ID newid, const CKObject* obj) ctor and CKClassDesc to implement.
*/
namespace LibCmo::CK2::ObjImpls {
2023-08-23 16:04:58 +08:00
class CKObject {
public:
2023-09-20 10:49:32 +08:00
CKObject(CKContext* ctx, CK_ID ckid, CKSTRING name);
virtual ~CKObject();
YYCC_DEL_CLS_COPY_MOVE(CKObject);
2023-08-23 16:04:58 +08:00
2023-09-20 10:49:32 +08:00
CK_ID GetID(void) const;
CKSTRING GetName(void) const;
void SetName(CKSTRING u8_name);
CK_OBJECT_FLAGS GetObjectFlags(void) const;
void SetObjectFlags(CK_OBJECT_FLAGS flags);
bool IsToBeDeleted() const;
2023-09-20 10:49:32 +08:00
CKContext* GetCKContext() const;
2023-08-23 16:04:58 +08:00
virtual CK_CLASSID GetClassID(void) {
return CK_CLASSID::CKCID_OBJECT;
}
2023-09-20 10:49:32 +08:00
virtual void PreDelete();
virtual void CheckPreDeletion();
virtual void CheckPostDeletion();
2023-09-20 10:49:32 +08:00
2023-08-25 21:57:22 +08:00
virtual void PreSave(CKFileVisitor* file, CKDWORD flags);
2023-08-28 17:04:28 +08:00
virtual bool Save(CKStateChunk* chunk, CKFileVisitor* file, CKDWORD flags);
2023-08-25 21:57:22 +08:00
virtual bool Load(CKStateChunk* chunk, CKFileVisitor* file);
2023-08-23 16:04:58 +08:00
virtual void PostLoad();
2023-09-20 10:49:32 +08:00
/**
* @brief Shows or hides an object
* @remark
* + If show is set to CKHIERARCHICALHIDE this object will be hidden along with all its children.
* + The render engine renders objets in a hierarchical way and stops iterating a hierarchy if it encounters an object which is hierarchically hidden. The problem is that, for performance reason, children objets visibility flags are left unchanged (ie. if a child object was visible CKObject::IsVisible will still return TRUE). To test is a object is hidden because one of its parent object is hierarchically hidden use CKObject::IsHiddenByParent
* + The CKHIERARCHICALHIDE option is only relevant for CK2dEntity and CK3dEntity derived classes.
* + If show is set to CKSHOW the object will be shown and it also removes the hierarchically hidden flags.
* + If show is set to CKHIDE the object will be hidden and it also removes the hierarchically hidden flags.
* + This function is overload by CKGroup,CKMesh and CK3dEntity.
*/
virtual void Show(CK_OBJECT_SHOWOPTION show = CK_OBJECT_SHOWOPTION::CKSHOW);
/**
2023-09-20 13:13:08 +08:00
* @brief Returns whether this object is visible
* @return TRUE if the object is visible, FALSE otherwise
2023-09-20 10:49:32 +08:00
* @remark
2023-09-20 13:13:08 +08:00
* + 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)
2023-09-20 10:49:32 +08:00
*/
virtual bool IsVisible() const;
2023-08-31 21:54:25 +08:00
protected:
2023-08-23 16:04:58 +08:00
CK_ID m_ID;
2023-09-16 18:31:25 +08:00
XContainer::XString m_Name;
2023-08-23 16:04:58 +08:00
CK_OBJECT_FLAGS m_ObjectFlags;
CKContext* m_Context;
};
}