| 119 | } |
| 120 | |
| 121 | bool MenuModeLoad::launchSelectedButtonPressed(const CEGUI::EventArgs&) |
| 122 | { |
| 123 | CEGUI::Window* tmpWin = getModeManager().getGui().getGuiSheet(Gui::loadSavedGameMenu)->getChild("LevelWindowFrame/SaveGameSelect"); |
| 124 | CEGUI::Listbox* levelSelectList = static_cast<CEGUI::Listbox*>(tmpWin); |
| 125 | |
| 126 | if(levelSelectList->getSelectedCount() == 0) |
| 127 | { |
| 128 | tmpWin = getModeManager().getGui().getGuiSheet(Gui::loadSavedGameMenu)->getChild("LoadingText"); |
| 129 | tmpWin->setText("Please select a saved game first."); |
| 130 | tmpWin->show(); |
| 131 | return true; |
| 132 | } |
| 133 | |
| 134 | std::string nickname = ConfigManager::getSingleton().getGameValue(Config::NICKNAME, std::string(), false); |
| 135 | if (!nickname.empty()) |
| 136 | ODFrameListener::getSingleton().getClientGameMap()->setLocalPlayerNick(nickname); |
| 137 | |
| 138 | tmpWin = getModeManager().getGui().getGuiSheet(Gui::loadSavedGameMenu)->getChild("LoadingText"); |
| 139 | tmpWin->setText("Loading..."); |
| 140 | tmpWin->show(); |
| 141 | |
| 142 | CEGUI::ListboxItem* selItem = levelSelectList->getFirstSelectedItem(); |
| 143 | int id = selItem->getID(); |
| 144 | |
| 145 | const std::string& level = mFilesList[id]; |
| 146 | // In single player mode, we act as a server |
| 147 | if(!ODServer::getSingleton().startServer(nickname, level, ServerMode::ModeGameLoaded, false)) |
| 148 | { |
| 149 | OD_LOG_ERR("Could not start server for single player game !!!"); |
| 150 | tmpWin = getModeManager().getGui().getGuiSheet(Gui::loadSavedGameMenu)->getChild("LoadingText"); |
| 151 | tmpWin->setText("ERROR: Could not start server for single player game !!!"); |
| 152 | tmpWin->show(); |
| 153 | return true; |
| 154 | } |
| 155 | |
| 156 | int port = ODServer::getSingleton().getNetworkPort(); |
| 157 | uint32_t timeout = ConfigManager::getSingleton().getClientConnectionTimeout(); |
| 158 | std::string replayFilename = ResourceManager::getSingleton().getReplayDataPath() |
| 159 | + ResourceManager::getSingleton().buildReplayFilename(); |
| 160 | if(!ODClient::getSingleton().connect("localhost", port, timeout, replayFilename)) |
| 161 | { |
| 162 | OD_LOG_ERR("Could not connect to server for single player game !!!"); |
| 163 | tmpWin = getModeManager().getGui().getGuiSheet(Gui::loadSavedGameMenu)->getChild("LoadingText"); |
| 164 | tmpWin->setText("Error: Couldn't connect to local server!"); |
| 165 | tmpWin->show(); |
| 166 | return true; |
| 167 | } |
| 168 | return true; |
| 169 | } |
| 170 | |
| 171 | bool MenuModeLoad::deleteSelectedButtonPressed(const CEGUI::EventArgs&) |
| 172 | { |
nothing calls this directly
no test coverage detected