| 37 | SaveMenu::~SaveMenu() = default; |
| 38 | |
| 39 | void SaveMenu::begin() |
| 40 | { |
| 41 | if (currentState) |
| 42 | { |
| 43 | menuform->findControlTyped<Label>("TEXT_FUNDS")->setText(currentState->getPlayerBalance()); |
| 44 | } |
| 45 | |
| 46 | auto saveListBox = menuform->findControlTyped<ListBox>("LISTBOX_OPTIONS"); |
| 47 | |
| 48 | UString titleLabelName; |
| 49 | bool newItemSlotVisible = false; |
| 50 | bool showAutoSaves = false; |
| 51 | switch (currentAction) |
| 52 | { |
| 53 | case SaveMenuAction::LoadNewGame: |
| 54 | case SaveMenuAction::Load: |
| 55 | titleLabelName = "LABEL_LOADGAME"; |
| 56 | showAutoSaves = true; |
| 57 | break; |
| 58 | case SaveMenuAction::Save: |
| 59 | titleLabelName = "LABEL_SAVEGAME"; |
| 60 | newItemSlotVisible = true; |
| 61 | break; |
| 62 | case SaveMenuAction::Delete: |
| 63 | titleLabelName = "LABEL_DELETEGAME"; |
| 64 | break; |
| 65 | } |
| 66 | |
| 67 | if (!titleLabelName.empty()) |
| 68 | { |
| 69 | auto label = menuform->findControlTyped<Label>(titleLabelName); |
| 70 | if (label) |
| 71 | { |
| 72 | label->setVisible(true); |
| 73 | } |
| 74 | } |
| 75 | |
| 76 | if (newItemSlotVisible == true) |
| 77 | { |
| 78 | auto newItemSlot = saveListBox->findControl(newSaveItemId); |
| 79 | if (newItemSlot != nullptr) |
| 80 | { |
| 81 | newItemSlot->setVisible(true); |
| 82 | } |
| 83 | } |
| 84 | |
| 85 | // load menu items |
| 86 | auto saves = saveManager.getSaveList(); |
| 87 | auto existingSlotControl = saveListBox->findControl(existingSaveItemId); |
| 88 | if (existingSlotControl != nullptr) |
| 89 | { |
| 90 | for (auto it = saves.begin(); it != saves.end(); ++it) |
| 91 | { |
| 92 | if (it->getType() != SaveType::Manual && !showAutoSaves) |
| 93 | { // skip quicksave and autosave on save screen |
| 94 | continue; |
| 95 | } |
| 96 |
nothing calls this directly
no test coverage detected