diff options
author | Perttu Ahola <celeron55@gmail.com> | 2013-02-15 22:06:38 +0200 |
---|---|---|
committer | Perttu Ahola <celeron55@gmail.com> | 2013-05-02 19:43:47 +0300 |
commit | 2708482f1bdb163d61193ebb976e9edc66449356 (patch) | |
tree | cb9d50e775ab65926217cf71469c50fcc68730d5 /src | |
parent | 084be3599a5ef0acba7c341bfd14a4e9801423a2 (diff) | |
download | minetest-2708482f1bdb163d61193ebb976e9edc66449356.tar.gz minetest-2708482f1bdb163d61193ebb976e9edc66449356.tar.bz2 minetest-2708482f1bdb163d61193ebb976e9edc66449356.zip |
Filter worlds by selected game
Diffstat (limited to 'src')
-rw-r--r-- | src/guiMainMenu.cpp | 23 | ||||
-rw-r--r-- | src/guiMainMenu.h | 2 |
2 files changed, 19 insertions, 6 deletions
diff --git a/src/guiMainMenu.cpp b/src/guiMainMenu.cpp index 07efbb62f..2e7fb955d 100644 --- a/src/guiMainMenu.cpp +++ b/src/guiMainMenu.cpp @@ -348,11 +348,17 @@ void GUIMainMenu::regenerateGui(v2u32 screensize) gui::IGUIListBox *e = Environment->addListBox(rect, this, GUI_ID_WORLD_LISTBOX); e->setDrawBackground(true); - for(std::vector<WorldSpec>::const_iterator i = m_data->worlds.begin(); - i != m_data->worlds.end(); i++){ - e->addItem(narrow_to_wide(i->name+" ["+i->gameid+"]").c_str()); + m_world_indices.clear(); + for(size_t wi = 0; wi < m_data->worlds.size(); wi++){ + const WorldSpec &spec = m_data->worlds[wi]; + if(spec.gameid == m_data->selected_game){ + //e->addItem(narrow_to_wide(spec.name+" ["+spec.gameid+"]").c_str()); + e->addItem(narrow_to_wide(spec.name).c_str()); + m_world_indices.push_back(wi); + if(m_data->selected_world == (int)wi) + e->setSelected(m_world_indices.size()-1); + } } - e->setSelected(m_data->selected_world); Environment->setFocus(e); } // Delete world button @@ -1131,8 +1137,13 @@ void GUIMainMenu::readInput(MainMenuData *dst) { gui::IGUIElement *e = getElementFromId(GUI_ID_WORLD_LISTBOX); - if(e != NULL && e->getType() == gui::EGUIET_LIST_BOX) - dst->selected_world = ((gui::IGUIListBox*)e)->getSelected(); + if(e != NULL && e->getType() == gui::EGUIET_LIST_BOX){ + int list_i = ((gui::IGUIListBox*)e)->getSelected(); + if(list_i == -1) + dst->selected_world = -1; + else + dst->selected_world = m_world_indices[list_i]; + } } { ServerListSpec server = diff --git a/src/guiMainMenu.h b/src/guiMainMenu.h index b0c9ff24b..1c5ca4d37 100644 --- a/src/guiMainMenu.h +++ b/src/guiMainMenu.h @@ -130,6 +130,8 @@ private: s32 id; IMenuManager *menumgr; + std::vector<int> m_world_indices; + bool m_is_regenerating; v2s32 m_topleft_client; v2s32 m_size_client; |