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 HARVESTER_MENU_H
23#define HARVESTER_MENU_H
24
25#include "common/array.h"
26#include "common/error.h"
27#include "common/rect.h"
28#include "common/str.h"
29#include "harvester/art.h"
30
31namespace Graphics {
32class Font;
33}
34
35namespace Common {
36struct Event;
37}
38
39namespace Harvester {
40
41class HarvesterEngine;
42class Flow;
43class ResourceManager;
44
47 Common::String yesLabel = "YES";
48 Common::String noLabel = "NO";
49 Common::String clickLabel = "CLICK";
50 Common::String onLabel = "On";
51 Common::String offLabel = "Off";
52 Common::String enterPasswordLabel = "ENTER PASSWORD";
53 Common::String newGamePrompt = "NEW GAME";
54 Common::String quitGamePrompt = "QUIT GAME";
55 Common::String talkToVerb = "Talk to";
56 Common::String examineVerb = "Examine";
57 Common::String examineTheVerb = "Examine the";
58 Common::String operateVerb = "Operate the";
59 Common::String pickUpVerb = "Pick up the";
60 Common::String useVerb = "Use";
61 Common::String useOnPreposition = "on";
62 Common::String dialogueOtherLabel = "Other";
63 Common::String dialogueResponsesLabel = "Responses";
64 Common::String dialogueKeywordLabel;
66 Common::String quickTipsExitLabel = "Exit";
67 Common::String quickTipsNextLabel = "Next";
68 Common::String quickTipsOnLabel = "Show Tips ON";
69 Common::String quickTipsOffLabel = "Show Tips OFF";
70 Common::String quickTipsHeader;
71
72 bool hasDialogueKeywordLabel() const { return !dialogueKeywordLabel.empty(); }
73 bool hasQuickTipsHeader() const { return !quickTipsHeader.empty(); }
74};
75
77 Common::Rect exitRect;
78 Common::Rect nextRect;
79 Common::Rect toggleRect;
80};
81
82bool loadMenuTextConfig(HarvesterEngine &engine, MenuTextConfig &config);
83Common::String buildUseItemPrompt(const MenuTextConfig &config,
84 const Common::String &itemLabel, const Common::String &targetLabel);
85bool resolveQuickTipsLayout(HarvesterEngine &engine, const MenuTextConfig &config,
86 QuickTipsLayout &layout);
87void drawQuickTipsPanel(HarvesterEngine &engine, const MenuTextConfig &config,
88 const QuickTipsLayout &layout, const Common::String &tipText);
89
91public:
92 MenuSystem(HarvesterEngine &engine, Common::Point &mousePos,
93 const Common::Array<Common::String> &menuItems);
94
95 Common::Error runMainMenu(Flow &flow);
96 Common::Error runHelpScreen(const byte *palette, float paletteBrightness, Flow &flow);
97 Common::Error runRoomMenu(const IndexedBitmap &backdrop, const byte *palette,
98 float paletteBrightness, Flow &flow, bool canSaveGame);
99 Common::Error validateParentalPassword(Flow &flow);
100 Common::Error showCdChangePrompt(int discNumber, ResourceManager &resources,
101 Flow &flow, bool &promptCompleted);
102
103private:
104 static bool loadPaletteResource(ResourceManager &resources, const Common::String &path, byte *palette);
105 struct MenuSelection;
106 struct MainMenu;
107 struct RoomMenu;
108 struct RoomMenuActivationResult;
109 enum MenuNavigationCommand { kNoMenuCommand, kActivateMenuItem, kCloseMenu };
110 MenuNavigationCommand handleMenuNavigationEvent(MenuSelection &selection,
111 const Common::Event &event, bool useBackdrop) const;
112 bool captureMainMenuBackdrop(MainMenu &menu, IndexedBitmap &backdrop);
113 Common::Error runMainMenuRoomLoop(MainMenu &menu, const Common::String &targetName);
114 Common::Error startNewGameFromMainMenu(MainMenu &menu, const byte *menuPalette);
115 Common::Error loadGameFromMainMenu(MainMenu &menu, const byte *menuPalette);
116 Common::Error activateMainMenuItem(MainMenu &menu);
117 RoomMenuActivationResult startNewGameFromRoomMenu(RoomMenu &menu);
118 RoomMenuActivationResult saveGameFromRoomMenu(RoomMenu &menu);
119 RoomMenuActivationResult activateRoomMenuItem(RoomMenu &menu);
120
121 static bool loadBitmapResource(ResourceManager &resources, const Common::String &path, IndexedBitmap &bitmap);
122 static int getNativeRoomMenuSelectionFromMouse(const Graphics::Font &selectedFont, uint itemCount,
123 const Common::Point &mousePos);
124
125 struct OptionsMenu;
126 void updateOptionsSlider(OptionsMenu &menu, int sliderIndex);
127 void cycleOptionsTextMode(OptionsMenu &menu);
128 void toggleOptionsGore(OptionsMenu &menu);
129 void toggleOptionsPassword(OptionsMenu &menu);
130 Common::Error activateOptionsItem(OptionsMenu &menu);
131 Common::Error handleOptionsQuickTipsEvent(OptionsMenu &menu, const Common::Event &event);
132 void handleOptionsMouseMove(OptionsMenu &menu, const Graphics::Font &selectedFont);
133 Common::Error handleOptionsMouseDown(OptionsMenu &menu, const Graphics::Font &selectedFont);
134 Common::Error handleOptionsKey(OptionsMenu &menu, const Common::Event &event, bool &closed);
135 Common::Error handleOptionsEvent(OptionsMenu &menu, const Common::Event &event,
136 const Graphics::Font &selectedFont, bool &closed);
137
138 struct SaveSlotMenu;
139 struct SaveSlotEventResult;
140 enum SaveLoadMode { kSaveMode, kLoadMode };
141 enum SaveSlotCommand { kNoSlotCommand, kConfirmSlot, kCancelSlot };
142
143 SaveSlotEventResult handleSaveSlotEvent(SaveSlotMenu &menu, SaveLoadMode mode,
144 const Common::Event &event) const;
145 Common::Error runSaveSlotMenu(Flow &flow, SaveLoadMode mode, bool &completed);
146 void reloadSaveSlotTitles(SaveSlotMenu &menu) const;
147 int getSaveSlotAt(const Common::Point &mousePos) const;
148 SaveSlotCommand getSaveSlotCommand(const Common::Event &event) const;
149 void renderSaveSlotMenu(const SaveSlotMenu &menu, const Common::String *editingText = nullptr) const;
150 Common::Error runSaveSlotEditor(SaveSlotMenu &menu, Flow &flow,
151 Common::String &editedTitle, bool &confirmed);
152 Common::Error saveSelectedSlot(SaveSlotMenu &menu, Flow &flow, bool &saved);
153 void loadSelectedSlot(SaveSlotMenu &menu, bool &loaded);
154
155 Common::Error runLoadGameMenu(const byte *palette, float paletteBrightness,
156 Flow &flow, bool &loadedGame);
157 Common::Error runOptionsMenu(const IndexedBitmap &backdrop, const byte *palette,
158 float paletteBrightness, Flow &flow);
159 Common::Error runSaveGameMenu(const byte *palette, float paletteBrightness,
160 Flow &flow, bool &savedGame);
161 Common::Error restoreRoomBackdropAfterSave(const IndexedBitmap &backdrop, const byte *palette,
162 float paletteBrightness, Flow &flow) const;
163 Common::Error runConfirmPrompt(const IndexedBitmap &backdrop, const byte *palette,
164 float paletteBrightness, Flow &flow, const Common::String &promptText,
165 bool &confirmed);
166 Common::Error runQuitGameConfirm(const IndexedBitmap &backdrop, const byte *palette,
167 float paletteBrightness, Flow &flow);
168 struct PasswordPromptResult {
169 Common::String password;
170 bool accepted = false;
171 };
172 Common::Error runPasswordPrompt(const IndexedBitmap &backdrop, const byte *palette,
173 float paletteBrightness, Flow &flow, bool drawLogo, PasswordPromptResult &prompt) const;
174 Common::Error showGameOverBackdrop(Flow &flow);
175 void clearMainMenuBackdrop();
176 void renderMainMenuScreen(int selectedItem, const Common::String &statusMessage,
177 bool drawCursor, const Common::Array<Common::String> &menuItems) const;
178 void renderBackdropMenuScreen(const IndexedBitmap &backdrop, const byte *palette,
179 float paletteBrightness, const Common::Array<Common::String> &menuItems,
180 int selectedItem) const;
181 int getMenuItemAt(const Common::Point &mousePos, const Common::Array<Common::String> &menuItems) const;
182 int getBackdropMenuItemAt(const Common::Point &mousePos,
183 const Common::Array<Common::String> &menuItems) const;
184
185 HarvesterEngine &_engine;
186 Common::Point &_mousePos;
187 const Common::Array<Common::String> &_menuItems;
188 IndexedBitmap _mainMenuBackdrop;
189 byte _mainMenuBackdropPalette[256 * 3] = { 0 };
190 bool _hasMainMenuBackdrop = false;
191};
192
193} // End of namespace Harvester
194
195#endif // HARVESTER_MENU_H
Definition: error.h:81
Definition: str.h:59
Definition: font.h:83
Definition: flow.h:45
Definition: harvester.h:47
Definition: menu.h:90
Definition: resources.h:32
Definition: algorithm.h:29
Definition: formatinfo.h:28
Definition: events.h:218
Definition: rect.h:144
Definition: rect.h:536
Definition: bitmap.h:33
Definition: menu.h:45
Definition: menu.h:76