void Application::RealChangeState(State *s) {
if (!states.empty()) {
- states.top()->PauseState(*this, screen.Screen());
+ states.top()->PauseState(screen.Screen());
states.top()->ExitState(*this, screen.Screen());
states.pop();
}
states.push(s);
s->EnterState(*this, screen.Screen());
- s->ResumeState(*this, screen.Screen());
+ s->ResumeState(screen.Screen());
}
void Application::RealPushState(State *s) {
if (!states.empty()) {
- states.top()->PauseState(*this, screen.Screen());
+ states.top()->PauseState(screen.Screen());
}
states.push(s);
s->EnterState(*this, screen.Screen());
- s->ResumeState(*this, screen.Screen());
+ s->ResumeState(screen.Screen());
}
void Application::RealPopState() {
if (states.empty()) return;
- states.top()->PauseState(*this, screen.Screen());
+ states.top()->PauseState(screen.Screen());
states.top()->ExitState(*this, screen.Screen());
delete states.top();
states.pop();
if (!states.empty()) {
- states.top()->ResumeState(*this, screen.Screen());
+ states.top()->ResumeState(screen.Screen());
}
}
void Application::PopAllStates() {
while (!states.empty()) {
- states.top()->PauseState(*this, screen.Screen());
+ states.top()->PauseState(screen.Screen());
states.top()->ExitState(*this, screen.Screen());
delete states.top();
states.pop();
void State::EnterState(Application &c, SDL_Surface *screen) {
ctrl = &c;
- OnEnterState(c, screen);
+ OnEnterState(screen);
}
void State::ExitState(Application &c, SDL_Surface *screen) {
- OnExitState(c, screen);
+ OnExitState(screen);
ctrl = 0;
}
-void State::ResumeState(Application &ctrl, SDL_Surface *screen) {
- OnResumeState(ctrl, screen);
+void State::ResumeState(SDL_Surface *screen) {
+ OnResumeState(screen);
}
-void State::PauseState(Application &ctrl, SDL_Surface *screen) {
- OnPauseState(ctrl, screen);
+void State::PauseState(SDL_Surface *screen) {
+ OnPauseState(screen);
}
void State::Resize(int width, int height) {
/// Called by Application when popping this state.
void ExitState(Application &ctrl, SDL_Surface *screen);
/// Called by Application when this state becomes the top state.
- void ResumeState(Application &ctrl, SDL_Surface *screen);
+ void ResumeState(SDL_Surface *screen);
/// Called by Application when this state no longer is the top state.
- void PauseState(Application &ctrl, SDL_Surface *screen);
+ void PauseState(SDL_Surface *screen);
/// Called by Application on SDL window resize events.
void Resize(int width, int height);
/// can not be done by the constructor.
/// Called when the state first enters the stack.
/// @param ctrl the Application running the state
- virtual void OnEnterState(Application &ctrl, SDL_Surface *screen) = 0;
+ virtual void OnEnterState(SDL_Surface *screen) = 0;
/// Do some cleanup.
/// Called when the state is popped from the stack.
- virtual void OnExitState(Application &ctrl, SDL_Surface *screen) = 0;
+ virtual void OnExitState(SDL_Surface *screen) = 0;
/// Called when the state becomes the active one.
- virtual void OnResumeState(Application &ctrl, SDL_Surface *screen) = 0;
+ virtual void OnResumeState(SDL_Surface *screen) = 0;
/// Called when the state becomes inactive.
- virtual void OnPauseState(Application &ctrl, SDL_Surface *screen) = 0;
+ virtual void OnPauseState(SDL_Surface *screen) = 0;
/// Adapt the state's graphics to given dimensions.
/// NOTE: currently, this is only called for the stack top and not
}
-void BattleState::OnEnterState(Application &ctrl, SDL_Surface *screen) {
+void BattleState::OnEnterState(SDL_Surface *screen) {
for (int i(0); i < 4; ++i) {
heroes[i].Position() = heroesLayout->CalculatePosition(i, background->w, background->h);
heroes[i].SpellMenu() = *res->spellMenuProperties;
ClearAllAttacks();
}
-void BattleState::OnExitState(Application &ctrl, SDL_Surface *screen) {
+void BattleState::OnExitState(SDL_Surface *screen) {
}
-void BattleState::OnResumeState(Application &ctrl, SDL_Surface *screen) {
+void BattleState::OnResumeState(SDL_Surface *screen) {
if (ranAway) {
- ctrl.PopState(); // quit the battle scene
+ Ctrl().PopState(); // quit the battle scene
return;
}
if (Victory()) {
- ctrl.PopState();
+ Ctrl().PopState();
return;
}
if (Defeat()) {
- ctrl.PopState();
+ Ctrl().PopState();
return;
}
// TODO: this should not push a state while quitting
if (AttackSelectionDone()) {
- ctrl.PushState(new PerformAttacks(this));
+ Ctrl().PushState(new PerformAttacks(this));
} else {
- ctrl.PushState(new SelectMoveAction(this));
+ Ctrl().PushState(new SelectMoveAction(this));
}
}
return true;
}
-void BattleState::OnPauseState(Application &ctrl, SDL_Surface *screen) {
+void BattleState::OnPauseState(SDL_Surface *screen) {
}
void RenderSmallHeroTags(SDL_Surface *screen, const geometry::Vector<int> &offset);
private:
- virtual void OnEnterState(app::Application &ctrl, SDL_Surface *screen);
- virtual void OnExitState(app::Application &ctrl, SDL_Surface *screen);
- virtual void OnResumeState(app::Application &ctrl, SDL_Surface *screen);
- virtual void OnPauseState(app::Application &ctrl, SDL_Surface *screen);
+ virtual void OnEnterState(SDL_Surface *screen);
+ virtual void OnExitState(SDL_Surface *screen);
+ virtual void OnResumeState(SDL_Surface *screen);
+ virtual void OnPauseState(SDL_Surface *screen);
virtual void OnResize(int width, int height);
namespace battle {
-void PerformAttacks::OnEnterState(Application &c, SDL_Surface *screen) {
+void PerformAttacks::OnEnterState(SDL_Surface *screen) {
battle->CalculateAttackOrder();
numberAnimation.reserve(battle->MaxMonsters() > battle->NumHeroes() + 1 ? battle->MaxMonsters() : battle->NumHeroes() + 1);
numberPosition.reserve(numberAnimation.size());
}
-void PerformAttacks::OnExitState(Application &c, SDL_Surface *screen) {
+void PerformAttacks::OnExitState(SDL_Surface *screen) {
battle->ClearAllAttacks();
}
-void PerformAttacks::OnResumeState(Application &ctrl, SDL_Surface *screen) {
+void PerformAttacks::OnResumeState(SDL_Surface *screen) {
}
-void PerformAttacks::OnPauseState(Application &ctrl, SDL_Surface *screen) {
+void PerformAttacks::OnPauseState(SDL_Surface *screen) {
}
virtual void Render(SDL_Surface *);
private:
- virtual void OnEnterState(app::Application &ctrl, SDL_Surface *screen);
- virtual void OnExitState(app::Application &ctrl, SDL_Surface *screen);
- virtual void OnResumeState(app::Application &ctrl, SDL_Surface *screen);
- virtual void OnPauseState(app::Application &ctrl, SDL_Surface *screen);
+ virtual void OnEnterState(SDL_Surface *screen);
+ virtual void OnExitState(SDL_Surface *screen);
+ virtual void OnResumeState(SDL_Surface *screen);
+ virtual void OnPauseState(SDL_Surface *screen);
virtual void OnResize(int width, int height);
namespace battle {
-void RunState::OnEnterState(Application &c, SDL_Surface *screen) {
+void RunState::OnEnterState(SDL_Surface *screen) {
}
-void RunState::OnExitState(Application &c, SDL_Surface *screen) {
+void RunState::OnExitState(SDL_Surface *screen) {
}
-void RunState::OnResumeState(Application &ctrl, SDL_Surface *screen) {
+void RunState::OnResumeState(SDL_Surface *screen) {
timer = GraphicsTimers().StartCountdown(2500);
}
-void RunState::OnPauseState(Application &ctrl, SDL_Surface *screen) {
+void RunState::OnPauseState(SDL_Surface *screen) {
}
virtual void Render(SDL_Surface *);
private:
- virtual void OnEnterState(app::Application &ctrl, SDL_Surface *screen);
- virtual void OnExitState(app::Application &ctrl, SDL_Surface *screen);
- virtual void OnResumeState(app::Application &ctrl, SDL_Surface *screen);
- virtual void OnPauseState(app::Application &ctrl, SDL_Surface *screen);
+ virtual void OnEnterState(SDL_Surface *screen);
+ virtual void OnExitState(SDL_Surface *screen);
+ virtual void OnResumeState(SDL_Surface *screen);
+ virtual void OnPauseState(SDL_Surface *screen);
virtual void OnResize(int width, int height);
namespace battle {
-void SelectAttackType::OnEnterState(Application &c, SDL_Surface *screen) {
+void SelectAttackType::OnEnterState(SDL_Surface *screen) {
}
-void SelectAttackType::OnExitState(Application &c, SDL_Surface *screen) {
+void SelectAttackType::OnExitState(SDL_Surface *screen) {
}
-void SelectAttackType::OnResumeState(Application &ctrl, SDL_Surface *screen) {
+void SelectAttackType::OnResumeState(SDL_Surface *screen) {
if (battle->ActiveHero().GetAttackChoice().Selection().HasSelected()) {
battle->ActiveHero().GetAttackChoice().SetType(battle->GetAttackTypeMenu().Selected());
battle->NextHero();
}
if (battle->AttackSelectionDone()) {
// pass through
- ctrl.PopState();
+ Ctrl().PopState();
}
}
-void SelectAttackType::OnPauseState(Application &ctrl, SDL_Surface *screen) {
+void SelectAttackType::OnPauseState(SDL_Surface *screen) {
}
virtual void Render(SDL_Surface *);
private:
- virtual void OnEnterState(app::Application &ctrl, SDL_Surface *screen);
- virtual void OnExitState(app::Application &ctrl, SDL_Surface *screen);
- virtual void OnResumeState(app::Application &ctrl, SDL_Surface *screen);
- virtual void OnPauseState(app::Application &ctrl, SDL_Surface *screen);
+ virtual void OnEnterState(SDL_Surface *screen);
+ virtual void OnExitState(SDL_Surface *screen);
+ virtual void OnResumeState(SDL_Surface *screen);
+ virtual void OnPauseState(SDL_Surface *screen);
virtual void OnResize(int width, int height);
namespace battle {
-void SelectIkari::OnEnterState(Application &c, SDL_Surface *screen) {
+void SelectIkari::OnEnterState(SDL_Surface *screen) {
}
-void SelectIkari::OnExitState(Application &c, SDL_Surface *screen) {
+void SelectIkari::OnExitState(SDL_Surface *screen) {
}
-void SelectIkari::OnResumeState(Application &ctrl, SDL_Surface *screen) {
+void SelectIkari::OnResumeState(SDL_Surface *screen) {
if (battle->ActiveHero().GetAttackChoice().Selection().HasSelected()) {
battle->ActiveHero().GetAttackChoice().SetType(AttackChoice::IKARI);
battle->ActiveHero().GetAttackChoice().SetItem(battle->ActiveHero().IkariMenu().Selected());
- ctrl.PopState();
+ Ctrl().PopState();
}
}
-void SelectIkari::OnPauseState(Application &ctrl, SDL_Surface *screen) {
+void SelectIkari::OnPauseState(SDL_Surface *screen) {
}
virtual void Render(SDL_Surface *);
private:
- virtual void OnEnterState(app::Application &ctrl, SDL_Surface *screen);
- virtual void OnExitState(app::Application &ctrl, SDL_Surface *screen);
- virtual void OnResumeState(app::Application &ctrl, SDL_Surface *screen);
- virtual void OnPauseState(app::Application &ctrl, SDL_Surface *screen);
+ virtual void OnEnterState(SDL_Surface *screen);
+ virtual void OnExitState(SDL_Surface *screen);
+ virtual void OnResumeState(SDL_Surface *screen);
+ virtual void OnPauseState(SDL_Surface *screen);
virtual void OnResize(int width, int height);
namespace battle {
-void SelectItem::OnEnterState(Application &c, SDL_Surface *screen) {
+void SelectItem::OnEnterState(SDL_Surface *screen) {
}
-void SelectItem::OnExitState(Application &c, SDL_Surface *screen) {
+void SelectItem::OnExitState(SDL_Surface *screen) {
}
-void SelectItem::OnResumeState(Application &ctrl, SDL_Surface *screen) {
+void SelectItem::OnResumeState(SDL_Surface *screen) {
if (battle->ActiveHero().GetAttackChoice().Selection().HasSelected()) {
battle->ActiveHero().GetAttackChoice().SetType(AttackChoice::ITEM);
battle->ActiveHero().GetAttackChoice().SetItem(battle->ItemMenu().Selected());
- ctrl.PopState();
+ Ctrl().PopState();
}
}
-void SelectItem::OnPauseState(Application &ctrl, SDL_Surface *screen) {
+void SelectItem::OnPauseState(SDL_Surface *screen) {
}
virtual void Render(SDL_Surface *);
private:
- virtual void OnEnterState(app::Application &ctrl, SDL_Surface *screen);
- virtual void OnExitState(app::Application &ctrl, SDL_Surface *screen);
- virtual void OnResumeState(app::Application &ctrl, SDL_Surface *screen);
- virtual void OnPauseState(app::Application &ctrl, SDL_Surface *screen);
+ virtual void OnEnterState(SDL_Surface *screen);
+ virtual void OnExitState(SDL_Surface *screen);
+ virtual void OnResumeState(SDL_Surface *screen);
+ virtual void OnPauseState(SDL_Surface *screen);
virtual void OnResize(int width, int height);
namespace battle {
-void SelectMoveAction::OnEnterState(Application &c, SDL_Surface *screen) {
+void SelectMoveAction::OnEnterState(SDL_Surface *screen) {
}
-void SelectMoveAction::OnExitState(Application &c, SDL_Surface *screen) {
+void SelectMoveAction::OnExitState(SDL_Surface *screen) {
}
-void SelectMoveAction::OnResumeState(Application &ctrl, SDL_Surface *screen) {
+void SelectMoveAction::OnResumeState(SDL_Surface *screen) {
}
-void SelectMoveAction::OnPauseState(Application &ctrl, SDL_Surface *screen) {
+void SelectMoveAction::OnPauseState(SDL_Surface *screen) {
}
virtual void Render(SDL_Surface *);
private:
- virtual void OnEnterState(app::Application &ctrl, SDL_Surface *screen);
- virtual void OnExitState(app::Application &ctrl, SDL_Surface *screen);
- virtual void OnResumeState(app::Application &ctrl, SDL_Surface *screen);
- virtual void OnPauseState(app::Application &ctrl, SDL_Surface *screen);
+ virtual void OnEnterState(SDL_Surface *screen);
+ virtual void OnExitState(SDL_Surface *screen);
+ virtual void OnResumeState(SDL_Surface *screen);
+ virtual void OnPauseState(SDL_Surface *screen);
virtual void OnResize(int width, int height);
namespace battle {
-void SelectSpell::OnEnterState(Application &c, SDL_Surface *screen) {
+void SelectSpell::OnEnterState(SDL_Surface *screen) {
}
-void SelectSpell::OnExitState(Application &c, SDL_Surface *screen) {
+void SelectSpell::OnExitState(SDL_Surface *screen) {
}
-void SelectSpell::OnResumeState(Application &ctrl, SDL_Surface *screen) {
+void SelectSpell::OnResumeState(SDL_Surface *screen) {
if (battle->ActiveHero().GetAttackChoice().Selection().HasSelected()) {
battle->ActiveHero().GetAttackChoice().SetType(AttackChoice::MAGIC);
battle->ActiveHero().GetAttackChoice().SetSpell(battle->ActiveHero().SpellMenu().Selected());
- ctrl.PopState();
+ Ctrl().PopState();
}
}
-void SelectSpell::OnPauseState(Application &ctrl, SDL_Surface *screen) {
+void SelectSpell::OnPauseState(SDL_Surface *screen) {
}
virtual void Render(SDL_Surface *);
private:
- virtual void OnEnterState(app::Application &ctrl, SDL_Surface *screen);
- virtual void OnExitState(app::Application &ctrl, SDL_Surface *screen);
- virtual void OnResumeState(app::Application &ctrl, SDL_Surface *screen);
- virtual void OnPauseState(app::Application &ctrl, SDL_Surface *screen);
+ virtual void OnEnterState(SDL_Surface *screen);
+ virtual void OnExitState(SDL_Surface *screen);
+ virtual void OnResumeState(SDL_Surface *screen);
+ virtual void OnPauseState(SDL_Surface *screen);
virtual void OnResize(int width, int height);
namespace battle {
-void SelectTarget::OnEnterState(Application &c, SDL_Surface *screen) {
+void SelectTarget::OnEnterState(SDL_Surface *screen) {
}
-void SelectTarget::OnExitState(Application &c, SDL_Surface *screen) {
+void SelectTarget::OnExitState(SDL_Surface *screen) {
}
-void SelectTarget::OnResumeState(Application &ctrl, SDL_Surface *screen) {
+void SelectTarget::OnResumeState(SDL_Surface *screen) {
}
-void SelectTarget::OnPauseState(Application &ctrl, SDL_Surface *screen) {
+void SelectTarget::OnPauseState(SDL_Surface *screen) {
}
virtual void Render(SDL_Surface *);
private:
- virtual void OnEnterState(app::Application &ctrl, SDL_Surface *screen);
- virtual void OnExitState(app::Application &ctrl, SDL_Surface *screen);
- virtual void OnResumeState(app::Application &ctrl, SDL_Surface *screen);
- virtual void OnPauseState(app::Application &ctrl, SDL_Surface *screen);
+ virtual void OnEnterState(SDL_Surface *screen);
+ virtual void OnExitState(SDL_Surface *screen);
+ virtual void OnResumeState(SDL_Surface *screen);
+ virtual void OnPauseState(SDL_Surface *screen);
virtual void OnResize(int width, int height);
namespace battle {
-void SwapHeroes::OnEnterState(Application &c, SDL_Surface *screen) {
+void SwapHeroes::OnEnterState(SDL_Surface *screen) {
}
-void SwapHeroes::OnExitState(Application &c, SDL_Surface *screen) {
+void SwapHeroes::OnExitState(SDL_Surface *screen) {
}
-void SwapHeroes::OnResumeState(Application &ctrl, SDL_Surface *screen) {
+void SwapHeroes::OnResumeState(SDL_Surface *screen) {
}
-void SwapHeroes::OnPauseState(Application &ctrl, SDL_Surface *screen) {
+void SwapHeroes::OnPauseState(SDL_Surface *screen) {
}
virtual void Render(SDL_Surface *);
private:
- virtual void OnEnterState(app::Application &ctrl, SDL_Surface *screen);
- virtual void OnExitState(app::Application &ctrl, SDL_Surface *screen);
- virtual void OnResumeState(app::Application &ctrl, SDL_Surface *screen);
- virtual void OnPauseState(app::Application &ctrl, SDL_Surface *screen);
+ virtual void OnEnterState(SDL_Surface *screen);
+ virtual void OnExitState(SDL_Surface *screen);
+ virtual void OnResumeState(SDL_Surface *screen);
+ virtual void OnPauseState(SDL_Surface *screen);
virtual void OnResize(int width, int height);
}
-void ColorFade::OnEnterState(Application &c, SDL_Surface *screen) {
+void ColorFade::OnEnterState(SDL_Surface *screen) {
if (leadIn > 0) {
timer = GraphicsTimers().StartCountdown(leadIn);
} else {
}
}
-void ColorFade::OnExitState(Application &, SDL_Surface *screen) {
+void ColorFade::OnExitState(SDL_Surface *screen) {
if (blinds) {
SDL_FreeSurface(blinds);
blinds = 0;
}
}
-void ColorFade::OnResumeState(Application &ctrl, SDL_Surface *screen) {
+void ColorFade::OnResumeState(SDL_Surface *screen) {
UpdateBlinds(screen->w, screen->h);
}
-void ColorFade::OnPauseState(Application &ctrl, SDL_Surface *screen) {
+void ColorFade::OnPauseState(SDL_Surface *screen) {
}
virtual void Render(SDL_Surface *);
private:
- virtual void OnEnterState(app::Application &ctrl, SDL_Surface *screen);
- virtual void OnExitState(app::Application &ctrl, SDL_Surface *screen);
- virtual void OnResumeState(app::Application &ctrl, SDL_Surface *screen);
- virtual void OnPauseState(app::Application &ctrl, SDL_Surface *screen);
+ virtual void OnEnterState(SDL_Surface *screen);
+ virtual void OnExitState(SDL_Surface *screen);
+ virtual void OnResumeState(SDL_Surface *screen);
+ virtual void OnPauseState(SDL_Surface *screen);
virtual void OnResize(int width, int height);
}
-void MapState::OnEnterState(Application &c, SDL_Surface *screen) {
+void MapState::OnEnterState(SDL_Surface *screen) {
camera.Resize(screen->w, screen->h);
LoadMap(map);
}
-void MapState::OnExitState(Application &ctrl, SDL_Surface *screen) {
+void MapState::OnExitState(SDL_Surface *screen) {
}
-void MapState::OnResumeState(Application &ctrl, SDL_Surface *screen) {
+void MapState::OnResumeState(SDL_Surface *screen) {
camera.Resize(screen->w, screen->h);
}
-void MapState::OnPauseState(Application &ctrl, SDL_Surface *screen) {
+void MapState::OnPauseState(SDL_Surface *screen) {
}
virtual void HandleSyscall(common::ScriptRunner &);
private:
- virtual void OnEnterState(app::Application &ctrl, SDL_Surface *screen);
- virtual void OnExitState(app::Application &ctrl, SDL_Surface *screen);
- virtual void OnResumeState(app::Application &ctrl, SDL_Surface *screen);
- virtual void OnPauseState(app::Application &ctrl, SDL_Surface *screen);
+ virtual void OnEnterState(SDL_Surface *screen);
+ virtual void OnExitState(SDL_Surface *screen);
+ virtual void OnResumeState(SDL_Surface *screen);
+ virtual void OnPauseState(SDL_Surface *screen);
virtual void OnResize(int width, int height);
}
-void TransitionState::OnEnterState(Application &c, SDL_Surface *screen) {
+void TransitionState::OnEnterState(SDL_Surface *screen) {
}
-void TransitionState::OnExitState(Application &, SDL_Surface *screen) {
+void TransitionState::OnExitState(SDL_Surface *screen) {
}
-void TransitionState::OnResumeState(Application &ctrl, SDL_Surface *screen) {
+void TransitionState::OnResumeState(SDL_Surface *screen) {
}
-void TransitionState::OnPauseState(Application &ctrl, SDL_Surface *screen) {
+void TransitionState::OnPauseState(SDL_Surface *screen) {
}
virtual void Render(SDL_Surface *);
private:
- virtual void OnEnterState(app::Application &ctrl, SDL_Surface *screen);
- virtual void OnExitState(app::Application &ctrl, SDL_Surface *screen);
- virtual void OnResumeState(app::Application &ctrl, SDL_Surface *screen);
- virtual void OnPauseState(app::Application &ctrl, SDL_Surface *screen);
+ virtual void OnEnterState(SDL_Surface *screen);
+ virtual void OnExitState(SDL_Surface *screen);
+ virtual void OnResumeState(SDL_Surface *screen);
+ virtual void OnPauseState(SDL_Surface *screen);
virtual void OnResize(int width, int height);