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 ALCACHOFA_MENU_H
23 #define ALCACHOFA_MENU_H
24 
25 #include "common/savefile.h"
26 
27 namespace Alcachofa {
28 
29 class Room;
30 class SlideButton;
31 
32 // the order of these enums are compatible to V3 the first to be developed
33 // any other version needs some translation
34 
35 enum class MainMenuAction : int32 {
36  ContinueGame = 0,
37  Save,
38  Load,
39  InternetMenu,
40  OptionsMenu,
41  Exit,
42  NextSave,
43  PrevSave,
44  NewGame, // unused in any game
45  AlsoExit, // there seems to be no difference to Exit
46 
47  ConfirmSavestate, // only used in V1
48  Accept, // only used in V2
49  Cancel, // only used in V2
50 };
51 
52 enum class OptionsMenuAction : int32 {
53  SubtitlesOn = 0,
54  SubtitlesOff,
55  HighQuality,
56  LowQuality,
57  Bits32,
58  Bits16,
59  MainMenu,
60 
61  Cursor0, // only used in V2
62  Cursor1,
63  Cursor2,
64  Cursor3,
65 };
66 
67 enum class OptionsMenuValue : int32 {
68  Music = 0,
69  Speech = 1,
70  Sensitivity = 2 // only used in V2 and no effect for ScummVM
71 };
72 
73 class Menu {
74 public:
75  static Menu *create();
76  Menu();
77  virtual ~Menu();
78 
79  inline bool isOpen() const { return _isOpen; }
80  inline uint32 millisBeforeMenu() const { return _millisBeforeMenu; }
81  inline Room *previousRoom() { return _previousRoom; }
82  inline FakeSemaphore &interactionSemaphore() { return _interactionSemaphore; }
83  inline SlideButton *&currentSlideButton() { return _currentSlideButton; }
84 
85  void triggerLoad();
86  void resetAfterLoad();
87  virtual void updateOpeningMenu();
88 
89  virtual void triggerMainMenuAction(MainMenuAction action);
90  void triggerOptionsAction(OptionsMenuAction action);
91  void triggerOptionsValue(OptionsMenuValue valueId, float value);
92 
93  // if we do still have a big thumbnail, any autosaves, ScummVM-saves, ingame-saves
94  // do not have to render themselves, they can just reuse the one we have.
95  // as such - may return nullptr
96  const Graphics::Surface *getBigThumbnail() const;
97 
98 protected:
99  inline bool isOnNewSlot() const { return _selectedSavefileI >= _savefiles.size(); }
100  virtual void updateSelectedSavefile(bool hasJustSaved);
101  virtual void setOptionsState() = 0;
102 
103  void openOptionsMenu();
104  void triggerSave();
105  bool tryReadOldSavefile();
106  void continueGame();
107  void continueMainMenu();
108 
109  bool
110  _isOpen = false,
111  _openAtNextFrame = false;
112  uint32
113  _millisBeforeMenu = 0,
114  _selectedSavefileI = 0;
115  Room *_previousRoom = nullptr;
116  FakeSemaphore _interactionSemaphore; // to prevent ScummVM loading during button clicks
117  SlideButton *_currentSlideButton = nullptr; // due to V2 we cannot store this in OptionsMenu
118  Common::String _selectedSavefileDescription = "<unset>";
121  _bigThumbnail, // big because it is for the in-game menu, not for ScummVM
122  _selectedThumbnail;
123  Common::SaveFileManager *_saveFileMgr;
124 };
125 
126 class MenuV3 : public Menu {
127 public:
128  void triggerMainMenuAction(MainMenuAction action) override;
129 
130 protected:
131  void updateSelectedSavefile(bool hasJustSaved) override;
132  void setOptionsState() override;
133 };
134 
135 class MenuV2 : public Menu {
136 public:
137  void updateOpeningMenu() override;
138  void triggerMainMenuAction(MainMenuAction action) override;
139 
140 protected:
141  void updateSelectedSavefile(bool hasJustSaved) override;
142  void setOptionsState() override;
143  void toggleMessageBox(bool show);
144 };
145 
146 class MenuV1 : public Menu {
147 public:
148  void updateOpeningMenu() override;
149  void triggerMainMenuAction(MainMenuAction action) override;
150 
151 protected:
152  void updateSelectedSavefile(bool hasJustSaved) override;
153  void setOptionsState() override;
154 
155 private:
156  friend class ButtonV1;
157  void switchToState(MainMenuAction state);
158 
159  MainMenuAction _currentState = MainMenuAction::ConfirmSavestate;
160 };
161 
162 }
163 
164 #endif // ALCACHOFA_MENU_H
Definition: managed_surface.h:51
Definition: alcachofa.h:45
Definition: str.h:59
Definition: surface.h:67
Definition: menu.h:146
Definition: objects.h:346
Definition: menu.h:126
Definition: objects.h:163
Definition: menu.h:135
Definition: menu.h:73
Definition: savefile.h:142
Definition: rooms.h:31
This fake semaphore does not work in multi-threaded scenarios It is used as a safer option for a simp...
Definition: common.h:93