]> git.localhorst.tv Git - l2e.git/blobdiff - src/battle/HeroTag.cpp
fix bug in select attack type state that caused the tag positioning to go nuts
[l2e.git] / src / battle / HeroTag.cpp
index 01cee4485f463ed1c68fce599c7fb6e47f0aa08e..a83ba8b9fc1f019dd5695816db09388cb653d5fe 100644 (file)
@@ -7,6 +7,7 @@
 
 #include "HeroTag.h"
 
+#include "AttackChoice.h"
 #include "Hero.h"
 #include "Resources.h"
 #include "../geometry/operators.h"
@@ -26,10 +27,9 @@ void HeroTag::Render(SDL_Surface *screen, int width, int height, Point<int> posi
        // frame
        const Frame *frame(active ? res->activeHeroTagFrame : res->heroTagFrame);
        Vector<int> frameOffset(frame->BorderWidth(), frame->BorderHeight());
+       Vector<int> alignOffset(align == LEFT ? 4 * res->heroTagFont->CharWidth() : 0, 0);
        frame->Draw(screen, position, width, height);
 
-       int yOffset((height - hero->Sprite()->Height()) / 2);
-
        // gauges
        // NOTE: assuming frame border is unit size until charsets are impemented
        int gaugeX((align == LEFT ? 10 : 6) * res->heroTagFont->CharWidth());
@@ -74,11 +74,23 @@ void HeroTag::Render(SDL_Surface *screen, int width, int height, Point<int> posi
        Vector<int> manaNumberOffset(labelX + res->heroTagLabels->Width(), manaLabelOffset.Y());
        res->heroTagFont->DrawNumber(hero->Mana(), screen, position + manaNumberOffset, 3);
 
+       // name
+       res->normalFont->DrawString(hero->Name(), screen, position + frameOffset + alignOffset, 5);
+
+       // attack icon
+       if (choice->GetType() != AttackChoice::UNDECIDED) {
+               Vector<int> attackIconOffset(labelX + res->heroTagLabels->Width(), frameOffset.Y() + 3 * res->heroTagFont->CharHeight());
+               res->attackChoiceIcons->Draw(screen, position + attackIconOffset, 0, choice->GetType());
+       }
+
        // hero
-       Vector<int> heroOffset(
-                       (align == LEFT) ? yOffset : width - hero->Sprite()->Width() - yOffset,
-                       yOffset);
-       hero->Sprite()->Draw(screen, position + heroOffset, 0, hero->Health() > 0 ? 0 : 2);
+       hero->Sprite()->Draw(screen, position + HeroOffset(), 0, hero->Health() > 0 ? 0 : 2);
+}
+
+Vector<int> HeroTag::HeroOffset() const {
+       return Vector<int>(
+                       (align == LEFT) ? res->normalFont->CharWidth() : 10 * res->normalFont->CharWidth(),
+                       res->normalFont->CharWidth());
 }
 
 }