Win32: Fix file deletion from scenario selection dialogue

objectmenu
Sven Eberhardt 2016-01-24 00:43:09 -05:00
parent 28e794654c
commit d9b8de9ea2
6 changed files with 11 additions and 7 deletions

View File

@ -586,7 +586,7 @@ IDS_MSG_PLAYERASSIGNMENT=Teilnehmer %s übernimmt Spieler %s aus dem Spielstand.
IDS_MSG_PRESSBTN=Taste für "%s" auf Gamepad drücken.
IDS_MSG_PRESSKEY=Taste für "%s" auf der Tastatur drücken.
IDS_MSG_PRESSORPUSHANYGAMEPADBUTT=Taste %s öffnet das Zuschauermenü.
IDS_MSG_PROMPTDELETE=%s löschen?
IDS_MSG_PROMPTDELETE=%s löschen?|(Dateiname: %s)
IDS_MSG_PROMPTRESETCONFIG=Sollen alle Konfigurationswerte zurückgesetzt werden?
IDS_MSG_RANK=[Rang
IDS_MSG_REMOVEPLR=&Entfernen

View File

@ -586,7 +586,7 @@ IDS_MSG_PLAYERASSIGNMENT=Participant %s will continue for player %s from the sav
IDS_MSG_PRESSBTN=Press the button for "%s" on the gamepad.
IDS_MSG_PRESSKEY=Press the key for "%s" on the keyboard.
IDS_MSG_PRESSORPUSHANYGAMEPADBUTT=Press %s or any gamepad button to open observer menu.
IDS_MSG_PROMPTDELETE=Delete %s?
IDS_MSG_PROMPTDELETE=Delete %s?|(Filename: %s)
IDS_MSG_PROMPTRESETCONFIG=Are you sure you want to reset all configuration values?
IDS_MSG_RANK=Rank
IDS_MSG_REMOVEPLR=&Remove

View File

@ -1844,7 +1844,7 @@ bool C4StartupScenSelDlg::KeyDelete()
if (!pSel) return false;
C4ScenarioListLoader::Entry *pEnt = pSel->GetEntry();
StdStrBuf sWarning;
sWarning.Format(LoadResStr("IDS_MSG_PROMPTDELETE"), FormatString("%s %s", pEnt->GetTypeName().getData(), pEnt->GetName().getData()).getData());
sWarning.Format(LoadResStr("IDS_MSG_PROMPTDELETE"), FormatString("%s %s", pEnt->GetTypeName().getData(), pEnt->GetName().getData()).getData(), pEnt->GetEntryFilename().getData());
GetScreen()->ShowRemoveDlg(new C4GUI::ConfirmationDialog(sWarning.getData(), LoadResStr("IDS_MNU_DELETE"),
new C4GUI::CallbackHandlerExPar<C4StartupScenSelDlg, ScenListItem *>(this, &C4StartupScenSelDlg::DeleteConfirm, pSel), C4GUI::MessageDialog::btnYesNo));
return true;

View File

@ -169,11 +169,13 @@ StdBuf StdStrBuf::GetWideCharBuf()
MultiByteToWideChar(CP_UTF8, 0, getData(), getSize(), getMBufPtr<wchar_t>(r), len);
return r;
}
StdStrBuf::wchar_t_holder GetWideChar(const char * utf8)
StdStrBuf::wchar_t_holder GetWideChar(const char * utf8, bool double_null_terminate)
{
int len = MultiByteToWideChar(CP_UTF8, 0, utf8, -1, NULL, 0);
if (double_null_terminate) ++len;
wchar_t * p = new wchar_t[len];
MultiByteToWideChar(CP_UTF8, 0, utf8, -1, p, len);
if (double_null_terminate) p[len - 1] = wchar_t(0);
return StdStrBuf::wchar_t_holder(p);
}
StdBuf GetWideCharBuf(const char * utf8)

View File

@ -28,7 +28,7 @@
#undef DrawText
// implemented in StdBuf.cpp
StdStrBuf::wchar_t_holder GetWideChar(const char * utf8);
StdStrBuf::wchar_t_holder GetWideChar(const char * utf8, bool double_null_terminate = false);
StdBuf GetWideCharBuf(const char * utf8);
#define ADDL2(s) L##s

View File

@ -29,16 +29,18 @@ bool EraseItemSafe(const char *szFilename)
char Filename[_MAX_PATH+1];
SCopy(szFilename, Filename, _MAX_PATH);
Filename[SLen(Filename)+1]=0;
auto wide_filename = GetWideChar(Filename, true); // wide_filename holds the buffer
SHFILEOPSTRUCTW shs;
shs.hwnd=0;
shs.wFunc=FO_DELETE;
shs.pFrom=GetWideChar(Filename);
shs.pFrom = wide_filename;
shs.pTo=NULL;
shs.fFlags=FOF_ALLOWUNDO | FOF_NOCONFIRMATION | FOF_SILENT;
shs.fAnyOperationsAborted=false;
shs.hNameMappings=0;
shs.lpszProgressTitle=NULL;
return !SHFileOperationW(&shs);
auto error = SHFileOperationW(&shs);
return !error;
}
bool IsGermanSystem()