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