Loading...
Searching...
No Matches
AppManager.h
Go to the documentation of this file.
1// Copyright (c) 2025 Dave R. Smith. All rights reserved.
2// Malena Framework — Proprietary Software. See LICENSE for terms.
3
4//
5// Created by Dave R. Smith on 3/5/25.
6//
7
8#ifndef MALENA_APPMANAGER_H
9#define MALENA_APPMANAGER_H
10
11#pragma once
12
16#include <SFML/Graphics.hpp>
17#include <optional>
18#include <string>
19
21namespace ml
22{
71 class MALENA_API AppManager : public Lifecycle, public CoreManager<Core>
72 {
73 private:
74 sf::RenderWindow* window = nullptr;
75
77 inline static bool _isDrawing = false;
78 inline static AppManager* _instance = nullptr;
79 inline static std::vector<std::function<void()>> _deferredUnloads;
81
82 public:
95 AppManager(const sf::VideoMode& videoMode,
96 const std::string& title,
98
110 void run();
111
112 virtual ~AppManager() = default;
113
115 static bool isDrawing() { return _isDrawing; }
116 static void deferUnload(std::function<void()> op)
117 {
118 _deferredUnloads.push_back(std::move(op));
119 }
120
129 static AppManager& get() { return *_instance; }
131
132 private:
133 void fireInputEvents(const std::optional<sf::Event>& event);
134 void fireUpdateEvents();
135 void draw();
136 };
137
138} // namespace ml
139
140#endif // UIMANAGER_H
void run()
Enter the main loop and run until the window is closed.
virtual ~AppManager()=default
AppManager(const sf::VideoMode &videoMode, const std::string &title, sf::RenderWindow &window=WindowManager::getWindow())
Construct an AppManager and create the SFML window.
Static, type-safe collection manager for Core-derived objects.
Definition CoreManager.h:56
Trait that adds one-time initialization lifecycle hooks to any class.
Definition Lifecycle.h:73
sf::RenderWindow & getWindow()
Return the framework's shared sf::RenderWindow.
#define MALENA_API
Definition Component.h:22