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