Add on_scene_enter & on_scene_exit
This commit is contained in:
parent
29827743f6
commit
e97812dcaf
2 changed files with 9 additions and 1 deletions
|
|
@ -9,6 +9,9 @@ namespace psemek::app
|
||||||
{
|
{
|
||||||
virtual ~scene() = 0;
|
virtual ~scene() = 0;
|
||||||
|
|
||||||
|
virtual void on_scene_enter() {}
|
||||||
|
virtual void on_scene_exit() {}
|
||||||
|
|
||||||
virtual void on_resize(int width, int height) {}
|
virtual void on_resize(int width, int height) {}
|
||||||
virtual void on_focus_gained() {}
|
virtual void on_focus_gained() {}
|
||||||
virtual void on_focus_lost() {}
|
virtual void on_focus_lost() {}
|
||||||
|
|
|
||||||
|
|
@ -198,6 +198,7 @@ namespace psemek::app
|
||||||
void app::run()
|
void app::run()
|
||||||
{
|
{
|
||||||
impl().running = true;
|
impl().running = true;
|
||||||
|
impl().get_scene()->on_scene_enter();
|
||||||
while (running())
|
while (running())
|
||||||
{
|
{
|
||||||
poll_events();
|
poll_events();
|
||||||
|
|
@ -221,9 +222,13 @@ namespace psemek::app
|
||||||
|
|
||||||
scene * app::set_scene(scene * s)
|
scene * app::set_scene(scene * s)
|
||||||
{
|
{
|
||||||
impl().had_initial_resize = false;
|
impl().get_scene()->on_scene_exit();
|
||||||
|
|
||||||
|
impl().had_initial_resize = false;
|
||||||
std::swap(s, impl().current_scene);
|
std::swap(s, impl().current_scene);
|
||||||
|
|
||||||
|
impl().get_scene()->on_scene_enter();
|
||||||
|
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue