diff --git a/config/GM8E01_00/symbols.txt b/config/GM8E01_00/symbols.txt index f1da57b7..eb2e7583 100644 --- a/config/GM8E01_00/symbols.txt +++ b/config/GM8E01_00/symbols.txt @@ -12095,8 +12095,8 @@ GetIsFinishedLoadingWidgetSpecific__9CGuiModelCFv = .text:0x802C3FF0; // type:fu Touch__9CGuiModelCFv = .text:0x802C409C; // type:function size:0x3C scope:global Draw__9CGuiModelCFRC19CGuiWidgetDrawParms = .text:0x802C40D8; // type:function size:0x390 scope:global __dt__9CGuiModelFv = .text:0x802C4468; // type:function size:0x98 scope:global -__ct__9CGuiModelFRCQ210CGuiWidget15CGuiWidgetParmsUiUib = .text:0x802C4500; // type:function size:0x130 scope:global -Create__9CGuiModelFP9CGuiFrameR12CInputStreamb = .text:0x802C4630; // type:function size:0x108 scope:global +__ct__9CGuiModelFRCQ210CGuiWidget15CGuiWidgetParmsP11CSimplePoolUiUib = .text:0x802C4500; // type:function size:0x130 scope:global +Create__9CGuiModelFP9CGuiFrameR12CInputStreamP11CSimplePool = .text:0x802C4630; // type:function size:0x108 scope:global SetO2WTransform__10CGuiObjectFRC12CTransform4f = .text:0x802C4738; // type:function size:0x78 scope:global SetLocalTransform__10CGuiObjectFRC12CTransform4f = .text:0x802C47B0; // type:function size:0x38 scope:global RecalculateTransforms__10CGuiObjectFv = .text:0x802C47E8; // type:function size:0x530 scope:global @@ -18765,7 +18765,7 @@ lbl_803EC7B8 = .data:0x803EC7B8; // type:object size:0x10 __vt__9CGuiGroup = .data:0x803EC7C8; // type:object size:0x40 __vt__14CGuiHeadWidget = .data:0x803EC808; // type:object size:0x3C scope:weak __vt__9CGuiLight = .data:0x803EC848; // type:object size:0x40 scope:global -lbl_803EC888 = .data:0x803EC888; // type:object size:0x40 +__vt__9CGuiModel = .data:0x803EC888; // type:object size:0x40 __vt__10CGuiObject = .data:0x803EC8C8; // type:object size:0x18 scope:global __vt__8CGuiPane = .data:0x803EC8E0; // type:object size:0x50 lbl_803EC930 = .data:0x803EC930; // type:object size:0x40 diff --git a/config/GM8E01_01/symbols.txt b/config/GM8E01_01/symbols.txt index 58a4a7af..8bb71e74 100644 --- a/config/GM8E01_01/symbols.txt +++ b/config/GM8E01_01/symbols.txt @@ -12095,8 +12095,8 @@ GetIsFinishedLoadingWidgetSpecific__9CGuiModelCFv = .text:0x802C409C; // type:fu Touch__9CGuiModelCFv = .text:0x802C4148; // type:function size:0x3C scope:global Draw__9CGuiModelCFRC19CGuiWidgetDrawParms = .text:0x802C4184; // type:function size:0x390 scope:global __dt__9CGuiModelFv = .text:0x802C4514; // type:function size:0x98 scope:global -__ct__9CGuiModelFRCQ210CGuiWidget15CGuiWidgetParmsUiUib = .text:0x802C45AC; // type:function size:0x130 scope:global -Create__9CGuiModelFP9CGuiFrameR12CInputStreamb = .text:0x802C46DC; // type:function size:0x108 scope:global +__ct__9CGuiModelFRCQ210CGuiWidget15CGuiWidgetParmsP11CSimplePoolUiUib = .text:0x802C45AC; // type:function size:0x130 scope:global +Create__9CGuiModelFP9CGuiFrameR12CInputStreamP11CSimplePool = .text:0x802C46DC; // type:function size:0x108 scope:global SetO2WTransform__10CGuiObjectFRC12CTransform4f = .text:0x802C47E4; // type:function size:0x78 scope:global SetLocalTransform__10CGuiObjectFRC12CTransform4f = .text:0x802C485C; // type:function size:0x38 scope:global RecalculateTransforms__10CGuiObjectFv = .text:0x802C4894; // type:function size:0x530 scope:global diff --git a/include/GuiSys/CGuiFrame.hpp b/include/GuiSys/CGuiFrame.hpp index 716c7c29..b00fa7ba 100644 --- a/include/GuiSys/CGuiFrame.hpp +++ b/include/GuiSys/CGuiFrame.hpp @@ -4,6 +4,7 @@ #include "GuiSys/CGuiWidgetIdDB.hpp" #include "rstl/string.hpp" +class CGuiSys; class CGuiWidget; class CGuiCamera; class CGuiLight; @@ -24,8 +25,13 @@ public: CGuiWidgetIdDB& WidgetIdDB() { return x18_db; } + CGuiSys& GetGuiSys() const { return x8_guiSys; } + private: - char x0_[0x14]; + uint x0_id; + uint x4_; + CGuiSys& x8_guiSys; + char x0_[0xC]; CGuiCamera* x14_camera; CGuiWidgetIdDB x18_db; }; diff --git a/include/GuiSys/CGuiModel.hpp b/include/GuiSys/CGuiModel.hpp index 710bebc0..fcd41dfe 100644 --- a/include/GuiSys/CGuiModel.hpp +++ b/include/GuiSys/CGuiModel.hpp @@ -5,6 +5,7 @@ #include "Kyoto/SObjectTag.hpp" #include "Kyoto/TToken.hpp" +#include "rstl/optional_object.hpp" class CModel; @@ -12,15 +13,18 @@ class CGuiModel : public CGuiWidget { public: CGuiModel(const CGuiWidgetParms& parms, CSimplePool* sp, CAssetId modelId, uint lightMask, bool flag); + ~CGuiModel(); - const TLockedToken< CModel >& GetModel() const { return xb8_model; } + const rstl::optional_object< TCachedToken< CModel > >& GetModel() const { return xb8_model; } bool GetIsFinishedLoadingWidgetSpecific() const override; void Touch() const override; void Draw(const CGuiWidgetDrawParms& parms) const override; // bool TestCursorHit(const CMatrix4f& vp, const CVector2f& point) const override; + static CGuiModel* Create(CGuiFrame* frame, CInputStream& in, CSimplePool* sp); + private: - TLockedToken< CModel > xb8_model; + mutable rstl::optional_object< TCachedToken< CModel > > xb8_model; CAssetId xc8_modelId; uint xcc_lightMask; }; diff --git a/src/GuiSys/CGuiModel.cpp b/src/GuiSys/CGuiModel.cpp new file mode 100644 index 00000000..5d9ce9f3 --- /dev/null +++ b/src/GuiSys/CGuiModel.cpp @@ -0,0 +1,39 @@ +#include "GuiSys/CGuiModel.hpp" + +#include "GuiSys/CGuiFrame.hpp" +#include "GuiSys/CGuiSys.hpp" +#include "Kyoto/Graphics/CModel.hpp" + +CGuiModel* CGuiModel::Create(CGuiFrame* frame, CInputStream& in, CSimplePool* sp) { + CGuiWidgetParms parms = ReadWidgetHeader(frame, in); + + CAssetId model = in.Get< CAssetId >(); + in.Get< uint >(); + uint lightMask = in.Get< uint >(); + + CGuiModel* ret = rs_new CGuiModel(parms, sp, model, lightMask, true); + ret->ParseBaseInfo(frame, in, parms); + return ret; +} + +CGuiModel::CGuiModel(const CGuiWidgetParms& parms, CSimplePool* sp, CAssetId modelId, + uint lightMask, bool flag) +: CGuiWidget(parms), xc8_modelId(modelId), xcc_lightMask(lightMask) { + const CGuiSys* gs = CGuiSys::GetGlobalGuiSys(); + if (flag && xc8_modelId != kInvalidAssetId && gs->GetUsageMode() != CGuiSys::kUM_Two) { + xb8_model = sp->GetObj(SObjectTag('CMDL', modelId)); + xb8_model->Lock(); + } +} + +CGuiModel::~CGuiModel() {} + +void CGuiModel::Draw(const CGuiWidgetDrawParms& parms) const {} + +void CGuiModel::Touch() const { + if (xb8_model && xb8_model->GetObject()) { + xb8_model->GetObject()->Touch(0); + } +} + +bool CGuiModel::GetIsFinishedLoadingWidgetSpecific() const {} \ No newline at end of file