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

Method refreshList

source/modes/MenuModeMasterServerJoin.cpp:114–167  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

112}
113
114void MenuModeMasterServerJoin::refreshList()
115{
116 Gui& gui = getModeManager().getGui();
117 CEGUI::Window* mainWin = gui.getGuiSheet(Gui::guiSheet::multiMasterServerJoinMenu);
118 CEGUI::MultiColumnList* levelSelectList = static_cast<CEGUI::MultiColumnList*>(
119 mainWin->getChild("LevelWindowFrame/LevelSelect"));
120
121 // If an item is already selected in the list, we save it so that it is selected
122 // again once we refresh (if still available)
123 std::string selUuid;
124 if(levelSelectList->getSelectedCount() > 0)
125 {
126 CEGUI::ListboxItem* selItem = levelSelectList->getFirstSelectedItem();
127 uint32_t id = selItem->getID();
128
129 if(id >= mMasterServerGames.size())
130 {
131 OD_LOG_ERR("index too high=" + Helper::toString(id) + ", size=" + Helper::toString(mMasterServerGames.size()));
132 return;
133 }
134
135 MasterServerGame& selGame = mMasterServerGames[id];
136 selUuid = selGame.mUuid;
137 }
138
139 levelSelectList->resetList();
140 mMasterServerGames.clear();
141
142 if(MasterServer::fillMasterServerGames(ODApplication::VERSION, mMasterServerGames))
143 {
144 uint32_t id = 0;
145 for(MasterServerGame& game : mMasterServerGames)
146 {
147 uint32_t rowIndex = levelSelectList->addRow(id);
148 CEGUI::ListboxTextItem* item0 = new CEGUI::ListboxTextItem(game.mCreator);
149 item0->setSelectionBrushImage("OpenDungeonsSkin/SelectionBrush");
150 item0->setID(id);
151 levelSelectList->setItem(item0, 0, rowIndex);
152 CEGUI::ListboxTextItem* item1 = new CEGUI::ListboxTextItem(game.mLabel);
153 item1->setSelectionBrushImage("OpenDungeonsSkin/SelectionBrush");
154 item1->setID(id);
155 levelSelectList->setItem(item1, 1, rowIndex);
156 if(!selUuid.empty() && (selUuid.compare(game.mUuid) == 0))
157 {
158 levelSelectList->setItemSelectState(item0, true);
159 levelSelectList->setItemSelectState(item1, true);
160 }
161
162 ++id;
163 }
164 }
165
166 mTimeSinceLastUpdateList = 0;
167}
168
169void MenuModeMasterServerJoin::onFrameStarted(const Ogre::FrameEvent& evt)
170{

Callers

nothing calls this directly

Calls 4

fillMasterServerGamesFunction · 0.85
getGuiSheetMethod · 0.80
clearMethod · 0.80
toStringFunction · 0.50

Tested by

no test coverage detected