From 85b9c60158adee3aae6d02a9e5529ea57ed39611 Mon Sep 17 00:00:00 2001 From: oy Date: Sat, 9 Oct 2010 13:27:21 +0200 Subject: added info in the demo browser by Choupom --- src/game/client/components/menus_demo.cpp | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) (limited to 'src/game/client/components/menus_demo.cpp') 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(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::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) { -- cgit 1.4.1