ScummVM API documentation
gui_v1.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_V1_H
23 #define KYRA_GUI_V1_H
24 
25 #include "kyra/gui/gui.h"
26 
27 namespace Kyra {
28 
29 struct MenuItem {
30  bool enabled;
31 
32  Common::String itemString;
33  uint16 itemId;
34  bool useItemString;
35 
36  int16 x, y;
37  uint16 width, height;
38 
39  uint8 textColor, highlightColor;
40 
41  int16 titleX;
42 
43  uint8 color1, color2;
44  uint8 bkgdColor;
45 
46  Button::Callback callback;
47 
48  int16 saveSlot;
49 
50  const char *labelString;
51  uint16 labelId;
52  int16 labelX, labelY;
53 
54  uint16 keyCode;
55 };
56 
57 struct Menu {
58  int16 x, y;
59  uint16 width, height;
60 
61  uint8 bkgdColor;
62  uint8 color1, color2;
63 
64  const char *menuNameString;
65  uint16 menuNameId;
66 
67  uint8 textColor;
68  int16 titleX, titleY;
69 
70  uint8 highlightedItem;
71 
72  uint8 numberOfItems;
73 
74  int16 scrollUpButtonX, scrollUpButtonY;
75  int16 scrollDownButtonX, scrollDownButtonY;
76 
77  MenuItem item[7];
78 };
79 
80 class TextDisplayer;
81 
82 class GUI_v1 : public GUI {
83 public:
84  GUI_v1(KyraEngine_v1 *vm);
85  ~GUI_v1() override {}
86 
87  // button specific
88  virtual Button *addButtonToList(Button *list, Button *newButton);
89 
90  void processButton(Button *button) override = 0;
91  int processButtonList(Button *buttonList, uint16 inputFlags, int8 mouseWheel) override = 0;
92 
93  virtual int redrawShadedButtonCallback(Button *button);
94  virtual int redrawButtonCallback(Button *button);
95 
96  // menu specific
97  virtual void initMenuLayout(Menu &menu);
98  void initMenu(Menu &menu);
99 
100  void processHighlights(Menu &menu);
101 
102  // utilities for thumbnail creation
103  void createScreenThumbnail(Graphics::Surface &dst) override = 0;
104 
105 protected:
106  TextDisplayer *_text;
107 
108  Button *_menuButtonList;
109  bool _displayMenu;
110  bool _displaySubMenu;
111  bool _cancelSubMenu;
112 
113  virtual void printMenuText(const Common::String &str, int x, int y, uint8 c0, uint8 c1, uint8 c2);
114  virtual int getMenuCenterStringX(const Common::String &str, int x1, int x2);
115 
116  Button::Callback _redrawShadedButtonFunctor;
117  Button::Callback _redrawButtonFunctor;
118 
119  virtual Button *getButtonListData() = 0;
120  virtual Button *getScrollUpButton() = 0;
121  virtual Button *getScrollDownButton() = 0;
122 
123  virtual Button::Callback getScrollUpButtonHandler() const = 0;
124  virtual Button::Callback getScrollDownButtonHandler() const = 0;
125 
126  virtual uint8 defaultColor1() const = 0;
127  virtual uint8 defaultColor2() const = 0;
128  virtual uint8 menuItemLabelColor() const = 0;
129 
130  virtual Common::String getMenuTitle(const Menu &menu) = 0;
131  virtual Common::String getMenuItemTitle(const MenuItem &menuItem) = 0;
132  virtual Common::String getMenuItemLabel(const MenuItem &menuItem) = 0;
133 
134  void updateAllMenuButtons();
135  void updateMenuButton(Button *button);
136  virtual void updateButton(Button *button);
137 
138  void redrawText(const Menu &menu);
139  void redrawHighlight(const Menu &menu);
140 
141  uint32 _lastScreenUpdate;
142  void checkTextfieldInput();
143 
144  int _menuLabelYOffset;
145 };
146 
147 class Movie;
148 
149 class MainMenu {
150 public:
151  MainMenu(KyraEngine_v1 *vm);
152  virtual ~MainMenu() {}
153 
154  struct Animation {
155  Animation() : anim(0), startFrame(0), endFrame(0), delay(0) {}
156 
157  Movie *anim;
158  int startFrame;
159  int endFrame;
160  int delay;
161  };
162 
163  struct StaticData {
164  const char *strings[5];
165 
166  uint8 menuTable[7];
167  uint8 colorTable[4];
168  const uint8 *boxCoords;
169 
170  Screen::FontId font;
171  int8 lineSpacingAdjust;
172 
173  uint8 altColor;
174  };
175 
176  void init(StaticData data, Animation anim);
177  int handle(int dim);
178 private:
179  KyraEngine_v1 *_vm;
180  Screen *_screen;
181  OSystem *_system;
182 
183  StaticData _static;
184  struct AnimIntern {
185  int curFrame;
186  int direction;
187  };
188  Animation _anim;
189  AnimIntern _animIntern;
190 
191  uint32 _nextUpdate;
192 
193  void updateAnimation();
194  void draw(int select);
195  void drawBox(int x, int y, int w, int h, int fill);
196  bool getInput();
197 
198  void printString(const char *string, int x, int y, int col1, int col2, int flags, ...) GCC_PRINTF(2, 8);
199 };
200 
201 } // end of namesapce Kyra
202 
203 #endif
Definition: str.h:59
Definition: surface.h:66
Definition: text.h:32
Definition: kyra_v1.h:126
Definition: screen.h:565
Definition: system.h:45
Definition: gui_v1.h:154
int FORCEINLINE GCC_PRINTF(2, 0) int vsprintf_s(T(&dst)[N]
Definition: gui_v1.h:57
Definition: gui_v1.h:29
Definition: wsamovie.h:31
Definition: detection.h:27
Definition: gui.h:38
signed char * fill(signed char *first, signed char *last, Value val)
Definition: algorithm.h:111
Definition: system.h:167
Definition: gui_v1.h:82
Definition: gui_v1.h:163
Definition: gui_v1.h:149