bit of renaming

This commit is contained in:
SweetId 2023-10-11 20:24:28 -04:00
parent d04860ed4b
commit a15e5e823d
14 changed files with 102 additions and 59 deletions

View File

@ -0,0 +1,17 @@
#pragma once
#include <NazaraEditor/Core/UI/Window.hpp>
namespace Nz
{
class NAZARAEDITOR_CORE_API EditorMainWindow
: public EditorWindow
{
public:
EditorMainWindow(EditorBaseApplication* app, const std::string& name = "");
virtual ~EditorMainWindow() = default;
protected:
virtual void OnRenderImgui() override;
};
}

View File

@ -15,7 +15,7 @@ namespace Nz
{ {
public: public:
EditorWindow(EditorBaseApplication* app, const std::string& name = ""); EditorWindow(EditorBaseApplication* app, const std::string& name = "");
~EditorWindow(); virtual ~EditorWindow();
EditorWindow(const EditorWindow&) = delete; EditorWindow(const EditorWindow&) = delete;
EditorWindow& operator=(const EditorWindow&) = delete; EditorWindow& operator=(const EditorWindow&) = delete;
@ -26,10 +26,13 @@ namespace Nz
void AddMenuSeparator(const std::string& path); void AddMenuSeparator(const std::string& path);
protected: protected:
void DrawMenus();
virtual void OnEditorGUI() {}; virtual void OnEditorGUI() {};
virtual ImGuiWindowFlags GetCustomWindowFlags() const { return ImGuiWindowFlags_None; }
private: private:
void DrawMenus();
EditorBaseApplication* m_application; EditorBaseApplication* m_application;
std::string m_windowName; std::string m_windowName;

View File

@ -2,8 +2,11 @@
#include <NazaraEditor/Core.hpp> #include <NazaraEditor/Core.hpp>
class EditorApplication namespace NzEditor
: public Nz::EditorBaseApplication
{ {
class Application
: public Nz::EditorBaseApplication
{
}; };
}

View File

@ -1,12 +1,12 @@
#include <NazaraEditor/Core/UI/Window.hpp> #include <NazaraEditor/Core/UI/Window.hpp>
namespace Nz namespace NzEditor
{ {
class EditorAssetsWindow class AssetsWindow
: public Nz::EditorWindow : public Nz::EditorWindow
{ {
public: public:
EditorAssetsWindow(EditorBaseApplication* app); AssetsWindow(Nz::EditorBaseApplication* app);
void ImportAsset(); void ImportAsset();

View File

@ -2,13 +2,13 @@
#include <entt/entt.hpp> #include <entt/entt.hpp>
namespace Nz namespace NzEditor
{ {
class EditorInspectorWindow class InspectorWindow
: public Nz::EditorWindow : public Nz::EditorWindow
{ {
public: public:
EditorInspectorWindow(EditorBaseApplication* app); InspectorWindow(Nz::EditorBaseApplication* app);
virtual void OnEditorGUI() override; virtual void OnEditorGUI() override;

View File

@ -1,22 +1,22 @@
#include <NazaraEditor/Core/UI/Window.hpp> #include <NazaraEditor/Core.hpp>
#include <Nazara/Core.hpp> #include <Nazara/Core.hpp>
#include <Nazara/Utility.hpp> #include <Nazara/Utility.hpp>
namespace Nz namespace NzEditor
{ {
class EditorLevelWindow class LevelWindow
: public Nz::EditorWindow : public Nz::EditorWindow
{ {
public: public:
EditorLevelWindow(EditorBaseApplication* app); LevelWindow(Nz::EditorBaseApplication* app);
virtual void OnEditorGUI() override; virtual void OnEditorGUI() override;
protected: protected:
void RefreshEntities(); void RefreshEntities();
Nz::EnttWorld* m_currentWorld; Nz::Level& m_currentLevel;
bool m_dirty; bool m_dirty;
std::vector<Nz::Node*> m_rootNodes; std::vector<Nz::Node*> m_rootNodes;

View File

@ -1,12 +1,12 @@
#include <NazaraEditor/Core/UI/Window.hpp> #include <NazaraEditor/Core/UI/MainWindow.h>
namespace Nz namespace NzEditor
{ {
class EditorMainWindow class MainWindow
: public Nz::EditorWindow : public Nz::EditorMainWindow
{ {
public: public:
EditorMainWindow(EditorBaseApplication* app); MainWindow(Nz::EditorBaseApplication* app);
bool Quit(); bool Quit();

View File

@ -0,0 +1,21 @@
#include <NazaraEditor/Core/UI/MainWindow.h>
namespace Nz
{
EditorMainWindow::EditorMainWindow(EditorBaseApplication* app, const std::string& name)
: EditorWindow(app, name)
{ }
void EditorMainWindow::OnRenderImgui()
{
if (ImGui::BeginMainMenuBar())
{
DrawMenus();
ImGui::EndMainMenuBar();
}
// Create docks everywhere in the main area
ImGui::DockSpaceOverViewport();
}
}

View File

@ -20,10 +20,13 @@ namespace Nz
{ {
bool bNeedsMenu = !m_root.entries.empty(); bool bNeedsMenu = !m_root.entries.empty();
ImGuiWindowFlags flags = (bNeedsMenu ? ImGuiWindowFlags_MenuBar : 0); ImGuiWindowFlags flags = (bNeedsMenu ? ImGuiWindowFlags_MenuBar : 0);
if (ImGui::Begin(m_windowName.c_str(), nullptr, flags)) if (ImGui::Begin(m_windowName.c_str(), nullptr, flags))
{ {
DrawMenus(); if (ImGui::BeginMenuBar())
{
DrawMenus();
ImGui::EndMenuBar();
}
OnEditorGUI(); OnEditorGUI();
@ -80,12 +83,8 @@ namespace Nz
}, menu); }, menu);
}; };
if (ImGui::BeginMenuBar()) for (auto& menu : m_root.entries)
{ visitor(menu);
for (auto& menu : m_root.entries)
visitor(menu);
ImGui::EndMenuBar();
}
} }
EditorWindow::MenuList& EditorWindow::GetOrCreateMenuHierarchy(const std::vector<std::string_view>& hierarchy) EditorWindow::MenuList& EditorWindow::GetOrCreateMenuHierarchy(const std::vector<std::string_view>& hierarchy)

View File

@ -1,19 +1,19 @@
#include <NazaraEditor/Editor/UI/AssetsWindow.hpp> #include <NazaraEditor/Editor/UI/AssetsWindow.hpp>
namespace Nz namespace NzEditor
{ {
EditorAssetsWindow::EditorAssetsWindow(EditorBaseApplication* app) AssetsWindow::AssetsWindow(Nz::EditorBaseApplication* app)
: Nz::EditorWindow(app, "Assets Browser") : Nz::EditorWindow(app, "Assets Browser")
{ {
BuildMenuBar(); BuildMenuBar();
} }
void EditorAssetsWindow::ImportAsset() void AssetsWindow::ImportAsset()
{ {
} }
void EditorAssetsWindow::BuildMenuBar() void AssetsWindow::BuildMenuBar()
{ {
AddMenuAction("Import", "Ctrl+I", [this]() { ImportAsset(); }); AddMenuAction("Import", "Ctrl+I", [this]() { ImportAsset(); });
} }

View File

@ -2,15 +2,15 @@
#include <NazaraEditor/Editor/Application.hpp> #include <NazaraEditor/Editor/Application.hpp>
namespace Nz namespace NzEditor
{ {
EditorInspectorWindow::EditorInspectorWindow(EditorBaseApplication* app) InspectorWindow::InspectorWindow(Nz::EditorBaseApplication* app)
: Nz::EditorWindow(app, "Inspector") : Nz::EditorWindow(app, "Inspector")
{ {
app->OnEntitySelected.Connect(this, &EditorInspectorWindow::OnEntitySelected); app->OnEntitySelected.Connect(this, &InspectorWindow::OnEntitySelected);
} }
void EditorInspectorWindow::OnEditorGUI() void InspectorWindow::OnEditorGUI()
{ {
if (!m_currentEntity) if (!m_currentEntity)
return; return;
@ -20,12 +20,12 @@ namespace Nz
ImGui::End(); ImGui::End();
} }
void EditorInspectorWindow::OnEntitySelected(entt::handle entity) void InspectorWindow::OnEntitySelected(entt::handle entity)
{ {
m_currentEntity = entity; m_currentEntity = entity;
} }
void EditorInspectorWindow::OnEntityDeselected(entt::handle) void InspectorWindow::OnEntityDeselected(entt::handle)
{ {
m_currentEntity = {}; m_currentEntity = {};
} }

View File

@ -2,9 +2,9 @@
#include <NazaraEditor/Editor/Application.hpp> #include <NazaraEditor/Editor/Application.hpp>
namespace Nz namespace NzEditor
{ {
EditorLevelWindow::EditorLevelWindow(EditorBaseApplication* app) LevelWindow::LevelWindow(Nz::EditorBaseApplication* app)
: Nz::EditorWindow(app, "Level") : Nz::EditorWindow(app, "Level")
, m_currentWorld(app->GetCurrentWorld()) , m_currentWorld(app->GetCurrentWorld())
, m_dirty(true) , m_dirty(true)
@ -15,7 +15,7 @@ namespace Nz
app->OnEntityParentChanged.Connect([this](entt::handle) { m_dirty = true; }); app->OnEntityParentChanged.Connect([this](entt::handle) { m_dirty = true; });
} }
void EditorLevelWindow::OnEditorGUI() void LevelWindow::OnEditorGUI()
{ {
RefreshEntities(); RefreshEntities();
@ -32,7 +32,7 @@ namespace Nz
drawHierarchy(node); drawHierarchy(node);
} }
void EditorLevelWindow::RefreshEntities() void LevelWindow::RefreshEntities()
{ {
if (!m_dirty) if (!m_dirty)
return; return;

View File

@ -1,14 +1,14 @@
#include <NazaraEditor/Editor/UI/MainWindow.hpp> #include <NazaraEditor/Editor/UI/MainWindow.hpp>
namespace Nz namespace NzEditor
{ {
EditorMainWindow::EditorMainWindow(EditorBaseApplication* app) MainWindow::MainWindow(Nz::EditorBaseApplication* app)
: Nz::EditorWindow(app, "MainWindow") : Nz::EditorMainWindow(app, "MainWindow")
{ {
BuildMenuBar(); BuildMenuBar();
} }
void EditorMainWindow::BuildMenuBar() void MainWindow::BuildMenuBar()
{ {
AddMenuAction("File|Project|New", "Ctrl+Shift+N", [this]() { NewProject(); }); AddMenuAction("File|Project|New", "Ctrl+Shift+N", [this]() { NewProject(); });
AddMenuAction("File|Project|Open", "Ctrl+Shift+O", [this]() { OpenProject(); }); AddMenuAction("File|Project|Open", "Ctrl+Shift+O", [this]() { OpenProject(); });
@ -20,37 +20,37 @@ namespace Nz
AddMenuAction("File|Quit", "Ctrl+W", [this]() { Quit(); }); AddMenuAction("File|Quit", "Ctrl+W", [this]() { Quit(); });
} }
bool EditorMainWindow::Quit() bool MainWindow::Quit()
{ {
return true; return true;
} }
bool EditorMainWindow::NewLevel() bool MainWindow::NewLevel()
{ {
return true; return true;
} }
bool EditorMainWindow::OpenLevel() bool MainWindow::OpenLevel()
{ {
return true; return true;
} }
bool EditorMainWindow::SaveLevel() bool MainWindow::SaveLevel()
{ {
return true; return true;
} }
bool EditorMainWindow::NewProject() bool MainWindow::NewProject()
{ {
return true; return true;
} }
bool EditorMainWindow::OpenProject() bool MainWindow::OpenProject()
{ {
return true; return true;
} }
bool EditorMainWindow::SaveProject() bool MainWindow::SaveProject()
{ {
return true; return true;
} }

View File

@ -25,14 +25,14 @@ int WinMain(int argc, char* argv[])
NazaraUnused(argc); NazaraUnused(argc);
NazaraUnused(argv); NazaraUnused(argv);
EditorApplication app; NzEditor::Application app;
ImGui::EnsureContextOnThisThread(); ImGui::EnsureContextOnThisThread();
app.RegisterWindow<Nz::EditorMainWindow>(); app.RegisterWindow<NzEditor::MainWindow>();
app.RegisterWindow<Nz::EditorAssetsWindow>(); app.RegisterWindow<NzEditor::AssetsWindow>();
app.RegisterWindow<Nz::EditorLevelWindow>(); app.RegisterWindow<NzEditor::LevelWindow>();
app.RegisterWindow<Nz::EditorInspectorWindow>(); app.RegisterWindow<NzEditor::InspectorWindow>();
entt::meta<Nz::NodeComponent>() entt::meta<Nz::NodeComponent>()
.type(entt::type_hash<Nz::NodeComponent>::value()) .type(entt::type_hash<Nz::NodeComponent>::value())