fixes audiofiles and adds screentext
This commit is contained in:
parent
47195d9445
commit
c8346ded11
12 changed files with 184 additions and 83 deletions
|
@ -3,36 +3,44 @@
|
|||
#include "context.h"
|
||||
|
||||
StateMachine::StateMachine(State* initialState)
|
||||
: currentState(initialState) {}
|
||||
|
||||
StateMachine::~StateMachine() {
|
||||
delete currentState;
|
||||
}
|
||||
|
||||
void StateMachine::updateState(State* newState, const Context& context) {
|
||||
if (newState != currentState) {
|
||||
delete currentState;
|
||||
currentState = newState;
|
||||
currentState->activated(context);
|
||||
}
|
||||
}
|
||||
|
||||
void StateMachine::pickedUp(const Context& context) {
|
||||
State* newState = currentState->pickedUp(context);
|
||||
updateState(newState, context);
|
||||
}
|
||||
|
||||
void StateMachine::putDown(const Context& context, Station* newStation) {
|
||||
State* newState = currentState->putDown(context, newStation);
|
||||
updateState(newState, context);
|
||||
}
|
||||
|
||||
void StateMachine::update(const Context& context) {
|
||||
State* newState = currentState->update(context);
|
||||
updateState(newState, context);
|
||||
}
|
||||
|
||||
String StateMachine::updateDisplay() const
|
||||
: currentState(initialState)
|
||||
{
|
||||
return currentState->updateDisplay();
|
||||
}
|
||||
|
||||
StateMachine::~StateMachine()
|
||||
{
|
||||
delete currentState;
|
||||
}
|
||||
|
||||
void StateMachine::updateState(State* newState, const Context& context)
|
||||
{
|
||||
if (newState != currentState)
|
||||
{
|
||||
delete currentState;
|
||||
currentState = newState;
|
||||
currentState->activated(context);
|
||||
}
|
||||
}
|
||||
|
||||
void StateMachine::pickedUp(const Context& context)
|
||||
{
|
||||
State* newState = currentState->pickedUp(context);
|
||||
updateState(newState, context);
|
||||
}
|
||||
|
||||
void StateMachine::putDown(const Context& context, Station* newStation)
|
||||
{
|
||||
State* newState = currentState->putDown(context, newStation);
|
||||
updateState(newState, context);
|
||||
}
|
||||
|
||||
void StateMachine::update(const Context& context)
|
||||
{
|
||||
State* newState = currentState->update(context);
|
||||
updateState(newState, context);
|
||||
}
|
||||
|
||||
String StateMachine::updateDisplay(const Context& context) const
|
||||
{
|
||||
return currentState->updateDisplay(context);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue