2023-02-14 16:28:37 +08:00
#include "StructFormatter.hpp"
2024-08-23 17:38:45 +08:00
#include <YYCCommonplace.hpp>
2023-02-14 16:28:37 +08:00
#include "AccessibleValue.hpp"
2024-08-23 17:38:45 +08:00
namespace Console = YYCC :: ConsoleHelper ;
2023-03-04 00:13:03 +08:00
namespace Unvirt :: StructFormatter {
2023-02-14 16:28:37 +08:00
2023-08-27 22:14:02 +08:00
#pragma region Assist Functions
2024-08-23 17:38:45 +08:00
static std :: u8string PrintCKSTRING ( LibCmo :: CKSTRING name ) {
std :: u8string ret ;
2023-08-29 10:42:13 +08:00
if ( name == nullptr ) {
2024-08-23 17:38:45 +08:00
ret = YYCC_COLOR_LIGHT_MAGENTA ( u8 "<anonymous>" );
2023-08-27 22:14:02 +08:00
} else {
2024-08-23 17:38:45 +08:00
if ( name [ 0 ] == u8 '\0' ) {
ret = YYCC_COLOR_LIGHT_MAGENTA ( u8 "<blank>" );
2023-08-29 10:42:13 +08:00
} else {
2024-08-23 17:38:45 +08:00
ret = name ;
2023-08-29 10:42:13 +08:00
}
2023-08-27 22:14:02 +08:00
}
2024-08-23 17:38:45 +08:00
return ret ;
2023-08-27 22:14:02 +08:00
}
2024-08-23 17:38:45 +08:00
static std :: u8string PrintPointer ( const void * ptr ) {
std :: u8string ret ;
2023-08-27 22:14:02 +08:00
if ( ptr == nullptr ) {
2024-08-23 17:38:45 +08:00
ret = YYCC_COLOR_LIGHT_CYAN ( u8 "<null>" );
2023-08-27 22:14:02 +08:00
} else {
2024-08-23 17:38:45 +08:00
YYCC :: StringHelper :: Printf ( ret , u8 "<0x%" PRI_XPTR_LEFT_PADDING PRIxPTR ">" , reinterpret_cast < uintptr_t > ( ptr ));
2023-08-27 22:14:02 +08:00
}
2024-08-23 17:38:45 +08:00
return ret ;
2023-08-27 22:14:02 +08:00
}
2024-08-23 17:38:45 +08:00
static std :: u8string PrintCKGUID ( const LibCmo :: CK2 :: CKGUID & guid ) {
return YYCC :: StringHelper :: Printf ( u8 "<0x%08" PRIxCKDWORD ", 0x%08" PRIxCKDWORD ">" , guid . d1 , guid . d2 );
2023-08-27 22:14:02 +08:00
}
2024-08-23 17:38:45 +08:00
static std :: u8string PrintBool ( bool v ) {
return ( v ? u8 "true" : u8 "false" );
2023-09-22 16:40:10 +08:00
}
2024-08-23 17:38:45 +08:00
static std :: u8string PrintColorfulBool ( bool v ) {
return ( v ? YYCC_COLOR_LIGHT_GREEN ( u8 "Yes" ) : YYCC_COLOR_LIGHT_RED ( u8 "No" ));
2023-10-28 18:17:53 +08:00
}
2024-08-23 17:38:45 +08:00
static std :: u8string PrintColor ( LibCmo :: CKDWORD argb ) {
2023-09-22 16:40:10 +08:00
LibCmo :: CKDWORD a = ( argb & 0xFF000000 ) >> 24 ,
r = ( argb & 0x00FF0000 ) >> 16 ,
g = ( argb & 0x0000FF00 ) >> 8 ,
b = ( argb & 0x000000FF );
2024-08-23 17:38:45 +08:00
LibCmo :: CKFLOAT fa = static_cast < LibCmo :: CKFLOAT > ( a ) / 255.0f ;
return YYCC :: StringHelper :: Printf (
u8 "A:%" PRIuCKDWORD " (%.4" PRIfCKFLOAT ") "
"RGB(%" PRIuCKDWORD ", %" PRIuCKDWORD ", %" PRIuCKDWORD ") "
"RGB#%02" PRIxCKDWORD "%02" PRIxCKDWORD "%02" PRIxCKDWORD " "
"RGBA#%02" PRIxCKDWORD "%02" PRIxCKDWORD "%02" PRIxCKDWORD "%02" PRIxCKDWORD ,
a , fa ,
2023-10-28 18:17:53 +08:00
r , g , b ,
r , g , b ,
2023-09-22 16:40:10 +08:00
r , g , b , a
);
}
2024-08-23 17:38:45 +08:00
static std :: u8string PrintColor ( const LibCmo :: VxMath :: VxColor & col ) {
return PrintColor ( col . ToARGB ());
2023-09-22 22:31:51 +08:00
}
2023-08-29 10:42:13 +08:00
2023-08-27 22:14:02 +08:00
template < class _Ty >
static void GeneralPrintList (
const std :: vector < _Ty >& data , size_t page , size_t pageitems ,
2023-08-29 10:42:13 +08:00
std :: function < void () > printHdrFct , std :: function < void ( size_t , const _Ty & ) > printEntryFct ) {
2023-08-27 22:14:02 +08:00
2023-10-28 18:17:53 +08:00
// check page overflow
if ( page * pageitems >= data . size ()) {
2024-08-23 17:38:45 +08:00
Console :: WriteLine ( YYCC_COLOR_LIGHT_RED ( u8 "Page out of range." ));
2023-10-28 18:17:53 +08:00
return ;
}
// calc page data
2023-08-27 22:14:02 +08:00
size_t fulllen = data . size (),
startpos = page * pageitems ,
2023-10-28 18:17:53 +08:00
fullpage = ( fulllen + ( pageitems - 1 )) / pageitems ; // to solve `fulllen / pageitems` empty page issue. like CKStateChunk::GetCeilDwordSize function (+3 /4 to get DWORD size).
2023-08-27 22:14:02 +08:00
// print header
printHdrFct ();
// print body
for ( size_t counter = startpos ; counter < fulllen && ( counter - startpos ) < pageitems ; ++ counter ) {
printEntryFct ( counter , data [ counter ]);
}
2024-08-23 17:38:45 +08:00
Console :: FormatLine ( u8 "Page %" PRIuSIZET " of %" PRIuSIZET , page + 1 , fullpage );
2023-08-27 22:14:02 +08:00
}
#pragma endregion
2023-02-14 16:28:37 +08:00
2023-09-19 10:53:48 +08:00
#pragma region Object Printer
2023-09-22 16:40:10 +08:00
2023-09-19 10:53:48 +08:00
static void PrintCKObjectDetail ( LibCmo :: CK2 :: ObjImpls :: CKObject * obj ) {
2024-08-23 17:38:45 +08:00
Console :: WriteLine ( YYCC_COLOR_LIGHT_YELLOW ( u8 "CKObject" ));
2023-09-20 20:44:03 +08:00
// print name
2024-08-23 17:38:45 +08:00
Console :: FormatLine ( u8 "Name: %s" , PrintCKSTRING ( obj -> GetName ()). c_str ());
2023-09-20 20:44:03 +08:00
// print id
2024-08-23 17:38:45 +08:00
Console :: FormatLine ( u8 "CK ID: %" PRIuCKID , obj -> GetID ());
2023-09-20 20:44:03 +08:00
// print class id
2024-08-23 17:38:45 +08:00
Console :: FormatLine ( u8 "Class ID: %" PRIiCLASSID " (%s)" , obj -> GetClassID (), AccessibleValue :: GetClassIdHierarchy ( obj -> GetClassID ()). c_str ());
2023-09-22 22:31:51 +08:00
// print flags
2024-08-23 17:38:45 +08:00
Console :: WriteLine ( u8 "Flags:" );
Console :: WriteLine ( AccessibleValue :: GetFlagEnumName ( obj -> GetObjectFlags (), AccessibleValue :: EnumDesc :: CK_OBJECT_FLAGS , u8 " \n " , u8 " \t " ). c_str ());
2023-09-19 10:53:48 +08:00
}
2023-09-22 16:40:10 +08:00
2023-09-19 10:53:48 +08:00
static void PrintCKSceneObjectDetail ( LibCmo :: CK2 :: ObjImpls :: CKSceneObject * obj ) {
PrintCKObjectDetail ( obj );
2024-08-23 17:38:45 +08:00
Console :: WriteLine ( YYCC_COLOR_LIGHT_YELLOW ( u8 "CKSceneObject" ));
Console :: WriteLine ( YYCC_COLOR_LIGHT_RED ( u8 "No Data" ));
2023-09-19 10:53:48 +08:00
}
static void PrintCKBeObjectDetail ( LibCmo :: CK2 :: ObjImpls :: CKBeObject * obj ) {
PrintCKSceneObjectDetail ( obj );
2024-08-23 17:38:45 +08:00
Console :: WriteLine ( YYCC_COLOR_LIGHT_YELLOW ( u8 "CKBeObject" ));
Console :: WriteLine ( YYCC_COLOR_LIGHT_RED ( u8 "No Data" ));
2023-09-19 10:53:48 +08:00
}
2023-09-19 11:59:23 +08:00
static void PrintCKGroupDetail ( LibCmo :: CK2 :: ObjImpls :: CKGroup * obj ) {
PrintCKBeObjectDetail ( obj );
2024-08-23 17:38:45 +08:00
Console :: WriteLine ( YYCC_COLOR_LIGHT_YELLOW ( u8 "CKGroup" ));
2023-09-22 16:40:10 +08:00
2023-09-20 20:44:03 +08:00
LibCmo :: CKDWORD count = obj -> GetObjectCount ();
2024-08-23 17:38:45 +08:00
Console :: FormatLine ( u8 "Group Object Count: %" PRIuCKDWORD , count );
Console :: WriteLine ( u8 "CKID \t Type \t Object \t Name" );
2023-09-20 20:44:03 +08:00
for ( LibCmo :: CKDWORD i = 0 ; i < count ; ++ i ) {
LibCmo :: CK2 :: ObjImpls :: CKBeObject * beobj = obj -> GetObject ( i );
2023-09-22 16:40:10 +08:00
2024-08-23 17:38:45 +08:00
Console :: FormatLine ( u8 "%" PRIuCKID " \t %s \t %s \t %s" ,
beobj -> GetID (),
AccessibleValue :: GetClassIdName ( beobj -> GetClassID ()). c_str (),
PrintPointer ( beobj ). c_str (),
2024-08-24 21:27:23 +08:00
( beobj != nullptr ? PrintCKSTRING ( beobj -> GetName ()). c_str () : u8 "" )
2024-08-23 17:38:45 +08:00
);
2023-09-20 20:44:03 +08:00
}
2023-09-19 11:59:23 +08:00
}
2023-09-22 16:40:10 +08:00
2023-09-19 11:59:23 +08:00
static void PrintCKRenderObjectDetail ( LibCmo :: CK2 :: ObjImpls :: CKRenderObject * obj ) {
PrintCKBeObjectDetail ( obj );
2024-08-23 17:38:45 +08:00
Console :: WriteLine ( YYCC_COLOR_LIGHT_YELLOW ( u8 "CKRenderObject" ));
Console :: WriteLine ( YYCC_COLOR_LIGHT_RED ( u8 "No Data" ));
2023-09-19 11:59:23 +08:00
}
2023-09-22 16:40:10 +08:00
2023-09-19 11:59:23 +08:00
static void PrintCK3dEntityDetail ( LibCmo :: CK2 :: ObjImpls :: CK3dEntity * obj ) {
PrintCKRenderObjectDetail ( obj );
2024-08-23 17:38:45 +08:00
Console :: WriteLine ( YYCC_COLOR_LIGHT_YELLOW ( u8 "CK3dEntity" ));
2023-09-22 16:40:10 +08:00
2024-08-23 17:38:45 +08:00
Console :: WriteLine ( u8 "== World Matrix ==" );
2023-09-22 16:40:10 +08:00
auto mat = obj -> GetWorldMatrix ();
for ( LibCmo :: CKDWORD i = 0 ; i < 4 ; ++ i ) {
2024-08-23 17:38:45 +08:00
Console :: FormatLine ( u8 "%+" PRIeCKFLOAT " \t %+" PRIeCKFLOAT " \t %+" PRIeCKFLOAT " \t %+" PRIeCKFLOAT ,
2023-09-22 16:40:10 +08:00
mat [ i ]. x , mat [ i ]. y , mat [ i ]. z , mat [ i ]. w
);
}
2024-08-23 17:38:45 +08:00
Console :: WriteLine ( u8 "== Flags ==" );
Console :: WriteLine ( u8 "3dEntity Flags:" );
Console :: WriteLine ( AccessibleValue :: GetFlagEnumName ( obj -> GetEntityFlags (), AccessibleValue :: EnumDesc :: CK_3DENTITY_FLAGS , u8 " \n " , u8 " \t " ). c_str ());
Console :: WriteLine ( u8 "Moveable Flags:" );
Console :: WriteLine ( AccessibleValue :: GetFlagEnumName ( obj -> GetMoveableFlags (), AccessibleValue :: EnumDesc :: VX_MOVEABLE_FLAGS , u8 " \n " , u8 " \t " ). c_str ());
2023-09-22 16:40:10 +08:00
2024-08-23 17:38:45 +08:00
Console :: WriteLine ( u8 "== Meshs ==" );
Console :: WriteLine ( u8 "Index \t Address \t Name" );
2023-09-22 16:40:10 +08:00
// print current mesh
2024-08-23 17:38:45 +08:00
{
auto curmesh = obj -> GetCurrentMesh ();
2024-12-25 13:58:39 +08:00
Console :: FormatLine ( u8 "-> \t %s \t %s" ,
2024-08-24 21:27:23 +08:00
PrintPointer ( curmesh ). c_str (),
( curmesh != nullptr ? PrintCKSTRING ( curmesh -> GetName ()). c_str () : u8 "" )
2024-08-23 17:38:45 +08:00
);
}
// print other meshes
2023-09-22 16:40:10 +08:00
for ( LibCmo :: CKDWORD i = 0 ; i < obj -> GetPotentialMeshCount (); ++ i ) {
auto thismesh = obj -> GetPotentialMesh ( i );
2024-08-23 17:38:45 +08:00
Console :: FormatLine ( u8 "#%" PRIuCKDWORD " \t %s \t %s" ,
i ,
PrintPointer ( thismesh ). c_str (),
2024-08-24 21:27:23 +08:00
( thismesh != nullptr ? PrintCKSTRING ( thismesh -> GetName ()). c_str () : u8 "" )
2024-08-23 17:38:45 +08:00
);
2023-09-22 16:40:10 +08:00
}
2023-09-19 11:59:23 +08:00
}
2024-12-25 13:58:39 +08:00
static void PrintCKLightDetail ( LibCmo :: CK2 :: ObjImpls :: CKLight * obj ) {
PrintCK3dEntityDetail ( obj );
Console :: WriteLine ( YYCC_COLOR_LIGHT_YELLOW ( u8 "CKLight" ));
Console :: WriteLine ( u8 "== Basics ==" );
Console :: FormatLine ( u8 "Type: %s" , AccessibleValue :: GetEnumName ( obj -> GetType (), AccessibleValue :: EnumDesc :: VXLIGHT_TYPE ). c_str ());
Console :: FormatLine ( u8 "Color: %s" , PrintColor ( obj -> GetColor ()). c_str ());
Console :: FormatLine ( u8 "Light Power: %.2" PRIfCKFLOAT , obj -> GetLightPower ());
Console :: WriteLine ( u8 "== Switches ==" );
Console :: FormatLine ( u8 "Activity: %s" , PrintBool ( obj -> GetActivity ()). c_str ());
Console :: FormatLine ( u8 "Specular Flag: %s" , PrintBool ( obj -> GetSpecularFlag ()). c_str ());
Console :: WriteLine ( u8 "== Attenuation ==" );
Console :: FormatLine ( u8 "Constant Attenuation: %.2" PRIfCKFLOAT , obj -> GetConstantAttenuation ());
Console :: FormatLine ( u8 "Linear Attenuation: %.2" PRIfCKFLOAT , obj -> GetLinearAttenuation ());
Console :: FormatLine ( u8 "Quadratic Attenuation: %.2" PRIfCKFLOAT , obj -> GetQuadraticAttenuation ());
Console :: WriteLine ( u8 "== Spot Cone ==" );
Console :: FormatLine ( u8 "Range: %.2" PRIfCKFLOAT , obj -> GetRange ());
Console :: FormatLine ( u8 "Hot Spot: %.2" PRIfCKFLOAT , obj -> GetHotSpot ());
Console :: FormatLine ( u8 "Falloff: %.2" PRIfCKFLOAT , obj -> GetFalloff ());
Console :: FormatLine ( u8 "Falloff Shape: %.2" PRIfCKFLOAT , obj -> GetFalloffShape ());
Console :: WriteLine ( u8 "== Target ==" );
auto thistarget = obj -> GetTarget ();
Console :: FormatLine ( u8 "Target Address: %s" , PrintPointer ( thistarget ). c_str ());
if ( thistarget != nullptr )
Console :: FormatLine ( u8 "Target Name: %s" , PrintCKSTRING ( thistarget -> GetName ()). c_str ());
}
static void PrintCKTargetLightDetail ( LibCmo :: CK2 :: ObjImpls :: CKTargetLight * obj ) {
PrintCKLightDetail ( obj );
Console :: WriteLine ( YYCC_COLOR_LIGHT_YELLOW ( u8 "CKTargetLight" ));
Console :: WriteLine ( YYCC_COLOR_LIGHT_RED ( u8 "No Data" ));
}
static void PrintCKCameraDetail ( LibCmo :: CK2 :: ObjImpls :: CKCamera * obj ) {
PrintCK3dEntityDetail ( obj );
Console :: WriteLine ( YYCC_COLOR_LIGHT_YELLOW ( u8 "CKCamera" ));
Console :: WriteLine ( u8 "== Basics ==" );
Console :: FormatLine ( u8 "Projection Type: %s" , AccessibleValue :: GetEnumName ( obj -> GetProjectionType (), AccessibleValue :: EnumDesc :: CK_CAMERA_PROJECTION ). c_str ());
Console :: FormatLine ( u8 "Orthographic Zoom: %.2" PRIfCKFLOAT , obj -> GetOrthographicZoom ());
Console :: FormatLine ( u8 "Front Plane: %.2" PRIfCKFLOAT , obj -> GetFrontPlane ());
Console :: FormatLine ( u8 "Back Plane: %.2" PRIfCKFLOAT , obj -> GetBackPlane ());
Console :: FormatLine ( u8 "Fov: %.2" PRIfCKFLOAT , obj -> GetFov ());
LibCmo :: CKDWORD width , height ;
obj -> GetAspectRatio ( width , height );
Console :: FormatLine ( u8 "Aspect Ratio: %" PRIuCKDWORD " : %" PRIuCKDWORD , width , height );
Console :: WriteLine ( u8 "== Target ==" );
auto thistarget = obj -> GetTarget ();
Console :: FormatLine ( u8 "Target Address: %s" , PrintPointer ( thistarget ). c_str ());
if ( thistarget != nullptr )
Console :: FormatLine ( u8 "Target Name: %s" , PrintCKSTRING ( thistarget -> GetName ()). c_str ());
}
static void PrintCKTargetCameraDetail ( LibCmo :: CK2 :: ObjImpls :: CKTargetCamera * obj ) {
PrintCKCameraDetail ( obj );
Console :: WriteLine ( YYCC_COLOR_LIGHT_YELLOW ( u8 "CKTargetCamera" ));
Console :: WriteLine ( YYCC_COLOR_LIGHT_RED ( u8 "No Data" ));
}
2023-09-22 16:40:10 +08:00
2023-09-19 11:59:23 +08:00
static void PrintCK3dObjectDetail ( LibCmo :: CK2 :: ObjImpls :: CK3dObject * obj ) {
PrintCK3dEntityDetail ( obj );
2024-08-23 17:38:45 +08:00
Console :: WriteLine ( YYCC_COLOR_LIGHT_YELLOW ( u8 "CK3dObject" ));
Console :: WriteLine ( YYCC_COLOR_LIGHT_RED ( u8 "No Data" ));
2023-09-19 11:59:23 +08:00
}
2023-09-22 16:40:10 +08:00
2023-09-19 11:59:23 +08:00
static void PrintCKTextureDetail ( LibCmo :: CK2 :: ObjImpls :: CKTexture * obj ) {
PrintCKBeObjectDetail ( obj );
2024-08-23 17:38:45 +08:00
Console :: WriteLine ( YYCC_COLOR_LIGHT_YELLOW ( u8 "CKTexture" ));
2023-09-22 22:31:51 +08:00
// texture
2024-08-23 17:38:45 +08:00
Console :: WriteLine ( u8 "== Texture ==" );
2023-09-22 22:31:51 +08:00
LibCmo :: CK2 :: CKBitmapData & bd = obj -> GetUnderlyingData ();
LibCmo :: CKDWORD slot_count = bd . GetSlotCount ();
2024-08-23 17:38:45 +08:00
Console :: FormatLine ( u8 "Slot Count: %" PRIuCKDWORD , slot_count );
Console :: FormatLine ( u8 "Current Slot: %" PRIuCKDWORD , bd . GetCurrentSlot ());
2023-09-22 22:31:51 +08:00
2024-08-23 17:38:45 +08:00
Console :: WriteLine ( u8 "Index \t Width \t Height \t Image Addr \t Image Size \t Filename" );
2023-09-22 22:31:51 +08:00
for ( LibCmo :: CKDWORD i = 0 ; i < slot_count ; ++ i ) {
auto desc = bd . GetImageDesc ( i );
2024-08-27 11:25:53 +08:00
Console :: FormatLine ( u8 "#%" PRIuCKDWORD " \t %" PRIuCKDWORD " \t %" PRIuCKDWORD " \t %s \t 0x%" PRIxCKDWORD " bytes \t %s" ,
2024-08-23 17:38:45 +08:00
i ,
desc -> GetWidth (),
desc -> GetHeight (),
PrintPointer ( desc -> GetImage ()). c_str (),
desc -> GetImageSize (),
PrintCKSTRING ( bd . GetSlotFileName ( i )). c_str ()
);
2023-09-22 22:31:51 +08:00
}
// other data
2024-08-23 17:38:45 +08:00
Console :: WriteLine ( u8 "== Misc ==" );
Console :: FormatLine ( u8 "Video Format: %s" , AccessibleValue :: GetEnumName ( obj -> GetVideoFormat (), AccessibleValue :: EnumDesc :: VX_PIXELFORMAT ). c_str ());
Console :: FormatLine ( u8 "Save Option: %s" , AccessibleValue :: GetEnumName ( bd . GetSaveOptions (), AccessibleValue :: EnumDesc :: CK_TEXTURE_SAVEOPTIONS ). c_str ());
Console :: FormatLine ( u8 "Pick Threshold: %" PRIuCKDWORD , bd . GetPickThreshold ());
Console :: FormatLine ( u8 "Transparent Color: %s" , PrintColor ( bd . GetTransparentColor ()). c_str ());
2023-10-28 18:17:53 +08:00
2024-08-23 17:38:45 +08:00
Console :: WriteLine ( u8 "Bitmap Flags:" );
Console :: WriteLine ( AccessibleValue :: GetFlagEnumName ( bd . GetBitmapFlags (), AccessibleValue :: EnumDesc :: CK_BITMAPDATA_FLAGS , u8 " \n " , u8 " \t " ). c_str ());
2023-09-19 11:59:23 +08:00
}
2023-09-22 16:40:10 +08:00
2023-09-19 11:59:23 +08:00
static void PrintCKMaterialDetail ( LibCmo :: CK2 :: ObjImpls :: CKMaterial * obj ) {
PrintCKBeObjectDetail ( obj );
2024-08-23 17:38:45 +08:00
Console :: WriteLine ( YYCC_COLOR_LIGHT_YELLOW ( u8 "CKMaterial" ));
2023-10-28 18:17:53 +08:00
2023-09-22 16:40:10 +08:00
// color
2024-08-23 17:38:45 +08:00
Console :: WriteLine ( u8 "== Color ==" );
2023-09-22 16:40:10 +08:00
2024-08-24 21:27:23 +08:00
Console :: FormatLine ( u8 "Diffuse: %s" , PrintColor ( obj -> GetDiffuse ()). c_str ());
Console :: FormatLine ( u8 "Ambient: %s" , PrintColor ( obj -> GetAmbient ()). c_str ());
Console :: FormatLine ( u8 "Specular: %s" , PrintColor ( obj -> GetSpecular ()). c_str ());
Console :: FormatLine ( u8 "Emissive: %s" , PrintColor ( obj -> GetEmissive ()). c_str ());
2023-09-22 16:40:10 +08:00
2024-08-23 17:38:45 +08:00
Console :: FormatLine ( u8 "Specular Power: %.2" PRIfCKFLOAT , obj -> GetSpecularPower ());
2023-09-22 16:40:10 +08:00
// basic data
2024-08-23 17:38:45 +08:00
Console :: WriteLine ( u8 "== Basic ==" );
2024-08-24 21:27:23 +08:00
Console :: FormatLine ( u8 "Both Sided: %s" , PrintBool ( obj -> GetTwoSidedEnabled ()). c_str ());
2024-08-23 17:38:45 +08:00
Console :: FormatLine ( u8 "Fill Mode: %s" , AccessibleValue :: GetEnumName ( obj -> GetFillMode (), AccessibleValue :: EnumDesc :: VXFILL_MODE ). c_str ());
Console :: FormatLine ( u8 "Shade Mode: %s" , AccessibleValue :: GetEnumName ( obj -> GetShadeMode (), AccessibleValue :: EnumDesc :: VXSHADE_MODE ). c_str ());
2023-09-22 16:40:10 +08:00
// textures
2024-08-23 17:38:45 +08:00
Console :: WriteLine ( u8 "== Texture ==" );
Console :: WriteLine ( u8 "Textures:" );
Console :: WriteLine ( u8 "Index \t Address \t Name" );
2023-09-22 16:40:10 +08:00
for ( LibCmo :: CKDWORD i = 0 ; i < 4 ; ++ i ) {
auto tex = obj -> GetTexture ( i );
2024-08-24 21:27:23 +08:00
Console :: FormatLine ( u8 "#%" PRIuCKDWORD " \t %s \t %s" ,
i ,
PrintPointer ( tex ). c_str (),
( tex != nullptr ? PrintCKSTRING ( tex -> GetName ()). c_str () : u8 "" )
);
2023-09-22 16:40:10 +08:00
}
2024-08-23 17:38:45 +08:00
Console :: FormatLine ( u8 "Texture Blend: %s" , AccessibleValue :: GetEnumName ( obj -> GetTextureBlendMode (), AccessibleValue :: EnumDesc :: VXTEXTURE_BLENDMODE ). c_str ());
Console :: FormatLine ( u8 "Filter Min: %s" , AccessibleValue :: GetEnumName ( obj -> GetTextureMinMode (), AccessibleValue :: EnumDesc :: VXTEXTURE_FILTERMODE ). c_str ());
Console :: FormatLine ( u8 "Filter Mag: %s" , AccessibleValue :: GetEnumName ( obj -> GetTextureMagMode (), AccessibleValue :: EnumDesc :: VXTEXTURE_FILTERMODE ). c_str ());
Console :: FormatLine ( u8 "Address Mode: %s" , AccessibleValue :: GetEnumName ( obj -> GetTextureAddressMode (), AccessibleValue :: EnumDesc :: VXTEXTURE_ADDRESSMODE ). c_str ());
2024-08-24 21:27:23 +08:00
Console :: FormatLine ( u8 "Perspective Correct: %s" , PrintBool ( obj -> GetPerspectiveCorrectionEnabled ()). c_str ());
2023-09-22 16:40:10 +08:00
// alpha test
2024-08-23 17:38:45 +08:00
Console :: WriteLine ( u8 "== Alpha Test ==" );
2024-08-24 21:27:23 +08:00
Console :: FormatLine ( u8 "Enabled: %s" , PrintBool ( obj -> GetAlphaTestEnabled ()). c_str ());
2024-08-23 17:38:45 +08:00
Console :: FormatLine ( u8 "Alpha Function: %s" , AccessibleValue :: GetEnumName ( obj -> GetAlphaFunc (), AccessibleValue :: EnumDesc :: VXCMPFUNC ). c_str ());
Console :: FormatLine ( u8 "Alpha Ref Value: %" PRIuCKBYTE , obj -> GetAlphaRef ());
2023-10-28 18:17:53 +08:00
2023-09-22 16:40:10 +08:00
// alpha blend
2024-08-23 17:38:45 +08:00
Console :: WriteLine ( u8 "== Alpha Blend ==" );
2024-08-24 21:27:23 +08:00
Console :: FormatLine ( u8 "Enabled: %s" , PrintBool ( obj -> GetAlphaBlendEnabled ()). c_str ());
2024-08-23 17:38:45 +08:00
Console :: FormatLine ( u8 "Source Blend: %s" , AccessibleValue :: GetEnumName ( obj -> GetSourceBlend (), AccessibleValue :: EnumDesc :: VXBLEND_MODE ). c_str ());
Console :: FormatLine ( u8 "Destination Blend: %s" , AccessibleValue :: GetEnumName ( obj -> GetDestBlend (), AccessibleValue :: EnumDesc :: VXBLEND_MODE ). c_str ());
2023-10-28 18:17:53 +08:00
2023-09-22 16:40:10 +08:00
// z buffer
2024-08-23 17:38:45 +08:00
Console :: WriteLine ( u8 "== Z-Buffer Write ==" );
2024-08-24 21:27:23 +08:00
Console :: FormatLine ( u8 "Enabled: %s" , PrintBool ( obj -> GetZWriteEnabled ()). c_str ());
2024-08-23 17:38:45 +08:00
Console :: FormatLine ( u8 "Z Compare Function: %s" , AccessibleValue :: GetEnumName ( obj -> GetZFunc (), AccessibleValue :: EnumDesc :: VXCMPFUNC ). c_str ());
2023-10-28 18:17:53 +08:00
2023-09-22 16:40:10 +08:00
// effect
2024-08-23 17:38:45 +08:00
Console :: WriteLine ( u8 "== Effect ==" );
Console :: FormatLine ( u8 "Effect: %s" , AccessibleValue :: GetEnumName ( obj -> GetEffect (), AccessibleValue :: EnumDesc :: VX_EFFECT ). c_str ());
2023-09-22 16:40:10 +08:00
2023-09-19 11:59:23 +08:00
}
2023-09-22 16:40:10 +08:00
2023-09-19 10:53:48 +08:00
static void PrintCKMeshDetail ( LibCmo :: CK2 :: ObjImpls :: CKMesh * obj ) {
PrintCKBeObjectDetail ( obj );
2024-08-23 17:38:45 +08:00
Console :: WriteLine ( YYCC_COLOR_LIGHT_YELLOW ( u8 "CKMesh" ));
2023-10-28 18:17:53 +08:00
2024-08-23 17:38:45 +08:00
Console :: WriteLine ( u8 "== Flags ==" );
Console :: WriteLine ( u8 "Mesh Flags:" );
2024-08-24 21:27:23 +08:00
Console :: WriteLine ( AccessibleValue :: GetFlagEnumName ( obj -> GetMeshFlags (), AccessibleValue :: EnumDesc :: VXMESH_FLAGS , u8 " \n " , u8 " \t " ). c_str ());
2024-08-23 17:38:45 +08:00
Console :: FormatLine ( u8 "Lit Mode: %s" , AccessibleValue :: GetEnumName ( obj -> GetLitMode (), AccessibleValue :: EnumDesc :: VXMESH_LITMODE ). c_str ());
Console :: FormatLine ( u8 "Wrap Mode: %s" , AccessibleValue :: GetEnumName ( obj -> GetWrapMode (), AccessibleValue :: EnumDesc :: VXTEXTURE_WRAPMODE ). c_str ());
2023-10-28 18:17:53 +08:00
2023-09-22 16:40:10 +08:00
// vertex data
2024-08-23 17:38:45 +08:00
Console :: WriteLine ( u8 "== Vertex ==" );
Console :: FormatLine ( u8 "Vertex Count: %" PRIuCKDWORD , obj -> GetVertexCount ());
Console :: WriteLine ( u8 "Address \t Size \t Type" );
2023-09-19 10:53:48 +08:00
2024-08-24 21:27:23 +08:00
Console :: FormatLine ( u8 "%s \t 0x%" PRIxCKDWORD " bytes \t Positions" ,
PrintPointer ( obj -> GetVertexPositions ()). c_str (),
obj -> GetVertexCount () * CKSizeof ( LibCmo :: VxMath :: VxVector3 )
);
Console :: FormatLine ( u8 "%s \t 0x%" PRIxCKDWORD " bytes \t Normals" ,
PrintPointer ( obj -> GetVertexNormals ()). c_str (),
obj -> GetVertexCount () * CKSizeof ( LibCmo :: VxMath :: VxVector3 )
);
Console :: FormatLine ( u8 "%s \t 0x%" PRIxCKDWORD " bytes \t UVs" ,
PrintPointer ( obj -> GetVertexUVs ()). c_str (),
obj -> GetVertexCount () * CKSizeof ( LibCmo :: VxMath :: VxVector2 )
);
Console :: FormatLine ( u8 "%s \t 0x%" PRIxCKDWORD " bytes \t Colors" ,
PrintPointer ( obj -> GetVertexColors ()). c_str (),
obj -> GetVertexCount () * CKSizeof ( LibCmo :: CKDWORD )
);
Console :: FormatLine ( u8 "%s \t 0x%" PRIxCKDWORD " bytes \t SpecularColors" ,
PrintPointer ( obj -> GetVertexSpecularColors ()). c_str (),
obj -> GetVertexCount () * CKSizeof ( LibCmo :: CKDWORD )
);
2023-10-28 18:17:53 +08:00
2023-09-22 16:40:10 +08:00
// face data
2024-08-23 17:38:45 +08:00
Console :: WriteLine ( u8 "== Face ==" );
Console :: FormatLine ( u8 "Face Count: %" PRIuCKDWORD , obj -> GetFaceCount ());
Console :: WriteLine ( u8 "Address \t Size \t Type" );
2023-09-22 16:40:10 +08:00
2024-08-24 21:27:23 +08:00
Console :: FormatLine ( u8 "%s \t 0x%" PRIxCKDWORD " bytes \t Indices" ,
PrintPointer ( obj -> GetFaceIndices ()). c_str (),
obj -> GetFaceCount () * 3 * CKSizeof ( LibCmo :: CKWORD )
);
Console :: FormatLine ( u8 "%s \t 0x%" PRIxCKDWORD " bytes \t MaterialSlotIndexs" ,
PrintPointer ( obj -> GetFaceMaterialSlotIndexs ()). c_str (),
obj -> GetFaceCount () * CKSizeof ( LibCmo :: CKWORD )
);
2023-09-19 10:53:48 +08:00
2023-09-26 20:51:16 +08:00
// mtl slot data
2024-08-23 17:38:45 +08:00
Console :: WriteLine ( u8 "== Material Slot ==" );
2023-09-26 20:51:16 +08:00
LibCmo :: CKDWORD slotcount = obj -> GetMaterialSlotCount ();
LibCmo :: CK2 :: ObjImpls :: CKMaterial ** pMtlSlots = obj -> GetMaterialSlots ();
2024-08-23 17:38:45 +08:00
Console :: FormatLine ( u8 "Material Slot Count: %" PRIuCKDWORD , slotcount );
Console :: WriteLine ( u8 "Index \t Address \t Name" );
2023-09-26 20:51:16 +08:00
for ( LibCmo :: CKDWORD i = 0 ; i < slotcount ; ++ i ) {
LibCmo :: CK2 :: ObjImpls :: CKMaterial * mtl = pMtlSlots [ i ];
2024-08-24 21:27:23 +08:00
Console :: FormatLine ( u8 "#%" PRIuCKDWORD " \t %s \t %s" ,
i ,
PrintPointer ( mtl ). c_str (),
( mtl != nullptr ? PrintCKSTRING ( mtl -> GetName ()). c_str () : u8 "" )
);
2023-09-26 20:51:16 +08:00
}
2023-09-19 10:53:48 +08:00
}
#pragma endregion
2023-03-04 00:13:03 +08:00
void PrintCKFileInfo ( const LibCmo :: CK2 :: CKFileInfo & fileinfo ) {
2023-02-14 16:28:37 +08:00
2024-08-23 17:38:45 +08:00
Console :: WriteLine ( YYCC_COLOR_LIGHT_YELLOW ( u8 "CKFileInfo" ));
Console :: FormatLine ( u8 "FileVersion: %" PRIuCKDWORD , fileinfo . FileVersion );
LibCmo :: CKDWORD ck_series [ 3 ] {
2023-03-04 00:13:03 +08:00
( fileinfo . CKVersion >> 24 ) & 0xFF ,
( fileinfo . CKVersion >> 16 ) & 0xFF ,
( fileinfo . CKVersion >> 0 ) & 0xFFFF
2024-08-23 17:38:45 +08:00
};
Console :: FormatLine ( u8 "CKVersion: %02" PRIxCKDWORD "/%02" PRIxCKDWORD "/%04" PRIxCKDWORD ,
ck_series [ 0 ], ck_series [ 1 ], ck_series [ 2 ]
2023-03-04 00:13:03 +08:00
);
2023-09-17 10:38:46 +08:00
LibCmo :: CKDWORD product_series [ 4 ] {
2023-03-04 00:13:03 +08:00
( fileinfo . ProductBuild >> 24 ) & 0xFF ,
( fileinfo . ProductBuild >> 16 ) & 0xFF ,
( fileinfo . ProductBuild >> 8 ) & 0xFF ,
( fileinfo . ProductBuild >> 0 ) & 0xFF ,
};
2024-08-23 17:38:45 +08:00
Console :: FormatLine ( u8 "Product (Version / Build): %" PRIuCKDWORD " / %" PRIuCKDWORD ".%" PRIuCKDWORD ".%" PRIuCKDWORD ".%" PRIuCKDWORD ,
2023-03-04 00:13:03 +08:00
fileinfo . ProductVersion , product_series [ 0 ], product_series [ 1 ], product_series [ 2 ], product_series [ 3 ]
);
2023-02-14 16:28:37 +08:00
2024-08-23 17:38:45 +08:00
Console :: FormatLine ( u8 "Save Flags: %s" ,
AccessibleValue :: GetFlagEnumName ( fileinfo . FileWriteMode , AccessibleValue :: EnumDesc :: CK_FILE_WRITEMODE , u8 ", " ). c_str ()
2023-03-04 00:13:03 +08:00
);
2023-02-14 16:28:37 +08:00
2024-08-23 17:38:45 +08:00
Console :: FormatLine ( u8 "File Size: %s" , AccessibleValue :: GetReadableFileSize ( fileinfo . FileSize ). c_str ());
Console :: FormatLine ( u8 "Crc: 0x%" PRIxCKDWORD , fileinfo . Crc );
Console :: WriteLine ( u8 "" );
Console :: FormatLine ( u8 "Hdr1 (Pack / UnPack): %s / %s" ,
AccessibleValue :: GetReadableFileSize ( fileinfo . Hdr1PackSize ). c_str (),
AccessibleValue :: GetReadableFileSize ( fileinfo . Hdr1UnPackSize ). c_str ()
);
Console :: FormatLine ( u8 "Data (Pack / UnPack): %s / %s" ,
AccessibleValue :: GetReadableFileSize ( fileinfo . DataPackSize ). c_str (),
AccessibleValue :: GetReadableFileSize ( fileinfo . DataUnPackSize ). c_str ()
);
Console :: WriteLine ( u8 "" );
Console :: FormatLine ( u8 "Manager Count: %" PRIuCKDWORD , fileinfo . ManagerCount );
Console :: FormatLine ( u8 "Object Count: %" PRIuCKDWORD , fileinfo . ObjectCount );
Console :: FormatLine ( u8 "Max ID Saved: %" PRIuCKID , fileinfo . MaxIDSaved );
2023-02-14 16:28:37 +08:00
}
2023-03-04 00:13:03 +08:00
2023-10-28 18:17:53 +08:00
#pragma region Object List Printer
static void PrintObjectListHeader ( bool full_detail ) {
if ( full_detail ) {
2024-08-23 17:38:45 +08:00
Console :: WriteLine ( u8 "SaveFlags \t Options \t CK ID \t File CK ID \t File Index \t Pack Size \t Index \t Type \t CKObject \t CKStateChunk \t Name" );
2023-10-28 18:17:53 +08:00
} else {
2024-08-23 17:38:45 +08:00
Console :: WriteLine ( u8 "Index \t Type \t Object \t Chunk \t Name" );
2023-10-28 18:17:53 +08:00
}
}
static void PrintObjectListEntry ( const LibCmo :: CK2 :: CKFileObject & obj , const LibCmo :: CK2 :: CKFileInfo & fileinfo , size_t entry_index , bool full_detail ) {
if ( full_detail ) {
2024-08-24 21:27:23 +08:00
Console :: Format ( u8 "0x%08" PRIxCKDWORD " \t " , obj . SaveFlags );
Console :: Format ( u8 "%s \t " , AccessibleValue :: GetEnumName ( obj . Options , AccessibleValue :: EnumDesc :: CK_FO_OPTIONS ). c_str ());
2023-10-28 18:17:53 +08:00
2024-08-24 21:27:23 +08:00
Console :: Format ( u8 "%" PRIuCKID " \t %" PRIuCKID " \t " ,
2024-08-23 17:38:45 +08:00
obj . CreatedObjectId ,
obj . ObjectId
);
2023-10-28 18:17:53 +08:00
2024-08-24 21:27:23 +08:00
Console :: Format ( u8 "0x%08" PRIxCKDWORD " (Rel: 0x%08" PRIxCKDWORD ") \t " ,
2023-10-28 18:17:53 +08:00
obj . FileIndex ,
2024-08-23 17:38:45 +08:00
obj . FileIndex - CKSizeof ( LibCmo :: CK2 :: CKRawFileInfo ) - fileinfo . Hdr1UnPackSize
);
2024-08-24 21:27:23 +08:00
Console :: Format ( u8 "0x%08" PRIxCKDWORD " \t " , obj . PackSize );
2023-10-28 18:17:53 +08:00
}
2024-08-23 17:38:45 +08:00
// following items are shared by full details and simple layout
2024-08-24 21:27:23 +08:00
Console :: FormatLine ( u8 "#%" PRIuSIZET " \t %s \t %s \t %s \t %s" ,
2024-08-23 17:38:45 +08:00
entry_index ,
AccessibleValue :: GetClassIdName ( obj . ObjectCid ). c_str (),
PrintColorfulBool ( obj . ObjPtr != nullptr ). c_str (),
PrintColorfulBool ( obj . Data != nullptr ). c_str (),
2024-08-24 21:27:23 +08:00
PrintCKSTRING ( LibCmo :: XContainer :: NSXString :: ToCKSTRING ( obj . Name )). c_str ()
2024-08-23 17:38:45 +08:00
);
2023-10-28 18:17:53 +08:00
}
2023-08-29 10:42:13 +08:00
void PrintObjectList (
const LibCmo :: XContainer :: XArray < LibCmo :: CK2 :: CKFileObject >& ls ,
const LibCmo :: CK2 :: CKFileInfo & fileinfo ,
2023-10-28 18:17:53 +08:00
size_t page , size_t pageitems ,
bool full_detail ) {
2023-03-04 00:13:03 +08:00
2024-08-23 17:38:45 +08:00
Console :: WriteLine ( YYCC_COLOR_LIGHT_YELLOW ( u8 "CKFileObject" ));
2023-08-27 22:14:02 +08:00
GeneralPrintList < LibCmo :: CK2 :: CKFileObject > ( ls , page , pageitems ,
2023-10-28 18:17:53 +08:00
[ full_detail ]() -> void {
PrintObjectListHeader ( full_detail );
2023-08-27 22:14:02 +08:00
},
2023-10-28 18:17:53 +08:00
[ & fileinfo , full_detail ]( size_t index , const LibCmo :: CK2 :: CKFileObject & obj ) -> void {
PrintObjectListEntry ( obj , fileinfo , index , full_detail );
2023-08-27 22:14:02 +08:00
}
2023-08-29 10:42:13 +08:00
);
2023-03-04 00:13:03 +08:00
}
2023-10-28 18:17:53 +08:00
void PrintSearchedObjectList (
const LibCmo :: XContainer :: XArray < size_t >& idxls ,
const LibCmo :: XContainer :: XArray < LibCmo :: CK2 :: CKFileObject >& ls ,
const LibCmo :: CK2 :: CKFileInfo & fileinfo ,
size_t page , size_t pageitems ,
bool full_detail ) {
2024-08-23 17:38:45 +08:00
Console :: WriteLine ( YYCC_COLOR_LIGHT_YELLOW ( u8 "CKFileObject Searching Result" ));
2023-10-28 18:17:53 +08:00
GeneralPrintList < size_t > ( idxls , page , pageitems ,
[ full_detail ]() -> void {
PrintObjectListHeader ( full_detail );
},
[ & ls , & fileinfo , full_detail ]( size_t , const size_t & index_to_obj ) -> void {
// resolve index to real item.
// and pass the entry index, not the page index.
PrintObjectListEntry ( ls [ index_to_obj ], fileinfo , index_to_obj , full_detail );
}
);
2023-03-04 00:13:03 +08:00
2023-10-28 18:17:53 +08:00
}
2024-08-23 17:38:45 +08:00
2023-10-28 18:17:53 +08:00
#pragma endregion
#pragma region Manager List Printer
static void PrintManagerListHeader ( bool full_detail ) {
// manager list now do not affected by list style because it is enough short
2024-08-23 17:38:45 +08:00
Console :: WriteLine ( u8 "Index \t CKGUID \t CKStateChunk" );
2023-10-28 18:17:53 +08:00
}
static void PrintManagerListEntry ( const LibCmo :: CK2 :: CKFileManagerData & mgr , size_t entry_index , bool full_detail ) {
// not affected by list style.
2024-08-23 17:38:45 +08:00
Console :: FormatLine ( u8 "#%" PRIuSIZET " \t %s \t %s" ,
entry_index ,
PrintCKGUID ( mgr . Manager ). c_str (),
PrintPointer ( mgr . Data ). c_str ()
);
2023-10-28 18:17:53 +08:00
}
2023-08-29 10:42:13 +08:00
void PrintManagerList (
const LibCmo :: XContainer :: XArray < LibCmo :: CK2 :: CKFileManagerData >& ls ,
2023-10-28 18:17:53 +08:00
size_t page , size_t pageitems ,
bool full_detail ) {
2023-03-04 00:13:03 +08:00
2024-08-23 17:38:45 +08:00
Console :: WriteLine ( YYCC_COLOR_LIGHT_YELLOW ( u8 "CKFileManager" ));
2023-08-27 22:14:02 +08:00
GeneralPrintList < LibCmo :: CK2 :: CKFileManagerData > ( ls , page , pageitems ,
2023-10-28 18:17:53 +08:00
[ full_detail ]() -> void {
2023-08-27 22:14:02 +08:00
// print header
2023-10-28 18:17:53 +08:00
PrintManagerListHeader ( full_detail );
2023-08-27 22:14:02 +08:00
},
2023-10-28 18:17:53 +08:00
[ full_detail ]( size_t index , const LibCmo :: CK2 :: CKFileManagerData & mgr ) -> void {
2023-08-27 22:14:02 +08:00
// print body
2023-10-28 18:17:53 +08:00
PrintManagerListEntry ( mgr , index , full_detail );
2023-08-27 22:14:02 +08:00
}
2023-08-29 10:42:13 +08:00
);
2023-03-04 00:13:03 +08:00
2023-08-27 22:14:02 +08:00
}
2023-10-28 18:17:53 +08:00
void PrintSearchedManagerList (
const LibCmo :: XContainer :: XArray < size_t >& idxls ,
const LibCmo :: XContainer :: XArray < LibCmo :: CK2 :: CKFileManagerData >& ls ,
size_t page , size_t pageitems ,
bool full_detail ) {
2024-08-23 17:38:45 +08:00
Console :: WriteLine ( YYCC_COLOR_LIGHT_YELLOW ( u8 "CKFileManager Searching Result" ));
2023-10-28 18:17:53 +08:00
GeneralPrintList < size_t > ( idxls , page , pageitems ,
[ full_detail ]() -> void {
PrintManagerListHeader ( full_detail );
},
[ & ls , full_detail ]( size_t , const size_t & index_to_mgr ) -> void {
// resolve index to real one
PrintManagerListEntry ( ls [ index_to_mgr ], index_to_mgr , full_detail );
}
);
}
2024-08-23 17:38:45 +08:00
2023-10-28 18:17:53 +08:00
#pragma endregion
2023-08-27 22:14:02 +08:00
void PrintCKObject ( const LibCmo :: CK2 :: ObjImpls :: CKObject * obj ) {
2023-09-01 12:19:06 +08:00
if ( obj == nullptr ) {
2024-08-23 17:38:45 +08:00
Console :: WriteLine ( YYCC_COLOR_LIGHT_RED ( u8 "Null Object" ));
2023-09-01 12:19:06 +08:00
return ;
}
2023-09-19 10:53:48 +08:00
LibCmo :: CK2 :: ObjImpls :: CKObject * mobj = const_cast < LibCmo :: CK2 :: ObjImpls :: CKObject *> ( obj );
switch ( mobj -> GetClassID ()) {
2023-09-19 11:59:23 +08:00
case LibCmo :: CK2 :: CK_CLASSID :: CKCID_OBJECT :
PrintCKObjectDetail ( static_cast < LibCmo :: CK2 :: ObjImpls :: CKObject *> ( mobj ));
break ;
case LibCmo :: CK2 :: CK_CLASSID :: CKCID_SCENEOBJECT :
PrintCKSceneObjectDetail ( static_cast < LibCmo :: CK2 :: ObjImpls :: CKSceneObject *> ( mobj ));
break ;
case LibCmo :: CK2 :: CK_CLASSID :: CKCID_BEOBJECT :
PrintCKBeObjectDetail ( static_cast < LibCmo :: CK2 :: ObjImpls :: CKBeObject *> ( mobj ));
break ;
case LibCmo :: CK2 :: CK_CLASSID :: CKCID_GROUP :
PrintCKGroupDetail ( static_cast < LibCmo :: CK2 :: ObjImpls :: CKGroup *> ( mobj ));
break ;
case LibCmo :: CK2 :: CK_CLASSID :: CKCID_RENDEROBJECT :
PrintCKRenderObjectDetail ( static_cast < LibCmo :: CK2 :: ObjImpls :: CKRenderObject *> ( mobj ));
break ;
case LibCmo :: CK2 :: CK_CLASSID :: CKCID_3DENTITY :
PrintCK3dEntityDetail ( static_cast < LibCmo :: CK2 :: ObjImpls :: CK3dEntity *> ( mobj ));
break ;
2024-12-25 13:58:39 +08:00
case LibCmo :: CK2 :: CK_CLASSID :: CKCID_LIGHT :
PrintCKLightDetail ( static_cast < LibCmo :: CK2 :: ObjImpls :: CKLight *> ( mobj ));
break ;
case LibCmo :: CK2 :: CK_CLASSID :: CKCID_TARGETLIGHT :
PrintCKTargetLightDetail ( static_cast < LibCmo :: CK2 :: ObjImpls :: CKTargetLight *> ( mobj ));
break ;
case LibCmo :: CK2 :: CK_CLASSID :: CKCID_CAMERA :
PrintCKCameraDetail ( static_cast < LibCmo :: CK2 :: ObjImpls :: CKCamera *> ( mobj ));
break ;
case LibCmo :: CK2 :: CK_CLASSID :: CKCID_TARGETCAMERA :
PrintCKTargetCameraDetail ( static_cast < LibCmo :: CK2 :: ObjImpls :: CKTargetCamera *> ( mobj ));
break ;
2023-09-19 11:59:23 +08:00
case LibCmo :: CK2 :: CK_CLASSID :: CKCID_3DOBJECT :
PrintCK3dObjectDetail ( static_cast < LibCmo :: CK2 :: ObjImpls :: CK3dObject *> ( mobj ));
break ;
case LibCmo :: CK2 :: CK_CLASSID :: CKCID_TEXTURE :
PrintCKTextureDetail ( static_cast < LibCmo :: CK2 :: ObjImpls :: CKTexture *> ( mobj ));
break ;
case LibCmo :: CK2 :: CK_CLASSID :: CKCID_MATERIAL :
PrintCKMaterialDetail ( static_cast < LibCmo :: CK2 :: ObjImpls :: CKMaterial *> ( mobj ));
break ;
2023-09-19 10:53:48 +08:00
case LibCmo :: CK2 :: CK_CLASSID :: CKCID_MESH :
PrintCKMeshDetail ( static_cast < LibCmo :: CK2 :: ObjImpls :: CKMesh *> ( mobj ));
break ;
default :
2024-08-23 17:38:45 +08:00
Console :: WriteLine ( YYCC_COLOR_LIGHT_RED ( u8 "Not Implemented." ));
2023-09-19 10:53:48 +08:00
break ;
}
2023-08-27 22:14:02 +08:00
}
2023-10-28 18:17:53 +08:00
2023-08-27 22:14:02 +08:00
void PrintCKBaseManager ( const LibCmo :: CK2 :: MgrImpls :: CKBaseManager * mgr ) {
2024-08-23 17:38:45 +08:00
Console :: WriteLine ( YYCC_COLOR_LIGHT_YELLOW ( u8 "CKBaseManager" ));
2023-09-01 12:19:06 +08:00
if ( mgr == nullptr ) {
2024-08-23 17:38:45 +08:00
Console :: WriteLine ( YYCC_COLOR_LIGHT_RED ( u8 "Null Manager" ));
2023-09-01 12:19:06 +08:00
return ;
}
2024-08-23 17:38:45 +08:00
Console :: WriteLine ( YYCC_COLOR_LIGHT_RED ( u8 "Not Implemented." ));
2023-08-27 22:14:02 +08:00
}
2023-10-28 18:17:53 +08:00
2023-08-27 22:14:02 +08:00
void PrintCKStateChunk ( const LibCmo :: CK2 :: CKStateChunk * chunk ) {
2024-08-23 17:38:45 +08:00
Console :: WriteLine ( YYCC_COLOR_LIGHT_YELLOW ( u8 "CKStateChunk" ));
2023-09-01 12:19:06 +08:00
if ( chunk == nullptr ) {
2024-08-23 17:38:45 +08:00
Console :: WriteLine ( YYCC_COLOR_LIGHT_RED ( u8 "Null Chunk" ));
2023-09-01 12:19:06 +08:00
return ;
}
2023-08-29 10:42:13 +08:00
// hack const state chunk
2023-08-27 22:14:02 +08:00
LibCmo :: CK2 :: CKStateChunk * operchunk = const_cast < LibCmo :: CK2 :: CKStateChunk *> ( chunk );
2023-08-29 10:42:13 +08:00
// write profile
const auto profile = operchunk -> GetStateChunkProfile ();
2024-08-23 17:38:45 +08:00
Console :: FormatLine ( u8 "Type: %s" , AccessibleValue :: GetClassIdName ( profile . m_ClassId ). c_str ());
2023-08-29 10:42:13 +08:00
2024-08-23 17:38:45 +08:00
Console :: FormatLine ( u8 "Version (Data / Chunk): %" PRIuCKDWORD " (%s) / %" PRIuCKDWORD " (%s)" ,
2023-09-17 10:38:46 +08:00
static_cast < LibCmo :: CKDWORD > ( profile . m_DataVersion ), AccessibleValue :: GetEnumName ( profile . m_DataVersion , AccessibleValue :: EnumDesc :: CK_STATECHUNK_DATAVERSION ). c_str (),
2024-08-23 17:38:45 +08:00
static_cast < LibCmo :: CKDWORD > ( profile . m_ChunkVersion ), AccessibleValue :: GetEnumName ( profile . m_ChunkVersion , AccessibleValue :: EnumDesc :: CK_STATECHUNK_CHUNKVERSION ). c_str ()
);
Console :: FormatLine ( u8 "List (Object / Chunk / Manager): %" PRIuCKDWORD " / %" PRIuCKDWORD " / %" PRIuCKDWORD ,
2023-09-17 10:38:46 +08:00
static_cast < LibCmo :: CKDWORD > ( profile . m_ObjectListSize ),
static_cast < LibCmo :: CKDWORD > ( profile . m_ChunkListSize ),
2024-08-23 17:38:45 +08:00
static_cast < LibCmo :: CKDWORD > ( profile . m_ManagerListSize )
);
2023-08-29 10:42:13 +08:00
2024-08-23 17:38:45 +08:00
Console :: FormatLine ( u8 "Data: %s (0x%" PRIxCKDWORD " DWORD)" ,
PrintPointer ( profile . m_pData ). c_str (),
profile . m_DataDwSize
);
2023-08-29 10:42:13 +08:00
2024-08-23 17:38:45 +08:00
Console :: FormatLine ( u8 "Bind CKFile: %s" , PrintPointer ( profile . m_BindFile ). c_str ());
Console :: FormatLine ( u8 "Bind CKContext: %s" , PrintPointer ( profile . m_BindContext ). c_str ());
2023-08-29 10:42:13 +08:00
// write identifiers
2023-08-27 22:14:02 +08:00
operchunk -> StartRead ();
2023-09-18 16:37:05 +08:00
const auto collection = operchunk -> GetIdentifiersProfile ();
2023-08-27 22:14:02 +08:00
operchunk -> StopRead ();
2024-08-23 17:38:45 +08:00
Console :: WriteLine ( YYCC_COLOR_LIGHT_YELLOW ( u8 "Identifiers" ));
Console :: WriteLine ( u8 "Identifier \t Data Pointer \t Data Size" );
2023-08-29 10:42:13 +08:00
for ( const auto & ident : collection ) {
2024-08-24 21:27:23 +08:00
Console :: FormatLine ( u8 "0x%08" PRIxCKDWORD " \t %s \t %" PRIuCKDWORD " (%" PRIuCKDWORD " DWORD + %" PRIuCKDWORD ")" ,
2024-08-23 17:38:45 +08:00
ident . m_Identifier ,
PrintPointer ( ident . m_DataPtr ). c_str (),
ident . m_AreaSize ,
ident . m_AreaSize / CKSizeof ( LibCmo :: CKDWORD ),
ident . m_AreaSize % CKSizeof ( LibCmo :: CKDWORD )
);
2023-03-04 00:13:03 +08:00
}
2023-08-27 16:45:07 +08:00
}
2023-02-14 16:28:37 +08:00
}