4 * Created on: Aug 6, 2012
11 #include "Resources.h"
12 #include "../geometry/operators.h"
13 #include "../geometry/Vector.h"
14 #include "../graphics/Font.h"
15 #include "../graphics/Frame.h"
16 #include "../graphics/Gauge.h"
17 #include "../graphics/Sprite.h"
19 using geometry::Point;
20 using geometry::Vector;
21 using graphics::Frame;
25 void HeroTag::Render(SDL_Surface *screen, int width, int height, Point<int> position, bool active) const {
27 const Frame *frame(active ? res->activeHeroTagFrame : res->heroTagFrame);
28 Vector<int> frameOffset(frame->BorderWidth(), frame->BorderHeight());
29 frame->Draw(screen, position, width, height);
31 int yOffset((height - hero->Sprite()->Height()) / 2);
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(gaugeWidth));
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(gaugeWidth));
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(gaugeWidth));
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 Vector<int> heroOffset(
79 (align == LEFT) ? yOffset : width - hero->Sprite()->Width() - yOffset,
81 hero->Sprite()->Draw(screen, position + heroOffset, 0, hero->Health() > 0 ? 0 : 2);