1 #include "SmallHeroTag.h"
3 #include "BattleState.h"
4 #include "../math/Vector.h"
5 #include "../graphics/Font.h"
6 #include "../graphics/Frame.h"
7 #include "../graphics/Gauge.h"
8 #include "../math/Vector.h"
12 using graphics::Frame;
13 using graphics::Sprite;
17 void SmallHeroTag::Render(SDL_Surface *screen, int width, int height, const math::Vector<int> &position) const {
18 const Resources &r(battle->Res());
19 const Frame *frame((index == battle->MaxHeroes() - 1) ? r.lastSmallHeroTagFrame : r.smallHeroTagFrame);
20 const Font *font(r.normalFont);
21 const Sprite *labels(r.heroTagLabels);
23 frame->Draw(screen, position, width, height);
25 if (battle->HeroPositionOccupied(index)) {
26 const Hero &hero(battle->HeroAt(index));
28 int gaugeWidth(width - 2 * frame->BorderWidth() - labels->Width());
29 Vector<int> nameOffset(frame->BorderSize());
30 Vector<int> hpLabelOffset(nameOffset.X(), nameOffset.Y() + font->CharHeight());
31 Vector<int> mpLabelOffset(hpLabelOffset.X(), hpLabelOffset.Y() + font->CharHeight());
32 Vector<int> ipLabelOffset(mpLabelOffset.X(), mpLabelOffset.Y() + font->CharHeight());
33 Vector<int> hpGaugeOffset(hpLabelOffset.X() + labels->Width(), hpLabelOffset.Y());
34 Vector<int> mpGaugeOffset(mpLabelOffset.X() + labels->Width(), mpLabelOffset.Y());
35 Vector<int> ipGaugeOffset(ipLabelOffset.X() + labels->Width(), ipLabelOffset.Y());
37 font->DrawString(hero.Name(), screen, position + nameOffset, 5);
38 labels->Draw(screen, position + hpLabelOffset, r.healthLabelCol, r.healthLabelRow);
39 labels->Draw(screen, position + mpLabelOffset, r.manaLabelCol, r.manaLabelRow);
40 labels->Draw(screen, position + ipLabelOffset, r.ikariLabelCol, r.ikariLabelRow);
41 r.healthGauge->Draw(screen, position + hpGaugeOffset, gaugeWidth, hero.RelativeHealth(255));
42 r.manaGauge->Draw(screen, position + mpGaugeOffset, gaugeWidth, hero.RelativeMana(255));
43 r.ikariGauge->Draw(screen, position + ipGaugeOffset, gaugeWidth, hero.RelativeIP(255));