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 #ifndef PELROCK_MENU_H
22 #define PELROCK_MENU_H
23 
24 #include "graphics/font.h"
25 #include "graphics/managed_surface.h"
26 #include "graphics/screen.h"
27 
28 #include "pelrock/events.h"
29 #include "pelrock/resources.h"
30 #include "pelrock/sound.h"
31 
32 namespace Pelrock {
33 
34 enum MainMenuButton {
35  QUESTION_MARK_BUTTON,
36  INVENTORY_PREV_BUTTON,
37  INVENTORY_NEXT_BUTTON,
38  SAVEGAME_PREV_BUTTON,
39  SAVEGAME_NEXT_BUTTON,
40  EXIT_MENU_BUTTON,
41  SAVE_GAME_BUTTON,
42  LOAD_GAME_BUTTON,
43  SOUNDS_BUTTON,
44  NO_MAIN_BUTTON
45 };
46 
47 enum SoundMenuButton {
48  MASTER_LEFT_BUTTON,
49  MASTER_RIGHT_BUTTON,
50  SFX_LEFT_BUTTON,
51  SFX_RIGHT_BUTTON,
52  MUSIC_LEFT_BUTTON,
53  MUSIC_RIGHT_BUTTON,
54  NO_SOUND_BUTTON
55 };
56 
57 static const int kCreditsOrder[34] = {
58  5, // PROGRAMACION
59  8, // Juan Jose Gil
60  20, // Jose Vicente Pons
61  24, // LuisFer Fernandez
62  22, // Fernando Perez
63  7, // GRAFICOS
64  12, // Queral,
65  14, // Ana maria polo
66  18, // Juan Arocas
67  16, // Gost
68  26, // Astorga
69  28, // Santi Sanz
70  2, // Fernando Aparicio
71  11, // INTRODUCCION
72  12, // Queral,
73  26, // Astorga
74  28, // Santi Sanz
75  9, // MUSICA
76  6, // Rufino Acosta
77  13, // GUION
78  8, // Juan Jose Gil
79  19, // DIALOGOS
80  4, // Vicent raul arnau,
81  8, // Juan Jose Gil,
82  21, // PROBADORES
83  0, // David Burgos
84  10, // Alberto Leon
85  1, // Carles Pons
86  3, // Roman Pons
87  25, // Andres Ruiz,
88  27, // Juan Jose Ruiz
89  23, // Marilo
90  15, // PRODUCCION
91  17 // DDM
92 };
93 
94 class MenuManager {
95 
96  enum MenuState {
97  MAIN_MENU,
98  SOUND,
99  ORIGINAL_SAVE,
100  ORIGINAL_LOAD,
101  EXIT_GAME
102  };
103 
104 public:
106  ~MenuManager();
107  void menuLoop();
108  void saveScreenshot();
109  void drawScreen();
110  void drawInventoryIcons();
111  void loadMenu();
112  byte _mainMenuPalette[768] = {0};
113 
114 private:
115  void checkMouseDown(int x, int y);
116  bool checkMouseClick(int x, int y);
117  void checkSoundMenuClick(int x, int y);
118  bool checkMainMenuMouse(int x, int y); // returns bool if its supposed to close the menu
119  void showCredits();
120  bool selectInventoryItem(int i);
121  void loadMenuTexts();
122  void cleanUp();
123  void drawButtons();
124  void drawConfirmation();
125  void drawSaves();
126  void drawMainButtons();
127  void drawSoundControls();
128  void readButton(byte *rawData, uint32 offset, byte *outBuffer[2], int w, int h);
129  void readButton(Common::File &alfred7, uint32 offset, byte *outBuffer[2], Common::Rect rect);
130  void refreshSaveDescriptions();
131  void handleSaveMenuKey(Common::KeyCode key, uint16 ascii);
132  void backToMainMenu();
133  SoundMenuButton isSoundMenuButtonUnder(int x, int y);
134  MainMenuButton isMainMenuButtonUnder(int x, int y);
135  Graphics::Screen *_screen = nullptr;
136  PelrockEventManager *_events = nullptr;
137  ResourceManager *_res = nullptr;
138  SoundManager *_sound = nullptr;
139  Graphics::ManagedSurface _mainMenu;
140  Graphics::ManagedSurface _compositeBuffer;
141 
142  Common::Rect _saveGameRect = Common::Rect(Common::Point(132, 186), 81, 34);
143  byte *_saveButtons[2] = {nullptr};
144 
145  Common::Rect _loadGameRect = Common::Rect(Common::Point(133, 222), 80, 33);
146  byte *_loadButtons[2] = {nullptr};
147 
148  Common::Rect _soundsRect = Common::Rect(Common::Point(134, 258), 77, 33);
149  byte *_soundsButtons[2] = {nullptr};
150 
151  Common::Rect _exitToDosRect = Common::Rect(Common::Point(134, 293), 75, 30);
152  byte *_exitToDosButtons[2] = {nullptr};
153 
154  Common::Rect _invLeft = Common::Rect(Common::Point(469, 88), 26, 37);
155  byte *_inventoryLeftArrow[2] = {nullptr};
156 
157  Common::Rect _invRight = Common::Rect(Common::Point(463, 132), 26, 37);
158  byte *_inventoryRightArrow[2] = {nullptr};
159 
160  Common::Rect _savesUp = Common::Rect(Common::Point(457, 189), 26, 24);
161  byte *_savesUpArrows[2] = {nullptr};
162 
163  Common::Rect _savesDown = Common::Rect(Common::Point(450, 278), 26, 24);
164  byte *_savesDownArrows[2] = {nullptr};
165 
166  Common::Rect _questionMarkRect = Common::Rect(Common::Point(217, 293), 31, 30);
167  byte *_questionMark[2] = {nullptr};
168 
169  Common::Rect _masterVolumeLeftRect = Common::Rect(Common::Point(232, 252), 36, 28);
170  Common::Rect _masterVolumeRightRect = Common::Rect(Common::Point(268, 252), 31, 28);
171 
172  Common::Rect _musicVolumeLeftRect = Common::Rect(Common::Point(298, 252), 36, 28);
173  Common::Rect _musicVolumeRightRect = Common::Rect(Common::Point(334, 252), 31, 28);
174 
175  Common::Rect _sfxVolumeLeftRect = Common::Rect(Common::Point(364, 252), 36, 28);
176  Common::Rect _sfxVolumeRightRect = Common::Rect(Common::Point(400, 252), 31, 28);
177 
178  byte *_soundControlArrowLeft[2] = {nullptr};
179  byte *_soundControlArrowRight[2] = {nullptr};
180 
181  byte *_soundControlMasterIcon = nullptr;
182  byte *_soundControlSfxIcon = nullptr;
183  byte *_soundControlMusicIcon = nullptr;
184 
185  Graphics::ManagedSurface _masterSoundIcon;
186  Graphics::ManagedSurface _sfxSoundIcon;
187  Graphics::ManagedSurface _musicSoundIcon;
188 
189  int _masterVolumeLevel = 14;
190  int _sfxVolumeLevel = 14;
191  int _musicVolumeLevel = 14;
192 
194  // Temporary
195  int _selectedInvIndex = 0;
196  uint _curInventoryPage = 0;
197  Common::StringArray _menuText;
198  Common::Array<Common::StringArray> _inventoryDescriptions;
199  Common::Array<Common::Point> _inventorySlots;
200 
201  bool showButtons = true;
202  MenuState _menuState = MAIN_MENU;
203  int _textLineH = 0;
204 
205  // Save/Load sub-menu state
206  int _saveGamePage = 0;
207  int _editingSaveSlot = -1; // -1 = not editing any slot
208  Common::String _editingName; // name being typed for a save
209  Common::Rect _cancelRect; // hit-rect for the CANCELAR row
210  Common::Array<Common::Rect> _saveSlotRects; // hit-rects for the 8 visible save rows
211  Common::StringArray _saveDescriptions; // indexed by slot 0-255
212 };
213 
214 } // End of namespace Pelrock
215 #endif // PELROCK_MENU_H
Definition: managed_surface.h:51
Definition: str.h:59
Definition: array.h:52
Definition: events.h:29
Definition: actions.h:27
Definition: rect.h:524
Definition: screen.h:47
Definition: file.h:47
Definition: rect.h:144
Definition: resources.h:36
Definition: sound.h:59
Definition: menu.h:94