27 changes: 13 additions & 14 deletions Source/Core/DolphinWX/Src/FrameTools.cpp
Expand Up @@ -101,7 +101,7 @@ void CFrame::CreateMenu()
drives = cdio_get_devices();
// Windows Limitation of 24 character drives
for (unsigned int i = 0; i < drives.size() && i < 24; i++) {
externalDrive->Append(IDM_DRIVE1 + i, wxString::FromAscii(drives[i].c_str()));
externalDrive->Append(IDM_DRIVE1 + i, StrToWxStr(drives[i]));
}

fileMenu->AppendSeparator();
Expand Down Expand Up @@ -601,12 +601,10 @@ void CFrame::DoOpen(bool Boot)

// Should we boot a new game or just change the disc?
if (Boot && !path.IsEmpty())
BootGame(std::string(path.mb_str()));
BootGame(WxStrToStr(path));
else
{
char newDiscpath[2048];
strncpy(newDiscpath, path.mb_str(), strlen(path.mb_str())+1);
DVDInterface::ChangeDisc(newDiscpath);
DVDInterface::ChangeDisc(WxStrToStr(path).c_str());
}
}

Expand Down Expand Up @@ -693,7 +691,7 @@ void CFrame::OnPlayRecording(wxCommandEvent& WXUNUSED (event))
GetMenuBar()->FindItem(IDM_RECORDREADONLY)->Check(true);
}

if(Movie::PlayInput(path.mb_str()))
if (Movie::PlayInput(WxStrToStr(path).c_str()))
BootGame(std::string(""));
}

Expand Down Expand Up @@ -1015,7 +1013,7 @@ void CFrame::DoStop()
X11Utils::InhibitScreensaver(X11Utils::XDisplayFromHandle(GetHandle()),
X11Utils::XWindowFromHandle(GetHandle()), false);
#endif
m_RenderFrame->SetTitle(wxString::FromAscii(scm_rev_str));
m_RenderFrame->SetTitle(StrToWxStr(scm_rev_str));

// Destroy the renderer frame when not rendering to main
m_RenderParent->Unbind(wxEVT_SIZE, &CFrame::OnRenderParentResize, this);
Expand Down Expand Up @@ -1081,7 +1079,7 @@ void CFrame::DoRecordingSave()
if(path.IsEmpty())
return;

Movie::SaveRecording(path.mb_str());
Movie::SaveRecording(WxStrToStr(path).c_str());

if (!paused)
DoPause();
Expand Down Expand Up @@ -1212,7 +1210,7 @@ void CFrame::StatusBarMessage(const char * Text, ...)
vsnprintf(Str, MAX_BYTES, Text, ArgPtr);
va_end(ArgPtr);

if (this->GetStatusBar()->IsEnabled()) this->GetStatusBar()->SetStatusText(wxString::FromAscii(Str),0);
if (this->GetStatusBar()->IsEnabled()) this->GetStatusBar()->SetStatusText(StrToWxStr(Str),0);
}


Expand Down Expand Up @@ -1248,7 +1246,8 @@ void CFrame::OnImportSave(wxCommandEvent& WXUNUSED (event))

if (!path.IsEmpty())
{
CWiiSaveCrypted* saveFile = new CWiiSaveCrypted(path.mb_str());
// TODO: Does this actually need to be dynamically allocated for some reason?
CWiiSaveCrypted* saveFile = new CWiiSaveCrypted(WxStrToStr(path).c_str());
delete saveFile;
}
}
Expand Down Expand Up @@ -1288,7 +1287,7 @@ void CFrame::OnInstallWAD(wxCommandEvent& event)
_T("Wii WAD file (*.wad)|*.wad"),
wxFD_OPEN | wxFD_PREVIEW | wxFD_FILE_MUST_EXIST,
this);
fileName = path.mb_str();
fileName = WxStrToStr(path);
break;
}
default:
Expand Down Expand Up @@ -1354,7 +1353,7 @@ void CFrame::ConnectWiimote(int wm_idx, bool connect)
GetUsbPointer()->AccessWiiMote(wm_idx | 0x100)->Activate(connect);
wxString msg(wxString::Format(wxT("Wiimote %i %s"), wm_idx + 1,
connect ? wxT("Connected") : wxT("Disconnected")));
Core::DisplayMessage(msg.ToAscii(), 3000);
Core::DisplayMessage(WxStrToStr(msg), 3000);
Host_UpdateMainFrame();
}
}
Expand Down Expand Up @@ -1394,7 +1393,7 @@ void CFrame::OnLoadStateFromFile(wxCommandEvent& WXUNUSED (event))
this);

if (!path.IsEmpty())
State::LoadAs((const char*)path.mb_str());
State::LoadAs(WxStrToStr(path));
}

void CFrame::OnSaveStateToFile(wxCommandEvent& WXUNUSED (event))
Expand All @@ -1408,7 +1407,7 @@ void CFrame::OnSaveStateToFile(wxCommandEvent& WXUNUSED (event))
this);

if (!path.IsEmpty())
State::SaveAs((const char*)path.mb_str());
State::SaveAs(WxStrToStr(path));
}

void CFrame::OnLoadLastState(wxCommandEvent& WXUNUSED (event))
Expand Down
118 changes: 32 additions & 86 deletions Source/Core/DolphinWX/Src/GameListCtrl.cpp
Expand Up @@ -257,7 +257,7 @@ void CGameListCtrl::BrowseForDirectory()

if (dialog.ShowModal() == wxID_OK)
{
std::string sPath(dialog.GetPath().mb_str());
std::string sPath(WxStrToStr(dialog.GetPath()));
std::vector<std::string>::iterator itResult = std::find(
SConfig::GetInstance().m_ISOFolder.begin(),
SConfig::GetInstance().m_ISOFolder.end(), sPath);
Expand Down Expand Up @@ -285,10 +285,6 @@ void CGameListCtrl::Update()
m_imageListSmall = NULL;
}

// NetPlay : Set/Reset the GameList string
m_gameList.clear();
m_gamePath.clear();

Hide();

ScanForISOs();
Expand Down Expand Up @@ -402,19 +398,10 @@ wxString NiceSizeFormat(s64 _size)
wxString NiceString;
char tempstr[32];
sprintf(tempstr,"%3.1f %s", f, sizes[s]);
NiceString = wxString::FromAscii(tempstr);
NiceString = StrToWxStr(tempstr);
return(NiceString);
}

std::string CGameListCtrl::GetGamePaths() const
{
return m_gamePath;
}
std::string CGameListCtrl::GetGameNames() const
{
return m_gameList;
}

void CGameListCtrl::InsertItemInReportView(long _Index)
{
// When using wxListCtrl, there is no hope of per-column text colors.
Expand All @@ -423,25 +410,7 @@ void CGameListCtrl::InsertItemInReportView(long _Index)
// company: 0x007030
int ImageIndex = -1;

#ifdef _WIN32
wxCSConv SJISConv(*(wxCSConv*)wxConvCurrent);
static bool validCP932 = ::IsValidCodePage(932) != 0;
if (validCP932)
{
SJISConv = wxCSConv(wxFontMapper::GetEncodingName(wxFONTENCODING_SHIFT_JIS));
}
else
{
WARN_LOG(COMMON, "Cannot Convert from Charset Windows Japanese cp 932");
}
#else
// on linux the wrong string is returned from wxFontMapper::GetEncodingName(wxFONTENCODING_SHIFT_JIS)
// it returns CP-932, in order to use iconv we need to use CP932
wxCSConv SJISConv(wxT("CP932"));
#endif

GameListItem& rISOFile = *m_ISOFiles[_Index];
m_gamePath.append(rISOFile.GetFileName() + '\n');

// Insert a first row with nothing in it, that will be used as the Index
long ItemIndex = InsertItem(_Index, wxEmptyString);
Expand All @@ -454,55 +423,33 @@ void CGameListCtrl::InsertItemInReportView(long _Index)

// Set the game's banner in the second column
SetItemColumnImage(_Index, COLUMN_BANNER, ImageIndex);

std::wstring wstring_name;
const std::wstring& wstring_description = rISOFile.GetDescription();
std::string company;

wxString name;
wxString description;

// We show the company string on Gamecube only
// On Wii we show the description instead as the company string is empty
if (rISOFile.GetPlatform() == GameListItem::GAMECUBE_DISC)
company = rISOFile.GetCompany().c_str();
int SelectedLanguage = SConfig::GetInstance().m_LocalCoreStartupParameter.SelectedLanguage;

// Is this sane?
switch (rISOFile.GetCountry())
{
case DiscIO::IVolume::COUNTRY_TAIWAN:
case DiscIO::IVolume::COUNTRY_JAPAN:
{
rISOFile.GetName(wstring_name, -1);
name = wxString(rISOFile.GetName(0).c_str(), SJISConv);
m_gameList.append(StringFromFormat("%s (J)\n", (const char *)name.c_str()));
description = wxString(company.size() ? company.c_str() :
rISOFile.GetDescription(0).c_str(), SJISConv);
}
SelectedLanguage = -1;
break;

case DiscIO::IVolume::COUNTRY_USA:
SelectedLanguage = 0;
break;

default:
{
wxCSConv WindowsCP1252(wxFontMapper::GetEncodingName(wxFONTENCODING_CP1252));
rISOFile.GetName(wstring_name, SelectedLanguage);

name = wxString(rISOFile.GetName(SelectedLanguage).c_str(), WindowsCP1252);
m_gameList.append(StringFromFormat("%s (%c)\n",
rISOFile.GetName(SelectedLanguage).c_str(),
(rISOFile.GetCountry() == DiscIO::IVolume::COUNTRY_USA) ? 'U' : 'E'));
description = wxString(company.size() ? company.c_str() :
rISOFile.GetDescription(SelectedLanguage).c_str(), WindowsCP1252);
}
break;
}

std::string const name = rISOFile.GetName(SelectedLanguage);
SetItem(_Index, COLUMN_TITLE, StrToWxStr(name), -1);

if (wstring_name.length())
name = wstring_name.c_str();
if (wstring_description.length())
description = wstring_description.c_str();

SetItem(_Index, COLUMN_TITLE, name, -1);
SetItem(_Index, COLUMN_NOTES, description, -1);
// We show the company string on Gamecube only
// On Wii we show the description instead as the company string is empty
std::string const notes = (rISOFile.GetPlatform() == GameListItem::GAMECUBE_DISC) ?
rISOFile.GetCompany() : rISOFile.GetDescription(SelectedLanguage);
SetItem(_Index, COLUMN_NOTES, StrToWxStr(notes), -1);

// Emulation state
SetItemColumnImage(_Index, COLUMN_EMULATION_STATE, m_EmuStateImageIndex[rISOFile.GetEmuState()]);
Expand Down Expand Up @@ -614,7 +561,7 @@ void CGameListCtrl::ScanForISOs()

// Update with the progress (i) and the message
dialog.Update(i, wxString::Format(_("Scanning %s"),
wxString(FileName.c_str(), *wxConvCurrent).c_str()));
StrToWxStr(FileName)));
if (dialog.WasCancelled())
break;

Expand Down Expand Up @@ -858,7 +805,7 @@ void CGameListCtrl::OnMouseMotion(wxMouseEvent& event)
char temp[2048];
sprintf(temp, "^ %s%s%s", emuState[emu_state - 1],
issues.size() > 0 ? " :\n" : "", issues.c_str());
toolTip = new wxEmuStateTip(this, wxString(temp, *wxConvCurrent), &toolTip);
toolTip = new wxEmuStateTip(this, StrToWxStr(temp), &toolTip);
}
else
toolTip = new wxEmuStateTip(this, _("Not Set"), &toolTip);
Expand Down Expand Up @@ -999,8 +946,7 @@ void CGameListCtrl::OnOpenContainingFolder(wxCommandEvent& WXUNUSED (event))
if (!iso)
return;

wxString strPath(iso->GetFileName().c_str(), wxConvUTF8);
wxFileName path = wxFileName::FileName(strPath);
wxFileName path = wxFileName::FileName(StrToWxStr(iso->GetFileName()));
path.MakeAbsolute();
WxUtils::Explore(path.GetPath().char_str());
}
Expand Down Expand Up @@ -1115,9 +1061,9 @@ void CGameListCtrl::OnWiki(wxCommandEvent& WXUNUSED (event))
void CGameListCtrl::MultiCompressCB(const char* text, float percent, void* arg)
{
percent = (((float)m_currentItem) + percent) / (float)m_numberItem;
wxString textString(StringFromFormat("%s (%i/%i) - %s",
wxString textString(StrToWxStr(StringFromFormat("%s (%i/%i) - %s",
m_currentFilename.c_str(), (int)m_currentItem+1,
(int)m_numberItem, text).c_str(), *wxConvCurrent);
(int)m_numberItem, text)));

((wxProgressDialog*)arg)->Update((int)(percent*1000), textString);
}
Expand Down Expand Up @@ -1170,13 +1116,13 @@ void CGameListCtrl::CompressSelection(bool _compress)

std::string OutputFileName;
BuildCompleteFilename(OutputFileName,
(const char *)browseDialog.GetPath().mb_str(wxConvUTF8),
WxStrToStr(browseDialog.GetPath()),
FileName);

if (wxFileExists(wxString::FromAscii(OutputFileName.c_str())) &&
if (wxFileExists(StrToWxStr(OutputFileName)) &&
wxMessageBox(
wxString::Format(_("The file %s already exists.\nDo you wish to replace it?"),
wxString(OutputFileName.c_str(), *wxConvCurrent).c_str()),
StrToWxStr(OutputFileName)),
_("Confirm File Overwrite"),
wxYES_NO) == wxNO)
continue;
Expand All @@ -1198,13 +1144,13 @@ void CGameListCtrl::CompressSelection(bool _compress)

std::string OutputFileName;
BuildCompleteFilename(OutputFileName,
(const char *)browseDialog.GetPath().mb_str(wxConvUTF8),
WxStrToStr(browseDialog.GetPath()),
FileName);

if (wxFileExists(wxString::FromAscii(OutputFileName.c_str())) &&
if (wxFileExists(StrToWxStr(OutputFileName)) &&
wxMessageBox(
wxString::Format(_("The file %s already exists.\nDo you wish to replace it?"),
wxString(OutputFileName.c_str(), *wxConvCurrent).c_str()),
StrToWxStr(OutputFileName)),
_("Confirm File Overwrite"),
wxYES_NO) == wxNO)
continue;
Expand All @@ -1225,7 +1171,7 @@ void CGameListCtrl::CompressSelection(bool _compress)
void CGameListCtrl::CompressCB(const char* text, float percent, void* arg)
{
((wxProgressDialog*)arg)->
Update((int)(percent*1000), wxString(text, *wxConvCurrent));
Update((int)(percent*1000), StrToWxStr(text));
}

void CGameListCtrl::OnCompressGCM(wxCommandEvent& WXUNUSED (event))
Expand All @@ -1251,8 +1197,8 @@ void CGameListCtrl::OnCompressGCM(wxCommandEvent& WXUNUSED (event))

path = wxFileSelector(
_("Save decompressed GCM/ISO"),
wxString(FilePath.c_str(), *wxConvCurrent),
wxString(FileName.c_str(), *wxConvCurrent) + FileType.After('*'),
StrToWxStr(FilePath),
StrToWxStr(FileName) + FileType.After('*'),
wxEmptyString,
FileType + wxT("|") + wxGetTranslation(wxALL_FILES),
wxFD_SAVE,
Expand All @@ -1262,8 +1208,8 @@ void CGameListCtrl::OnCompressGCM(wxCommandEvent& WXUNUSED (event))
{
path = wxFileSelector(
_("Save compressed GCM/ISO"),
wxString(FilePath.c_str(), *wxConvCurrent),
wxString(FileName.c_str(), *wxConvCurrent) + _T(".gcz"),
StrToWxStr(FilePath),
StrToWxStr(FileName) + _T(".gcz"),
wxEmptyString,
_("All compressed GC/Wii ISO files (gcz)") +
wxString::Format(wxT("|*.gcz|%s"), wxGetTranslation(wxALL_FILES)),
Expand Down
8 changes: 0 additions & 8 deletions Source/Core/DolphinWX/Src/GameListCtrl.h
Expand Up @@ -47,10 +47,6 @@ class CGameListCtrl : public wxListCtrl

void Update();

// Net Play method
std::string GetGamePaths() const;
std::string GetGameNames() const;

void BrowseForDirectory();
const GameListItem *GetSelectedISO();
const GameListItem *GetISO(size_t index) const;
Expand Down Expand Up @@ -84,10 +80,6 @@ class CGameListCtrl : public wxListCtrl
}
}

// NetPlay string for the gamelist
std::string m_gameList;
std::string m_gamePath;

int last_column;
int last_sort;
wxSize lastpos;
Expand Down
9 changes: 5 additions & 4 deletions Source/Core/DolphinWX/Src/GeckoCodeDiag.cpp
Expand Up @@ -13,6 +13,7 @@
// If not, see http://www.gnu.org/licenses/

#include "GeckoCodeDiag.h"
#include "WxUtils.h"

#include <SFML/Network/Http.hpp>

Expand Down Expand Up @@ -76,7 +77,7 @@ void CodeConfigPanel::UpdateCodeList()
gcodes_end = m_gcodes.end();
for (; gcodes_iter!=gcodes_end; ++gcodes_iter)
{
m_listbox_gcodes->Append(wxString(gcodes_iter->name.c_str(), *wxConvCurrent));
m_listbox_gcodes->Append(StrToWxStr(gcodes_iter->name));
if (gcodes_iter->enabled)
m_listbox_gcodes->Check(m_listbox_gcodes->GetCount()-1, true);
}
Expand Down Expand Up @@ -109,18 +110,18 @@ void CodeConfigPanel::UpdateInfoBox(wxCommandEvent&)

if (sel > -1)
{
m_infobox.label_name->SetLabel(wxGetTranslation(wxstr_name) + wxString(m_gcodes[sel].name.c_str(), *wxConvCurrent));
m_infobox.label_name->SetLabel(wxGetTranslation(wxstr_name) + StrToWxStr(m_gcodes[sel].name));

// notes textctrl
m_infobox.textctrl_notes->Clear();
std::vector<std::string>::const_iterator
notes_iter = m_gcodes[sel].notes.begin(),
notes_end = m_gcodes[sel].notes.end();
for (; notes_iter!=notes_end; ++notes_iter)
m_infobox.textctrl_notes->AppendText(wxString(notes_iter->c_str(), *wxConvCurrent));
m_infobox.textctrl_notes->AppendText(StrToWxStr(*notes_iter));
m_infobox.textctrl_notes->ScrollLines(-99); // silly

m_infobox.label_creator->SetLabel(wxGetTranslation(wxstr_creator) + wxString(m_gcodes[sel].creator.c_str(), *wxConvCurrent));
m_infobox.label_creator->SetLabel(wxGetTranslation(wxstr_creator) + StrToWxStr(m_gcodes[sel].creator));

// add codes to info listbox
std::vector<GeckoCode::Code>::const_iterator
Expand Down
166 changes: 65 additions & 101 deletions Source/Core/DolphinWX/Src/ISOFile.cpp
Expand Up @@ -28,6 +28,7 @@
#include "StringUtil.h"
#include "Hash.h"
#include "IniFile.h"
#include "WxUtils.h"

#include "Filesystem.h"
#include "BannerLoader.h"
Expand All @@ -36,7 +37,7 @@
#include "ChunkFile.h"
#include "ConfigManager.h"

#define CACHE_REVISION 0x110
#define CACHE_REVISION 0x112

#define DVD_BANNER_WIDTH 96
#define DVD_BANNER_HEIGHT 32
Expand Down Expand Up @@ -65,26 +66,10 @@ GameListItem::GameListItem(const std::string& _rFileName)
else
{
m_Platform = WII_WAD;
pVolume->GetWName(m_wNames);
}

m_Company = "N/A";
m_volume_names = pVolume->GetNames();


m_Name[0] = pVolume->GetName();

if(m_Name[0] == "") // Couldn't find the name in the WAD...
{
std::string FileName;
SplitPath(m_FileName, NULL, &FileName, NULL);
m_Name[0] = FileName; // Then just display the filename... Better than something like "No Name"
}

for (int i = 0; i < 6; i++)
{
m_Name[i] = m_Name[0];
m_Description[i] = "No Description";
}
m_Country = pVolume->GetCountry();
m_FileSize = File::GetSize(_rFileName);
m_VolumeSize = pVolume->GetSize();
Expand All @@ -104,12 +89,9 @@ GameListItem::GameListItem(const std::string& _rFileName)
{
if (pBannerLoader->IsValid())
{
m_wNames.clear();
pBannerLoader->GetName(m_wNames);
pBannerLoader->GetName(m_Name);
pBannerLoader->GetCompany(m_Company);
pBannerLoader->GetDescription(m_wDescription);
pBannerLoader->GetDescription(m_Description);
m_names = pBannerLoader->GetNames();
m_company = pBannerLoader->GetCompany();
m_descriptions = pBannerLoader->GetDescriptions();

if (pBannerLoader->GetBanner(g_ImageTemp))
{
Expand All @@ -129,25 +111,6 @@ GameListItem::GameListItem(const std::string& _rFileName)

delete pFileSystem;
}
std::vector<std::wstring>::iterator i, end = m_wNames.end();
std::wstring wFileName;
for (i = m_wNames.begin(); i != end; ++i)
{
if (*i == L"")
{
if (!wFileName.length())
{
std::string FileName;
SplitPath(m_FileName, NULL, &FileName, NULL);
int length = FileName.length();
wFileName.reserve(length+1);
for (int j = 0; j < length; ++j)
wFileName.push_back(FileName[j]);
wFileName.push_back(0);
}
*i = wFileName;
}
}

delete pVolume;

Expand Down Expand Up @@ -208,33 +171,10 @@ void GameListItem::SaveToCache()

void GameListItem::DoState(PointerWrap &p)
{
p.Do(m_Name[0]); p.Do(m_Name[1]); p.Do(m_Name[2]);
p.Do(m_Name[3]); p.Do(m_Name[4]); p.Do(m_Name[5]);

int wNamesSize = m_wNames.size();
p.Do(wNamesSize);

if (p.mode == p.MODE_READ)
{
for (int i = 0; i < wNamesSize; ++i)
{
std::wstring temp;
p.Do(temp);
m_wNames.push_back(temp);
}
}
else
{
for (int i = 0; i < wNamesSize; ++i)
{
p.Do(m_wNames[i]);
}
}

p.Do(m_Company);
p.Do(m_Description[0]); p.Do(m_Description[1]); p.Do(m_Description[2]);
p.Do(m_Description[3]); p.Do(m_Description[4]); p.Do(m_Description[5]);
p.Do(m_wDescription);
p.Do(m_volume_names);
p.Do(m_company);
p.Do(m_names);
p.Do(m_descriptions);
p.Do(m_UniqueID);
p.Do(m_FileSize);
p.Do(m_VolumeSize);
Expand Down Expand Up @@ -263,49 +203,73 @@ std::string GameListItem::CreateCacheFilename()
return fullname;
}

const std::string& GameListItem::GetDescription(int index) const
std::string GameListItem::GetCompany() const
{
if ((index >=0) && (index < 6))
{
return m_Description[index];
}
return m_Description[0];
if (m_company.empty())
return "N/A";
else
return m_company;
}

const std::wstring& GameListItem::GetDescription() const
// (-1 = Japanese, 0 = English, etc)
std::string GameListItem::GetDescription(int _index) const
{
return m_wDescription;
const u32 index = _index + 1;

if (index < m_descriptions.size())
return m_descriptions[index];

if (!m_descriptions.empty())
return m_descriptions[0];

return "";
}

const std::string& GameListItem::GetName(int index) const
// (-1 = Japanese, 0 = English, etc)
std::string GameListItem::GetVolumeName(int _index) const
{
if ((index >=0) && (index < 6))
{
return m_Name[index];
}
return m_Name[0];
u32 const index = _index + 1;

if (index < m_volume_names.size() && !m_volume_names[index].empty())
return m_volume_names[index];

if (!m_volume_names.empty())
return m_volume_names[0];

return "";
}

bool GameListItem::GetName(std::wstring& wName, int index) const
// (-1 = Japanese, 0 = English, etc)
std::string GameListItem::GetBannerName(int _index) const
{
// This function will only succeed for wii discs with banners or WADs
// utilize the same array as for gc discs (-1= Japanese, 0 = English etc
index++;
if ((index >= 0) && (index < 10))
{
if (m_wNames.size() > (size_t)index)
{
wName = m_wNames[index];
return true;
}
}
if (m_wNames.size() > 0)
u32 const index = _index + 1;

if (index < m_names.size() && !m_names[index].empty())
return m_names[index];

if (!m_names.empty())
return m_names[0];

return "";
}

// (-1 = Japanese, 0 = English, etc)
std::string GameListItem::GetName(int _index) const
{
// Prefer name from banner, fallback to name from volume, fallback to filename

std::string name = GetBannerName(_index);

if (name.empty())
name = GetVolumeName(_index);

if (name.empty())
{
wName = m_wNames[0];
return true;
// No usable name, return filename (better than nothing)
SplitPath(GetFileName(), NULL, &name, NULL);
}
return false;

return name;
}

const std::string GameListItem::GetWiiFSPath() const
Expand All @@ -331,7 +295,7 @@ const std::string GameListItem::GetWiiFSPath() const
File::CreateFullPath(Path);

if (Path[0] == '.')
ret = std::string(wxGetCwd().mb_str()) + std::string(Path).substr(strlen(ROOT_DIR));
ret = WxStrToStr(wxGetCwd()) + std::string(Path).substr(strlen(ROOT_DIR));
else
ret = std::string(Path);
}
Expand Down
27 changes: 17 additions & 10 deletions Source/Core/DolphinWX/Src/ISOFile.h
Expand Up @@ -18,6 +18,9 @@
#ifndef __ISOFILE_H_
#define __ISOFILE_H_

#include <vector>
#include <string>

#include "Volume.h"
#include "VolumeCreator.h"

Expand All @@ -34,11 +37,11 @@ class GameListItem : NonCopyable

bool IsValid() const {return m_Valid;}
const std::string& GetFileName() const {return m_FileName;}
const std::string& GetName(int index) const;
bool GetName(std::wstring& wName, int index=0) const;
const std::string& GetCompany() const {return m_Company;}
const std::string& GetDescription(int index) const;
const std::wstring& GetDescription() const;
std::string GetBannerName(int index) const;
std::string GetVolumeName(int index) const;
std::string GetName(int index) const;
std::string GetCompany() const;
std::string GetDescription(int index = 0) const;
const std::string& GetUniqueID() const {return m_UniqueID;}
const std::string GetWiiFSPath() const;
DiscIO::IVolume::ECountry GetCountry() const {return m_Country;}
Expand All @@ -65,11 +68,15 @@ class GameListItem : NonCopyable

private:
std::string m_FileName;
std::string m_Name[6];
std::vector<std::wstring> m_wNames;
std::string m_Company;
std::string m_Description[6];
std::wstring m_wDescription;

// TODO: eliminate this and overwrite with names from banner when available?
std::vector<std::string> m_volume_names;

// Stuff from banner
std::string m_company;
std::vector<std::string> m_names;
std::vector<std::string> m_descriptions;

std::string m_UniqueID;

std::string m_issues;
Expand Down
116 changes: 41 additions & 75 deletions Source/Core/DolphinWX/Src/ISOProperties.cpp
Expand Up @@ -23,6 +23,7 @@
#include "CommonPaths.h"
#include "Globals.h"

#include "WxUtils.h"
#include "VolumeCreator.h"
#include "Filesystem.h"
#include "ISOProperties.h"
Expand Down Expand Up @@ -136,7 +137,8 @@ CISOProperties::CISOProperties(const std::string fileName, wxWindow* parent, wxW
else
{
// Will fail out if GameConfig folder doesn't exist
std::ofstream f(GameIniFile.c_str());
std::ofstream f;
OpenFStream(f, GameIniFile, std::ios_base::out);
if (f)
{
f << "# " << OpenISO->GetUniqueID() << " - " << OpenISO->GetName() << '\n'
Expand All @@ -150,21 +152,14 @@ CISOProperties::CISOProperties(const std::string fileName, wxWindow* parent, wxW
LoadGameConfig();
else
wxMessageBox(wxString::Format(_("Could not create %s"),
wxString::From8BitData(GameIniFile.c_str()).c_str()),
StrToWxStr(GameIniFile).c_str()),
_("Error"), wxOK|wxICON_ERROR, this);
}

// Disk header and apploader

std::wstring wname;
wxString name;
if (OpenGameListItem->GetName(wname))
name = wname.c_str();
else
name = wxString(OpenISO->GetName().c_str(), wxConvUTF8);
m_Name->SetValue(name);

m_GameID->SetValue(wxString(OpenISO->GetUniqueID().c_str(), wxConvUTF8));
m_Name->SetValue(StrToWxStr(OpenISO->GetName()));
m_GameID->SetValue(StrToWxStr(OpenISO->GetUniqueID()));
switch (OpenISO->GetCountry())
{
case DiscIO::IVolume::COUNTRY_EUROPE:
Expand Down Expand Up @@ -204,9 +199,9 @@ CISOProperties::CISOProperties(const std::string fileName, wxWindow* parent, wxW
m_Country->SetValue(_("UNKNOWN"));
break;
}
wxString temp = _T("0x") + wxString::From8BitData(OpenISO->GetMakerID().c_str());
wxString temp = _T("0x") + StrToWxStr(OpenISO->GetMakerID());
m_MakerID->SetValue(temp);
m_Date->SetValue(wxString::From8BitData(OpenISO->GetApploaderDate().c_str()));
m_Date->SetValue(StrToWxStr(OpenISO->GetApploaderDate()));
m_FST->SetValue(wxString::Format(wxT("%u"), OpenISO->GetFSTSize()));

// Here we set all the info to be shown (be it SJIS or Ascii) + we set the window title
Expand Down Expand Up @@ -271,12 +266,12 @@ size_t CISOProperties::CreateDirectoryTree(wxTreeItemId& parent,
// check next index
if (rFileInfo->IsDirectory())
{
wxTreeItemId item = m_Treectrl->AppendItem(parent, wxString::From8BitData(itemName), 1, 1);
wxTreeItemId item = m_Treectrl->AppendItem(parent, StrToWxStr(itemName), 1, 1);
CurrentIndex = CreateDirectoryTree(item, fileInfos, CurrentIndex + 1, (size_t)rFileInfo->m_FileSize);
}
else
{
m_Treectrl->AppendItem(parent, wxString::From8BitData(itemName), 2, 2);
m_Treectrl->AppendItem(parent, StrToWxStr(itemName), 2, 2);
CurrentIndex++;
}
}
Expand Down Expand Up @@ -663,10 +658,10 @@ void CISOProperties::OnExtractFile(wxCommandEvent& WXUNUSED (event))
{
int partitionNum = wxAtoi(File.SubString(10, 11));
File.Remove(0, 12); // Remove "Partition x/"
WiiDisc.at(partitionNum).FileSystem->ExportFile(File.mb_str(), Path.mb_str());
WiiDisc.at(partitionNum).FileSystem->ExportFile(WxStrToStr(File).c_str(), WxStrToStr(Path).c_str());
}
else
pFileSystem->ExportFile(File.mb_str(), Path.mb_str());
pFileSystem->ExportFile(WxStrToStr(File).c_str(), WxStrToStr(Path).c_str());
}

void CISOProperties::ExportDir(const char* _rFullPath, const char* _rExportFolder, const int partitionNum)
Expand Down Expand Up @@ -727,7 +722,7 @@ void CISOProperties::ExportDir(const char* _rFullPath, const char* _rExportFolde
(u32)(((float)(i - index[0]) / (float)(index[1] - index[0])) * 100)));

dialog.Update(i, wxString::Format(_("Extracting %s"),
wxString(fst[i]->m_FullPath, *wxConvCurrent).c_str()));
StrToWxStr(fst[i]->m_FullPath)));

if (dialog.WasCancelled())
break;
Expand Down Expand Up @@ -778,9 +773,9 @@ void CISOProperties::OnExtractDir(wxCommandEvent& event)
{
if (DiscIO::IsVolumeWiiDisc(OpenISO))
for (u32 i = 0; i < WiiDisc.size(); i++)
ExportDir(NULL, Path.mb_str(), i);
ExportDir(NULL, WxStrToStr(Path).c_str(), i);
else
ExportDir(NULL, Path.mb_str());
ExportDir(NULL, WxStrToStr(Path).c_str());

return;
}
Expand All @@ -798,10 +793,10 @@ void CISOProperties::OnExtractDir(wxCommandEvent& event)
{
int partitionNum = wxAtoi(Directory.SubString(10, 11));
Directory.Remove(0, 12); // Remove "Partition x/"
ExportDir(Directory.mb_str(), Path.mb_str(), partitionNum);
ExportDir(WxStrToStr(Directory).c_str(), WxStrToStr(Path).c_str(), partitionNum);
}
else
ExportDir(Directory.mb_str(), Path.mb_str());
ExportDir(WxStrToStr(Directory).c_str(), WxStrToStr(Path).c_str());
}

void CISOProperties::OnExtractDataFromHeader(wxCommandEvent& event)
Expand All @@ -821,15 +816,15 @@ void CISOProperties::OnExtractDataFromHeader(wxCommandEvent& event)
bool ret = false;
if (event.GetId() == IDM_EXTRACTAPPLOADER)
{
ret = FS->ExportApploader(Path.mb_str());
ret = FS->ExportApploader(WxStrToStr(Path).c_str());
}
else if (event.GetId() == IDM_EXTRACTDOL)
{
ret = FS->ExportDOL(Path.mb_str());
ret = FS->ExportDOL(WxStrToStr(Path).c_str());
}

if (!ret)
PanicAlertT("Failed to extract to %s!", (const char *)Path.mb_str());
PanicAlertT("Failed to extract to %s!", WxStrToStr(Path).c_str());
}

