diff --git a/Windows/main.cpp b/Windows/main.cpp index c4c79c809c..6894c8105f 100644 --- a/Windows/main.cpp +++ b/Windows/main.cpp @@ -15,6 +15,7 @@ // Official git repository and contact information can be found at // https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/. +#include #include #include #include @@ -332,6 +333,26 @@ bool System_InputBoxGetWString(const wchar_t *title, const std::wstring &default } } +static std::string GetDefaultLangRegion() { + wchar_t lcLangName[256] = {}; + + // LOCALE_SNAME is only available in WinVista+ + if (0 != GetLocaleInfo(LOCALE_NAME_USER_DEFAULT, LOCALE_SNAME, lcLangName, ARRAY_SIZE(lcLangName))) { + std::string result = ConvertWStringToUTF8(lcLangName); + std::replace(result.begin(), result.end(), '-', '_'); + return result; + } else { + // This should work on XP, but we may get numbers for some countries. + if (0 != GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SISO639LANGNAME, lcLangName, ARRAY_SIZE(lcLangName))) { + wchar_t lcRegion[256] = {}; + if (0 != GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SISO3166CTRYNAME, lcRegion, ARRAY_SIZE(lcRegion))) { + return ConvertWStringToUTF8(lcLangName) + "_" + ConvertWStringToUTF8(lcRegion); + } + } + // Unfortunate default. We tried. + return "en_US"; + } +} std::vector GetWideCmdLine() { wchar_t **wargv; @@ -365,27 +386,14 @@ int WINAPI WinMain(HINSTANCE _hInstance, HINSTANCE hPrevInstance, LPSTR szCmdLin #ifndef _DEBUG bool showLog = false; #else - bool showLog = false; + bool showLog = true; #endif const std::string &exePath = File::GetExeDirectory(); VFSRegister("", new DirectoryAssetReader((exePath + "/assets/").c_str())); VFSRegister("", new DirectoryAssetReader(exePath.c_str())); - wchar_t lcCountry[256]; - - // LOCALE_SNAME is only available in WinVista+ - // Really should find a way to do this in XP too :/ - if (0 != GetLocaleInfo(LOCALE_NAME_USER_DEFAULT, LOCALE_SNAME, lcCountry, 256)) { - langRegion = ConvertWStringToUTF8(lcCountry); - for (size_t i = 0; i < langRegion.size(); i++) { - if (langRegion[i] == '-') - langRegion[i] = '_'; - } - } else { - langRegion = "en_US"; - } - + langRegion = GetDefaultLangRegion(); osName = GetWindowsVersion() + " " + GetWindowsSystemArchitecture(); char configFilename[MAX_PATH] = { 0 };