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