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