ScummVM API documentation
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
inventory.h
1 
2 /* ScummVM - Graphic Adventure Engine
3  *
4  * ScummVM is the legal property of its developers, whose names
5  * are too numerous to list here. Please refer to the COPYRIGHT
6  * file distributed with this source distribution.
7  *
8  * This program is free software: you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation, either version 3 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program. If not, see <http://www.gnu.org/licenses/>.
20  *
21  */
22 
23 #ifndef M4_RIDDLE_GUI_INVENTORY_H
24 #define M4_RIDDLE_GUI_INVENTORY_H
25 
26 #include "m4/gui/gui_cheapo.h"
27 
28 namespace M4 {
29 namespace Riddle {
30 namespace GUI {
31 
32 using namespace M4::GUI;
33 
34 constexpr int16 INVENTORY_CELLS_COUNT = 128;
35 constexpr int16 ARROW_WIDTH = 8;
36 constexpr int16 MAX_INVENTORY = 20;
37 
38 constexpr int16 LEFT_ARROW_TAG = 128;
39 constexpr int16 RIGHT_ARROW_TAG = 129;
40 
41 constexpr int16 LEFT_ARROW_TAG_DORMANT = 130;
42 constexpr int16 RIGHT_ARROW_TAG_DORMANT = 134;
43 constexpr int16 LEFT_ARROW_TAG_ROLL = 131;
44 constexpr int16 RIGHT_ARROW_TAG_ROLL = 135;
45 constexpr int16 LEFT_ARROW_TAG_DOWN = 132;
46 constexpr int16 RIGHT_ARROW_TAG_DOWN = 136;
47 constexpr int16 LEFT_ARROW_TAG_NONFUNC = 133;
48 constexpr int16 RIGHT_ARROW_TAG_NONFUNC = 137;
49 
50 class Inventory : public RectClass {
51  struct Entry {
52  Common::String _name;
53  Common::String _verb;
54  int16 _cell = -1;
55  int16 _cursor = -1;
56  };
57 private:
58  GUI::ButtonClass *_btnScrollLeft = nullptr;
59  GUI::ButtonClass *_btnScrollRight = nullptr;
60 
61  int32 _sprite = 0;
62  int16 _tag = 0;
63  int16 _num_cells = 0;
64  bool _right_arrow_visible = false;
65  bool _hidden = false;
66 
67  int16 cell_pos_x(int16 index);
68  int16 cell_pos_y(int16 index);
69  int16 interface_tracking = -1;
70 
71 public:
72  int16 _scroll = 0;
73  int16 _cells_h = 0, _cells_v = 0;
74  int16 _cell_w = 0, _cell_h = 0;
75  int16 _must_redraw1 = 0, _must_redraw2 = 0;
76  int16 _highlight = 0;
77  bool _must_redraw_all = false;
78 
79  Entry _items[INVENTORY_CELLS_COUNT];
80 
81 public:
82  Inventory(const RectClass &r, int32 sprite, int16 cells_h, int16 cells_v, int16 cell_w, int16 cell_h, int16 tag);
83  ~Inventory();
84  void addToInterfaceBox(InterfaceBox *box);
85 
86  void draw(GrBuff *interface_buffer);
87 
88  int16 inside(int16 x, int16 y) const override;
89  ControlStatus track(int32 eventType, int16 x, int16 y);
90 
91  bool add(const Common::String &name, const Common::String &verb, int32 cel, int32 cursor);
92  bool remove(const Common::String &name);
93  void highlight_part(int16 index);
94 
95  bool need_left() const;
96  bool need_right() const;
97  void refresh_right_arrow();
98  void refresh_left_arrow();
99  void refresh_scrollbars();
100  void check_left();
101  void check_right();
102 
103  void set_scroll(int32 new_scroll);
104 
108  void toggleHidden();
109 };
110 
111 } // namespace GUI
112 } // namespace Riddle
113 } // namespace M4
114 
115 #endif
Definition: str.h:59
Definition: gui_cheapo.h:47
Definition: gui_cheapo.h:136
Definition: system.h:46
Definition: inventory.h:50
Definition: database.h:28
Definition: gr_buff.h:30
Definition: gui_cheapo.h:78
Definition: game_menu.h:30