+/*
+ * SmallHeroTag.cpp
+ *
+ * Created on: Aug 11, 2012
+ * Author: holy
+ */
+
+#include "SmallHeroTag.h"
+
+#include "BattleState.h"
+#include "../geometry/operators.h"
+#include "../geometry/Vector.h"
+#include "../graphics/Font.h"
+#include "../graphics/Frame.h"
+#include "../graphics/Gauge.h"
+
+using geometry::Point;
+using geometry::Vector;
+using graphics::Font;
+using graphics::Frame;
+using graphics::Sprite;
+
+namespace battle {
+
+void SmallHeroTag::Render(SDL_Surface *screen, int width, int height, geometry::Point<int> position) const {
+ const Resources &r(battle->Res());
+ const Frame *frame((index == battle->MaxHeroes() - 1) ? r.lastSmallHeroTagFrame : r.smallHeroTagFrame);
+ const Font *font(r.normalFont);
+ const Sprite *labels(r.heroTagLabels);
+
+ frame->Draw(screen, position, width, height);
+
+ if (battle->HeroPositionOccupied(index)) {
+ const Hero &hero(battle->HeroAt(index));
+
+ int gaugeWidth(width - 2 * frame->BorderWidth() - labels->Width());
+ Vector<int> nameOffset(frame->BorderWidth(), frame->BorderHeight());
+ Vector<int> hpLabelOffset(nameOffset.X(), nameOffset.Y() + font->CharHeight());
+ Vector<int> mpLabelOffset(hpLabelOffset.X(), hpLabelOffset.Y() + font->CharHeight());
+ Vector<int> ipLabelOffset(mpLabelOffset.X(), mpLabelOffset.Y() + font->CharHeight());
+ Vector<int> hpGaugeOffset(hpLabelOffset.X() + labels->Width(), hpLabelOffset.Y());
+ Vector<int> mpGaugeOffset(mpLabelOffset.X() + labels->Width(), mpLabelOffset.Y());
+ Vector<int> ipGaugeOffset(ipLabelOffset.X() + labels->Width(), ipLabelOffset.Y());
+
+ font->DrawString(hero.Name(), screen, position + nameOffset, 5);
+ labels->Draw(screen, position + hpLabelOffset, r.healthLabelCol, r.healthLabelRow);
+ labels->Draw(screen, position + mpLabelOffset, r.manaLabelCol, r.manaLabelRow);
+ labels->Draw(screen, position + ipLabelOffset, r.ikariLabelCol, r.ikariLabelRow);
+ r.healthGauge->Draw(screen, position + hpGaugeOffset, gaugeWidth, hero.RelativeHealth(255));
+ r.manaGauge->Draw(screen, position + mpGaugeOffset, gaugeWidth, hero.RelativeMana(255));
+ r.ikariGauge->Draw(screen, position + ipGaugeOffset, gaugeWidth, hero.RelativeIP(255));
+ }
+
+}
+
+}