]> git.localhorst.tv Git - l2e.git/blobdiff - src/battle/HeroTag.cpp
better positioning of hero tags
[l2e.git] / src / battle / HeroTag.cpp
index 713fb8fe35774fbf9766ef72f8791236d8d6b277..87f35dd171813f4db3e093c77b5d99f3ed0ab8e7 100644 (file)
@@ -10,6 +10,7 @@
 #include "Hero.h"
 #include "../geometry/operators.h"
 #include "../geometry/Vector.h"
+#include "../graphics/Frame.h"
 #include "../graphics/Sprite.h"
 
 using geometry::Point;
@@ -18,27 +19,17 @@ using geometry::Vector;
 namespace battle {
 
 void HeroTag::Render(SDL_Surface *screen, int width, int height, Point<int> position, bool active) const {
-       SDL_Rect destRect;
-       destRect.x = position.X();
-       destRect.y = position.Y();
-       destRect.w = width;
-       destRect.h = height;
-
-       destRect.x += 1;
-       destRect.y += 1;
-       destRect.w -= 2;
-       destRect.h -= 2;
-       SDL_FillRect(screen, &destRect, SDL_MapRGB(screen->format, 0xFF, active ? 0 : 0xFF, active ? 0 : 0xFF));
-
-       destRect.x += 1;
-       destRect.y += 1;
-       destRect.w -= 2;
-       destRect.h -= 2;
-       SDL_FillRect(screen, &destRect, SDL_MapRGB(screen->format, 0, 0, 0));
+       if (active) {
+               activeFrame->Draw(screen, position, width, height);
+       } else {
+               frame->Draw(screen, position, width, height);
+       }
+
+       int verticalHeroOffset((height - hero->Sprite()->Height()) / 2);
 
        Vector<int> heroOffset(
-                       (align == LEFT) ? 3 : width - hero->Sprite()->Width() - 3,
-                       height - hero->Sprite()->Height() - 3);
+                       (align == LEFT) ? verticalHeroOffset : width - hero->Sprite()->Width() - verticalHeroOffset,
+                       verticalHeroOffset);
        hero->Sprite()->Draw(screen, position + heroOffset, 0, hero->Health() > 0 ? 0 : 2);
 }