Gamedev Framework (gf)  0.14.0
A C++14 framework for 2D games
SceneManager.h
1 /*
2  * Gamedev Framework (gf)
3  * Copyright (C) 2016-2019 Julien Bernard
4  *
5  * This software is provided 'as-is', without any express or implied
6  * warranty. In no event will the authors be held liable for any damages
7  * arising from the use of this software.
8  *
9  * Permission is granted to anyone to use this software for any purpose,
10  * including commercial applications, and to alter it and redistribute it
11  * freely, subject to the following restrictions:
12  *
13  * 1. The origin of this software must not be misrepresented; you must not
14  * claim that you wrote the original software. If you use this software
15  * in a product, an acknowledgment in the product documentation would be
16  * appreciated but is not required.
17  * 2. Altered source versions must be plainly marked as such, and must not be
18  * misrepresented as being the original software.
19  * 3. This notice may not be removed or altered from any source distribution.
20  */
21 #ifndef GF_SCENE_MANAGER_H
22 #define GF_SCENE_MANAGER_H
23 
24 #include <vector>
25 
26 #include "Portability.h"
27 #include "Ref.h"
28 #include "RenderWindow.h"
29 #include "Scene.h"
30 #include "Window.h"
31 
32 namespace gf {
33 #ifndef DOXYGEN_SHOULD_SKIP_THIS
34 inline namespace v1 {
35 #endif
36 
51  class GF_API SceneManager {
52  public:
59  SceneManager(StringRef title, Vector2i size);
60 
64  void run();
65 
71  void pushScene(Scene& scene);
72 
76  void popScene();
77 
85  void replaceScene(Scene& scene) {
86  popScene();
87  pushScene(scene);
88  }
89 
93  const RenderTarget& getRenderer() const {
94  return m_renderer;
95  }
96 
97  private:
98  Window m_window;
99  RenderWindow m_renderer;
100  std::vector<Ref<Scene>> m_scenes;
101  };
102 
103 #ifndef DOXYGEN_SHOULD_SKIP_THIS
104 }
105 #endif
106 }
107 
108 
109 #endif // GF_SCENE_MANAGER_H
Base class for all render targets (window, texture, ...)
Definition: RenderTarget.h:73
void replaceScene(Scene &scene)
Replace the top scene with a new scene.
Definition: SceneManager.h:85
A scene manager.
Definition: SceneManager.h:51
The namespace for gf classes.
Definition: Action.h:35
A window that can serve as a target for 2D drawing.
Definition: RenderWindow.h:80
An OS window.
Definition: Window.h:88
A constant reference to a string and its size.
Definition: StringRef.h:41
A scene in the game.
Definition: Scene.h:65
const RenderTarget & getRenderer() const
Get the renderer associated to the scene.
Definition: SceneManager.h:93