X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fbattle%2FHeroTag.cpp;h=33c42db72de3f0b7d270eaace92d9c1f5ad1b47c;hb=ca31ddeab37eebaa2de5e5b1c94974fac06d418b;hp=87f35dd171813f4db3e093c77b5d99f3ed0ab8e7;hpb=3ecf76abb280da727806262b4cac3472d94f9c5a;p=l2e.git diff --git a/src/battle/HeroTag.cpp b/src/battle/HeroTag.cpp index 87f35dd..33c42db 100644 --- a/src/battle/HeroTag.cpp +++ b/src/battle/HeroTag.cpp @@ -10,7 +10,9 @@ #include "Hero.h" #include "../geometry/operators.h" #include "../geometry/Vector.h" +#include "../graphics/Font.h" #include "../graphics/Frame.h" +#include "../graphics/Gauge.h" #include "../graphics/Sprite.h" using geometry::Point; @@ -19,17 +21,66 @@ using geometry::Vector; namespace battle { void HeroTag::Render(SDL_Surface *screen, int width, int height, Point position, bool active) const { + // 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 verticalHeroOffset((height - hero->Sprite()->Height()) / 2); + 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) * font->CharWidth()); + // 4 units reserved for hero, gaugeX already includes frame offset + int gaugeWidth(width - gaugeX - (align == LEFT ? 1 : 5) * font->CharWidth()); + // health gauge, second line + Vector healthGaugeOffset(gaugeX, frameOffset.Y() + font->CharHeight()); + healthGauge->Draw(screen, position + healthGaugeOffset, gaugeWidth, hero->RelativeHealth(gaugeWidth)); + // mana gauge, third line + Vector manaGaugeOffset(gaugeX, frameOffset.Y() + 2 * font->CharHeight()); + manaGauge->Draw(screen, position + manaGaugeOffset, gaugeWidth, hero->RelativeMana(gaugeWidth)); + // ikari gauge, fourth line + Vector ikariGaugeOffset(gaugeX, frameOffset.Y() + 3 * font->CharHeight()); + ikariGauge->Draw(screen, position + ikariGaugeOffset, gaugeWidth, hero->RelativeIP(gaugeWidth)); + + // labels + int labelX((align == LEFT ? 5 : 1) * font->CharWidth()); + // level + Vector levelLabelOffset(gaugeX, frameOffset.Y()); + sprites->Draw(screen, position + levelLabelOffset, 0, 0); + // hp + Vector healthLabelOffset(labelX, frameOffset.Y() + font->CharHeight()); + sprites->Draw(screen, position + healthLabelOffset, 0, 1); + // mp + Vector manaLabelOffset(labelX, frameOffset.Y() + 2 * font->CharHeight()); + sprites->Draw(screen, position + manaLabelOffset, 0, 2); + // cm + Vector moveLabelOffset(labelX, frameOffset.Y() + 3 * font->CharHeight()); + sprites->Draw(screen, position + moveLabelOffset, 0, 3); + // ip + Vector ikariLabelOffset(labelX + 3 * font->CharWidth(), frameOffset.Y() + 3 * font->CharHeight()); + sprites->Draw(screen, position + ikariLabelOffset, 0, 4); + + // numbers + // level + Vector levelNumberOffset(gaugeX + sprites->Width(), levelLabelOffset.Y()); + font->DrawNumber(hero->Level(), screen, position + levelNumberOffset, 2); + // health + Vector healthNumberOffset(labelX + sprites->Width(), healthLabelOffset.Y()); + font->DrawNumber(hero->Health(), screen, position + healthNumberOffset, 3); + //mana + Vector manaNumberOffset(labelX + sprites->Width(), manaLabelOffset.Y()); + font->DrawNumber(hero->Mana(), screen, position + manaNumberOffset, 3); + + // hero Vector heroOffset( - (align == LEFT) ? verticalHeroOffset : width - hero->Sprite()->Width() - verticalHeroOffset, - verticalHeroOffset); + (align == LEFT) ? yOffset : width - hero->Sprite()->Width() - yOffset, + yOffset); hero->Sprite()->Draw(screen, position + heroOffset, 0, hero->Health() > 0 ? 0 : 2); }