ScummVM API documentation
menu_room.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 M4_BURGER_ROOMS_SECTION9_MENU_ROOM_H
23 #define M4_BURGER_ROOMS_SECTION9_MENU_ROOM_H
24 
25 #include "common/array.h"
26 #include "m4/wscript/ws_machine.h"
27 #include "m4/burger/rooms/room.h"
28 
29 namespace M4 {
30 namespace Burger {
31 namespace Rooms {
32 
33 constexpr int NO_BUTTONS_HILITED = -1;
34 
35 enum ButtonState { BTNSTATE_DISABLED = 0, BTNSTATE_ENABLED = 1, BTNSTATE_HIGHLIGHTED = 2, BTNSTATE_PRESSED = 3 };
36 
37 struct MenuButtonDef {
38  int32 _x1;
39  int32 _y1;
40  int32 _x2;
41  int32 _y2;
42  int32 _frame_disabled;
43  int32 _frame_enabled;
44  int32 _frame_highlighted;
45  int32 _frame_pressed;
46  ButtonState _state;
47  int32 _trigger;
48 };
49 
50 struct MenuButton : public MenuButtonDef {
51  machine *_machine = nullptr;
52 
53  MenuButton() : MenuButtonDef() {}
54  MenuButton(const MenuButtonDef &def) : MenuButtonDef(def) {}
55 };
56 
60 class MenuRoom : public Rooms::Room {
61 private:
62  const char *_menuName;
63  const char *_clickName;
64  int _buttonNum = -1;
65  int _highlightedButton = -1;
66  int _activeButton = -1;
67  bool _flag = false;
68 
72  void buttonsFrame();
73 
77  int32 is_mouse_over_a_button() const;
78 
79 protected:
81 
85  void setButtons(const MenuButtonDef *btns, int count);
86 
90  void drawButton(int index);
91 
95  void drawButtons();
96 
100  void setButtonState(int index, ButtonState newState);
101 
106  _activeButton = -1;
107  }
108 public:
109  MenuRoom(const char *menuName, const char *clickName) : Rooms::Room(),
110  _menuName(menuName), _clickName(clickName) {}
111  virtual ~MenuRoom() {}
112 
113  void init() override;
114  void daemon() override;
115 };
116 
117 } // namespace Rooms
118 } // namespace Burger
119 } // namespace M4
120 
121 #endif
Definition: ws_machine.h:130
Definition: menu_room.h:50
void resetSelectedButton()
Definition: menu_room.h:105
Definition: menu_room.h:37
Definition: array.h:52
Definition: menu_room.h:60
Definition: room.h:38
Definition: database.h:28