App: scene_base tracks whether a scene is currently active

This commit is contained in:
Nikita Lisitsa 2021-03-03 16:18:18 +03:00
parent a7f259352c
commit 692da35066

View file

@ -42,6 +42,9 @@ namespace psemek::app
struct scene_base
: scene
{
void on_scene_enter() override { active_ = true; }
void on_scene_exit() override { active_ = false; }
void on_resize(int width, int height) override { width_ = width; height_ = height; }
void on_mouse_move(int x, int y, int, int) override { mouse_ = geom::point{x, y}; }
@ -54,6 +57,8 @@ namespace psemek::app
void on_key_down(SDL_Keycode key) override { keys_.insert(key); }
void on_key_up(SDL_Keycode key) override { keys_.erase(key); }
bool active() const { return active_; }
bool is_left_button_down() const { return left_button_down_; }
bool is_middle_button_down() const { return middle_button_down_; }
bool is_right_button_down() const { return right_button_down_; }
@ -66,6 +71,8 @@ namespace psemek::app
int height() const { return height_; }
private:
bool active_ = false;
int width_ = 0;
int height_ = 0;