#ifndef STATE_H #define STATE_H #include #define FIRST 1 #define LAST 2 struct StateManager { // TODO: Reference states by a Table (associative array) // This way we can pass off state handling in a lazier fashion, esp. // switching states or adding states to the state stack int count; // count of states, changed during push/pop operations struct State *first; // linked list of running states. struct State *last; // last state in the linked list/chain struct State *temp; // location to hold states to be pushed onto stack }; struct StateManager *newStateManager(); int freeStateManager(struct StateManager *manager); // closes and frees all States in manager int closeStateManager(struct StateManager *manager); // handleStates is poorly named :S int handleStates(struct StateManager *manager, int order, SDL_Event event); int processStates(struct StateManager *manager, int order); int renderStates(struct StateManager *manager, int order); // ill named int cleanStates(struct StateManager *manager); // eww int pushState(struct StateManager *manager, struct State *peasant); int popState(struct StateManager *manager); int remState(struct State *state); //int unshiftState(struct StateManager *manager, struct State *peasant); //int shiftState(struct StateManager *manager); #define STATE_FREE 1 // free on pop #define STATE_DEFAULT 1 #define STATE_IS_OPEN 1 #define STATE_DO_CLEAR 2 struct State { int flags; int s_flags; int (*doOpen)(); // called on initialize void (*doClose)(); // called on close int (*doInput)(SDL_Event event); // stick with SDL, I guess int (*doProcess)(); // delta? int (*doRender)(); // render delta? // linked list, in effect struct State *next; struct State *prev; }; // :S struct State *newState(int flags, void (*doOpen), void (*doClose), void (*doInput), void (*doProcess), void (*doRender)); int freeState(struct State *state); int openState(struct State *state); int closeState(struct State *state); #endif