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 DGDS_MENU_H
23 #define DGDS_MENU_H
24 
25 #include "common/error.h"
26 #include "common/events.h"
27 #include "common/platform.h"
28 
29 #include "graphics/surface.h"
30 #include "graphics/managed_surface.h"
31 
32 #include "engines/advancedDetector.h"
33 #include "engines/engine.h"
34 
35 #include "gui/debugger.h"
36 
37 #include "dgds/resource.h"
38 #include "dgds/request.h"
39 
40 namespace Dgds {
41 
42 class REQFileData;
43 
44 enum MenuId {
45  // Request data numbers, most are same in both RoTD and China VCRs
46  kMenuNone = 0,
47  kMenuMainBeamish = 3,
48  kMenuMain = 5,
49  kMenuControls = 7,
50  kMenuOptions = 29,
51  kMenuCalibrate = 30,
52  kMenuFiles = 21,
53  kMenuGameOver = 41,
54  kMenuRestart = 39,
55  kMenuCantSave = 36,
56  kMenuSaveNeedName = 43,
57  kMenuNotSavedDiskFull = 42,
58  kMenuReplaceSave = 38,
59  kMenuSaveDlg = 23,
60  kMenuChangeDir = 25,
61  kMenuAskCreateDir = 26,
62  kMenuInvalidDir = 37,
63  kMenuCalibrateJoystick = 28,
64  kMenuCalibrateMouse = 32,
65  kMenuReallyQuit = 35,
66  kMenuReplayArcade = 45,
67  kMenuSaveBeforeArcade = 46,
68  kMenuArcadeFrustrated = 47,
69  kMenuSkipPlayIntro = 50,
70  kMenuSkipArcade = 52,
71 };
72 
73 class Menu {
74 private:
75  Graphics::Surface _screenBuffer;
76  MenuId _curMenu = kMenuMain;
77 
78 public:
79  Menu();
80  virtual ~Menu();
81 
82  void setScreenBuffer();
83  void drawMenu(MenuId menu = kMenuMain);
84  void onMouseLUp(const Common::Point &mouse);
85  void onMouseLDown(const Common::Point &mouse);
86  void onMouseMove(const Common::Point &mouse);
87  bool menuShown() const { return _curMenu != kMenuNone; }
88  void hideMenu() { _curMenu = kMenuNone; }
89 
90  void setRequestData(const REQFileData &data);
91  void prevChoice();
92  void nextChoice();
93  void activateChoice();
94 
95 private:
96  Gadget *getClickedMenuItem(const Common::Point &mouseClick);
97  void drawMenuText(Graphics::ManagedSurface &dst);
98  void toggleGadget(int16 gadgetId, bool enable);
99  void configureGadget(MenuId menu, Gadget *gadget);
100  bool updateOptionsGadget(Gadget *gadget);
101  void handleClick(const Common::Point &mouse);
102  void handleClickOptionsMenu(const Common::Point &mouse);
103  void handleClickSkipPlayIntroMenu(const Common::Point &mouse);
104 
105  void putMouseOnSelectedItem();
106  Gadget *getSelectedItem();
107 
108  Common::HashMap<int, RequestData> _menuRequests;
109 
110  SliderGadget *_dragGadget;
111  Common::Point _dragStartPt;
112  int _selectedItem;
113  int _numSelectable;
114 };
115 
116 } // End of namespace Dgds
117 
118 #endif // DGDS_DGDS_H
Definition: managed_surface.h:51
Definition: surface.h:67
Definition: ads.h:28
Definition: request.h:63
Definition: menu.h:73
Definition: hashmap.h:85
Definition: rect.h:45
Definition: request.h:219
Definition: request.h:134