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

Method begin

game/ui/general/savemenu.cpp:39–160  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

37SaveMenu::~SaveMenu() = default;
38
39void 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

Callers

nothing calls this directly

Calls 15

getPlayerBalanceMethod · 0.80
emptyMethod · 0.80
findControlMethod · 0.80
getSaveListMethod · 0.80
endMethod · 0.80
setDataMethod · 0.80
getCreationDateMethod · 0.80
getGameTicksMethod · 0.80
getDayMethod · 0.80
getLongTimeStringMethod · 0.80
setTextMethod · 0.45
setVisibleMethod · 0.45

Tested by

no test coverage detected