Add BaseApplication to wrap basic code
This commit is contained in:
@@ -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>
|
||||
|
||||
46
include/NazaraEditor/Core/Application/Action.hpp
Normal file
46
include/NazaraEditor/Core/Application/Action.hpp
Normal 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;
|
||||
};
|
||||
}
|
||||
55
include/NazaraEditor/Core/Application/BaseApplication.hpp
Normal file
55
include/NazaraEditor/Core/Application/BaseApplication.hpp
Normal 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;
|
||||
};
|
||||
}
|
||||
9
include/NazaraEditor/Core/Application/Shortcut.hpp
Normal file
9
include/NazaraEditor/Core/Application/Shortcut.hpp
Normal file
@@ -0,0 +1,9 @@
|
||||
#pragma once
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
struct Shortcut
|
||||
{
|
||||
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user