-
Notifications
You must be signed in to change notification settings - Fork 0
/
menu.h
169 lines (141 loc) · 4.21 KB
/
menu.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* $URL: https://www.switchlink.se/svn/picture/resource.h $
* $Id: resource.h 2 2008-08-04 12:18:15Z johndoe $
*
*/
#ifndef PICTURE_MENU_H
#define PICTURE_MENU_H
#include "common/array.h"
#include "common/str-array.h"
namespace Picture {
enum MenuID {
kMenuIdNone,
kMenuIdMain,
kMenuIdSave,
kMenuIdLoad,
kMenuIdVolumes
};
enum ItemID {
kItemIdNone,
// Main menu
kItemIdSave,
kItemIdLoad,
kItemIdToggleText,
kItemIdToggleVoices,
kItemIdVolumesMenu,
kItemIdPlay,
kItemIdQuit,
// Volumes menu
kItemIdMasterUp,
kItemIdVoicesUp,
kItemIdMusicUp,
kItemIdSoundFXUp,
kItemIdBackgroundUp,
kItemIdMasterDown,
kItemIdVoicesDown,
kItemIdMusicDown,
kItemIdSoundFXDown,
kItemIdBackgroundDown,
kItemIdMaster,
kItemIdVoices,
kItemIdMusic,
kItemIdSoundFX,
kItemIdBackground,
kItemIdDone,
kItemIdCancel,
// Save/load menu
kItemIdSavegameUp,
kItemIdSavegameDown,
kItemIdSavegame1,
kItemIdSavegame2,
kItemIdSavegame3,
kItemIdSavegame4,
kItemIdSavegame5,
kItemIdSavegame6,
kItemIdSavegame7,
// TODO
kMenuIdDummy
};
class MenuSystem {
public:
MenuSystem(PictureEngine *vm);
~MenuSystem();
int run();
void update();
void handleEvents();
protected:
struct Item {
Common::Rect rect;
ItemID id;
Common::String caption;
byte defaultColor, activeColor;
int x, y, w;
uint fontNum;
};
struct SavegameItem {
int _slotNum;
Common::String _description;
SavegameItem()
: _slotNum(-1), _description("") {}
SavegameItem(int slotNum, Common::String description)
: _slotNum(slotNum), _description(description) {}
};
PictureEngine *_vm;
Graphics::Surface *_background;
bool _running;
MenuID _currMenuID, _newMenuID;
ItemID _currItemID;
int _top;
int _savegameListTopIndex;
bool _editingDescription;
ItemID _editingDescriptionID;
Item *_editingDescriptionItem;
bool _needRedraw;
Common::Array<Item> _items;
Common::Array<SavegameItem> _savegames;
bool _cfgText, _cfgVoices;
int _cfgMasterVolume, _cfgVoicesVolume, _cfgMusicVolume, _cfgSoundFXVolume, _cfgBackgroundVolume;
void addClickTextItem(ItemID id, int x, int y, int w, uint fontNum, const char *caption, byte defaultColor, byte activeColor);
void drawItem(ItemID itemID, bool active);
void handleMouseMove(int x, int y);
void handleMouseClick(int x, int y);
void handleKeyDown(const Common::KeyState& kbd);
ItemID findItemAt(int x, int y);
Item *getItem(ItemID id);
void setItemCaption(Item *item, const char *caption);
void initMenu(MenuID menuID);
void enterItem(ItemID id);
void leaveItem(ItemID id);
void clickItem(ItemID id);
void restoreRect(int x, int y, int w, int h);
void shadeRect(int x, int y, int w, int h, byte color1, byte color2);
void drawString(int16 x, int16 y, int w, uint fontNum, byte color, const char *text);
SavegameItem *getSavegameItemByID(ItemID id);
int loadSavegamesList();
void setSavegameCaptions();
void scrollSavegames(int delta);
void clickSavegameItem(ItemID id);
void setCfgText(bool value, bool active);
void setCfgVoices(bool value, bool active);
void drawVolumeBar(ItemID itemID);
void changeVolumeBar(ItemID itemID, int delta);
};
} // End of namespace Picture
#endif /* PICTURE_MENU_H */