]> git.localhorst.tv Git - l2e.git/blob - src/menu/HeroStatus.cpp
added hero status tags in party menu
[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 , hero(0) {
22
23 }
24
25 HeroStatus::~HeroStatus() {
26
27 }
28
29
30 int HeroStatus::Width() const {
31         return hero->BattleSprite()->Width() + res->normalFont->CharWidth() * 10;
32 }
33
34 int HeroStatus::Height() const {
35         return hero->BattleSprite()->Height();
36 }
37
38
39 void HeroStatus::Render(SDL_Surface *screen, const Vector<int> &offset) const {
40         if (!hero) return;
41
42         hero->BattleSprite()->Draw(screen, position + offset, 0, 0);
43
44         // for some reason, fonts are shifted by one pixel in the original
45         Vector<int> nameOffset(
46                         hero->BattleSprite()->Width(),
47                         res->normalFont->CharHeight() * 7 / 8);
48         nameOffset += position + offset;
49         res->normalFont->DrawString(hero->Name(), screen, nameOffset, 5);
50
51         Vector<int> levelLabelOffset(nameOffset.X() + 6 * res->normalFont->CharWidth(), nameOffset.Y());
52         res->statusLabels->Draw(screen, levelLabelOffset, 0, 0);
53
54         Vector<int> levelOffset(levelLabelOffset.X() + 2 * res->normalFont->CharWidth(), levelLabelOffset.Y());
55         res->normalFont->DrawNumber(hero->Level(), screen, levelOffset, 2);
56
57         Vector<int> healthLabelOffset(nameOffset.X(), nameOffset.Y() + res->normalFont->CharHeight());
58         res->statusLabels->Draw(screen, healthLabelOffset, 0, 1);
59
60         Vector<int> healthOffset(nameOffset.X() + 3 * res->normalFont->CharWidth(), nameOffset.Y() + res->normalFont->CharHeight());
61         res->normalFont->DrawNumber(hero->Health(), screen, healthOffset, 3);
62
63         Vector<int> healthSeparatorOffset(healthOffset.X() + 3 * res->normalFont->CharWidth(), healthOffset.Y());
64         res->normalFont->DrawChar('/', screen, healthSeparatorOffset);
65
66         Vector<int> maxHealthOffset(healthSeparatorOffset.X() + res->normalFont->CharWidth(), healthOffset.Y());
67         res->normalFont->DrawNumber(hero->MaxHealth(), screen, maxHealthOffset, 3);
68
69         Vector<int> manaLabelOffset(healthLabelOffset.X(), healthLabelOffset.Y() + res->normalFont->CharHeight());
70         res->statusLabels->Draw(screen, manaLabelOffset, 0, 2);
71
72         Vector<int> manaOffset(healthOffset.X(), healthOffset.Y() + res->normalFont->CharHeight());
73         res->normalFont->DrawNumber(hero->Mana(), screen, manaOffset, 3);
74
75         Vector<int> manaSeparatorOffset(healthSeparatorOffset.X(), manaOffset.Y());
76         res->normalFont->DrawChar('/', screen, manaSeparatorOffset);
77
78         Vector<int> maxManaOffset(maxHealthOffset.X(), manaOffset.Y());
79         res->normalFont->DrawNumber(hero->MaxMana(), screen, maxManaOffset, 3);
80 }
81
82 }