Better scene management.
This commit is contained in:
@@ -4,10 +4,22 @@
|
||||
#include <Engine/GameWindow.h>
|
||||
|
||||
namespace Globals {
|
||||
inline std::vector<Scene*> SceneList{};
|
||||
inline Scene* CurrentScene = nullptr;
|
||||
inline DemoGameWindow* Window = nullptr;
|
||||
|
||||
inline float DeltaTime() { return Window->GetDeltaTime(); }
|
||||
inline void RemoveScene() { delete CurrentScene; CurrentScene = nullptr; }
|
||||
inline void ChangeScene(Scene* scene) { delete CurrentScene; CurrentScene = scene; CurrentScene->Init(); }
|
||||
inline void ChangeScene(Scene* scene) { if (CurrentScene != nullptr) CurrentScene->Unload(); CurrentScene = scene; if (CurrentScene != nullptr) CurrentScene->Init(); }
|
||||
inline bool ChangeScene (const std::string& scene_name)
|
||||
{
|
||||
Scene* scene = nullptr;
|
||||
for (auto* s : SceneList)
|
||||
if (s->GetName() == scene_name)
|
||||
scene = s;
|
||||
|
||||
if (scene)
|
||||
ChangeScene(scene);
|
||||
|
||||
return scene;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user