link selected item in the demo list to the first entry (if available) on startup and browse

This commit is contained in:
oy 2010-09-05 14:28:08 +02:00
parent 8f3e98208e
commit 62fe7cd5b2

View file

@ -440,10 +440,15 @@ void CMenus::DemolistPopulate()
void CMenus::RenderDemoList(CUIRect MainView) void CMenus::RenderDemoList(CUIRect MainView)
{ {
static int s_SelectedItem = -1;
static int s_Inited = 0; static int s_Inited = 0;
if(!s_Inited) if(!s_Inited)
{
DemolistPopulate(); DemolistPopulate();
s_Inited = 1; s_Inited = 1;
if(m_lDemos.size() > 0)
s_SelectedItem = 0;
}
// render background // render background
RenderTools()->DrawUIRect(&MainView, ms_ColorTabbarActive, CUI::CORNER_ALL, 10.0f); 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); MainView.HSplitBottom(ms_ButtonHeight+5.0f, &MainView, &ButtonBar);
ButtonBar.HSplitTop(5.0f, 0, &ButtonBar); ButtonBar.HSplitTop(5.0f, 0, &ButtonBar);
static int s_SelectedItem = -1;
static int s_DemoListId = 0; static int s_DemoListId = 0;
static float s_ScrollValue = 0; static float s_ScrollValue = 0;
@ -501,7 +505,7 @@ void CMenus::RenderDemoList(CUIRect MainView)
{ {
DemoSetParentDirectory(); DemoSetParentDirectory();
DemolistPopulate(); DemolistPopulate();
s_SelectedItem = -1; s_SelectedItem = m_lDemos.size() > 0 ? 0 : -1;
} }
else if(IsDir) //folder else if(IsDir) //folder
{ {
@ -509,7 +513,7 @@ void CMenus::RenderDemoList(CUIRect MainView)
str_copy(aTemp, m_aCurrentDemoFolder, sizeof(aTemp)); str_copy(aTemp, m_aCurrentDemoFolder, sizeof(aTemp));
str_format(m_aCurrentDemoFolder, sizeof(m_aCurrentDemoFolder), "%s/%s", aTemp, m_lDemos[s_SelectedItem].m_aName); str_format(m_aCurrentDemoFolder, sizeof(m_aCurrentDemoFolder), "%s/%s", aTemp, m_lDemos[s_SelectedItem].m_aName);
DemolistPopulate(); DemolistPopulate();
s_SelectedItem = 0; s_SelectedItem = m_lDemos.size() > 0 ? 0 : -1;
} }
else //file else //file
{ {