| 220 | } |
| 221 | |
| 222 | bool 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 | |
| 262 | bool MenuModeEditorLoad::updateDescription(const CEGUI::EventArgs&) |
| 263 | { |
nothing calls this directly
no test coverage detected