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 "actors.h"
24 #include "game.h"
25 #include "gamewin.h"
26 #include "misc_buttons.h"
27 #include "CombatStats_gump.h"
28 #include "Paperdoll_gump.h"
29 #include "Gump_manager.h"
30 
31 
32 /*
33  *  Statics:
34  */
35 
36 static const int colx = 110;
37 static const int coldx = 29;
38 static const int rowy[7] = {15, 29, 42, 73, 87, 93, 106};
39 
40 /*
41  *  Create stats display.
42  */
CombatStats_gump(int initx,int inity)43 CombatStats_gump::CombatStats_gump(int initx, int inity) :
44 	Gump(nullptr, initx, inity, game->get_shape("gumps/cstats/1")) {
45 	set_object_area(TileRect(0, 0, 0, 0), 7, 95);
46 
47 
48 	party_size = gwin->get_party(party, 1);
49 
50 	int shnum = game->get_shape("gumps/cstats/1") + party_size - 1;
51 	ShapeID::set_shape(shnum, 0);
52 
53 	int i;  // Blame MSVC
54 	for (i = 0; i < party_size; i++) {
55 		add_elem(new Halo_button(
56 		             this, colx + i * coldx, rowy[4], party[i]));
57 		add_elem(new Combat_mode_button(
58 		             this, colx + i * coldx + 1, rowy[3], party[i]));
59 		add_elem(new Face_button(
60 		             this, colx + i * coldx - 13, rowy[0], party[i]));
61 	}
62 }
63 
64 /*
65  *  Paint on screen.
66  */
67 
paint()68 void CombatStats_gump::paint() {
69 	Gump_manager *gman = gumpman;
70 
71 	Gump::paint();
72 
73 	if (gwin->failed_copy_protection()) {
74 		int oinkx = 91;
75 		for (int i = 0; i < party_size; i++) {
76 			sman->paint_text(2, "Oink", x + oinkx + i * coldx, y + rowy[1]);
77 			sman->paint_text(2, "Oink", x + oinkx + i * coldx, y + rowy[2]);
78 		}
79 		sman->paint_text(2, "Oink", x + oinkx, y + rowy[5]);
80 		sman->paint_text(2, "Oink", x + oinkx, y + rowy[6]);
81 	} else {
82 		// stats for all party members
83 		for (int i = 0; i < party_size; i++) {
84 			gman->paint_num(party[i]->get_effective_prop(Actor::combat),
85 			                x + colx + i * coldx, y + rowy[1]);
86 			gman->paint_num(party[i]->get_property(Actor::health),
87 			                x + colx + i * coldx, y + rowy[2]);
88 		}
89 		// magic stats only for Avatar
90 		gman->paint_num(party[0]->get_property(Actor::magic),
91 		                x + colx, y + rowy[5]);
92 		gman->paint_num(party[0]->get_property(Actor::mana),
93 		                x + colx, y + rowy[6]);
94 	}
95 }
96 
97