class IntegrityCheckThread : public wxThread
Expand Down Expand Up @@ -989,7 +984,7 @@ void CISOProperties::LoadGameConfig()
GameIni.Get("EmuState", "EmulationIssues", &sTemp);
if (!sTemp.empty())
{
EmuIssues->SetValue(wxString(sTemp.c_str(), *wxConvCurrent));
EmuIssues->SetValue(StrToWxStr(sTemp));
}
EmuIssues->Enable(EmuState->GetSelection() != 0);

Expand Down Expand Up @@ -1075,7 +1070,7 @@ bool CISOProperties::SaveGameConfig()
GameIni.Get("EmuState","EmulationIssues", &sTemp);
if (EmuIssues->GetValue() != sTemp)
bRefreshList = true;
GameIni.Set("EmuState", "EmulationIssues", (const char*)EmuIssues->GetValue().mb_str(*wxConvCurrent));
GameIni.Set("EmuState", "EmulationIssues", WxStrToStr(EmuIssues->GetValue()));

PatchList_Save();
ActionReplayList_Save();
Expand All @@ -1086,7 +1081,7 @@ bool CISOProperties::SaveGameConfig()

void CISOProperties::OnEditConfig(wxCommandEvent& WXUNUSED (event))
{
if (wxFileExists(wxString::From8BitData(GameIniFile.c_str())))
if (File::Exists(GameIniFile))
{
SaveGameConfig();

Expand All @@ -1107,7 +1102,7 @@ void CISOProperties::OnEditConfig(wxCommandEvent& WXUNUSED (event))
}
}
wxString OpenCommand;
OpenCommand = filetype->GetOpenCommand(wxString::From8BitData(GameIniFile.c_str()));
OpenCommand = filetype->GetOpenCommand(StrToWxStr(GameIniFile));
if(OpenCommand.IsEmpty())
PanicAlertT("Couldn't find open command for extension 'ini'!");
else
Expand Down Expand Up @@ -1156,7 +1151,7 @@ void CISOProperties::PatchList_Load()
for (std::vector<PatchEngine::Patch>::const_iterator it = onFrame.begin(); it != onFrame.end(); ++it)
{
PatchEngine::Patch p = *it;
Patches->Append(wxString(p.name.c_str(), *wxConvCurrent));
Patches->Append(StrToWxStr(p.name));
Patches->Check(index, p.active);
++index;
}
Expand Down Expand Up @@ -1209,7 +1204,7 @@ void CISOProperties::PatchButtonClicked(wxCommandEvent& event)
CPatchAddEdit dlg(-1, this, 1, _("Add Patch"));
if (dlg.ShowModal() == wxID_OK)
{
Patches->Append(wxString(onFrame.back().name.c_str(), *wxConvCurrent));
Patches->Append(StrToWxStr(onFrame.back().name));
Patches->Check((unsigned int)(onFrame.size() - 1), onFrame.back().active);
}
}
Expand Down Expand Up @@ -1238,7 +1233,7 @@ void CISOProperties::ActionReplayList_Load()
for (std::vector<ActionReplay::ARCode>::const_iterator it = arCodes.begin(); it != arCodes.end(); ++it)
{
ActionReplay::ARCode arCode = *it;
Cheats->Append(wxString(arCode.name.c_str(), *wxConvCurrent));
Cheats->Append(StrToWxStr(arCode.name));
Cheats->Check(index, arCode.active);
++index;
}
Expand All @@ -1256,7 +1251,7 @@ void CISOProperties::ActionReplayList_Save()

for (std::vector<ActionReplay::AREntry>::const_iterator iter2 = code.ops.begin(); iter2 != code.ops.end(); ++iter2)
{
lines.push_back(std::string(wxString::Format(wxT("%08X %08X"), iter2->cmd_addr, iter2->value).mb_str()));
lines.push_back(WxStrToStr(wxString::Format(wxT("%08X %08X"), iter2->cmd_addr, iter2->value)));
}
++index;
}
Expand All @@ -1280,7 +1275,7 @@ void CISOProperties::ActionReplayButtonClicked(wxCommandEvent& event)
CARCodeAddEdit dlg(-1, this, 1, _("Add ActionReplay Code"));
if (dlg.ShowModal() == wxID_OK)
{
Cheats->Append(wxString::From8BitData(arCodes.back().name.c_str()));
Cheats->Append(StrToWxStr(arCodes.back().name));
Cheats->Check((unsigned int)(arCodes.size() - 1), arCodes.back().active);
}
}
Expand All @@ -1306,56 +1301,26 @@ void CISOProperties::OnChangeBannerLang(wxCommandEvent& event)

void CISOProperties::ChangeBannerDetails(int lang)
{
std::wstring wname;
wxString shortName,
comment,
maker;

#ifdef _WIN32
wxCSConv SJISConv(*(wxCSConv*)wxConvCurrent);
static bool validCP932 = ::IsValidCodePage(932) != 0;
if (validCP932)
{
SJISConv = wxCSConv(wxFontMapper::GetEncodingName(wxFONTENCODING_SHIFT_JIS));
}
else
{
WARN_LOG(COMMON, "Cannot Convert from Charset Windows Japanese cp 932");
}
#else
// on linux the wrong string is returned from wxFontMapper::GetEncodingName(wxFONTENCODING_SHIFT_JIS)
// it returns CP-932, in order to use iconv we need to use CP932
wxCSConv SJISConv(wxT("CP932"));
#endif
// why?
switch (OpenGameListItem->GetCountry())
{
case DiscIO::IVolume::COUNTRY_TAIWAN:
case DiscIO::IVolume::COUNTRY_JAPAN:

if (OpenGameListItem->GetName(wname, -1))
shortName = wname.c_str();
else
shortName = wxString(OpenGameListItem->GetName(0).c_str(), SJISConv);

if ((comment = OpenGameListItem->GetDescription().c_str()).size() == 0)
comment = wxString(OpenGameListItem->GetDescription(0).c_str(), SJISConv);
maker = wxString(OpenGameListItem->GetCompany().c_str(), SJISConv);
lang = -1;
break;

case DiscIO::IVolume::COUNTRY_USA:
lang = 0;
break;

default:
{
wxCSConv WindowsCP1252(wxFontMapper::GetEncodingName(wxFONTENCODING_CP1252));
if (OpenGameListItem->GetName(wname, lang))
shortName = wname.c_str();
else
shortName = wxString(OpenGameListItem->GetName(lang).c_str(), WindowsCP1252);
if ((comment = OpenGameListItem->GetDescription().c_str()).size() == 0)
comment = wxString(OpenGameListItem->GetDescription(lang).c_str(), WindowsCP1252);
maker = wxString(OpenGameListItem->GetCompany().c_str(), WindowsCP1252);
}
break;
}

wxString const shortName = StrToWxStr(OpenGameListItem->GetBannerName(lang));
wxString const comment = StrToWxStr(OpenGameListItem->GetDescription(lang));
wxString const maker = StrToWxStr(OpenGameListItem->GetCompany());

// Updates the informations shown in the window
m_ShortName->SetValue(shortName);
m_Comment->SetValue(comment);
Expand All @@ -1364,5 +1329,6 @@ void CISOProperties::ChangeBannerDetails(int lang)
std::string filename, extension;
SplitPath(OpenGameListItem->GetFileName(), 0, &filename, &extension);
// Also sets the window's title
SetTitle(wxString(StringFromFormat("%s%s: %s - ", filename.c_str(), extension.c_str(), OpenGameListItem->GetUniqueID().c_str()).c_str(), *wxConvCurrent)+shortName);
SetTitle(StrToWxStr(StringFromFormat("%s%s: %s - ", filename.c_str(),
extension.c_str(), OpenGameListItem->GetUniqueID().c_str())) + shortName);
}
75 changes: 36 additions & 39 deletions Source/Core/DolphinWX/Src/InputConfigDiag.cpp
Expand Up @@ -17,10 +17,7 @@

#include "InputConfigDiag.h"
#include "UDPConfigDiag.h"

#define WXSTR_FROM_STR(s) (wxString::FromUTF8((s).c_str()))
#define WXTSTR_FROM_CSTR(s) (wxGetTranslation(wxString::FromUTF8(s)))
#define STR_FROM_WXSTR(w) (std::string((w).ToUTF8()))
#include "WxUtils.h"

