doc: fix issue. add documentation.

- fix build issue in CKTypes
- add documentation for CKTypes, VTAll and VTImage.
This commit is contained in:
yyc12345 2024-08-18 11:33:51 +08:00
parent 9903b61cac
commit 1483466211
3 changed files with 91 additions and 60 deletions

View File

@ -12,15 +12,15 @@
namespace LibCmo { namespace LibCmo {
// Types. // Types.
// These types is general types used in every module. // These types are general types used in every module.
// So we declare them in LibCmo, not LibCmo::CK2 to make sure every module can use it. // So we declare them in LibCmo, not LibCmo::CK2 to make sure every module can use it.
/** /**
* @brief General constant UTF8 string type. * @brief The representation of constant UTF8 string pointer.
*/ */
using CKSTRING = const char8_t*; using CKSTRING = const char8_t*;
/** /**
* @brief Changeble CKSTRING. * @brief The representation of mutable CKSTRING (UTF8 string pointer).
* @see CKSTRING * @see CKSTRING
*/ */
using CKMUTSTRING = char8_t*; using CKMUTSTRING = char8_t*;
@ -28,58 +28,58 @@ namespace LibCmo {
* @brief The representation of single UTF8 code unit (1 byte). * @brief The representation of single UTF8 code unit (1 byte).
* @remarks * @remarks
* \li Only used with string process. * \li Only used with string process.
* \li For memory representation and moving, use CKBYTE instead. * \li For memory representation and operating, use CKBYTE instead.
* @see CKBYTE * @see CKSTRING, CKBYTE
*/ */
using CKCHAR = char8_t; using CKCHAR = char8_t;
/** /**
* @brief Always Represent a Byte (1 byte, unsigned). Platform Independent. * @brief Platform independent representation of a byte (1 byte, unsigned).
* @remark * @remarks
* + This type should only be used when representing memory data or position. * \li This type should only be used when representing memory data or position.
* + If you want to represent a char, or a sequence of chars, use CKCHAR instead. * \li If you want to represent a character code unit, or a sequence of chars, use CKCHAR instead.
* @see CKCHAR * @see CKCHAR
*/ */
using CKBYTE = uint8_t; using CKBYTE = uint8_t;
/** /**
* @brief Always Represent a WORD (2 byte, unsigned). Platform Independent. * @brief Platform independent representation of a WORD (2 byte, unsigned).
*/ */
using CKWORD = uint16_t; using CKWORD = uint16_t;
/** /**
* @brief Always Represent a DWORD (4 byte, unsigned). Platform Independent. * @brief Platform independent representation of a DWORD (4 byte, unsigned).
* @see CKINT * @see CKINT
*/ */
using CKDWORD = uint32_t; using CKDWORD = uint32_t;
/** /**
* @brief Always Represent a QWORD (8 byte, unsigned). Platform Independent. * @brief Platform independent representation of a QWORD (8 byte, unsigned).
*/ */
using CKQWORD = uint64_t; using CKQWORD = uint64_t;
/** /**
* @brief The Int type used in LibCmo. * @brief Platform independent representation of \c int.
* @remark * @remarks
* \i All \c int type in original Virtools SDK should be replaced with CKINT in this project if needed. * \li All \c int type presented in original Virtools SDK should be replaced by this type, CKINT, in this project if needed.
* \li This type also can be seen as the equvalent of signed CKDWORD. * \li This type also can be seen as the equvalent of signed CKDWORD.
* @see CKDWORD * @see CKDWORD
*/ */
using CKINT = int32_t; using CKINT = int32_t;
/** /**
* @brief Always Represent a float (32 bit). Platform Independent. * @brief Platform independent representation of a float (32 bit floating point type).
*/ */
using CKFLOAT = float; using CKFLOAT = float;
/** /**
* @brief Always Represent a double (64 bit). Platform Independent. * @brief Platform independent representation of a double (64 bit floating point type).
*/ */
using CKDOUBLE = double; using CKDOUBLE = double;
/** /**
* @brief Represent a x86 Platform Pointer. * @brief Platform independent representation of a x86 pointer.
* @remark * @remark
* \li This type only can be used when replacing pointer in old Virtools struct / class. * \li This type only should be used when replacing pointer in old Virtools struct / class.
* \li Due to Virtools shitty design, in some cases we need read data with x86 memory layout from file. * \li Due to Virtools shitty design, in some cases we need read data with x86 memory layout from file.
* So we use this type to replace native pointer in struct existed in Virtools SDK to make sure this * So we use this type to replace native pointer in struct existed in Virtools SDK
* program can run perfectly on x64 and more architectures. * to make sure this program can run perfectly on x64 and more architectures.
* \li A example usage can be found in CK2::ObjImpls::CKTexture::Load(). * \li A example usage can be found in CK2::ObjImpls::CKTexture::Load().
*/ */
using CKPTR = uint32_t; using CKPTR = uint32_t;
@ -116,7 +116,8 @@ namespace LibCmo {
/** /**
* @brief The convenient sizeof macro which return \c CKDWORD instead of \c size_t. * @brief The convenient sizeof macro which return \c CKDWORD instead of \c size_t.
* This is usually used in LibCmo because LibCmo use \c CKDWORD, not \c size_t everywhere. * @details This macro is frequently used in LibCmo.
* Because LibCmo use \c CKDWORD, not \c size_t everywhere.
*/ */
#define CKSizeof(_Ty) (static_cast<::LibCmo::CKDWORD>(sizeof(_Ty))) #define CKSizeof(_Ty) (static_cast<::LibCmo::CKDWORD>(sizeof(_Ty)))
@ -124,23 +125,34 @@ namespace LibCmo {
// ========== CK2 Section ========== // ========== CK2 Section ==========
/**
* @brief The CK2 part of LibCmo. The main part of LibCmo.
* @details
* This namespace include most implementations of LibCmo,
* including important CKContext, CKStateChunk and etc.
*/
namespace LibCmo::CK2 { namespace LibCmo::CK2 {
/** /**
* @brief Unique Identifier for all Objects instanciated in a given CKContext * @brief Unique identifier for all CK2 objects instantiated in CKContext
* @remarks * @remarks
* \li Each instance of CKObject and derived classes are automatically given a global unique * \li Each instance of ObjImpls::CKObject and derived classes are automatically given a global unique ID at creation time.
* ID at creation time. This ID can be accessed through the CKObject::GetID method. * This ID can be accessed through the ObjImpls::CKObject::GetID() method.
* It is safer, though a bit slower, to reference object through their global ID than through * It is safer, though a bit slower, to reference object through their global ID than through a direct pointer.
* a direct pointer reference. In any case the referenced object may be deleted even though * In some cases the referenced object may be deleted even though the client has a object ID for it.
* the client object has a ID for it. The client object should verify that the referenced object * The client should verify that the referenced object still exists when used via CKContext::GetObject().
* still exists when used with the CKGetObject function. * \li The global ID for an instance remains unique and unchanged through a application session,
* \li The global ID for an instance remains unique and unchanged through a application session, but there * but there is no guarateen that this ID will be the same when a level is saved and loaded back again.
* is no garanty that this ID will be the same when a level is saved and loaded back again. * @see ObjImpls::CKObject::GetID(), CKContext::GetObject()
* @see CKObject::GetID, CKContext::GetObject
*/ */
using CK_ID = CKDWORD; using CK_ID = CKDWORD;
/**
* @brief The enumeration of all CK2 errors
* @details
* Some CK2, Vx, XContainer functions will try to return a error code to indicate
* whether given operation has been done successfully.
*/
enum class CKERROR : CKINT { enum class CKERROR : CKINT {
CKERR_OK = 0, /**< Operation successful */ CKERR_OK = 0, /**< Operation successful */
CKERR_INVALIDPARAMETER = -1, /**< One of the parameter passed to the function was invalid */ CKERR_INVALIDPARAMETER = -1, /**< One of the parameter passed to the function was invalid */
@ -196,14 +208,16 @@ namespace LibCmo::CK2 {
}; };
/** /**
* @brief Per Class Unique Identifier. * @brief Unique class identifier.
* @remark * @remarks
* \li Each class derived from the CKObject class has a unique class ID. * \li Each class derived from the ObjImpls::CKObject class has a unique class ID.
* \li This ID can be accessed through each instance of these classes, with the * \li This ID can be accessed through each instance of these classes, with the ObjImpls::CKObject::GetClassID() method.
* CKObject::GetClassID method. * \li This class ID is used internally for various matching operations, like matching behaviors on objects, etc..
* \li This class ID is used internally for various matching operations, like matching behaviors on * \li Identifiers listed in there is CK2 builtin class identifier list.
* objects, etc.. * In original Virtools SDK, user can use plugin mechanism to register more class identifier in runtime.
* @see CKObject::GetClassID, CKIsChildClassOf, Class Identifiers * Virtools only guarateen that identifiers listed in there must correspond with its real meaning.
* However, there is no guarateen that IDs not listed in there will be the same when Virtools engine quit and initialized back again.
* @see ObjImpls::CKObject::GetClassID(), CKIsChildClassOf()
*/ */
enum class CK_CLASSID : CKINT { enum class CK_CLASSID : CKINT {
CKCID_OBJECT = 1, CKCID_OBJECT = 1,
@ -389,7 +403,7 @@ namespace LibCmo::CK2 {
class CKSoundHandler; class CKSoundHandler;
} }
// Important classes // Important classes (rewritten hugely)
class CKContext; class CKContext;
class CKStateChunk; class CKStateChunk;
class CKFileReader; class CKFileReader;
@ -397,30 +411,34 @@ namespace LibCmo::CK2 {
class CKFileVisitor; class CKFileVisitor;
/** /**
* @brief Global Unique Identifier Struture. * @brief Global unique identifier struture.
* @remark * @remarks
* \li Guids are used to uniquely identify plugins,operation types, parameter types and behavior prototypes. * \li Guids are used to uniquely identify plugins, operation types, parameter types and behavior prototypes.
* \li Comparison operators are defined so CKGUID can be compared with ==, != , <, > operators. * \li Comparison operators are defined so CKGUID can be compared with ==, != , <, > operators.
* \li Its defined as following code * \li It's defined as following code
* \code * \code
* typedef struct CKGUID { * typedef struct CKGUID {
* union { * union {
* struct { CKDWORD d1,d2; }; * struct { CKDWORD d1,d2; };
* CKDWORD d[2]; * CKDWORD d[2];
* }; * };
* }; * };
* \endcode * \endcode
* @see Pre-Registred Parameter Types, ParameterOperation Types
*/ */
struct CKGUID { struct CKGUID {
CKDWORD d1, d2; CKDWORD d1, d2;
constexpr CKGUID(CKDWORD gd1 = 0, CKDWORD gd2 = 0) : d1(gd1), d2(gd2) {} constexpr CKGUID(CKDWORD gd1 = 0, CKDWORD gd2 = 0) : d1(gd1), d2(gd2) {}
CKGUID(const CKGUID& rhs) : d1(rhs.d1), d2(rhs.d2) {} CKGUID(const CKGUID& rhs) : d1(rhs.d1), d2(rhs.d2) {}
CKGUID(CKGUID&& rhs) : d1(rhs.d1), d2(rhs.d2) {}
CKGUID& operator=(const CKGUID& rhs) { CKGUID& operator=(const CKGUID& rhs) {
this->d1 = rhs.d1; this->d1 = rhs.d1;
this->d2 = rhs.d2; this->d2 = rhs.d2;
return *this;
}
CKGUID& operator=(CKGUID&& rhs) {
this->d1 = rhs.d1;
this->d2 = rhs.d2;
return *this; return *this;
} }

View File

@ -1,20 +1,29 @@
#pragma once #pragma once
/* /**
This file is provided for user of LibCmo. * \file
This file should not be included in LibCmo project inside. * This header file is exposed to end user.
Use VTInternal.hpp for project internal including. * In end user program, user can only simply include this single header file
* to include all necessity about Virtools.
* This file is pretty like \c CKAll.h in original Virtools SDK.
*
* This file should not be included in LibCmo project inside.
* If you want to have initialized LibCmo development environment within this project,
* please include VTInternal.hpp instead.
*/ */
// Include internal header
#include "VTInternal.hpp" #include "VTInternal.hpp"
// CK2 Misc
#include "CK2/CKContext.hpp" #include "CK2/CKContext.hpp"
#include "CK2/CKStateChunk.hpp" #include "CK2/CKStateChunk.hpp"
#include "CK2/CKFile.hpp" #include "CK2/CKFile.hpp"
// Data handlers // CK2 Data handlers
#include "CK2/DataHandlers/CKBitmapHandler.hpp" #include "CK2/DataHandlers/CKBitmapHandler.hpp"
// Objects // CK2 Objects
#include "CK2/ObjImpls/CKObject.hpp" #include "CK2/ObjImpls/CKObject.hpp"
#include "CK2/ObjImpls/CKSceneObject.hpp" #include "CK2/ObjImpls/CKSceneObject.hpp"
#include "CK2/ObjImpls/CKBeObject.hpp" #include "CK2/ObjImpls/CKBeObject.hpp"
@ -26,7 +35,7 @@ Use VTInternal.hpp for project internal including.
#include "CK2/ObjImpls/CKMaterial.hpp" #include "CK2/ObjImpls/CKMaterial.hpp"
#include "CK2/ObjImpls/CKMesh.hpp" #include "CK2/ObjImpls/CKMesh.hpp"
// Managers // CK2 Managers
#include "CK2/MgrImpls/CKBaseManager.hpp" #include "CK2/MgrImpls/CKBaseManager.hpp"
#include "CK2/MgrImpls/CKObjectManager.hpp" #include "CK2/MgrImpls/CKObjectManager.hpp"
#include "CK2/MgrImpls/CKPathManager.hpp" #include "CK2/MgrImpls/CKPathManager.hpp"

View File

@ -1,5 +1,9 @@
/**
// Bad wrapper for stb image library. * \file
* This file extract all stb-image implementations used by this project.
* Because std-image is a header-only library.
* It use macro to control whether extract implementation.
*/
#define STB_IMAGE_IMPLEMENTATION #define STB_IMAGE_IMPLEMENTATION
#include <stb_image.h> #include <stb_image.h>