4 * Created on: Aug 6, 2012
10 #include "AttackChoice.h"
12 #include "Resources.h"
13 #include "../geometry/operators.h"
14 #include "../geometry/Vector.h"
15 #include "../graphics/Font.h"
16 #include "../graphics/Frame.h"
17 #include "../graphics/Gauge.h"
18 #include "../graphics/Sprite.h"
20 using geometry::Point;
21 using geometry::Vector;
22 using graphics::Frame;
26 void HeroTag::Render(SDL_Surface *screen, int width, int height, Point<int> position, bool active) const {
28 const Frame *frame(active ? res->activeHeroTagFrame : res->heroTagFrame);
29 Vector<int> frameOffset(frame->BorderWidth(), frame->BorderHeight());
30 Vector<int> alignOffset(align == LEFT ? 4 * res->heroTagFont->CharWidth() : 0, 0);
31 frame->Draw(screen, position, width, height);
34 // NOTE: assuming frame border is unit size until charsets are impemented
35 int gaugeX((align == LEFT ? 10 : 6) * res->heroTagFont->CharWidth());
36 // 4 units reserved for hero, gaugeX already includes frame offset
37 int gaugeWidth(width - gaugeX - (align == LEFT ? 1 : 5) * res->heroTagFont->CharWidth());
38 // health gauge, second line
39 Vector<int> healthGaugeOffset(gaugeX, frameOffset.Y() + res->heroTagFont->CharHeight());
40 res->healthGauge->Draw(screen, position + healthGaugeOffset, gaugeWidth, hero->RelativeHealth(255));
41 // mana gauge, third line
42 Vector<int> manaGaugeOffset(gaugeX, frameOffset.Y() + 2 * res->heroTagFont->CharHeight());
43 res->manaGauge->Draw(screen, position + manaGaugeOffset, gaugeWidth, hero->RelativeMana(255));
44 // ikari gauge, fourth line
45 Vector<int> ikariGaugeOffset(gaugeX, frameOffset.Y() + 3 * res->heroTagFont->CharHeight());
46 res->ikariGauge->Draw(screen, position + ikariGaugeOffset, gaugeWidth, hero->RelativeIP(255));
49 int labelX((align == LEFT ? 5 : 1) * res->heroTagFont->CharWidth());
51 Vector<int> levelLabelOffset(gaugeX, frameOffset.Y());
52 res->heroTagLabels->Draw(screen, position + levelLabelOffset, 0, 0);
54 Vector<int> healthLabelOffset(labelX, frameOffset.Y() + res->heroTagFont->CharHeight());
55 res->heroTagLabels->Draw(screen, position + healthLabelOffset, 0, 1);
57 Vector<int> manaLabelOffset(labelX, frameOffset.Y() + 2 * res->heroTagFont->CharHeight());
58 res->heroTagLabels->Draw(screen, position + manaLabelOffset, 0, 2);
60 Vector<int> moveLabelOffset(labelX, frameOffset.Y() + 3 * res->heroTagFont->CharHeight());
61 res->heroTagLabels->Draw(screen, position + moveLabelOffset, 0, 3);
63 Vector<int> ikariLabelOffset(labelX + 3 * res->heroTagFont->CharWidth(), frameOffset.Y() + 3 * res->heroTagFont->CharHeight());
64 res->heroTagLabels->Draw(screen, position + ikariLabelOffset, 0, 4);
68 Vector<int> levelNumberOffset(gaugeX + res->heroTagLabels->Width(), levelLabelOffset.Y());
69 res->heroTagFont->DrawNumber(hero->Level(), screen, position + levelNumberOffset, 2);
71 Vector<int> healthNumberOffset(labelX + res->heroTagLabels->Width(), healthLabelOffset.Y());
72 res->heroTagFont->DrawNumber(hero->Health(), screen, position + healthNumberOffset, 3);
74 Vector<int> manaNumberOffset(labelX + res->heroTagLabels->Width(), manaLabelOffset.Y());
75 res->heroTagFont->DrawNumber(hero->Mana(), screen, position + manaNumberOffset, 3);
78 res->normalFont->DrawString(hero->Name(), screen, position + frameOffset + alignOffset, 5);
81 if (choice->GetType() != AttackChoice::UNDECIDED) {
82 Vector<int> attackIconOffset(labelX + res->heroTagLabels->Width(), frameOffset.Y() + 3 * res->heroTagFont->CharHeight());
83 res->attackChoiceIcons->Draw(screen, position + attackIconOffset, 0, choice->GetType());
87 hero->Sprite()->Draw(screen, position + HeroOffset(), 0, hero->Health() > 0 ? 0 : 2);
90 Vector<int> HeroTag::HeroOffset() const {
92 (align == LEFT) ? res->normalFont->CharWidth() : 10 * res->normalFont->CharWidth(),
93 res->normalFont->CharWidth());