From: Daniel Karbach Date: Wed, 8 Aug 2012 12:47:09 +0000 (+0200) Subject: added hero tag labels X-Git-Url: https://git.localhorst.tv/?a=commitdiff_plain;h=0ef4dc19f03955b82d22330342acb179cf12b551;p=l2e.git added hero tag labels --- diff --git a/src/battle/BattleState.cpp b/src/battle/BattleState.cpp index b1eaa4d..4053220 100644 --- a/src/battle/BattleState.cpp +++ b/src/battle/BattleState.cpp @@ -50,7 +50,7 @@ void BattleState::EnterState(Application &ctrl, SDL_Surface *screen) { heroesLayout->CalculatePositions(background->w, background->h, heroesPositions); attackChoices.resize(heroes.size()); for (vector::size_type i(0), end(heroes.size()); i < end; ++i) { - heroTags.push_back(HeroTag(&heroes[i], &attackChoices[i], heroTagFrame, activeHeroTagFrame, healthGauge, manaGauge, ikariGauge, HeroTag::Alignment((i + 1) % 2))); + heroTags.push_back(HeroTag(&heroes[i], &attackChoices[i], heroTagFrame, activeHeroTagFrame, healthGauge, manaGauge, ikariGauge, heroTagSprites, HeroTag::Alignment((i + 1) % 2))); } } diff --git a/src/battle/BattleState.h b/src/battle/BattleState.h index b56b9fe..0e3436b 100644 --- a/src/battle/BattleState.h +++ b/src/battle/BattleState.h @@ -36,7 +36,7 @@ class BattleState : public app::State { public: - BattleState(SDL_Surface *background, const PartyLayout &monstersLayout, const PartyLayout &heroesLayout, const graphics::Sprite *attackIcons, const graphics::Sprite *moveIcons, const graphics::Frame *heroTagFrame, const graphics::Frame *activeHeroTagFrame, const graphics::Gauge *healthGauge, const graphics::Gauge *manaGauge, const graphics::Gauge *ikariGauge) + BattleState(SDL_Surface *background, const PartyLayout &monstersLayout, const PartyLayout &heroesLayout, const graphics::Sprite *attackIcons, const graphics::Sprite *moveIcons, const graphics::Frame *heroTagFrame, const graphics::Frame *activeHeroTagFrame, const graphics::Gauge *healthGauge, const graphics::Gauge *manaGauge, const graphics::Gauge *ikariGauge, const graphics::Sprite *heroTagSprites) : background(background) , monstersLayout(&monstersLayout) , heroesLayout(&heroesLayout) @@ -45,6 +45,7 @@ public: , healthGauge(healthGauge) , manaGauge(manaGauge) , ikariGauge(ikariGauge) + , heroTagSprites(heroTagSprites) , attackTypeMenu(attackIcons) , moveMenu(moveIcons) , activeHero(-1) { } @@ -98,6 +99,7 @@ private: const graphics::Gauge *healthGauge; const graphics::Gauge *manaGauge; const graphics::Gauge *ikariGauge; + const graphics::Sprite *heroTagSprites; AttackTypeMenu attackTypeMenu; MoveMenu moveMenu; std::vector > monsterPositions; diff --git a/src/battle/HeroTag.cpp b/src/battle/HeroTag.cpp index 4c34402..a823749 100644 --- a/src/battle/HeroTag.cpp +++ b/src/battle/HeroTag.cpp @@ -47,6 +47,24 @@ void HeroTag::Render(SDL_Surface *screen, int width, int height, Point posi Vector ikariGaugeOffset(gaugeX, 4 * frameOffset.Y()); ikariGauge->Draw(screen, position + ikariGaugeOffset, gaugeWidth, hero->RelativeIP(gaugeWidth)); + // labels + int labelX((align == LEFT ? 5 : 1) * frameOffset.X()); + // level + Vector levelLabelOffset(gaugeX, frameOffset.Y()); + sprites->Draw(screen, position + levelLabelOffset, 0, 0); + // hp + Vector healthLabelOffset(labelX, 2 * frameOffset.Y()); + sprites->Draw(screen, position + healthLabelOffset, 0, 1); + // mp + Vector manaLabelOffset(labelX, 3 * frameOffset.Y()); + sprites->Draw(screen, position + manaLabelOffset, 0, 2); + // cm + Vector moveLabelOffset(labelX, 4 * frameOffset.Y()); + sprites->Draw(screen, position + moveLabelOffset, 0, 3); + // ip + Vector ikariLabelOffset(labelX + 3 * frameOffset.X(), 4 * frameOffset.Y()); + sprites->Draw(screen, position + ikariLabelOffset, 0, 4); + // hero Vector heroOffset( (align == LEFT) ? yOffset : width - hero->Sprite()->Width() - yOffset, diff --git a/src/battle/HeroTag.h b/src/battle/HeroTag.h index b5ab475..004d3ec 100644 --- a/src/battle/HeroTag.h +++ b/src/battle/HeroTag.h @@ -15,6 +15,7 @@ namespace graphics { class Frame; class Gauge; + class Sprite; } namespace battle { @@ -31,8 +32,8 @@ public: }; public: - HeroTag(const Hero *hero, const AttackChoice *choice, const graphics::Frame *frame, const graphics::Frame *activeFrame, const graphics::Gauge *healthGauge, const graphics::Gauge *manaGauge, const graphics::Gauge *ikariGauge, Alignment align) - : hero(hero), choice(choice), frame(frame), activeFrame(activeFrame), healthGauge(healthGauge), manaGauge(manaGauge), ikariGauge(ikariGauge), align(align) { } + HeroTag(const Hero *hero, const AttackChoice *choice, const graphics::Frame *frame, const graphics::Frame *activeFrame, const graphics::Gauge *healthGauge, const graphics::Gauge *manaGauge, const graphics::Gauge *ikariGauge, const graphics::Sprite *sprites, Alignment align) + : hero(hero), choice(choice), frame(frame), activeFrame(activeFrame), healthGauge(healthGauge), manaGauge(manaGauge), ikariGauge(ikariGauge), sprites(sprites), align(align) { } ~HeroTag() { } public: @@ -46,6 +47,7 @@ private: const graphics::Gauge *healthGauge; const graphics::Gauge *manaGauge; const graphics::Gauge *ikariGauge; + const graphics::Sprite *sprites; Alignment align; }; diff --git a/src/main.cpp b/src/main.cpp index c3d73cb..71a4afb 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -86,6 +86,8 @@ int main(int argc, char **argv) { Sprite attackIconsSprite(attackIcons, 32, 32); SDL_Surface *moveIcons(IMG_Load("test-data/move-icons.png")); Sprite moveIconsSprite(moveIcons, 32, 32); + SDL_Surface *heroTagSprites(IMG_Load("test-data/hero-tag-sprites.png")); + Sprite heroTagSprite(heroTagSprites, 32, 16); SDL_Surface *tagFrames(IMG_Load("test-data/tag-frames.png")); Frame heroTagFrame(tagFrames, 16, 16, 1, 1, 0, 33); Frame activeHeroTagFrame(tagFrames, 16, 16); @@ -95,7 +97,7 @@ int main(int argc, char **argv) { Gauge manaGauge(gauges, 0, 32, 0, 0, 16, 6, 1, 6); Gauge ikariGauge(gauges, 0, 48, 0, 0, 16, 6, 1, 6); - BattleState *battleState(new BattleState(bg, monstersLayout, heroesLayout, &attackIconsSprite, &moveIconsSprite, &heroTagFrame, &activeHeroTagFrame, &healthGauge, &manaGauge, &ikariGauge)); + BattleState *battleState(new BattleState(bg, monstersLayout, heroesLayout, &attackIconsSprite, &moveIconsSprite, &heroTagFrame, &activeHeroTagFrame, &healthGauge, &manaGauge, &ikariGauge, &heroTagSprite)); battleState->AddMonster(monster); battleState->AddMonster(monster); battleState->AddMonster(monster); diff --git a/test-data/hero-tag-sprites.png b/test-data/hero-tag-sprites.png new file mode 100644 index 0000000..0a3fee9 Binary files /dev/null and b/test-data/hero-tag-sprites.png differ