X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fbattle%2Fstates%2FSelectTarget.cpp;h=f9507a17024966158efca526d50193961bd2c8b4;hb=087783315ac5955c17bb3b051c9351f321653df6;hp=dc8c1239145f9a7cfbd95828a2c16612eea25e27;hpb=eb2ad5ffd08128d31af32f3929a3295fcfa251e9;p=l2e.git diff --git a/src/battle/states/SelectTarget.cpp b/src/battle/states/SelectTarget.cpp index dc8c123..f9507a1 100644 --- a/src/battle/states/SelectTarget.cpp +++ b/src/battle/states/SelectTarget.cpp @@ -13,6 +13,20 @@ using std::vector; namespace battle { +SelectTarget::SelectTarget( + Battle *battle, + SelectAttackType *parent, + TargetSelection *selection, + const graphics::Sprite *cursorIcon) +: battle(battle) +, parent(parent) +, selection(selection) +, cursorIcon(cursorIcon) +, flipFlop(true) { + +} + + void SelectTarget::OnEnterState(SDL_Surface *screen) { OnResize(screen->w, screen->h); } @@ -31,21 +45,21 @@ void SelectTarget::OnPauseState(SDL_Surface *screen) { void SelectTarget::OnResize(int width, int height) { - Vector offset(battle->ScreenOffset()); + Vector offset(parent->ScreenOffset()); cursorOffset = Vector(cursorIcon->Width() / -2, cursorIcon->Height()) + offset; // offset the indicator by 1/8th to the right and top indicatorOffset = cursorOffset + Vector(cursorIcon->Width() / 8, cursorIcon->Height() / -8); monsterPositions.clear(); - monsterPositions.reserve(battle->MaxMonsters()); - for (int i(0), end(battle->MaxMonsters()); i < end; ++i) { + monsterPositions.reserve(battle->NumMonsters()); + for (int i(0), end(battle->NumMonsters()); i < end; ++i) { monsterPositions.push_back(battle->MonsterAt(i).Position()); } heroPositions.clear(); heroPositions.reserve(battle->NumHeroes()); for (int i(0), end(battle->NumHeroes()); i < end; ++i) { - heroPositions.push_back(battle->HeroTagPositionAt(i) + battle->HeroTagAt(i).HeroOffset()); + heroPositions.push_back(parent->HeroTagPositionAt(i) + parent->HeroTagAt(i).HeroOffset()); } }