Add log actions

This commit is contained in:
SweetId 2023-10-16 19:38:22 -04:00
parent eb35ee8050
commit 14b5088e26
6 changed files with 79 additions and 0 deletions

View File

@ -3,6 +3,8 @@
#include <NazaraEditor/Core/Core.hpp>
#include <NazaraEditor/Core/Application/Action.hpp>
#include <NazaraEditor/Core/Application/ActionStack.hpp>
#include <NazaraEditor/Core/Application/Actions/EditorAction_Log_Clear.hpp>
#include <NazaraEditor/Core/Application/Actions/EditorAction_Log_CopyToClipboard.hpp>
#include <NazaraEditor/Core/Application/BaseApplication.hpp>
#include <NazaraEditor/Core/Application/EditorLogger.hpp>
#include <NazaraEditor/Core/Application/Level.hpp>

View File

@ -0,0 +1,15 @@
#pragma once
#include <NazaraEditor/Core/Application/Action.hpp>
namespace Nz
{
class NAZARAEDITOR_CORE_API EditorAction_Log_Clear final
: public EditorAction
{
EDITORACTION_BODY(EditorAction_Log_Clear, false);
public:
void Execute() override;
};
}

View File

@ -0,0 +1,15 @@
#pragma once
#include <NazaraEditor/Core/Application/Action.hpp>
namespace Nz
{
class NAZARAEDITOR_CORE_API EditorAction_Log_CopyToClipboard final
: public EditorAction
{
EDITORACTION_BODY(EditorAction_Log_CopyToClipboard, false);
public:
void Execute() override;
};
}

View File

@ -0,0 +1,10 @@
#include <NazaraEditor/Core/Application/Actions/EditorAction_Log_Clear.hpp>
#include <NazaraEditor/Core/Application/EditorLogger.hpp>
namespace Nz
{
void EditorAction_Log_Clear::Execute()
{
Nz::EditorLogger::Instance()->Clear();
}
}

View File

@ -0,0 +1,23 @@
#include <NazaraEditor/Core/Application/Actions/EditorAction_Log_CopyToClipboard.hpp>
#include <NazaraEditor/Core/Application/EditorLogger.hpp>
#include <Nazara/Platform.hpp>
#include <sstream>
namespace Nz
{
void EditorAction_Log_CopyToClipboard::Execute()
{
auto& lines = Nz::EditorLogger::Instance()->GetLog();
if (lines.empty())
return;
std::ostringstream oss;
oss << lines[0];
for (size_t i = 1; i < lines.size(); ++i)
oss << '\n' << lines[i];
Nz::Clipboard::SetString(oss.str());
}
}

View File

@ -43,6 +43,20 @@ int WinMain(int argc, char* argv[])
app.RegisterWindow<NzEditor::InspectorWindow>();
app.RegisterWindow<NzEditor::OutputWindow>();
Nz::TextureParams texParams;
texParams.renderDevice = Nz::Graphics::Instance()->GetRenderDevice();
texParams.loadFormat = Nz::PixelFormat::RGBA8_SRGB;
app.RegisterAction<Nz::EditorAction_Log_Clear>({
.description = "Clears log output",
.path = "Clear",
.category = "Output",
});
app.RegisterAction<Nz::EditorAction_Log_CopyToClipboard>({
.description = "Copies log output to clipboard",
.path = "Copy to Clipboard",
.category = "Output",
});
entt::meta<Nz::NodeComponent>()
.type(entt::type_hash<Nz::NodeComponent>::value())
.func<&Nz::ReflectComponent<Nz::EditorPropertyInspector<Nz::EditorRenderer>, Nz::NodeComponent>>(entt::hashed_string("Reflect"));