| 193 | } |
| 194 | |
| 195 | bool MenuModeSkirmish::launchSelectedButtonPressed(const CEGUI::EventArgs&) |
| 196 | { |
| 197 | CEGUI::Window* mainWin = getModeManager().getGui().getGuiSheet(Gui::skirmishMenu); |
| 198 | CEGUI::Listbox* levelSelectList = static_cast<CEGUI::Listbox*>(mainWin->getChild(Gui::SKM_LIST_LEVELS)); |
| 199 | |
| 200 | if(levelSelectList->getSelectedCount() == 0) |
| 201 | { |
| 202 | mainWin->getChild(Gui::SKM_TEXT_LOADING)->setText("Please select a level first."); |
| 203 | return true; |
| 204 | } |
| 205 | |
| 206 | mainWin->getChild(Gui::SKM_TEXT_LOADING)->setText("Loading..."); |
| 207 | |
| 208 | CEGUI::ListboxItem* selItem = levelSelectList->getFirstSelectedItem(); |
| 209 | int id = selItem->getID(); |
| 210 | |
| 211 | const std::string& level = mFilesList[id]; |
| 212 | // In single player mode, we act as a server |
| 213 | const std::string& nickname = ODFrameListener::getSingleton().getClientGameMap()->getLocalPlayerNick(); |
| 214 | if(!ODServer::getSingleton().startServer(nickname, level, ServerMode::ModeGameSinglePlayer, false)) |
| 215 | { |
| 216 | OD_LOG_ERR("Could not start server for single player game !!!"); |
| 217 | mainWin->getChild(Gui::SKM_TEXT_LOADING)->setText("ERROR: Could not start server for single player game !!!"); |
| 218 | return true; |
| 219 | } |
| 220 | |
| 221 | int port = ODServer::getSingleton().getNetworkPort(); |
| 222 | uint32_t timeout = ConfigManager::getSingleton().getClientConnectionTimeout(); |
| 223 | std::string replayFilename = ResourceManager::getSingleton().getReplayDataPath() |
| 224 | + ResourceManager::getSingleton().buildReplayFilename(); |
| 225 | if(!ODClient::getSingleton().connect("localhost", port, timeout, replayFilename)) |
| 226 | { |
| 227 | OD_LOG_ERR("Could not connect to server for single player game !!!"); |
| 228 | mainWin->getChild(Gui::SKM_TEXT_LOADING)->setText("Error: Couldn't connect to local server!"); |
| 229 | return true; |
| 230 | } |
| 231 | return true; |
| 232 | } |
| 233 | |
| 234 | bool MenuModeSkirmish::updateDescription(const CEGUI::EventArgs&) |
| 235 | { |
nothing calls this directly
no test coverage detected