GUI: U32: Use unicode strings for native Windows dialogs

These make use of newly added win-wrapper UTF8ToUnicode.
This commit is contained in:
aryanrawlani28 2020-07-22 04:49:07 +05:30 committed by Eugene Sandulenko
parent 93cb408c05
commit f95762881e
2 changed files with 10 additions and 8 deletions

View File

@ -100,7 +100,7 @@ HRESULT getShellPath(IShellItem *item, Common::String &path) {
return hr;
}
Common::DialogManager::DialogResult Win32DialogManager::showFileBrowser(const char *title, Common::FSNode &choice, bool isDirBrowser) {
Common::DialogManager::DialogResult Win32DialogManager::showFileBrowser(const Common::U32String &title, Common::FSNode &choice, bool isDirBrowser) {
DialogResult result = kDialogError;
// Do nothing if not running on Windows Vista or later
@ -130,14 +130,15 @@ Common::DialogManager::DialogResult Win32DialogManager::showFileBrowser(const ch
hr = dialog->SetOptions(dwOptions);
}
LPWSTR str = Win32::ansiToUnicode(title, Win32::getCurrentCharset());
hr = dialog->SetTitle(str);
free(str);
LPWSTR dialogTitle = Win32::UTF8ToUnicode(title.encode().c_str());
hr = dialog->SetTitle(dialogTitle);
free(dialogTitle);
str = Win32::ansiToUnicode(Common::convertFromU32String(_("Choose")).c_str(), Win32::getCurrentCharset());
hr = dialog->SetOkButtonLabel(str);
free(str);
LPWSTR okTitle = Win32::UTF8ToUnicode(_("Choose").encode().c_str());
hr = dialog->SetOkButtonLabel(okTitle);
free(okTitle);
LPWSTR str;
if (ConfMan.hasKey("browser_lastpath")) {
str = Win32::ansiToUnicode(ConfMan.get("browser_lastpath").c_str());
IShellItem *item = NULL;

View File

@ -27,6 +27,7 @@
#include "common/fs.h"
#include "common/dialogs.h"
#include "common/ustr.h"
class SdlWindow_Win32;
@ -34,7 +35,7 @@ class Win32DialogManager : public Common::DialogManager {
public:
Win32DialogManager(SdlWindow_Win32 *window);
virtual ~Win32DialogManager();
virtual DialogResult showFileBrowser(const char *title, Common::FSNode &choice, bool isDirBrowser);
virtual DialogResult showFileBrowser(const Common::U32String &title, Common::FSNode &choice, bool isDirBrowser);
private:
SdlWindow_Win32 *_window;