mirror of https://github.com/AxioDL/metaforce.git
Proper handling for persistently resident resources
This commit is contained in:
parent
2f963b9ce3
commit
52b36795ac
|
@ -91,7 +91,7 @@ void CToken::Lock() {
|
|||
}
|
||||
}
|
||||
bool CToken::IsLoaded() const {
|
||||
if (!x0_objRef)
|
||||
if (!x0_objRef || !x4_lockHeld)
|
||||
return false;
|
||||
return x0_objRef->IsLoaded();
|
||||
}
|
||||
|
|
|
@ -1188,15 +1188,7 @@ void CModel::Draw(const CModelFlags& flags) const {
|
|||
|
||||
bool CModel::IsLoaded(int shaderIdx) const {
|
||||
const_cast<CBooModel&>(*x28_modelInst).VerifyCurrentShader(shaderIdx);
|
||||
std::vector<TCachedToken<CTexture>>& texs = x28_modelInst->x1c_textures;
|
||||
bool loaded = true;
|
||||
for (TCachedToken<CTexture>& tex : texs) {
|
||||
if (!tex.IsLoaded()) {
|
||||
loaded = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return loaded;
|
||||
return const_cast<CBooModel&>(*x28_modelInst).TryLockTextures();
|
||||
}
|
||||
|
||||
size_t CModel::GetPoolVertexOffset(size_t idx) const { return m_hmdlMeta.vertStride * idx; }
|
||||
|
|
|
@ -32,6 +32,12 @@ std::shared_ptr<CGuiWidget> CAuiImagePane::Create(CGuiFrame* frame, CInputStream
|
|||
return ret;
|
||||
}
|
||||
|
||||
void CAuiImagePane::Reset(ETraversalMode mode) {
|
||||
xc8_tex0 = CAssetId();
|
||||
xb8_tex0Tok = TLockedToken<CTexture>();
|
||||
CGuiWidget::Reset(mode);
|
||||
}
|
||||
|
||||
void CAuiImagePane::Update(float dt) {
|
||||
xd0_uvBias0.x() = std::fmod(xd0_uvBias0.x(), 1.f);
|
||||
xd0_uvBias0.y() = std::fmod(xd0_uvBias0.y(), 1.f);
|
||||
|
|
|
@ -41,6 +41,7 @@ public:
|
|||
FourCC GetWidgetTypeID() const { return FOURCC('IMGP'); }
|
||||
static std::shared_ptr<CGuiWidget> Create(CGuiFrame* frame, CInputStream& in, CSimplePool* sp);
|
||||
|
||||
void Reset(ETraversalMode mode);
|
||||
void Update(float dt);
|
||||
void Draw(const CGuiWidgetDrawParms& params) const;
|
||||
bool GetIsFinishedLoadingWidgetSpecific() const;
|
||||
|
|
|
@ -124,6 +124,10 @@ void CGuiFrame::SetMaxAspect(float c) {
|
|||
CGuiSys::ViewportResizeFrame(this);
|
||||
}
|
||||
|
||||
void CGuiFrame::Reset() {
|
||||
x10_rootWidget->Reset(ETraversalMode::Children);
|
||||
}
|
||||
|
||||
void CGuiFrame::Update(float dt) { xc_headWidget->Update(dt); }
|
||||
|
||||
void CGuiFrame::Draw(const CGuiWidgetDrawParms& parms) const {
|
||||
|
|
|
@ -89,6 +89,7 @@ public:
|
|||
m_mouseScrollCb = std::move(cb);
|
||||
}
|
||||
|
||||
void Reset();
|
||||
void Update(float dt);
|
||||
void Draw(const CGuiWidgetDrawParms& parms) const;
|
||||
CGuiWidget* BestCursorHit(const zeus::CVector2f& point, const CGuiWidgetDrawParms& parms) const;
|
||||
|
|
|
@ -10,6 +10,7 @@ struct CGuiWidgetDrawParms;
|
|||
|
||||
class CGuiObject : public std::enable_shared_from_this<CGuiObject> {
|
||||
protected:
|
||||
zeus::CTransform m_initLocalXF;
|
||||
zeus::CTransform x4_localXF;
|
||||
zeus::CTransform x34_worldXF;
|
||||
CGuiObject* x64_parent = nullptr;
|
||||
|
@ -24,6 +25,8 @@ public:
|
|||
virtual void Initialize() = 0;
|
||||
|
||||
void MoveInWorld(const zeus::CVector3f& vec);
|
||||
const zeus::CVector3f& GetInitialLocalPosition() const { return m_initLocalXF.origin; }
|
||||
const zeus::CTransform& GetInitialLocalTransform() const { return m_initLocalXF; }
|
||||
const zeus::CVector3f& GetLocalPosition() const { return x4_localXF.origin; }
|
||||
const zeus::CTransform& GetLocalTransform() const { return x4_localXF; }
|
||||
void SetLocalPosition(const zeus::CVector3f& pos);
|
||||
|
|
|
@ -7,6 +7,7 @@ static logvisor::Module Log("urde::CGuiWidget");
|
|||
CGuiWidget::CGuiWidget(const CGuiWidgetParms& parms)
|
||||
: x70_selfId(parms.x6_selfId)
|
||||
, x72_parentId(parms.x8_parentId)
|
||||
, m_initColor(parms.x10_color)
|
||||
, xa4_color(parms.x10_color)
|
||||
, xa8_color2(parms.x10_color)
|
||||
, xac_drawFlags(parms.x14_drawFlags)
|
||||
|
@ -60,6 +61,7 @@ void CGuiWidget::ParseBaseInfo(CGuiFrame* frame, CInputStream& in, const CGuiWid
|
|||
zeus::CVector3f trans = zeus::CVector3f::ReadBig(in);
|
||||
zeus::CMatrix3f orient = zeus::CMatrix3f::ReadBig(in);
|
||||
x74_transform = zeus::CTransform(orient, trans);
|
||||
m_initTransform = x74_transform;
|
||||
ReapplyXform();
|
||||
zeus::CVector3f::ReadBig(in);
|
||||
in.readUint32Big();
|
||||
|
@ -71,6 +73,36 @@ void CGuiWidget::ParseBaseInfo(CGuiFrame* frame, CInputStream& in, const CGuiWid
|
|||
}
|
||||
}
|
||||
parent->AddChildWidget(this, false, true);
|
||||
m_initLocalXF = x4_localXF;
|
||||
}
|
||||
|
||||
void CGuiWidget::Reset(ETraversalMode mode) {
|
||||
xa4_color = m_initColor;
|
||||
xa8_color2 = m_initColor;
|
||||
x74_transform = m_initTransform;
|
||||
ReapplyXform();
|
||||
x4_localXF = m_initLocalXF;
|
||||
RecalculateTransforms();
|
||||
|
||||
switch (mode) {
|
||||
case ETraversalMode::Children: {
|
||||
CGuiWidget* child = static_cast<CGuiWidget*>(GetChildObject());
|
||||
if (child)
|
||||
child->Reset(ETraversalMode::ChildrenAndSiblings);
|
||||
break;
|
||||
}
|
||||
case ETraversalMode::ChildrenAndSiblings: {
|
||||
CGuiWidget* child = static_cast<CGuiWidget*>(GetChildObject());
|
||||
if (child)
|
||||
child->Reset(ETraversalMode::ChildrenAndSiblings);
|
||||
CGuiWidget* nextSib = static_cast<CGuiWidget*>(GetNextSibling());
|
||||
if (nextSib)
|
||||
nextSib->Reset(ETraversalMode::ChildrenAndSiblings);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void CGuiWidget::Update(float dt) {
|
||||
|
|
|
@ -53,7 +53,9 @@ public:
|
|||
protected:
|
||||
s16 x70_selfId;
|
||||
s16 x72_parentId;
|
||||
zeus::CTransform m_initTransform;
|
||||
zeus::CTransform x74_transform;
|
||||
zeus::CColor m_initColor;
|
||||
zeus::CColor xa4_color;
|
||||
zeus::CColor xa8_color2;
|
||||
EGuiModelDrawFlags xac_drawFlags;
|
||||
|
@ -80,6 +82,7 @@ public:
|
|||
static CGuiWidgetParms ReadWidgetHeader(CGuiFrame* frame, CInputStream& in);
|
||||
static std::shared_ptr<CGuiWidget> Create(CGuiFrame* frame, CInputStream& in, CSimplePool* sp);
|
||||
|
||||
virtual void Reset(ETraversalMode mode);
|
||||
virtual void Update(float dt);
|
||||
virtual void Draw(const CGuiWidgetDrawParms& drawParms) const;
|
||||
virtual void Initialize();
|
||||
|
|
|
@ -123,6 +123,7 @@ CHudDecoInterfaceScan::CHudDecoInterfaceScan(CGuiFrame& selHud) : x14_selHud(sel
|
|||
zeus::CVector3f sidesPos(x234_sidesPositioner, 0.f, 0.f);
|
||||
x24c_basewidget_leftside->SetLocalPosition(x24c_basewidget_leftside->RotateO2P(x218_leftsidePosition + sidesPos));
|
||||
x250_basewidget_rightside->SetLocalPosition(x250_basewidget_rightside->RotateO2P(x224_rightsidePosition - sidesPos));
|
||||
x234_sidesPositioner = FLT_MAX;
|
||||
|
||||
UpdateHudAlpha();
|
||||
}
|
||||
|
|
|
@ -174,6 +174,8 @@ void CScanDisplay::StartScan(TUniqueId id, const CScannableObjectInfo& scanInfo,
|
|||
xb8_dash = dash;
|
||||
xa4_textGroup->SetVisibility(true, ETraversalMode::Children);
|
||||
xa4_textGroup->SetColor(zeus::CColor(1.f, 0.f));
|
||||
xa8_message->TextSupport().SetText(u"");
|
||||
xac_scrollMessage->TextSupport().SetText(u"");
|
||||
|
||||
for (int i = 0; i < 20; ++i) {
|
||||
CAuiImagePane* pane =
|
||||
|
@ -181,7 +183,7 @@ void CScanDisplay::StartScan(TUniqueId id, const CScannableObjectInfo& scanInfo,
|
|||
zeus::CColor color = g_tweakGuiColors->GetScanDisplayImagePaneColor();
|
||||
color.a() = 0.f;
|
||||
pane->SetColor(color);
|
||||
pane->SetTextureID0(-1, g_SimplePool);
|
||||
pane->SetTextureID0({}, g_SimplePool);
|
||||
pane->SetAnimationParms(zeus::skZero2f, 0.f, 0.f);
|
||||
int pos = -1;
|
||||
for (int j = 0; j < 4; ++j) {
|
||||
|
@ -304,7 +306,7 @@ void CScanDisplay::Update(float dt, float scanningTime) {
|
|||
}
|
||||
|
||||
for (int i = 0; i < 4; ++i) {
|
||||
if (x170_paneStates[i].second == 0)
|
||||
if (x170_paneStates[i].second == nullptr)
|
||||
continue;
|
||||
if (x170_paneStates[i].first > 0.f) {
|
||||
x170_paneStates[i].first = std::max(0.f, x170_paneStates[i].first - dt);
|
||||
|
|
|
@ -1503,6 +1503,7 @@ void CSamusHud::UpdateStateTransition(float dt, const CStateManager& mgr) {
|
|||
if (!x278_selectedHud.IsLoaded() || !x278_selectedHud->GetIsFinishedLoading())
|
||||
return;
|
||||
x288_loadedSelectedHud = x278_selectedHud.GetObj();
|
||||
x288_loadedSelectedHud->Reset();
|
||||
x288_loadedSelectedHud->SetMaxAspect(1.78f);
|
||||
x2b8_curState = x2bc_nextState;
|
||||
x2bc_nextState = x2c0_setState;
|
||||
|
|
|
@ -408,6 +408,9 @@ CSpacePirate::CSpacePirate(TUniqueId uid, std::string_view name, const CEntityIn
|
|||
else if (GetDamageVulnerability()->WeaponHurts(CWeaponMode(EWeaponType::Wave), false))
|
||||
x8cc_trooperColor = zeus::CColor(0.776f, 0.054f, 1.f, 1.f);
|
||||
}
|
||||
|
||||
x568_pirateData.x20_Projectile.Token().Lock();
|
||||
x568_pirateData.x6c_KneelAttackShot.Token().Lock();
|
||||
}
|
||||
|
||||
void CSpacePirate::Accept(IVisitor& visitor) { visitor.Visit(this); }
|
||||
|
|
|
@ -48,6 +48,8 @@ CScriptSpecialFunction::CScriptSpecialFunction(TUniqueId uid, std::string_view n
|
|||
void CScriptSpecialFunction::Accept(IVisitor& visitor) { visitor.Visit(this); }
|
||||
|
||||
void CScriptSpecialFunction::Think(float dt, CStateManager& mgr) {
|
||||
if (!GetActive())
|
||||
return;
|
||||
switch (xe8_function) {
|
||||
case ESpecialFunction::PlayerFollowLocator:
|
||||
ThinkPlayerFollowLocator(dt, mgr);
|
||||
|
@ -655,6 +657,7 @@ u32 CScriptSpecialFunction::GetSpecialEnding(const CStateManager& mgr) const {
|
|||
return 2;
|
||||
}
|
||||
|
||||
CScriptSpecialFunction::SRingController::SRingController(TUniqueId uid, float f, bool b) : x0_id(uid), x4_rotateSpeed(f), x8_reachedTarget(b) {}
|
||||
CScriptSpecialFunction::SRingController::SRingController(TUniqueId uid, float rotateSpeed, bool reachedTarget)
|
||||
: x0_id(uid), x4_rotateSpeed(rotateSpeed), x8_reachedTarget(reachedTarget) {}
|
||||
|
||||
} // namespace urde
|
||||
|
|
|
@ -65,7 +65,7 @@ public:
|
|||
float x4_rotateSpeed;
|
||||
bool x8_reachedTarget;
|
||||
zeus::CVector3f xc_;
|
||||
SRingController(TUniqueId uid, float f, bool b);
|
||||
SRingController(TUniqueId uid, float rotateSpeed, bool reachedTarget);
|
||||
};
|
||||
|
||||
private:
|
||||
|
|
2
amuse
2
amuse
|
@ -1 +1 @@
|
|||
Subproject commit aa5abd5ff5561f3b105a20046588fa1d8bd7785c
|
||||
Subproject commit e04603bb7dfcdcc59f7cb14a4122b5c22c966716
|
2
hecl
2
hecl
|
@ -1 +1 @@
|
|||
Subproject commit 180d304cfaf7261d7e29d9176a63e1734574d5e5
|
||||
Subproject commit e57b8113abfb6fb256da97bf0acb082acca07dfc
|
2
specter
2
specter
|
@ -1 +1 @@
|
|||
Subproject commit c2d69c84931174f016577369ba47ac1151005ce4
|
||||
Subproject commit a7bd8f8235372b986c8793397398c49173f0c1a3
|
Loading…
Reference in New Issue