]> git.localhorst.tv Git - l2e.git/commitdiff
added hero tag labels
authorDaniel Karbach <daniel.karbach@localhorst.tv>
Wed, 8 Aug 2012 12:47:09 +0000 (14:47 +0200)
committerDaniel Karbach <daniel.karbach@localhorst.tv>
Wed, 8 Aug 2012 12:47:09 +0000 (14:47 +0200)
src/battle/BattleState.cpp
src/battle/BattleState.h
src/battle/HeroTag.cpp
src/battle/HeroTag.h
src/main.cpp
test-data/hero-tag-sprites.png [new file with mode: 0644]

index b1eaa4d144996525ee2a449f4020d2a8529d987a..4053220b14c96b5c82076679a6070bc598b159d3 100644 (file)
@@ -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<Hero>::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)));
        }
 }
 
index b56b9fe3d55cd262dab2ff1e5acec7ad2f65e7d9..0e3436b1fcda93164eafa8b2f801951219a4d1a0 100644 (file)
@@ -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<geometry::Point<int> > monsterPositions;
index 4c344028735e14928e0fc2cd2d7921c9b559d87e..a823749d4fb81e39c84ecee38c606647f81ebea5 100644 (file)
@@ -47,6 +47,24 @@ void HeroTag::Render(SDL_Surface *screen, int width, int height, Point<int> posi
        Vector<int> 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<int> levelLabelOffset(gaugeX, frameOffset.Y());
+       sprites->Draw(screen, position + levelLabelOffset, 0, 0);
+       // hp
+       Vector<int> healthLabelOffset(labelX, 2 * frameOffset.Y());
+       sprites->Draw(screen, position + healthLabelOffset, 0, 1);
+       // mp
+       Vector<int> manaLabelOffset(labelX, 3 * frameOffset.Y());
+       sprites->Draw(screen, position + manaLabelOffset, 0, 2);
+       // cm
+       Vector<int> moveLabelOffset(labelX, 4 * frameOffset.Y());
+       sprites->Draw(screen, position + moveLabelOffset, 0, 3);
+       // ip
+       Vector<int> ikariLabelOffset(labelX + 3 * frameOffset.X(), 4 * frameOffset.Y());
+       sprites->Draw(screen, position + ikariLabelOffset, 0, 4);
+
        // hero
        Vector<int> heroOffset(
                        (align == LEFT) ? yOffset : width - hero->Sprite()->Width() - yOffset,
index b5ab475698b90e14d634fc183fc3e10c2f5727c6..004d3eced8fa11d5b93897964d1a45d6934ee617 100644 (file)
@@ -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;
 
 };
index c3d73cb93ec43b6c2cc1bac78498e58d283a3406..71a4afbd72287ef6934c28af54fc73c0db0c70cd 100644 (file)
@@ -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 (file)
index 0000000..0a3fee9
Binary files /dev/null and b/test-data/hero-tag-sprites.png differ