X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fbattle%2FHeroTag.cpp;h=96dedd9269e836037804c4d1a0c822375ca20763;hb=8723daa89e877ac98e6012b0c37e3b4eb6131426;hp=851e88ed07f10d32e4da792364efc0ede7426cd4;hpb=2e0bbc9fcc1cce3e1faeff85cc63de7f676e8077;p=l2e.git diff --git a/src/battle/HeroTag.cpp b/src/battle/HeroTag.cpp index 851e88e..96dedd9 100644 --- a/src/battle/HeroTag.cpp +++ b/src/battle/HeroTag.cpp @@ -7,45 +7,83 @@ #include "HeroTag.h" +#include "AttackChoice.h" #include "Hero.h" +#include "Resources.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; using geometry::Vector; +using graphics::Frame; 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()); - } + const Frame *frame(active ? res->activeHeroTagFrame : res->heroTagFrame); + Vector frameOffset(frame->BorderWidth(), frame->BorderHeight()); + Vector 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) * frameOffset.X()); + int gaugeX((align == LEFT ? 10 : 6) * res->heroTagFont->CharWidth()); // 4 units reserved for hero, gaugeX already includes frame offset - int gaugeWidth(width - gaugeX - (align == LEFT ? 1 : 5) * frameOffset.X()); + int gaugeWidth(width - gaugeX - (align == LEFT ? 1 : 5) * res->heroTagFont->CharWidth()); // health gauge, second line - Vector healthGaugeOffset(gaugeX, 2 * frameOffset.Y()); - healthGauge->Draw(screen, position + healthGaugeOffset, gaugeWidth, hero->RelativeHealth(256)); + Vector healthGaugeOffset(gaugeX, frameOffset.Y() + res->heroTagFont->CharHeight()); + res->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(256)); + Vector manaGaugeOffset(gaugeX, frameOffset.Y() + 2 * res->heroTagFont->CharHeight()); + res->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(256)); + Vector ikariGaugeOffset(gaugeX, frameOffset.Y() + 3 * res->heroTagFont->CharHeight()); + res->ikariGauge->Draw(screen, position + ikariGaugeOffset, gaugeWidth, hero->RelativeIP(gaugeWidth)); + + // labels + int labelX((align == LEFT ? 5 : 1) * res->heroTagFont->CharWidth()); + // level + Vector levelLabelOffset(gaugeX, frameOffset.Y()); + res->heroTagLabels->Draw(screen, position + levelLabelOffset, 0, 0); + // hp + Vector healthLabelOffset(labelX, frameOffset.Y() + res->heroTagFont->CharHeight()); + res->heroTagLabels->Draw(screen, position + healthLabelOffset, 0, 1); + // mp + Vector manaLabelOffset(labelX, frameOffset.Y() + 2 * res->heroTagFont->CharHeight()); + res->heroTagLabels->Draw(screen, position + manaLabelOffset, 0, 2); + // cm + Vector moveLabelOffset(labelX, frameOffset.Y() + 3 * res->heroTagFont->CharHeight()); + res->heroTagLabels->Draw(screen, position + moveLabelOffset, 0, 3); + // ip + Vector ikariLabelOffset(labelX + 3 * res->heroTagFont->CharWidth(), frameOffset.Y() + 3 * res->heroTagFont->CharHeight()); + res->heroTagLabels->Draw(screen, position + ikariLabelOffset, 0, 4); + + // numbers + // level + Vector levelNumberOffset(gaugeX + res->heroTagLabels->Width(), levelLabelOffset.Y()); + res->heroTagFont->DrawNumber(hero->Level(), screen, position + levelNumberOffset, 2); + // health + Vector healthNumberOffset(labelX + res->heroTagLabels->Width(), healthLabelOffset.Y()); + res->heroTagFont->DrawNumber(hero->Health(), screen, position + healthNumberOffset, 3); + //mana + Vector 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 attackIconOffset(labelX + res->heroTagLabels->Width(), frameOffset.Y() + 3 * res->heroTagFont->CharHeight()); + res->attackChoiceIcons->Draw(screen, position + attackIconOffset, 0, choice->GetType()); + } // hero Vector heroOffset(