From 014e40a268e0e3cbb1ca01ac2ad3e021817e2110 Mon Sep 17 00:00:00 2001 From: SweetId <2630750+SweetId@users.noreply.github.com> Date: Sun, 29 Oct 2023 22:35:40 -0400 Subject: [PATCH] moving actions register to their respective files --- .../Actions/EditorAction_Editor.hpp | 2 + .../Actions/EditorAction_Level.hpp | 2 + .../Application/Actions/EditorAction_Log.hpp | 2 + .../Actions/EditorAction_Editor.cpp | 10 ++++ .../Actions/EditorAction_Level.cpp | 29 ++++++++++ .../Application/Actions/EditorAction_Log.cpp | 14 +++++ src/NazaraEditor/Editor/Application.cpp | 15 ++++++ src/NazaraEditor/Editor/main.cpp | 53 ------------------- 8 files changed, 74 insertions(+), 53 deletions(-) diff --git a/include/NazaraEditor/Core/Application/Actions/EditorAction_Editor.hpp b/include/NazaraEditor/Core/Application/Actions/EditorAction_Editor.hpp index 957e3c7..faa0fb8 100644 --- a/include/NazaraEditor/Core/Application/Actions/EditorAction_Editor.hpp +++ b/include/NazaraEditor/Core/Application/Actions/EditorAction_Editor.hpp @@ -4,6 +4,8 @@ namespace Nz { + NAZARAEDITOR_CORE_API void RegisterEditorActions(class EditorBaseApplication& app); + class NAZARAEDITOR_CORE_API EditorAction_Quit final : public EditorAction { diff --git a/include/NazaraEditor/Core/Application/Actions/EditorAction_Level.hpp b/include/NazaraEditor/Core/Application/Actions/EditorAction_Level.hpp index d7fa881..b0e8bcf 100644 --- a/include/NazaraEditor/Core/Application/Actions/EditorAction_Level.hpp +++ b/include/NazaraEditor/Core/Application/Actions/EditorAction_Level.hpp @@ -4,6 +4,8 @@ namespace Nz { + NAZARAEDITOR_CORE_API void RegisterLevelActions(class EditorBaseApplication& app); + class NAZARAEDITOR_CORE_API EditorAction_Level_New final : public EditorAction { diff --git a/include/NazaraEditor/Core/Application/Actions/EditorAction_Log.hpp b/include/NazaraEditor/Core/Application/Actions/EditorAction_Log.hpp index 30f9dce..2422952 100644 --- a/include/NazaraEditor/Core/Application/Actions/EditorAction_Log.hpp +++ b/include/NazaraEditor/Core/Application/Actions/EditorAction_Log.hpp @@ -4,6 +4,8 @@ namespace Nz { + NAZARAEDITOR_CORE_API void RegisterLogActions(class EditorBaseApplication& app); + class NAZARAEDITOR_CORE_API EditorAction_Log_Clear final : public EditorAction { diff --git a/src/NazaraEditor/Core/Application/Actions/EditorAction_Editor.cpp b/src/NazaraEditor/Core/Application/Actions/EditorAction_Editor.cpp index be2a517..cb9195c 100644 --- a/src/NazaraEditor/Core/Application/Actions/EditorAction_Editor.cpp +++ b/src/NazaraEditor/Core/Application/Actions/EditorAction_Editor.cpp @@ -5,6 +5,16 @@ namespace Nz { + void RegisterEditorActions(EditorBaseApplication& app) + { + app.RegisterAction({ + .description = "LOC_EDITOR_ACTION_QUIT_DESC", + .path = { "LOC_EDITOR_MENU_FILE", "LOC_EDITOR_MENU_QUIT" }, + .category = "General", + .shortcut = Nz::Shortcut::Create(Nz::Keyboard::VKey::F4, false, false, true), + }); + } + void EditorAction_Quit::Execute() { Nz::EditorBaseApplication::Instance()->GetPopupManager().CreatePopup({ diff --git a/src/NazaraEditor/Core/Application/Actions/EditorAction_Level.cpp b/src/NazaraEditor/Core/Application/Actions/EditorAction_Level.cpp index f18068d..852cf4e 100644 --- a/src/NazaraEditor/Core/Application/Actions/EditorAction_Level.cpp +++ b/src/NazaraEditor/Core/Application/Actions/EditorAction_Level.cpp @@ -4,6 +4,35 @@ namespace Nz { + void RegisterLevelActions(EditorBaseApplication& app) + { + Nz::TextureParams texParams; + texParams.renderDevice = Nz::Graphics::Instance()->GetRenderDevice(); + texParams.loadFormat = Nz::PixelFormat::RGBA8_SRGB; + + app.RegisterAction({ + .description = "LOC_EDITOR_ACTION_LEVEL_NEW_DESC", + .path = { "LOC_EDITOR_MENU_FILE", "LOC_EDITOR_MENU_LEVEL", "LOC_EDITOR_MENU_NEW" }, + .category = "General", + .shortcut = Nz::Shortcut::Create(Nz::Keyboard::VKey::N, true, true), + .icon = Nz::Texture::LoadFromFile("assets/editor/icons/file_new.png", texParams) + }); + app.RegisterAction({ + .description = "LOC_EDITOR_ACTION_LEVEL_OPEN_DESC", + .path = { "LOC_EDITOR_MENU_FILE", "LOC_EDITOR_MENU_LEVEL", "LOC_EDITOR_MENU_OPEN" }, + .category = "General", + .shortcut = Nz::Shortcut::Create(Nz::Keyboard::VKey::O, true, true), + .icon = Nz::Texture::LoadFromFile("assets/editor/icons/file_open.png", texParams) + }); + app.RegisterAction({ + .description = "LOC_EDITOR_ACTION_LEVEL_SAVE_DESC", + .path = { "LOC_EDITOR_MENU_FILE", "LOC_EDITOR_MENU_LEVEL", "LOC_EDITOR_MENU_SAVE" }, + .category = "General", + .shortcut = Nz::Shortcut::Create(Nz::Keyboard::VKey::S, true, true), + .icon = Nz::Texture::LoadFromFile("assets/editor/icons/file_save.png", texParams) + }); + } + void EditorAction_Level_New::Execute() { Nz::EditorBaseApplication::Instance()->GetPopupManager().CreatePopup({ diff --git a/src/NazaraEditor/Core/Application/Actions/EditorAction_Log.cpp b/src/NazaraEditor/Core/Application/Actions/EditorAction_Log.cpp index afa3dfd..38e8f7b 100644 --- a/src/NazaraEditor/Core/Application/Actions/EditorAction_Log.cpp +++ b/src/NazaraEditor/Core/Application/Actions/EditorAction_Log.cpp @@ -3,6 +3,20 @@ namespace Nz { + void RegisterLogActions(EditorBaseApplication& app) + { + app.RegisterAction({ + .description = "LOC_EDITOR_ACTION_LOG_CLEAR_DESC", + .path = { "LOC_EDITOR_MENU_LOG_CLEAR" }, + .category = "Output", + }); + app.RegisterAction({ + .description = "LOC_EDITOR_ACTION_LOG_COPY_DESC", + .path = { "LOC_EDITOR_MENU_LOG_COPY" }, + .category = "Output", + }); + } + void EditorAction_Log_Clear::Execute() { Nz::EditorBaseApplication::Instance()->GetLogger().Clear(); diff --git a/src/NazaraEditor/Editor/Application.cpp b/src/NazaraEditor/Editor/Application.cpp index a23c9e0..c10398d 100644 --- a/src/NazaraEditor/Editor/Application.cpp +++ b/src/NazaraEditor/Editor/Application.cpp @@ -1,4 +1,9 @@ #include +#include +#include +#include +#include +#include #include @@ -6,6 +11,16 @@ namespace NzEditor { Application::Application() { + RegisterWindow(); + RegisterWindow(); + RegisterWindow(); + RegisterWindow(); + RegisterWindow(); + + Nz::RegisterLevelActions(*this); + Nz::RegisterEditorActions(*this); + Nz::RegisterLogActions(*this); + Nz::Localization::OnLocaleInstalled.Connect([this](std::string_view locale) { RegisterAction({ .className = std::format("{}_{}", Nz::EditorAction_SetLocale::GetClassName(), locale), diff --git a/src/NazaraEditor/Editor/main.cpp b/src/NazaraEditor/Editor/main.cpp index e35d11a..d690ee0 100644 --- a/src/NazaraEditor/Editor/main.cpp +++ b/src/NazaraEditor/Editor/main.cpp @@ -9,11 +9,6 @@ #include #include -#include -#include -#include -#include -#include NAZARA_REQUEST_DEDICATED_GPU() @@ -38,57 +33,9 @@ int WinMain(int argc, char* argv[]) ImGui::EnsureContextOnThisThread(); - app.RegisterWindow(); - app.RegisterWindow(); - app.RegisterWindow(); - app.RegisterWindow(); - app.RegisterWindow(); - Nz::Localization::Instance()->LoadLocalizationFile(resourceDir / "localization.csv"); Nz::Localization::Instance()->SetLocale("en-US"); - Nz::TextureParams texParams; - texParams.renderDevice = Nz::Graphics::Instance()->GetRenderDevice(); - texParams.loadFormat = Nz::PixelFormat::RGBA8_SRGB; - - app.RegisterAction({ - .description = "LOC_EDITOR_ACTION_LEVEL_NEW_DESC", - .path = { "LOC_EDITOR_MENU_FILE", "LOC_EDITOR_MENU_LEVEL", "LOC_EDITOR_MENU_NEW" }, - .category = "General", - .shortcut = Nz::Shortcut::Create(Nz::Keyboard::VKey::N, true, true), - .icon = Nz::Texture::LoadFromFile(app.GetResourceFolder() / "icons" / "file_new.png", texParams) - }); - app.RegisterAction({ - .description = "LOC_EDITOR_ACTION_LEVEL_OPEN_DESC", - .path = { "LOC_EDITOR_MENU_FILE", "LOC_EDITOR_MENU_LEVEL", "LOC_EDITOR_MENU_OPEN" }, - .category = "General", - .shortcut = Nz::Shortcut::Create(Nz::Keyboard::VKey::O, true, true), - .icon = Nz::Texture::LoadFromFile(app.GetResourceFolder() / "icons" / "file_open.png", texParams) - }); - app.RegisterAction({ - .description = "LOC_EDITOR_ACTION_LEVEL_SAVE_DESC", - .path = { "LOC_EDITOR_MENU_FILE", "LOC_EDITOR_MENU_LEVEL", "LOC_EDITOR_MENU_SAVE" }, - .category = "General", - .shortcut = Nz::Shortcut::Create(Nz::Keyboard::VKey::S, true, true), - .icon = Nz::Texture::LoadFromFile(app.GetResourceFolder() / "icons" / "file_save.png", texParams) - }); - app.RegisterAction({ - .description = "LOC_EDITOR_ACTION_LOG_CLEAR_DESC", - .path = { "LOC_EDITOR_MENU_LOG_CLEAR" }, - .category = "Output", - }); - app.RegisterAction({ - .description = "LOC_EDITOR_ACTION_LOG_COPY_DESC", - .path = { "LOC_EDITOR_MENU_LOG_COPY" }, - .category = "Output", - }); - app.RegisterAction({ - .description = "LOC_EDITOR_ACTION_QUIT_DESC", - .path = { "LOC_EDITOR_MENU_FILE", "LOC_EDITOR_MENU_QUIT" }, - .category = "General", - .shortcut = Nz::Shortcut::Create(Nz::Keyboard::VKey::F4, false, false, true), - }); - entt::meta() .type(entt::type_hash::value()) .func<&Nz::ReflectComponent, Nz::NodeComponent>>(entt::hashed_string("Reflect"));