mirror of
https://github.com/cemu-project/Cemu.git
synced 2024-11-22 00:59: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/TitleList/TitleList.h"
|
||||
|
||||
#include "wxHelper.h"
|
||||
|
||||
#if BOOST_OS_LINUX || BOOST_OS_MACOS
|
||||
#include "resource/embedded/resources.h"
|
||||
#endif
|
||||
@ -89,10 +91,10 @@ void GraphicPacksWindow2::FillGraphicPackList() const
|
||||
const auto parent_node = node;
|
||||
if (i < (tokens.size() - 1))
|
||||
{
|
||||
node = FindTreeItem(parent_node, wxString(token.data(), token.length()));
|
||||
node = FindTreeItem(parent_node, wxHelper::FromUtf8(token));
|
||||
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
|
||||
@ -101,9 +103,9 @@ void GraphicPacksWindow2::FillGraphicPackList() const
|
||||
// if a node with same name already exists, add a number suffix
|
||||
for (sint32 s = 0; s < 999; s++)
|
||||
{
|
||||
wxString nodeName(token.data(), token.length());
|
||||
wxString nodeName = wxHelper::FromUtf8(token);
|
||||
if (s > 0)
|
||||
nodeName.append(fmt::format(" #{}", s + 1));
|
||||
nodeName.append(wxHelper::FromUtf8(fmt::format(" #{}", s + 1)));
|
||||
|
||||
node = FindTreeItem(parent_node, nodeName);
|
||||
if (!node.IsOk())
|
||||
@ -218,7 +220,7 @@ GraphicPacksWindow2::GraphicPacksWindow2(wxWindow* parent, uint64_t title_id_fil
|
||||
text->Wrap(-1);
|
||||
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);
|
||||
m_filter_text->Bind(wxEVT_COMMAND_TEXT_UPDATED, &GraphicPacksWindow2::OnFilterUpdate, this);
|
||||
|
||||
@ -386,13 +388,14 @@ void GraphicPacksWindow2::LoadPresetSelections(const GraphicPackPtr& gp)
|
||||
{
|
||||
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_sizer = new wxStaticBoxSizer(box, wxVERTICAL);
|
||||
|
||||
auto* preset = new wxChoice(box, wxID_ANY);
|
||||
preset->SetClientObject(new wxStringClientData(category));
|
||||
preset->SetClientObject(new wxStringClientData(categoryWxStr));
|
||||
preset->Bind(wxEVT_CHOICE, &GraphicPacksWindow2::OnActivePresetChanged, this);
|
||||
|
||||
std::optional<std::string> active_preset;
|
||||
@ -400,14 +403,14 @@ void GraphicPacksWindow2::LoadPresetSelections(const GraphicPackPtr& gp)
|
||||
{
|
||||
if (!pentry->visible)
|
||||
continue;
|
||||
|
||||
preset->AppendString(pentry->name);
|
||||
|
||||
preset->AppendString(wxHelper::FromUtf8(pentry->name));
|
||||
if (pentry->active)
|
||||
active_preset = pentry->name;
|
||||
}
|
||||
|
||||
if (active_preset)
|
||||
preset->SetStringSelection(active_preset.value());
|
||||
preset->SetStringSelection(wxHelper::FromUtf8(active_preset.value()));
|
||||
else if (preset->GetCount() > 0)
|
||||
preset->SetSelection(0);
|
||||
|
||||
@ -439,14 +442,14 @@ void GraphicPacksWindow2::OnTreeSelectionChanged(wxTreeEvent& event)
|
||||
{
|
||||
m_preset_sizer->Clear(true);
|
||||
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())
|
||||
m_gp_description = _("This graphic pack has no description");
|
||||
else
|
||||
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);
|
||||
|
||||
@ -567,8 +570,8 @@ void GraphicPacksWindow2::OnActivePresetChanged(wxCommandEvent& event)
|
||||
wxASSERT(obj);
|
||||
const auto string_data = dynamic_cast<wxStringClientData*>(obj->GetClientObject());
|
||||
wxASSERT(string_data);
|
||||
const auto preset = obj->GetStringSelection().ToStdString();
|
||||
if(m_shown_graphic_pack->SetActivePreset(string_data->GetData().c_str().AsChar(), preset))
|
||||
const auto preset = wxHelper::MakeUTF8(obj->GetStringSelection());
|
||||
if(m_shown_graphic_pack->SetActivePreset(wxHelper::MakeUTF8(string_data->GetData()), preset))
|
||||
{
|
||||
wxWindowUpdateLocker lock(this);
|
||||
ClearPresets();
|
||||
@ -642,10 +645,10 @@ void GraphicPacksWindow2::OnSizeChanged(wxSizeEvent& event)
|
||||
obj->SetSashPosition((sint32)(m_ratio * width));
|
||||
|
||||
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())
|
||||
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_description->Wrap(m_graphic_pack_description->GetParent()->GetClientSize().GetWidth() - 10);
|
||||
@ -665,7 +668,7 @@ void GraphicPacksWindow2::SashPositionChanged(wxEvent& event)
|
||||
|
||||
void GraphicPacksWindow2::OnFilterUpdate(wxEvent& event)
|
||||
{
|
||||
m_filter = m_filter_text->GetValue();
|
||||
m_filter = wxHelper::MakeUTF8(m_filter_text->GetValue());
|
||||
FillGraphicPackList();
|
||||
event.Skip();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user