From 38c2a1b45c9a896184c44ab5976559984a2a9ba5 Mon Sep 17 00:00:00 2001 From: Choupom Date: Sat, 20 Nov 2010 14:45:09 +0100 Subject: fixed so every demo infos are not loaded when making the demos list --- src/game/client/components/menus.h | 2 ++ src/game/client/components/menus_demo.cpp | 24 ++++++++++++++++-------- 2 files changed, 18 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/game/client/components/menus.h b/src/game/client/components/menus.h index 0c6686cd..8efb7969 100644 --- a/src/game/client/components/menus.h +++ b/src/game/client/components/menus.h @@ -162,6 +162,8 @@ class CMenus : public CComponent char m_aName[128]; bool m_IsDir; int m_StorageType; + + bool m_InfosLoaded; bool m_Valid; char m_aMap[64]; diff --git a/src/game/client/components/menus_demo.cpp b/src/game/client/components/menus_demo.cpp index 4918fcfe..86cfde87 100644 --- a/src/game/client/components/menus_demo.cpp +++ b/src/game/client/components/menus_demo.cpp @@ -445,10 +445,7 @@ void CMenus::DemolistFetchCallback(const char *pName, int IsDir, int StorageType else { str_copy(Item.m_aName, pName, min(static_cast(sizeof(Item.m_aName)), Length)); - char aBuffer[512]; - str_format(aBuffer, sizeof(aBuffer), "%s/%s", pSelf->m_aCurrentDemoFolder, Item.m_aFilename); - // TODO: many items slow this down, don't load the info from every file when making the filelist - Item.m_Valid = pSelf->DemoPlayer()->GetDemoInfo(pSelf->Storage(), aBuffer, StorageType, Item.m_aMap, sizeof(Item.m_aMap)); + Item.m_InfosLoaded = false; } Item.m_IsDir = IsDir != 0; Item.m_StorageType = StorageType; @@ -497,14 +494,25 @@ void CMenus::RenderDemoList(CUIRect MainView) char aFooterLabel[128] = {0}; if(m_DemolistSelectedIndex >= 0) { - if(str_comp(m_lDemos[m_DemolistSelectedIndex].m_aFilename, "..") == 0) + CDemoItem *Item = &m_lDemos[m_DemolistSelectedIndex]; + if(str_comp(Item->m_aFilename, "..") == 0) str_copy(aFooterLabel, Localize("Parent Folder"), sizeof(aFooterLabel)); else if(m_DemolistSelectedIsDir) str_copy(aFooterLabel, Localize("Folder"), sizeof(aFooterLabel)); - else if(!m_lDemos[m_DemolistSelectedIndex].m_Valid) - str_copy(aFooterLabel, Localize("Invalid Demo"), sizeof(aFooterLabel)); else - str_format(aFooterLabel, sizeof(aFooterLabel), "%s: %s", Localize("Map"), m_lDemos[m_DemolistSelectedIndex].m_aMap); + { + if(!Item->m_InfosLoaded) + { + char aBuffer[512]; + str_format(aBuffer, sizeof(aBuffer), "%s/%s", m_aCurrentDemoFolder, Item->m_aFilename); + Item->m_Valid = DemoPlayer()->GetDemoInfo(Storage(), aBuffer, Item->m_StorageType, Item->m_aMap, sizeof(Item->m_aMap)); + Item->m_InfosLoaded = true; + } + if(!Item->m_Valid) + str_copy(aFooterLabel, Localize("Invalid Demo"), sizeof(aFooterLabel)); + else + str_format(aFooterLabel, sizeof(aFooterLabel), "%s: %s", Localize("Map"), Item->m_aMap); + } } // render background -- cgit 1.4.1