Adding Level to handle entt world

This commit is contained in:
SweetId
2023-10-11 20:28:28 -04:00
parent 30fcb71332
commit 5b4ae459ad
6 changed files with 73 additions and 23 deletions

View File

@@ -3,7 +3,7 @@
#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/Application/Level.hpp>
#include <NazaraEditor/Core/UI/Window.hpp>
#include <NazaraEditor/Core/Reflection/Math.hpp>
#include <NazaraEditor/Core/Reflection/Core.hpp>

View File

@@ -8,6 +8,7 @@
#include <NazaraEditor/Core/Core.hpp>
#include <NazaraEditor/Core/Application/Action.hpp>
#include <NazaraEditor/Core/Application/Level.hpp>
#include <NazaraEditor/Core/UI/Window.hpp>
#include <NazaraImgui/NazaraImgui.hpp>
@@ -17,7 +18,7 @@ namespace Nz
: public Nz::Application<Nz::Graphics, Nz::Imgui, Nz::EditorCore>
{
public:
NazaraSignal(OnWorldChanged, Nz::EnttWorld*);
NazaraSignal(OnWorldChanged, Nz::Level&);
// Entity lifetime events
NazaraSignal(OnEntityCreated, entt::handle);
@@ -30,8 +31,10 @@ namespace Nz
EditorBaseApplication();
void NewWorld();
Nz::EnttWorld* GetCurrentWorld();
Nz::Level& GetLevel();
bool NewLevel();
bool CloseLevel();
bool OpenLevel(const std::filesystem::path& path);
entt::handle CreateEntity();
@@ -44,12 +47,10 @@ namespace Nz
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;
Nz::Level m_level;
};
}

View File

@@ -0,0 +1,32 @@
#pragma once
#include <NazaraEditor/Core/Config.hpp>
#include <Nazara/Core/EnttWorld.hpp>
namespace Nz
{
class EditorBaseApplication;
class NAZARAEDITOR_CORE_API Level final
{
public:
Level(EditorBaseApplication* app);
inline bool IsValid() const { return m_world != nullptr; }
inline Nz::EnttWorld* GetEnttWorld() { return m_world; }
inline const Nz::EnttWorld* GetEnttWorld() const { return m_world; }
entt::handle CreateEntity();
bool CreateNewLevel();
protected:
EditorBaseApplication* m_application;
Nz::EnttWorld* m_world;
std::filesystem::path m_path;
std::string m_name;
};
}