MCPcopy Create free account
hub / github.com/OpenApoc/OpenApoc / loadWithWarning

Method loadWithWarning

game/ui/general/savemenu.cpp:223–253  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

221}
222
223void SaveMenu::loadWithWarning(sp<Control> parent)
224{
225 if (parent->Name == existingSaveItemId)
226 {
227 sp<SaveMetadata> slot = parent->getData<SaveMetadata>();
228 if (slot != nullptr)
229 {
230 std::function<void()> onSuccess = std::function<void()>([this, slot] {
231 auto state = mksp<GameState>();
232 auto task = saveManager.loadGame(*slot, state);
233 fw().stageQueueCommand(
234 {StageCmd::Command::PUSH,
235 mksp<LoadingScreen>(nullptr, std::move(task), [state]() -> sp<Stage> {
236 if (state->current_battle)
237 {
238 return mksp<BattleView>(state);
239 }
240 else
241 {
242 return mksp<CityView>(state);
243 }
244 })});
245 });
246 sp<MessageBox> messageBox = mksp<MessageBox>(
247 MessageBox("Load game", "Unsaved progress will be lost. Continue?",
248 MessageBox::ButtonOptions::YesNo, std::move(onSuccess), nullptr));
249
250 fw().stageQueueCommand({StageCmd::Command::PUSH, messageBox});
251 }
252 }
253}
254
255void SaveMenu::tryToLoadGame(sp<Control> slotControl)
256{

Callers

nothing calls this directly

Calls 3

MessageBoxClass · 0.85
stageQueueCommandMethod · 0.80
loadGameMethod · 0.45

Tested by

no test coverage detected