void GamepadPage::ConfigUDPWii(wxCommandEvent &event)
{
Expand All @@ -37,7 +34,7 @@ void GamepadPage::ConfigExtension(wxCommandEvent& event)
if (ex->switch_extension)
{
wxDialog dlg(this, -1,
WXTSTR_FROM_CSTR(ex->attachments[ex->switch_extension]->GetName().c_str()),
StrToWxStr(ex->attachments[ex->switch_extension]->GetName()),
wxDefaultPosition, wxDefaultSize);

wxBoxSizer* const main_szr = new wxBoxSizer(wxVERTICAL);
Expand Down Expand Up @@ -67,7 +64,7 @@ PadSettingExtension::PadSettingExtension(wxWindow* const parent, ControllerEmu::
e = extension->attachments.end();

for (; i!=e; ++i)
((wxChoice*)wxcontrol)->Append(WXTSTR_FROM_CSTR((*i)->GetName().c_str()));
((wxChoice*)wxcontrol)->Append(StrToWxStr((*i)->GetName()));

UpdateGUI();
}
Expand All @@ -83,7 +80,7 @@ void PadSettingExtension::UpdateValue()
}

PadSettingCheckBox::PadSettingCheckBox(wxWindow* const parent, ControlState& _value, const char* const label)
: PadSetting(new wxCheckBox(parent, -1, WXTSTR_FROM_CSTR(label), wxDefaultPosition))
: PadSetting(new wxCheckBox(parent, -1, StrToWxStr(label), wxDefaultPosition))
, value(_value)
{
UpdateGUI();
Expand Down Expand Up @@ -119,8 +116,8 @@ ControlDialog::ControlDialog(GamepadPage* const parent, InputPlugin& plugin, Con
m_devq = m_parent->controller->default_device;

// GetStrings() sounds slow :/
//device_cbox = new wxComboBox(this, -1, WXSTR_FROM_STR(ref->device_qualifier.ToString()), wxDefaultPosition, wxSize(256,-1), parent->device_cbox->GetStrings(), wxTE_PROCESS_ENTER);
device_cbox = new wxComboBox(this, -1, WXSTR_FROM_STR(m_devq.ToString()), wxDefaultPosition, wxSize(256,-1), parent->device_cbox->GetStrings(), wxTE_PROCESS_ENTER);
//device_cbox = new wxComboBox(this, -1, StrToWxStr(ref->device_qualifier.ToString()), wxDefaultPosition, wxSize(256,-1), parent->device_cbox->GetStrings(), wxTE_PROCESS_ENTER);
device_cbox = new wxComboBox(this, -1, StrToWxStr(m_devq.ToString()), wxDefaultPosition, wxSize(256,-1), parent->device_cbox->GetStrings(), wxTE_PROCESS_ENTER);

device_cbox->Bind(wxEVT_COMMAND_COMBOBOX_SELECTED, &ControlDialog::SetDevice, this);
device_cbox->Bind(wxEVT_COMMAND_TEXT_ENTER, &ControlDialog::SetDevice, this);
Expand All @@ -145,9 +142,9 @@ ControlButton::ControlButton(wxWindow* const parent, ControllerInterface::Contro
, control_reference(_ref)
{
if (label.empty())
SetLabel(WXSTR_FROM_STR(_ref->expression));
SetLabel(StrToWxStr(_ref->expression));
else
SetLabel(WXSTR_FROM_STR(label));
SetLabel(StrToWxStr(label));
}

void InputConfigDialog::UpdateProfileComboBox()
Expand All @@ -169,7 +166,7 @@ void InputConfigDialog::UpdateProfileComboBox()
for (; si!=se; ++si)
{
std::string str(si->begin() + si->find_last_of('/') + 1 , si->end() - 4) ;
strs.push_back(WXSTR_FROM_STR(str));
strs.push_back(StrToWxStr(str));
}

std::vector< GamepadPage* >::iterator i = m_padpages.begin(),
Expand Down Expand Up @@ -209,7 +206,7 @@ void ControlDialog::UpdateListContents()
i = dev->Inputs().begin(),
e = dev->Inputs().end();
for (; i!=e; ++i)
control_lbox->Append(WXSTR_FROM_STR((*i)->GetName()));
control_lbox->Append(StrToWxStr((*i)->GetName()));
}
else
{
Expand All @@ -218,7 +215,7 @@ void ControlDialog::UpdateListContents()
i = dev->Outputs().begin(),
e = dev->Outputs().end();
for (; i!=e; ++i)
control_lbox->Append(WXSTR_FROM_STR((*i)->GetName()));
control_lbox->Append(StrToWxStr((*i)->GetName()));
}
}
}
Expand All @@ -227,15 +224,15 @@ void ControlDialog::SelectControl(const std::string& name)
{
//UpdateGUI();

const int f = control_lbox->FindString(WXSTR_FROM_STR(name));
const int f = control_lbox->FindString(StrToWxStr(name));
if (f >= 0)
control_lbox->Select(f);
}

void ControlDialog::UpdateGUI()
{
// update textbox
textctrl->SetValue(WXSTR_FROM_STR(control_reference->expression));
textctrl->SetValue(StrToWxStr(control_reference->expression));

// updates the "bound controls:" label
m_bound_label->SetLabel(wxString::Format(_("Bound Controls: %lu"),
Expand All @@ -244,7 +241,7 @@ void ControlDialog::UpdateGUI()

void GamepadPage::UpdateGUI()
{
device_cbox->SetValue(WXSTR_FROM_STR(controller->default_device.ToString()));
device_cbox->SetValue(StrToWxStr(controller->default_device.ToString()));

std::vector< ControlGroupBox* >::const_iterator g = control_groups.begin(),
ge = control_groups.end();
Expand All @@ -255,7 +252,7 @@ void GamepadPage::UpdateGUI()
, e = (*g)->control_buttons.end();
for (; i!=e; ++i)
//if (std::string::npos == (*i)->control_reference->expression.find_first_of("`|&!#"))
(*i)->SetLabel(WXSTR_FROM_STR((*i)->control_reference->expression));
(*i)->SetLabel(StrToWxStr((*i)->control_reference->expression));
//else
//(*i)->SetLabel(wxT("..."));

Expand Down Expand Up @@ -294,7 +291,7 @@ void GamepadPage::LoadDefaults(wxCommandEvent&)

void ControlDialog::SetControl(wxCommandEvent&)
{
control_reference->expression = STR_FROM_WXSTR(textctrl->GetValue());
control_reference->expression = WxStrToStr(textctrl->GetValue());

std::lock_guard<std::recursive_mutex> lk(m_plugin.controls_lock);
g_controller_interface.UpdateReference(control_reference, m_parent->controller->default_device);
Expand All @@ -304,10 +301,10 @@ void ControlDialog::SetControl(wxCommandEvent&)

void GamepadPage::SetDevice(wxCommandEvent&)
{
controller->default_device.FromString(STR_FROM_WXSTR(device_cbox->GetValue()));
controller->default_device.FromString(WxStrToStr(device_cbox->GetValue()));

// show user what it was validated as
device_cbox->SetValue(WXSTR_FROM_STR(controller->default_device.ToString()));
device_cbox->SetValue(StrToWxStr(controller->default_device.ToString()));

// this will set all the controls to this default device
controller->UpdateDefaultDevice();
Expand All @@ -319,10 +316,10 @@ void GamepadPage::SetDevice(wxCommandEvent&)

void ControlDialog::SetDevice(wxCommandEvent&)
{
m_devq.FromString(STR_FROM_WXSTR(device_cbox->GetValue()));
m_devq.FromString(WxStrToStr(device_cbox->GetValue()));

// show user what it was validated as
device_cbox->SetValue(WXSTR_FROM_STR(m_devq.ToString()));
device_cbox->SetValue(StrToWxStr(m_devq.ToString()));

// update gui
UpdateListContents();
Expand All @@ -349,12 +346,12 @@ void ControlDialog::SetSelectedControl(wxCommandEvent&)

// non-default device
if (false == (m_devq == m_parent->controller->default_device))
expr.append(wxT('`')).append(WXSTR_FROM_STR(m_devq.ToString())).append(wxT('`'));
expr.append(wxT('`')).append(StrToWxStr(m_devq.ToString())).append(wxT('`'));

// append the control name
expr += control_lbox->GetString(num);

control_reference->expression = STR_FROM_WXSTR(expr);
control_reference->expression = WxStrToStr(expr);

std::lock_guard<std::recursive_mutex> lk(m_plugin.controls_lock);
g_controller_interface.UpdateReference(control_reference, m_parent->controller->default_device);
Expand All @@ -380,12 +377,12 @@ void ControlDialog::AppendControl(wxCommandEvent& event)

// non-default device
if (false == (m_devq == m_parent->controller->default_device))
expr.append(wxT('`')).append(WXSTR_FROM_STR(m_devq.ToString())).append(wxT('`'));
expr.append(wxT('`')).append(StrToWxStr(m_devq.ToString())).append(wxT('`'));

// append the control name
expr += control_lbox->GetString(num);

control_reference->expression = STR_FROM_WXSTR(expr);
control_reference->expression = WxStrToStr(expr);

std::lock_guard<std::recursive_mutex> lk(m_plugin.controls_lock);
g_controller_interface.UpdateReference(control_reference, m_parent->controller->default_device);
Expand Down Expand Up @@ -475,7 +472,7 @@ void GamepadPage::DetectControl(wxCommandEvent& event)
g_controller_interface.UpdateReference(btn->control_reference, controller->default_device);
}

btn->SetLabel(WXSTR_FROM_STR(btn->control_reference->expression));
btn->SetLabel(StrToWxStr(btn->control_reference->expression));
}
}

Expand Down Expand Up @@ -565,7 +562,7 @@ void GamepadPage::GetProfilePath(std::string& path)
path += PROFILES_PATH;
path += m_plugin.profile_name;
path += '/';
path += STR_FROM_WXSTR(profile_cbox->GetValue());
path += WxStrToStr(profile_cbox->GetValue());
path += ".ini";
}
}
Expand Down Expand Up @@ -615,7 +612,7 @@ void GamepadPage::DeleteProfile(wxCommandEvent&)

if (File::Exists(fnamecstr) &&
AskYesNoT("Are you sure you want to delete \"%s\"?",
STR_FROM_WXSTR(profile_cbox->GetValue()).c_str()))
WxStrToStr(profile_cbox->GetValue()).c_str()))
{
File::Delete(fnamecstr);

Expand All @@ -637,9 +634,9 @@ void InputConfigDialog::UpdateDeviceComboBox()
for (; di!=de; ++di)
{
dq.FromDevice(*di);
(*i)->device_cbox->Append(WXSTR_FROM_STR(dq.ToString()));
(*i)->device_cbox->Append(StrToWxStr(dq.ToString()));
}
(*i)->device_cbox->SetValue(WXSTR_FROM_STR((*i)->controller->default_device.ToString()));
(*i)->device_cbox->SetValue(StrToWxStr((*i)->controller->default_device.ToString()));
}
}

