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

Method updateFilesList

source/modes/MenuModeSkirmish.cpp:131–193  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 9

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

Tested by

no test coverage detected