ScummVM API documentation
qd_inventory.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 QDENGINE_QDCORE_QD_INVENTORY_H
23 #define QDENGINE_QDCORE_QD_INVENTORY_H
24 
25 #include "qdengine/system/input/mouse_input.h"
26 #include "qdengine/qdcore/qd_named_object.h"
27 #include "qdengine/qdcore/qd_inventory_cell.h"
28 
29 namespace Common {
30 class WriteStream;
31 }
32 
33 namespace QDEngine {
34 
36 class qdInventory : public qdNamedObject {
37 public:
38  qdInventory();
39  ~qdInventory();
40 
42  enum {
44  INV_TAKE_TO_MOUSE = 0x01,
46  INV_DONT_OPEN_AFTER_TAKE = 0x02,
48  INV_PUT_OBJECT_AFTER_CLICK = 0x04,
50  INV_ENABLE_RIGHT_CLICK = 0x08,
52  INV_VISIBLE_WHEN_INACTIVE = 0x10
53  };
54 
55  enum {
56  INV_DEFAULT_SHADOW_COLOR = 0,
57  INV_DEFAULT_SHADOW_ALPHA = 128
58  };
59 
60  int named_object_type() const {
61  return QD_NAMED_OBJECT_INVENTORY;
62  }
63 
64  void add_cell_set(const qdInventoryCellSet &set) {
65  _cell_sets.push_back(set);
66  }
67  void remove_cell_set(int idx);
68 
69  const qdInventoryCellSet &get_cell_set(int id = 0) const {
70  return _cell_sets[id];
71  }
72 
73  void set_cells_pos(int set_id, const Vect2s &pos) {
74  if (set_id >= 0 && set_id < (int)_cell_sets.size())
75  _cell_sets[set_id].set_screen_pos(pos);
76  }
77  void set_cells_type(int set_id, const qdInventoryCellType &tp) {
78  if (set_id >= 0 && set_id < (int)_cell_sets.size())
79  _cell_sets[set_id].set_cell_type(tp);
80  }
81  void set_cells_size(int set_id, const Vect2s &sz) {
82  if (set_id >= 0 && set_id < (int)_cell_sets.size())
83  _cell_sets[set_id].set_size(sz);
84  }
85 
86  int cell_index(const qdGameObjectAnimated *obj) const;
87  Vect2s cell_position(int cell_idx) const;
88 
89  void redraw(int offs_x = 0, int offs_y = 0, bool inactive_mode = false) const;
90  void toggle_redraw(bool state) {
91  _need_redraw = state;
92  }
93  void pre_redraw() const;
94  void post_redraw();
95 
96  bool put_object(qdGameObjectAnimated *p);
97  bool put_object(qdGameObjectAnimated *p, const Vect2s &pos);
98  bool remove_object(qdGameObjectAnimated *p);
99  qdGameObjectAnimated *get_object(const Vect2s &pos) const;
100  bool is_object_in_list(const qdGameObjectAnimated *p) const;
101 
102  uint32 shadow_color() const {
103  return _shadow_color;
104  }
105  void set_shadow_color(uint32 color) {
106  _shadow_color = color;
107  }
108 
109  int shadow_alpha() const {
110  return _shadow_alpha;
111  }
112  void set_shadow_alpha(int alpha) {
113  _shadow_alpha = alpha;
114  }
115 
116  bool load_script(const xml::tag *p);
117  bool save_script(Common::WriteStream &fh, int indent = 0) const;
118 
119  bool load_resources();
120  bool free_resources();
121 
123  bool load_data(Common::SeekableReadStream &fh, int save_version);
125  bool save_data(Common::WriteStream &fh) const;
126 
127  bool init(const qdInventoryCellTypeVector &tp);
128 
129  bool mouse_handler(int x, int y, mouseDispatcher::mouseEvent ev);
130 
131  void objects_quant(float dt);
132 
133  Vect2s additional_cells() const {
134  return _additional_cells;
135  }
136  void set_additional_cells(Vect2s val) {
137  _additional_cells = val;
138  }
139 
141  void scroll_left();
142  void scroll_right();
143  void scroll_up();
144  void scroll_down();
145 
146  void debug_log() const;
147 
148 private:
149 
150  qdInventoryCellSetVector _cell_sets;
151 
152  bool _need_redraw;
153 
154  uint32 _shadow_color;
155  int _shadow_alpha;
156 
158  Vect2s _additional_cells;
159 };
160 
161 } // namespace QDEngine
162 
163 #endif // QDENGINE_QDCORE_QD_INVENTORY_H
Definition: stream.h:77
Поименованный объект.
Definition: qd_named_object.h:70
Группа ячеек инвентори.
Definition: qd_inventory_cell.h:176
Инвентори.
Definition: qd_inventory.h:36
Definition: stream.h:745
Dynamic object.
Definition: qd_game_object_animated.h:37
Definition: xmath.h:419
XML тег.
Definition: xml_tag.h:33
int named_object_type() const
Возвращает тип объекта.
Definition: qd_inventory.h:60
Базовый класс для игровых ресурсов.
Definition: console.h:28
Definition: algorithm.h:29
Описание ячейки инвентори.
Definition: qd_inventory_cell.h:37
mouseEvent
События.
Definition: mouse_input.h:41