From 76fafe02304cafc363795da1180f89e140304dcb Mon Sep 17 00:00:00 2001 From: zeromus Date: Tue, 5 May 2020 02:00:58 -0400 Subject: [PATCH] winport - fix drag & drop and recent roms menu so I can verify whether any of that stuff works in chinese --- desmume/src/frontend/windows/main.cpp | 9 +++---- desmume/src/frontend/windows/recentroms.cpp | 26 +++++++++++---------- 2 files changed, 19 insertions(+), 16 deletions(-) diff --git a/desmume/src/frontend/windows/main.cpp b/desmume/src/frontend/windows/main.cpp index 664ceed50..7cd83153d 100755 --- a/desmume/src/frontend/windows/main.cpp +++ b/desmume/src/frontend/windows/main.cpp @@ -4253,12 +4253,13 @@ DOKEYDOWN: case WM_DROPFILES: { - char filename[MAX_PATH] = ""; - DragQueryFile((HDROP)wParam,0,filename,MAX_PATH); + wchar_t wfilename[MAX_PATH] = L""; + DragQueryFileW((HDROP)wParam,0,wfilename,MAX_PATH); DragFinish((HDROP)wParam); + std::string fileDropped = wcstombs((std::wstring)wfilename); + const char* filename = fileDropped.c_str(); //adelikat: dropping these in from FCEUX, I hope this is the best place for that - std::string fileDropped = filename; //------------------------------------------------------- //Check if Movie file //------------------------------------------------------- @@ -4326,7 +4327,7 @@ DOKEYDOWN: //Else load it as a ROM //------------------------------------------------------- - else if(OpenCoreSystemCP(filename)) + else if(OpenCore(filename)) { romloaded = TRUE; } diff --git a/desmume/src/frontend/windows/recentroms.cpp b/desmume/src/frontend/windows/recentroms.cpp index d5d213753..acc7077c6 100644 --- a/desmume/src/frontend/windows/recentroms.cpp +++ b/desmume/src/frontend/windows/recentroms.cpp @@ -41,6 +41,7 @@ void PopulateRecentRomsMenu() //---------------------------------------------------------------------- //Get Menu item info + MENUITEMINFOW moow; MENUITEMINFO moo; moo.cbSize = sizeof(moo); moo.fMask = MIIM_SUBMENU | MIIM_STATE; @@ -91,20 +92,21 @@ void PopulateRecentRomsMenu() //the recent roms are UTF-8, so convert to windows stupid codepage auto wtmp = mbstowcs(tmp); - char garbage[1024]; - WideCharToMultiByte(CP_ACP,0,wtmp.c_str(),-1,garbage,1024,NULL,NULL); + wchar_t garbage[1024]; + wcscpy(garbage,wtmp.c_str()); - PathCompactPath(dc, garbage, 500); + PathCompactPathW(dc, garbage, 500); - moo.cbSize = sizeof(moo); - moo.fMask = MIIM_DATA | MIIM_ID | MIIM_TYPE; + memset(&moow, 0, sizeof(moow)); + moow.cbSize = sizeof(moo); + moow.fMask = MIIM_DATA | MIIM_ID | MIIM_TYPE; - moo.cch = tmp.size(); - moo.fType = 0; - moo.wID = recentRoms_baseid + x; - moo.dwTypeData = garbage; + moow.cch = wtmp.size(); + moow.fType = 0; + moow.wID = recentRoms_baseid + x; + moow.dwTypeData = garbage; //LOG("Inserting: %s\n",tmp.c_str()); //Debug - InsertMenuItem(GetSubMenu(recentromsmenu, 0), 0, 1, &moo); + InsertMenuItemW(GetSubMenu(recentromsmenu, 0), 0, 1, &moow); } ReleaseDC(MainWindow->getHWnd(), dc); @@ -141,7 +143,7 @@ void LoadRecentRoms() //This function retrieves the recent ROMs stored in the .ini file //Then is populates the RecentRomsMenu array - char tempstr[256]; + char tempstr[1024]; // Avoids duplicating when changing the language. RecentRoms.clear(); @@ -152,7 +154,7 @@ void LoadRecentRoms() char keyName[100]; sprintf(keyName,"Recent Rom %d",x); - GetPrivateProfileString("General",keyName,"", tempstr, 256, IniName); + GetPrivateProfileString("General",keyName,"", tempstr, 1024, IniName); if (tempstr[0]) RecentRoms.push_back(tempstr); }