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