From ce4ff48df5bffec403b0ef96b0b31471083515e5 Mon Sep 17 00:00:00 2001 From: William JCM Date: Thu, 9 Jan 2020 22:10:38 +0100 Subject: [PATCH] EvtMainFrame: make the previous fix Unicode-aware. I hate the Windows API. --- GUI/EvtMainFrame.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/GUI/EvtMainFrame.cpp b/GUI/EvtMainFrame.cpp index 9e21d1d..51744ff 100644 --- a/GUI/EvtMainFrame.cpp +++ b/GUI/EvtMainFrame.cpp @@ -22,9 +22,13 @@ #include #include +#define WIN32_LEAN_AND_MEAN +#include + #include #include #include +#include #include "EvtMainFrame.h" @@ -179,7 +183,14 @@ void EvtMainFrame::timerEvent(wxTimerEvent&) { } void EvtMainFrame::getSaveDirectory() { - _saveDirectory = Utility::Directory::join(Utility::Directory::fromNativeSeparators(getenv("localappdata")), "MASS_Builder/Saved/SaveGames"); + wchar_t h[MAX_PATH]; + if(!SUCCEEDED(SHGetFolderPathW(nullptr, CSIDL_LOCAL_APPDATA, nullptr, 0, h))) { + errorMessage("Couldn't get the path for %LOCALAPPDATA%. :/"); + Close(); + return; + } + + _saveDirectory = Utility::Directory::join(Utility::Directory::fromNativeSeparators(Utility::Unicode::narrow(h)), "MASS_Builder/Saved/SaveGames"); if(!Utility::Directory::exists(_saveDirectory)) { errorMessage("Couldn't find the M.A.S.S. Builder save directory at " + _saveDirectory + ". Please run the game at least once to create it.");