Closed soulweaver91 closed 7 years ago
Some drafting for new APIs to implement:
// menus and LevelManager descend from this class
class EngineState {
public:
EngineState(T params);
~EngineState();
// broadcasted to all states; passive states can still draw if necessary
// (for example: have a separate state to deal with the background animations
// on main menu, submenus don't have to care about that)
virtual void drawUpdate();
// broadcast to all states? or just the topmost one? TBD
virtual void handleInput(const QVector<T>& inputs);
// Logic happens here. Should input go here as well?
virtual void tick();
void setActive(bool active);
bool getActive();
private:
bool isStateActive;
}
class CarrotQt5 {
public:
void moveToState(EngineState* state, bool replace, T... params);
// return new top state so that functions on it can be called if necessary
EngineState* exitTopState(T returnValue);
// stack cannot be empty, so a replacement bottom state must be provided
void exitAllStates(EngineState* newRootState);
private:
QStack<EngineState*> states;
}
Rather than having all menu functionality in one class, have each unique screen as its own class and implement the menu system as a stack of those screen classes.
The level manager could potentially also be put on the stack, so a pause menu could work in top of it easily.