X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fbattle%2FHeroTag.cpp;h=4c344028735e14928e0fc2cd2d7921c9b559d87e;hb=cf20874f973521e84fc2aaa6cd47c56a278d9de7;hp=713fb8fe35774fbf9766ef72f8791236d8d6b277;hpb=bfcf2f4de43077249b82af03a0e1b8281b8490e3;p=l2e.git diff --git a/src/battle/HeroTag.cpp b/src/battle/HeroTag.cpp index 713fb8f..4c34402 100644 --- a/src/battle/HeroTag.cpp +++ b/src/battle/HeroTag.cpp @@ -10,6 +10,8 @@ #include "Hero.h" #include "../geometry/operators.h" #include "../geometry/Vector.h" +#include "../graphics/Frame.h" +#include "../graphics/Gauge.h" #include "../graphics/Sprite.h" using geometry::Point; @@ -18,27 +20,37 @@ using geometry::Vector; namespace battle { void HeroTag::Render(SDL_Surface *screen, int width, int height, Point 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)); - + // frame + Vector frameOffset; + if (active) { + activeFrame->Draw(screen, position, width, height); + frameOffset = Vector(activeFrame->BorderWidth(), activeFrame->BorderHeight()); + } else { + frame->Draw(screen, position, width, height); + frameOffset = Vector(frame->BorderWidth(), frame->BorderHeight()); + } + + 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) * frameOffset.X()); + // 4 units reserved for hero, gaugeX already includes frame offset + int gaugeWidth(width - gaugeX - (align == LEFT ? 1 : 5) * frameOffset.X()); + // health gauge, second line + Vector healthGaugeOffset(gaugeX, 2 * frameOffset.Y()); + healthGauge->Draw(screen, position + healthGaugeOffset, gaugeWidth, hero->RelativeHealth(gaugeWidth)); + // mana gauge, third line + Vector manaGaugeOffset(gaugeX, 3 * frameOffset.Y()); + manaGauge->Draw(screen, position + manaGaugeOffset, gaugeWidth, hero->RelativeMana(gaugeWidth)); + // ikari gauge, fourth line + Vector ikariGaugeOffset(gaugeX, 4 * frameOffset.Y()); + ikariGauge->Draw(screen, position + ikariGaugeOffset, gaugeWidth, hero->RelativeIP(gaugeWidth)); + + // hero Vector heroOffset( - (align == LEFT) ? 3 : width - hero->Sprite()->Width() - 3, - height - hero->Sprite()->Height() - 3); + (align == LEFT) ? yOffset : width - hero->Sprite()->Width() - yOffset, + yOffset); hero->Sprite()->Draw(screen, position + heroOffset, 0, hero->Health() > 0 ? 0 : 2); }