X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fbattle%2FHeroTag.cpp;fp=src%2Fbattle%2FHeroTag.cpp;h=d50b4132d85860f7556041794eac260793c92480;hb=04b582180c8f86f50f08f5141a2514a1fcda3e01;hp=6212f36a5c87bdadf3b3832df02bef94909ae2e2;hpb=f0f4fa6f537c383c77ab586e068e9679b8df1300;p=l2e.git diff --git a/src/battle/HeroTag.cpp b/src/battle/HeroTag.cpp index 6212f36..d50b413 100644 --- a/src/battle/HeroTag.cpp +++ b/src/battle/HeroTag.cpp @@ -29,65 +29,67 @@ const graphics::Sprite *HeroTag::HeroSprite() const { } void HeroTag::Render(SDL_Surface *screen, int width, int height, Point position, bool active) const { + const Resources &r(battle->Res()); + // frame - const Frame *frame(active ? battle->Res().activeHeroTagFrame : battle->Res().heroTagFrame); + const Frame *frame(active ? r.activeHeroTagFrame : r.heroTagFrame); Vector frameOffset(frame->BorderWidth(), frame->BorderHeight()); - Vector alignOffset((index % 2) ? 4 * battle->Res().heroTagFont->CharWidth() : 0, 0); + Vector alignOffset((index % 2) ? 4 * r.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(((index % 2) ? 10 : 6) * battle->Res().heroTagFont->CharWidth()); + int gaugeX(((index % 2) ? 10 : 6) * r.heroTagFont->CharWidth()); // 4 units reserved for hero, gaugeX already includes frame offset - int gaugeWidth(width - gaugeX - ((index % 2) ? 1 : 5) * battle->Res().heroTagFont->CharWidth()); + int gaugeWidth(width - gaugeX - ((index % 2) ? 1 : 5) * r.heroTagFont->CharWidth()); // health gauge, second line - Vector healthGaugeOffset(gaugeX, frameOffset.Y() + battle->Res().heroTagFont->CharHeight()); - battle->Res().healthGauge->Draw(screen, position + healthGaugeOffset, gaugeWidth, hero.RelativeHealth(255)); + Vector healthGaugeOffset(gaugeX, frameOffset.Y() + r.heroTagFont->CharHeight()); + r.healthGauge->Draw(screen, position + healthGaugeOffset, gaugeWidth, hero.RelativeHealth(255)); // mana gauge, third line - Vector manaGaugeOffset(gaugeX, frameOffset.Y() + 2 * battle->Res().heroTagFont->CharHeight()); - battle->Res().manaGauge->Draw(screen, position + manaGaugeOffset, gaugeWidth, hero.RelativeMana(255)); + Vector manaGaugeOffset(gaugeX, frameOffset.Y() + 2 * r.heroTagFont->CharHeight()); + r.manaGauge->Draw(screen, position + manaGaugeOffset, gaugeWidth, hero.RelativeMana(255)); // ikari gauge, fourth line - Vector ikariGaugeOffset(gaugeX, frameOffset.Y() + 3 * battle->Res().heroTagFont->CharHeight()); - battle->Res().ikariGauge->Draw(screen, position + ikariGaugeOffset, gaugeWidth, hero.RelativeIP(255)); + Vector ikariGaugeOffset(gaugeX, frameOffset.Y() + 3 * r.heroTagFont->CharHeight()); + r.ikariGauge->Draw(screen, position + ikariGaugeOffset, gaugeWidth, hero.RelativeIP(255)); // labels - int labelX(((index % 2) ? 5 : 1) * battle->Res().heroTagFont->CharWidth()); + int labelX(((index % 2) ? 5 : 1) * r.heroTagFont->CharWidth()); // level Vector levelLabelOffset(gaugeX, frameOffset.Y()); - battle->Res().heroTagLabels->Draw(screen, position + levelLabelOffset, 0, 0); + r.heroTagLabels->Draw(screen, position + levelLabelOffset, r.levelLabelCol, r.levelLabelRow); // hp - Vector healthLabelOffset(labelX, frameOffset.Y() + battle->Res().heroTagFont->CharHeight()); - battle->Res().heroTagLabels->Draw(screen, position + healthLabelOffset, 0, 1); + Vector healthLabelOffset(labelX, frameOffset.Y() + r.heroTagFont->CharHeight()); + r.heroTagLabels->Draw(screen, position + healthLabelOffset, r.healthLabelCol, r.healthLabelRow); // mp - Vector manaLabelOffset(labelX, frameOffset.Y() + 2 * battle->Res().heroTagFont->CharHeight()); - battle->Res().heroTagLabels->Draw(screen, position + manaLabelOffset, 0, 2); + Vector manaLabelOffset(labelX, frameOffset.Y() + 2 * r.heroTagFont->CharHeight()); + r.heroTagLabels->Draw(screen, position + manaLabelOffset, r.manaLabelCol, r.manaLabelRow); // cm - Vector moveLabelOffset(labelX, frameOffset.Y() + 3 * battle->Res().heroTagFont->CharHeight()); - battle->Res().heroTagLabels->Draw(screen, position + moveLabelOffset, 0, 3); + Vector moveLabelOffset(labelX, frameOffset.Y() + 3 * r.heroTagFont->CharHeight()); + r.heroTagLabels->Draw(screen, position + moveLabelOffset, r.moveLabelCol, r.moveLabelRow); // ip - Vector ikariLabelOffset(labelX + 3 * battle->Res().heroTagFont->CharWidth(), frameOffset.Y() + 3 * battle->Res().heroTagFont->CharHeight()); - battle->Res().heroTagLabels->Draw(screen, position + ikariLabelOffset, 0, 4); + Vector ikariLabelOffset(labelX + 3 * r.heroTagFont->CharWidth(), frameOffset.Y() + 3 * r.heroTagFont->CharHeight()); + r.heroTagLabels->Draw(screen, position + ikariLabelOffset, r.ikariLabelCol, r.ikariLabelRow); // numbers // level - Vector levelNumberOffset(gaugeX + battle->Res().heroTagLabels->Width(), levelLabelOffset.Y()); - battle->Res().heroTagFont->DrawNumber(hero.Level(), screen, position + levelNumberOffset, 2); + Vector levelNumberOffset(gaugeX + r.heroTagLabels->Width(), levelLabelOffset.Y()); + r.heroTagFont->DrawNumber(hero.Level(), screen, position + levelNumberOffset, 2); // health - Vector healthNumberOffset(labelX + battle->Res().heroTagLabels->Width(), healthLabelOffset.Y()); - battle->Res().heroTagFont->DrawNumber(hero.Health(), screen, position + healthNumberOffset, 3); + Vector healthNumberOffset(labelX + r.heroTagLabels->Width(), healthLabelOffset.Y()); + r.heroTagFont->DrawNumber(hero.Health(), screen, position + healthNumberOffset, 3); //mana - Vector manaNumberOffset(labelX + battle->Res().heroTagLabels->Width(), manaLabelOffset.Y()); - battle->Res().heroTagFont->DrawNumber(hero.Mana(), screen, position + manaNumberOffset, 3); + Vector manaNumberOffset(labelX + r.heroTagLabels->Width(), manaLabelOffset.Y()); + r.heroTagFont->DrawNumber(hero.Mana(), screen, position + manaNumberOffset, 3); // name - battle->Res().normalFont->DrawString(hero.Name(), screen, position + frameOffset + alignOffset, 5); + r.normalFont->DrawString(hero.Name(), screen, position + frameOffset + alignOffset, 5); // attack icon 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()); + Vector attackIconOffset(labelX + r.heroTagLabels->Width(), frameOffset.Y() + 3 * r.heroTagFont->CharHeight()); + r.attackChoiceIcons->Draw(screen, position + attackIconOffset, 0, battle->AttackChoiceAt(index).GetType()); } // hero