use Nz::LocalizedText instead of std::string for text displayed to users
This commit is contained in:
parent
89671593e1
commit
77d4c747ef
|
|
@ -5,6 +5,7 @@
|
||||||
#include <NazaraEditor/Core/Application/Shortcut.hpp>
|
#include <NazaraEditor/Core/Application/Shortcut.hpp>
|
||||||
|
|
||||||
#include <Nazara/Renderer.hpp>
|
#include <Nazara/Renderer.hpp>
|
||||||
|
#include <NazaraLocalization/LocalizedText.hpp>
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
@ -17,8 +18,8 @@ namespace Nz
|
||||||
struct Properties
|
struct Properties
|
||||||
{
|
{
|
||||||
std::string className;
|
std::string className;
|
||||||
std::string description;
|
Nz::LocalizedText description;
|
||||||
std::string path;
|
Nz::LocalizedText path;
|
||||||
std::string category;
|
std::string category;
|
||||||
Nz::Shortcut shortcut;
|
Nz::Shortcut shortcut;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -14,11 +14,12 @@
|
||||||
#include <NazaraEditor/Core/UI/PopupManager.hpp>
|
#include <NazaraEditor/Core/UI/PopupManager.hpp>
|
||||||
#include <NazaraEditor/Core/UI/Window.hpp>
|
#include <NazaraEditor/Core/UI/Window.hpp>
|
||||||
#include <NazaraImgui/NazaraImgui.hpp>
|
#include <NazaraImgui/NazaraImgui.hpp>
|
||||||
|
#include <NazaraLocalization/Localization.hpp>
|
||||||
|
|
||||||
namespace Nz
|
namespace Nz
|
||||||
{
|
{
|
||||||
class NAZARAEDITOR_CORE_API EditorBaseApplication
|
class NAZARAEDITOR_CORE_API EditorBaseApplication
|
||||||
: public Nz::Application<Nz::Graphics, Nz::Imgui, Nz::EditorCore>
|
: public Nz::Application<Nz::Graphics, Nz::Imgui, Nz::Localization, Nz::EditorCore>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
NazaraSignal(OnLevelChanged, Nz::Level&);
|
NazaraSignal(OnLevelChanged, Nz::Level&);
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ namespace Nz
|
||||||
: public EditorWindow
|
: public EditorWindow
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
EditorMainWindow(EditorBaseApplication* app, const std::string& name = "", const std::vector<std::string>& categories = {});
|
EditorMainWindow(EditorBaseApplication* app, const Nz::LocalizedText& name, const std::vector<std::string>& categories = {});
|
||||||
virtual ~EditorMainWindow() = default;
|
virtual ~EditorMainWindow() = default;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@
|
||||||
#include <NazaraUtils/Prerequisites.hpp>
|
#include <NazaraUtils/Prerequisites.hpp>
|
||||||
#include <NazaraEditor/Core/Config.hpp>
|
#include <NazaraEditor/Core/Config.hpp>
|
||||||
#include <NazaraImgui/NazaraImgui.hpp>
|
#include <NazaraImgui/NazaraImgui.hpp>
|
||||||
|
#include <NazaraLocalization/LocalizedText.hpp>
|
||||||
|
|
||||||
namespace Nz
|
namespace Nz
|
||||||
{
|
{
|
||||||
|
|
@ -14,7 +15,7 @@ namespace Nz
|
||||||
: private Nz::ImguiHandler
|
: private Nz::ImguiHandler
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
EditorWindow(EditorBaseApplication* app, const std::string& name = "", const std::vector<std::string>& categories = {});
|
EditorWindow(EditorBaseApplication* app, const Nz::LocalizedText& name, const std::vector<std::string>& categories = {});
|
||||||
virtual ~EditorWindow();
|
virtual ~EditorWindow();
|
||||||
|
|
||||||
EditorWindow(const EditorWindow&) = delete;
|
EditorWindow(const EditorWindow&) = delete;
|
||||||
|
|
@ -40,7 +41,7 @@ namespace Nz
|
||||||
private:
|
private:
|
||||||
|
|
||||||
EditorBaseApplication* m_application;
|
EditorBaseApplication* m_application;
|
||||||
std::string m_windowName;
|
Nz::LocalizedText m_windowName;
|
||||||
std::vector<std::string> m_categories;
|
std::vector<std::string> m_categories;
|
||||||
|
|
||||||
struct MenuAction
|
struct MenuAction
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
namespace Nz
|
namespace Nz
|
||||||
{
|
{
|
||||||
EditorMainWindow::EditorMainWindow(EditorBaseApplication* app, const std::string& name, const std::vector<std::string>& categories)
|
EditorMainWindow::EditorMainWindow(EditorBaseApplication* app, const Nz::LocalizedText& name, const std::vector<std::string>& categories)
|
||||||
: EditorWindow(app, name, categories)
|
: EditorWindow(app, name, categories)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@
|
||||||
|
|
||||||
namespace Nz
|
namespace Nz
|
||||||
{
|
{
|
||||||
EditorWindow::EditorWindow(EditorBaseApplication* app, const std::string& name, const std::vector<std::string>& categories)
|
EditorWindow::EditorWindow(EditorBaseApplication* app, const Nz::LocalizedText& name, const std::vector<std::string>& categories)
|
||||||
: m_application(app)
|
: m_application(app)
|
||||||
, m_windowName(name)
|
, m_windowName(name)
|
||||||
, m_categories(categories)
|
, m_categories(categories)
|
||||||
|
|
@ -18,7 +18,7 @@ namespace Nz
|
||||||
return;
|
return;
|
||||||
|
|
||||||
auto name = prop.className;
|
auto name = prop.className;
|
||||||
AddMenuAction(prop.path, prop.shortcut.ToString(), [name]() { Nz::EditorBaseApplication::Instance()->GetActionStack().ExecuteAction(name); }, prop.icon);
|
AddMenuAction(prop.path.ToString(), prop.shortcut.ToString(), [name]() { Nz::EditorBaseApplication::Instance()->GetActionStack().ExecuteAction(name); }, prop.icon);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
namespace NzEditor
|
namespace NzEditor
|
||||||
{
|
{
|
||||||
AssetsWindow::AssetsWindow(Nz::EditorBaseApplication* app)
|
AssetsWindow::AssetsWindow(Nz::EditorBaseApplication* app)
|
||||||
: Nz::EditorWindow(app, "Assets Browser", { "Assets" })
|
: Nz::EditorWindow(app, Nz::LocalizedText("LOC_EDITOR_WINDOW_ASSET_BROWSER_TITLE"), { "Assets" })
|
||||||
{
|
{
|
||||||
BuildMenuBar();
|
BuildMenuBar();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@
|
||||||
namespace NzEditor
|
namespace NzEditor
|
||||||
{
|
{
|
||||||
InspectorWindow::InspectorWindow(Nz::EditorBaseApplication* app)
|
InspectorWindow::InspectorWindow(Nz::EditorBaseApplication* app)
|
||||||
: Nz::EditorWindow(app, "Inspector")
|
: Nz::EditorWindow(app, Nz::LocalizedText("LOC_EDITOR_WINDOW_INSPECTOR_TITLE"))
|
||||||
{
|
{
|
||||||
app->OnEntitySelected.Connect(this, &InspectorWindow::OnEntitySelected);
|
app->OnEntitySelected.Connect(this, &InspectorWindow::OnEntitySelected);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
namespace NzEditor
|
namespace NzEditor
|
||||||
{
|
{
|
||||||
LevelWindow::LevelWindow(Nz::EditorBaseApplication* app)
|
LevelWindow::LevelWindow(Nz::EditorBaseApplication* app)
|
||||||
: Nz::EditorWindow(app, "Level")
|
: Nz::EditorWindow(app, Nz::LocalizedText("LOC_EDITOR_WINDOW_LEVEL_TITLE"))
|
||||||
, m_currentLevel(app->GetLevel())
|
, m_currentLevel(app->GetLevel())
|
||||||
, m_dirty(true)
|
, m_dirty(true)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
namespace NzEditor
|
namespace NzEditor
|
||||||
{
|
{
|
||||||
MainWindow::MainWindow(Nz::EditorBaseApplication* app)
|
MainWindow::MainWindow(Nz::EditorBaseApplication* app)
|
||||||
: Nz::EditorMainWindow(app, "MainWindow", { "General", "Plugins" })
|
: Nz::EditorMainWindow(app, Nz::LocalizedText("LOC_EDITOR_WINDOW_MAIN_TITLE"), { "General", "Plugins" })
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
namespace NzEditor
|
namespace NzEditor
|
||||||
{
|
{
|
||||||
OutputWindow::OutputWindow(Nz::EditorBaseApplication* app)
|
OutputWindow::OutputWindow(Nz::EditorBaseApplication* app)
|
||||||
: Nz::EditorWindow(app, "Output", { "Output" })
|
: Nz::EditorWindow(app, Nz::LocalizedText("LOC_EDITOR_WINDOW_OUTPUT_TITLE"), { "Output" })
|
||||||
, m_bScrollToBottom(true)
|
, m_bScrollToBottom(true)
|
||||||
, m_bScrollToTop(false)
|
, m_bScrollToTop(false)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -36,6 +36,9 @@ int WinMain(int argc, char* argv[])
|
||||||
app.SetResourceFolder(resourceDir);
|
app.SetResourceFolder(resourceDir);
|
||||||
app.SetLogger(logger);
|
app.SetLogger(logger);
|
||||||
|
|
||||||
|
Nz::Localization::Instance()->LoadLocalizationFile(resourceDir / "localization.csv");
|
||||||
|
Nz::Localization::Instance()->SetLocale("en-US");
|
||||||
|
|
||||||
ImGui::EnsureContextOnThisThread();
|
ImGui::EnsureContextOnThisThread();
|
||||||
|
|
||||||
app.RegisterWindow<NzEditor::MainWindow>();
|
app.RegisterWindow<NzEditor::MainWindow>();
|
||||||
|
|
@ -49,25 +52,25 @@ int WinMain(int argc, char* argv[])
|
||||||
texParams.loadFormat = Nz::PixelFormat::RGBA8_SRGB;
|
texParams.loadFormat = Nz::PixelFormat::RGBA8_SRGB;
|
||||||
|
|
||||||
app.RegisterAction<Nz::EditorAction_Level_New>({
|
app.RegisterAction<Nz::EditorAction_Level_New>({
|
||||||
.description = "Create new level",
|
.description = Nz::LocalizedText("LOC_EDITOR_ACTION_LEVEL_NEW_DESC"),
|
||||||
.path = "File|Level|New",
|
.path = Nz::LocalizedText("LOC_EDITOR_ACTION_LEVEL_NEW_PATH"),
|
||||||
.category = "General",
|
.category = "General",
|
||||||
.shortcut = Nz::Shortcut::Create(Nz::Keyboard::VKey::N, true, true),
|
.shortcut = Nz::Shortcut::Create(Nz::Keyboard::VKey::N, true, true),
|
||||||
.icon = Nz::Texture::LoadFromFile(app.GetResourceFolder() / "file_new.png", texParams)
|
.icon = Nz::Texture::LoadFromFile(app.GetResourceFolder() / "file_new.png", texParams)
|
||||||
});
|
});
|
||||||
app.RegisterAction<Nz::EditorAction_Log_Clear>({
|
app.RegisterAction<Nz::EditorAction_Log_Clear>({
|
||||||
.description = "Clears log output",
|
.description = Nz::LocalizedText("LOC_EDITOR_ACTION_LOG_CLEAR_DESC"),
|
||||||
.path = "Clear",
|
.path = Nz::LocalizedText("LOC_EDITOR_ACTION_LOG_CLEAR_PATH"),
|
||||||
.category = "Output",
|
.category = "Output",
|
||||||
});
|
});
|
||||||
app.RegisterAction<Nz::EditorAction_Log_CopyToClipboard>({
|
app.RegisterAction<Nz::EditorAction_Log_CopyToClipboard>({
|
||||||
.description = "Copies log output to clipboard",
|
.description = Nz::LocalizedText("LOC_EDITOR_ACTION_LOG_COPY_DESC"),
|
||||||
.path = "Copy to Clipboard",
|
.path = Nz::LocalizedText("LOC_EDITOR_ACTION_LOG_COPY_PATH"),
|
||||||
.category = "Output",
|
.category = "Output",
|
||||||
});
|
});
|
||||||
app.RegisterAction<Nz::EditorAction_Quit>({
|
app.RegisterAction<Nz::EditorAction_Quit>({
|
||||||
.description = "Exits the editor",
|
.description = Nz::LocalizedText("LOC_EDITOR_ACTION_QUIT_DESC"),
|
||||||
.path = "File|Exit",
|
.path = Nz::LocalizedText("LOC_EDITOR_ACTION_QUIT_PATH"),
|
||||||
.category = "General",
|
.category = "General",
|
||||||
.shortcut = Nz::Shortcut::Create(Nz::Keyboard::VKey::F4, false, false, true),
|
.shortcut = Nz::Shortcut::Create(Nz::Keyboard::VKey::F4, false, false, true),
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue