Use std::vector<CMenuImage> instead of array

This commit is contained in:
Robert Müller 2022-05-23 22:48:56 +02:00
parent 24ad383211
commit ce54a0d075
2 changed files with 7 additions and 9 deletions

View file

@ -1053,7 +1053,7 @@ void CMenus::OnInit()
m_IsInit = true; m_IsInit = true;
// load menu images // load menu images
m_lMenuImages.clear(); m_vMenuImages.clear();
Storage()->ListDirectory(IStorage::TYPE_ALL, "menuimages", MenuImageScan, this); Storage()->ListDirectory(IStorage::TYPE_ALL, "menuimages", MenuImageScan, this);
} }
@ -2762,7 +2762,7 @@ int CMenus::MenuImageScan(const char *pName, int IsDir, int DirType, void *pUser
// set menu image data // set menu image data
str_truncate(MenuImage.m_aName, sizeof(MenuImage.m_aName), pName, str_length(pName) - 4); str_truncate(MenuImage.m_aName, sizeof(MenuImage.m_aName), pName, str_length(pName) - 4);
pSelf->m_lMenuImages.add(MenuImage); pSelf->m_vMenuImages.push_back(MenuImage);
pSelf->RenderLoading(true); pSelf->RenderLoading(true);
return 0; return 0;
@ -2770,12 +2770,10 @@ int CMenus::MenuImageScan(const char *pName, int IsDir, int DirType, void *pUser
const CMenus::CMenuImage *CMenus::FindMenuImage(const char *pName) const CMenus::CMenuImage *CMenus::FindMenuImage(const char *pName)
{ {
for(int i = 0; i < m_lMenuImages.size(); i++) for(auto &Image : m_vMenuImages)
{ if(str_comp(Image.m_aName, pName) == 0)
if(str_comp(m_lMenuImages[i].m_aName, pName) == 0) return &Image;
return &m_lMenuImages[i]; return nullptr;
}
return 0;
} }
void CMenus::SetMenuPage(int NewPage) void CMenus::SetMenuPage(int NewPage)

View file

@ -296,7 +296,7 @@ protected:
IGraphics::CTextureHandle m_OrgTexture; IGraphics::CTextureHandle m_OrgTexture;
IGraphics::CTextureHandle m_GreyTexture; IGraphics::CTextureHandle m_GreyTexture;
}; };
array<CMenuImage> m_lMenuImages; std::vector<CMenuImage> m_vMenuImages;
static int MenuImageScan(const char *pName, int IsDir, int DirType, void *pUser); static int MenuImageScan(const char *pName, int IsDir, int DirType, void *pUser);