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
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (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, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20  *
21  */
22 
23 #ifndef NUVIE_VIEWS_CONTAINER_WIDGET_H
24 #define NUVIE_VIEWS_CONTAINER_WIDGET_H
25 
26 #include "ultima/nuvie/gui/widgets/gui_widget.h"
27 #include "ultima/nuvie/core/obj_manager.h"
28 #include "ultima/nuvie/views/inventory_message.h"
29 
30 namespace Ultima {
31 namespace Nuvie {
32 
33 #define CONTAINER_WIDGET_ROWS 3
34 #define CONTAINER_WIDGET_COLS 4
35 
36 class Configuration;
37 class TileManager;
38 class Actor;
39 class Font;
40 
41 class ContainerWidget : public GUI_Widget {
42 
43 protected:
44 	Configuration *config;
45 
46 	int game_type;
47 
48 	TileManager *tile_manager;
49 	ObjManager *obj_manager;
50 
51 	Actor *actor;
52 	Obj *container_obj;
53 
54 	Obj *selected_obj, *target_obj, *ready_obj;
55 	Obj *target_cont;
56 	uint16 rows, cols;
57 	uint16 row_offset;
58 
59 	uint8 bg_color;
60 	uint8 obj_font_color;
61 
62 	bool fill_bg;
63 
64 	const Tile *empty_tile;
65 
66 public:
67 	ContainerWidget(Configuration *cfg, GUI_CallBack *callback = NULL);
68 	~ContainerWidget() override;
69 
70 	bool init(Actor *a, uint16 x, uint16 y, TileManager *tm, ObjManager *om, Font *f);
71 	virtual void set_actor(Actor *a);
get_actor()72 	Actor *get_actor() {
73 		return (actor);
74 	}
get_container()75 	Obj *get_container() {
76 		return (container_obj);
77 	}
set_container(Obj * obj)78 	void set_container(Obj *obj) {
79 		container_obj = obj;
80 		row_offset = 0;
81 		Redraw();
82 	}
is_showing_container()83 	bool is_showing_container() {
84 		return (container_obj != NULL ? true : false);
85 	}
86 	void Display(bool full_redraw) override;
87 
88 	GUI_status MouseDown(int x, int y, Shared::MouseButton button) override;
89 	GUI_status MouseUp(int x, int y, Shared::MouseButton button) override;
90 	GUI_status MouseMotion(int x, int y, uint8 state) override;
91 	GUI_status MouseDouble(int x, int y, Shared::MouseButton button) override;
92 	GUI_status MouseClick(int x, int y, Shared::MouseButton button) override;
93 	GUI_status MouseDelayed(int x, int y, Shared::MouseButton button) override;
94 
95 	void drag_drop_success(int x, int y, int message, void *data) override;
96 	void drag_drop_failed(int x, int y, int message, void *data) override;
97 
98 	bool drag_accept_drop(int x, int y, int message, void *data) override;
99 	void drag_perform_drop(int x, int y, int message, void *data) override;
100 
101 	void drag_draw(int x, int y, int message, void *data) override;
102 
103 protected:
104 
105 	GUI_CallBack *callback_object; // object-selected callback
106 
107 	inline uint16 get_list_position(int x, int y);
108 	void display_inventory_list();
109 	inline void display_qty_string(uint16 x, uint16 y, uint16 qty);
110 	inline void display_special_char(uint16 x, uint16 y, uint8 quality);
111 	void display_arrows();
112 
113 	bool drag_set_target_obj(int x, int y);
114 	void try_click();
115 
116 public:
117 	bool up_arrow();
118 	bool down_arrow();
119 	Obj *get_obj_at_location(int x, int y);
120 };
121 
122 } // End of namespace Nuvie
123 } // End of namespace Ultima
124 
125 #endif
126