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

Method launchSelectedButtonPressed

source/modes/MenuModeEditorLoad.cpp:222–260  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

220}
221
222bool MenuModeEditorLoad::launchSelectedButtonPressed(const CEGUI::EventArgs&)
223{
224 CEGUI::Window* window = getModeManager().getGui().getGuiSheet(Gui::guiSheet::editorLoadMenu);
225 CEGUI::Listbox* levelSelectList = static_cast<CEGUI::Listbox*>(window->getChild(Gui::EDM_LIST_LEVELS));
226
227 if(levelSelectList->getSelectedCount() == 0)
228 {
229 window->getChild(Gui::EDM_TEXT_LOADING)->setText("Please select a level first.");
230 return true;
231 }
232
233 window->getChild(Gui::EDM_TEXT_LOADING)->setText("Loading...");
234
235 CEGUI::ListboxItem* selItem = levelSelectList->getFirstSelectedItem();
236 int id = selItem->getID();
237
238 const std::string& level = mFilesList[id];
239
240 // In editor mode, we act as a server
241 ConfigManager& config = ConfigManager::getSingleton();
242 std::string nickname = config.getGameValue(Config::NICKNAME, std::string(), false);
243 if(!ODServer::getSingleton().startServer(nickname, level, ServerMode::ModeEditor, false))
244 {
245 OD_LOG_ERR("Could not start server for editor !!!");
246 window->getChild(Gui::EDM_TEXT_LOADING)->setText("ERROR: Could not start server for editor !!!");
247 }
248
249 int port = ODServer::getSingleton().getNetworkPort();
250 uint32_t timeout = ConfigManager::getSingleton().getClientConnectionTimeout();
251 std::string replayFilename = ResourceManager::getSingleton().getReplayDataPath()
252 + ResourceManager::getSingleton().buildReplayFilename();
253 if(!ODClient::getSingleton().connect("localhost", port, timeout, replayFilename))
254 {
255 OD_LOG_ERR("Could not connect to server for editor !!!");
256 window->getChild(Gui::EDM_TEXT_LOADING)->setText("Error: Couldn't connect to local server!");
257 return true;
258 }
259 return true;
260}
261
262bool MenuModeEditorLoad::updateDescription(const CEGUI::EventArgs&)
263{

Callers

nothing calls this directly

Calls 8

getGuiSheetMethod · 0.80
setTextMethod · 0.80
getGameValueMethod · 0.80
buildReplayFilenameMethod · 0.80
startServerMethod · 0.45
getNetworkPortMethod · 0.45
connectMethod · 0.45

Tested by

no test coverage detected