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()
26 HeroStatus::~HeroStatus() {
31 int HeroStatus::Width() const {
32 return party[hero]->BattleSprite()->Width() + res->statusFont->CharWidth() * 11;
35 int HeroStatus::Height() const {
36 return party[hero]->BattleSprite()->Height() + res->statusFont->CharWidth();
40 void HeroStatus::Render(SDL_Surface *screen, const Vector<int> &offset) const {
43 party[hero]->BattleSprite()->Draw(screen, offset, 0, 0);
45 // for some reason, fonts are shifted by one pixel in the original
46 Vector<int> nameOffset(
47 party[hero]->BattleSprite()->Width(),
48 res->statusFont->CharHeight() * 7 / 8);
50 res->statusFont->DrawString(party[hero]->Name(), screen, nameOffset, 5);
52 Vector<int> levelLabelOffset(nameOffset.X() + 6 * res->statusFont->CharWidth(), nameOffset.Y());
53 res->statusLabels->Draw(screen, levelLabelOffset, 0, 0);
55 Vector<int> levelOffset(levelLabelOffset.X() + 2 * res->statusFont->CharWidth(), levelLabelOffset.Y());
56 res->statusFont->DrawNumber(party[hero]->Level(), screen, levelOffset, 2);
58 Vector<int> healthLabelOffset(nameOffset.X(), nameOffset.Y() + res->statusFont->CharHeight());
59 res->statusLabels->Draw(screen, healthLabelOffset, 0, 1);
61 Vector<int> healthOffset(nameOffset.X() + 3 * res->statusFont->CharWidth(), nameOffset.Y() + res->statusFont->CharHeight());
62 res->statusFont->DrawNumber(party[hero]->Health(), screen, healthOffset, 3);
64 Vector<int> healthSeparatorOffset(healthOffset.X() + 3 * res->statusFont->CharWidth(), healthOffset.Y());
65 res->statusFont->DrawChar('/', screen, healthSeparatorOffset);
67 Vector<int> maxHealthOffset(healthSeparatorOffset.X() + res->statusFont->CharWidth(), healthOffset.Y());
68 res->statusFont->DrawNumber(party[hero]->MaxHealth(), screen, maxHealthOffset, 3);
70 Vector<int> manaLabelOffset(healthLabelOffset.X(), healthLabelOffset.Y() + res->statusFont->CharHeight());
71 res->statusLabels->Draw(screen, manaLabelOffset, 0, 2);
73 Vector<int> manaOffset(healthOffset.X(), healthOffset.Y() + res->statusFont->CharHeight());
74 res->statusFont->DrawNumber(party[hero]->Mana(), screen, manaOffset, 3);
76 Vector<int> manaSeparatorOffset(healthSeparatorOffset.X(), manaOffset.Y());
77 res->statusFont->DrawChar('/', screen, manaSeparatorOffset);
79 Vector<int> maxManaOffset(maxHealthOffset.X(), manaOffset.Y());
80 res->statusFont->DrawNumber(party[hero]->MaxMana(), screen, maxManaOffset, 3);