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 
37 namespace Myst3 {
38 
39 class Myst3Engine;
40 class SpotItemFace;
41 class GameState;
42 
43 enum DialogType {
44  kConfirmNewGame,
45  kConfirmLoadGame,
46  kConfirmOverwrite,
47  kConfirmEraseSavedGame,
48  kErrorEraseSavedGame,
49  kConfirmQuit
50 };
51 
52 class Menu : public Drawable {
53 public:
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 
79  void generateSaveThumbnail();
80 
87 
88  virtual void saveLoadAction(uint16 action, uint16 item) = 0;
89  virtual void setSaveLoadSpotItem(uint16 id, SpotItemFace *spotItem);
90 
91 protected:
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 
108 class PagingMenu : public Menu {
109 public:
110  PagingMenu(Myst3Engine *vm);
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 
118 private:
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 
141 class AlbumMenu : public Menu {
142 public:
143  AlbumMenu(Myst3Engine *vm);
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 
152 private:
153  static const uint16 kAlbumThumbnailWidth = 100;
154  static const uint16 kAlbumThumbnailHeight = 56;
155 
156  // This map does not own its elements
157  Common::HashMap<int, SpotItemFace *> _albumSpotItems;
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();
168  Common::HashMap<int, Common::String> listSaveFiles();
169  void loadSaves();
170 };
171 
172 class Dialog : public Drawable {
173 public:
174  Dialog(Myst3Engine *vm, uint id);
175  virtual ~Dialog();
176  void draw() override;
177  virtual int16 update() = 0;
178 
179 protected:
180  Common::Rect getPosition() const;
181 
182  Myst3Engine *_vm;
183  Video::BinkDecoder _bink;
184  Texture *_texture;
185 
186  uint _buttonCount;
187 };
188 
189 class ButtonsDialog : public Dialog {
190 public:
191  ButtonsDialog(Myst3Engine *vm, uint id);
192  virtual ~ButtonsDialog();
193 
194  void draw() override;
195  int16 update() override;
196 
197 private:
198  Common::Point getRelativeMousePosition() const;
199 
200  uint16 _previousframe;
201  uint16 _frameToDisplay;
202 
203  Common::Rect _buttons[3];
204 
205  void loadButtons();
206 };
207 
208 class GamepadDialog : public Dialog {
209 public:
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_
Graphics::Surface * borrowSaveThumbnail()
void generateSaveThumbnail()
Definition: str.h:59
Definition: surface.h:67
Graphics::Surface * captureThumbnail()
Definition: menu.h:208
Definition: ambient.h:27
Definition: state.h:48
Definition: rect.h:144
Definition: node.h:64
Definition: gfx.h:93
Definition: hashmap.h:85
Definition: rect.h:45
Definition: menu.h:52
Definition: menu.h:172
Definition: menu.h:141
Definition: keyboard.h:294
Definition: gfx.h:36
Definition: menu.h:108
virtual bool handleInput(const Common::KeyState &e)=0
Definition: myst3.h:87
bool isOpen() const
Definition: menu.h:189