From: Daniel Karbach Date: Fri, 10 Aug 2012 20:24:03 +0000 (+0200) Subject: moved popping of battle state into battle state X-Git-Url: https://git.localhorst.tv/?a=commitdiff_plain;h=69123d71dacfdd6592c00ead8b92b6441d0f0228;p=l2e.git moved popping of battle state into battle state --- diff --git a/src/battle/BattleState.cpp b/src/battle/BattleState.cpp index b3ad20e..c294e1a 100644 --- a/src/battle/BattleState.cpp +++ b/src/battle/BattleState.cpp @@ -187,7 +187,11 @@ void BattleState::ExitState(Application &ctrl, SDL_Surface *screen) { } void BattleState::ResumeState(Application &ctrl, SDL_Surface *screen) { - // TODO: check for victory, defeat or run + // TODO: check for victory or defeat + if (ranAway) { + ctrl.PopState(); // quit the battle scene + return; + } // reset attack choices activeHero = -1; for (vector::size_type i(0), end(heroes.size()); i < end; ++i) { diff --git a/src/battle/BattleState.h b/src/battle/BattleState.h index e3ecca9..e94ed41 100644 --- a/src/battle/BattleState.h +++ b/src/battle/BattleState.h @@ -51,7 +51,8 @@ public: , res(res) , attackTypeMenu(res->attackIcons) , moveMenu(res->moveIcons) - , activeHero(-1) { } + , activeHero(-1) + , ranAway(false) { } public: void AddMonster(const Monster &); @@ -109,6 +110,8 @@ public: std::vector &Heroes() { return heroes; } const std::vector &Heroes() const { return heroes; } + void SetRunaway() { ranAway = true; } + public: geometry::Vector CalculateScreenOffset(SDL_Surface *screen) const { return geometry::Vector( @@ -147,6 +150,7 @@ private: geometry::Point heroTagPositions[4]; AttackChoice attackChoices[4]; int activeHero; + bool ranAway; }; diff --git a/src/battle/states/RunState.cpp b/src/battle/states/RunState.cpp index 7fdc066..6f4325a 100644 --- a/src/battle/states/RunState.cpp +++ b/src/battle/states/RunState.cpp @@ -49,8 +49,8 @@ void RunState::Resize(int width, int height) { void RunState::HandleEvents(const Input &input) { if (timer.Finished()) { + battle->SetRunaway(); ctrl->PopState(); // pop self - ctrl->PopState(); // pop battle } }