use localized text for popup manager

This commit is contained in:
SweetId 2023-10-21 17:17:25 -04:00
parent 8a2d118641
commit 4f2e03c228
3 changed files with 12 additions and 9 deletions

View File

@ -1,6 +1,7 @@
#pragma once
#include <NazaraEditor/Core/Core.hpp>
#include <NazaraLocalization/LocalizedText.hpp>
#include <memory>
#include <vector>
@ -11,11 +12,11 @@ namespace Nz
{
struct Choice
{
std::string name;
Nz::LocalizedText name;
std::function<void(void)> callback;
};
std::string title;
std::string description;
Nz::LocalizedText title;
Nz::LocalizedText description;
std::vector<Choice> choices;
};

View File

@ -7,15 +7,15 @@ namespace Nz
void EditorAction_Level_New::Execute()
{
Nz::EditorBaseApplication::Instance()->GetPopupManager().CreatePopup({
.title = "Warning",
.description = "Are you sure you want to create a new level?",
.title = "LOC_EDITOR_POPUP_CREATE_LEVEL_TITLE",
.description = "LOC_EDITOR_POPUP_CREATE_LEVEL_DESC",
.choices = {
{
.name = "Yes",
.name = "LOC_EDITOR_YES",
.callback = []() { Nz::EditorBaseApplication::Instance()->NewLevel(); }
},
{
.name = "No"
.name = "LOC_EDITOR_NO"
}
}
});

View File

@ -18,8 +18,10 @@ namespace Nz
void EditorPopup::OnRenderImgui()
{
ImGui::OpenPopup(m_parameters.title.c_str());
if (ImGui::BeginPopupModal(m_parameters.title.c_str(), nullptr, ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoCollapse))
std::string name = std::format("{}###{}", m_parameters.title.ToString(), m_parameters.title.GetBaseString());
ImGui::OpenPopup(name.c_str());
if (ImGui::BeginPopupModal(name.c_str(), nullptr, ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoCollapse))
{
ImGui::Text(m_parameters.description.c_str());