moving actions register to their respective files

This commit is contained in:
SweetId 2023-10-29 22:35:40 -04:00
parent d80069b345
commit 014e40a268
8 changed files with 74 additions and 53 deletions

View File

@ -4,6 +4,8 @@
namespace Nz
{
NAZARAEDITOR_CORE_API void RegisterEditorActions(class EditorBaseApplication& app);
class NAZARAEDITOR_CORE_API EditorAction_Quit final
: public EditorAction
{

View File

@ -4,6 +4,8 @@
namespace Nz
{
NAZARAEDITOR_CORE_API void RegisterLevelActions(class EditorBaseApplication& app);
class NAZARAEDITOR_CORE_API EditorAction_Level_New final
: public EditorAction
{

View File

@ -4,6 +4,8 @@
namespace Nz
{
NAZARAEDITOR_CORE_API void RegisterLogActions(class EditorBaseApplication& app);
class NAZARAEDITOR_CORE_API EditorAction_Log_Clear final
: public EditorAction
{

View File

@ -5,6 +5,16 @@
namespace Nz
{
void RegisterEditorActions(EditorBaseApplication& app)
{
app.RegisterAction<Nz::EditorAction_Quit>({
.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({

View File

@ -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<Nz::EditorAction_Level_New>({
.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<Nz::EditorAction_Level_Open>({
.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<Nz::EditorAction_Level_Save>({
.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({

View File

@ -3,6 +3,20 @@
namespace Nz
{
void RegisterLogActions(EditorBaseApplication& app)
{
app.RegisterAction<Nz::EditorAction_Log_Clear>({
.description = "LOC_EDITOR_ACTION_LOG_CLEAR_DESC",
.path = { "LOC_EDITOR_MENU_LOG_CLEAR" },
.category = "Output",
});
app.RegisterAction<Nz::EditorAction_Log_CopyToClipboard>({
.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();

View File

@ -1,4 +1,9 @@
#include <NazaraEditor/Editor/Application.hpp>
#include <NazaraEditor/Editor/UI/AssetsWindow.hpp>
#include <NazaraEditor/Editor/UI/InspectorWindow.hpp>
#include <NazaraEditor/Editor/UI/LevelWindow.hpp>
#include <NazaraEditor/Editor/UI/MainWindow.hpp>
#include <NazaraEditor/Editor/UI/OutputWindow.hpp>
#include <NazaraLocalization/Localization.hpp>
@ -6,6 +11,16 @@ namespace NzEditor
{
Application::Application()
{
RegisterWindow<NzEditor::MainWindow>();
RegisterWindow<NzEditor::AssetsWindow>();
RegisterWindow<NzEditor::LevelWindow>();
RegisterWindow<NzEditor::InspectorWindow>();
RegisterWindow<NzEditor::OutputWindow>();
Nz::RegisterLevelActions(*this);
Nz::RegisterEditorActions(*this);
Nz::RegisterLogActions(*this);
Nz::Localization::OnLocaleInstalled.Connect([this](std::string_view locale) {
RegisterAction<Nz::EditorAction_SetLocale>({
.className = std::format("{}_{}", Nz::EditorAction_SetLocale::GetClassName(), locale),

View File

@ -9,11 +9,6 @@
#include <NazaraEditor/Core.hpp>
#include <NazaraEditor/Editor/Application.hpp>
#include <NazaraEditor/Editor/UI/AssetsWindow.hpp>
#include <NazaraEditor/Editor/UI/InspectorWindow.hpp>
#include <NazaraEditor/Editor/UI/LevelWindow.hpp>
#include <NazaraEditor/Editor/UI/MainWindow.hpp>
#include <NazaraEditor/Editor/UI/OutputWindow.hpp>
NAZARA_REQUEST_DEDICATED_GPU()
@ -38,57 +33,9 @@ int WinMain(int argc, char* argv[])
ImGui::EnsureContextOnThisThread();
app.RegisterWindow<NzEditor::MainWindow>();
app.RegisterWindow<NzEditor::AssetsWindow>();
app.RegisterWindow<NzEditor::LevelWindow>();
app.RegisterWindow<NzEditor::InspectorWindow>();
app.RegisterWindow<NzEditor::OutputWindow>();
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<Nz::EditorAction_Level_New>({
.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<Nz::EditorAction_Level_Open>({
.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<Nz::EditorAction_Level_Save>({
.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<Nz::EditorAction_Log_Clear>({
.description = "LOC_EDITOR_ACTION_LOG_CLEAR_DESC",
.path = { "LOC_EDITOR_MENU_LOG_CLEAR" },
.category = "Output",
});
app.RegisterAction<Nz::EditorAction_Log_CopyToClipboard>({
.description = "LOC_EDITOR_ACTION_LOG_COPY_DESC",
.path = { "LOC_EDITOR_MENU_LOG_COPY" },
.category = "Output",
});
app.RegisterAction<Nz::EditorAction_Quit>({
.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<Nz::NodeComponent>()
.type(entt::type_hash<Nz::NodeComponent>::value())
.func<&Nz::ReflectComponent<Nz::EditorPropertyInspector<Nz::EditorRenderer>, Nz::NodeComponent>>(entt::hashed_string("Reflect"));