X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fbattle%2Fstates%2FPerformAttacks.cpp;h=a1a5b8b260226a5ad816765b1d14e419417f9582;hb=3f8fac16c7ae2cbe7da47b98aba9b558825723e7;hp=44831791d2c749695cc83716d099178c6f552f67;hpb=9718062e6ed305d9f8f1674ff172079688e78088;p=l2e.git diff --git a/src/battle/states/PerformAttacks.cpp b/src/battle/states/PerformAttacks.cpp index 4483179..a1a5b8b 100644 --- a/src/battle/states/PerformAttacks.cpp +++ b/src/battle/states/PerformAttacks.cpp @@ -15,8 +15,6 @@ #include "../../common/Ikari.h" #include "../../common/Item.h" #include "../../common/Spell.h" -#include "../../geometry/operators.h" -#include "../../geometry/Point.h" #include "../../graphics/Animation.h" #include "../../graphics/Font.h" #include "../../graphics/Frame.h" @@ -25,35 +23,32 @@ using app::Application; using app::Input; -using geometry::Point; using geometry::Vector; using graphics::AnimationRunner; using std::vector; namespace battle { -void PerformAttacks::EnterState(Application &c, SDL_Surface *screen) { - ctrl = &c; +void PerformAttacks::OnEnterState(Application &c, SDL_Surface *screen) { battle->CalculateAttackOrder(); numberAnimation.reserve(battle->MaxMonsters() > battle->NumHeroes() + 1 ? battle->MaxMonsters() : battle->NumHeroes() + 1); numberPosition.reserve(numberAnimation.size()); } -void PerformAttacks::ExitState(Application &c, SDL_Surface *screen) { +void PerformAttacks::OnExitState(Application &c, SDL_Surface *screen) { battle->ClearAllAttacks(); - ctrl = 0; } -void PerformAttacks::ResumeState(Application &ctrl, SDL_Surface *screen) { +void PerformAttacks::OnResumeState(Application &ctrl, SDL_Surface *screen) { } -void PerformAttacks::PauseState(Application &ctrl, SDL_Surface *screen) { +void PerformAttacks::OnPauseState(Application &ctrl, SDL_Surface *screen) { } -void PerformAttacks::Resize(int width, int height) { +void PerformAttacks::OnResize(int width, int height) { } @@ -65,7 +60,7 @@ void PerformAttacks::HandleEvents(const Input &input) { battle->ApplyDamage(); battle->NextAttack(); if (battle->AttacksFinished()) { - ctrl->PopState(); + Ctrl().PopState(); return; } @@ -140,7 +135,7 @@ void PerformAttacks::HandleEvents(const Input &input) { } void PerformAttacks::AddNumberAnimations(const TargetSelection &ts) { - if (ts.TargetsEnemies()) { + if (ts.TargetsMonsters()) { for (int i(0); i < battle->MaxMonsters(); ++i) { if (ts.IsBad(i)) { numberAnimation.push_back(NumberAnimation(ts.GetAmount(i), battle->Res().numberAnimationPrototype, battle->Res().bigNumberSprite)); @@ -231,9 +226,9 @@ void PerformAttacks::RenderTitleBar(SDL_Surface *screen, const Vector &offs if (!titleBarText || !titleBarTimer.Running()) return; int height(battle->Res().titleFrame->BorderHeight() * 2 + battle->Res().titleFont->CharHeight()); - battle->Res().titleFrame->Draw(screen, Point(offset.X(), offset.Y()), battle->Width(), height); + battle->Res().titleFrame->Draw(screen, offset, battle->Width(), height); - Point textPosition( + Vector textPosition( (battle->Width() - (std::strlen(titleBarText) * battle->Res().titleFont->CharWidth())) / 2, battle->Res().titleFrame->BorderHeight()); battle->Res().titleFont->DrawString(titleBarText, screen, textPosition + offset); @@ -252,13 +247,13 @@ void PerformAttacks::RenderTargetAnimation(SDL_Surface *screen, const geometry:: if (!targetAnimation.Valid() || !targetAnimation.Running()) return; const TargetSelection &ts(battle->CurrentAttackAttackChoice().Selection()); if (ts.TargetsHeroes()) { - for (vector >::size_type i(0), end(battle->NumHeroes()); i < end; ++i) { + for (vector >::size_type i(0), end(battle->NumHeroes()); i < end; ++i) { if (ts.IsSelected(i)) { targetAnimation.DrawCenter(screen, battle->HeroAt(i).Position() + offset); } } } else { - for (vector >::size_type i(0), end(battle->MaxMonsters()); i < end; ++i) { + for (vector >::size_type i(0), end(battle->MaxMonsters()); i < end; ++i) { if (ts.IsSelected(i)) { targetAnimation.DrawCenter(screen, battle->MonsterAt(i).Position() + offset); }