mirror of https://github.com/PCSX2/pcsx2.git
gsdx:windows: Handle capture dialog filenames properly
The capture dialog filename handling code did not handle non-English filenames properly. Fix the filename handling by working in Unicode only and avoiding unnecessary and incorrect string conversions.
This commit is contained in:
parent
d81f236910
commit
157add3eea
|
@ -424,15 +424,15 @@ bool GSCapture::BeginCapture(float fps, GSVector2i recommendedResolution, float
|
|||
const int start = dlg.m_filename.length() - 4;
|
||||
if (start > 0)
|
||||
{
|
||||
std::string test = dlg.m_filename.substr(start);
|
||||
std::wstring test = dlg.m_filename.substr(start);
|
||||
std::transform(test.begin(), test.end(), test.begin(), (char(_cdecl*)(int))tolower);
|
||||
if (test.compare(".avi") != 0)
|
||||
dlg.m_filename += ".avi";
|
||||
if (test.compare(L".avi") != 0)
|
||||
dlg.m_filename += L".avi";
|
||||
}
|
||||
else
|
||||
dlg.m_filename += ".avi";
|
||||
dlg.m_filename += L".avi";
|
||||
|
||||
FILE* test = fopen(dlg.m_filename.c_str(), "w");
|
||||
FILE* test = _wfopen(dlg.m_filename.c_str(), L"w");
|
||||
if (test)
|
||||
fclose(test);
|
||||
else
|
||||
|
@ -507,7 +507,7 @@ bool GSCapture::BeginCapture(float fps, GSVector2i recommendedResolution, float
|
|||
CComQIPtr<IGSSource>(m_src)->DeliverNewSegment();
|
||||
|
||||
m_capturing = true;
|
||||
filename = dlg.m_filename.erase(dlg.m_filename.length() - 3, 3) + "wav";
|
||||
filename = convert_utf16_to_utf8(dlg.m_filename.erase(dlg.m_filename.length() - 3, 3) + L"wav");
|
||||
return true;
|
||||
#elif defined(__unix__)
|
||||
// Note I think it doesn't support multiple depth creation
|
||||
|
|
|
@ -22,8 +22,6 @@
|
|||
#include "stdafx.h"
|
||||
#include "GSdx.h"
|
||||
#include "GSCaptureDlg.h"
|
||||
#include <codecvt>
|
||||
#include <locale>
|
||||
|
||||
#define BeginEnumSysDev(clsid, pMoniker) \
|
||||
{CComPtr<ICreateDevEnum> pDevEnum4$##clsid; \
|
||||
|
@ -39,10 +37,8 @@
|
|||
|
||||
void GSCaptureDlg::InvalidFile()
|
||||
{
|
||||
wchar_t tmp[512];
|
||||
std::wstring tmpstr(m_filename.begin(), m_filename.end());
|
||||
swprintf_s(tmp, L"GSdx couldn't open file for capturing: %ls.\nCapture aborted.", tmpstr.c_str());
|
||||
MessageBox(GetActiveWindow(), tmp, L"GSdx System Message", MB_OK | MB_SETFOREGROUND);
|
||||
const std::wstring message = L"GSdx couldn't open file for capturing: " + m_filename + L".\nCapture aborted.";
|
||||
MessageBox(GetActiveWindow(), message.c_str(), L"GSdx System Message", MB_OK | MB_SETFOREGROUND);
|
||||
}
|
||||
|
||||
GSCaptureDlg::GSCaptureDlg()
|
||||
|
@ -50,7 +46,7 @@ GSCaptureDlg::GSCaptureDlg()
|
|||
{
|
||||
m_width = theApp.GetConfigI("CaptureWidth");
|
||||
m_height = theApp.GetConfigI("CaptureHeight");
|
||||
m_filename = theApp.GetConfigS("CaptureFileName");
|
||||
m_filename = convert_utf8_to_utf16(theApp.GetConfigS("CaptureFileName"));
|
||||
}
|
||||
|
||||
int GSCaptureDlg::GetSelCodec(Codec& c)
|
||||
|
@ -106,8 +102,7 @@ void GSCaptureDlg::OnInit()
|
|||
|
||||
SetTextAsInt(IDC_WIDTH, m_width);
|
||||
SetTextAsInt(IDC_HEIGHT, m_height);
|
||||
std::wstring tmp = std::wstring(m_filename.begin(), m_filename.end());
|
||||
SetText(IDC_FILENAME, tmp.c_str());
|
||||
SetText(IDC_FILENAME, m_filename.c_str());
|
||||
|
||||
m_codecs.clear();
|
||||
|
||||
|
@ -185,15 +180,11 @@ bool GSCaptureDlg::OnCommand(HWND hWnd, UINT id, UINT code)
|
|||
ofn.lpstrFilter = L"Avi files (*.avi)\0*.avi\0";
|
||||
ofn.Flags = OFN_EXPLORER | OFN_ENABLESIZING | OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT | OFN_PATHMUSTEXIST;
|
||||
|
||||
std::wstring tmp = std::wstring(m_filename.begin(), m_filename.end());
|
||||
wcscpy(ofn.lpstrFile, tmp.c_str());
|
||||
wcscpy(ofn.lpstrFile, m_filename.c_str());
|
||||
if (GetSaveFileName(&ofn))
|
||||
{
|
||||
tmp = ofn.lpstrFile;
|
||||
using convert_type = std::codecvt_utf8<wchar_t>;
|
||||
std::wstring_convert<convert_type, wchar_t> converter;
|
||||
m_filename = converter.to_bytes(tmp);
|
||||
SetText(IDC_FILENAME, tmp.c_str());
|
||||
m_filename = ofn.lpstrFile;
|
||||
SetText(IDC_FILENAME, m_filename.c_str());
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -254,7 +245,7 @@ bool GSCaptureDlg::OnCommand(HWND hWnd, UINT id, UINT code)
|
|||
|
||||
theApp.SetConfig("CaptureWidth", m_width);
|
||||
theApp.SetConfig("CaptureHeight", m_height);
|
||||
theApp.SetConfig("CaptureFileName", m_filename.c_str());
|
||||
theApp.SetConfig("CaptureFileName", convert_utf16_to_utf8(m_filename).c_str());
|
||||
|
||||
if (ris != 2)
|
||||
theApp.SetConfig("CaptureVideoCodecDisplayName", c.DisplayName);
|
||||
|
|
|
@ -50,7 +50,7 @@ public:
|
|||
|
||||
int m_width;
|
||||
int m_height;
|
||||
std::string m_filename;
|
||||
std::wstring m_filename;
|
||||
INT_PTR m_colorspace;
|
||||
CComPtr<IBaseFilter> m_enc;
|
||||
};
|
||||
|
|
|
@ -125,9 +125,9 @@ bool GSDialog::OnCommand(HWND hWnd, UINT id, UINT code)
|
|||
return false;
|
||||
}
|
||||
|
||||
std::string GSDialog::GetText(UINT id)
|
||||
std::wstring GSDialog::GetText(UINT id)
|
||||
{
|
||||
std::string s;
|
||||
std::wstring s;
|
||||
|
||||
wchar_t* buff = NULL;
|
||||
|
||||
|
@ -137,8 +137,7 @@ std::string GSDialog::GetText(UINT id)
|
|||
|
||||
if(GetDlgItemText(m_hWnd, id, buff, size))
|
||||
{
|
||||
std::wstring tmp(buff);
|
||||
s = std::string(tmp.begin(), tmp.end());
|
||||
s = buff;
|
||||
size = limit;
|
||||
}
|
||||
|
||||
|
@ -150,7 +149,7 @@ std::string GSDialog::GetText(UINT id)
|
|||
|
||||
int GSDialog::GetTextAsInt(UINT id)
|
||||
{
|
||||
return atoi(GetText(id).c_str());
|
||||
return _wtoi(GetText(id).c_str());
|
||||
}
|
||||
|
||||
void GSDialog::SetText(UINT id, const wchar_t* str)
|
||||
|
|
|
@ -45,7 +45,7 @@ public:
|
|||
|
||||
INT_PTR DoModal();
|
||||
|
||||
std::string GetText(UINT id);
|
||||
std::wstring GetText(UINT id);
|
||||
int GetTextAsInt(UINT id);
|
||||
|
||||
void SetText(UINT id, const wchar_t* str);
|
||||
|
|
Loading…
Reference in New Issue