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 
31 enum class MainMenuAction : int32 {
32  ContinueGame = 0,
33  Save,
34  Load,
35  InternetMenu,
36  OptionsMenu,
37  Exit,
38  NextSave,
39  PrevSave,
40  NewGame,
41  AlsoExit, // there seems to be no difference to Exit
42 
43  ConfirmSavestate, // only used in V1
44 };
45 
46 enum class OptionsMenuAction : int32 {
47  SubtitlesOn = 0,
48  SubtitlesOff,
49  HighQuality,
50  LowQuality,
51  Bits32,
52  Bits16,
53  MainMenu
54 };
55 
56 enum class OptionsMenuValue : int32 {
57  Music = 0,
58  Speech = 1
59 };
60 
61 class Menu {
62 public:
63  Menu();
64  virtual ~Menu();
65 
66  inline bool isOpen() const { return _isOpen; }
67  inline uint32 millisBeforeMenu() const { return _millisBeforeMenu; }
68  inline Room *previousRoom() { return _previousRoom; }
69  inline FakeSemaphore &interactionSemaphore() { return _interactionSemaphore; }
70 
71  void triggerLoad();
72  void resetAfterLoad();
73  virtual void updateOpeningMenu();
74 
75  virtual void triggerMainMenuAction(MainMenuAction action);
76  void triggerOptionsAction(OptionsMenuAction action);
77  void triggerOptionsValue(OptionsMenuValue valueId, float value);
78 
79  // if we do still have a big thumbnail, any autosaves, ScummVM-saves, ingame-saves
80  // do not have to render themselves, they can just reuse the one we have.
81  // as such - may return nullptr
82  const Graphics::Surface *getBigThumbnail() const;
83 
84 protected:
85  inline bool isOnNewSlot() const { return _selectedSavefileI >= _savefiles.size(); }
86  virtual void updateSelectedSavefile(bool hasJustSaved);
87  virtual void setOptionsState() = 0;
88 
89  void openOptionsMenu();
90  void triggerSave();
91  bool tryReadOldSavefile();
92  void continueGame();
93  void continueMainMenu();
94 
95  bool
96  _isOpen = false,
97  _openAtNextFrame = false;
98  uint32
99  _millisBeforeMenu = 0,
100  _selectedSavefileI = 0;
101  Room *_previousRoom = nullptr;
102  FakeSemaphore _interactionSemaphore; // to prevent ScummVM loading during button clicks
103  Common::String _selectedSavefileDescription = "<unset>";
106  _bigThumbnail, // big because it is for the in-game menu, not for ScummVM
107  _selectedThumbnail;
108  Common::SaveFileManager *_saveFileMgr;
109 };
110 
111 class MenuV3 : public Menu {
112 public:
113  void triggerMainMenuAction(MainMenuAction action) override;
114 
115 protected:
116  void updateSelectedSavefile(bool hasJustSaved) override;
117  void setOptionsState() override;
118 };
119 
120 class MenuV1 : public Menu {
121 public:
122  void updateOpeningMenu() override;
123  void triggerMainMenuAction(MainMenuAction action) override;
124 
125 protected:
126  void updateSelectedSavefile(bool hasJustSaved) override;
127  void setOptionsState() override;
128 
129 private:
130  friend class ButtonV1;
131  void switchToState(MainMenuAction state);
132 
133  MainMenuAction _currentState = MainMenuAction::ConfirmSavestate;
134 };
135 
136 }
137 
138 #endif // ALCACHOFA_MENU_H
Definition: managed_surface.h:51
Definition: alcachofa.h:45
Definition: str.h:59
Definition: surface.h:67
Definition: menu.h:120
Definition: menu.h:111
Definition: objects.h:163
Definition: menu.h:61
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