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