add basic editor

This commit is contained in:
SweetId
2023-09-23 19:20:41 -04:00
parent d1f132b07e
commit a30e94dee9
13 changed files with 438 additions and 0 deletions

View File

@@ -0,0 +1,9 @@
#pragma once
#include <NazaraEditor/Core/Core.hpp>
#include <NazaraEditor/Core/UI/Window.hpp>
#include <NazaraEditor/Core/Reflection/Math.hpp>
#include <NazaraEditor/Core/Reflection/Core.hpp>
#include <NazaraEditor/Core/Reflection/Utility.hpp>
#include <NazaraEditor/Core/Reflection/Graphics.hpp>
#include <NazaraEditor/Core/Reflection/Editor.hpp>

View File

@@ -0,0 +1,51 @@
#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::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;
};
}

View File

@@ -0,0 +1,16 @@
#include <NazaraEditor/Core/UI/Window.hpp>
namespace Nz
{
class EditorAssetsWindow
: public Nz::EditorWindow
{
public:
EditorAssetsWindow();
void ImportAsset();
protected:
void BuildMenuBar();
};
}

View File

@@ -0,0 +1,21 @@
#include <NazaraEditor/Core/UI/Window.hpp>
#include <entt/entt.hpp>
namespace Nz
{
class EditorInspectorWindow
: public Nz::EditorWindow
{
public:
EditorInspectorWindow();
virtual void OnEditorGUI() override;
protected:
void OnEntitySelected(entt::handle entity);
void OnEntityDeselected(entt::handle);
entt::handle m_currentEntity;
};
}

View File

@@ -0,0 +1,25 @@
#include <NazaraEditor/Core/UI/Window.hpp>
#include <Nazara/Core.hpp>
#include <Nazara/Utility.hpp>
namespace Nz
{
class EditorLevelWindow
: public Nz::EditorWindow
{
public:
EditorLevelWindow();
virtual void OnEditorGUI() override;
protected:
void RefreshEntities();
Nz::EnttWorld* m_currentWorld;
bool m_dirty;
std::vector<Nz::Node*> m_rootNodes;
std::map<Nz::Node*, entt::handle> m_nodeToEntity;
};
}

View File

@@ -0,0 +1,24 @@
#include <NazaraEditor/Core/UI/Window.hpp>
namespace Nz
{
class EditorMainWindow
: public Nz::EditorWindow
{
public:
EditorMainWindow();
bool Quit();
bool NewLevel();
bool OpenLevel();
bool SaveLevel();
bool NewProject();
bool OpenProject();
bool SaveProject();
protected:
void BuildMenuBar();
};
}