about summary refs log tree commit diff
diff options
context:
space:
mode:
authorChoupom <andycootlapin@hotmail.fr>2010-11-20 14:45:09 +0100
committeroy <Tom_Adams@web.de>2010-11-20 21:34:13 +0100
commit38c2a1b45c9a896184c44ab5976559984a2a9ba5 (patch)
treecc0bd7fe8cf8e7c720f5db0fe8a29e2c8590a97c
parentfc9211c7774a0d2d755addfb82b7a02047a6568a (diff)
downloadzcatch-38c2a1b45c9a896184c44ab5976559984a2a9ba5.tar.gz
zcatch-38c2a1b45c9a896184c44ab5976559984a2a9ba5.zip
fixed so every demo infos are not loaded when making the demos list
-rw-r--r--src/game/client/components/menus.h2
-rw-r--r--src/game/client/components/menus_demo.cpp24
2 files changed, 18 insertions, 8 deletions
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<int>(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