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

menu.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 MENU_H_
00024 #define MENU_H_
00025 
00026 #include "engines/myst3/gfx.h"
00027 
00028 #include "common/events.h"
00029 #include "common/hashmap.h"
00030 #include "common/memstream.h"
00031 #include "common/ptr.h"
00032 #include "common/rect.h"
00033 #include "common/savefile.h"
00034 #include "common/str-array.h"
00035 
00036 #include "video/bink_decoder.h"
00037 
00038 namespace Myst3 {
00039 
00040 class Myst3Engine;
00041 class SpotItemFace;
00042 class GameState;
00043 
00044 enum DialogType {
00045     kConfirmNewGame,
00046     kConfirmLoadGame,
00047     kConfirmOverwrite,
00048     kConfirmEraseSavedGame,
00049     kErrorEraseSavedGame,
00050     kConfirmQuit
00051 };
00052 
00053 class Menu : public Drawable {
00054 public:
00055     Menu(Myst3Engine *vm);
00056     virtual ~Menu();
00057 
00059     bool isOpen() const;
00060 
00066     virtual bool handleInput(const Common::KeyState &e) = 0;
00067 
00068     void updateMainMenu(uint16 action);
00069     void goToNode(uint16 node);
00070 
00074     Graphics::Surface *captureThumbnail();
00075 
00080     void generateSaveThumbnail();
00081 
00087     Graphics::Surface *borrowSaveThumbnail();
00088 
00089     virtual void saveLoadAction(uint16 action, uint16 item) = 0;
00090     virtual void setSaveLoadSpotItem(uint16 id, SpotItemFace *spotItem);
00091 
00092 protected:
00093     Myst3Engine *_vm;
00094 
00095     Common::ScopedPtr<Graphics::Surface, Graphics::SurfaceDeleter> _saveThumbnail;
00096 
00097     SpotItemFace *_saveLoadSpotItem;
00098     Common::String _saveLoadAgeName;
00099 
00100     uint dialogIdFromType(DialogType type);
00101     uint16 dialogConfirmValue();
00102     uint16 dialogSaveValue();
00103 
00104     Graphics::Surface *createThumbnail(Graphics::Surface *big);
00105 
00106     Common::String getAgeLabel(GameState *gameState);
00107 };
00108 
00109 class PagingMenu : public Menu {
00110 public:
00111     PagingMenu(Myst3Engine *vm);
00112     virtual ~PagingMenu();
00113 
00114     void draw() override;
00115     bool handleInput(const Common::KeyState &e) override;
00116 
00117     void saveLoadAction(uint16 action, uint16 item) override;
00118 
00119 private:
00120     Common::StringArray _saveLoadFiles;
00121     Common::String _saveName;
00122     bool _saveDrawCaret;
00123     int32 _saveCaretCounter;
00124 
00125     static const uint kCaretSpeed = 25;
00126 
00127     void loadMenuOpen();
00128     void loadMenuSelect(uint16 item);
00129     void loadMenuLoad();
00130     void loadMenuChangePage();
00131     void saveMenuOpen();
00132     void saveMenuSelect(uint16 item);
00133     void saveMenuChangePage();
00134     void saveMenuSave();
00135     void saveLoadErase();
00136 
00137     void saveLoadUpdateVars();
00138 
00139     Common::String prepareSaveNameForDisplay(const Common::String &name);
00140 };
00141 
00142 class AlbumMenu : public Menu {
00143 public:
00144     AlbumMenu(Myst3Engine *vm);
00145     virtual ~AlbumMenu();
00146 
00147     void draw() override;
00148     bool handleInput(const Common::KeyState &e) override;
00149 
00150     void saveLoadAction(uint16 action, uint16 item) override;
00151     void setSaveLoadSpotItem(uint16 id, SpotItemFace *spotItem) override;
00152 
00153 private:
00154     static const uint16 kAlbumThumbnailWidth = 100;
00155     static const uint16 kAlbumThumbnailHeight = 56;
00156 
00157     // This map does not own its elements
00158     Common::HashMap<int, SpotItemFace *> _albumSpotItems;
00159     Common::String _saveLoadTime;
00160 
00161     void loadMenuOpen();
00162     void loadMenuSelect();
00163     void loadMenuLoad();
00164     void saveMenuOpen();
00165     void saveMenuSave();
00166     void setSavesAvailable();
00167 
00168     Common::String getSaveNameTemplate();
00169     Common::HashMap<int, Common::String> listSaveFiles();
00170     void loadSaves();
00171 };
00172 
00173 class Dialog : public Drawable {
00174 public:
00175     Dialog(Myst3Engine *vm, uint id);
00176     virtual ~Dialog();
00177     virtual void draw() override;
00178     virtual int16 update() = 0;
00179 
00180 protected:
00181     Common::Rect getPosition() const;
00182 
00183     Myst3Engine *_vm;
00184     Video::BinkDecoder _bink;
00185     Texture *_texture;
00186 
00187     uint _buttonCount;
00188 };
00189 
00190 class ButtonsDialog : public Dialog {
00191 public:
00192     ButtonsDialog(Myst3Engine *vm, uint id);
00193     virtual ~ButtonsDialog();
00194 
00195     void draw() override;
00196     int16 update() override;
00197 
00198 private:
00199     Common::Point getRelativeMousePosition() const;
00200 
00201     uint16 _previousframe;
00202     uint16 _frameToDisplay;
00203 
00204     Common::Rect _buttons[3];
00205 
00206     void loadButtons();
00207 };
00208 
00209 class GamepadDialog : public Dialog {
00210 public:
00211     GamepadDialog(Myst3Engine *vm, uint id);
00212     virtual ~GamepadDialog();
00213 
00214     int16 update() override;
00215 };
00216 
00217 } // End of namespace Myst3
00218 
00219 #endif // MENU_H_


Generated on Sat Aug 17 2019 05:00:39 for ResidualVM by doxygen 1.7.1
curved edge   curved edge