X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fbattle%2FHeroTag.cpp;fp=src%2Fbattle%2FHeroTag.cpp;h=6212f36a5c87bdadf3b3832df02bef94909ae2e2;hb=62c0a1d0ac98eb51418e4daa59e80b6cc97b522f;hp=3f9be08557fc45696dc4831f3cc54a6137fc351e;hpb=41983a2cd8dbbfe6adc02cdfccbf5c2887306e51;p=l2e.git diff --git a/src/battle/HeroTag.cpp b/src/battle/HeroTag.cpp index 3f9be08..6212f36 100644 --- a/src/battle/HeroTag.cpp +++ b/src/battle/HeroTag.cpp @@ -8,6 +8,7 @@ #include "HeroTag.h" #include "AttackChoice.h" +#include "BattleState.h" #include "Hero.h" #include "Resources.h" #include "../geometry/operators.h" @@ -23,74 +24,80 @@ using graphics::Frame; namespace battle { +const graphics::Sprite *HeroTag::HeroSprite() const { + return battle->HeroAt(index).Sprite(); +} + void HeroTag::Render(SDL_Surface *screen, int width, int height, Point position, bool active) const { // frame - const Frame *frame(active ? res->activeHeroTagFrame : res->heroTagFrame); + const Frame *frame(active ? battle->Res().activeHeroTagFrame : battle->Res().heroTagFrame); Vector frameOffset(frame->BorderWidth(), frame->BorderHeight()); - Vector alignOffset(align == LEFT ? 4 * res->heroTagFont->CharWidth() : 0, 0); + Vector alignOffset((index % 2) ? 4 * battle->Res().heroTagFont->CharWidth() : 0, 0); frame->Draw(screen, position, width, height); + const Hero &hero(battle->HeroAt(index)); + // gauges // NOTE: assuming frame border is unit size until charsets are impemented - int gaugeX((align == LEFT ? 10 : 6) * res->heroTagFont->CharWidth()); + int gaugeX(((index % 2) ? 10 : 6) * battle->Res().heroTagFont->CharWidth()); // 4 units reserved for hero, gaugeX already includes frame offset - int gaugeWidth(width - gaugeX - (align == LEFT ? 1 : 5) * res->heroTagFont->CharWidth()); + int gaugeWidth(width - gaugeX - ((index % 2) ? 1 : 5) * battle->Res().heroTagFont->CharWidth()); // health gauge, second line - Vector healthGaugeOffset(gaugeX, frameOffset.Y() + res->heroTagFont->CharHeight()); - res->healthGauge->Draw(screen, position + healthGaugeOffset, gaugeWidth, hero->RelativeHealth(255)); + Vector healthGaugeOffset(gaugeX, frameOffset.Y() + battle->Res().heroTagFont->CharHeight()); + battle->Res().healthGauge->Draw(screen, position + healthGaugeOffset, gaugeWidth, hero.RelativeHealth(255)); // mana gauge, third line - Vector manaGaugeOffset(gaugeX, frameOffset.Y() + 2 * res->heroTagFont->CharHeight()); - res->manaGauge->Draw(screen, position + manaGaugeOffset, gaugeWidth, hero->RelativeMana(255)); + Vector manaGaugeOffset(gaugeX, frameOffset.Y() + 2 * battle->Res().heroTagFont->CharHeight()); + battle->Res().manaGauge->Draw(screen, position + manaGaugeOffset, gaugeWidth, hero.RelativeMana(255)); // ikari gauge, fourth line - Vector ikariGaugeOffset(gaugeX, frameOffset.Y() + 3 * res->heroTagFont->CharHeight()); - res->ikariGauge->Draw(screen, position + ikariGaugeOffset, gaugeWidth, hero->RelativeIP(255)); + Vector ikariGaugeOffset(gaugeX, frameOffset.Y() + 3 * battle->Res().heroTagFont->CharHeight()); + battle->Res().ikariGauge->Draw(screen, position + ikariGaugeOffset, gaugeWidth, hero.RelativeIP(255)); // labels - int labelX((align == LEFT ? 5 : 1) * res->heroTagFont->CharWidth()); + int labelX(((index % 2) ? 5 : 1) * battle->Res().heroTagFont->CharWidth()); // level Vector levelLabelOffset(gaugeX, frameOffset.Y()); - res->heroTagLabels->Draw(screen, position + levelLabelOffset, 0, 0); + battle->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); + Vector healthLabelOffset(labelX, frameOffset.Y() + battle->Res().heroTagFont->CharHeight()); + battle->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); + Vector manaLabelOffset(labelX, frameOffset.Y() + 2 * battle->Res().heroTagFont->CharHeight()); + battle->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); + Vector moveLabelOffset(labelX, frameOffset.Y() + 3 * battle->Res().heroTagFont->CharHeight()); + battle->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); + Vector ikariLabelOffset(labelX + 3 * battle->Res().heroTagFont->CharWidth(), frameOffset.Y() + 3 * battle->Res().heroTagFont->CharHeight()); + battle->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); + Vector levelNumberOffset(gaugeX + battle->Res().heroTagLabels->Width(), levelLabelOffset.Y()); + battle->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); + Vector healthNumberOffset(labelX + battle->Res().heroTagLabels->Width(), healthLabelOffset.Y()); + battle->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); + Vector manaNumberOffset(labelX + battle->Res().heroTagLabels->Width(), manaLabelOffset.Y()); + battle->Res().heroTagFont->DrawNumber(hero.Mana(), screen, position + manaNumberOffset, 3); // name - res->normalFont->DrawString(hero->Name(), screen, position + frameOffset + alignOffset, 5); + battle->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()); + if (battle->AttackChoiceAt(index).GetType() != AttackChoice::UNDECIDED) { + Vector attackIconOffset(labelX + battle->Res().heroTagLabels->Width(), frameOffset.Y() + 3 * battle->Res().heroTagFont->CharHeight()); + battle->Res().attackChoiceIcons->Draw(screen, position + attackIconOffset, 0, battle->AttackChoiceAt(index).GetType()); } // hero - hero->Sprite()->Draw(screen, position + HeroOffset(), 0, hero->Health() > 0 ? 0 : 2); + HeroSprite()->Draw(screen, position + HeroOffset(), 0, battle->HeroAt(index).Health() > 0 ? 0 : 2); } Vector HeroTag::HeroOffset() const { return Vector( - (align == LEFT) ? res->normalFont->CharWidth() : 10 * res->normalFont->CharWidth(), - res->normalFont->CharWidth()); + (index % 2) ? battle->Res().normalFont->CharWidth() : 10 * battle->Res().normalFont->CharWidth(), + battle->Res().normalFont->CharWidth()); } }