From: Perttu Ahola Date: Thu, 2 May 2013 16:07:44 +0000 (+0300) Subject: Pre-select current game in world creation dialog X-Git-Tag: 0.4.7~29^2~31 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=refs%2Fpull%2F698%2Fhead;p=oweals%2Fminetest.git Pre-select current game in world creation dialog --- diff --git a/src/guiCreateWorld.cpp b/src/guiCreateWorld.cpp index 09b18fb3c..caa884bc0 100644 --- a/src/guiCreateWorld.cpp +++ b/src/guiCreateWorld.cpp @@ -42,13 +42,22 @@ GUICreateWorld::GUICreateWorld(gui::IGUIEnvironment* env, gui::IGUIElement* parent, s32 id, IMenuManager *menumgr, CreateWorldDest *dest, - const std::vector &games + const std::vector &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; iaddItem(os.str().c_str()); } - e->setSelected(0); + e->setSelected(m_initial_game_i); } changeCtype(""); { diff --git a/src/guiCreateWorld.h b/src/guiCreateWorld.h index d9bc3638a..2765dc2bd 100644 --- a/src/guiCreateWorld.h +++ b/src/guiCreateWorld.h @@ -38,7 +38,8 @@ public: gui::IGUIElement* parent, s32 id, IMenuManager *menumgr, CreateWorldDest *dest, - const std::vector &games); + const std::vector &games, + const std::string &initial_game); ~GUICreateWorld(); void removeChildren(); @@ -56,6 +57,7 @@ public: private: CreateWorldDest *m_dest; std::vector m_games; + int m_initial_game_i; }; #endif diff --git a/src/guiMainMenu.cpp b/src/guiMainMenu.cpp index 2e7fb955d..c6142d4ce 100644 --- a/src/guiMainMenu.cpp +++ b/src/guiMainMenu.cpp @@ -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;