ScummVM API documentation
inventory_widget.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 NUVIE_VIEWS_INVENTORY_WIDGET_H
23 #define NUVIE_VIEWS_INVENTORY_WIDGET_H
24 
25 #include "ultima/nuvie/gui/widgets/gui_widget.h"
26 #include "ultima/nuvie/core/obj_manager.h"
27 #include "ultima/nuvie/views/inventory_message.h"
28 
29 namespace Ultima {
30 namespace Nuvie {
31 
32 class Configuration;
33 class TileManager;
34 class Actor;
35 class Font;
36 
37 class InventoryWidget : public GUI_Widget {
38 private:
39  Common::Rect arrow_rects[2];
40 protected:
41  const Configuration *config;
42 
43  int game_type;
44 
45  TileManager *tile_manager;
46  ObjManager *obj_manager;
47  Font *font;
48 
49  Actor *actor;
50  Obj *container_obj;
51 
52  Obj *selected_obj, *target_obj, *ready_obj;
53  Obj *target_cont;
54  uint16 row_offset;
55  uint8 icon_x;
56  uint8 bg_color;
57  uint8 objlist_offset_x, objlist_offset_y;
58  uint8 obj_font_color;
59 
60  const Tile *empty_tile;
61 
62 public:
63  InventoryWidget(const Configuration *cfg, GUI_CallBack *callback = nullptr);
64  ~InventoryWidget() override;
65 
66  bool init(Actor *a, uint16 x, uint16 y, TileManager *tm, ObjManager *om, Font *f);
67  void set_actor(Actor *a);
68  Actor *get_actor() {
69  return actor;
70  }
71  Obj *get_container() {
72  return container_obj;
73  }
74  void set_container(Obj *obj) {
75  container_obj = obj;
76  row_offset = 0;
77  Redraw();
78  }
79  Obj *get_prev_container();
80  void set_prev_container();
81  bool is_showing_container() {
82  return (container_obj != nullptr ? true : false);
83  }
84  void Display(bool full_redraw) override;
85 
86  GUI_status MouseDown(int x, int y, Shared::MouseButton button) override;
87  GUI_status MouseUp(int x, int y, Shared::MouseButton button) override;
88  GUI_status MouseMotion(int x, int y, uint8 state) override;
89  GUI_status MouseDouble(int x, int y, Shared::MouseButton button) override;
90  GUI_status MouseClick(int x, int y, Shared::MouseButton button) override;
91  GUI_status MouseDelayed(int x, int y, Shared::MouseButton button) override;
92  GUI_status MouseWheel(sint32 x, sint32 y) override;
93  void drag_drop_success(int x, int y, int message, void *data) override;
94  void drag_drop_failed(int x, int y, int message, void *data) override;
95 
96  bool drag_accept_drop(int x, int y, int message, void *data) override;
97  void drag_perform_drop(int x, int y, int message, void *data) override;
98 
99  void drag_draw(int x, int y, int message, void *data) override;
100 
101  uint8 get_num_rows() const {
102  return game_type == NUVIE_GAME_U6 ? 3 : 4;
103  }
104 
105 protected:
106 
107  GUI_CallBack *callback_object; // object-selected callback
108 
109  inline uint16 get_list_position(int x, int y);
110  void display_inventory_container();
111  void display_inventory_list();
112  inline void display_qty_string(uint16 x, uint16 y, uint16 qty);
113  inline void display_special_char(uint16 x, uint16 y, uint8 quality);
114  void display_arrows();
115 
116  bool drag_set_target_obj(int x, int y);
117  void try_click();
118 
119 public:
120  bool up_arrow();
121  bool down_arrow();
122  Obj *get_obj_at_location(int x, int y);
123 };
124 
125 } // End of namespace Nuvie
126 } // End of namespace Ultima
127 
128 #endif
Definition: actor.h:178
Definition: gui_widget.h:38
Definition: obj.h:84
Definition: configuration.h:61
Definition: inventory_widget.h:37
Definition: rect.h:144
Definition: tile_manager.h:145
Definition: detection.h:27
Definition: obj_manager.h:75
Definition: tile_manager.h:113
Definition: font.h:42
Definition: gui_callback.h:31