jak-project/game/sce/libscf.cpp
ManDude 190fa4bbe8
[windows] make the games start up in the user's preferred system UI language (#2267)
Where applicable, of course.

My system language is set to English so I actually can't test this. If
anyone has their Windows language (NOT LOCALE) set to Spanish, German,
French, Italian or Japanese please test this.

Fixes #1734 

Also fixes the opengoal debugger on Windows and fixes the decomp for
`menu` which was causing some crashes related to input handling.
2023-02-26 09:46:57 -05:00

68 lines
2 KiB
C++

#include "libscf.h"
#include <ctime>
#ifdef _WIN32
// clang-format off
#include <Windows.h>
#include <WinNls.h>
// clang-format on
#endif
namespace ee {
int sceScfGetAspect() {
return SCE_ASPECT_43;
}
int sceScfGetLanguage() {
#ifdef _WIN32
// method 1: GetUserDefaultUILanguage
LANGID curLang = GetUserDefaultUILanguage();
auto curLangMain = curLang & 0x3ff; // "base" language
auto curLangSub = (curLang >> 10) & 0x3f; // "sub"-language
if (curLangMain == LANG_JAPANESE) {
return SCE_JAPANESE_LANGUAGE;
} else if (curLangMain == LANG_ENGLISH) {
return SCE_ENGLISH_LANGUAGE;
} else if (curLangMain == LANG_FRENCH) {
return SCE_FRENCH_LANGUAGE;
} else if (curLangMain == LANG_SPANISH) {
// would non-European Spanish speakers prefer this over English?
// I'll wait for someone to complain first
return SCE_SPANISH_LANGUAGE;
} else if (curLangMain == LANG_GERMAN) {
return SCE_GERMAN_LANGUAGE;
} else if (curLangMain == LANG_ITALIAN) {
return SCE_ITALIAN_LANGUAGE;
} else if (curLangMain == LANG_PORTUGUESE) {
if (curLangSub == SUBLANG_PORTUGUESE) {
return SCE_ENGLISH_LANGUAGE; // SCE_PORTUGUESE_LANGUAGE;
} else {
return SCE_ENGLISH_LANGUAGE;
}
} else if (curLangMain == LANG_DUTCH) {
return SCE_DUTCH_LANGUAGE;
}
#endif
return SCE_ENGLISH_LANGUAGE;
}
void sceCdReadClock(sceCdCLOCK* result) {
time_t t = time(0);
std::tm* date = localtime(&t);
// convert decimal value into hex value with identical digit representation
// e.g. 60 -> 0x60
auto convert = [](u8 val) -> u8 { return ((val % 10) * 0x01) + ((val / 10) * 0x10); };
result->stat = 0; // ??
result->second = convert(date->tm_sec);
result->minute = convert(date->tm_min);
result->hour = convert(date->tm_hour);
result->week = convert((date->tm_yday - date->tm_wday + 7) / 7);
result->day = convert(date->tm_mday);
result->month = convert(date->tm_mon + 1);
result->year = convert(date->tm_year - 100);
}
} // namespace ee