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 TOLTECS_MENU_H
23#define TOLTECS_MENU_H
24
25#include "common/array.h"
26#include "common/str-array.h"
27
28namespace Toltecs {
29
30enum ItemID {
31 kItemIdNone,
32 // Main menu
33 kItemIdSave,
34 kItemIdLoad,
35 kItemIdToggleText,
36 kItemIdToggleVoices,
37 kItemIdVolumesMenu,
38 kItemIdPlay,
39 kItemIdQuit,
40 // Volumes menu
41 kItemIdMasterUp,
42 kItemIdVoicesUp,
43 kItemIdMusicUp,
44 kItemIdSoundFXUp,
45 kItemIdBackgroundUp,
46 kItemIdMasterDown,
47 kItemIdVoicesDown,
48 kItemIdMusicDown,
49 kItemIdSoundFXDown,
50 kItemIdBackgroundDown,
51 kItemIdMaster,
52 kItemIdVoices,
53 kItemIdMusic,
54 kItemIdSoundFX,
55 kItemIdBackground,
56 kItemIdDone,
57 kItemIdCancel,
58 // Save/load menu
59 kItemIdSavegameUp,
60 kItemIdSavegameDown,
61 kItemIdSavegame1,
62 kItemIdSavegame2,
63 kItemIdSavegame3,
64 kItemIdSavegame4,
65 kItemIdSavegame5,
66 kItemIdSavegame6,
67 kItemIdSavegame7,
68 // TODO
69 kMenuIdDummy
70};
71
73
74public:
77
78 int run(MenuID menuId);
79 void update();
80 void handleEvents();
81
82protected:
83
84 struct Item {
85 bool enabled;
86 Common::Rect rect;
87 ItemID id;
88 Common::String caption;
89 byte defaultColor, activeColor;
90 int x, y, w;
91 uint fontNum;
92 };
93
94 struct SavegameItem {
95 int _slotNum;
96 Common::String _description;
98 : _slotNum(-1), _description("") {}
99 SavegameItem(int slotNum, Common::String description)
100 : _slotNum(slotNum), _description(description) {}
101 };
102
103 ToltecsEngine *_vm;
104 Graphics::Surface *_background;
105
106 bool _running;
107 MenuID _currMenuID, _newMenuID;
108 ItemID _currItemID;
109 int _top;
110 int _savegameListTopIndex;
111 bool _editingDescription;
112 ItemID _editingDescriptionID;
113 Item *_editingDescriptionItem;
114 bool _needRedraw;
115 bool _returnToGame;
116
117 Common::Array<Item> _items;
119
120 void addClickTextItem(ItemID id, int x, int y, int w, uint fontNum, const char *caption, byte defaultColor, byte activeColor);
121
122 void drawItem(ItemID itemID, bool active);
123 void handleMouseMove(int x, int y);
124 void handleMouseClick(int x, int y);
125 void handleKeyDown(const Common::KeyState& kbd);
126
127 ItemID findItemAt(int x, int y);
128 Item *getItem(ItemID id);
129 void setItemCaption(Item *item, const char *caption);
130
131 void initMenu(MenuID menuID);
132
133 void enableItem(ItemID id);
134 void disableItem(ItemID id);
135
136 void enterItem(ItemID id);
137 void leaveItem(ItemID id);
138 void clickItem(ItemID id);
139
140 void restoreRect(int x, int y, int w, int h);
141 void shadeRect(int x, int y, int w, int h, byte color1, byte color2);
142 void drawString(int16 x, int16 y, int w, uint fontNum, byte color, const char *text);
143
144 SavegameItem *getSavegameItemByID(ItemID id);
145
146 int loadSavegamesList();
147 void setSavegameCaptions(bool scrollToBottom);
148 void scrollSavegames(int delta);
149 void clickSavegameItem(ItemID id);
150 void setCfgText(bool value, bool active);
151 void setCfgVoices(bool value, bool active);
152 void drawVolumeBar(ItemID itemID);
153 void changeVolumeBar(ItemID itemID, int delta);
154
155};
156
157} // End of namespace Toltecs
158
159#endif /* TOLTECS_MENU_H */
Definition: str.h:59
Definition: menu.h:72
Definition: toltecs.h:104
Definition: keyboard.h:294
Definition: rect.h:536
Definition: surface.h:67
Definition: menu.h:84