MCPcopy Create free account
hub / github.com/ddnet/ddnet / LoadExtrasSkin

Method LoadExtrasSkin

src/game/client/gameclient.cpp:4421–4475  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4419}
4420
4421void CGameClient::LoadExtrasSkin(const char *pPath, bool AsDir)
4422{
4423 if(m_ExtrasSkinLoaded)
4424 {
4425 Graphics()->UnloadTexture(&m_ExtrasSkin.m_SpriteParticleSnowflake);
4426 Graphics()->UnloadTexture(&m_ExtrasSkin.m_SpriteParticleSparkle);
4427 Graphics()->UnloadTexture(&m_ExtrasSkin.m_SpritePulley);
4428 Graphics()->UnloadTexture(&m_ExtrasSkin.m_SpriteHectagon);
4429
4430 for(auto &SpriteParticle : m_ExtrasSkin.m_aSpriteParticles)
4431 SpriteParticle = IGraphics::CTextureHandle();
4432
4433 m_ExtrasSkinLoaded = false;
4434 }
4435
4436 char aPath[IO_MAX_PATH_LENGTH];
4437 bool IsDefault = false;
4438 if(str_comp(pPath, "default") == 0)
4439 {
4440 str_copy(aPath, g_pData->m_aImages[IMAGE_EXTRAS].m_pFilename);
4441 IsDefault = true;
4442 }
4443 else
4444 {
4445 if(AsDir)
4446 str_format(aPath, sizeof(aPath), "assets/extras/%s/%s", pPath, g_pData->m_aImages[IMAGE_EXTRAS].m_pFilename);
4447 else
4448 str_format(aPath, sizeof(aPath), "assets/extras/%s.png", pPath);
4449 }
4450
4451 CImageInfo ImgInfo;
4452 bool PngLoaded = Graphics()->LoadPng(ImgInfo, aPath, IStorage::TYPE_ALL);
4453 if(!PngLoaded && !IsDefault)
4454 {
4455 if(AsDir)
4456 LoadExtrasSkin("default");
4457 else
4458 LoadExtrasSkin(pPath, true);
4459 }
4460 else if(PngLoaded && Graphics()->CheckImageDivisibility(aPath, ImgInfo, g_pData->m_aSprites[SPRITE_PART_SNOWFLAKE].m_pSet->m_Gridx, g_pData->m_aSprites[SPRITE_PART_SNOWFLAKE].m_pSet->m_Gridy, true) && Graphics()->IsImageFormatRgba(aPath, ImgInfo))
4461 {
4462 m_ExtrasSkin.m_SpriteParticleSnowflake = Graphics()->LoadSpriteTexture(ImgInfo, &g_pData->m_aSprites[SPRITE_PART_SNOWFLAKE]);
4463 m_ExtrasSkin.m_SpriteParticleSparkle = Graphics()->LoadSpriteTexture(ImgInfo, &g_pData->m_aSprites[SPRITE_PART_SPARKLE]);
4464 m_ExtrasSkin.m_SpritePulley = Graphics()->LoadSpriteTexture(ImgInfo, &g_pData->m_aSprites[SPRITE_PART_PULLEY]);
4465 m_ExtrasSkin.m_SpriteHectagon = Graphics()->LoadSpriteTexture(ImgInfo, &g_pData->m_aSprites[SPRITE_PART_HECTAGON]);
4466
4467 m_ExtrasSkin.m_aSpriteParticles[0] = m_ExtrasSkin.m_SpriteParticleSnowflake;
4468 m_ExtrasSkin.m_aSpriteParticles[1] = m_ExtrasSkin.m_SpriteParticleSparkle;
4469 m_ExtrasSkin.m_aSpriteParticles[2] = m_ExtrasSkin.m_SpritePulley;
4470 m_ExtrasSkin.m_aSpriteParticles[3] = m_ExtrasSkin.m_SpriteHectagon;
4471
4472 m_ExtrasSkinLoaded = true;
4473 }
4474 ImgInfo.Free();
4475}
4476
4477void CGameClient::RefreshSkin(const std::shared_ptr<CManagedTeeRenderInfo> &pManagedTeeRenderInfo)
4478{

Callers 3

ClearCustomItemsMethod · 0.80
RenderSettingsCustomMethod · 0.80
ConchainAssetExtrasMethod · 0.80

Calls 11

GraphicsFunction · 0.85
CTextureHandleClass · 0.85
str_compFunction · 0.85
str_formatFunction · 0.85
UnloadTextureMethod · 0.80
IsImageFormatRgbaMethod · 0.80
LoadSpriteTextureMethod · 0.80
str_copyFunction · 0.50
LoadPngMethod · 0.45
FreeMethod · 0.45

Tested by

no test coverage detected