Pre-select current game in world creation dialog 698/head
authorPerttu Ahola <celeron55@gmail.com>
Thu, 2 May 2013 16:07:44 +0000 (19:07 +0300)
committerPerttu Ahola <celeron55@gmail.com>
Thu, 2 May 2013 16:43:47 +0000 (19:43 +0300)
src/guiCreateWorld.cpp
src/guiCreateWorld.h
src/guiMainMenu.cpp

index 09b18fb3c7e690708294c31cdeecd8f8522f5365..caa884bc05e7beb36c5cc0e2e4d87946686fec86 100644 (file)
@@ -42,13 +42,22 @@ GUICreateWorld::GUICreateWorld(gui::IGUIEnvironment* env,
                gui::IGUIElement* parent, s32 id,
                IMenuManager *menumgr,
                CreateWorldDest *dest,
-               const std::vector<SubgameSpec> &games
+               const std::vector<SubgameSpec> &games,
+               const std::string &initial_game
 ):
        GUIModalMenu(env, parent, id, menumgr),
        m_dest(dest),
-       m_games(games)
+       m_games(games),
+       m_initial_game_i(0)
 {
        assert(games.size() > 0);
+
+       for(size_t i=0; i<games.size(); i++){
+               if(games[i].id == initial_game){
+                       m_initial_game_i = i;
+                       break;
+               }
+       }
 }
 
 GUICreateWorld::~GUICreateWorld()
@@ -151,7 +160,7 @@ void GUICreateWorld::regenerateGui(v2u32 screensize)
                        os<<L"]";
                        e->addItem(os.str().c_str());
                }
-               e->setSelected(0);
+               e->setSelected(m_initial_game_i);
        }
        changeCtype("");
        {
index d9bc3638a86a60da244ff79e1ce223d7f56bd071..2765dc2bd523c20f5b38531b633b5f7fc2071a5d 100644 (file)
@@ -38,7 +38,8 @@ public:
                        gui::IGUIElement* parent, s32 id,
                        IMenuManager *menumgr,
                        CreateWorldDest *dest,
-                       const std::vector<SubgameSpec> &games);
+                       const std::vector<SubgameSpec> &games,
+                       const std::string &initial_game);
        ~GUICreateWorld();
        
        void removeChildren();
@@ -56,6 +57,7 @@ public:
 private:
        CreateWorldDest *m_dest;
        std::vector<SubgameSpec> m_games;
+       int m_initial_game_i;
 };
 
 #endif
index 2e7fb955d6c03b253c76a7ca7796954d8271f93d..c6142d4ce5a2844972ca7ac6493bbd25cfe9bf2c 100644 (file)
@@ -1274,7 +1274,7 @@ bool GUIMainMenu::OnEvent(const SEvent& event)
                                } else {
                                        CreateWorldDest *dest = new CreateWorldDestMainMenu(this);
                                        GUICreateWorld *menu = new GUICreateWorld(env, parent, -1,
-                                                       menumgr, dest, games);
+                                                       menumgr, dest, games, m_data->selected_game);
                                        menu->drop();
                                }
                                return true;