1 #include "HeroStatus.h"
4 #include "../common/Hero.h"
5 #include "../graphics/Font.h"
6 #include "../graphics/Sprite.h"
8 using geometry::Vector;
12 HeroStatus::HeroStatus()
19 HeroStatus::~HeroStatus() {
24 int HeroStatus::Width() const {
25 return party[hero]->BattleSprite()->Width() + res->statusFont->CharWidth() * 11;
28 int HeroStatus::Height() const {
29 return party[hero]->BattleSprite()->Height() + res->statusFont->CharWidth();
33 void HeroStatus::Render(SDL_Surface *screen, const Vector<int> &offset) const {
36 party[hero]->BattleSprite()->Draw(screen, offset, 0, 0);
38 // for some reason, fonts are shifted by one pixel in the original
39 Vector<int> nameOffset(
40 party[hero]->BattleSprite()->Width(),
41 res->statusFont->CharHeight() * 7 / 8);
43 res->statusFont->DrawString(party[hero]->Name(), screen, nameOffset, 5);
45 Vector<int> levelLabelOffset(nameOffset.X() + 6 * res->statusFont->CharWidth(), nameOffset.Y());
46 res->statusLabels->Draw(screen, levelLabelOffset, 0, 0);
48 Vector<int> levelOffset(levelLabelOffset.X() + 2 * res->statusFont->CharWidth(), levelLabelOffset.Y());
49 res->statusFont->DrawNumber(party[hero]->Level(), screen, levelOffset, 2);
51 Vector<int> healthLabelOffset(nameOffset.X(), nameOffset.Y() + res->statusFont->CharHeight());
52 res->statusLabels->Draw(screen, healthLabelOffset, 0, 1);
54 Vector<int> healthOffset(nameOffset.X() + 3 * res->statusFont->CharWidth(), nameOffset.Y() + res->statusFont->CharHeight());
55 res->statusFont->DrawNumber(party[hero]->Health(), screen, healthOffset, 3);
57 Vector<int> healthSeparatorOffset(healthOffset.X() + 3 * res->statusFont->CharWidth(), healthOffset.Y());
58 res->statusFont->DrawChar('/', screen, healthSeparatorOffset);
60 Vector<int> maxHealthOffset(healthSeparatorOffset.X() + res->statusFont->CharWidth(), healthOffset.Y());
61 res->statusFont->DrawNumber(party[hero]->MaxHealth(), screen, maxHealthOffset, 3);
63 Vector<int> manaLabelOffset(healthLabelOffset.X(), healthLabelOffset.Y() + res->statusFont->CharHeight());
64 res->statusLabels->Draw(screen, manaLabelOffset, 0, 2);
66 Vector<int> manaOffset(healthOffset.X(), healthOffset.Y() + res->statusFont->CharHeight());
67 res->statusFont->DrawNumber(party[hero]->Mana(), screen, manaOffset, 3);
69 Vector<int> manaSeparatorOffset(healthSeparatorOffset.X(), manaOffset.Y());
70 res->statusFont->DrawChar('/', screen, manaSeparatorOffset);
72 Vector<int> maxManaOffset(maxHealthOffset.X(), manaOffset.Y());
73 res->statusFont->DrawNumber(party[hero]->MaxMana(), screen, maxManaOffset, 3);