Loading...
Searching...
No Matches
AppManager.h
Go to the documentation of this file.
1//
2// Created by Dave R. Smith on 3/5/25.
3//
4
5#ifndef UIMANAGER_H
6#define UIMANAGER_H
7
8#pragma once
9
10#include <SFML/Graphics.hpp>
12#include <Malena/Core/Manager.h>
15#include <string>
16namespace ml
17{
58 class AppManager : public Manager
59 {
60 private:
61 UIController* uiController;
62 sf::RenderWindow* window = nullptr;
63
65 inline static bool _isDrawing = false;
66 inline static std::vector<std::function<void()>> _deferredUnloads;
68
69 public:
77 {
81 };
82
98 AppManager(const sf::VideoMode& videoMode,
99 const std::string& title,
100 UIController& appLogic,
102 Architecture architecture = MVC);
103
115 void run() override;
116
117 virtual ~AppManager() = default;
118
120 static bool isDrawing() { return _isDrawing; }
121 static void deferUnload(std::function<void()> op)
122 {
123 _deferredUnloads.push_back(std::move(op));
124 }
126
127 private:
128 void fireInputEvents(const std::optional<sf::Event>& event) override;
129 void fireUpdateEvents() override;
130 void draw() override;
131 };
132
133} // namespace ml
134
135#endif // UIMANAGER_H
Architecture
Architectural style hint passed at construction.
Definition AppManager.h:77
@ EDA
Event-Driven Architecture.
Definition AppManager.h:79
@ ECS
Entity-Component-System.
Definition AppManager.h:80
@ MVC
Model-View-Controller.
Definition AppManager.h:78
void run() override
Enter the main loop and run until the window is closed.
AppManager(const sf::VideoMode &videoMode, const std::string &title, UIController &appLogic, sf::RenderWindow &window=WindowManager::getWindow(), Architecture architecture=MVC)
Construct an AppManager with an explicit controller and window.
virtual ~AppManager()=default
Abstract base class for all Malena managers.
Definition Manager.h:33
virtual void fireUpdateEvents()=0
Fire the per-frame update event across all subscribers.
virtual void draw()=0
Render the subsystem's visual output to the window.
Concrete Controller base with a per-frame update hook.
sf::RenderWindow & getWindow()
Return the framework's shared sf::RenderWindow.
Definition Component.h:18