Add BaseApplication to wrap basic code

This commit is contained in:
SweetId
2023-10-08 22:26:43 -04:00
parent c60ece1670
commit 73e942809b
5 changed files with 187 additions and 0 deletions

View File

@@ -1,6 +1,9 @@
#pragma once
#include <NazaraEditor/Core/Core.hpp>
#include <NazaraEditor/Core/Application/Action.hpp>
#include <NazaraEditor/Core/Application/BaseApplication.hpp>
#include <NazaraEditor/Core/Application/World.hpp>
#include <NazaraEditor/Core/UI/Window.hpp>
#include <NazaraEditor/Core/Reflection/Math.hpp>
#include <NazaraEditor/Core/Reflection/Core.hpp>

View File

@@ -0,0 +1,46 @@
#pragma once
#include <NazaraEditor/Core/Core.hpp>
#include <NazaraEditor/Core/Application/Shortcut.hpp>
#include <Nazara/Renderer.hpp>
#include <string>
namespace Nz
{
class EditorAction
{
public:
struct Properties
{
std::string name;
std::string description;
Nz::Shortcut shortcut;
Nz::Texture* icon;
};
EditorAction(const Properties& properties)
: m_properties(std::make_shared<Properties>(properties))
{}
~EditorAction() = default;
EditorAction(const EditorAction&) = delete;
EditorAction& operator=(const EditorAction&) = delete;
EditorAction(EditorAction&&) = delete;
EditorAction& operator=(EditorAction&&) = delete;
virtual void Execute() = 0;
virtual void Revert() = 0;
virtual EditorAction* Clone() const = 0;
protected:
EditorAction(const std::shared_ptr<Properties>& properties)
: m_properties(properties)
{}
std::shared_ptr<Properties> m_properties;
};
}

View File

@@ -0,0 +1,55 @@
#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/Core.hpp>
#include <NazaraEditor/Core/Application/Action.hpp>
#include <NazaraEditor/Core/UI/Window.hpp>
#include <NazaraImgui/NazaraImgui.hpp>
namespace Nz
{
class NAZARAEDITOR_CORE_API EditorBaseApplication
: 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);
EditorBaseApplication();
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>(this));
}
private:
std::unique_ptr<Nz::WindowSwapchain> m_windowSwapchain;
Nz::EnttWorld* m_world;
std::vector<std::unique_ptr<Nz::EditorWindow>> m_windows;
std::vector<std::unique_ptr<EditorAction>> m_actions;
static EditorBaseApplication* s_instance;
};
}

View File

@@ -0,0 +1,9 @@
#pragma once
namespace Nz
{
struct Shortcut
{
};
}