1 /*
2 Copyright (C) 2001-2013 The Exult Team
3
4 This program is free software; you can redistribute it and/or
5 modify it under the terms of the GNU General Public License
6 as published by the Free Software Foundation; either version 2
7 of the License, or (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 */
18
19 #ifdef HAVE_CONFIG_H
20 # include <config.h>
21 #endif
22
23 #include "Face_button.h"
24 #include "Paperdoll_gump.h"
25 #include "actors.h"
26 #include "gamewin.h"
27 #include "npcdollinf.h"
28 #include "ignore_unused_variable_warning.h"
29
Face_button(Gump * par,int px,int py,Actor * a)30 Face_button::Face_button(Gump *par, int px, int py, Actor *a)
31 : Gump_button(par, 0, px, py), actor(a) {
32 const Paperdoll_npc *npcinfo = a->get_info().get_npc_paperdoll();
33
34 if (!npcinfo) {
35 const Shape_info &inf = ShapeID::get_info(a->get_sexed_coloured_shape());
36 npcinfo = inf.get_npc_paperdoll();
37 }
38 if (!npcinfo) {
39 const Shape_info &inf = ShapeID::get_info(a->get_shape_real());
40 npcinfo = inf.get_npc_paperdoll_safe(a->get_type_flag(Actor::tf_sex));
41 }
42
43 set_shape(npcinfo->get_head_shape());
44 set_frame(npcinfo->get_head_frame());
45 translucent = npcinfo->is_translucent();
46 set_file(SF_PAPERDOL_VGA);
47 }
48
49
double_clicked(int x,int y)50 void Face_button::double_clicked(int x, int y) {
51 ignore_unused_variable_warning(x, y);
52 actor->show_inventory();
53 }
54
paint()55 void Face_button::paint(
56 ) {
57 int px = 0;
58 int py = 0;
59
60 if (parent) {
61 px = parent->get_x();
62 py = parent->get_y();
63 }
64 paint_shape(x + px, y + py, translucent);
65 }
66
update_widget()67 void Face_button::update_widget() {
68 const Paperdoll_npc *npcinfo = actor->get_info().get_npc_paperdoll();
69
70 if (!npcinfo) {
71 const Shape_info &inf = ShapeID::get_info(actor->get_sexed_coloured_shape());
72 npcinfo = inf.get_npc_paperdoll();
73 }
74 if (!npcinfo) {
75 const Shape_info &inf = ShapeID::get_info(actor->get_shape_real());
76 npcinfo = inf.get_npc_paperdoll_safe(actor->get_type_flag(Actor::tf_sex));
77 }
78
79 if (get_shapenum() != npcinfo->get_head_shape() ||
80 get_framenum() != npcinfo->get_head_frame()) {
81 gwin->add_dirty(get_rect());
82 set_shape(npcinfo->get_head_shape());
83 set_frame(npcinfo->get_head_frame());
84 gwin->add_dirty(get_rect());
85 }
86
87 }
88