Expand Down Expand Up @@ -680,7 +677,7 @@ ControlGroupBox::ControlGroupBox(ControllerEmu::ControlGroup* const group, wxWin
for (; ci != ce; ++ci)
{

wxStaticText* const label = new wxStaticText(parent, -1, WXTSTR_FROM_CSTR((*ci)->name));
wxStaticText* const label = new wxStaticText(parent, -1, StrToWxStr((*ci)->name));

ControlButton* const control_button = new ControlButton(parent, (*ci)->control_ref, 80);
control_button->SetFont(m_SmallFont);
Expand Down Expand Up @@ -734,7 +731,7 @@ ControlGroupBox::ControlGroupBox(ControllerEmu::ControlGroup* const group, wxWin
PadSettingSpin* setting = new PadSettingSpin(parent, *i);
setting->wxcontrol->Bind(wxEVT_COMMAND_SPINCTRL_UPDATED, &GamepadPage::AdjustSetting, eventsink);
options.push_back(setting);
szr->Add(new wxStaticText(parent, -1, WXTSTR_FROM_CSTR((*i)->name)));
szr->Add(new wxStaticText(parent, -1, StrToWxStr((*i)->name)));
szr->Add(setting->wxcontrol, 0, wxLEFT, 0);
}

Expand All @@ -760,7 +757,7 @@ ControlGroupBox::ControlGroupBox(ControllerEmu::ControlGroup* const group, wxWin
options.push_back(threshold_cbox);

wxBoxSizer* const szr = new wxBoxSizer(wxHORIZONTAL);
szr->Add(new wxStaticText(parent, -1, WXTSTR_FROM_CSTR(group->settings[0]->name)),
szr->Add(new wxStaticText(parent, -1, StrToWxStr(group->settings[0]->name)),
0, wxCENTER|wxRIGHT, 3);
szr->Add(threshold_cbox->wxcontrol, 0, wxRIGHT, 3);

Expand Down Expand Up @@ -795,7 +792,7 @@ ControlGroupBox::ControlGroupBox(ControllerEmu::ControlGroup* const group, wxWin
setting->wxcontrol->Bind(wxEVT_COMMAND_SPINCTRL_UPDATED, &GamepadPage::AdjustSetting, eventsink);
options.push_back(setting);
wxBoxSizer* const szr = new wxBoxSizer(wxHORIZONTAL);
szr->Add(new wxStaticText(parent, -1, WXTSTR_FROM_CSTR((*i)->name)), 0, wxCENTER|wxRIGHT, 3);
szr->Add(new wxStaticText(parent, -1, StrToWxStr((*i)->name)), 0, wxCENTER|wxRIGHT, 3);
szr->Add(setting->wxcontrol, 0, wxRIGHT, 3);
Add(szr, 0, wxALL|wxCENTER, 3);
}
Expand Down Expand Up @@ -859,7 +856,7 @@ ControlGroupsSizer::ControlGroupsSizer(ControllerEmu* const controller, wxWindow
{
ControlGroupBox* control_group_box = new ControlGroupBox(controller->groups[i], parent, eventsink);
wxStaticBoxSizer *control_group =
new wxStaticBoxSizer(wxVERTICAL, parent, WXTSTR_FROM_CSTR(controller->groups[i]->name));
new wxStaticBoxSizer(wxVERTICAL, parent, StrToWxStr(controller->groups[i]->name));
control_group->Add(control_group_box);

const size_t grp_size = controller->groups[i]->controls.size() + controller->groups[i]->settings.size();
Expand Down Expand Up @@ -955,15 +952,15 @@ GamepadPage::GamepadPage(wxWindow* parent, InputPlugin& plugin, const unsigned i


InputConfigDialog::InputConfigDialog(wxWindow* const parent, InputPlugin& plugin, const std::string& name, const int tab_num)
: wxDialog(parent, wxID_ANY, WXTSTR_FROM_CSTR(name.c_str()), wxPoint(128,-1), wxDefaultSize)
: wxDialog(parent, wxID_ANY, StrToWxStr(name), wxPoint(128,-1), wxDefaultSize)
, m_plugin(plugin)
{
m_pad_notebook = new wxNotebook(this, -1, wxDefaultPosition, wxDefaultSize, wxNB_DEFAULT);
for (unsigned int i = 0; i < plugin.controllers.size(); ++i)
{
GamepadPage* gp = new GamepadPage(m_pad_notebook, m_plugin, i, this);
m_padpages.push_back(gp);
m_pad_notebook->AddPage(gp, wxString::Format(wxT("%s %u"), WXTSTR_FROM_CSTR(m_plugin.gui_name), 1+i));
m_pad_notebook->AddPage(gp, wxString::Format(wxT("%s %u"), StrToWxStr(m_plugin.gui_name), 1+i));
}

m_pad_notebook->SetSelection(tab_num);
Expand Down
11 changes: 6 additions & 5 deletions Source/Core/DolphinWX/Src/InputConfigDiagBitmaps.cpp
Expand Up @@ -16,6 +16,7 @@
// http://code.google.com/p/dolphin-emu/

#include "InputConfigDiag.h"
#include "WxUtils.h"

void InputConfigDialog::UpdateBitmaps(wxTimerEvent& WXUNUSED(event))
{
Expand Down Expand Up @@ -48,7 +49,7 @@ void InputConfigDialog::UpdateBitmaps(wxTimerEvent& WXUNUSED(event))

// label for sticks and stuff
if (64 == bitmap.GetHeight())
dc.DrawText(wxString::FromAscii((*g)->control_group->name).Upper(), 4, 2);
dc.DrawText(StrToWxStr((*g)->control_group->name).Upper(), 4, 2);

switch ( (*g)->control_group->type )
{
Expand Down Expand Up @@ -227,7 +228,7 @@ void InputConfigDialog::UpdateBitmaps(wxTimerEvent& WXUNUSED(event))
// text
const char* const name = (*g)->control_group->controls[n]->name;
// bit of hax so ZL, ZR show up as L, R
dc.DrawText(wxString::FromAscii((name[1] && name[1] < 'a') ? name[1] : name[0]), n*12 + 2, 1);
dc.DrawText(StrToWxStr(std::string(1, (name[1] && name[1] < 'a') ? name[1] : name[0])), n*12 + 2, 1);
}

delete[] bitmasks;
Expand Down Expand Up @@ -263,7 +264,7 @@ void InputConfigDialog::UpdateBitmaps(wxTimerEvent& WXUNUSED(event))
dc.DrawRectangle(0, n*12, trigs[n], 14);

// text
dc.DrawText(wxString::FromAscii((*g)->control_group->controls[n]->name), 3, n*12 + 1);
dc.DrawText(StrToWxStr((*g)->control_group->controls[n]->name), 3, n*12 + 1);
}

delete[] trigs;
Expand Down Expand Up @@ -298,8 +299,8 @@ void InputConfigDialog::UpdateBitmaps(wxTimerEvent& WXUNUSED(event))
dc.DrawRectangle(64, n*12, 32, 14);

// text
dc.DrawText(wxString::FromAscii((*g)->control_group->controls[n+trigger_count]->name), 3, n*12 + 1);
dc.DrawText(wxString::FromAscii((*g)->control_group->controls[n]->name[0]), 64 + 3, n*12 + 1);
dc.DrawText(StrToWxStr((*g)->control_group->controls[n+trigger_count]->name), 3, n*12 + 1);
dc.DrawText(StrToWxStr(std::string(1, (*g)->control_group->controls[n]->name[0])), 64 + 3, n*12 + 1);
}

// threshold box
Expand Down
3 changes: 2 additions & 1 deletion Source/Core/DolphinWX/Src/LogConfigWindow.cpp
Expand Up @@ -20,6 +20,7 @@
#include "ConsoleListener.h"
#include "LogWindow.h"
#include "FileUtil.h"
#include "WxUtils.h"

LogConfigWindow::LogConfigWindow(wxWindow* parent, CLogWindow *log_window, wxWindowID id)
: wxPanel(parent, id, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL, _("Log Configuration"))
Expand Down Expand Up @@ -74,7 +75,7 @@ void LogConfigWindow::CreateGUIControls()
m_checks = new wxCheckListBox(this, wxID_ANY);
m_checks->Bind(wxEVT_COMMAND_CHECKLISTBOX_TOGGLED, &LogConfigWindow::OnLogCheck, this);
for (int i = 0; i < LogTypes::NUMBER_OF_LOGS; i++)
m_checks->Append(wxString::FromAscii(m_LogManager->GetFullName((LogTypes::LOG_TYPE)i)));
m_checks->Append(StrToWxStr(m_LogManager->GetFullName((LogTypes::LOG_TYPE)i)));

// Sizers
wxStaticBoxSizer* sbOutputs = new wxStaticBoxSizer(wxVERTICAL, this, _("Logger Outputs"));
Expand Down
25 changes: 5 additions & 20 deletions Source/Core/DolphinWX/Src/LogWindow.cpp
Expand Up @@ -21,6 +21,8 @@
#include "IniFile.h"
#include "FileUtil.h"
#include "Debugger/DebuggerUIUtil.h"
#include "WxUtils.h"

#include <wx/fontmap.h>

// Milliseconds between msgQueue flushes to wxTextCtrl
Expand All @@ -41,25 +43,7 @@ CLogWindow::CLogWindow(CFrame *parent, wxWindowID id, const wxPoint& pos,
, x(0), y(0), winpos(0)
, Parent(parent), m_ignoreLogTimer(false), m_LogAccess(true)
, m_Log(NULL), m_cmdline(NULL), m_FontChoice(NULL)
, m_SJISConv(wxT(""))
{
#ifdef _WIN32
static bool validCP932 = ::IsValidCodePage(932) != 0;
if (validCP932)
{
m_SJISConv = wxCSConv(wxFontMapper::GetEncodingName(wxFONTENCODING_SHIFT_JIS));
}
else
{
WARN_LOG(COMMON, "Cannot Convert from Charset Windows Japanese cp 932");
m_SJISConv = *(wxCSConv*)wxConvCurrent;
}
#else
// on linux the wrong string is returned from wxFontMapper::GetEncodingName(wxFONTENCODING_SHIFT_JIS)
// it returns CP-932, in order to use iconv we need to use CP932
m_SJISConv = wxCSConv(wxT("CP932"));
#endif

m_LogManager = LogManager::GetInstance();

CreateGUIControls();
Expand Down Expand Up @@ -208,7 +192,7 @@ void CLogWindow::SaveSettings()
void CLogWindow::OnSubmit(wxCommandEvent& WXUNUSED (event))
{
if (!m_cmdline) return;
Console_Submit(m_cmdline->GetValue().To8BitData());
Console_Submit(WxStrToStr(m_cmdline->GetValue()).c_str());
m_cmdline->SetValue(wxEmptyString);
}

Expand Down Expand Up @@ -370,5 +354,6 @@ void CLogWindow::Log(LogTypes::LOG_LEVELS level, const char *text)

if (msgQueue.size() >= 100)
msgQueue.pop();
msgQueue.push(std::pair<u8, wxString>((u8)level, wxString(text, m_SJISConv)));

msgQueue.push(std::make_pair(u8(level), StrToWxStr(text)));
}
2 changes: 0 additions & 2 deletions Source/Core/DolphinWX/Src/LogWindow.h
Expand Up @@ -75,8 +75,6 @@ class CLogWindow : public wxPanel, LogListener

std::mutex m_LogSection;

wxCSConv m_SJISConv;

DECLARE_EVENT_TABLE()

wxTextCtrl * CreateTextCtrl(wxPanel* parent, wxWindowID id = wxID_ANY, long Style = NULL);
Expand Down
24 changes: 12 additions & 12 deletions Source/Core/DolphinWX/Src/Main.cpp
Expand Up @@ -32,6 +32,7 @@
#include "Host.h" // Core
#include "HW/Wiimote.h"

#include "WxUtils.h"
#include "Globals.h" // Local
#include "Main.h"
#include "ConfigManager.h"
Expand Down Expand Up @@ -211,7 +212,7 @@ bool DolphinApp::OnInit()
}

#ifdef _WIN32
if (!wxSetWorkingDirectory(wxString(File::GetExeDirectory().c_str(), *wxConvCurrent)))
if (!wxSetWorkingDirectory(StrToWxStr(File::GetExeDirectory())))
{
INFO_LOG(CONSOLE, "set working directory failed");
}
Expand Down Expand Up @@ -246,7 +247,7 @@ bool DolphinApp::OnInit()

if (selectVideoBackend && videoBackendName != wxEmptyString)
SConfig::GetInstance().m_LocalCoreStartupParameter.m_strVideoBackend =
std::string(videoBackendName.mb_str());
WxStrToStr(videoBackendName);

if (selectAudioEmulation)
{
Expand Down Expand Up @@ -296,7 +297,7 @@ bool DolphinApp::OnInit()
#endif

main_frame = new CFrame((wxFrame*)NULL, wxID_ANY,
wxString::FromAscii(scm_rev_str),
StrToWxStr(scm_rev_str),
wxPoint(x, y), wxSize(w, h),
UseDebugger, BatchMode, UseLogger);
SetTopWindow(main_frame);
Expand All @@ -317,7 +318,7 @@ void DolphinApp::MacOpenFile(const wxString &fileName)
LoadFile = true;

if (m_afterinit == NULL)
main_frame->BootGame(std::string(FileToLoad.mb_str()));
main_frame->BootGame(WxStrToStr(FileToLoad));
}

void DolphinApp::AfterInit(wxTimerEvent& WXUNUSED(event))
Expand All @@ -331,7 +332,7 @@ void DolphinApp::AfterInit(wxTimerEvent& WXUNUSED(event))
// First check if we have an exec command line.
if (LoadFile && FileToLoad != wxEmptyString)
{
main_frame->BootGame(std::string(FileToLoad.mb_str()));
main_frame->BootGame(WxStrToStr(FileToLoad));
}
// If we have selected Automatic Start, start the default ISO,
// or if no default ISO exists, start the last loaded ISO
Expand Down Expand Up @@ -418,7 +419,7 @@ void Host_SysMessage(const char *fmt, ...)
va_end(list);

if (msg[strlen(msg)-1] == '\n') msg[strlen(msg)-1] = 0;
//wxMessageBox(wxString::FromAscii(msg));
//wxMessageBox(StrToWxStr(msg));
PanicAlert("%s", msg);
}

Expand All @@ -427,14 +428,13 @@ bool wxMsgAlert(const char* caption, const char* text, bool yes_no, int /*Style*
#ifdef __WXGTK__
if (wxIsMainThread())
#endif
return wxYES == wxMessageBox(wxString::FromUTF8(text),
wxString::FromUTF8(caption),
return wxYES == wxMessageBox(StrToWxStr(text), StrToWxStr(caption),
(yes_no) ? wxYES_NO : wxOK, wxGetActiveWindow());
#ifdef __WXGTK__
else
{
wxCommandEvent event(wxEVT_HOST_COMMAND, IDM_PANIC);
event.SetString(wxString::FromUTF8(caption) + wxT(":") + wxString::FromUTF8(text));
event.SetString(StrToWxStr(caption) + wxT(":") + StrToWxStr(text));
event.SetInt(yes_no);
main_frame->GetEventHandler()->AddPendingEvent(event);
main_frame->panic_event.Wait();
Expand All @@ -445,7 +445,7 @@ bool wxMsgAlert(const char* caption, const char* text, bool yes_no, int /*Style*

std::string wxStringTranslator(const char *text)
{
return (const char *)wxString(wxGetTranslation(wxString::From8BitData(text))).ToUTF8();
return WxStrToStr(wxGetTranslation(wxString::FromUTF8(text)));
}

// Accessor for the main window class
Expand Down Expand Up @@ -536,7 +536,7 @@ void Host_UpdateMainFrame()
void Host_UpdateTitle(const char* title)
{
wxCommandEvent event(wxEVT_HOST_COMMAND, IDM_UPDATETITLE);
event.SetString(wxString::FromAscii(title));
event.SetString(StrToWxStr(title));
main_frame->GetEventHandler()->AddPendingEvent(event);
}

Expand Down Expand Up @@ -603,7 +603,7 @@ void Host_UpdateStatusBar(const char* _pText, int Field)
{
wxCommandEvent event(wxEVT_HOST_COMMAND, IDM_UPDATESTATUSBAR);
// Set the event string
event.SetString(wxString::FromAscii(_pText));
event.SetString(StrToWxStr(_pText));
// Update statusbar field
event.SetInt(Field);
// Post message
Expand Down
63 changes: 25 additions & 38 deletions Source/Core/DolphinWX/Src/MemcardManager.cpp
Expand Up @@ -17,6 +17,8 @@

#include "MemcardManager.h"
#include "Common.h"

#include "WxUtils.h"
#include "wx/mstream.h"

#define ARROWS slot ? _T("") : ARROW[slot], slot ? ARROW[slot] : _T("")
Expand Down Expand Up @@ -212,7 +214,7 @@ void CMemcardManager::CreateGUIControls()
sPages->Add(m_NextPage[slot], 0, wxEXPAND|wxALL, 1);

m_MemcardPath[slot] = new wxFilePickerCtrl(this, ID_MEMCARDPATH_A + slot,
wxString::From8BitData(File::GetUserPath(D_GCUSER_IDX).c_str()), _("Choose a memory card:"),
StrToWxStr(File::GetUserPath(D_GCUSER_IDX)), _("Choose a memory card:"),
_("Gamecube Memory Cards (*.raw,*.gcp)") + wxString(wxT("|*.raw;*.gcp")), wxDefaultPosition, wxDefaultSize, wxFLP_USE_TEXTCTRL|wxFLP_OPEN);

m_MemcardList[slot] = new CMemcardListCtrl(this, ID_MEMCARDLIST_A + slot, wxDefaultPosition, wxSize(350,400),
Expand Down Expand Up @@ -263,7 +265,7 @@ void CMemcardManager::CreateGUIControls()
m_Delete[i]->Disable();
if (DefaultMemcard[i].length())
{
m_MemcardPath[i]->SetPath(wxString::From8BitData(DefaultMemcard[i].c_str()));
m_MemcardPath[i]->SetPath(StrToWxStr(DefaultMemcard[i]));
ChangePath(i);
}
}
Expand All @@ -290,7 +292,7 @@ void CMemcardManager::ChangePath(int slot)
}
else
{
if (m_MemcardPath[slot]->GetPath().length() && ReloadMemcard(m_MemcardPath[slot]->GetPath().mb_str(), slot))
if (m_MemcardPath[slot]->GetPath().length() && ReloadMemcard(WxStrToStr(m_MemcardPath[slot]->GetPath()).c_str(), slot))
{
if (memoryCard[slot2])
{
Expand Down Expand Up @@ -345,7 +347,7 @@ void CMemcardManager::OnPageChange(wxCommandEvent& event)
m_NextPage[slot]->Disable();
m_MemcardList[slot]->nextPage = false;
}
ReloadMemcard(m_MemcardPath[slot]->GetPath().mb_str(), slot);
ReloadMemcard(WxStrToStr(m_MemcardPath[slot]->GetPath()).c_str(), slot);
break;
case ID_PREVPAGE_A:
slot = SLOT_A;
Expand All @@ -361,7 +363,7 @@ void CMemcardManager::OnPageChange(wxCommandEvent& event)
m_PrevPage[slot]->Disable();
m_MemcardList[slot]->prevPage = false;
}
ReloadMemcard(m_MemcardPath[slot]->GetPath().mb_str(), slot);
ReloadMemcard(WxStrToStr(m_MemcardPath[slot]->GetPath()).c_str(), slot);
break;
}
}
Expand All @@ -373,7 +375,7 @@ void CMemcardManager::OnMenuChange(wxCommandEvent& event)
{
case ID_MEMCARDPATH_A:
case ID_MEMCARDPATH_B:
DefaultMemcard[_id - ID_MEMCARDPATH_A] = m_MemcardPath[_id - ID_MEMCARDPATH_A]->GetPath().mb_str();
DefaultMemcard[_id - ID_MEMCARDPATH_A] = WxStrToStr(m_MemcardPath[_id - ID_MEMCARDPATH_A]->GetPath());
return;
case ID_USEPAGES:
mcmSettings.usePages = !mcmSettings.usePages;
Expand All @@ -400,8 +402,8 @@ void CMemcardManager::OnMenuChange(wxCommandEvent& event)
break;
}

if (memoryCard[SLOT_A]) ReloadMemcard(m_MemcardPath[SLOT_A]->GetPath().mb_str(), SLOT_A);
if (memoryCard[SLOT_B]) ReloadMemcard(m_MemcardPath[SLOT_B]->GetPath().mb_str(), SLOT_B);
if (memoryCard[SLOT_A]) ReloadMemcard(WxStrToStr(m_MemcardPath[SLOT_A]->GetPath()).c_str(), SLOT_A);
if (memoryCard[SLOT_B]) ReloadMemcard(WxStrToStr(m_MemcardPath[SLOT_B]->GetPath()).c_str(), SLOT_B);
}
bool CMemcardManager::CopyDeleteSwitch(u32 error, int slot)
{
Expand All @@ -416,7 +418,7 @@ bool CMemcardManager::CopyDeleteSwitch(u32 error, int slot)
memoryCard[slot]->FixChecksums();
if (!memoryCard[slot]->Save()) PanicAlert(E_SAVEFAILED);
page[slot] = FIRSTPAGE;
ReloadMemcard(m_MemcardPath[slot]->GetPath().mb_str(), slot);
ReloadMemcard(WxStrToStr(m_MemcardPath[slot]->GetPath()).c_str(), slot);
}
break;
case NOMEMCARD:
Expand Down Expand Up @@ -517,8 +519,8 @@ void CMemcardManager::CopyDeleteClick(wxCommandEvent& event)
wxString fileName = wxFileSelector(
_("Select a save file to import"),
(strcmp(DefaultIOPath.c_str(), "/Users/GC") == 0)
? wxString::FromAscii("")
: wxString::From8BitData(DefaultIOPath.c_str()),
? StrToWxStr("")
: StrToWxStr(DefaultIOPath),
wxEmptyString, wxEmptyString,
_("GameCube Savegame files(*.gci;*.gcs;*.sav)") + wxString(wxT("|*.gci;*.gcs;*.sav|")) +
_("Native GCI files(*.gci)") + wxString(wxT("|*.gci|")) +
Expand All @@ -532,11 +534,11 @@ void CMemcardManager::CopyDeleteClick(wxCommandEvent& event)
_("GCI File(*.gci)") + wxString(_T("|*.gci")),
wxFD_OVERWRITE_PROMPT|wxFD_SAVE, this);
if (temp2.empty()) break;
fileName2 = temp2.mb_str();
fileName2 = WxStrToStr(temp2);
}
if (fileName.length() > 0)
{
CopyDeleteSwitch(memoryCard[slot]->ImportGci(fileName.mb_str(), fileName2), slot);
CopyDeleteSwitch(memoryCard[slot]->ImportGci(WxStrToStr(fileName).c_str(), fileName2), slot);
}
}
break;
Expand All @@ -555,18 +557,18 @@ void CMemcardManager::CopyDeleteClick(wxCommandEvent& event)
}
wxString fileName = wxFileSelector(
_("Export save as..."),
wxString::From8BitData(DefaultIOPath.c_str()),
wxString::From8BitData(gciFilename.c_str()), wxT(".gci"),
StrToWxStr(DefaultIOPath),
StrToWxStr(gciFilename), wxT(".gci"),
_("Native GCI files(*.gci)") + wxString(wxT("|*.gci|")) +
_("MadCatz Gameshark files(*.gcs)") + wxString(wxT("|*.gcs|")) +
_("Datel MaxDrive/Pro files(*.sav)") + wxString(wxT("|*.sav")),
wxFD_OVERWRITE_PROMPT|wxFD_SAVE, this);

if (fileName.length() > 0)
{
if (!CopyDeleteSwitch(memoryCard[slot]->ExportGci(index, fileName.mb_str(), ""), -1))
if (!CopyDeleteSwitch(memoryCard[slot]->ExportGci(index, WxStrToStr(fileName).c_str(), ""), -1))
{
File::Delete(std::string(fileName.mb_str()));
File::Delete(WxStrToStr(fileName));
}
}
}
Expand All @@ -576,7 +578,7 @@ void CMemcardManager::CopyDeleteClick(wxCommandEvent& event)
case ID_EXPORTALL_B:
{
std::string path1, path2, mpath;
mpath = m_MemcardPath[slot]->GetPath().mb_str();
mpath = WxStrToStr(m_MemcardPath[slot]->GetPath());
SplitPath(mpath, &path1, &path2, NULL);
path1 += path2;
File::CreateDir(path1);
Expand Down Expand Up @@ -702,26 +704,11 @@ bool CMemcardManager::ReloadMemcard(const char *fileName, int card)
std::string title = memoryCard[card]->GetSaveComment1(fileIndex);
std::string comment = memoryCard[card]->GetSaveComment2(fileIndex);

bool ascii = memoryCard[card]->IsAsciiEncoding();

#ifdef _WIN32
wxCSConv SJISConv(*(wxCSConv*)wxConvCurrent);
static bool validCP932 = ::IsValidCodePage(932) != 0;
if (validCP932)
{
SJISConv = wxCSConv(wxFontMapper::GetEncodingName(wxFONTENCODING_SHIFT_JIS));
}
else
{
WARN_LOG(COMMON, "Cannot Convert from Charset Windows Japanese cp 932");
}
#else
// on linux the wrong string is returned from wxFontMapper::GetEncodingName(wxFONTENCODING_SHIFT_JIS)
// it returns CP-932, in order to use iconv we need to use CP932
wxCSConv SJISConv(wxT("CP932"));
#endif
wxTitle = wxString(title.c_str(), ascii ? *wxConvCurrent : SJISConv);
wxComment = wxString(comment.c_str(), ascii ? *wxConvCurrent : SJISConv);
auto const string_decoder = memoryCard[card]->IsAsciiEncoding() ?
CP1252ToUTF8 : SHIFTJISToUTF8;

wxTitle = StrToWxStr(string_decoder(title));
wxComment = StrToWxStr(string_decoder(comment));

m_MemcardList[card]->SetItem(index, COLUMN_TITLE, wxTitle);
m_MemcardList[card]->SetItem(index, COLUMN_COMMENT, wxComment);
Expand Down
96 changes: 51 additions & 45 deletions Source/Core/DolphinWX/Src/NetWindow.cpp
Expand Up @@ -18,11 +18,13 @@
#include <FileUtil.h>
#include <IniFile.h>

#include "WxUtils.h"
#include "NetPlay.h"
#include "NetWindow.h"
#include "Frame.h"

#include <sstream>
#include <string>

#define NETPLAY_TITLEBAR "Dolphin NetPlay"

Expand All @@ -34,6 +36,24 @@ static NetPlay* netplay_ptr = NULL;
extern CFrame* main_frame;
NetPlayDiag *NetPlayDiag::npd = NULL;

std::string BuildGameName(const GameListItem& game)
{
// Lang needs to be consistent
auto const lang = 0;

std::string name(game.GetBannerName(lang));
if (name.empty())
name = game.GetVolumeName(lang);

return name + " (" + game.GetUniqueID() + ")";
}

void FillWithGameNames(wxListBox* game_lbox, const CGameListCtrl& game_list)
{
for (u32 i = 0 ; auto game = game_list.GetISO(i); ++i)
game_lbox->Append(StrToWxStr(BuildGameName(*game)));
}

NetPlaySetupDiag::NetPlaySetupDiag(wxWindow* const parent, const CGameListCtrl* const game_list)
: wxFrame(parent, wxID_ANY, wxT(NETPLAY_TITLEBAR), wxDefaultPosition, wxDefaultSize)
, m_game_list(game_list)
Expand All @@ -50,7 +70,7 @@ NetPlaySetupDiag::NetPlaySetupDiag(wxWindow* const parent, const CGameListCtrl*

std::string nickname;
netplay_section.Get("Nickname", &nickname, "Player");
m_nickname_text = new wxTextCtrl(panel, wxID_ANY, wxString::From8BitData(nickname.c_str()));
m_nickname_text = new wxTextCtrl(panel, wxID_ANY, StrToWxStr(nickname));

wxBoxSizer* const nick_szr = new wxBoxSizer(wxHORIZONTAL);
nick_szr->Add(nick_lbl, 0, wxCENTER);
Expand All @@ -72,15 +92,15 @@ NetPlaySetupDiag::NetPlaySetupDiag(wxWindow* const parent, const CGameListCtrl*

std::string address;
netplay_section.Get("Address", &address, "localhost");
m_connect_ip_text = new wxTextCtrl(connect_tab, wxID_ANY, wxString::FromAscii(address.c_str()));
m_connect_ip_text = new wxTextCtrl(connect_tab, wxID_ANY, StrToWxStr(address));

wxStaticText* const port_lbl = new wxStaticText(connect_tab, wxID_ANY, _("Port :"),
wxDefaultPosition, wxDefaultSize);

// string? w/e
std::string port;
netplay_section.Get("ConnectPort", &port, "2626");
m_connect_port_text = new wxTextCtrl(connect_tab, wxID_ANY, wxString::FromAscii(port.c_str()));
m_connect_port_text = new wxTextCtrl(connect_tab, wxID_ANY, StrToWxStr(port));

wxButton* const connect_btn = new wxButton(connect_tab, wxID_ANY, _("Connect"));
connect_btn->Bind(wxEVT_COMMAND_BUTTON_CLICKED, &NetPlaySetupDiag::OnJoin, this);
Expand Down Expand Up @@ -113,18 +133,15 @@ NetPlaySetupDiag::NetPlaySetupDiag(wxWindow* const parent, const CGameListCtrl*
// string? w/e
std::string port;
netplay_section.Get("HostPort", &port, "2626");
m_host_port_text = new wxTextCtrl(host_tab, wxID_ANY, wxString::FromAscii(port.c_str()));
m_host_port_text = new wxTextCtrl(host_tab, wxID_ANY, StrToWxStr(port));

wxButton* const host_btn = new wxButton(host_tab, wxID_ANY, _("Host"));
host_btn->Bind(wxEVT_COMMAND_BUTTON_CLICKED, &NetPlaySetupDiag::OnHost, this);

m_game_lbox = new wxListBox(host_tab, wxID_ANY);
m_game_lbox->Bind(wxEVT_COMMAND_LISTBOX_DOUBLECLICKED, &NetPlaySetupDiag::OnHost, this);

std::istringstream ss(game_list->GetGameNames());
std::string game;
while (std::getline(ss,game))
m_game_lbox->Append(wxString(game.c_str(), *wxConvCurrent));

FillWithGameNames(m_game_lbox, *game_list);

wxBoxSizer* const top_szr = new wxBoxSizer(wxHORIZONTAL);
top_szr->Add(port_lbl, 0, wxCENTER | wxRIGHT, 5);
Expand Down Expand Up @@ -167,10 +184,10 @@ NetPlaySetupDiag::~NetPlaySetupDiag()
inifile.Load(dolphin_ini);
IniFile::Section& netplay_section = *inifile.GetOrCreateSection("NetPlay");

netplay_section.Set("Nickname", m_nickname_text->GetValue().mb_str());
netplay_section.Set("Address", m_connect_ip_text->GetValue().mb_str());
netplay_section.Set("ConnectPort", m_connect_port_text->GetValue().mb_str());
netplay_section.Set("HostPort", m_host_port_text->GetValue().mb_str());
netplay_section.Set("Nickname", WxStrToStr(m_nickname_text->GetValue()));
netplay_section.Set("Address", WxStrToStr(m_connect_ip_text->GetValue()));
netplay_section.Set("ConnectPort", WxStrToStr(m_connect_port_text->GetValue()));
netplay_section.Set("HostPort", WxStrToStr(m_host_port_text->GetValue()));

inifile.Save(dolphin_ini);
main_frame->g_NetPlaySetupDiag = NULL;
Expand All @@ -191,13 +208,13 @@ void NetPlaySetupDiag::OnHost(wxCommandEvent&)
return;
}

std::string game(m_game_lbox->GetStringSelection().mb_str());
std::string game(WxStrToStr(m_game_lbox->GetStringSelection()));

npd = new NetPlayDiag(m_parent, m_game_list, game, true);
unsigned long port = 0;
m_host_port_text->GetValue().ToULong(&port);
netplay_ptr = new NetPlayServer(u16(port)
, std::string(m_nickname_text->GetValue().mb_str()), npd, game);
, WxStrToStr(m_nickname_text->GetValue()), npd, game);
if (netplay_ptr->is_connected)
{
npd->Show();
Expand All @@ -222,8 +239,8 @@ void NetPlaySetupDiag::OnJoin(wxCommandEvent&)
npd = new NetPlayDiag(m_parent, m_game_list, "");
unsigned long port = 0;
m_connect_port_text->GetValue().ToULong(&port);
netplay_ptr = new NetPlayClient(std::string(m_connect_ip_text->GetValue().mb_str())
, (u16)port, npd, std::string(m_nickname_text->GetValue().mb_str()));
netplay_ptr = new NetPlayClient(WxStrToStr(m_connect_ip_text->GetValue())
, (u16)port, npd, WxStrToStr(m_nickname_text->GetValue()));
if (netplay_ptr->is_connected)
{
npd->Show();
Expand All @@ -250,7 +267,7 @@ NetPlayDiag::NetPlayDiag(wxWindow* const parent, const CGameListCtrl* const game

// top crap
m_game_btn = new wxButton(panel, wxID_ANY,
wxString(m_selected_game.c_str(), *wxConvCurrent).Prepend(_(" Game : ")),
StrToWxStr(m_selected_game).Prepend(_(" Game : ")),
wxDefaultPosition, wxDefaultSize, wxBU_LEFT);

if (is_hosting)
Expand Down Expand Up @@ -351,32 +368,25 @@ void NetPlayDiag::OnChat(wxCommandEvent&)

if (s.Length())
{
netplay_ptr->SendChatMessage(std::string(s.mb_str()));
netplay_ptr->SendChatMessage(WxStrToStr(s));
m_chat_text->AppendText(s.Prepend(wxT(" >> ")).Append(wxT('\n')));
m_chat_msg_text->Clear();
}
}

void NetPlayDiag::OnStart(wxCommandEvent&)
{
// find path for selected game
std::string ntmp, ptmp, path;
std::istringstream nss(m_game_list->GetGameNames()), pss(m_game_list->GetGamePaths());

while(std::getline(nss,ntmp))
// find path for selected game, sloppy..
for (u32 i = 0 ; auto game = m_game_list->GetISO(i); ++i)
{
std::getline(pss,ptmp);
if (m_selected_game == ntmp)
if (m_selected_game == BuildGameName(*game))
{
path = ptmp;
break;
netplay_ptr->StartGame(game->GetFileName());
return;
}
}

if (path.length())
netplay_ptr->StartGame(path);
else
PanicAlertT("Game not found!!");

PanicAlertT("Game not found!");
}

void NetPlayDiag::OnStop(wxCommandEvent&)
Expand Down Expand Up @@ -412,7 +422,7 @@ void NetPlayDiag::OnMsgChangeGame(const std::string& filename)
{
wxCommandEvent evt(wxEVT_THREAD, NP_GUI_EVT_CHANGE_GAME);
// TODO: using a wxString in AddPendingEvent from another thread is unsafe i guess?
evt.SetString(wxString(filename.c_str(), *wxConvCurrent));
evt.SetString(StrToWxStr(filename));
GetEventHandler()->AddPendingEvent(evt);
}

Expand All @@ -436,7 +446,7 @@ void NetPlayDiag::OnPadBuffHelp(wxCommandEvent&)
<< time * (60.0f/1000) << "(60fps) / "
<< time * (50.0f/1000) << "(50fps) >\n";

m_chat_text->AppendText(wxString(ss.str().c_str(), *wxConvCurrent));
m_chat_text->AppendText(StrToWxStr(ss.str()));
}

void NetPlayDiag::OnAdjustBuffer(wxCommandEvent& event)
Expand All @@ -447,7 +457,7 @@ void NetPlayDiag::OnAdjustBuffer(wxCommandEvent& event)
std::ostringstream ss;
ss << "< Pad Buffer: " << val << " >";
netplay_ptr->SendChatMessage(ss.str());
m_chat_text->AppendText(wxString(ss.str().c_str(), *wxConvCurrent).Append(wxT('\n')));
m_chat_text->AppendText(StrToWxStr(ss.str()).Append(wxT('\n')));
}

void NetPlayDiag::OnQuit(wxCommandEvent&)
Expand All @@ -468,7 +478,7 @@ void NetPlayDiag::OnThread(wxCommandEvent& event)
m_player_lbox->Clear();
std::istringstream ss(tmps);
while (std::getline(ss, tmps))
m_player_lbox->Append(wxString(tmps.c_str(), *wxConvCurrent));
m_player_lbox->Append(StrToWxStr(tmps));

m_player_lbox->SetSelection(selection);

Expand All @@ -477,7 +487,7 @@ void NetPlayDiag::OnThread(wxCommandEvent& event)
case NP_GUI_EVT_CHANGE_GAME :
// update selected game :/
{
m_selected_game.assign(event.GetString().mb_str());
m_selected_game.assign(WxStrToStr(event.GetString()));
m_game_btn->SetLabel(event.GetString().Prepend(_(" Game : ")));
}
break;
Expand All @@ -503,7 +513,7 @@ void NetPlayDiag::OnThread(wxCommandEvent& event)
std::string s;
chat_msgs.Pop(s);
//PanicAlert("message: %s", s.c_str());
m_chat_text->AppendText(wxString(s.c_str(), *wxConvCurrent).Append(wxT('\n')));
m_chat_text->AppendText(StrToWxStr(s).Append(wxT('\n')));
}
}

Expand All @@ -515,7 +525,7 @@ void NetPlayDiag::OnChangeGame(wxCommandEvent&)

if (game_name.length())
{
m_selected_game = std::string(game_name.mb_str());
m_selected_game = WxStrToStr(game_name);
netplay_ptr->ChangeGame(m_selected_game);
m_game_btn->SetLabel(game_name.Prepend(_(" Game : ")));
}
Expand Down Expand Up @@ -549,11 +559,7 @@ ChangeGameDiag::ChangeGameDiag(wxWindow* const parent, const CGameListCtrl* cons
m_game_lbox = new wxListBox(this, wxID_ANY);
m_game_lbox->Bind(wxEVT_COMMAND_LISTBOX_DOUBLECLICKED, &ChangeGameDiag::OnPick, this);

// fill list with games
std::istringstream ss(game_list->GetGameNames());
std::string game;
while (std::getline(ss,game))
m_game_lbox->Append(wxString(game.c_str(), *wxConvCurrent));
FillWithGameNames(m_game_lbox, *game_list);

wxButton* const ok_btn = new wxButton(this, wxID_OK, _("Change"));
ok_btn->Bind(wxEVT_COMMAND_BUTTON_CLICKED, &ChangeGameDiag::OnPick, this);
Expand Down
13 changes: 7 additions & 6 deletions Source/Core/DolphinWX/Src/PHackSettings.cpp
Expand Up @@ -17,6 +17,7 @@

#include "PHackSettings.h"
#include "ConfigManager.h"
#include "WxUtils.h"

extern PHackData PHack_Data;

Expand Down Expand Up @@ -97,17 +98,17 @@ void CPHackSettings::LoadPHackData()
if (sTemp.empty())
sTemp = wxString(_("(UNKNOWN)")).char_str();
if (i == 0)
PHackChoice->Append(wxString("-------------", *wxConvCurrent));
PHackChoice->Append(wxString(sTemp.c_str(), *wxConvCurrent));
PHackChoice->Append(StrToWxStr("-------------"));
PHackChoice->Append(StrToWxStr(sTemp));
}
PHackChoice->Select(0);

PHackSZNear->Set3StateValue((wxCheckBoxState)PHack_Data.PHackSZNear);
PHackSZFar->Set3StateValue((wxCheckBoxState)PHack_Data.PHackSZFar);
PHackExP->Set3StateValue((wxCheckBoxState)PHack_Data.PHackExP);

PHackZNear->SetValue(wxString(PHack_Data.PHZNear.c_str(), *wxConvCurrent));
PHackZFar->SetValue(wxString(PHack_Data.PHZFar.c_str(), *wxConvCurrent));
PHackZNear->SetValue(StrToWxStr(PHack_Data.PHZNear));
PHackZFar->SetValue(StrToWxStr(PHack_Data.PHZFar));
}

void CPHackSettings::SetRefresh(wxCommandEvent& event)
Expand All @@ -128,9 +129,9 @@ void CPHackSettings::SetRefresh(wxCommandEvent& event)
PHPresetsIni.Get(sIndex, "PH_ExtraParam", &bTemp);
PHackExP->Set3StateValue((wxCheckBoxState)bTemp);
PHPresetsIni.Get(sIndex, "PH_ZNear", &sTemp);
PHackZNear->SetValue(wxString(sTemp.c_str(), *wxConvCurrent));
PHackZNear->SetValue(StrToWxStr(sTemp));
PHPresetsIni.Get(sIndex, "PH_ZFar", &sTemp);
PHackZFar->SetValue(wxString(sTemp.c_str(), *wxConvCurrent));
PHackZFar->SetValue(StrToWxStr(sTemp));
}
}

Expand Down
9 changes: 5 additions & 4 deletions Source/Core/DolphinWX/Src/PatchAddEdit.cpp
Expand Up @@ -16,6 +16,7 @@
// http://code.google.com/p/dolphin-emu/

#include "PatchAddEdit.h"
#include "WxUtils.h"

extern std::vector<PatchEngine::Patch> onFrame;

Expand Down Expand Up @@ -48,7 +49,7 @@ void CPatchAddEdit::CreateGUIControls(int _selection)
}
else
{
currentName = wxString(onFrame.at(_selection).name.c_str(), *wxConvCurrent);
currentName = StrToWxStr(onFrame.at(_selection).name);
tempEntries = onFrame.at(_selection).entries;
}

Expand All @@ -66,7 +67,7 @@ void CPatchAddEdit::CreateGUIControls(int _selection)
EntrySelection->SetValue((int)tempEntries.size()-1);
wxArrayString wxArrayStringFor_EditPatchType;
for (int i = 0; i < 3; ++i)
wxArrayStringFor_EditPatchType.Add(wxString::FromAscii(PatchEngine::PatchTypeStrings[i]));
wxArrayStringFor_EditPatchType.Add(StrToWxStr(PatchEngine::PatchTypeStrings[i]));
EditPatchType = new wxRadioBox(this, ID_EDITPATCH_TYPE, _("Type"), wxDefaultPosition, wxDefaultSize, wxArrayStringFor_EditPatchType, 3, wxRA_SPECIFY_COLS);
EditPatchType->SetSelection((int)tempEntries.at(0).type);
wxStaticText* EditPatchValueText = new wxStaticText(this, ID_EDITPATCH_VALUE_TEXT, _("Value:"));
Expand Down Expand Up @@ -121,15 +122,15 @@ void CPatchAddEdit::SavePatchData(wxCommandEvent& event)
if (selection == -1)
{
PatchEngine::Patch newPatch;
newPatch.name = std::string(EditPatchName->GetValue().mb_str());
newPatch.name = WxStrToStr(EditPatchName->GetValue());
newPatch.entries = tempEntries;
newPatch.active = true;

onFrame.push_back(newPatch);
}
else
{
onFrame.at(selection).name = std::string(EditPatchName->GetValue().mb_str());
onFrame.at(selection).name = WxStrToStr(EditPatchName->GetValue());
onFrame.at(selection).entries = tempEntries;
}

Expand Down
8 changes: 5 additions & 3 deletions Source/Core/DolphinWX/Src/UDPConfigDiag.cpp
Expand Up @@ -4,6 +4,8 @@
#include "Common.h"
#include "ControllerEmu.h"
#include "IniFile.h"
#include "WxUtils.h"

#include <string>

UDPConfigDiag::UDPConfigDiag(wxWindow * const parent, UDPWrapper * _wrp) :
Expand All @@ -26,7 +28,7 @@ UDPConfigDiag::UDPConfigDiag(wxWindow * const parent, UDPWrapper * _wrp) :

wxBoxSizer *const port_sizer = new wxBoxSizer(wxHORIZONTAL);
port_sizer->Add(new wxStaticText(this, wxID_ANY, _("UDP Port:")), 0, wxALIGN_CENTER);
port_tbox = new wxTextCtrl(this, wxID_ANY, wxString::FromUTF8(wrp->port.c_str()));
port_tbox = new wxTextCtrl(this, wxID_ANY, StrToWxStr(wrp->port));
port_sizer->Add(port_tbox, 1, wxLEFT | wxEXPAND, 5);

enable->Bind(wxEVT_COMMAND_CHECKBOX_CLICKED, &UDPConfigDiag::ChangeState, this);
Expand Down Expand Up @@ -71,7 +73,7 @@ void UDPConfigDiag::ChangeUpdateFlags(wxCommandEvent & WXUNUSED(event))

void UDPConfigDiag::ChangeState(wxCommandEvent & WXUNUSED(event))
{
wrp->udpEn=enable->GetValue();
wrp->port=port_tbox->GetValue().mb_str(wxConvUTF8);
wrp->udpEn = enable->GetValue();
wrp->port = WxStrToStr(port_tbox->GetValue());
wrp->Refresh();
}
21 changes: 10 additions & 11 deletions Source/Core/DolphinWX/Src/VideoConfigDiag.cpp
Expand Up @@ -141,7 +141,7 @@ wxArrayString GetListOfResolutions()
if (std::find(resos.begin(), resos.end(), strRes) == resos.end())
{
resos.push_back(strRes);
retlist.Add(wxString::FromAscii(res));
retlist.Add(StrToWxStr(res));
}
ZeroMemory(&dmi, sizeof(dmi));
}
Expand Down Expand Up @@ -180,8 +180,7 @@ wxArrayString GetListOfResolutions()

VideoConfigDiag::VideoConfigDiag(wxWindow* parent, const std::string &title, const std::string& _ininame)
: wxDialog(parent, -1,
wxString::Format(_("Dolphin %s Graphics Configuration"),
wxGetTranslation(wxString::From8BitData(title.c_str()))),
wxString::Format(_("Dolphin %s Graphics Configuration"), wxGetTranslation(StrToWxStr(title))),
wxDefaultPosition, wxDefaultSize)
, vconfig(g_Config)
, ininame(_ininame)
Expand Down Expand Up @@ -212,9 +211,9 @@ VideoConfigDiag::VideoConfigDiag(wxWindow* parent, const std::string &title, con
it = g_available_video_backends.begin(),
itend = g_available_video_backends.end();
for (; it != itend; ++it)
choice_backend->AppendString(wxGetTranslation(wxString::FromAscii((*it)->GetName().c_str())));
choice_backend->AppendString(wxGetTranslation(StrToWxStr((*it)->GetName())));

choice_backend->SetStringSelection(wxGetTranslation(wxString::FromAscii(g_video_backend->GetName().c_str())));
choice_backend->SetStringSelection(wxGetTranslation(StrToWxStr(g_video_backend->GetName())));
choice_backend->Bind(wxEVT_COMMAND_CHOICE_SELECTED, &VideoConfigDiag::Event_Backend, this);

szr_basic->Add(label_backend, 1, wxALIGN_CENTER_VERTICAL, 5);
Expand All @@ -236,7 +235,7 @@ VideoConfigDiag::VideoConfigDiag(wxWindow* parent, const std::string &title, con
it = vconfig.backend_info.Adapters.begin(),
itend = vconfig.backend_info.Adapters.end();
for (; it != itend; ++it)
choice_adapter->AppendString(wxString::FromAscii(it->c_str()));
choice_adapter->AppendString(StrToWxStr(*it));

choice_adapter->Select(vconfig.iAdapter);

Expand All @@ -259,7 +258,7 @@ VideoConfigDiag::VideoConfigDiag(wxWindow* parent, const std::string &title, con
RegisterControl(choice_display_resolution, wxGetTranslation(display_res_desc));
choice_display_resolution->Bind(wxEVT_COMMAND_CHOICE_SELECTED, &VideoConfigDiag::Event_DisplayResolution, this);

choice_display_resolution->SetStringSelection(wxString::FromAscii(SConfig::GetInstance().m_LocalCoreStartupParameter.strFullscreenResolution.c_str()));
choice_display_resolution->SetStringSelection(StrToWxStr(SConfig::GetInstance().m_LocalCoreStartupParameter.strFullscreenResolution));

szr_display->Add(label_display_resolution, 1, wxALIGN_CENTER_VERTICAL, 0);
szr_display->Add(choice_display_resolution);
Expand Down Expand Up @@ -355,7 +354,7 @@ VideoConfigDiag::VideoConfigDiag(wxWindow* parent, const std::string &title, con
it = vconfig.backend_info.AAModes.begin(),
itend = vconfig.backend_info.AAModes.end();
for (; it != itend; ++it)
choice_aamode->AppendString(wxGetTranslation(wxString::FromAscii(it->c_str())));
choice_aamode->AppendString(wxGetTranslation(StrToWxStr(*it)));

choice_aamode->Select(vconfig.iMultisampleMode);
szr_enh->Add(text_aamode, 1, wxALIGN_CENTER_VERTICAL, 0);
Expand All @@ -380,12 +379,12 @@ VideoConfigDiag::VideoConfigDiag(wxWindow* parent, const std::string &title, con
it = vconfig.backend_info.PPShaders.begin(),
itend = vconfig.backend_info.PPShaders.end();
for (; it != itend; ++it)
choice_ppshader->AppendString(wxString::FromAscii(it->c_str()));
choice_ppshader->AppendString(StrToWxStr(*it));

if (vconfig.sPostProcessingShader.empty())
choice_ppshader->Select(0);
else
choice_ppshader->SetStringSelection(wxString::FromAscii(vconfig.sPostProcessingShader.c_str()));
choice_ppshader->SetStringSelection(StrToWxStr(vconfig.sPostProcessingShader));

choice_ppshader->Bind(wxEVT_COMMAND_CHOICE_SELECTED, &VideoConfigDiag::Event_PPShader, this);

Expand Down Expand Up @@ -595,7 +594,7 @@ VideoConfigDiag::VideoConfigDiag(wxWindow* parent, const std::string &title, con
void VideoConfigDiag::Event_DisplayResolution(wxCommandEvent &ev)
{
SConfig::GetInstance().m_LocalCoreStartupParameter.strFullscreenResolution =
choice_display_resolution->GetStringSelection().mb_str();
WxStrToStr(choice_display_resolution->GetStringSelection());
#if defined(HAVE_XRANDR) && HAVE_XRANDR
main_frame->m_XRRConfig->Update();
#endif
Expand Down
5 changes: 3 additions & 2 deletions Source/Core/DolphinWX/Src/VideoConfigDiag.h
Expand Up @@ -20,6 +20,7 @@
#include <wx/spinctrl.h>

#include "MsgHandler.h"
#include "WxUtils.h"

template <typename W>
class BoolSetting : public W
Expand Down Expand Up @@ -99,7 +100,7 @@ class VideoConfigDiag : public wxDialog
else
{
// Select current backend again
choice_backend->SetStringSelection(wxString::FromAscii(g_video_backend->GetName().c_str()));
choice_backend->SetStringSelection(StrToWxStr(g_video_backend->GetName()));
}
}

Expand Down Expand Up @@ -129,7 +130,7 @@ class VideoConfigDiag : public wxDialog
{
const int sel = ev.GetInt();
if (sel)
vconfig.sPostProcessingShader = ev.GetString().mb_str();
vconfig.sPostProcessingShader = WxStrToStr(ev.GetString());
else
vconfig.sPostProcessingShader.clear();

Expand Down
17 changes: 15 additions & 2 deletions Source/Core/DolphinWX/Src/WxUtils.cpp
Expand Up @@ -20,12 +20,14 @@
#include <wx/wx.h>
#include <wx/string.h>

#include "WxUtils.h"

namespace WxUtils {

// Launch a file according to its mime type
void Launch(const char *filename)
{
if (! ::wxLaunchDefaultBrowser(wxString(filename, *wxConvCurrent)))
if (! ::wxLaunchDefaultBrowser(StrToWxStr(filename)))
{
// WARN_LOG
}
Expand All @@ -34,7 +36,7 @@ void Launch(const char *filename)
// Launch an file explorer window on a certain path
void Explore(const char *path)
{
wxString wxPath = wxString(path, *wxConvCurrent);
wxString wxPath = StrToWxStr(path);
// Default to file
if (! wxPath.Contains(wxT("://")))
{
Expand All @@ -52,3 +54,14 @@ void Explore(const char *path)
}

} // namespace

std::string WxStrToStr(const wxString& str)
{
return str.ToUTF8().data();
}

wxString StrToWxStr(const std::string& str)
{
//return wxString::FromUTF8Unchecked(str.c_str());
return wxString::FromUTF8(str.c_str());
}
9 changes: 8 additions & 1 deletion Source/Core/DolphinWX/Src/WxUtils.h
Expand Up @@ -18,7 +18,11 @@
#ifndef WXUTILS_H
#define WXUTILS_H

namespace WxUtils {
#include <string>
#include <wx/string.h>

namespace WxUtils
{

// Launch a file according to its mime type
void Launch(const char *filename);
Expand All @@ -28,4 +32,7 @@ void Explore(const char *path);

} // namespace

std::string WxStrToStr(const wxString& str);
wxString StrToWxStr(const std::string& str);

#endif // WXUTILS
3 changes: 2 additions & 1 deletion Source/Core/DolphinWX/Src/X11Utils.cpp
Expand Up @@ -16,6 +16,7 @@
// http://code.google.com/p/dolphin-emu/

#include "X11Utils.h"
#include "WxUtils.h"

#include <unistd.h>
#include <spawn.h>
Expand Down Expand Up @@ -350,7 +351,7 @@ void XRRConfiguration::AddResolutions(wxArrayString& arrayStringFor_FullscreenRe
if (std::find(resos.begin(), resos.end(), strRes) == resos.end())
{
resos.push_back(strRes);
arrayStringFor_FullscreenResolution.Add(wxString::FromUTF8(strRes.c_str()));
arrayStringFor_FullscreenResolution.Add(StrToWxStr(strRes));
}
}
}
Expand Down
16 changes: 5 additions & 11 deletions Source/Core/InputCommon/Src/ControllerInterface/DInput/DInput.cpp
Expand Up @@ -4,7 +4,7 @@

#include "DInput.h"

#include <StringUtil.h>
#include "StringUtil.h"

#ifdef CIFACE_USE_DINPUT_JOYSTICK
#include "DInputJoystick.h"
Expand Down Expand Up @@ -41,24 +41,18 @@ BOOL CALLBACK DIEnumDevicesCallback(LPCDIDEVICEINSTANCE lpddi, LPVOID pvRef)

std::string GetDeviceName(const LPDIRECTINPUTDEVICE8 device)
{
std::string out;

DIPROPSTRING str;
ZeroMemory(&str, sizeof(str));
DIPROPSTRING str = {};
str.diph.dwSize = sizeof(str);
str.diph.dwHeaderSize = sizeof(str.diph);
str.diph.dwHow = DIPH_DEVICE;

std::string result;
if (SUCCEEDED(device->GetProperty(DIPROP_PRODUCTNAME, &str.diph)))
{
const int size = WideCharToMultiByte(CP_UTF8, 0, str.wsz, -1, NULL, 0, NULL, NULL);
char* const data = new char[size];
if (size == WideCharToMultiByte(CP_UTF8, 0, str.wsz, -1, data, size, NULL, NULL))
out.assign(data);
delete[] data;
result = StripSpaces(UTF16ToUTF8(str.wsz));
}

return StripSpaces(out);
return result;
}

void Init(std::vector<ControllerInterface::Device*>& devices, HWND hwnd)
Expand Down
3 changes: 2 additions & 1 deletion Source/Core/VideoCommon/Src/ImageWrite.cpp
Expand Up @@ -69,7 +69,8 @@ bool SaveTGA(const char* filename, int width, int height, void* pdata)

bool SaveData(const char* filename, const char* data)
{
std::ofstream f(filename, std::ios::binary);
std::ofstream f;
OpenFStream(f, filename, std::ios::binary);
f << data;

return true;
Expand Down
3 changes: 2 additions & 1 deletion Source/Core/VideoCommon/Src/PixelShaderGen.cpp
Expand Up @@ -252,7 +252,8 @@ void ValidatePixelShaderIDs(API_TYPE api, PIXELSHADERUIDSAFE old_id, const std::
static int num_failures = 0;
char szTemp[MAX_PATH];
sprintf(szTemp, "%spsuid_mismatch_%04i.txt", File::GetUserPath(D_DUMP_IDX).c_str(), num_failures++);
std::ofstream file(szTemp);
std::ofstream file;
OpenFStream(file, szTemp, std::ios_base::out);
file << msg;
file << "\n\nOld shader code:\n" << old_code;
file << "\n\nNew shader code:\n" << new_code;
Expand Down
6 changes: 4 additions & 2 deletions Source/Core/VideoCommon/Src/VertexManagerBase.cpp
Expand Up @@ -279,10 +279,12 @@ void VertexManager::Flush()
// save the shaders
char strfile[255];
sprintf(strfile, "%sps%.3d.txt", File::GetUserPath(D_DUMPFRAMES_IDX).c_str(), g_ActiveConfig.iSaveTargetId);
std::ofstream fps(strfile);
std::ofstream fps;
OpenFStream(fps, strfile, std::ios_base::out);
fps << ps->strprog.c_str();
sprintf(strfile, "%svs%.3d.txt", File::GetUserPath(D_DUMPFRAMES_IDX).c_str(), g_ActiveConfig.iSaveTargetId);
std::ofstream fvs(strfile);
std::ofstream fvs;
OpenFStream(fvs, strfile, std::ios_base::out);
fvs << vs->strprog.c_str();
}

Expand Down
3 changes: 2 additions & 1 deletion Source/Core/VideoCommon/Src/VertexShaderGen.cpp
Expand Up @@ -114,7 +114,8 @@ void ValidateVertexShaderIDs(API_TYPE api, VERTEXSHADERUIDSAFE old_id, const std
static int num_failures = 0;
char szTemp[MAX_PATH];
sprintf(szTemp, "%svsuid_mismatch_%04i.txt", File::GetUserPath(D_DUMP_IDX).c_str(), num_failures++);
std::ofstream file(szTemp);
std::ofstream file;
OpenFStream(file, szTemp, std::ios_base::out);
file << msg;
file << "\n\nOld shader code:\n" << old_code;
file << "\n\nNew shader code:\n" << new_code;
Expand Down
9 changes: 6 additions & 3 deletions Source/Plugins/Plugin_VideoDX11/Src/D3DShader.cpp
Expand Up @@ -64,7 +64,8 @@ bool CompileVertexShader(const char* code, unsigned int len, D3DBlob** blob)
static int num_failures = 0;
char szTemp[MAX_PATH];
sprintf(szTemp, "%sbad_vs_%04i.txt", File::GetUserPath(D_DUMP_IDX).c_str(), num_failures++);
std::ofstream file(szTemp);
std::ofstream file;
OpenFStream(file, szTemp, std::ios_base::out);
file << code;
file.close();

Expand Down Expand Up @@ -121,7 +122,8 @@ bool CompileGeometryShader(const char* code, unsigned int len, D3DBlob** blob,
static int num_failures = 0;
char szTemp[MAX_PATH];
sprintf(szTemp, "%sbad_gs_%04i.txt", File::GetUserPath(D_DUMP_IDX).c_str(), num_failures++);
std::ofstream file(szTemp);
std::ofstream file;
OpenFStream(file, szTemp, std::ios_base::out);
file << code;
file.close();

Expand Down Expand Up @@ -180,7 +182,8 @@ bool CompilePixelShader(const char* code, unsigned int len, D3DBlob** blob,
static int num_failures = 0;
char szTemp[MAX_PATH];
sprintf(szTemp, "%sbad_ps_%04i.txt", File::GetUserPath(D_DUMP_IDX).c_str(), num_failures++);
std::ofstream file(szTemp);
std::ofstream file;
OpenFStream(file, szTemp, std::ios_base::out);
file << code;
file.close();

Expand Down
6 changes: 2 additions & 4 deletions Source/Plugins/Plugin_VideoDX11/Src/main.cpp
Expand Up @@ -103,15 +103,13 @@ void InitBackendInfo()
if (FAILED(hr))
PanicAlert("Failed to create IDXGIFactory object");

char tmpstr[512] = {};
DXGI_ADAPTER_DESC desc;
// adapters
g_Config.backend_info.Adapters.clear();
g_Config.backend_info.AAModes.clear();
while (factory->EnumAdapters((UINT)g_Config.backend_info.Adapters.size(), &ad) != DXGI_ERROR_NOT_FOUND)
{
DXGI_ADAPTER_DESC desc;
ad->GetDesc(&desc);
WideCharToMultiByte(/*CP_UTF8*/CP_ACP, 0, desc.Description, -1, tmpstr, 512, 0, false);

// TODO: These don't get updated on adapter change, yet
if (g_Config.backend_info.Adapters.size() == g_Config.iAdapter)
Expand All @@ -128,7 +126,7 @@ void InitBackendInfo()
}
}

g_Config.backend_info.Adapters.push_back(tmpstr);
g_Config.backend_info.Adapters.push_back(UTF16ToUTF8(desc.Description));
ad->Release();
}

Expand Down
6 changes: 4 additions & 2 deletions Source/Plugins/Plugin_VideoDX9/Src/D3DShader.cpp
Expand Up @@ -50,7 +50,8 @@ bool CompileVertexShader(const char *code, int len, u8 **bytecode, int *bytecode
static int num_failures = 0;
char szTemp[MAX_PATH];
sprintf(szTemp, "%sbad_vs_%04i.txt", File::GetUserPath(D_DUMP_IDX).c_str(), num_failures++);
std::ofstream file(szTemp);
std::ofstream file;
OpenFStream(file, szTemp, std::ios_base::out);
file << code;
file.close();

Expand Down Expand Up @@ -105,7 +106,8 @@ bool CompilePixelShader(const char *code, int len, u8 **bytecode, int *bytecodel
static int num_failures = 0;
char szTemp[MAX_PATH];
sprintf(szTemp, "%sbad_ps_%04i.txt", File::GetUserPath(D_DUMP_IDX).c_str(), num_failures++);
std::ofstream file(szTemp);
std::ofstream file;
OpenFStream(file, szTemp, std::ios_base::out);
file << code;
file.close();

Expand Down
3 changes: 2 additions & 1 deletion Source/Plugins/Plugin_VideoOGL/Src/PixelShaderCache.cpp
Expand Up @@ -264,7 +264,8 @@ bool PixelShaderCache::CompilePixelShader(FRAGMENTSHADER& ps, const char* pstrpr
static int num_failures = 0;
char szTemp[MAX_PATH];
sprintf(szTemp, "%sbad_ps_%04i.txt", File::GetUserPath(D_DUMP_IDX).c_str(), num_failures++);
std::ofstream file(szTemp);
std::ofstream file;
OpenFStream(file, szTemp, std::ios_base::out);
file << pstrprogram;
file.close();

Expand Down
3 changes: 2 additions & 1 deletion Source/Plugins/Plugin_VideoOGL/Src/Render.cpp
Expand Up @@ -24,6 +24,7 @@
#include <cstdio>

#include "GLUtil.h"
#include "WxUtils.h"

#include "FileUtil.h"

Expand Down Expand Up @@ -1539,7 +1540,7 @@ void TakeScreenshot(ScrStrct* threadStruct)

// Save the screenshot and finally kill the wxImage object
// This is really expensive when saving to PNG, but not at all when using BMP
threadStruct->img->SaveFile(wxString::FromAscii(threadStruct->filename.c_str()),
threadStruct->img->SaveFile(StrToWxStr(threadStruct->filename),
wxBITMAP_TYPE_PNG);
threadStruct->img->Destroy();

Expand Down
6 changes: 4 additions & 2 deletions Source/Plugins/Plugin_VideoOGL/Src/VertexManager.cpp
Expand Up @@ -253,10 +253,12 @@ void VertexManager::vFlush()
// save the shaders
char strfile[255];
sprintf(strfile, "%sps%.3d.txt", File::GetUserPath(D_DUMPFRAMES_IDX).c_str(), g_ActiveConfig.iSaveTargetId);
std::ofstream fps(strfile);
std::ofstream fps;
OpenFStream(fps, strfile, std::ios_base::out);
fps << ps->strprog.c_str();
sprintf(strfile, "%svs%.3d.txt", File::GetUserPath(D_DUMPFRAMES_IDX).c_str(), g_ActiveConfig.iSaveTargetId);
std::ofstream fvs(strfile);
std::ofstream fvs;
OpenFStream(fvs, strfile, std::ios_base::out);
fvs << vs->strprog.c_str();
}

Expand Down
3 changes: 2 additions & 1 deletion Source/Plugins/Plugin_VideoOGL/Src/VertexShaderCache.cpp
Expand Up @@ -144,7 +144,8 @@ bool VertexShaderCache::CompileVertexShader(VERTEXSHADER& vs, const char* pstrpr
static int num_failures = 0;
char szTemp[MAX_PATH];
sprintf(szTemp, "%sbad_vs_%04i.txt", File::GetUserPath(D_DUMP_IDX).c_str(), num_failures++);
std::ofstream file(szTemp);
std::ofstream file;
OpenFStream(file, szTemp, std::ios_base::out);
file << pstrprogram;
file.close();

Expand Down
6 changes: 3 additions & 3 deletions Source/Plugins/Plugin_VideoSoftware/Src/VideoConfigDialog.cpp
Expand Up @@ -34,7 +34,7 @@ IntegerSetting<T>::IntegerSetting(wxWindow* parent, const wxString& label, T& se

VideoConfigDialog::VideoConfigDialog(wxWindow* parent, const std::string& title, const std::string& _ininame) :
wxDialog(parent, -1,
wxString(wxT("Dolphin ")).append(wxString::FromAscii(title.c_str())).append(wxT(" Graphics Configuration")),
wxString(wxT("Dolphin ")).append(StrToWxStr(title)).append(wxT(" Graphics Configuration")),
wxDefaultPosition, wxDefaultSize),
vconfig(g_SWVideoConfig),
ininame(_ininame)
Expand Down Expand Up @@ -64,10 +64,10 @@ VideoConfigDialog::VideoConfigDialog(wxWindow* parent, const std::string& title,
it = g_available_video_backends.begin(),
itend = g_available_video_backends.end();
for (; it != itend; ++it)
choice_backend->AppendString(wxString::FromAscii((*it)->GetName().c_str()));
choice_backend->AppendString(StrToWxStr((*it)->GetName()));

// TODO: How to get the translated plugin name?
choice_backend->SetStringSelection(wxString::FromAscii(g_video_backend->GetName().c_str()));
choice_backend->SetStringSelection(StrToWxStr(g_video_backend->GetName()));
choice_backend->Bind(wxEVT_COMMAND_CHOICE_SELECTED, &VideoConfigDialog::Event_Backend, this);

szr_rendering->Add(label_backend, 1, wxALIGN_CENTER_VERTICAL, 5);
Expand Down