4 * Created on: Oct 21, 2012
8 #include "HeroStatus.h"
10 #include "Resources.h"
11 #include "../common/Hero.h"
12 #include "../graphics/Font.h"
13 #include "../graphics/Sprite.h"
15 using geometry::Vector;
19 HeroStatus::HeroStatus()
25 HeroStatus::~HeroStatus() {
30 int HeroStatus::Width() const {
31 return hero->BattleSprite()->Width() + res->statusFont->CharWidth() * 11;
34 int HeroStatus::Height() const {
35 return hero->BattleSprite()->Height() + res->statusFont->CharWidth();
39 void HeroStatus::Render(SDL_Surface *screen, const Vector<int> &offset) const {
42 hero->BattleSprite()->Draw(screen, offset, 0, 0);
44 // for some reason, fonts are shifted by one pixel in the original
45 Vector<int> nameOffset(
46 hero->BattleSprite()->Width(),
47 res->statusFont->CharHeight() * 7 / 8);
49 res->statusFont->DrawString(hero->Name(), screen, nameOffset, 5);
51 Vector<int> levelLabelOffset(nameOffset.X() + 6 * res->statusFont->CharWidth(), nameOffset.Y());
52 res->statusLabels->Draw(screen, levelLabelOffset, 0, 0);
54 Vector<int> levelOffset(levelLabelOffset.X() + 2 * res->statusFont->CharWidth(), levelLabelOffset.Y());
55 res->statusFont->DrawNumber(hero->Level(), screen, levelOffset, 2);
57 Vector<int> healthLabelOffset(nameOffset.X(), nameOffset.Y() + res->statusFont->CharHeight());
58 res->statusLabels->Draw(screen, healthLabelOffset, 0, 1);
60 Vector<int> healthOffset(nameOffset.X() + 3 * res->statusFont->CharWidth(), nameOffset.Y() + res->statusFont->CharHeight());
61 res->statusFont->DrawNumber(hero->Health(), screen, healthOffset, 3);
63 Vector<int> healthSeparatorOffset(healthOffset.X() + 3 * res->statusFont->CharWidth(), healthOffset.Y());
64 res->statusFont->DrawChar('/', screen, healthSeparatorOffset);
66 Vector<int> maxHealthOffset(healthSeparatorOffset.X() + res->statusFont->CharWidth(), healthOffset.Y());
67 res->statusFont->DrawNumber(hero->MaxHealth(), screen, maxHealthOffset, 3);
69 Vector<int> manaLabelOffset(healthLabelOffset.X(), healthLabelOffset.Y() + res->statusFont->CharHeight());
70 res->statusLabels->Draw(screen, manaLabelOffset, 0, 2);
72 Vector<int> manaOffset(healthOffset.X(), healthOffset.Y() + res->statusFont->CharHeight());
73 res->statusFont->DrawNumber(hero->Mana(), screen, manaOffset, 3);
75 Vector<int> manaSeparatorOffset(healthSeparatorOffset.X(), manaOffset.Y());
76 res->statusFont->DrawChar('/', screen, manaSeparatorOffset);
78 Vector<int> maxManaOffset(maxHealthOffset.X(), manaOffset.Y());
79 res->statusFont->DrawNumber(hero->MaxMana(), screen, maxManaOffset, 3);