3 #include "AttackChoice.h"
4 #include "BattleState.h"
7 #include "../math/Vector.h"
8 #include "../graphics/Font.h"
9 #include "../graphics/Frame.h"
10 #include "../graphics/Gauge.h"
11 #include "../graphics/Sprite.h"
14 using graphics::Frame;
18 const graphics::Sprite *HeroTag::HeroSprite() const {
19 return battle->HeroAt(index).Sprite();
22 void HeroTag::Render(SDL_Surface *screen, int width, int height, const Vector<int> &position, bool active) const {
23 const Resources &r(battle->Res());
26 const Frame *frame(active ? r.activeHeroTagFrame : r.heroTagFrame);
27 Vector<int> frameOffset(frame->BorderSize());
28 Vector<int> alignOffset((index % 2) ? 4 * r.heroTagFont->CharWidth() : 0, 0);
29 frame->Draw(screen, position, width, height);
31 const Hero &hero(battle->HeroAt(index));
34 // NOTE: assuming frame border is unit size until charsets are impemented
35 int gaugeX(((index % 2) ? 10 : 6) * r.heroTagFont->CharWidth());
36 // 4 units reserved for hero, gaugeX already includes frame offset
37 int gaugeWidth(width - gaugeX - ((index % 2) ? 1 : 5) * r.heroTagFont->CharWidth());
38 // health gauge, second line
39 Vector<int> healthGaugeOffset(gaugeX, frameOffset.Y() + r.heroTagFont->CharHeight());
40 r.healthGauge->Draw(screen, position + healthGaugeOffset, gaugeWidth, hero.RelativeHealth(255));
41 // mana gauge, third line
42 Vector<int> manaGaugeOffset(gaugeX, frameOffset.Y() + 2 * r.heroTagFont->CharHeight());
43 r.manaGauge->Draw(screen, position + manaGaugeOffset, gaugeWidth, hero.RelativeMana(255));
44 // ikari gauge, fourth line
45 Vector<int> ikariGaugeOffset(gaugeX, frameOffset.Y() + 3 * r.heroTagFont->CharHeight());
46 r.ikariGauge->Draw(screen, position + ikariGaugeOffset, gaugeWidth, hero.RelativeIP(255));
49 int labelX(((index % 2) ? 5 : 1) * r.heroTagFont->CharWidth());
51 Vector<int> levelLabelOffset(gaugeX, frameOffset.Y());
52 r.heroTagLabels->Draw(screen, position + levelLabelOffset, r.levelLabelCol, r.levelLabelRow);
54 Vector<int> healthLabelOffset(labelX, frameOffset.Y() + r.heroTagFont->CharHeight());
55 r.heroTagLabels->Draw(screen, position + healthLabelOffset, r.healthLabelCol, r.healthLabelRow);
57 Vector<int> manaLabelOffset(labelX, frameOffset.Y() + 2 * r.heroTagFont->CharHeight());
58 r.heroTagLabels->Draw(screen, position + manaLabelOffset, r.manaLabelCol, r.manaLabelRow);
60 Vector<int> moveLabelOffset(labelX, frameOffset.Y() + 3 * r.heroTagFont->CharHeight());
61 r.heroTagLabels->Draw(screen, position + moveLabelOffset, r.moveLabelCol, r.moveLabelRow);
63 Vector<int> ikariLabelOffset(labelX + 3 * r.heroTagFont->CharWidth(), frameOffset.Y() + 3 * r.heroTagFont->CharHeight());
64 r.heroTagLabels->Draw(screen, position + ikariLabelOffset, r.ikariLabelCol, r.ikariLabelRow);
68 Vector<int> levelNumberOffset(gaugeX + r.heroTagLabels->Width(), levelLabelOffset.Y());
69 r.heroTagFont->DrawNumber(hero.Level(), screen, position + levelNumberOffset, 2);
71 Vector<int> healthNumberOffset(labelX + r.heroTagLabels->Width(), healthLabelOffset.Y());
72 r.heroTagFont->DrawNumber(hero.Health(), screen, position + healthNumberOffset, 3);
74 Vector<int> manaNumberOffset(labelX + r.heroTagLabels->Width(), manaLabelOffset.Y());
75 r.heroTagFont->DrawNumber(hero.Mana(), screen, position + manaNumberOffset, 3);
78 r.normalFont->DrawString(hero.Name(), screen, position + frameOffset + alignOffset, 5);
81 if (battle->HeroAt(index).GetAttackChoice().GetType() != AttackChoice::UNDECIDED) {
82 Vector<int> attackIconOffset(labelX + r.heroTagLabels->Width(), frameOffset.Y() + 3 * r.heroTagFont->CharHeight());
83 r.attackChoiceIcons->Draw(screen, position + attackIconOffset, 0, battle->HeroAt(index).GetAttackChoice().GetType());
87 HeroSprite()->DrawCenter(screen, position + HeroOffset(), 0, battle->HeroAt(index).Health() > 0 ? 0 : 2);
90 Vector<int> HeroTag::HeroOffset() const {
92 ((index % 2) ? battle->Res().normalFont->CharWidth() : 10 * battle->Res().normalFont->CharWidth()) + HeroSprite()->Width() / 2,
93 battle->Res().normalFont->CharWidth() + HeroSprite()->Height() / 2);