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 "common/keyboard.h"
00031 #include "common/rect.h"
00032 #include "common/str-array.h"
00033 #include "common/stack.h"
00034 
00035 namespace Common {
00036 class SeekableReadStream;
00037 class WriteStream;
00038 }
00039 
00040 namespace Graphics {
00041 struct Surface;
00042 }
00043 
00044 namespace Stark {
00045 
00046 namespace Gfx {
00047 class Driver;
00048 }
00049 
00050 class DialogBox;
00051 class DiaryIndexScreen;
00052 class GameScreen;
00053 class MainMenuScreen;
00054 class SettingsMenuScreen;
00055 class SaveMenuScreen;
00056 class LoadMenuScreen;
00057 class FMVMenuScreen;
00058 class DiaryPagesScreen;
00059 class DialogScreen;
00060 class Cursor;
00061 class FMVScreen;
00062 
00066 class UserInterface {
00067 public:
00068     explicit UserInterface(Gfx::Driver *gfx);
00069     virtual ~UserInterface();
00070 
00071     void init();
00072 
00074     void onGameLoop();
00075 
00076     void render();
00077     void handleMouseMove(const Common::Point &pos);
00078     void handleMouseUp();
00079     void handleClick();
00080     void handleRightClick();
00081     void handleDoubleClick();
00082     void handleEscape();
00083     void notifyShouldExit() { _exitGame = true; }
00084     void inventoryOpen(bool open);
00085     bool shouldExit() { return _exitGame; }
00086 
00088     void requestFMVPlayback(const Common::String &name);
00089 
00091     void onFMVStopped();
00092 
00098     bool skipFMV();
00099 
00101     void changeScreen(Screen::Name screenName);
00102 
00104     void backPrevScreen();
00105 
00107     void doQueuedScreenChange();
00108 
00110     void requestQuitToMainMenu() { _quitToMainMenu = true; }
00111 
00113     void restoreScreenHistory();
00114 
00116     bool isInGameScreen() const;
00117 
00119     bool isInSaveLoadMenuScreen() const;
00120 
00122     bool isInDiaryIndexScreen() const;
00123 
00125     bool isInventoryOpen() const;
00126 
00128     bool isInteractive() const;
00129 
00131     void setInteractive(bool interactive);
00132 
00134     void notifyInventoryItemEnabled(uint16 itemIndex);
00135 
00137     void notifyDiaryEntryEnabled();
00138 
00140     int16 getSelectedInventoryItem() const;
00141     void selectInventoryItem(int16 itemIndex);
00142 
00144     void clearLocationDependentState();
00145 
00147     void optionsOpen();
00148 
00150     void markInteractionDenied();
00151 
00153     bool wasInteractionDenied() const;
00154 
00156     void onScreenChanged();
00157 
00159     void saveGameScreenThumbnail();
00160 
00162     void freeGameScreenThumbnail();
00163 
00165     const Graphics::Surface *getGameWindowThumbnail() const;
00166 
00173     template<class T>
00174     void confirm(const Common::String &message, T *instance, void (T::*confirmCallBack)());
00175     template<class T>
00176     void confirm(GameMessage::TextKey key, T *instance, void (T::*confirmCallBack)());
00177     void confirm(const Common::String &message, Common::Functor0<void> *confirmCallBack);
00178     void confirm(GameMessage::TextKey key, Common::Functor0<void> *confirmCallBack);
00179 
00181     void toggleScreen(Screen::Name screenName);
00182 
00184     bool hasToggleSubtitleRequest() { return _shouldToggleSubtitle; }
00185     void performToggleSubtitle();
00186 
00188     void handleKeyPress(const Common::KeyState &keyState);
00189 
00190     static const uint kThumbnailWidth = 160;
00191     static const uint kThumbnailHeight = 92;
00192     static const uint kThumbnailSize = kThumbnailWidth * kThumbnailHeight * 4;
00193 
00194 private:
00195     Screen *getScreenByName(Screen::Name screenName) const;
00196 
00197     void cycleInventory(bool forward);
00198 
00199     GameScreen *_gameScreen;
00200     FMVScreen *_fmvScreen;
00201     DiaryIndexScreen *_diaryIndexScreen;
00202     MainMenuScreen *_mainMenuScreen;
00203     SettingsMenuScreen *_settingsMenuScreen;
00204     SaveMenuScreen *_saveMenuScreen;
00205     LoadMenuScreen *_loadMenuScreen;
00206     FMVMenuScreen *_fmvMenuScreen;
00207     DiaryPagesScreen *_diaryPagesScreen;
00208     DialogScreen *_dialogScreen;
00209     Screen *_currentScreen;
00210     Common::Stack<Screen::Name> _prevScreenNameStack;
00211 
00212     DialogBox *_modalDialog;
00213     Cursor *_cursor;
00214 
00215     Gfx::Driver *_gfx;
00216     bool _exitGame;
00217     bool _quitToMainMenu;
00218 
00219     bool _interactive;
00220     bool _interactionAttemptDenied;
00221 
00222     bool _shouldToggleSubtitle;
00223 
00224     // TODO: Generalize to all screen changes
00225     bool _shouldGoBackToPreviousScreen;
00226     Common::String _shouldPlayFmv;
00227 
00228     Graphics::Surface *_gameWindowThumbnail;
00229 };
00230 
00231 template<class T>
00232 void UserInterface::confirm(GameMessage::TextKey key, T *instance, void (T::*confirmCallBack)()) {
00233     confirm(key, new Common::Functor0Mem<void, T>(instance, confirmCallBack));
00234 }
00235 
00236 template<class T>
00237 void UserInterface::confirm(const Common::String &message, T *instance, void (T::*confirmCallBack)()) {
00238     confirm(message, new Common::Functor0Mem<void, T>(instance, confirmCallBack));
00239 }
00240 
00241 } // End of namespace Stark
00242 
00243 #endif // STARK_SERVICES_USER_INTERFACE_H


Generated on Sat Jul 20 2019 05:00:58 for ResidualVM by doxygen 1.7.1
curved edge   curved edge