4 * Created on: Aug 11, 2012
8 #include "SmallHeroTag.h"
10 #include "BattleState.h"
11 #include "../geometry/operators.h"
12 #include "../geometry/Vector.h"
13 #include "../graphics/Font.h"
14 #include "../graphics/Frame.h"
15 #include "../graphics/Gauge.h"
17 using geometry::Point;
18 using geometry::Vector;
20 using graphics::Frame;
21 using graphics::Sprite;
25 void SmallHeroTag::Render(SDL_Surface *screen, int width, int height, geometry::Point<int> position) const {
26 const Resources &r(battle->Res());
27 const Frame *frame((index == battle->MaxHeroes() - 1) ? r.lastSmallHeroTagFrame : r.smallHeroTagFrame);
28 const Font *font(r.normalFont);
29 const Sprite *labels(r.heroTagLabels);
31 frame->Draw(screen, position, width, height);
33 if (battle->HeroPositionOccupied(index)) {
34 const Hero &hero(battle->HeroAt(index));
36 int gaugeWidth(width - 2 * frame->BorderWidth() - labels->Width());
37 Vector<int> nameOffset(frame->BorderWidth(), frame->BorderHeight());
38 Vector<int> hpLabelOffset(nameOffset.X(), nameOffset.Y() + font->CharHeight());
39 Vector<int> mpLabelOffset(hpLabelOffset.X(), hpLabelOffset.Y() + font->CharHeight());
40 Vector<int> ipLabelOffset(mpLabelOffset.X(), mpLabelOffset.Y() + font->CharHeight());
41 Vector<int> hpGaugeOffset(hpLabelOffset.X() + labels->Width(), hpLabelOffset.Y());
42 Vector<int> mpGaugeOffset(mpLabelOffset.X() + labels->Width(), mpLabelOffset.Y());
43 Vector<int> ipGaugeOffset(ipLabelOffset.X() + labels->Width(), ipLabelOffset.Y());
45 font->DrawString(hero.Name(), screen, position + nameOffset, 5);
46 labels->Draw(screen, position + hpLabelOffset, r.healthLabelCol, r.healthLabelRow);
47 labels->Draw(screen, position + mpLabelOffset, r.manaLabelCol, r.manaLabelRow);
48 labels->Draw(screen, position + ipLabelOffset, r.ikariLabelCol, r.ikariLabelRow);
49 r.healthGauge->Draw(screen, position + hpGaugeOffset, gaugeWidth, hero.RelativeHealth(255));
50 r.manaGauge->Draw(screen, position + mpGaugeOffset, gaugeWidth, hero.RelativeMana(255));
51 r.ikariGauge->Draw(screen, position + ipGaugeOffset, gaugeWidth, hero.RelativeIP(255));