ScummVM API documentation
MainMenu.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/*
23 * Copyright (C) 2006-2010 - Frictional Games
24 *
25 * This file is part of Penumbra Overture.
26 */
27
28#ifndef GAME_MAIN_MENU_H
29#define GAME_MAIN_MENU_H
30
31#include "hpl1/engine/engine.h"
32
33#include "hpl1/penumbra-overture/GameTypes.h"
34
35using namespace hpl;
36
37class cInit;
38
39enum eMainMenuState {
40 eMainMenuState_Start,
41 eMainMenuState_NewGame,
42 eMainMenuState_Exit,
43 eMainMenuState_Continue,
44 eMainMenuState_Resume,
45
46 eMainMenuState_LoadGameSpot,
47 eMainMenuState_LoadGameAuto,
48 eMainMenuState_LoadGameFavorite,
49
50 eMainMenuState_Options,
51 eMainMenuState_OptionsGraphics,
52 eMainMenuState_OptionsGraphicsAdvanced,
53 eMainMenuState_OptionsControls,
54 eMainMenuState_OptionsGame,
55 eMainMenuState_OptionsSound,
56 eMainMenuState_OptionsKeySetupMove,
57 eMainMenuState_OptionsKeySetupAction,
58 eMainMenuState_OptionsKeySetupMisc,
59
60 eMainMenuState_GraphicsRestart,
61
62 eMainMenuState_FirstStart,
63
64 eMainMenuState_LastEnum
65};
66
67//---------------------------
68
70public:
71 cMainMenuWidget(cInit *apInit, const cVector3f &avPos, const cVector2f &avSize);
72 virtual ~cMainMenuWidget();
73
74 virtual void OnUpdate(float afTimeStep) {}
75
76 virtual void OnDraw() {}
77
78 virtual void OnMouseDown(eMButton aButton){};
79 virtual void OnMouseUp(eMButton aButton){};
80
81 virtual void OnDoubleClick(eMButton aButton){};
82
83 virtual void OnMouseOver(bool abOver) {}
84
85 const cRect2f &GetRect() { return mRect; }
86
87 virtual void Reset() {}
88
89 virtual void OnActivate() {}
90
91 bool IsActive() { return mbActive; }
92 void SetActive(bool abX) {
93 if (mbActive == abX)
94 return;
95
96 mbActive = abX;
97 if (mbActive)
98 OnActivate();
99 }
100
101 bool mbOver;
102
103protected:
104 cInit *mpInit;
105 cGraphicsDrawer *mpDrawer;
106
107 cVector3f mvPositon;
108 cRect2f mRect;
109
110 float mfAlpha;
111 bool mbActive;
112};
113
114//---------------------------------------------
115
117public:
118 cMainMenuWidget_MainButton(cInit *apInit, const cVector3f &avPos, const tWString &asText,
119 eMainMenuState aNextState);
121
122 void OnUpdate(float afTimeStep);
123
124 void OnMouseOver(bool abOver);
125
126 void OnDraw();
127
128 virtual void OnMouseDown(eMButton aButton);
129 virtual void OnMouseUp(eMButton aButton){};
130
131 void OnActivate() {
132 mfAlpha = 0;
133 mfOverTimer = 0;
134 mbOver = false;
135 }
136
137protected:
138 tWString msText;
139 tWString msTip;
140 FontData *mpFont;
141 bool mbOver;
142 cVector2f mvFontSize;
143 eMainMenuState mNextState;
144
145 float mfOverTimer;
146};
147
148//---------------------------------------------
149
151public:
152 cMainMenuWidget_Button(cInit *apInit, const cVector3f &avPos, const tWString &asText,
153 eMainMenuState aNextState, cVector2f avFontSize, eFontAlign aAlignment);
155
156 void OnUpdate(float afTimeStep);
157 void OnMouseOver(bool abOver);
158 void OnDraw();
159
160 virtual void OnMouseDown(eMButton aButton);
161 virtual void OnMouseUp(eMButton aButton){};
162
163 void OnActivate() {
164 mfAlpha = 0;
165 mfOverTimer = 0;
166 mbOver = false;
167 }
168
169 tWString msText;
170
171protected:
172 FontData *mpFont;
173
174 cVector2f mvFontSize;
175 eMainMenuState mNextState;
176 tWString msTip;
177
178 eFontAlign mAlignment;
179
180 float mfOverTimer;
181};
182
183//---------------------------------------------
184
186public:
187 cMainMenuWidget_Text(cInit *apInit, const cVector3f &avPos, const tWString &asText,
188 cVector2f avFontSize, eFontAlign aAlignment,
189 cMainMenuWidget *apExtra = NULL, float afMaxWidth = 0);
191
192 void OnDraw();
193 void OnMouseDown(eMButton aButton);
194 void OnMouseOver(bool abOver);
195
196 void SetExtraWidget(cMainMenuWidget *apExtra) { mpExtra = apExtra; }
197 cMainMenuWidget *GetExtraWidget() { return mpExtra; }
198
199 void UpdateSize();
200
201 tWString msText;
202
203protected:
204 FontData *mpFont;
205
206 eFontAlign mAlignment;
207
208 cVector2f mvFontSize;
209
210 float mfMaxWidth;
211
212 cMainMenuWidget *mpExtra;
213};
214
215//---------------------------------------------
216
218public:
219 cMainMenuWidget_Image(cInit *apInit, const cVector3f &avPos, const cVector2f &avSize,
220 const tString &asImageFile, const tString &asImageMat,
221 const cColor &aColor);
223
224 void OnDraw();
225
226protected:
227 cGfxObject *mpImage;
228 cColor mColor;
229
230 cVector2f mvSize;
231};
232
233//---------------------------------------------
234
236public:
237 cMainMenuWidget_List(cInit *apInit, const cVector3f &avPos, const cVector2f &avSize,
238 cVector2f avFontSize);
239
241
242 void OnUpdate(float afTimeStep);
243 void OnMouseOver(bool abOver);
244 void OnDraw();
245
246 void OnMouseDown(eMButton aButton);
247 void OnMouseUp(eMButton aButton);
248
249 void AddEntry(const tWString &asText);
250
251 const tWString &GetSelectedEntry();
252 int GetSelectedIndex() { return mlSelected; }
253 void SetSelectedIndex(int alIdx) { mlSelected = alIdx; }
254
255protected:
256 cGraphicsDrawer *mpDrawer;
257 FontData *mpFont;
258 cGfxObject *mpBackGfx;
259
260 cGfxObject *mpDownGfx;
261 cGfxObject *mpUpGfx;
262 cGfxObject *mpSlideGfx;
263 cGfxObject *mpSlideButtonGfx;
264 cGfxObject *mpBorderLeftGfx;
265 cGfxObject *mpBorderTopGfx;
266 cGfxObject *mpBorderBottomGfx;
267
268 float mfSlideButtonSize;
269 float mfSlideButtonPos;
270 bool mbSlideButtonPressed;
271 float mfSlideButtonMove;
272
273 bool mbOver;
274 cVector2f mvFontSize;
275 cVector3f mvPosition;
276 cVector2f mvSize;
277
278 eFontAlign mAlignment;
279
280 float mfOverTimer;
281
282 int mlMaxRows;
283
284 int mlFirstRow;
285
286 int mlSelected;
287 tWStringVec mvEntries;
288
289 cVector2f mvLastMousePos;
290};
291//---------------------------------------------
292
294public:
295 cMainMenuWidget_NewGame(cInit *apInit, const cVector3f &avPos, const tWString &asText,
296 cVector2f avFontSize, eFontAlign aAlignment,
297 eGameDifficulty aDiffuculty);
298
299 virtual void OnMouseDown(eMButton aButton);
300
301private:
302 eGameDifficulty mDiffuculty;
303};
304
305//---------------------------------------------
306
308public:
309 cMainMenuWidget_Continue(cInit *apInit, const cVector3f &avPos, const tWString &asText, cVector2f avFontSize, eFontAlign aAlignment);
310
311 virtual void OnMouseDown(eMButton aButton);
312};
313
314//---------------------------------------------
315
317public:
318 cMainMenuWidget_Quit(cInit *apInit, const cVector3f &avPos, const tWString &asText, cVector2f avFontSize, eFontAlign aAlignment);
319
320 virtual void OnMouseDown(eMButton aButton);
321};
322
323//---------------------------------------------
324
326public:
327 cMainMenuWidget_Resume(cInit *apInit, const cVector3f &avPos, const tWString &asText);
328
329 virtual void OnMouseDown(eMButton aButton);
330};
331
332//---------------------------------------------
333
336
337//---------------------------------------------
338
340public:
341 cVector3f mvPos;
342 cVector3f mvVel;
343 cVector2f mvSize;
344 cColor mCol;
345
346 cGfxObject *mpGfx;
347};
348
349//---------------------------------------------
350
351class cMainMenu : public iUpdateable {
352 friend class cMainMenuWidget;
353
354public:
355 cMainMenu(cInit *apInit);
356 ~cMainMenu();
357
358 void Reset();
359
360 void OnPostSceneDraw();
361
362 void OnDraw();
363
364 void Update(float afTimeStep);
365
366 void SetButtonTip(const tWString &asString) { msButtonTip = asString; }
367
368 void SetMousePos(const cVector2f &avPos);
369 void AddMousePos(const cVector2f &avRel);
370 cVector2f GetMousePos() { return mvMousePos; }
371
372 void OnMouseDown(eMButton aButton);
373 void OnMouseUp(eMButton aButton);
374
375 void OnMouseDoubleClick(eMButton aButton);
376
377 void SetActive(bool abX);
378 bool IsActive() { return mbActive; }
379
380 void OnExit();
381
382 void Exit();
383
384 void SetState(eMainMenuState aState);
385
386 void SetInputToAction(const tString &asActionName, cMainMenuWidget_Text *apText);
387
388 void InitCheckInput();
389 bool CheckForInput();
390
391 void ResetWidgets(eMainMenuState aState);
392
393 void UpdateWidgets() { mbUpdateWidgets = true; }
394
395private:
396 void DrawBackground();
397
398 void CreateWidgets();
399
400 void AddWidgetToState(eMainMenuState aState, cMainMenuWidget *apWidget);
401
402 cInit *mpInit;
403 cGraphicsDrawer *mpDrawer;
404
405 cGfxObject *mpGfxBlackQuad;
406 cGfxObject *mpGfxMouse;
407
408 cGfxObject *mpGfxRainDrop;
409 cGfxObject *mpGfxRainSplash;
410 cGfxObject *mpGfxSnowFlake;
411
412 iTexture *mpLogo;
413 iTexture *mpBackground;
414
415 tString msCurrentActionName;
416 cMainMenuWidget_Text *mpCurrentActionText;
417
418 tWString msButtonTip;
419 FontData *mpTipFont;
420
422 float mfRainDropCount;
423
425
427
428 bool mbMouseIsDown;
429
430 bool mbFadeIn;
431 float mfFadeAmount;
432
433 bool mbActive;
434 float mfAlpha;
435
436 bool mbUpdateWidgets;
437
438 eMainMenuState mLastState;
439
440 FontData *mpFont;
441
442 cVector2f mvMousePos;
443
444 tMainMenuWidgetList mlstWidgets;
445
446 eMainMenuState mState;
448
449 bool mbGameActive;
450
451 bool mvKeyPressed[Common::KEYCODE_LAST];
452 bool mvMousePressed[eMButton_LastEnum];
453};
454
455//---------------------------------------------
456
457#endif // GAME_MAIN_MENU_H
Definition: str.h:59
Definition: ustr.h:57
Definition: Init.h:70
Definition: MainMenu.h:351
Definition: MainMenu.h:339
Definition: MainMenu.h:150
Definition: MainMenu.h:307
Definition: MainMenu.h:217
Definition: MainMenu.h:235
Definition: MainMenu.h:116
Definition: MainMenu.h:293
Definition: MainMenu.h:316
Definition: MainMenu.h:325
Definition: MainMenu.h:185
Definition: MainMenu.h:69
Definition: font_data.h:67
Definition: Color.h:37
Definition: GfxObject.h:38
Definition: GraphicsDrawer.h:77
Definition: Texture.h:88
Definition: Updateable.h:35
Definition: list_intern.h:54