From 4dd8fcd0b0c522973e88cf3859967d42e1f9a989 Mon Sep 17 00:00:00 2001 From: Phillip Stephens Date: Wed, 7 Jan 2026 11:01:50 -0800 Subject: [PATCH] CGuiWidget progress --- config/GM8E01_00/symbols.txt | 2 +- config/GM8E01_01/symbols.txt | 2 +- include/GuiSys/CGuiFrame.hpp | 6 +++- include/GuiSys/CGuiWidget.hpp | 9 +++-- include/GuiSys/CGuiWidgetIdDB.hpp | 5 +-- include/Kyoto/Streams/CInputStream.hpp | 2 +- include/WorldFormat/COBBTree.hpp | 10 +++--- src/Collision/COBBox.cpp | 4 ++- src/GuiSys/CGuiWidget.cpp | 49 ++++++++++++++++++++++++++ src/Kyoto/Streams/CInputStream.cpp | 8 ++--- src/WorldFormat/COBBTree.cpp | 4 +++ 11 files changed, 82 insertions(+), 19 deletions(-) create mode 100644 src/GuiSys/CGuiWidget.cpp diff --git a/config/GM8E01_00/symbols.txt b/config/GM8E01_00/symbols.txt index d9a91c87..d5186a64 100644 --- a/config/GM8E01_00/symbols.txt +++ b/config/GM8E01_00/symbols.txt @@ -12272,7 +12272,7 @@ ParseBaseInfo__10CGuiWidgetFP9CGuiFrameR12CInputStreamRCQ210CGuiWidget15CGuiWidg __dt__10CGuiWidgetFv = .text:0x802CABB4; // type:function size:0x70 scope:global __ct__10CGuiWidgetFRCQ210CGuiWidget15CGuiWidgetParms = .text:0x802CAC24; // type:function size:0x12C scope:global ReadWidgetHeader__10CGuiWidgetFP9CGuiFrameR12CInputStream = .text:0x802CAD50; // type:function size:0x108 scope:global -Create__10CGuiWidgetFP9CGuiFrameR12CInputStreamb = .text:0x802CAE58; // type:function size:0xD8 scope:global +Create__10CGuiWidgetFP9CGuiFrameR12CInputStreamP11CSimplePool = .text:0x802CAE58; // type:function size:0xD8 scope:global __ct__Q210CGuiWidget15CGuiWidgetParmsFP9CGuiFramebssbbbRC6CColorQ210CGuiWidget18EGuiModelDrawFlagsbb = .text:0x802CAF30; // type:function size:0x44 scope:global FindWidgetID__14CGuiWidgetIdDBCFRCQ24rstl66basic_string,Q24rstl17rmemory_allocator> = .text:0x802CAF74; // type:function size:0x88 scope:global AddWidget__14CGuiWidgetIdDBFRCQ24rstl66basic_string,Q24rstl17rmemory_allocator> = .text:0x802CAFFC; // type:function size:0xA8 scope:global diff --git a/config/GM8E01_01/symbols.txt b/config/GM8E01_01/symbols.txt index f141dd1a..fb109ab8 100644 --- a/config/GM8E01_01/symbols.txt +++ b/config/GM8E01_01/symbols.txt @@ -12272,7 +12272,7 @@ ParseBaseInfo__10CGuiWidgetFP9CGuiFrameR12CInputStreamRCQ210CGuiWidget15CGuiWidg __dt__10CGuiWidgetFv = .text:0x802CAC60; // type:function size:0x70 scope:global __ct__10CGuiWidgetFRCQ210CGuiWidget15CGuiWidgetParms = .text:0x802CACD0; // type:function size:0x12C scope:global ReadWidgetHeader__10CGuiWidgetFP9CGuiFrameR12CInputStream = .text:0x802CADFC; // type:function size:0x108 scope:global -Create__10CGuiWidgetFP9CGuiFrameR12CInputStreamb = .text:0x802CAF04; // type:function size:0xD8 scope:global +Create__10CGuiWidgetFP9CGuiFrameR12CInputStreamP11CSimplePool = .text:0x802CAF04; // type:function size:0xD8 scope:global __ct__Q210CGuiWidget15CGuiWidgetParmsFP9CGuiFramebssbbbRC6CColorQ210CGuiWidget18EGuiModelDrawFlagsbb = .text:0x802CAFDC; // type:function size:0x44 scope:global FindWidgetID__14CGuiWidgetIdDBCFRCQ24rstl66basic_string,Q24rstl17rmemory_allocator> = .text:0x802CB020; // type:function size:0x88 scope:global AddWidget__14CGuiWidgetIdDBFRCQ24rstl66basic_string,Q24rstl17rmemory_allocator> = .text:0x802CB0A8; // type:function size:0xA8 scope:global diff --git a/include/GuiSys/CGuiFrame.hpp b/include/GuiSys/CGuiFrame.hpp index 8336d36c..4fdfce28 100644 --- a/include/GuiSys/CGuiFrame.hpp +++ b/include/GuiSys/CGuiFrame.hpp @@ -1,6 +1,7 @@ #ifndef _CGUIFRAME #define _CGUIFRAME +#include "GuiSys/CGuiWidgetIdDB.hpp" #include "rstl/string.hpp" class CGuiWidget; @@ -15,9 +16,12 @@ public: void AddLight(CGuiLight* light); void RemoveLight(CGuiLight* light); + CGuiWidgetIdDB& WidgetIdDB() { return x18_db; } + private: - char x0_pad[0x14]; + char x0_[0x14]; CGuiCamera* x14_camera; + CGuiWidgetIdDB x18_db; }; #endif // _CGUIFRAME diff --git a/include/GuiSys/CGuiWidget.hpp b/include/GuiSys/CGuiWidget.hpp index 0ed0f031..22bdd06b 100644 --- a/include/GuiSys/CGuiWidget.hpp +++ b/include/GuiSys/CGuiWidget.hpp @@ -9,7 +9,8 @@ class CFinalInput; class CGuiFrame; - +class CInputStream; +class CSimplePool; enum ETraversalMode { kTM_ChildrenAndSiblings = 0, kTM_Children = 1, @@ -27,8 +28,9 @@ public: }; class CGuiWidgetParms { public: - CGuiWidgetParms(CGuiFrame*, const rstl::string&, bool, short, short, bool, bool, bool, - const CColor&, CGuiWidget::EGuiModelDrawFlags, bool, bool); + CGuiWidgetParms(CGuiFrame* frame, bool useAnimController, short selfId, short parentId, + bool defaultVisible, bool defaultActive, bool cullFaces, const CColor& color, + EGuiModelDrawFlags drawFlags, bool g, bool h); CGuiFrame* x0_frame; bool x4_useAnimController; short x6_selfId; @@ -68,6 +70,7 @@ public: CGuiFrame* GetFrame() { return xb0_frame; } + static CGuiWidget* Create(CGuiFrame* frame, CInputStream& in, CSimplePool* sp); static const short InvalidWidgetId() { return gkInvalidWidgetId; } private: diff --git a/include/GuiSys/CGuiWidgetIdDB.hpp b/include/GuiSys/CGuiWidgetIdDB.hpp index b12a2211..a960d57f 100644 --- a/include/GuiSys/CGuiWidgetIdDB.hpp +++ b/include/GuiSys/CGuiWidgetIdDB.hpp @@ -8,8 +8,9 @@ class CGuiWidgetIdDB { public: CGuiWidgetIdDB(); void Reserve(int); - int AddWidget(const rstl::string& name); - short FindWidgetID(const rstl::string& name) const; + const short AddWidget(const rstl::string& name); + const short FindWidgetID(const rstl::string& name) const; + private: rstl::vector< rstl::string > x0_db; }; diff --git a/include/Kyoto/Streams/CInputStream.hpp b/include/Kyoto/Streams/CInputStream.hpp index 4028e770..10a9cbe9 100644 --- a/include/Kyoto/Streams/CInputStream.hpp +++ b/include/Kyoto/Streams/CInputStream.hpp @@ -28,7 +28,7 @@ public: uint ReadLong(); ushort ReadShort(); bool ReadBool(); - uchar ReadChar(); + char ReadChar(); uint ReadBits(uint len); size_t ReadBytes(void* dest, size_t len); void Get(void* dest, unsigned long len); diff --git a/include/WorldFormat/COBBTree.hpp b/include/WorldFormat/COBBTree.hpp index 2cfc2d20..3593a339 100644 --- a/include/WorldFormat/COBBTree.hpp +++ b/include/WorldFormat/COBBTree.hpp @@ -9,12 +9,12 @@ class COBBTree { struct SIndexData { - rstl::vector< u32 > x0_materials; - rstl::vector< u8 > x10_vertMaterials; - rstl::vector< u8 > x20_edgeMaterials; - rstl::vector< u8 > x30_surfaceMaterials; + rstl::vector< uint > x0_materials; + rstl::vector< uchar > x10_vertMaterials; + rstl::vector< uchar > x20_edgeMaterials; + rstl::vector< uchar > x30_surfaceMaterials; rstl::vector< CCollisionEdge > x40_edges; - rstl::vector< u16 > x50_surfaceIndices; + rstl::vector< ushort > x50_surfaceIndices; rstl::vector< CVector3f > x60_vertices; SIndexData(CInputStream& in); }; diff --git a/src/Collision/COBBox.cpp b/src/Collision/COBBox.cpp index 1740c778..0975f79e 100644 --- a/src/Collision/COBBox.cpp +++ b/src/Collision/COBBox.cpp @@ -7,7 +7,9 @@ COBBox::COBBox(const CTransform4f& xf, const CVector3f& extents) COBBox::COBBox(CInputStream& in) : mTransform(in), mExtents(in) {} -CAABox COBBox::CalculateAABox(const CTransform4f& xf) const { return CAABox(CVector3f::Zero(), CVector3f::Zero()); } +CAABox COBBox::CalculateAABox(const CTransform4f& xf) const { + return CAABox(CVector3f::Zero(), CVector3f::Zero()); +} COBBox COBBox::FromAABox(const CAABox& box, const CTransform4f& xf) { CVector3f center = box.GetCenterPoint(); diff --git a/src/GuiSys/CGuiWidget.cpp b/src/GuiSys/CGuiWidget.cpp new file mode 100644 index 00000000..924b147b --- /dev/null +++ b/src/GuiSys/CGuiWidget.cpp @@ -0,0 +1,49 @@ +#include "GuiSys/CGuiWidget.hpp" +#include "GuiSys/CGuiFrame.hpp" +#include "GuiSys/CGuiWidgetDrawParms.hpp" + +#include + +static const char* tmp = "Warning: Discarding useless worker id. Parent is not a compound widget."; + +CGuiWidget::CGuiWidgetParms::CGuiWidgetParms(CGuiFrame* frame, bool useAnimController, + const short selfId, const short parentId, + const bool defaultVisible, const bool defaultActive, + const bool cullFaces, const CColor& color, + EGuiModelDrawFlags drawFlags, const bool g, + const bool h) +: x0_frame(frame) +, x4_useAnimController(useAnimController) +, x6_selfId(selfId) +, x8_parentId(parentId) +, xa_defaultVisible(defaultVisible) +, xb_defaultActive(defaultActive) +, xc_cullFaces(cullFaces) +, xd_g(g) +, xe_h(h) +, x10_color(color) +, x14_drawFlags(drawFlags) {} + +CGuiWidget* CGuiWidget::Create(CGuiFrame* frame, CInputStream& in, CSimplePool* sp) { + CGuiWidgetParms parms = ReadWidgetHeader(frame, in); + CGuiWidget* ret = rs_new CGuiWidget(parms); + ret->ParseBaseInfo(frame, in, parms); + return ret; +} + +CGuiWidget::CGuiWidgetParms CGuiWidget::ReadWidgetHeader(CGuiFrame* frame, CInputStream& in) { + rstl::string name(in); + const short selfId = frame->WidgetIdDB().AddWidget(name); + rstl::string parent(in); + const short parentId = frame->WidgetIdDB().AddWidget(parent); + + bool useAnimController = in.Get< bool >(); + bool defaultVis = in.Get< bool >(); + bool defaultActive = in.Get< bool >(); + bool cullFaces = in.Get< bool >(); + CColor color(in); + EGuiModelDrawFlags flags = static_cast< EGuiModelDrawFlags >(in.Get< uint >()); + + return CGuiWidgetParms(frame, useAnimController, selfId, parentId, defaultVis, defaultActive, + cullFaces, color, flags, true, false); +} diff --git a/src/Kyoto/Streams/CInputStream.cpp b/src/Kyoto/Streams/CInputStream.cpp index 942d6e75..8c27e1ad 100644 --- a/src/Kyoto/Streams/CInputStream.cpp +++ b/src/Kyoto/Streams/CInputStream.cpp @@ -143,13 +143,13 @@ uint CInputStream::ReadBits(uint bitCount) { return ret; } -uchar CInputStream::ReadChar() { - static uchar c; - Get(&c, sizeof(uchar)); +char CInputStream::ReadChar() { + static char c; + Get(&c, sizeof(char)); return c; } -bool CInputStream::ReadBool() { return static_cast< bool >(ReadChar()); } +bool CInputStream::ReadBool() { return static_cast< uchar >(ReadChar()) != 0; } ushort CInputStream::ReadShort() { static ushort s; diff --git a/src/WorldFormat/COBBTree.cpp b/src/WorldFormat/COBBTree.cpp index d9e5789a..3df986f4 100644 --- a/src/WorldFormat/COBBTree.cpp +++ b/src/WorldFormat/COBBTree.cpp @@ -2,6 +2,8 @@ #include "Kyoto/Streams/CInputStream.hpp" +#pragma inline_max_size(250) + COBBTree::SIndexData::SIndexData(CInputStream& in) : x0_materials(in) , x10_vertMaterials(in) @@ -10,3 +12,5 @@ COBBTree::SIndexData::SIndexData(CInputStream& in) , x40_edges(in) , x50_surfaceIndices(in) , x60_vertices(in) {} + +COBBTree::COBBTree(const SIndexData& indexData, const CNode* root);