Handle windows and EnTT with application components
This commit is contained in:
committed by
Jérôme Leclercq
parent
18851c9185
commit
da9eb14ebe
@@ -10,21 +10,33 @@
|
||||
#include <Nazara/Prerequisites.hpp>
|
||||
#include <Nazara/Core/ApplicationComponent.hpp>
|
||||
#include <Nazara/Platform/Config.hpp>
|
||||
#include <Nazara/Platform/Window.hpp>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
class NAZARA_PLATFORM_API AppWindowingComponent : public ApplicationComponent
|
||||
{
|
||||
public:
|
||||
AppWindowingComponent() = default;
|
||||
using ApplicationComponent::ApplicationComponent;
|
||||
AppWindowingComponent(const AppWindowingComponent&) = delete;
|
||||
AppWindowingComponent(AppWindowingComponent&&) = delete;
|
||||
~AppWindowingComponent() = default;
|
||||
|
||||
template<typename... Args> Window& CreateWindow(Args&&... args);
|
||||
|
||||
inline void DisableQuitOnLastWindowClosed();
|
||||
inline void EnableQuitOnLastWindowClosed(bool enable = true);
|
||||
|
||||
inline bool IsQuitOnLastWindowClosedEnabled() const;
|
||||
|
||||
void Update(Time elapsedTime) override;
|
||||
|
||||
AppWindowingComponent& operator=(const AppWindowingComponent&) = delete;
|
||||
AppWindowingComponent& operator=(AppWindowingComponent&&) = delete;
|
||||
|
||||
private:
|
||||
std::vector<std::unique_ptr<Window>> m_windows;
|
||||
bool m_quitOnLastWindowClosed;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -7,6 +7,26 @@
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
template<typename ...Args>
|
||||
Window& AppWindowingComponent::CreateWindow(Args&&... args)
|
||||
{
|
||||
return *m_windows.emplace_back(std::make_unique<Window>(std::forward<Args>(args)...));
|
||||
}
|
||||
|
||||
inline void AppWindowingComponent::DisableQuitOnLastWindowClosed()
|
||||
{
|
||||
return EnableQuitOnLastWindowClosed(false);
|
||||
}
|
||||
|
||||
inline void AppWindowingComponent::EnableQuitOnLastWindowClosed(bool enable)
|
||||
{
|
||||
m_quitOnLastWindowClosed = enable;
|
||||
}
|
||||
|
||||
inline bool AppWindowingComponent::IsQuitOnLastWindowClosedEnabled() const
|
||||
{
|
||||
return m_quitOnLastWindowClosed;
|
||||
}
|
||||
}
|
||||
|
||||
#include <Nazara/Platform/DebugOff.hpp>
|
||||
|
||||
Reference in New Issue
Block a user