ScummVM API documentation
userinterface.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 STARK_SERVICES_USER_INTERFACE_H
23 #define STARK_SERVICES_USER_INTERFACE_H
24 
25 #include "engines/stark/stark.h"
26 #include "engines/stark/ui/screen.h"
27 
28 #include "engines/stark/services/gamemessage.h"
29 
30 #include "engines/engine.h"
31 
32 #include "common/keyboard.h"
33 #include "common/rect.h"
34 #include "common/str-array.h"
35 #include "common/stack.h"
36 
37 namespace Common {
38 class SeekableReadStream;
39 class WriteStream;
40 }
41 
42 namespace Graphics {
43 struct Surface;
44 }
45 
46 namespace Stark {
47 
48 namespace Gfx {
49 class Driver;
50 }
51 
52 class DialogBox;
53 class DiaryIndexScreen;
54 class GameScreen;
55 class MainMenuScreen;
56 class SettingsMenuScreen;
57 class SaveMenuScreen;
58 class LoadMenuScreen;
59 class FMVMenuScreen;
60 class DiaryPagesScreen;
61 class DialogScreen;
62 class Cursor;
63 class FMVScreen;
64 
65 enum {
66  kThumbnailWidth = 160,
67  kThumbnailHeight = 92,
68  kThumbnailSize = kThumbnailWidth * kThumbnailHeight * 4
69 };
70 
75 public:
76  explicit UserInterface(StarkEngine *vm, Gfx::Driver *gfx);
77  virtual ~UserInterface();
78 
79  void init();
80 
82  void onGameLoop();
83 
84  void render();
85  void handleMouseMove(const Common::Point &pos);
86  void handleMouseUp();
87  void handleClick();
88  void handleRightClick();
89  void handleDoubleClick();
90  void handleEscape();
91  void notifyShouldExit() { _exitGame = true; }
92  void inventoryOpen(bool open);
93  bool shouldExit() { return _exitGame; }
94 
96  void requestFMVPlayback(const Common::Path &name);
97 
99  void onFMVStopped();
100 
106  bool skipFMV();
107 
109  void changeScreen(Screen::Name screenName);
110 
112  void backPrevScreen();
113 
115  void doQueuedScreenChange();
116 
118  void requestQuitToMainMenu() { _quitToMainMenu = true; }
119 
121  void restoreScreenHistory();
122 
124  bool isInGameScreen() const;
125 
127  bool isInSaveLoadMenuScreen() const;
128 
130  bool isInDiaryIndexScreen() const;
131 
133  bool isInventoryOpen() const;
134 
136  bool isInteractive() const;
137 
139  void setInteractive(bool interactive);
140 
142  void notifyInventoryItemEnabled(uint16 itemIndex);
143 
145  void notifyDiaryEntryEnabled();
146 
148  int16 getSelectedInventoryItem() const;
149  void selectInventoryItem(int16 itemIndex);
150 
152  void clearLocationDependentState();
153 
155  void optionsOpen();
156 
158  void markInteractionDenied();
159 
161  bool wasInteractionDenied() const;
162 
164  void onScreenChanged();
165 
167  void saveGameScreenThumbnail();
168 
170  void freeGameScreenThumbnail();
171 
173  const Graphics::Surface *getGameWindowThumbnail() const;
174 
181  template<class T>
182  void confirm(const Common::String &message, T *instance, void (T::*confirmCallBack)());
183  template<class T>
184  void confirm(GameMessage::TextKey key, T *instance, void (T::*confirmCallBack)());
185  void confirm(const Common::String &message, Common::Functor0<void> *confirmCallBack);
186  void confirm(GameMessage::TextKey key, Common::Functor0<void> *confirmCallBack);
187 
189  void toggleScreen(Screen::Name screenName);
190 
192  bool hasToggleSubtitleRequest() { return _shouldToggleSubtitle; }
193  void performToggleSubtitle();
194 
196  void handleActions(Common::CustomEventType customType);
197  void handleKeyPress(const Common::KeyState &keyState);
198 
199 private:
200  Screen *getScreenByName(Screen::Name screenName) const;
201 
202  void cycleInventory(bool forward);
203 
204  StarkEngine *_vm;
205  GameScreen *_gameScreen;
206  FMVScreen *_fmvScreen;
207  DiaryIndexScreen *_diaryIndexScreen;
208  MainMenuScreen *_mainMenuScreen;
209  SettingsMenuScreen *_settingsMenuScreen;
210  SaveMenuScreen *_saveMenuScreen;
211  LoadMenuScreen *_loadMenuScreen;
212  FMVMenuScreen *_fmvMenuScreen;
213  DiaryPagesScreen *_diaryPagesScreen;
214  DialogScreen *_dialogScreen;
215  Screen *_currentScreen;
216  Common::Stack<Screen::Name> _prevScreenNameStack;
217 
218  DialogBox *_modalDialog;
219  Cursor *_cursor;
220 
221  Gfx::Driver *_gfx;
222  bool _exitGame;
223  bool _quitToMainMenu;
224  PauseToken _gamePauseToken;
225 
226  bool _interactive;
227  bool _interactionAttemptDenied;
228 
229  bool _shouldToggleSubtitle;
230 
231  // TODO: Generalize to all screen changes
232  bool _shouldGoBackToPreviousScreen;
233  Common::Path _shouldPlayFmv;
234 
235  Graphics::Surface *_gameWindowThumbnail;
236 };
237 
238 template<class T>
239 void UserInterface::confirm(GameMessage::TextKey key, T *instance, void (T::*confirmCallBack)()) {
240  confirm(key, new Common::Functor0Mem<void, T>(instance, confirmCallBack));
241 }
242 
243 template<class T>
244 void UserInterface::confirm(const Common::String &message, T *instance, void (T::*confirmCallBack)()) {
245  confirm(message, new Common::Functor0Mem<void, T>(instance, confirmCallBack));
246 }
247 
248 } // End of namespace Stark
249 
250 #endif // STARK_SERVICES_USER_INTERFACE_H
Definition: engine.h:102
Definition: str.h:59
Definition: surface.h:67
Definition: fmvscreen.h:46
void requestQuitToMainMenu()
Definition: userinterface.h:118
Definition: saveloadmenu.h:90
Definition: mainmenu.h:32
Definition: path.h:52
Definition: diarypages.h:32
uint32 CustomEventType
Definition: events.h:193
Definition: func.h:389
Definition: settingsmenu.h:68
Definition: driver.h:44
Definition: fmvmenu.h:37
Definition: cursor.h:45
Definition: diaryindex.h:32
Definition: atari-cursor.h:38
Definition: console.h:27
Definition: algorithm.h:29
Definition: formatinfo.h:28
Definition: rect.h:45
Definition: stark.h:91
Definition: dialogbox.h:49
Definition: dialogmenu.h:36
Definition: keyboard.h:294
Definition: userinterface.h:74
Definition: saveloadmenu.h:114
bool hasToggleSubtitleRequest()
Definition: userinterface.h:192
Definition: gamescreen.h:42
Definition: screen.h:35