ScummVM API documentation
menu.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 MENU_H_
23#define MENU_H_
24
25#include "engines/myst3/gfx.h"
26
27#include "common/events.h"
28#include "common/hashmap.h"
29#include "common/memstream.h"
30#include "common/ptr.h"
31#include "common/rect.h"
32#include "common/savefile.h"
33#include "common/str-array.h"
34
35#include "video/bink_decoder.h"
36
37namespace Myst3 {
38
39class Myst3Engine;
40class SpotItemFace;
41class GameState;
42
43enum DialogType {
44 kConfirmNewGame,
45 kConfirmLoadGame,
46 kConfirmOverwrite,
47 kConfirmEraseSavedGame,
48 kErrorEraseSavedGame,
49 kConfirmQuit
50};
51
52class Menu : public Drawable {
53public:
54 Menu(Myst3Engine *vm);
55 virtual ~Menu();
56
58 bool isOpen() const;
59
65 virtual bool handleInput(const Common::KeyState &e) = 0;
66
67 void updateMainMenu(uint16 action);
68 void goToNode(uint16 node);
69
74
80
87
88 virtual void saveLoadAction(uint16 action, uint16 item) = 0;
89 virtual void setSaveLoadSpotItem(uint16 id, SpotItemFace *spotItem);
90
91protected:
92 Myst3Engine *_vm;
93
95
96 SpotItemFace *_saveLoadSpotItem;
97 Common::String _saveLoadAgeName;
98
99 uint dialogIdFromType(DialogType type);
100 uint16 dialogConfirmValue();
101 uint16 dialogSaveValue();
102
103 Graphics::Surface *createThumbnail(Graphics::Surface *big);
104
105 Common::String getAgeLabel(GameState *gameState);
106};
107
108class PagingMenu : public Menu {
109public:
111 virtual ~PagingMenu();
112
113 void draw() override;
114 bool handleInput(const Common::KeyState &e) override;
115
116 void saveLoadAction(uint16 action, uint16 item) override;
117
118private:
119 Common::StringArray _saveLoadFiles;
120 Common::String _saveName;
121 bool _saveDrawCaret;
122 int32 _saveCaretCounter;
123
124 static const uint kCaretSpeed = 25;
125
126 void loadMenuOpen();
127 void loadMenuSelect(uint16 item);
128 void loadMenuLoad();
129 void loadMenuChangePage();
130 void saveMenuOpen();
131 void saveMenuSelect(uint16 item);
132 void saveMenuChangePage();
133 void saveMenuSave();
134 void saveLoadErase();
135
136 void saveLoadUpdateVars();
137
138 Common::String prepareSaveNameForDisplay(const Common::String &name);
139};
140
141class AlbumMenu : public Menu {
142public:
144 virtual ~AlbumMenu();
145
146 void draw() override;
147 bool handleInput(const Common::KeyState &e) override;
148
149 void saveLoadAction(uint16 action, uint16 item) override;
150 void setSaveLoadSpotItem(uint16 id, SpotItemFace *spotItem) override;
151
152private:
153 static const uint16 kAlbumThumbnailWidth = 100;
154 static const uint16 kAlbumThumbnailHeight = 56;
155
156 // This map does not own its elements
158 Common::String _saveLoadTime;
159
160 void loadMenuOpen();
161 void loadMenuSelect();
162 void loadMenuLoad();
163 void saveMenuOpen();
164 void saveMenuSave();
165 void setSavesAvailable();
166
167 Common::String getSaveNameTemplate();
169 void loadSaves();
170};
171
172class Dialog : public Drawable {
173public:
174 Dialog(Myst3Engine *vm, uint id);
175 virtual ~Dialog();
176 void draw() override;
177 virtual int16 update() = 0;
178
179protected:
180 Common::Rect getPosition() const;
181
182 Myst3Engine *_vm;
183 Video::BinkDecoder _bink;
184 Texture *_texture;
185
186 uint _buttonCount;
187};
188
189class ButtonsDialog : public Dialog {
190public:
191 ButtonsDialog(Myst3Engine *vm, uint id);
192 virtual ~ButtonsDialog();
193
194 void draw() override;
195 int16 update() override;
196
197private:
198 Common::Point getRelativeMousePosition() const;
199
200 uint16 _previousframe;
201 uint16 _frameToDisplay;
202
203 Common::Rect _buttons[3];
204
205 void loadButtons();
206};
207
208class GamepadDialog : public Dialog {
209public:
210 GamepadDialog(Myst3Engine *vm, uint id);
211 virtual ~GamepadDialog();
212
213 int16 update() override;
214};
215
216} // End of namespace Myst3
217
218#endif // MENU_H_
Definition: hashmap.h:85
Definition: str.h:59
Definition: menu.h:141
bool handleInput(const Common::KeyState &e) override
Definition: menu.h:189
Definition: menu.h:172
Definition: gfx.h:36
Definition: state.h:48
Definition: menu.h:208
Definition: menu.h:52
Graphics::Surface * captureThumbnail()
bool isOpen() const
Graphics::Surface * borrowSaveThumbnail()
void generateSaveThumbnail()
virtual bool handleInput(const Common::KeyState &e)=0
Definition: myst3.h:87
Definition: menu.h:108
bool handleInput(const Common::KeyState &e) override
Definition: node.h:64
Definition: gfx.h:93
Definition: keyboard.h:294
Definition: rect.h:144
Definition: rect.h:536
Definition: surface.h:67