Add scene stack menu flow and restore stable TFT sync refresh
This commit is contained in:
45
lib/scene_stack.h
Normal file
45
lib/scene_stack.h
Normal file
@@ -0,0 +1,45 @@
|
||||
#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
|
||||
Reference in New Issue
Block a user