Add current work
Former-commit-id: 06dd34f00951e334b330c067f61f69fc73dcc2d2
This commit is contained in:
@@ -3,12 +3,21 @@
|
||||
// For conditions of distribution and use, see copyright notice in Prerequesites.hpp
|
||||
|
||||
#include <Nazara/Core/ErrorFlags.hpp>
|
||||
#include <type_traits>
|
||||
#include <NDK/Sdk.hpp>
|
||||
|
||||
namespace Ndk
|
||||
{
|
||||
inline Application::Application()
|
||||
inline Application::Application() :
|
||||
#ifndef NDK_SERVER
|
||||
m_exitOnClosedWindows(true),
|
||||
#endif
|
||||
m_shouldQuit(false),
|
||||
m_updateTime(0.f)
|
||||
{
|
||||
NazaraAssert(s_application == nullptr, "You can create only one application instance per program");
|
||||
s_application = this;
|
||||
|
||||
Nz::ErrorFlags errFlags(Nz::ErrorFlag_ThrowException, true);
|
||||
|
||||
// Initialisation du SDK
|
||||
@@ -21,5 +30,32 @@ namespace Ndk
|
||||
Sdk::Uninitialize();
|
||||
|
||||
// Libération automatique des modules
|
||||
s_application = nullptr;
|
||||
}
|
||||
|
||||
template<typename T, typename... Args>
|
||||
T& Application::AddWindow(Args&&... args)
|
||||
{
|
||||
static_assert(std::is_base_of<Nz::Window, T>::value, "Type must inherit Window");
|
||||
|
||||
m_windows.emplace_back(new T(std::forward<Args>(args)...));
|
||||
return static_cast<T&>(*m_windows.back().get());
|
||||
}
|
||||
|
||||
template<typename... Args>
|
||||
World& Application::AddWorld(Args&&... args)
|
||||
{
|
||||
m_worlds.emplace_back(std::forward<Args>(args)...);
|
||||
return *m_worlds.back();
|
||||
}
|
||||
|
||||
inline void Application::Quit()
|
||||
{
|
||||
m_shouldQuit = true;
|
||||
}
|
||||
|
||||
inline Application* Application::Instance()
|
||||
{
|
||||
return s_application;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user