mirror of
https://github.com/cemu-project/Cemu.git
synced 2024-11-22 17:19:18 +01:00
GraphicsPackWindow2: Use UTF8 (#802)
This commit is contained in:
parent
1f16e999c5
commit
d56bc807cf
@ -10,6 +10,8 @@
|
|||||||
#include "Cafe/CafeSystem.h"
|
#include "Cafe/CafeSystem.h"
|
||||||
#include "Cafe/TitleList/TitleList.h"
|
#include "Cafe/TitleList/TitleList.h"
|
||||||
|
|
||||||
|
#include "wxHelper.h"
|
||||||
|
|
||||||
#if BOOST_OS_LINUX || BOOST_OS_MACOS
|
#if BOOST_OS_LINUX || BOOST_OS_MACOS
|
||||||
#include "resource/embedded/resources.h"
|
#include "resource/embedded/resources.h"
|
||||||
#endif
|
#endif
|
||||||
@ -89,10 +91,10 @@ void GraphicPacksWindow2::FillGraphicPackList() const
|
|||||||
const auto parent_node = node;
|
const auto parent_node = node;
|
||||||
if (i < (tokens.size() - 1))
|
if (i < (tokens.size() - 1))
|
||||||
{
|
{
|
||||||
node = FindTreeItem(parent_node, wxString(token.data(), token.length()));
|
node = FindTreeItem(parent_node, wxHelper::FromUtf8(token));
|
||||||
if (!node.IsOk())
|
if (!node.IsOk())
|
||||||
{
|
{
|
||||||
node = m_graphic_pack_tree->AppendItem(parent_node, wxString(token.data(), token.length()));
|
node = m_graphic_pack_tree->AppendItem(parent_node, wxHelper::FromUtf8(token));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -101,9 +103,9 @@ void GraphicPacksWindow2::FillGraphicPackList() const
|
|||||||
// if a node with same name already exists, add a number suffix
|
// if a node with same name already exists, add a number suffix
|
||||||
for (sint32 s = 0; s < 999; s++)
|
for (sint32 s = 0; s < 999; s++)
|
||||||
{
|
{
|
||||||
wxString nodeName(token.data(), token.length());
|
wxString nodeName = wxHelper::FromUtf8(token);
|
||||||
if (s > 0)
|
if (s > 0)
|
||||||
nodeName.append(fmt::format(" #{}", s + 1));
|
nodeName.append(wxHelper::FromUtf8(fmt::format(" #{}", s + 1)));
|
||||||
|
|
||||||
node = FindTreeItem(parent_node, nodeName);
|
node = FindTreeItem(parent_node, nodeName);
|
||||||
if (!node.IsOk())
|
if (!node.IsOk())
|
||||||
@ -218,7 +220,7 @@ GraphicPacksWindow2::GraphicPacksWindow2(wxWindow* parent, uint64_t title_id_fil
|
|||||||
text->Wrap(-1);
|
text->Wrap(-1);
|
||||||
filter_row->Add(text, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5);
|
filter_row->Add(text, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5);
|
||||||
|
|
||||||
m_filter_text = new wxTextCtrl(left_panel, wxID_ANY, m_filter, wxDefaultPosition, wxDefaultSize, 0);
|
m_filter_text = new wxTextCtrl(left_panel, wxID_ANY, wxHelper::FromUtf8(m_filter), wxDefaultPosition, wxDefaultSize, 0);
|
||||||
filter_row->Add(m_filter_text, 0, wxALL | wxEXPAND, 5);
|
filter_row->Add(m_filter_text, 0, wxALL | wxEXPAND, 5);
|
||||||
m_filter_text->Bind(wxEVT_COMMAND_TEXT_UPDATED, &GraphicPacksWindow2::OnFilterUpdate, this);
|
m_filter_text->Bind(wxEVT_COMMAND_TEXT_UPDATED, &GraphicPacksWindow2::OnFilterUpdate, this);
|
||||||
|
|
||||||
@ -387,12 +389,13 @@ void GraphicPacksWindow2::LoadPresetSelections(const GraphicPackPtr& gp)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxString label(category.empty() ? _("Active preset") : wxString(category));
|
wxString categoryWxStr = wxHelper::FromUtf8(category);
|
||||||
|
wxString label(category.empty() ? _("Active preset") : categoryWxStr);
|
||||||
auto* box = new wxStaticBox(m_preset_sizer->GetContainingWindow(), wxID_ANY, label);
|
auto* box = new wxStaticBox(m_preset_sizer->GetContainingWindow(), wxID_ANY, label);
|
||||||
auto* box_sizer = new wxStaticBoxSizer(box, wxVERTICAL);
|
auto* box_sizer = new wxStaticBoxSizer(box, wxVERTICAL);
|
||||||
|
|
||||||
auto* preset = new wxChoice(box, wxID_ANY);
|
auto* preset = new wxChoice(box, wxID_ANY);
|
||||||
preset->SetClientObject(new wxStringClientData(category));
|
preset->SetClientObject(new wxStringClientData(categoryWxStr));
|
||||||
preset->Bind(wxEVT_CHOICE, &GraphicPacksWindow2::OnActivePresetChanged, this);
|
preset->Bind(wxEVT_CHOICE, &GraphicPacksWindow2::OnActivePresetChanged, this);
|
||||||
|
|
||||||
std::optional<std::string> active_preset;
|
std::optional<std::string> active_preset;
|
||||||
@ -401,13 +404,13 @@ void GraphicPacksWindow2::LoadPresetSelections(const GraphicPackPtr& gp)
|
|||||||
if (!pentry->visible)
|
if (!pentry->visible)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
preset->AppendString(pentry->name);
|
preset->AppendString(wxHelper::FromUtf8(pentry->name));
|
||||||
if (pentry->active)
|
if (pentry->active)
|
||||||
active_preset = pentry->name;
|
active_preset = pentry->name;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (active_preset)
|
if (active_preset)
|
||||||
preset->SetStringSelection(active_preset.value());
|
preset->SetStringSelection(wxHelper::FromUtf8(active_preset.value()));
|
||||||
else if (preset->GetCount() > 0)
|
else if (preset->GetCount() > 0)
|
||||||
preset->SetSelection(0);
|
preset->SetSelection(0);
|
||||||
|
|
||||||
@ -439,14 +442,14 @@ void GraphicPacksWindow2::OnTreeSelectionChanged(wxTreeEvent& event)
|
|||||||
{
|
{
|
||||||
m_preset_sizer->Clear(true);
|
m_preset_sizer->Clear(true);
|
||||||
m_gp_name = gp->GetName();
|
m_gp_name = gp->GetName();
|
||||||
m_graphic_pack_name->SetLabel(m_gp_name);
|
m_graphic_pack_name->SetLabel(wxHelper::FromUtf8(m_gp_name));
|
||||||
|
|
||||||
if (gp->GetDescription().empty())
|
if (gp->GetDescription().empty())
|
||||||
m_gp_description = _("This graphic pack has no description");
|
m_gp_description = _("This graphic pack has no description");
|
||||||
else
|
else
|
||||||
m_gp_description = gp->GetDescription();
|
m_gp_description = gp->GetDescription();
|
||||||
|
|
||||||
m_graphic_pack_description->SetLabel(m_gp_description);
|
m_graphic_pack_description->SetLabel(wxHelper::FromUtf8(m_gp_description));
|
||||||
|
|
||||||
LoadPresetSelections(gp);
|
LoadPresetSelections(gp);
|
||||||
|
|
||||||
@ -567,8 +570,8 @@ void GraphicPacksWindow2::OnActivePresetChanged(wxCommandEvent& event)
|
|||||||
wxASSERT(obj);
|
wxASSERT(obj);
|
||||||
const auto string_data = dynamic_cast<wxStringClientData*>(obj->GetClientObject());
|
const auto string_data = dynamic_cast<wxStringClientData*>(obj->GetClientObject());
|
||||||
wxASSERT(string_data);
|
wxASSERT(string_data);
|
||||||
const auto preset = obj->GetStringSelection().ToStdString();
|
const auto preset = wxHelper::MakeUTF8(obj->GetStringSelection());
|
||||||
if(m_shown_graphic_pack->SetActivePreset(string_data->GetData().c_str().AsChar(), preset))
|
if(m_shown_graphic_pack->SetActivePreset(wxHelper::MakeUTF8(string_data->GetData()), preset))
|
||||||
{
|
{
|
||||||
wxWindowUpdateLocker lock(this);
|
wxWindowUpdateLocker lock(this);
|
||||||
ClearPresets();
|
ClearPresets();
|
||||||
@ -642,10 +645,10 @@ void GraphicPacksWindow2::OnSizeChanged(wxSizeEvent& event)
|
|||||||
obj->SetSashPosition((sint32)(m_ratio * width));
|
obj->SetSashPosition((sint32)(m_ratio * width));
|
||||||
|
|
||||||
if (!m_gp_name.empty())
|
if (!m_gp_name.empty())
|
||||||
m_graphic_pack_name->SetLabel(m_gp_name);
|
m_graphic_pack_name->SetLabel(wxHelper::FromUtf8(m_gp_name));
|
||||||
|
|
||||||
if (!m_gp_description.empty())
|
if (!m_gp_description.empty())
|
||||||
m_graphic_pack_description->SetLabel(m_gp_description);
|
m_graphic_pack_description->SetLabel(wxHelper::FromUtf8(m_gp_description));
|
||||||
|
|
||||||
m_graphic_pack_name->Wrap(m_graphic_pack_name->GetParent()->GetClientSize().GetWidth() - 10);
|
m_graphic_pack_name->Wrap(m_graphic_pack_name->GetParent()->GetClientSize().GetWidth() - 10);
|
||||||
m_graphic_pack_description->Wrap(m_graphic_pack_description->GetParent()->GetClientSize().GetWidth() - 10);
|
m_graphic_pack_description->Wrap(m_graphic_pack_description->GetParent()->GetClientSize().GetWidth() - 10);
|
||||||
@ -665,7 +668,7 @@ void GraphicPacksWindow2::SashPositionChanged(wxEvent& event)
|
|||||||
|
|
||||||
void GraphicPacksWindow2::OnFilterUpdate(wxEvent& event)
|
void GraphicPacksWindow2::OnFilterUpdate(wxEvent& event)
|
||||||
{
|
{
|
||||||
m_filter = m_filter_text->GetValue();
|
m_filter = wxHelper::MakeUTF8(m_filter_text->GetValue());
|
||||||
FillGraphicPackList();
|
FillGraphicPackList();
|
||||||
event.Skip();
|
event.Skip();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user