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 ASYLUM_VIEWS_MENU_H
23 #define ASYLUM_VIEWS_MENU_H
24 
25 #include "graphics/surface.h"
26 
27 #include "asylum/eventhandler.h"
28 #include "asylum/shared.h"
29 
30 namespace Asylum {
31 
32 class AsylumEngine;
33 class Cursor;
34 class GraphicResource;
35 class ResourcePack;
36 class Scene;
37 class Text;
38 
39 class Menu : public EventHandler {
40 public:
41  Menu(AsylumEngine *vm);
42  virtual ~Menu() {};
43 
47  void show();
48 
56  bool handleEvent(const AsylumEvent &evt);
57 
61  void setGameStarted() { _gameStarted = true; }
62 
63  // Savegames
64  void setDword455C78(bool state) { _dword_455C78 = state; }
65  void setDword455C80(bool state) { _dword_455C80 = state; }
66  void setLoadingDuringStartup() { _loadingDuringStartup = true; }
67 
68  bool isEditingSavegameName() { return _activeScreen == kMenuSaveGame && _isEditingSavegameName; };
69  bool isConfiguringKeyboard() { return _activeScreen == kMenuKeyboardConfig && _selectedShortcutIndex != -1; }
70 
71 private:
72  AsylumEngine *_vm;
73 
74  enum MenuScreen {
75  kMenuNone = -1,
76  kMenuNewGame = 0,
77  kMenuLoadGame = 1,
78  kMenuSaveGame = 2,
79  kMenuDeleteGame = 3,
80  kMenuViewMovies = 4,
81  kMenuQuitGame = 5,
82  kMenuTextOptions = 6,
83  kMenuAudioOptions = 7,
84  kMenuSettings = 8,
85  kMenuKeyboardConfig = 9,
86  kMenuReturnToGame = 10,
87  kMenuShowCredits = 11
88  };
89 
90  enum MenuResource {
91  kMenuResourceNone = 0,
92  kBackground = MAKE_RESOURCE(kResourcePackShared, 0),
93  kEye = MAKE_RESOURCE(kResourcePackShared, 1),
94  kFontBlue = MAKE_RESOURCE(kResourcePackShared, 22),
95  kFontYellow = MAKE_RESOURCE(kResourcePackShared, 16),
96  kSfxSound = MAKE_RESOURCE(kResourcePackShared, 41),
97  kAmbientSound = MAKE_RESOURCE(kResourcePackShared, 42),
98  kVoiceSound = MAKE_RESOURCE(kResourcePackShared, 43)
99  };
100 
101  // Game initialization
102  bool _initGame;
103 
104  // Data
105  MenuScreen _activeScreen;
106  ResourceId _soundResourceId;
107  ResourceId _musicResourceId;
108  bool _gameStarted;
109  MenuScreen _currentIcon;
110  int32 _selectedShortcutIndex;
111  int32 _dword_455C74;
112  bool _dword_455C78;
113  bool _dword_455C80;
114  bool _dword_455D4C;
115  bool _dword_455D5C;
116  bool _isEditingSavegameName;
117  bool _testSoundsPlaying;
118  int32 _dword_456288;
119  int32 _caretBlink;
120  int32 _startIndex;
121  int32 _creditsFrameIndex;
122  int32 _creditsNumSteps;
123  bool _showMovie;
124  uint32 _iconFrames[12];
125 
126  // Movies
127  int32 _movieList[196];
128  uint32 _movieCount;
129  uint32 _movieIndex;
130 
131  // Savegames
132  Common::String _previousName;
133  int32 _prefixWidth;
134  bool _loadingDuringStartup;
135 
136  // Thumbnails
137  int _thumbnailIndex;
138  Graphics::Surface _thumbnailSurface;
139 
143  void setup();
144 
148  void leave();
149 
155  void switchFont(bool condition);
156 
160  void closeCredits();
161 
165  void setupMusic();
166 
172  MenuScreen findMousePosition();
173 
177  void playTestSounds();
178 
182  void stopTestSounds();
183 
189  void adjustMasterVolume(int32 delta) const;
190 
194  void adjustTestVolume();
195 
199  void adjustPerformance();
200 
206  Common::String getChapterName();
207 
209  // Message handling
210  bool init();
211  bool update();
212  bool music();
213  bool key(const AsylumEvent &evt);
214  bool click(const AsylumEvent &evt);
215 
216  // Thumbnails
217  bool hasThumbnail(int index);
218  void readThumbnail();
219  void showThumbnail();
220 
221  // Update handlers
222  void updateNewGame();
223  void updateLoadGame();
224  void updateSaveGame();
225  void updateDeleteGame();
226  void updateViewMovies();
227  void updateQuitGame();
228  void updateTextOptions();
229  void updateAudioOptions();
230  void updateSettings();
231  void updateKeyboardConfig();
232  void updateReturnToGame();
233  void updateShowCredits();
234 
235  // Click handlers
236  void clickNewGame();
237  void clickLoadGame();
238  void clickSaveGame();
239  void clickDeleteGame();
240  void clickViewMovies();
241  void clickQuitGame();
242  void clickTextOptions();
243  void clickAudioOptions();
244  void clickSettings();
245  void clickKeyboardConfig();
246  void clickReturnToGame();
247  void clickShowCredits();
248 
249  // Key handlers
250  void keySaveGame(const AsylumEvent &evt);
251  void keyKeyboardConfig(const AsylumEvent &evt);
252  void keyShowCredits();
253 
254 }; // end of class MainMenu
255 
256 } // end of namespace Asylum
257 
258 #endif // ASYLUM_VIEWS_MENU_H
Definition: str.h:59
Definition: surface.h:66
Definition: asylum.h:53
Definition: menu.h:39
Definition: eventhandler.h:43
Definition: eventhandler.h:61
Definition: asylum.h:70
Definition: cursor.h:27
bool handleEvent(const AsylumEvent &evt)
void setGameStarted()
Definition: menu.h:61