about summary refs log tree commit diff
path: root/src/game/client
diff options
context:
space:
mode:
authoroy <Tom_Adams@web.de>2010-09-05 14:28:08 +0200
committeroy <Tom_Adams@web.de>2010-09-05 14:28:08 +0200
commit62fe7cd5b2d0c845beae164369e39f5815832af7 (patch)
treec7ca6fab340f23da7f11e2ae618f1cdc1941fcfb /src/game/client
parent8f3e98208ec750276f67e52de24ff00716d2095f (diff)
downloadzcatch-62fe7cd5b2d0c845beae164369e39f5815832af7.tar.gz
zcatch-62fe7cd5b2d0c845beae164369e39f5815832af7.zip
link selected item in the demo list to the first entry (if available) on startup and browse
Diffstat (limited to 'src/game/client')
-rw-r--r--src/game/client/components/menus_demo.cpp12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/game/client/components/menus_demo.cpp b/src/game/client/components/menus_demo.cpp
index b356bb33..ae4873c1 100644
--- a/src/game/client/components/menus_demo.cpp
+++ b/src/game/client/components/menus_demo.cpp
@@ -440,10 +440,15 @@ void CMenus::DemolistPopulate()
 
 void CMenus::RenderDemoList(CUIRect MainView)
 {
+	static int s_SelectedItem = -1;
 	static int s_Inited = 0;
 	if(!s_Inited)
+	{
 		DemolistPopulate();
-	s_Inited = 1;
+		s_Inited = 1;
+		if(m_lDemos.size() > 0)
+			s_SelectedItem = 0;
+	}
 	
 	// render background
 	RenderTools()->DrawUIRect(&MainView, ms_ColorTabbarActive, CUI::CORNER_ALL, 10.0f);
@@ -453,7 +458,6 @@ void CMenus::RenderDemoList(CUIRect MainView)
 	MainView.HSplitBottom(ms_ButtonHeight+5.0f, &MainView, &ButtonBar);
 	ButtonBar.HSplitTop(5.0f, 0, &ButtonBar);
 	
-	static int s_SelectedItem = -1;
 	static int s_DemoListId = 0;
 	static float s_ScrollValue = 0;
 	
@@ -501,7 +505,7 @@ void CMenus::RenderDemoList(CUIRect MainView)
 			{
 				DemoSetParentDirectory();
 				DemolistPopulate();
-				s_SelectedItem = -1;
+				s_SelectedItem = m_lDemos.size() > 0 ? 0 : -1;
 			}
 			else if(IsDir) //folder
 			{
@@ -509,7 +513,7 @@ void CMenus::RenderDemoList(CUIRect MainView)
 				str_copy(aTemp, m_aCurrentDemoFolder, sizeof(aTemp));
 				str_format(m_aCurrentDemoFolder, sizeof(m_aCurrentDemoFolder), "%s/%s", aTemp, m_lDemos[s_SelectedItem].m_aName);
 				DemolistPopulate();
-				s_SelectedItem = 0;
+				s_SelectedItem = m_lDemos.size() > 0 ? 0 : -1;
 			}
 			else //file
 			{