remove application code since it migrated in Core
This commit is contained in:
parent
c64e015ce1
commit
1cedfc0419
|
|
@ -1,51 +1,9 @@
|
|||
#pragma once
|
||||
|
||||
#include <Nazara/Core.hpp>
|
||||
#include <Nazara/Graphics.hpp>
|
||||
#include <Nazara/Platform.hpp>
|
||||
#include <Nazara/Renderer.hpp>
|
||||
#include <Nazara/Utility.hpp>
|
||||
|
||||
#include <NazaraEditor/Core.hpp>
|
||||
#include <NazaraImgui/NazaraImgui.hpp>
|
||||
|
||||
namespace Nz
|
||||
class EditorApplication
|
||||
: public Nz::EditorBaseApplication
|
||||
{
|
||||
class EditorApplication
|
||||
: public Nz::Application<Nz::Graphics, Nz::Imgui, Nz::EditorCore>
|
||||
{
|
||||
public:
|
||||
NazaraSignal(OnWorldChanged, Nz::EnttWorld*);
|
||||
|
||||
// Entity lifetime events
|
||||
NazaraSignal(OnEntityCreated, entt::handle);
|
||||
NazaraSignal(OnEntityDestroyed, entt::handle);
|
||||
NazaraSignal(OnEntityParentChanged, entt::handle);
|
||||
|
||||
// Entity selection events
|
||||
NazaraSignal(OnEntitySelected, entt::handle);
|
||||
NazaraSignal(OnEntityDeselected, entt::handle);
|
||||
|
||||
static EditorApplication& Instance();
|
||||
|
||||
void NewWorld();
|
||||
Nz::EnttWorld* GetCurrentWorld();
|
||||
|
||||
entt::handle CreateEntity();
|
||||
|
||||
template<typename T>
|
||||
void RegisterWindow()
|
||||
{
|
||||
static_assert(std::is_base_of<Nz::EditorWindow, T>::value, "Register Window should be called with a subclass of Nz::EditorWindow");
|
||||
m_windows.push_back(std::make_unique<T>());
|
||||
}
|
||||
|
||||
private:
|
||||
EditorApplication();
|
||||
|
||||
std::unique_ptr<Nz::WindowSwapchain> m_windowSwapchain;
|
||||
Nz::EnttWorld* m_world;
|
||||
|
||||
std::vector<std::unique_ptr<Nz::EditorWindow>> m_windows;
|
||||
};
|
||||
}
|
||||
};
|
||||
|
|
@ -1,76 +0,0 @@
|
|||
#include <NazaraEditor/Editor/Application.hpp>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
EditorApplication::EditorApplication()
|
||||
: m_world(nullptr)
|
||||
{
|
||||
auto& windowing = AddComponent<Nz::AppWindowingComponent>();
|
||||
|
||||
std::shared_ptr<Nz::RenderDevice> device = Nz::Graphics::Instance()->GetRenderDevice();
|
||||
|
||||
std::string windowTitle = "Nazara Editor";
|
||||
Nz::Window& window = windowing.CreateWindow(Nz::VideoMode(1280, 720, 32), windowTitle);
|
||||
m_windowSwapchain = std::make_unique<Nz::WindowSwapchain>(device, window);
|
||||
|
||||
// connect basic handler
|
||||
window.GetEventHandler().OnQuit.Connect([&window](const auto* handler) {
|
||||
NazaraUnused(handler);
|
||||
window.Close();
|
||||
});
|
||||
|
||||
AddComponent<Nz::AppEntitySystemComponent>();
|
||||
|
||||
Nz::Imgui::Instance()->Init(window);
|
||||
ImGui::EnsureContextOnThisThread();
|
||||
|
||||
NewWorld();
|
||||
|
||||
AddUpdaterFunc(Interval{ Nz::Time::Milliseconds(16) }, [&](Nz::Time elapsed) {
|
||||
if (!window.IsOpen())
|
||||
return;
|
||||
|
||||
window.ProcessEvents();
|
||||
|
||||
Nz::RenderFrame frame = m_windowSwapchain->AcquireFrame();
|
||||
if (!frame)
|
||||
return;
|
||||
|
||||
Nz::Imgui::Instance()->Update(window, elapsed.AsSeconds());
|
||||
|
||||
Nz::Imgui::Instance()->Render(m_windowSwapchain.get(), frame);
|
||||
|
||||
frame.Present();
|
||||
});
|
||||
}
|
||||
|
||||
EditorApplication& EditorApplication::Instance()
|
||||
{
|
||||
static EditorApplication e;
|
||||
return e;
|
||||
}
|
||||
|
||||
Nz::EnttWorld* EditorApplication::GetCurrentWorld()
|
||||
{
|
||||
return m_world;
|
||||
}
|
||||
|
||||
entt::handle EditorApplication::CreateEntity()
|
||||
{
|
||||
if (m_world == nullptr)
|
||||
return {};
|
||||
|
||||
entt::handle entity = m_world->CreateEntity();
|
||||
entity.emplace<Nz::NodeComponent>();
|
||||
|
||||
OnEntityCreated(entity);
|
||||
OnEntitySelected(entity);
|
||||
return entity;
|
||||
}
|
||||
|
||||
void EditorApplication::NewWorld()
|
||||
{
|
||||
auto& ecs = GetComponent<Nz::AppEntitySystemComponent>();
|
||||
m_world = &ecs.AddWorld<Nz::EnttWorld>();
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue