]> git.localhorst.tv Git - l2e.git/blob - src/menu/HeroStatus.cpp
removed stupid file headers that eclipse put in
[l2e.git] / src / menu / HeroStatus.cpp
1 #include "HeroStatus.h"
2
3 #include "Resources.h"
4 #include "../common/Hero.h"
5 #include "../graphics/Font.h"
6 #include "../graphics/Sprite.h"
7
8 using geometry::Vector;
9
10 namespace menu {
11
12 HeroStatus::HeroStatus()
13 : res(0)
14 , party(0)
15 , hero(0) {
16
17 }
18
19 HeroStatus::~HeroStatus() {
20
21 }
22
23
24 int HeroStatus::Width() const {
25         return party[hero]->BattleSprite()->Width() + res->statusFont->CharWidth() * 11;
26 }
27
28 int HeroStatus::Height() const {
29         return party[hero]->BattleSprite()->Height() + res->statusFont->CharWidth();
30 }
31
32
33 void HeroStatus::Render(SDL_Surface *screen, const Vector<int> &offset) const {
34         if (!party) return;
35
36         party[hero]->BattleSprite()->Draw(screen, offset, 0, 0);
37
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);
42         nameOffset += offset;
43         res->statusFont->DrawString(party[hero]->Name(), screen, nameOffset, 5);
44
45         Vector<int> levelLabelOffset(nameOffset.X() + 6 * res->statusFont->CharWidth(), nameOffset.Y());
46         res->statusLabels->Draw(screen, levelLabelOffset, 0, 0);
47
48         Vector<int> levelOffset(levelLabelOffset.X() + 2 * res->statusFont->CharWidth(), levelLabelOffset.Y());
49         res->statusFont->DrawNumber(party[hero]->Level(), screen, levelOffset, 2);
50
51         Vector<int> healthLabelOffset(nameOffset.X(), nameOffset.Y() + res->statusFont->CharHeight());
52         res->statusLabels->Draw(screen, healthLabelOffset, 0, 1);
53
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);
56
57         Vector<int> healthSeparatorOffset(healthOffset.X() + 3 * res->statusFont->CharWidth(), healthOffset.Y());
58         res->statusFont->DrawChar('/', screen, healthSeparatorOffset);
59
60         Vector<int> maxHealthOffset(healthSeparatorOffset.X() + res->statusFont->CharWidth(), healthOffset.Y());
61         res->statusFont->DrawNumber(party[hero]->MaxHealth(), screen, maxHealthOffset, 3);
62
63         Vector<int> manaLabelOffset(healthLabelOffset.X(), healthLabelOffset.Y() + res->statusFont->CharHeight());
64         res->statusLabels->Draw(screen, manaLabelOffset, 0, 2);
65
66         Vector<int> manaOffset(healthOffset.X(), healthOffset.Y() + res->statusFont->CharHeight());
67         res->statusFont->DrawNumber(party[hero]->Mana(), screen, manaOffset, 3);
68
69         Vector<int> manaSeparatorOffset(healthSeparatorOffset.X(), manaOffset.Y());
70         res->statusFont->DrawChar('/', screen, manaSeparatorOffset);
71
72         Vector<int> maxManaOffset(maxHealthOffset.X(), manaOffset.Y());
73         res->statusFont->DrawNumber(party[hero]->MaxMana(), screen, maxManaOffset, 3);
74 }
75
76 }