ResidualVM logo ResidualVM website - Forums - Contact us BuildBot - Doxygen - Wiki curved edge

userinterface.h

Go to the documentation of this file.
00001 /* ResidualVM - A 3D game interpreter
00002  *
00003  * ResidualVM is the legal property of its developers, whose names
00004  * are too numerous to list here. Please refer to the AUTHORS
00005  * file distributed with this source distribution.
00006  *
00007  * This program is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU General Public License
00009  * as published by the Free Software Foundation; either version 2
00010  * of the License, or (at your option) any later version.
00011  *
00012  * This program is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  * GNU General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU General Public License
00018  * along with this program; if not, write to the Free Software
00019  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00020  *
00021  */
00022 
00023 #ifndef STARK_SERVICES_USER_INTERFACE_H
00024 #define STARK_SERVICES_USER_INTERFACE_H
00025 
00026 #include "engines/stark/ui/screen.h"
00027 
00028 #include "engines/stark/services/gamemessage.h"
00029 
00030 #include "engines/engine.h"
00031 
00032 #include "common/keyboard.h"
00033 #include "common/rect.h"
00034 #include "common/str-array.h"
00035 #include "common/stack.h"
00036 
00037 namespace Common {
00038 class SeekableReadStream;
00039 class WriteStream;
00040 }
00041 
00042 namespace Graphics {
00043 struct Surface;
00044 }
00045 
00046 namespace Stark {
00047 
00048 namespace Gfx {
00049 class Driver;
00050 }
00051 
00052 class DialogBox;
00053 class DiaryIndexScreen;
00054 class GameScreen;
00055 class MainMenuScreen;
00056 class SettingsMenuScreen;
00057 class SaveMenuScreen;
00058 class LoadMenuScreen;
00059 class FMVMenuScreen;
00060 class DiaryPagesScreen;
00061 class DialogScreen;
00062 class Cursor;
00063 class FMVScreen;
00064 
00068 class UserInterface {
00069 public:
00070     explicit UserInterface(Gfx::Driver *gfx);
00071     virtual ~UserInterface();
00072 
00073     void init();
00074 
00076     void onGameLoop();
00077 
00078     void render();
00079     void handleMouseMove(const Common::Point &pos);
00080     void handleMouseUp();
00081     void handleClick();
00082     void handleRightClick();
00083     void handleDoubleClick();
00084     void handleEscape();
00085     void notifyShouldExit() { _exitGame = true; }
00086     void inventoryOpen(bool open);
00087     bool shouldExit() { return _exitGame; }
00088 
00090     void requestFMVPlayback(const Common::String &name);
00091 
00093     void onFMVStopped();
00094 
00100     bool skipFMV();
00101 
00103     void changeScreen(Screen::Name screenName);
00104 
00106     void backPrevScreen();
00107 
00109     void doQueuedScreenChange();
00110 
00112     void requestQuitToMainMenu() { _quitToMainMenu = true; }
00113 
00115     void restoreScreenHistory();
00116 
00118     bool isInGameScreen() const;
00119 
00121     bool isInSaveLoadMenuScreen() const;
00122 
00124     bool isInDiaryIndexScreen() const;
00125 
00127     bool isInventoryOpen() const;
00128 
00130     bool isInteractive() const;
00131 
00133     void setInteractive(bool interactive);
00134 
00136     void notifyInventoryItemEnabled(uint16 itemIndex);
00137 
00139     void notifyDiaryEntryEnabled();
00140 
00142     int16 getSelectedInventoryItem() const;
00143     void selectInventoryItem(int16 itemIndex);
00144 
00146     void clearLocationDependentState();
00147 
00149     void optionsOpen();
00150 
00152     void markInteractionDenied();
00153 
00155     bool wasInteractionDenied() const;
00156 
00158     void onScreenChanged();
00159 
00161     void saveGameScreenThumbnail();
00162 
00164     void freeGameScreenThumbnail();
00165 
00167     const Graphics::Surface *getGameWindowThumbnail() const;
00168 
00175     template<class T>
00176     void confirm(const Common::String &message, T *instance, void (T::*confirmCallBack)());
00177     template<class T>
00178     void confirm(GameMessage::TextKey key, T *instance, void (T::*confirmCallBack)());
00179     void confirm(const Common::String &message, Common::Functor0<void> *confirmCallBack);
00180     void confirm(GameMessage::TextKey key, Common::Functor0<void> *confirmCallBack);
00181 
00183     void toggleScreen(Screen::Name screenName);
00184 
00186     bool hasToggleSubtitleRequest() { return _shouldToggleSubtitle; }
00187     void performToggleSubtitle();
00188 
00190     void handleKeyPress(const Common::KeyState &keyState);
00191 
00192     static const uint kThumbnailWidth = 160;
00193     static const uint kThumbnailHeight = 92;
00194     static const uint kThumbnailSize = kThumbnailWidth * kThumbnailHeight * 4;
00195 
00196 private:
00197     Screen *getScreenByName(Screen::Name screenName) const;
00198 
00199     void cycleInventory(bool forward);
00200 
00201     GameScreen *_gameScreen;
00202     FMVScreen *_fmvScreen;
00203     DiaryIndexScreen *_diaryIndexScreen;
00204     MainMenuScreen *_mainMenuScreen;
00205     SettingsMenuScreen *_settingsMenuScreen;
00206     SaveMenuScreen *_saveMenuScreen;
00207     LoadMenuScreen *_loadMenuScreen;
00208     FMVMenuScreen *_fmvMenuScreen;
00209     DiaryPagesScreen *_diaryPagesScreen;
00210     DialogScreen *_dialogScreen;
00211     Screen *_currentScreen;
00212     Common::Stack<Screen::Name> _prevScreenNameStack;
00213 
00214     DialogBox *_modalDialog;
00215     Cursor *_cursor;
00216 
00217     Gfx::Driver *_gfx;
00218     bool _exitGame;
00219     bool _quitToMainMenu;
00220     PauseToken _gamePauseToken;
00221 
00222     bool _interactive;
00223     bool _interactionAttemptDenied;
00224 
00225     bool _shouldToggleSubtitle;
00226 
00227     // TODO: Generalize to all screen changes
00228     bool _shouldGoBackToPreviousScreen;
00229     Common::String _shouldPlayFmv;
00230 
00231     Graphics::Surface *_gameWindowThumbnail;
00232 };
00233 
00234 template<class T>
00235 void UserInterface::confirm(GameMessage::TextKey key, T *instance, void (T::*confirmCallBack)()) {
00236     confirm(key, new Common::Functor0Mem<void, T>(instance, confirmCallBack));
00237 }
00238 
00239 template<class T>
00240 void UserInterface::confirm(const Common::String &message, T *instance, void (T::*confirmCallBack)()) {
00241     confirm(message, new Common::Functor0Mem<void, T>(instance, confirmCallBack));
00242 }
00243 
00244 } // End of namespace Stark
00245 
00246 #endif // STARK_SERVICES_USER_INTERFACE_H


Generated on Sat Aug 1 2020 05:01:23 for ResidualVM by doxygen 1.7.1
curved edge   curved edge