Extract SSkinTextures::Unload function

This commit is contained in:
Robert Müller 2024-02-06 23:42:11 +01:00
parent fbc4181809
commit e350ceeb16
2 changed files with 15 additions and 19 deletions

View file

@ -310,26 +310,10 @@ void CSkins::OnInit()
void CSkins::Refresh(TSkinLoadedCBFunc &&SkinLoadedFunc)
{
for(const auto &SkinIt : m_Skins)
for(const auto &[_, pSkin] : m_Skins)
{
const auto &pSkin = SkinIt.second;
Graphics()->UnloadTexture(&pSkin->m_OriginalSkin.m_Body);
Graphics()->UnloadTexture(&pSkin->m_OriginalSkin.m_BodyOutline);
Graphics()->UnloadTexture(&pSkin->m_OriginalSkin.m_Feet);
Graphics()->UnloadTexture(&pSkin->m_OriginalSkin.m_FeetOutline);
Graphics()->UnloadTexture(&pSkin->m_OriginalSkin.m_Hands);
Graphics()->UnloadTexture(&pSkin->m_OriginalSkin.m_HandsOutline);
for(auto &Eye : pSkin->m_OriginalSkin.m_aEyes)
Graphics()->UnloadTexture(&Eye);
Graphics()->UnloadTexture(&pSkin->m_ColorableSkin.m_Body);
Graphics()->UnloadTexture(&pSkin->m_ColorableSkin.m_BodyOutline);
Graphics()->UnloadTexture(&pSkin->m_ColorableSkin.m_Feet);
Graphics()->UnloadTexture(&pSkin->m_ColorableSkin.m_FeetOutline);
Graphics()->UnloadTexture(&pSkin->m_ColorableSkin.m_Hands);
Graphics()->UnloadTexture(&pSkin->m_ColorableSkin.m_HandsOutline);
for(auto &Eye : pSkin->m_ColorableSkin.m_aEyes)
Graphics()->UnloadTexture(&Eye);
pSkin->m_OriginalSkin.Unload(Graphics());
pSkin->m_ColorableSkin.Unload(Graphics());
}
m_Skins.clear();

View file

@ -37,6 +37,18 @@ public:
for(auto &Eye : m_aEyes)
Eye = IGraphics::CTextureHandle();
}
void Unload(IGraphics *pGraphics)
{
pGraphics->UnloadTexture(&m_Body);
pGraphics->UnloadTexture(&m_BodyOutline);
pGraphics->UnloadTexture(&m_Feet);
pGraphics->UnloadTexture(&m_FeetOutline);
pGraphics->UnloadTexture(&m_Hands);
pGraphics->UnloadTexture(&m_HandsOutline);
for(auto &Eye : m_aEyes)
pGraphics->UnloadTexture(&Eye);
}
};
SSkinTextures m_OriginalSkin;