Skip to content

Commit

Permalink
Detect language on first boot on Windows (Vista+) and Android
Browse files Browse the repository at this point in the history
  • Loading branch information
hrydgard committed Sep 4, 2013
1 parent 8e6b031 commit ad620e4
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 8 deletions.
12 changes: 11 additions & 1 deletion Core/Config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include "Common/FileUtil.h"
#include "Config.h"
#include "file/ini_file.h"
#include "i18n/i18n.h"
#include "HLE/sceUtility.h"
#include "Common/CPUDetect.h"

Expand Down Expand Up @@ -55,7 +56,16 @@ void Config::Load(const char *iniFileName, const char *controllerIniFilename)
general->Get("IgnoreBadMemAccess", &bIgnoreBadMemAccess, true);
general->Get("CurrentDirectory", &currentDirectory, "");
general->Get("ShowDebuggerOnLoad", &bShowDebuggerOnLoad, false);
general->Get("Language", &languageIni, "en_US");

std::string defaultLangRegion = "en_US";
if (bFirstRun) {
std::string langRegion = System_GetProperty(SYSPROP_LANGREGION);
if (i18nrepo.IniExists(langRegion))
defaultLangRegion = langRegion;
// TODO: Be smart about same language, different country
}

general->Get("Language", &languageIni, defaultLangRegion.c_str());
general->Get("NumWorkerThreads", &iNumWorkerThreads, cpu_info.num_cores);
general->Get("EnableCheats", &bEnableCheats, false);
general->Get("ScreenshotsAsPNG", &bScreenshotsAsPNG, false);
Expand Down
2 changes: 1 addition & 1 deletion UI/MiscScreens.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2013- PPSSPP Project.
// Copyright (c) 2013- PPSSPP Project.

// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
Expand Down
25 changes: 21 additions & 4 deletions Windows/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 <WinNls.h>
#include "Common/CommonWindows.h"

#include "file/vfs.h"
Expand Down Expand Up @@ -51,6 +52,8 @@
CDisasm *disasmWindow[MAX_CPUCOUNT] = {0};
CMemoryDlg *memoryWindow[MAX_CPUCOUNT] = {0};

static std::string langRegion;

void LaunchBrowser(const char *url) {
ShellExecute(NULL, L"open", ConvertUTF8ToWString(url).c_str(), NULL, NULL, SW_SHOWNORMAL);
}
Expand All @@ -60,7 +63,7 @@ std::string System_GetProperty(SystemProperty prop) {
case SYSPROP_NAME:
return "PC:Windows";
case SYSPROP_LANGREGION:
return "en_US";
return langRegion;
default:
return "";
}
Expand All @@ -87,7 +90,6 @@ int WINAPI WinMain(HINSTANCE _hInstance, HINSTANCE hPrevInstance, LPSTR szCmdLin
hideLog = false;
#endif


// The rest is handled in NativeInit().
for (int i = 1; i < __argc; ++i)
{
Expand All @@ -109,14 +111,29 @@ int WINAPI WinMain(HINSTANCE _hInstance, HINSTANCE hPrevInstance, LPSTR szCmdLin
}
}

VFSRegister("", new DirectoryAssetReader("assets/"));
VFSRegister("", new DirectoryAssetReader(""));

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 (int i = 0; i < langRegion.size(); i++) {
if (langRegion[i] == '-')
langRegion[i] = '_';
}
} else {
langRegion = "en_US";
}

g_Config.Load();

LogManager::Init();
LogManager::GetInstance()->GetConsoleListener()->Open(hideLog, 150, 120, "PPSSPP Debug Console");
LogManager::GetInstance()->SetLogLevel(LogTypes::G3D, LogTypes::LERROR);

VFSRegister("", new DirectoryAssetReader("assets/"));
VFSRegister("", new DirectoryAssetReader(""));

//Windows, API init stuff
INITCOMMONCONTROLSEX comm;
Expand Down
5 changes: 4 additions & 1 deletion headless/Headless.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
#include "Core/Host.h"
#include "Log.h"
#include "LogManager.h"
#include "native/input/input_state.h"
#include "base/NativeApp.h"
#include "input/input_state.h"

#include "Compare.h"
#include "StubHost.h"
Expand Down Expand Up @@ -57,6 +58,8 @@ void GL_SwapBuffers() { }
void NativeUpdate(InputState &input_state) { }
void NativeRender() { }

std::string System_GetProperty(SystemProperty prop) { return ""; }

#ifndef _WIN32
InputState input_state;
#endif
Expand Down
2 changes: 2 additions & 0 deletions unittest/UnitTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#include <cmath>
#include <string>

#include "base/NativeApp.h"
#include "Common/ArmEmitter.h"
#include "ext/disarm.h"
#include "math/math_util.h"
Expand All @@ -41,6 +42,7 @@

#define RET(a) if (!(a)) { return false; }

std::string System_GetProperty(SystemProperty prop) { return ""; }

bool CheckLast(ArmGen::ARMXEmitter &emit, const char *comp) {
u32 instr;
Expand Down

0 comments on commit ad620e4

Please sign in to comment.