From 842c8fb19de8bd00c445bfab759724c3f4f00175 Mon Sep 17 00:00:00 2001 From: illyum Date: Fri, 13 Sep 2024 07:44:55 -0600 Subject: [PATCH] feat(ui): rework renderer to work with deltatime and ui rendering --- src/scene_manager.h | 50 +++++++-------------------------------------- 1 file changed, 7 insertions(+), 43 deletions(-) diff --git a/src/scene_manager.h b/src/scene_manager.h index 5e62982..cf79872 100644 --- a/src/scene_manager.h +++ b/src/scene_manager.h @@ -5,50 +5,14 @@ class SceneManager { public: - SceneManager(entt::registry& registry) : registry(registry), activeScene(entt::null) {} - - void SetActiveScene(entt::entity scene) { - if (activeScene != entt::null) { - auto& currentScene = registry.get(activeScene); - currentScene.isActive = false; - } - - activeScene = scene; - auto& newScene = registry.get(activeScene); - newScene.isActive = true; - } - - entt::entity CreateScene() { - entt::entity scene = registry.create(); - registry.emplace(scene, false); - return scene; - } - - void UpdateActiveScene() { - if (activeScene != entt::null) { - // Iterate over entities in the active scene that have an InputComponent - auto view = registry.view(); - for (auto entity : view) { - auto& inputComponent = view.get(entity); - inputComponent.Update(); // This will call the input logic - } - } - } - - void RenderActiveScene() { - if (activeScene != entt::null) { - // Iterate over entities in the active scene that have both SpriteComponent and TransformComponent - auto view = registry.view(); - for (auto entity : view) { - auto& sprite = view.get(entity); - auto& transform = view.get(entity); - - // Render the sprite at the position defined by the TransformComponent - sprite.Render(transform); - } - } - } + SceneManager(entt::registry& registry); + void SetActiveScene(entt::entity scene); + entt::entity CreateScene(); + void UpdateActiveScene(float delta); + void RenderActiveScene(); + void UpdateUI(entt::registry& registry); + void RenderUI(entt::registry& registry); private: entt::registry& registry;