2023-02-08 22:57:31 +08:00
|
|
|
#pragma once
|
|
|
|
|
2023-08-26 20:34:51 +08:00
|
|
|
#include <VTAll.hpp>
|
2023-02-09 14:12:02 +08:00
|
|
|
#include <vector>
|
2023-02-08 22:57:31 +08:00
|
|
|
#include <string>
|
2024-08-23 17:38:45 +08:00
|
|
|
#include <type_traits>
|
2023-02-08 22:57:31 +08:00
|
|
|
|
|
|
|
namespace Unvirt {
|
|
|
|
namespace AccessibleValue {
|
|
|
|
|
2024-08-23 17:38:45 +08:00
|
|
|
constexpr const char8_t c_InvalidEnumName[] = u8"[undefined]";
|
2023-02-09 17:16:58 +08:00
|
|
|
|
2024-08-23 17:38:45 +08:00
|
|
|
#pragma region Size Formatter
|
|
|
|
|
|
|
|
std::u8string GetReadableFileSize(uint64_t _size);
|
|
|
|
|
|
|
|
#pragma endregion
|
|
|
|
|
|
|
|
#pragma region CKERROR CK_CLASSID Data
|
|
|
|
|
|
|
|
std::u8string GetCkErrorName(LibCmo::CK2::CKERROR err);
|
|
|
|
std::u8string GetCkErrorDescription(LibCmo::CK2::CKERROR err);
|
|
|
|
|
|
|
|
std::u8string GetClassIdName(LibCmo::CK2::CK_CLASSID cls);
|
|
|
|
std::u8string GetClassIdHierarchy(LibCmo::CK2::CK_CLASSID cls);
|
|
|
|
|
|
|
|
#pragma endregion
|
|
|
|
|
|
|
|
#pragma region Other Enums
|
|
|
|
|
|
|
|
struct GeneralReflection { const char8_t* mName; };
|
|
|
|
template<typename _Ty, std::enable_if_t<std::is_enum_v<_Ty>, int> = 0>
|
2023-08-26 20:34:51 +08:00
|
|
|
using GeneralReflectionArray = std::vector<std::pair<_Ty, GeneralReflection>>;
|
2023-02-09 17:16:58 +08:00
|
|
|
|
2024-08-23 17:38:45 +08:00
|
|
|
template<typename _Ty, std::enable_if_t<std::is_enum_v<_Ty>, int> = 0>
|
|
|
|
std::u8string GetEnumName(_Ty val, const GeneralReflectionArray<_Ty>& desc) {
|
|
|
|
std::u8string strl;
|
2023-08-26 20:34:51 +08:00
|
|
|
for (auto& item : desc) {
|
|
|
|
if (item.first == val) {
|
|
|
|
strl = item.second.mName;
|
2023-03-03 16:05:32 +08:00
|
|
|
return strl;
|
2023-02-09 17:16:58 +08:00
|
|
|
}
|
|
|
|
}
|
2024-08-23 17:38:45 +08:00
|
|
|
YYCC::StringHelper::Printf(strl, u8"%s (0x%08" PRIXCKDWORD ")",
|
|
|
|
c_InvalidEnumName,
|
2023-09-22 16:40:10 +08:00
|
|
|
static_cast<LibCmo::CKDWORD>(val)
|
|
|
|
);
|
2023-03-03 16:05:32 +08:00
|
|
|
return strl;
|
2023-02-09 17:16:58 +08:00
|
|
|
}
|
2024-08-23 17:38:45 +08:00
|
|
|
template<typename _Ty, std::enable_if_t<std::is_enum_v<_Ty>, int> = 0>
|
|
|
|
std::u8string GetFlagEnumName(_Ty val, const GeneralReflectionArray<_Ty>& desc, const char8_t* splitor = u8" ", const char8_t* indent = u8"") {
|
|
|
|
std::u8string strl, cache;
|
2023-08-26 20:34:51 +08:00
|
|
|
for (auto& item : desc) {
|
2023-02-09 17:16:58 +08:00
|
|
|
// if it have exacelt same entry, return directly
|
2023-08-26 20:34:51 +08:00
|
|
|
if (item.first == val) {
|
2024-08-23 17:38:45 +08:00
|
|
|
YYCC::StringHelper::Printf(strl, u8"%s (0x%08" PRIXCKDWORD ")",
|
2023-09-22 22:31:51 +08:00
|
|
|
item.second.mName,
|
|
|
|
static_cast<LibCmo::CKDWORD>(item.first)
|
|
|
|
);
|
2023-03-03 16:05:32 +08:00
|
|
|
return strl;
|
2023-02-09 17:16:58 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// check flag match
|
2024-11-03 19:05:27 +08:00
|
|
|
if (YYCC::EnumHelper::Has(val, item.first)) {
|
2024-08-23 17:38:45 +08:00
|
|
|
// add splittor if it not the first entry
|
2023-09-22 16:40:10 +08:00
|
|
|
if (strl.size() != 0u && splitor != nullptr) {
|
|
|
|
strl += splitor;
|
|
|
|
}
|
|
|
|
|
2024-08-23 17:38:45 +08:00
|
|
|
// add indent if possible
|
|
|
|
if (indent != nullptr) {
|
|
|
|
strl += indent;
|
|
|
|
}
|
|
|
|
|
|
|
|
// add value self.
|
|
|
|
YYCC::StringHelper::Printf(cache, u8"%s (0x%08" PRIXCKDWORD ")",
|
2023-09-22 16:40:10 +08:00
|
|
|
item.second.mName,
|
|
|
|
static_cast<LibCmo::CKDWORD>(item.first)
|
|
|
|
);
|
|
|
|
strl += cache;
|
2023-02-09 17:16:58 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-08-26 20:34:51 +08:00
|
|
|
// if nothing was gotten. set to undefined
|
2023-02-09 17:16:58 +08:00
|
|
|
if (strl.size() == 0u) {
|
2024-08-23 17:38:45 +08:00
|
|
|
YYCC::StringHelper::Printf(strl, u8"%s (0x%08" PRIXCKDWORD ")",
|
|
|
|
c_InvalidEnumName,
|
2023-09-22 16:40:10 +08:00
|
|
|
static_cast<LibCmo::CKDWORD>(val)
|
|
|
|
);
|
2023-08-26 20:34:51 +08:00
|
|
|
}
|
|
|
|
|
2023-03-03 16:05:32 +08:00
|
|
|
return strl;
|
2023-02-09 17:16:58 +08:00
|
|
|
}
|
|
|
|
|
2023-08-26 20:34:51 +08:00
|
|
|
namespace EnumDesc {
|
|
|
|
extern const GeneralReflectionArray<LibCmo::CK2::CK_FILE_WRITEMODE> CK_FILE_WRITEMODE;
|
|
|
|
extern const GeneralReflectionArray<LibCmo::CK2::CK_FO_OPTIONS> CK_FO_OPTIONS;
|
|
|
|
extern const GeneralReflectionArray<LibCmo::CK2::CK_STATECHUNK_CHUNKOPTIONS> CK_STATECHUNK_CHUNKOPTIONS;
|
|
|
|
extern const GeneralReflectionArray<LibCmo::CK2::CK_STATECHUNK_DATAVERSION> CK_STATECHUNK_DATAVERSION;
|
|
|
|
extern const GeneralReflectionArray<LibCmo::CK2::CK_STATECHUNK_CHUNKVERSION> CK_STATECHUNK_CHUNKVERSION;
|
2023-09-22 16:40:10 +08:00
|
|
|
extern const GeneralReflectionArray<LibCmo::CK2::CK_OBJECT_FLAGS> CK_OBJECT_FLAGS;
|
|
|
|
extern const GeneralReflectionArray<LibCmo::CK2::CK_3DENTITY_FLAGS> CK_3DENTITY_FLAGS;
|
|
|
|
extern const GeneralReflectionArray<LibCmo::CK2::CK_TEXTURE_SAVEOPTIONS> CK_TEXTURE_SAVEOPTIONS;
|
2023-09-22 22:31:51 +08:00
|
|
|
extern const GeneralReflectionArray<LibCmo::CK2::CK_BITMAPDATA_FLAGS> CK_BITMAPDATA_FLAGS;
|
|
|
|
|
2023-09-22 16:40:10 +08:00
|
|
|
extern const GeneralReflectionArray<LibCmo::VxMath::VX_PIXELFORMAT> VX_PIXELFORMAT;
|
|
|
|
extern const GeneralReflectionArray<LibCmo::VxMath::VXTEXTURE_BLENDMODE> VXTEXTURE_BLENDMODE;
|
|
|
|
extern const GeneralReflectionArray<LibCmo::VxMath::VXTEXTURE_FILTERMODE> VXTEXTURE_FILTERMODE;
|
|
|
|
extern const GeneralReflectionArray<LibCmo::VxMath::VXBLEND_MODE> VXBLEND_MODE;
|
|
|
|
extern const GeneralReflectionArray<LibCmo::VxMath::VXTEXTURE_ADDRESSMODE> VXTEXTURE_ADDRESSMODE;
|
|
|
|
extern const GeneralReflectionArray<LibCmo::VxMath::VXFILL_MODE> VXFILL_MODE;
|
|
|
|
extern const GeneralReflectionArray<LibCmo::VxMath::VXSHADE_MODE> VXSHADE_MODE;
|
|
|
|
extern const GeneralReflectionArray<LibCmo::VxMath::VXCMPFUNC> VXCMPFUNC;
|
|
|
|
extern const GeneralReflectionArray<LibCmo::VxMath::VX_EFFECT> VX_EFFECT;
|
|
|
|
extern const GeneralReflectionArray<LibCmo::VxMath::VX_MOVEABLE_FLAGS> VX_MOVEABLE_FLAGS;
|
|
|
|
extern const GeneralReflectionArray<LibCmo::VxMath::VXMESH_FLAGS> VXMESH_FLAGS;
|
2023-11-15 21:47:58 +08:00
|
|
|
extern const GeneralReflectionArray<LibCmo::VxMath::VXMESH_LITMODE> VXMESH_LITMODE;
|
2023-09-22 16:40:10 +08:00
|
|
|
extern const GeneralReflectionArray<LibCmo::VxMath::VXTEXTURE_WRAPMODE> VXTEXTURE_WRAPMODE;
|
2023-08-26 20:34:51 +08:00
|
|
|
}
|
2023-02-08 22:57:31 +08:00
|
|
|
|
2024-08-23 17:38:45 +08:00
|
|
|
#pragma endregion
|
|
|
|
|
2023-02-08 22:57:31 +08:00
|
|
|
}
|
|
|
|
}
|