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 8 * modify it under the terms of the GNU General Public License 9 * as published by the Free Software Foundation; either version 2 10 * of the License, or (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, write to the Free Software 19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 * 21 */ 22 23 #ifndef LASTEXPRESS_MENU_H 24 #define LASTEXPRESS_MENU_H 25 26 #include "lastexpress/data/sequence.h" 27 28 #include "lastexpress/eventhandler.h" 29 30 #include "lastexpress/shared.h" 31 32 #include "common/hashmap.h" 33 34 namespace LastExpress { 35 36 class LastExpressEngine; 37 class Scene; 38 class SceneHotspot; 39 40 class Clock; 41 class TrainLine; 42 43 class Menu : public EventHandler { 44 public: 45 Menu(LastExpressEngine *engine); 46 ~Menu() override; 47 48 void show(bool doSavegame, SavegameType type, uint32 value); 49 50 // Event handling 51 void eventMouse(const Common::Event &ev) override; 52 void eventTick(const Common::Event &ev) override; 53 isShown()54 bool isShown() const { return _isShowingMenu; } 55 getGameId()56 GameId getGameId() const { return _gameId; } 57 58 private: 59 // Start menu events 60 enum StartMenuAction { 61 kMenuContinue = 1, 62 kMenuCredits = 2, 63 kMenuQuitGame = 3, 64 kMenuCase4 = 4, 65 kMenuSwitchSaveGame = 6, 66 kMenuRewindGame = 7, 67 kMenuForwardGame = 8, 68 kMenuParis = 10, 69 kMenuStrasBourg = 11, 70 kMenuMunich = 12, 71 kMenuVienna = 13, 72 kMenuBudapest = 14, 73 kMenuBelgrade = 15, 74 kMenuConstantinople = 16, 75 kMenuDecreaseVolume = 17, 76 kMenuIncreaseVolume = 18, 77 kMenuDecreaseBrightness = 19, 78 kMenuIncreaseBrightness = 20 79 }; 80 81 // City buttons 82 enum CityButton { 83 kParis = 0, 84 kStrasbourg = 1, 85 kMunich = 2, 86 kVienna = 3, 87 kBudapest = 4, 88 kBelgrade = 5, 89 kConstantinople = 6 90 }; 91 92 // Start menu overlay elements 93 enum StartMenuOverlay { 94 kOverlayTooltip, // 0 95 kOverlayEggButtons, 96 kOverlayButtons, 97 kOverlayAcorn, 98 kOverlayCity1, 99 kOverlayCity2, // 5 100 kOverlayCity3, 101 kOverlayCredits 102 }; 103 104 LastExpressEngine *_engine; 105 106 // Sequences 107 Sequence *_seqTooltips; 108 Sequence *_seqEggButtons; 109 Sequence *_seqButtons; 110 Sequence *_seqAcorn; 111 Sequence *_seqCity1; 112 Sequence *_seqCity2; 113 Sequence *_seqCity3; 114 Sequence *_seqCredits; 115 116 GameId _gameId; 117 118 // Indicator to know if we need to show the start animation when showMenu is called 119 bool _hasShownStartScreen; 120 bool _hasShownIntro; 121 122 bool _isShowingCredits; 123 bool _isGameStarted; 124 bool _isShowingMenu; 125 126 127 uint16 _creditsSequenceIndex; 128 129 ////////////////////////////////////////////////////////////////////////// 130 // Event handling 131 uint32 _checkHotspotsTicks; 132 Common::EventType _mouseFlags; 133 SceneHotspot *_lastHotspot; 134 135 void init(bool doSavegame, SavegameType type, uint32 value); 136 void setup(); 137 bool handleEvent(StartMenuAction action, Common::EventType type); 138 void checkHotspots(); 139 void setLogicEventHandlers(); 140 141 ////////////////////////////////////////////////////////////////////////// 142 // Game-related 143 void startGame(); 144 void switchGame(); 145 146 ////////////////////////////////////////////////////////////////////////// 147 // Overlays & elements 148 Clock *_clock; 149 TrainLine *_trainLine; 150 151 struct MenuOverlays_EqualTo { operatorMenuOverlays_EqualTo152 bool operator()(const StartMenuOverlay &x, const StartMenuOverlay &y) const { return x == y; } 153 }; 154 155 struct MenuOverlays_Hash { operatorMenuOverlays_Hash156 uint operator()(const StartMenuOverlay &x) const { return x; } 157 }; 158 159 typedef Common::HashMap<StartMenuOverlay, SequenceFrame *, MenuOverlays_Hash, MenuOverlays_EqualTo> MenuFrames; 160 161 MenuFrames _frames; 162 163 void hideOverlays(); 164 void showFrame(StartMenuOverlay overlay, int index, bool redraw); 165 166 void clear(); 167 168 // TODO: remove? 169 void moveToCity(CityButton city, bool clicked); 170 171 ////////////////////////////////////////////////////////////////////////// 172 // Misc 173 Common::String getAcornSequenceName(GameId id) const; 174 175 ////////////////////////////////////////////////////////////////////////// 176 // Time 177 uint32 _currentTime; // current game time 178 uint32 _lowerTime; // lower time value 179 uint32 _time; 180 181 uint32 _currentIndex; // current savegame entry 182 uint32 _index; 183 uint32 _lastIndex; 184 uint32 _delta; 185 bool _handleTimeDelta; 186 187 void initTime(SavegameType type, uint32 val); 188 void updateTime(uint32 time); 189 void adjustTime(); 190 void adjustIndex(uint32 time1, uint32 time2, bool searchEntry); 191 void goToTime(uint32 time); 192 void setTime(); 193 void forwardTime(); 194 void rewindTime(); hasTimeDelta()195 bool hasTimeDelta() { return (_currentTime - _time) >= 1; } 196 197 ////////////////////////////////////////////////////////////////////////// 198 // Sound/Brightness related 199 uint32 getVolume() const; 200 void setVolume(uint32 volume) const; 201 uint32 getBrightness() const; 202 void setBrightness(uint32 brightness) const; 203 }; 204 205 } // End of namespace LastExpress 206 207 #endif // LASTEXPRESS_MENU_H 208