Fix game selection in world creation (used always the first one)
authorPerttu Ahola <celeron55@gmail.com>
Mon, 12 Mar 2012 22:58:57 +0000 (00:58 +0200)
committerPerttu Ahola <celeron55@gmail.com>
Mon, 12 Mar 2012 22:58:57 +0000 (00:58 +0200)
src/guiCreateWorld.cpp

index 7143f9558f464d711818e7fc3965fcea3b15b29c..159e736c36e5d929a109ff3c93661b64b2dedb66 100644 (file)
@@ -184,11 +184,20 @@ void GUICreateWorld::acceptInput()
 {
        if(m_dest)
        {
-               gui::IGUIElement *e = getElementFromId(GUI_ID_NAME_INPUT);
-               if(e != NULL)
+               int selected = -1;
+               {
+                       gui::IGUIElement *e = getElementFromId(GUI_ID_GAME_LISTBOX);
+                       if(e != NULL && e->getType() == gui::EGUIET_LIST_BOX)
+                               selected = ((gui::IGUIListBox*)e)->getSelected();
+               }
+               std::wstring name;
                {
-                       m_dest->accepted(e->getText(), m_games[0].id);
+                       gui::IGUIElement *e = getElementFromId(GUI_ID_NAME_INPUT);
+                       if(e != NULL)
+                               name = e->getText();
                }
+               if(selected != -1 && name != L"")
+                       m_dest->accepted(name, m_games[selected].id);
                delete m_dest;
                m_dest = NULL;
        }