mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 10:08:18 +00:00
improved demos listing
This commit is contained in:
parent
27425facff
commit
1cbf731fc0
|
@ -408,30 +408,23 @@ int CMenus::UiDoListboxEnd(float *pScrollValue, bool *pItemActivated)
|
|||
return gs_ListBoxNewSelected;
|
||||
}
|
||||
|
||||
struct FETCH_CALLBACKINFO
|
||||
{
|
||||
CMenus *m_pSelf;
|
||||
const char *m_pPrefix;
|
||||
};
|
||||
|
||||
void CMenus::DemolistFetchCallback(const char *pName, int IsDir, void *pUser)
|
||||
{
|
||||
if(pName[0] == '.')
|
||||
return;
|
||||
|
||||
FETCH_CALLBACKINFO *pInfo = (FETCH_CALLBACKINFO *)pUser;
|
||||
CMenus *pSelf = (CMenus *)pUser;
|
||||
|
||||
CDemoItem Item;
|
||||
str_format(Item.m_aFilename, sizeof(Item.m_aFilename), "%s/%s", pInfo->m_pPrefix, pName);
|
||||
str_format(Item.m_aFilename, sizeof(Item.m_aFilename), "%s/%s/%s", pSelf->Client()->UserDirectory(), pSelf->m_aCurrentDemoFolder, pName);
|
||||
str_copy(Item.m_aName, pName, sizeof(Item.m_aName));
|
||||
pInfo->m_pSelf->m_lDemos.add(Item);
|
||||
pSelf->m_lDemos.add(Item);
|
||||
}
|
||||
|
||||
void CMenus::DemolistPopulate()
|
||||
{
|
||||
m_lDemos.clear();
|
||||
|
||||
|
||||
if(str_comp(m_aCurrentDemoFolder, "demos") != 0) //add parent folder
|
||||
{
|
||||
CDemoItem Item;
|
||||
|
@ -440,14 +433,7 @@ void CMenus::DemolistPopulate()
|
|||
m_lDemos.add(Item);
|
||||
}
|
||||
|
||||
|
||||
char aBuf[512];
|
||||
str_format(aBuf, sizeof(aBuf), "%s/%s", Client()->UserDirectory(), m_aCurrentDemoFolder);
|
||||
|
||||
FETCH_CALLBACKINFO Info = {this, aBuf};
|
||||
fs_listdir(aBuf, DemolistFetchCallback, &Info);
|
||||
Info.m_pPrefix = m_aCurrentDemoFolder;
|
||||
fs_listdir(m_aCurrentDemoFolder, DemolistFetchCallback, &Info);
|
||||
Storage()->ListDirectory(IStorage::TYPE_SAVE, m_aCurrentDemoFolder, DemolistFetchCallback, this);
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue