about summary refs log tree commit diff
path: root/src/game/client/components/menus_demo.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/game/client/components/menus_demo.cpp')
-rw-r--r--src/game/client/components/menus_demo.cpp27
1 files changed, 25 insertions, 2 deletions
diff --git a/src/game/client/components/menus_demo.cpp b/src/game/client/components/menus_demo.cpp
index 9a8a7706..20aee00f 100644
--- a/src/game/client/components/menus_demo.cpp
+++ b/src/game/client/components/menus_demo.cpp
@@ -429,9 +429,19 @@ void CMenus::DemolistFetchCallback(const char *pName, int IsDir, int StorageType
 	CDemoItem Item;
 	str_copy(Item.m_aFilename, pName, sizeof(Item.m_aFilename));
 	if(IsDir)
+	{
 		str_format(Item.m_aName, sizeof(Item.m_aName), "%s/", pName);
+		Item.m_aMap[0] = 0;
+		Item.m_Valid = false;
+	}
 	else
+	{
 		str_format(Item.m_aName, min(static_cast<int>(sizeof(Item.m_aName)), Length), "    %s", pName);
+		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_IsDir = IsDir != 0;
 	Item.m_StorageType = StorageType;
 	pSelf->m_lDemos.add(Item);
@@ -475,6 +485,19 @@ void CMenus::RenderDemoList(CUIRect MainView)
 		}
 		m_DemolistDelEntry = false;
 	}
+
+	char aFooterLabel[128] = {0};

+	if(m_DemolistSelectedIndex >= 0)

+	{

+		if(str_comp(m_lDemos[m_DemolistSelectedIndex].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);

+	}
 	
 	// render background
 	RenderTools()->DrawUIRect(&MainView, ms_ColorTabbarActive, CUI::CORNER_ALL, 10.0f);
@@ -490,7 +513,7 @@ void CMenus::RenderDemoList(CUIRect MainView)
 	
 	static int s_DemoListId = 0;
 	static float s_ScrollValue = 0;
-	UiDoListboxStart(&s_DemoListId, &MainView, 17.0f, Localize("Demos"), "", m_lDemos.size(), 1, m_DemolistSelectedIndex, s_ScrollValue);
+	UiDoListboxStart(&s_DemoListId, &MainView, 17.0f, Localize("Demos"), aFooterLabel, m_lDemos.size(), 1, m_DemolistSelectedIndex, s_ScrollValue);
 	for(sorted_array<CDemoItem>::range r = m_lDemos.all(); !r.empty(); r.pop_front())
 	{
 		CListboxItem Item = UiDoListboxNextItem((void*)(&r.front()));
@@ -507,7 +530,7 @@ void CMenus::RenderDemoList(CUIRect MainView)
 		DemolistPopulate();
 		DemolistOnUpdate(false);
 	}
-	
+
 	static int s_PlayButton = 0;
 	if(DoButton_Menu(&s_PlayButton, m_DemolistSelectedIsDir?Localize("Open"):Localize("Play"), 0, &PlayRect) || Activated)
 	{