MCPcopy Create free account
hub / github.com/OpenDungeons/OpenDungeons / updateFilesList

Method updateFilesList

source/modes/MenuModeMultiplayerServer.cpp:133–189  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

131}
132
133bool MenuModeMultiplayerServer::updateFilesList(const CEGUI::EventArgs&)
134{
135 CEGUI::Window* window = getModeManager().getGui().getGuiSheet(Gui::guiSheet::multiplayerServerMenu);
136 CEGUI::Listbox* levelSelectList = static_cast<CEGUI::Listbox*>(window->getChild(Gui::MPM_LIST_LEVELS));
137
138 CEGUI::Combobox* levelTypeCb = static_cast<CEGUI::Combobox*>(window->getChild(MPM_LIST_LEVEL_TYPES));
139
140 CEGUI::Window* loadText = window->getChild(Gui::MPM_TEXT_LOADING);
141 loadText->setText("");
142 mFilesList.clear();
143 mDescriptionList.clear();
144 levelSelectList->resetList();
145
146 std::string levelPath;
147 size_t selection = levelTypeCb->getItemIndex(levelTypeCb->getSelectedItem());
148 switch (selection)
149 {
150 default:
151 case 0:
152 levelPath = ResourceManager::getSingleton().getGameLevelPathMultiplayer();
153 break;
154 case 1:
155 levelPath = ResourceManager::getSingleton().getUserLevelPathMultiplayer();
156 break;
157 }
158
159 if(Helper::fillFilesList(levelPath, mFilesList, MapHandler::LEVEL_EXTENSION))
160 {
161 for (uint32_t n = 0; n < mFilesList.size(); ++n)
162 {
163 std::string filename = mFilesList[n];
164
165 LevelInfo levelInfo;
166 std::string mapName;
167 std::string mapDescription;
168 if(MapHandler::getMapInfo(filename, levelInfo))
169 {
170 mapName = levelInfo.mLevelName;
171 mapDescription = levelInfo.mLevelDescription;
172 }
173 else
174 {
175 mapName = "invalid map";
176 mapDescription = "invalid map";
177 }
178
179 mDescriptionList.push_back(mapDescription);
180 CEGUI::ListboxTextItem* item = new CEGUI::ListboxTextItem(mapName);
181 item->setID(n);
182 item->setSelectionBrushImage("OpenDungeonsSkin/SelectionBrush");
183 levelSelectList->addItem(item);
184 }
185 }
186
187 updateDescription();
188 return true;
189}
190

Callers

nothing calls this directly

Calls 7

fillFilesListFunction · 0.85
getMapInfoFunction · 0.85
getGuiSheetMethod · 0.80
setTextMethod · 0.80
clearMethod · 0.80

Tested by

no test coverage detected