ScummVM API documentation
gui_v2.h
1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  *
20  */
21 
22 #ifndef KYRA_GUI_V2_H
23 #define KYRA_GUI_V2_H
24 
25 #include "kyra/gui/gui_v1.h"
26 
27 namespace Kyra {
28 
29 #define GUI_V2_BUTTON(button, a, b, c, d, e, f, h, i, j, k, l, m, n, o, p, q, r, s, t) \
30  do { \
31  button.nextButton = 0; \
32  button.index = a; \
33  button.keyCode = b; \
34  button.keyCode2 = c; \
35  button.data0Val1 = d; \
36  button.data1Val1 = e; \
37  button.data2Val1 = f; \
38  button.flags = h; \
39  button.data0ShapePtr = button.data1ShapePtr = button.data2ShapePtr = 0; \
40  button.dimTableIndex = i; \
41  button.x = j; \
42  button.y = k; \
43  button.width = l; \
44  button.height = m; \
45  button.data0Val2 = n; \
46  button.data0Val3 = o; \
47  button.data1Val2 = p; \
48  button.data1Val3 = q; \
49  button.data2Val2 = r; \
50  button.data2Val3 = s; \
51  button.flags2 = t; \
52  button.mouseWheel = 0; \
53  button.arg = 0; \
54  } while (0)
55 
56 #define GUI_V2_MENU(menu, a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q) \
57  do { \
58  menu.x = a; \
59  menu.y = b; \
60  menu.width = c; \
61  menu.height = d; \
62  menu.bkgdColor = e; \
63  menu.color1 = f; \
64  menu.color2 = g; \
65  menu.menuNameId = h; \
66  menu.textColor = i; \
67  menu.titleX = j; \
68  menu.titleY = k; \
69  menu.highlightedItem = l; \
70  menu.numberOfItems = m; \
71  menu.scrollUpButtonX = n; \
72  menu.scrollUpButtonY = o; \
73  menu.scrollDownButtonX = p; \
74  menu.scrollDownButtonY = q; \
75  } while (0)
76 
77 #define GUI_V2_MENU_ITEM(item, a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q) \
78  do { \
79  item.enabled = a; \
80  item.itemId = b; \
81  item.useItemString = false; \
82  item.x = c; \
83  item.y = d; \
84  item.width = e; \
85  item.height = f; \
86  item.textColor = g; \
87  item.highlightColor = h; \
88  item.titleX = i; \
89  item.bkgdColor = j; \
90  item.color1 = k; \
91  item.color2 = l; \
92  item.saveSlot = m; \
93  item.labelId = n; \
94  item.labelX = o; \
95  item.labelY = p; \
96  item.keyCode = q; \
97  } while (0)
98 
99 class KyraEngine_v2;
100 class Screen_v2;
101 
102 class GUI_v2 : public GUI_v1 {
103 public:
104  GUI_v2(KyraEngine_v2 *vm);
105 
106  virtual void initStaticData() = 0;
107 
108  Button *addButtonToList(Button *list, Button *newButton) override;
109 
110  void processButton(Button *button) override;
111  int processButtonList(Button *button, uint16 inputFlag, int8 mouseWheel) override;
112 
113 protected:
114  void updateButton(Button *button) override;
115 
116  KyraEngine_v2 *_vm;
117  Screen_v2 *_screen;
118 
119  bool _buttonListChanged;
120  Button *_backUpButtonList;
121  Button *_specialProcessButton;
122  uint16 _flagsModifier;
123 
124 protected:
125  virtual void setupPalette() {}
126  virtual void restorePalette() {}
127 
128  virtual Common::String getTableString(int id, bool decode = false) = 0;
129 
130  virtual uint8 textFieldColor1() const = 0;
131  virtual uint8 textFieldColor2() const = 0;
132  virtual uint8 textFieldColor3() const = 0;
133 protected:
134  virtual void getInput();
135 
136  Button _menuButtons[7];
137  Button _scrollUpButton;
138  Button _scrollDownButton;
139  Menu _mainMenu, _gameOptions, _audioOptions, _choiceMenu, _loadMenu, _saveMenu, _savenameMenu, _deathMenu;
140 
141  Button *getButtonListData() override { return _menuButtons; }
142 
143  Button *getScrollUpButton() override { return &_scrollUpButton; }
144  Button *getScrollDownButton() override { return &_scrollDownButton; }
145 
146  int scrollUpButton(Button *button);
147  int scrollDownButton(Button *button);
148  Button::Callback _scrollUpFunctor;
149  Button::Callback _scrollDownFunctor;
150  Button::Callback getScrollUpButtonHandler() const override { return _scrollUpFunctor; }
151  Button::Callback getScrollDownButtonHandler() const override { return _scrollDownFunctor; }
152 
153  Button _sliderButtons[3][4];
154 
155  void renewHighlight(Menu &menu);
156 
157  void backUpPage1(uint8 *buffer);
158  void restorePage1(const uint8 *buffer);
159 
160  Menu *_currentMenu;
161  bool _isLoadMenu;
162  bool _isDeathMenu;
163  bool _isSaveMenu;
164  bool _isDeleteMenu;
165  bool _isChoiceMenu;
166  bool _isOptionsMenu;
167  bool _madeSave;
168  bool _loadedSave;
169  bool _restartGame;
170  bool _reloadTemporarySave;
171 
172  int _savegameOffset;
173 
174  void setupSavegameNames(Menu &menu, int num);
175 
176  // main menu
177  int resumeGame(Button *caller);
178 
179  // audio menu
180  static const int _sliderBarsPosition[];
181 
182  // load menu
183  bool _noLoadProcess;
184  int clickLoadSlot(Button *caller);
185  int cancelLoadMenu(Button *caller);
186 
187  // save menu
188  bool _noSaveProcess;
189  int _saveSlot;
190  char _saveDescription[0x51];
191 
192  int saveMenu(Button *caller);
193  int clickSaveSlot(Button *caller);
194  int cancelSaveMenu(Button *caller);
195 
196  int _saveLoadNumSlots;
197 
198  // delete menu
199  int _slotToDelete;
200  int deleteMenu(Button *caller);
201 
202  // options menu
203  int quitOptionsMenu(Button *caller);
204 
205  int toggleWalkspeed(Button *caller);
206  int toggleText(Button *caller);
207 
208  virtual void setupOptionsButtons() = 0;
209 
210  // audio options
211  Button::Callback _sliderHandlerFunctor;
212  virtual int sliderHandler(Button *caller) = 0;
213 
214  // savename menu
215  bool _finishNameInput, _cancelNameInput;
216 
217  const char *nameInputProcess(char *buffer, int x, int y, uint8 c1, uint8 c2, uint8 c3, int bufferSize);
218  int finishSavename(Button *caller);
219  int cancelSavename(Button *caller);
220 
221  bool checkSavegameDescription(const char *buffer, int size);
222  int getCharWidth(uint8 c);
223  void drawTextfieldBlock(int x, int y, uint8 c);
224 
225  Screen::FontId _saveMenuFont;
226  Common::Rect _saveMenuCursor;
227 
228  // choice menu
229  bool _choice;
230 
231  bool choiceDialog(int name, bool type);
232  int choiceYes(Button *caller);
233  int choiceNo(Button *caller);
234 };
235 
236 } // End of namespace Kyra
237 
238 #endif
Definition: str.h:59
Definition: rect.h:144
Definition: gui_v1.h:57
Definition: kyra_v2.h:53
Definition: gui_v2.h:102
Definition: detection.h:27
Definition: gui.h:38
Definition: screen_v2.h:30
Definition: gui_v1.h:82