|
28 | 28 | #include "../Interface/Text.h" |
29 | 29 | #include "../Interface/TextButton.h" |
30 | 30 | #include "../Mod/Mod.h" |
| 31 | +#include "../Mod/ArticleDefinition.h" |
31 | 32 |
|
32 | 33 | namespace OpenXcom |
33 | | -{ |
34 | | - const std::string UfopaediaStartState::SECTIONS[] = {UFOPAEDIA_XCOM_CRAFT_ARMAMENT, |
35 | | - UFOPAEDIA_HEAVY_WEAPONS_PLATFORMS, |
36 | | - UFOPAEDIA_WEAPONS_AND_EQUIPMENT, |
37 | | - UFOPAEDIA_ALIEN_ARTIFACTS, |
38 | | - UFOPAEDIA_BASE_FACILITIES, |
39 | | - UFOPAEDIA_ALIEN_LIFE_FORMS, |
40 | | - UFOPAEDIA_ALIEN_RESEARCH, |
41 | | - UFOPAEDIA_UFO_COMPONENTS, |
42 | | - UFOPAEDIA_UFOS, |
43 | | - UFOPAEDIA_COMMENDATIONS}; |
44 | | - |
| 34 | +{ |
45 | 35 | UfopaediaStartState::UfopaediaStartState() |
46 | 36 | { |
47 | | - // Modify the Ufopaedia in case the commendations mod is enabled or not. |
48 | | - bool commendations = false; |
49 | | - _commendationsYAdjustment = 0; |
50 | | - if (!_game->getMod()->getCommendation().empty()) |
51 | | - { |
52 | | - commendations = true; |
53 | | - _commendationsYAdjustment = 7; |
54 | | - } |
55 | | - |
56 | 37 | _screen = false; |
57 | 38 |
|
58 | 39 | // set background window |
59 | | - _window = new Window(this, 256, 180 + 2*_commendationsYAdjustment, 32, 10 - _commendationsYAdjustment, POPUP_BOTH); |
| 40 | + _window = new Window(this, 256, 180, 32, 10, POPUP_BOTH); |
60 | 41 |
|
61 | 42 | // set title |
62 | | - _txtTitle = new Text(224, 17, 48, 33 - _commendationsYAdjustment); |
| 43 | + _txtTitle = new Text(224, 17, 48, 33); |
63 | 44 |
|
64 | 45 | // Set palette |
65 | 46 | setInterface("ufopaedia"); |
66 | 47 |
|
67 | | - |
68 | 48 | add(_window, "window", "ufopaedia"); |
69 | 49 | add(_txtTitle, "text", "ufopaedia"); |
| 50 | + |
| 51 | + _btnOk = new TextButton(224, 12, 48, 167); |
| 52 | + add(_btnOk, "button1", "ufopaedia"); |
| 53 | + |
70 | 54 | // set buttons |
71 | | - int y = 50 - _commendationsYAdjustment; |
72 | | - for (int i = 0; i < NUM_SECTIONS; ++i) |
| 55 | + const std::vector<std::string> &list = _game->getMod()->getUfopaediaCategoryList(); |
| 56 | + int y = 50; |
| 57 | + y -= 13 * (list.size() - 9); |
| 58 | + for (std::vector<std::string>::const_iterator i = list.begin(); i != list.end(); ++i) |
73 | 59 | { |
74 | | - if (!commendations && SECTIONS[i] == UFOPAEDIA_COMMENDATIONS) |
75 | | - { |
76 | | - continue; |
77 | | - } |
78 | | - _btnSection[i] = new TextButton(224, 12, 48, y); |
| 60 | + TextButton *button = new TextButton(224, 12, 48, y); |
79 | 61 | y += 13; |
80 | 62 |
|
81 | | - add(_btnSection[i], "button1", "ufopaedia"); |
| 63 | + add(button, "button1", "ufopaedia"); |
82 | 64 |
|
83 | | - _btnSection[i]->setText(tr(SECTIONS[i])); |
84 | | - _btnSection[i]->onMouseClick((ActionHandler)&UfopaediaStartState::btnSectionClick); |
| 65 | + button->setText(tr(*i)); |
| 66 | + button->onMouseClick((ActionHandler)&UfopaediaStartState::btnSectionClick); |
| 67 | + |
| 68 | + _btnSections.push_back(button); |
85 | 69 | } |
86 | | - _btnOk = new TextButton(224, 12, 48, y); |
87 | | - add(_btnOk, "button1", "ufopaedia"); |
| 70 | + _txtTitle->setY(_btnSections.front()->getY() - _txtTitle->getHeight()); |
88 | 71 |
|
89 | 72 | centerAllSurfaces(); |
90 | 73 |
|
@@ -118,11 +101,12 @@ namespace OpenXcom |
118 | 101 | */ |
119 | 102 | void UfopaediaStartState::btnSectionClick(Action *action) |
120 | 103 | { |
121 | | - for (int i = 0; i < NUM_SECTIONS; ++i) |
| 104 | + const std::vector<std::string> &list = _game->getMod()->getUfopaediaCategoryList(); |
| 105 | + for (size_t i = 0; i < list.size(); ++i) |
122 | 106 | { |
123 | | - if (action->getSender() == _btnSection[i]) |
| 107 | + if (action->getSender() == _btnSections[i]) |
124 | 108 | { |
125 | | - _game->pushState(new UfopaediaSelectState(SECTIONS[i], _commendationsYAdjustment)); |
| 109 | + _game->pushState(new UfopaediaSelectState(list[i])); |
126 | 110 | break; |
127 | 111 | } |
128 | 112 | } |
|
0 commit comments