1 /*
2 Copyright (C) 2000-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 #ifndef PAPERDOLL_GUMP_H
20 #define PAPERDOLL_GUMP_H
21 
22 #include "Gump.h"
23 
24 class Heart_button;
25 class Disk_button;
26 class Combat_button;
27 class Halo_button;
28 class Cstats_button;
29 class Combat_mode_button;
30 class Paperdoll_npc;
31 
32 //
33 // For best viewing use Tab size = 4
34 //
35 
36 class Paperdoll_gump : public Gump {
37 protected:
38 	struct Position {
39 		short x;
40 		short y;
41 	};
42 
43 	// Statics
44 	static Position coords[18];        // Coords. of where to draw things,
45 	static Position coords_blue[18];   // indexed by spot # (0-17).
46 	static Position shapes_blue[18];
47 	static Position coords_hot[18];    // Hot spots
48 
49 	static Position disk;         // Where to show 'diskette' button.
50 	static Position heart;        // Where to show 'stats' button.
51 	static Position combat;       // Combat button.
52 	static Position cstat;        // Combat mode.
53 	static Position halo;         // "Protected" halo.
54 	static Position cmode;        // Combat mode.
55 
56 	static Position body;         // Body
57 	static Position headp;        // Head
58 	static Position beltf;        // Female Belt
59 	static Position neckf;        // Female Neck
60 	static Position beltm;        // Male Belt
61 	static Position neckm;        // Male Neck
62 	static Position legsp;        // Legs
63 	static Position feetp;        // Feet
64 	static Position hands;        // Hands
65 	static Position lhandp;       // Left Hand
66 	static Position rhandp;       // Right Hand
67 	static Position ahand;        // Ammo in Left Hand
68 	static Position ammo;         // Quiver
69 
70 	static Position backf;        // Female Back
71 	static Position backm;        // Male Back
72 	static Position back2f;       // Female Back Weapon
73 	static Position back2m;       // Male Back Weapon
74 	static Position shieldf;      // Female Back Shield
75 	static Position shieldm;      // Male Back Shield
76 
77 
78 	// Non Statics
79 
80 	Heart_button *heart_button;         // For bringing up stats.
81 	Disk_button *disk_button;           // For bringing up 'save' box. (Avatar Only)
82 	Combat_button *combat_button;       // Combat Toggle (Avatar Only)
83 	Cstats_button *cstats_button;       // Combat Stats (Not BG)
84 	Halo_button *halo_button;           // Halo (protection) (BG Only)
85 	Combat_mode_button *cmode_button;   // Combat Modes (BG Only)
86 
87 	// Non Statics
88 
89 	// Find index of closest spot to the mouse pointer
90 	int find_closest(int mx, int my, int only_empty = 0);
91 
92 	// Set to location of an object a spot
93 	void set_to_spot(Game_object *obj, int index);
94 public:
95 	Paperdoll_gump(Container_game_object *cont, int initx, int inity,
96 	               int shnum);
97 
98 	~Paperdoll_gump() override;
99 
100 	// Is a given point on a button?
101 	Gump_button *on_button(int mx, int my) override;
102 
103 	// Find the object the mouse is over
104 	Game_object *find_object(int mx, int my) override;
105 
106 	// Add object.
107 	bool add(Game_object *obj, int mx = -1, int my = -1,
108 	                int sx = -1, int sy = -1, bool dont_check = false,
109 	                bool combine = false) override;
110 
111 	// Paint it and its contents.
112 	void paint() override;
113 
114 
115 	//
116 	// Painting Helpers
117 	//
118 
119 	// Generic Paint Object Method
120 	void paint_object(const TileRect &box, const Paperdoll_npc *info, int spot,
121 	                  int sx, int sy, int frame = 0, int itemtype = -1);
122 
123 	// Generic Paint Object Method for something that is armed dependant
124 	void paint_object_arms(const TileRect &box, const Paperdoll_npc *info, int spot,
125 	                       int sx, int sy, int start = 0, int itemtype = -1);
126 
127 	// Special 'Constant' Paint Methods
128 	void paint_body(const TileRect &box, const Paperdoll_npc *info);
129 	void paint_belt(const TileRect &box, const Paperdoll_npc *info);
130 	void paint_head(const TileRect &box, const Paperdoll_npc *info);
131 	void paint_arms(const TileRect &box, const Paperdoll_npc *info);
132 
133 	// What are we holding?
134 	int get_arm_type();
135 
136 
137 	//
138 	// Finding Helpers
139 	//
140 
141 	// Generic Check Object Method
142 	Game_object *check_object(int mx, int my, const Paperdoll_npc *info, int spot,
143 	                          int sx, int sy, int frame = 0, int itemtype = -1);
144 
145 
146 	// Generic Check Object Method for something that is armed dependant
147 	Game_object *check_object_arms(int mx, int my, const Paperdoll_npc *info, int spot,
148 	                               int sx, int sy, int start = 0, int itemtype = -1);
149 
150 	// Special 'Constant' Check Methods
151 	bool check_body(int mx, int my, const Paperdoll_npc *info);
152 	bool check_belt(int mx, int my, const Paperdoll_npc *info);
153 	bool check_head(int mx, int my, const Paperdoll_npc *info);
154 	bool check_arms(int mx, int my, const Paperdoll_npc *info);
155 
156 	// Generic Method to check a shape
157 	bool check_shape(int px, int py, int shape, int frame, ShapeFile file);
158 
159 	Container_game_object *find_actor(int mx, int my) override;
160 };
161 
162 #endif
163