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