void Application::RealChangeState(State *s) {
if (!states.empty()) {
- states.top()->PauseState(*this, screen.Screen());
- states.top()->ExitState(*this, screen.Screen());
+ states.top()->OnPauseState(*this, screen.Screen());
+ states.top()->OnExitState(*this, screen.Screen());
states.pop();
}
states.push(s);
- s->EnterState(*this, screen.Screen());
- s->ResumeState(*this, screen.Screen());
+ s->OnEnterState(*this, screen.Screen());
+ s->OnResumeState(*this, screen.Screen());
}
void Application::RealPushState(State *s) {
if (!states.empty()) {
- states.top()->PauseState(*this, screen.Screen());
+ states.top()->OnPauseState(*this, screen.Screen());
}
states.push(s);
- s->EnterState(*this, screen.Screen());
- s->ResumeState(*this, screen.Screen());
+ s->OnEnterState(*this, screen.Screen());
+ s->OnResumeState(*this, screen.Screen());
}
void Application::RealPopState() {
if (states.empty()) return;
- states.top()->PauseState(*this, screen.Screen());
- states.top()->ExitState(*this, screen.Screen());
+ states.top()->OnPauseState(*this, screen.Screen());
+ states.top()->OnExitState(*this, screen.Screen());
delete states.top();
states.pop();
if (!states.empty()) {
- states.top()->ResumeState(*this, screen.Screen());
+ states.top()->OnResumeState(*this, screen.Screen());
}
}
void Application::PopAllStates() {
while (!states.empty()) {
- states.top()->PauseState(*this, screen.Screen());
- states.top()->ExitState(*this, screen.Screen());
+ states.top()->OnPauseState(*this, screen.Screen());
+ states.top()->OnExitState(*this, screen.Screen());
delete states.top();
states.pop();
}
/// can not be done by the constructor.
/// Called when the state first enters the stack.
/// @param ctrl the Application running the state
- virtual void EnterState(Application &ctrl, SDL_Surface *screen) = 0;
+ virtual void OnEnterState(Application &ctrl, SDL_Surface *screen) = 0;
/// Do some cleanup.
/// Called when the state is popped from the stack.
- virtual void ExitState(Application &ctrl, SDL_Surface *screen) = 0;
+ virtual void OnExitState(Application &ctrl, SDL_Surface *screen) = 0;
/// Called when the state becomes the active one.
- virtual void ResumeState(Application &ctrl, SDL_Surface *screen) = 0;
+ virtual void OnResumeState(Application &ctrl, SDL_Surface *screen) = 0;
/// Called when the state becomes inactive.
- virtual void PauseState(Application &ctrl, SDL_Surface *screen) = 0;
+ virtual void OnPauseState(Application &ctrl, 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::EnterState(Application &ctrl, SDL_Surface *screen) {
+void BattleState::OnEnterState(Application &ctrl, 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::ExitState(Application &ctrl, SDL_Surface *screen) {
+void BattleState::OnExitState(Application &ctrl, SDL_Surface *screen) {
}
-void BattleState::ResumeState(Application &ctrl, SDL_Surface *screen) {
+void BattleState::OnResumeState(Application &ctrl, SDL_Surface *screen) {
if (ranAway) {
ctrl.PopState(); // quit the battle scene
return;
return true;
}
-void BattleState::PauseState(Application &ctrl, SDL_Surface *screen) {
+void BattleState::OnPauseState(Application &ctrl, SDL_Surface *screen) {
}
void AddHero(const Hero &);
public:
- virtual void EnterState(app::Application &ctrl, SDL_Surface *screen);
- virtual void ExitState(app::Application &ctrl, SDL_Surface *screen);
- virtual void ResumeState(app::Application &ctrl, SDL_Surface *screen);
- virtual void PauseState(app::Application &ctrl, SDL_Surface *screen);
+ 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 Resize(int width, int height);
namespace battle {
-void PerformAttacks::EnterState(Application &c, SDL_Surface *screen) {
+void PerformAttacks::OnEnterState(Application &c, SDL_Surface *screen) {
ctrl = &c;
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) {
}
: ctrl(0), battle(battle), moveAnimation(0), targetAnimation(0), titleBarText(0), cursor(-1) { }
public:
- virtual void EnterState(app::Application &ctrl, SDL_Surface *screen);
- virtual void ExitState(app::Application &ctrl, SDL_Surface *screen);
- virtual void ResumeState(app::Application &ctrl, SDL_Surface *screen);
- virtual void PauseState(app::Application &ctrl, SDL_Surface *screen);
+ 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 Resize(int width, int height);
namespace battle {
-void RunState::EnterState(Application &c, SDL_Surface *screen) {
+void RunState::OnEnterState(Application &c, SDL_Surface *screen) {
ctrl = &c;
}
-void RunState::ExitState(Application &c, SDL_Surface *screen) {
+void RunState::OnExitState(Application &c, SDL_Surface *screen) {
ctrl = 0;
}
-void RunState::ResumeState(Application &ctrl, SDL_Surface *screen) {
+void RunState::OnResumeState(Application &ctrl, SDL_Surface *screen) {
timer = GraphicsTimers().StartCountdown(2500);
}
-void RunState::PauseState(Application &ctrl, SDL_Surface *screen) {
+void RunState::OnPauseState(Application &ctrl, SDL_Surface *screen) {
}
: ctrl(0), battle(battle){ }
public:
- virtual void EnterState(app::Application &ctrl, SDL_Surface *screen);
- virtual void ExitState(app::Application &ctrl, SDL_Surface *screen);
- virtual void ResumeState(app::Application &ctrl, SDL_Surface *screen);
- virtual void PauseState(app::Application &ctrl, SDL_Surface *screen);
+ 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 Resize(int width, int height);
namespace battle {
-void SelectAttackType::EnterState(Application &c, SDL_Surface *screen) {
+void SelectAttackType::OnEnterState(Application &c, SDL_Surface *screen) {
ctrl = &c;
}
-void SelectAttackType::ExitState(Application &c, SDL_Surface *screen) {
+void SelectAttackType::OnExitState(Application &c, SDL_Surface *screen) {
ctrl = 0;
}
-void SelectAttackType::ResumeState(Application &ctrl, SDL_Surface *screen) {
+void SelectAttackType::OnResumeState(Application &ctrl, SDL_Surface *screen) {
if (battle->ActiveHero().GetAttackChoice().Selection().HasSelected()) {
battle->ActiveHero().GetAttackChoice().SetType(battle->GetAttackTypeMenu().Selected());
battle->NextHero();
}
}
-void SelectAttackType::PauseState(Application &ctrl, SDL_Surface *screen) {
+void SelectAttackType::OnPauseState(Application &ctrl, SDL_Surface *screen) {
}
: ctrl(0), battle(battle) { }
public:
- virtual void EnterState(app::Application &ctrl, SDL_Surface *screen);
- virtual void ExitState(app::Application &ctrl, SDL_Surface *screen);
- virtual void ResumeState(app::Application &ctrl, SDL_Surface *screen);
- virtual void PauseState(app::Application &ctrl, SDL_Surface *screen);
+ 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 Resize(int width, int height);
namespace battle {
-void SelectIkari::EnterState(Application &c, SDL_Surface *screen) {
+void SelectIkari::OnEnterState(Application &c, SDL_Surface *screen) {
ctrl = &c;
}
-void SelectIkari::ExitState(Application &c, SDL_Surface *screen) {
+void SelectIkari::OnExitState(Application &c, SDL_Surface *screen) {
ctrl = 0;
}
-void SelectIkari::ResumeState(Application &ctrl, SDL_Surface *screen) {
+void SelectIkari::OnResumeState(Application &ctrl, SDL_Surface *screen) {
if (battle->ActiveHero().GetAttackChoice().Selection().HasSelected()) {
battle->ActiveHero().GetAttackChoice().SetType(AttackChoice::IKARI);
battle->ActiveHero().GetAttackChoice().SetItem(battle->ActiveHero().IkariMenu().Selected());
}
}
-void SelectIkari::PauseState(Application &ctrl, SDL_Surface *screen) {
+void SelectIkari::OnPauseState(Application &ctrl, SDL_Surface *screen) {
}
: ctrl(0), battle(battle), parent(parent) { }
public:
- virtual void EnterState(app::Application &ctrl, SDL_Surface *screen);
- virtual void ExitState(app::Application &ctrl, SDL_Surface *screen);
- virtual void ResumeState(app::Application &ctrl, SDL_Surface *screen);
- virtual void PauseState(app::Application &ctrl, SDL_Surface *screen);
+ 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 Resize(int width, int height);
namespace battle {
-void SelectItem::EnterState(Application &c, SDL_Surface *screen) {
+void SelectItem::OnEnterState(Application &c, SDL_Surface *screen) {
ctrl = &c;
}
-void SelectItem::ExitState(Application &c, SDL_Surface *screen) {
+void SelectItem::OnExitState(Application &c, SDL_Surface *screen) {
ctrl = 0;
}
-void SelectItem::ResumeState(Application &ctrl, SDL_Surface *screen) {
+void SelectItem::OnResumeState(Application &ctrl, SDL_Surface *screen) {
if (battle->ActiveHero().GetAttackChoice().Selection().HasSelected()) {
battle->ActiveHero().GetAttackChoice().SetType(AttackChoice::ITEM);
battle->ActiveHero().GetAttackChoice().SetItem(battle->ItemMenu().Selected());
}
}
-void SelectItem::PauseState(Application &ctrl, SDL_Surface *screen) {
+void SelectItem::OnPauseState(Application &ctrl, SDL_Surface *screen) {
}
: ctrl(0), battle(battle), parent(parent) { }
public:
- virtual void EnterState(app::Application &ctrl, SDL_Surface *screen);
- virtual void ExitState(app::Application &ctrl, SDL_Surface *screen);
- virtual void ResumeState(app::Application &ctrl, SDL_Surface *screen);
- virtual void PauseState(app::Application &ctrl, SDL_Surface *screen);
+ 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 Resize(int width, int height);
namespace battle {
-void SelectMoveAction::EnterState(Application &c, SDL_Surface *screen) {
+void SelectMoveAction::OnEnterState(Application &c, SDL_Surface *screen) {
ctrl = &c;
}
-void SelectMoveAction::ExitState(Application &c, SDL_Surface *screen) {
+void SelectMoveAction::OnExitState(Application &c, SDL_Surface *screen) {
ctrl = 0;
}
-void SelectMoveAction::ResumeState(Application &ctrl, SDL_Surface *screen) {
+void SelectMoveAction::OnResumeState(Application &ctrl, SDL_Surface *screen) {
}
-void SelectMoveAction::PauseState(Application &ctrl, SDL_Surface *screen) {
+void SelectMoveAction::OnPauseState(Application &ctrl, SDL_Surface *screen) {
}
: ctrl(0), battle(battle) { }
public:
- virtual void EnterState(app::Application &ctrl, SDL_Surface *screen);
- virtual void ExitState(app::Application &ctrl, SDL_Surface *screen);
- virtual void ResumeState(app::Application &ctrl, SDL_Surface *screen);
- virtual void PauseState(app::Application &ctrl, SDL_Surface *screen);
+ 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 Resize(int width, int height);
namespace battle {
-void SelectSpell::EnterState(Application &c, SDL_Surface *screen) {
+void SelectSpell::OnEnterState(Application &c, SDL_Surface *screen) {
ctrl = &c;
}
-void SelectSpell::ExitState(Application &c, SDL_Surface *screen) {
+void SelectSpell::OnExitState(Application &c, SDL_Surface *screen) {
ctrl = 0;
}
-void SelectSpell::ResumeState(Application &ctrl, SDL_Surface *screen) {
+void SelectSpell::OnResumeState(Application &ctrl, SDL_Surface *screen) {
if (battle->ActiveHero().GetAttackChoice().Selection().HasSelected()) {
battle->ActiveHero().GetAttackChoice().SetType(AttackChoice::MAGIC);
battle->ActiveHero().GetAttackChoice().SetSpell(battle->ActiveHero().SpellMenu().Selected());
}
}
-void SelectSpell::PauseState(Application &ctrl, SDL_Surface *screen) {
+void SelectSpell::OnPauseState(Application &ctrl, SDL_Surface *screen) {
}
: ctrl(0), battle(battle), parent(parent) { }
public:
- virtual void EnterState(app::Application &ctrl, SDL_Surface *screen);
- virtual void ExitState(app::Application &ctrl, SDL_Surface *screen);
- virtual void ResumeState(app::Application &ctrl, SDL_Surface *screen);
- virtual void PauseState(app::Application &ctrl, SDL_Surface *screen);
+ 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 Resize(int width, int height);
namespace battle {
-void SelectTarget::EnterState(Application &c, SDL_Surface *screen) {
+void SelectTarget::OnEnterState(Application &c, SDL_Surface *screen) {
ctrl = &c;
}
-void SelectTarget::ExitState(Application &c, SDL_Surface *screen) {
+void SelectTarget::OnExitState(Application &c, SDL_Surface *screen) {
ctrl = 0;
}
-void SelectTarget::ResumeState(Application &ctrl, SDL_Surface *screen) {
+void SelectTarget::OnResumeState(Application &ctrl, SDL_Surface *screen) {
}
-void SelectTarget::PauseState(Application &ctrl, SDL_Surface *screen) {
+void SelectTarget::OnPauseState(Application &ctrl, SDL_Surface *screen) {
}
: ctrl(0), battle(battle), parent(parent), selection(selection), cursorIcon(cursorIcon), flipFlop(true) { }
public:
- virtual void EnterState(app::Application &ctrl, SDL_Surface *screen);
- virtual void ExitState(app::Application &ctrl, SDL_Surface *screen);
- virtual void ResumeState(app::Application &ctrl, SDL_Surface *screen);
- virtual void PauseState(app::Application &ctrl, SDL_Surface *screen);
+ 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 Resize(int width, int height);
namespace battle {
-void SwapHeroes::EnterState(Application &c, SDL_Surface *screen) {
+void SwapHeroes::OnEnterState(Application &c, SDL_Surface *screen) {
ctrl = &c;
}
-void SwapHeroes::ExitState(Application &c, SDL_Surface *screen) {
+void SwapHeroes::OnExitState(Application &c, SDL_Surface *screen) {
ctrl = 0;
}
-void SwapHeroes::ResumeState(Application &ctrl, SDL_Surface *screen) {
+void SwapHeroes::OnResumeState(Application &ctrl, SDL_Surface *screen) {
}
-void SwapHeroes::PauseState(Application &ctrl, SDL_Surface *screen) {
+void SwapHeroes::OnPauseState(Application &ctrl, SDL_Surface *screen) {
}
: ctrl(0), battle(battle), parent(parent), cursor(0), selected(-1), flipFlop(true) { }
public:
- virtual void EnterState(app::Application &ctrl, SDL_Surface *screen);
- virtual void ExitState(app::Application &ctrl, SDL_Surface *screen);
- virtual void ResumeState(app::Application &ctrl, SDL_Surface *screen);
- virtual void PauseState(app::Application &ctrl, SDL_Surface *screen);
+ 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 Resize(int width, int height);
}
-void ColorFade::EnterState(Application &c, SDL_Surface *screen) {
+void ColorFade::OnEnterState(Application &c, SDL_Surface *screen) {
ctrl = &c;
if (leadIn > 0) {
timer = GraphicsTimers().StartCountdown(leadIn);
}
}
-void ColorFade::ExitState(Application &, SDL_Surface *screen) {
+void ColorFade::OnExitState(Application &, SDL_Surface *screen) {
if (blinds) {
SDL_FreeSurface(blinds);
blinds = 0;
}
}
-void ColorFade::ResumeState(Application &ctrl, SDL_Surface *screen) {
+void ColorFade::OnResumeState(Application &ctrl, SDL_Surface *screen) {
UpdateBlinds(screen->w, screen->h);
}
-void ColorFade::PauseState(Application &ctrl, SDL_Surface *screen) {
+void ColorFade::OnPauseState(Application &ctrl, SDL_Surface *screen) {
}
void SetLeadOutTime(int ms) { leadOut = ms; }
public:
- virtual void EnterState(app::Application &ctrl, SDL_Surface *screen);
- virtual void ExitState(app::Application &ctrl, SDL_Surface *screen);
- virtual void ResumeState(app::Application &ctrl, SDL_Surface *screen);
- virtual void PauseState(app::Application &ctrl, SDL_Surface *screen);
+ 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 Resize(int width, int height);
}
-void MapState::EnterState(Application &c, SDL_Surface *screen) {
+void MapState::OnEnterState(Application &c, SDL_Surface *screen) {
ctrl = &c;
camera.Resize(screen->w, screen->h);
LoadMap(map);
}
-void MapState::ExitState(Application &ctrl, SDL_Surface *screen) {
+void MapState::OnExitState(Application &ctrl, SDL_Surface *screen) {
}
-void MapState::ResumeState(Application &ctrl, SDL_Surface *screen) {
+void MapState::OnResumeState(Application &ctrl, SDL_Surface *screen) {
camera.Resize(screen->w, screen->h);
}
-void MapState::PauseState(Application &ctrl, SDL_Surface *screen) {
+void MapState::OnPauseState(Application &ctrl, SDL_Surface *screen) {
}
virtual ~MapState() { }
public:
- virtual void EnterState(app::Application &ctrl, SDL_Surface *screen);
- virtual void ExitState(app::Application &ctrl, SDL_Surface *screen);
- virtual void ResumeState(app::Application &ctrl, SDL_Surface *screen);
- virtual void PauseState(app::Application &ctrl, SDL_Surface *screen);
+ 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 Resize(int width, int height);
virtual void HandleEvents(const app::Input &);
}
-void TransitionState::EnterState(Application &c, SDL_Surface *screen) {
+void TransitionState::OnEnterState(Application &c, SDL_Surface *screen) {
ctrl = &c;
}
-void TransitionState::ExitState(Application &, SDL_Surface *screen) {
+void TransitionState::OnExitState(Application &, SDL_Surface *screen) {
}
-void TransitionState::ResumeState(Application &ctrl, SDL_Surface *screen) {
+void TransitionState::OnResumeState(Application &ctrl, SDL_Surface *screen) {
}
-void TransitionState::PauseState(Application &ctrl, SDL_Surface *screen) {
+void TransitionState::OnPauseState(Application &ctrl, SDL_Surface *screen) {
}
virtual ~TransitionState() { }
public:
- virtual void EnterState(app::Application &ctrl, SDL_Surface *screen);
- virtual void ExitState(app::Application &ctrl, SDL_Surface *screen);
- virtual void ResumeState(app::Application &ctrl, SDL_Surface *screen);
- virtual void PauseState(app::Application &ctrl, SDL_Surface *screen);
+ 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 Resize(int width, int height);