File: Stats_gump.cc

package info (click to toggle)
exult 0.98rc1-2
  • links: PTS
  • area: contrib
  • in suites: woody
  • size: 6,924 kB
  • ctags: 8,928
  • sloc: cpp: 83,768; sh: 7,643; ansic: 4,328; makefile: 890; yacc: 618; lex: 255; xml: 19
file content (144 lines) | stat: -rwxr-xr-x 4,197 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
/*
Copyright (C) 2000 The Exult Team

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
*/

#ifdef HAVE_CONFIG_H
#  include <config.h>
#endif

#include "actors.h"
#include "game.h"
#include "gamewin.h"
#include "gump_utils.h"
#include "misc_buttons.h"
#include "Stats_gump.h"


/*
 *	Some gump shape numbers:
 */

const int ASLEEP = 0, POISONED = 1, CHARMED = 2, HUNGRY = 3,
		  PROTECTED = 4, CURSED = 5, PARALYZED = 6;

/*
 *	Statics:
 */

short Stats_gump::textx = 123;
short Stats_gump::texty[10] = {17, 26, 35, 46, 55, 67, 76, 86,
							95, 104};

/*
 *	Show one of the atts.
 *
 *	Output:	Amount to increment x-pos for the next one.
 */

static int Show_atts
	(
	Game_window *gwin,
	int x, int y,			// Pos. on screen.
	int framenum
	)
{
	ShapeID sid(game->get_shape("gumps/statatts"), framenum, SF_GUMPS_VGA);
	Shape_frame *s = sid.get_shape();
	gwin->paint_shape(x + s->get_xleft(),
				 y + s->get_ybelow(), s, 1);
	return s->get_width() + 2;
}

/*
 *	Create stats display.
 */
Stats_gump::Stats_gump
	(
	Container_game_object *cont, 
	int initx, int inity
	) : Gump(cont, initx, inity, game->get_shape("gumps/statsdisplay"))
{
	set_object_area(Rectangle(0,0,0,0), 6, 136);
}

/*
 *	Paint on screen.
 */

void Stats_gump::paint
	(
	Game_window *gwin
	)
{
					// Area to print name in.
	const int namex = 30, namey = 6, namew = 95;
	Actor *act = get_actor();	// Check for freezing (SI).
	if (gwin->get_main_actor()->get_flag(Obj_flags::freeze))
		{
		int temp = act->get_temperature();
		int framenum = temp/10;	// Want it 1-5.
		if (framenum <= 0)
			framenum = 1;
		else if (framenum > 5)
			framenum = 5;
		set_frame(framenum);
		}
					// Paint the gump itself.
	gwin->paint_shape(x, y, *this);
					// Paint red "checkmark".
	check_button->paint(gwin);
					// Show statistics.
	std::string nm = act->get_name();
	gwin->paint_text(2, nm.c_str(), x + namex +
		(namew - gwin->get_text_width(2, nm.c_str()))/2, y + namey);
	Paint_num(gwin, act->get_property(Actor::strength),
						x + textx, y + texty[0]);
	Paint_num(gwin, act->get_property(Actor::dexterity),
						x + textx, y + texty[1]);
	Paint_num(gwin, act->get_property(Actor::intelligence),
						x + textx, y + texty[2]);
  	Paint_num(gwin, act->get_property(Actor::combat),
						x + textx, y + texty[3]);
  	Paint_num(gwin, act->get_property(Actor::magic),
						x + textx, y + texty[4]);
  	Paint_num(gwin, act->get_property(Actor::health),
						x + textx, y + texty[5]);
  	Paint_num(gwin, act->get_property(Actor::mana),
						x + textx, y + texty[6]);
  	Paint_num(gwin, act->get_property(Actor::exp),
						x + textx, y + texty[7]);
	Paint_num(gwin, act->get_level(), x + textx, y + texty[8]);
  	Paint_num(gwin, act->get_property(Actor::training),
						x + textx, y + texty[9]);
					// Now show atts. at bottom.
	const int attsy = 130, attsx0 = 29;
	int attsx = attsx0;
	if (act->get_flag(Obj_flags::asleep))
		attsx += Show_atts(gwin, x + attsx, y + attsy, ASLEEP);
	if (act->get_flag(Obj_flags::poisoned))
		attsx += Show_atts(gwin, x + attsx, y + attsy, POISONED);
	if (act->get_flag(Obj_flags::charmed))
		attsx += Show_atts(gwin, x + attsx, y + attsy, CHARMED);
	if (act->get_property((int) Actor::food_level) <= 4)
		attsx += Show_atts(gwin, x + attsx, y + attsy, HUNGRY);
	if (act->get_flag(Obj_flags::protection))
		attsx += Show_atts(gwin, x + attsx, y + attsy, PROTECTED);
	if (act->get_flag(Obj_flags::cursed))
		attsx += Show_atts(gwin, x + attsx, y + attsy, CURSED);
	if (act->get_flag(Obj_flags::paralyzed))
		attsx += Show_atts(gwin, x + attsx, y + attsy, PARALYZED);
}