10
10
#include " Cafe/CafeSystem.h"
11
11
#include " Cafe/TitleList/TitleList.h"
12
12
13
+ #include " wxHelper.h"
14
+
13
15
#if BOOST_OS_LINUX || BOOST_OS_MACOS
14
16
#include " resource/embedded/resources.h"
15
17
#endif
@@ -89,10 +91,10 @@ void GraphicPacksWindow2::FillGraphicPackList() const
89
91
const auto parent_node = node;
90
92
if (i < (tokens.size () - 1 ))
91
93
{
92
- node = FindTreeItem (parent_node, wxString (token. data (), token. length () ));
94
+ node = FindTreeItem (parent_node, wxHelper::FromUtf8 (token));
93
95
if (!node.IsOk ())
94
96
{
95
- node = m_graphic_pack_tree->AppendItem (parent_node, wxString (token. data (), token. length () ));
97
+ node = m_graphic_pack_tree->AppendItem (parent_node, wxHelper::FromUtf8 (token));
96
98
}
97
99
}
98
100
else
@@ -101,9 +103,9 @@ void GraphicPacksWindow2::FillGraphicPackList() const
101
103
// if a node with same name already exists, add a number suffix
102
104
for (sint32 s = 0 ; s < 999 ; s++)
103
105
{
104
- wxString nodeName (token. data (), token. length () );
106
+ wxString nodeName = wxHelper::FromUtf8 (token );
105
107
if (s > 0 )
106
- nodeName.append (fmt::format (" #{}" , s + 1 ));
108
+ nodeName.append (wxHelper::FromUtf8 ( fmt::format (" #{}" , s + 1 ) ));
107
109
108
110
node = FindTreeItem (parent_node, nodeName);
109
111
if (!node.IsOk ())
@@ -218,7 +220,7 @@ GraphicPacksWindow2::GraphicPacksWindow2(wxWindow* parent, uint64_t title_id_fil
218
220
text->Wrap (-1 );
219
221
filter_row->Add (text, 0 , wxALIGN_CENTER_VERTICAL | wxALL, 5 );
220
222
221
- m_filter_text = new wxTextCtrl (left_panel, wxID_ANY, m_filter, wxDefaultPosition, wxDefaultSize, 0 );
223
+ m_filter_text = new wxTextCtrl (left_panel, wxID_ANY, wxHelper::FromUtf8 ( m_filter) , wxDefaultPosition, wxDefaultSize, 0 );
222
224
filter_row->Add (m_filter_text, 0 , wxALL | wxEXPAND, 5 );
223
225
m_filter_text->Bind (wxEVT_COMMAND_TEXT_UPDATED, &GraphicPacksWindow2::OnFilterUpdate, this );
224
226
@@ -386,28 +388,29 @@ void GraphicPacksWindow2::LoadPresetSelections(const GraphicPackPtr& gp)
386
388
{
387
389
continue ;
388
390
}
389
-
390
- wxString label (category.empty () ? _ (" Active preset" ) : wxString (category));
391
+
392
+ wxString categoryWxStr = wxHelper::FromUtf8 (category);
393
+ wxString label (category.empty () ? _ (" Active preset" ) : categoryWxStr);
391
394
auto * box = new wxStaticBox (m_preset_sizer->GetContainingWindow (), wxID_ANY, label);
392
395
auto * box_sizer = new wxStaticBoxSizer (box, wxVERTICAL);
393
396
394
397
auto * preset = new wxChoice (box, wxID_ANY);
395
- preset->SetClientObject (new wxStringClientData (category ));
398
+ preset->SetClientObject (new wxStringClientData (categoryWxStr ));
396
399
preset->Bind (wxEVT_CHOICE, &GraphicPacksWindow2::OnActivePresetChanged, this );
397
400
398
401
std::optional<std::string> active_preset;
399
402
for (auto & pentry : entry)
400
403
{
401
404
if (!pentry->visible )
402
405
continue ;
403
-
404
- preset->AppendString (pentry->name );
406
+
407
+ preset->AppendString (wxHelper::FromUtf8 ( pentry->name ) );
405
408
if (pentry->active )
406
409
active_preset = pentry->name ;
407
410
}
408
411
409
412
if (active_preset)
410
- preset->SetStringSelection (active_preset.value ());
413
+ preset->SetStringSelection (wxHelper::FromUtf8 ( active_preset.value () ));
411
414
else if (preset->GetCount () > 0 )
412
415
preset->SetSelection (0 );
413
416
@@ -439,14 +442,14 @@ void GraphicPacksWindow2::OnTreeSelectionChanged(wxTreeEvent& event)
439
442
{
440
443
m_preset_sizer->Clear (true );
441
444
m_gp_name = gp->GetName ();
442
- m_graphic_pack_name->SetLabel (m_gp_name);
445
+ m_graphic_pack_name->SetLabel (wxHelper::FromUtf8 ( m_gp_name) );
443
446
444
447
if (gp->GetDescription ().empty ())
445
448
m_gp_description = _ (" This graphic pack has no description" );
446
449
else
447
450
m_gp_description = gp->GetDescription ();
448
451
449
- m_graphic_pack_description->SetLabel (m_gp_description);
452
+ m_graphic_pack_description->SetLabel (wxHelper::FromUtf8 ( m_gp_description) );
450
453
451
454
LoadPresetSelections (gp);
452
455
@@ -567,8 +570,8 @@ void GraphicPacksWindow2::OnActivePresetChanged(wxCommandEvent& event)
567
570
wxASSERT (obj);
568
571
const auto string_data = dynamic_cast <wxStringClientData*>(obj->GetClientObject ());
569
572
wxASSERT (string_data);
570
- const auto preset = obj->GetStringSelection (). ToStdString ( );
571
- if (m_shown_graphic_pack->SetActivePreset (string_data->GetData (). c_str (). AsChar ( ), preset))
573
+ const auto preset = wxHelper::MakeUTF8 ( obj->GetStringSelection ());
574
+ if (m_shown_graphic_pack->SetActivePreset (wxHelper::MakeUTF8 ( string_data->GetData ()), preset))
572
575
{
573
576
wxWindowUpdateLocker lock (this );
574
577
ClearPresets ();
@@ -642,10 +645,10 @@ void GraphicPacksWindow2::OnSizeChanged(wxSizeEvent& event)
642
645
obj->SetSashPosition ((sint32)(m_ratio * width));
643
646
644
647
if (!m_gp_name.empty ())
645
- m_graphic_pack_name->SetLabel (m_gp_name);
648
+ m_graphic_pack_name->SetLabel (wxHelper::FromUtf8 ( m_gp_name) );
646
649
647
650
if (!m_gp_description.empty ())
648
- m_graphic_pack_description->SetLabel (m_gp_description);
651
+ m_graphic_pack_description->SetLabel (wxHelper::FromUtf8 ( m_gp_description) );
649
652
650
653
m_graphic_pack_name->Wrap (m_graphic_pack_name->GetParent ()->GetClientSize ().GetWidth () - 10 );
651
654
m_graphic_pack_description->Wrap (m_graphic_pack_description->GetParent ()->GetClientSize ().GetWidth () - 10 );
@@ -665,7 +668,7 @@ void GraphicPacksWindow2::SashPositionChanged(wxEvent& event)
665
668
666
669
void GraphicPacksWindow2::OnFilterUpdate (wxEvent& event)
667
670
{
668
- m_filter = m_filter_text->GetValue ();
671
+ m_filter = wxHelper::MakeUTF8 ( m_filter_text->GetValue () );
669
672
FillGraphicPackList ();
670
673
event.Skip ();
671
674
}
0 commit comments