]> git.localhorst.tv Git - l2e.git/blob - src/battle/SmallHeroTag.cpp
a70dbfecd2b1e4f577c1d9053ec46f3c6ae5af34
[l2e.git] / src / battle / SmallHeroTag.cpp
1 /*
2  * SmallHeroTag.cpp
3  *
4  *  Created on: Aug 11, 2012
5  *      Author: holy
6  */
7
8 #include "SmallHeroTag.h"
9
10 #include "BattleState.h"
11 #include "../geometry/Vector.h"
12 #include "../graphics/Font.h"
13 #include "../graphics/Frame.h"
14 #include "../graphics/Gauge.h"
15
16 using geometry::Vector;
17 using graphics::Font;
18 using graphics::Frame;
19 using graphics::Sprite;
20
21 namespace battle {
22
23 void SmallHeroTag::Render(SDL_Surface *screen, int width, int height, const geometry::Vector<int> &position) const {
24         const Resources &r(battle->Res());
25         const Frame *frame((index == battle->MaxHeroes() - 1) ? r.lastSmallHeroTagFrame : r.smallHeroTagFrame);
26         const Font *font(r.normalFont);
27         const Sprite *labels(r.heroTagLabels);
28
29         frame->Draw(screen, position, width, height);
30
31         if (battle->HeroPositionOccupied(index)) {
32                 const Hero &hero(battle->HeroAt(index));
33
34                 int gaugeWidth(width - 2 * frame->BorderWidth() - labels->Width());
35                 Vector<int> nameOffset(frame->BorderSize());
36                 Vector<int> hpLabelOffset(nameOffset.X(), nameOffset.Y() + font->CharHeight());
37                 Vector<int> mpLabelOffset(hpLabelOffset.X(), hpLabelOffset.Y() + font->CharHeight());
38                 Vector<int> ipLabelOffset(mpLabelOffset.X(), mpLabelOffset.Y() + font->CharHeight());
39                 Vector<int> hpGaugeOffset(hpLabelOffset.X() + labels->Width(), hpLabelOffset.Y());
40                 Vector<int> mpGaugeOffset(mpLabelOffset.X() + labels->Width(), mpLabelOffset.Y());
41                 Vector<int> ipGaugeOffset(ipLabelOffset.X() + labels->Width(), ipLabelOffset.Y());
42
43                 font->DrawString(hero.Name(), screen, position + nameOffset, 5);
44                 labels->Draw(screen, position + hpLabelOffset, r.healthLabelCol, r.healthLabelRow);
45                 labels->Draw(screen, position + mpLabelOffset, r.manaLabelCol, r.manaLabelRow);
46                 labels->Draw(screen, position + ipLabelOffset, r.ikariLabelCol, r.ikariLabelRow);
47                 r.healthGauge->Draw(screen, position + hpGaugeOffset, gaugeWidth, hero.RelativeHealth(255));
48                 r.manaGauge->Draw(screen, position + mpGaugeOffset, gaugeWidth, hero.RelativeMana(255));
49                 r.ikariGauge->Draw(screen, position + ipGaugeOffset, gaugeWidth, hero.RelativeIP(255));
50         }
51
52 }
53
54 }