Files
basic1/lib/scene_stack.h

46 lines
750 B
C++

#ifndef SCENE_STACK_H
#define SCENE_STACK_H
#include <vector>
enum class SceneId {
LAUNCHER = 0,
GAME,
IN_GAME_MENU
};
class SceneStack {
public:
SceneStack() {
stack.push_back(SceneId::LAUNCHER);
}
SceneId current() const {
return stack.empty() ? SceneId::LAUNCHER : stack.back();
}
bool is(SceneId scene) const {
return current() == scene;
}
void push(SceneId scene) {
stack.push_back(scene);
}
void pop() {
if (stack.size() > 1) {
stack.pop_back();
}
}
void clear_to_launcher() {
stack.clear();
stack.push_back(SceneId::LAUNCHER);
}
private:
std::vector<SceneId> stack;
};
#endif // SCENE_STACK_H