| 278 | } |
| 279 | |
| 280 | void SaveMenu::tryToSaveGame(const UString &saveName, sp<Control> parent) |
| 281 | { |
| 282 | if (parent->Name == newSaveItemId) |
| 283 | { |
| 284 | if (saveManager.newSaveGame(saveName, currentState)) |
| 285 | { |
| 286 | fw().stageQueueCommand({StageCmd::Command::POP}); |
| 287 | } |
| 288 | else |
| 289 | { |
| 290 | clearTextEdit(activeTextEdit); |
| 291 | } |
| 292 | } |
| 293 | else |
| 294 | { |
| 295 | sp<SaveMetadata> slot = parent->getData<SaveMetadata>(); |
| 296 | std::function<void()> onSuccess = std::function<void()>([this, slot, saveName] { |
| 297 | if (saveManager.overrideGame(*slot, saveName, currentState)) |
| 298 | { |
| 299 | fw().stageQueueCommand({StageCmd::Command::POP}); |
| 300 | } |
| 301 | else |
| 302 | { |
| 303 | clearTextEdit(activeTextEdit); |
| 304 | } |
| 305 | }); |
| 306 | std::function<void()> onCancel = |
| 307 | std::function<void()>([this] { clearTextEdit(activeTextEdit); }); |
| 308 | sp<MessageBox> messageBox = mksp<MessageBox>(MessageBox( |
| 309 | "Override saved game", "Do you really want to override " + slot->getName() + "?", |
| 310 | MessageBox::ButtonOptions::YesNo, std::move(onSuccess), std::move(onCancel))); |
| 311 | |
| 312 | fw().stageQueueCommand({StageCmd::Command::PUSH, messageBox}); |
| 313 | } |
| 314 | } |
| 315 | |
| 316 | void SaveMenu::tryToDeleteSavedGame(sp<Control> &slotControl) |
| 317 | { |
nothing calls this directly
no test coverage detected