Add support for localising gamelist
This commit is contained in:
parent
747a9c9d57
commit
2e0475630a
|
@ -67,9 +67,9 @@ drvobj = d_dodonpachi.o d_donpachi.o d_esprade.o d_feversos.o d_gaia.o d_guwang
|
|||
d_snes.o
|
||||
|
||||
depobj := about.o bzip.o cona.o debugger.o drv.o dwmapi_core.o dynhuff.o fba_kaillera.o image_win32.o inpc.o inpcheat.o inpd.o \
|
||||
inpdipsw.o inps.o ips_manager.o localise.o main.o mdi.o media.o memcard.o menu.o misc_win32.o neocdlist.o neocdsel.o \
|
||||
numdial.o numpluscommas.o paletteviewer.o popup_win32.o progress.o replay.o res.o roms.o run.o scrn.o sel.o sfactd.o \
|
||||
splash.o stated.o support_paths.o systeminfo.o wave.o \
|
||||
inpdipsw.o inps.o ips_manager.o localise.o localise_gamelist.o main.o mdi.o media.o memcard.o menu.o misc_win32.o \
|
||||
neocdlist.o neocdsel.o numdial.o numpluscommas.o paletteviewer.o popup_win32.o progress.o replay.o res.o roms.o run.o \
|
||||
scrn.o sel.o sfactd.o splash.o stated.o support_paths.o systeminfo.o wave.o \
|
||||
\
|
||||
conc.o cong.o dat.o gamc.o gami.o image.o ioapi.o misc.o sshot.o state.o statec.o unzip.o zipfn.o \
|
||||
\
|
||||
|
|
|
@ -410,6 +410,16 @@ extern "C" char* BurnDrvGetTextA(UINT32 i)
|
|||
}
|
||||
}
|
||||
|
||||
void BurnLocalisationSetName(char *szName, TCHAR *szLongName)
|
||||
{
|
||||
for (UINT32 i = 0; i < nBurnDrvCount; i++) {
|
||||
nBurnDrvActive = i;
|
||||
if (!strcmp(szName, pDriver[i]->szShortName)) {
|
||||
pDriver[i]->szFullNameW = szLongName;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Get the zip names for the driver
|
||||
extern "C" INT32 BurnDrvGetZipName(char** pszName, UINT32 i)
|
||||
{
|
||||
|
@ -901,6 +911,8 @@ INT32 BurnTransferInit()
|
|||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// Savestate support
|
||||
|
||||
|
|
|
@ -227,6 +227,8 @@ INT32 BurnDrvGetPaletteEntries();
|
|||
INT32 BurnSetProgressRange(double dProgressRange);
|
||||
INT32 BurnUpdateProgress(double dProgressStep, const TCHAR* pszText, bool bAbs);
|
||||
|
||||
void BurnLocalisationSetName(char *szName, TCHAR *szLongName);
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Retrieve driver information
|
||||
|
||||
|
|
|
@ -906,6 +906,12 @@ BEGIN
|
|||
MENUITEM "Select UI language...", MENU_LANGUAGE_SELECT
|
||||
MENUITEM "Export UI translation template...", MENU_LANGUAGE_EXPORT
|
||||
MENUITEM "Reset UI default language", MENU_LANGUAGE_RESET
|
||||
END
|
||||
POPUP "Gamelist language"
|
||||
BEGIN
|
||||
MENUITEM "Select gamelist language...", MENU_LANGUAGE_GL_SELECT
|
||||
MENUITEM "Export gamelist translation template...", MENU_LANGUAGE_GL_EXPORT
|
||||
MENUITEM "Reset gamelist default language", MENU_LANGUAGE_GL_RESET
|
||||
END
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "Save snapshot\tF12", MENU_SAVESNAP
|
||||
|
|
|
@ -147,6 +147,15 @@ HWND FBACreateDialog(HINSTANCE hInstance, LPCTSTR lpTemplate, HWND hWndParent, D
|
|||
int FBALoadString(HINSTANCE hInstance, UINT uID, LPTSTR lpBuffer, int nBufferMax);
|
||||
TCHAR* FBALoadStringEx(HINSTANCE hInstance, UINT uID, bool bTranslate);
|
||||
|
||||
// localise_gamelist.cpp
|
||||
extern TCHAR szGamelistLocalisationTemplate[MAX_PATH];
|
||||
extern bool nGamelistLocalisationActive;
|
||||
|
||||
void BurnerDoGameListLocalisation();
|
||||
void BurnerExitGameListLocalisation();
|
||||
int FBALocaliseGamelistLoadTemplate();
|
||||
int FBALocaliseGamelistCreateTemplate();
|
||||
|
||||
// popup_win32.cpp
|
||||
enum FBAPopupType { MT_NONE = 0, MT_ERROR, MT_WARNING, MT_INFO };
|
||||
|
||||
|
|
|
@ -161,6 +161,8 @@ int ConfigAppLoad()
|
|||
|
||||
// Other
|
||||
STR(szLocalisationTemplate);
|
||||
STR(szGamelistLocalisationTemplate);
|
||||
VAR(nGamelistLocalisationActive);
|
||||
|
||||
VAR(nVidSDisplayStatus);
|
||||
VAR(nMinChatFontSize);
|
||||
|
@ -448,6 +450,12 @@ int ConfigAppSave()
|
|||
_ftprintf(h, _T("\n// Filename of the active UI translation template\n"));
|
||||
STR(szLocalisationTemplate);
|
||||
|
||||
_ftprintf(h, _T("\n// Filename of the active gamelist translation template\n"));
|
||||
STR(szGamelistLocalisationTemplate);
|
||||
|
||||
_ftprintf(h, _T("\n// If non-zero, enable gamelist localisation\n"));
|
||||
VAR(nGamelistLocalisationActive);
|
||||
|
||||
_ftprintf(h, _T("\n// 1 = display pause/record/replay/kaillera icons in the upper right corner of the display\n"));
|
||||
VAR(nVidSDisplayStatus);
|
||||
_ftprintf(h, _T("\n// Minimum height (in pixels) of the font used for the Kaillera chat function (used for arcade resolution)\n"));
|
||||
|
|
|
@ -0,0 +1,199 @@
|
|||
#include "burner.h"
|
||||
#include <string>
|
||||
|
||||
#define MAX_LST_GAMES 25000
|
||||
#define MAX_LST_LINE_LEN 256
|
||||
|
||||
TCHAR szGamelistLocalisationTemplate[MAX_PATH] = _T("");
|
||||
bool nGamelistLocalisationActive = false;
|
||||
static int nCodePage = 1252;
|
||||
static TCHAR *szLongNamesArray[MAX_LST_GAMES];
|
||||
|
||||
void BurnerDoGameListLocalisation()
|
||||
{
|
||||
if (!nGamelistLocalisationActive) return;
|
||||
|
||||
FILE* fp = _tfopen(szGamelistLocalisationTemplate, _T("rt"));
|
||||
if (fp) {
|
||||
TCHAR *szShortNamesArray[MAX_LST_GAMES];
|
||||
TCHAR szLine[MAX_LST_GAMES];
|
||||
int nTokenPos = 0;
|
||||
int nArrayPos = 0;
|
||||
int nNumGames = 0;
|
||||
|
||||
// Allocate arrays to read the file into
|
||||
for (int i = 0; i < MAX_LST_GAMES; i++) {
|
||||
szLongNamesArray[i] = (TCHAR*)malloc(MAX_LST_LINE_LEN * sizeof(TCHAR));
|
||||
szShortNamesArray[i] = (TCHAR*)malloc(33 * sizeof(TCHAR));
|
||||
}
|
||||
|
||||
char szTemp[MAX_LST_LINE_LEN];
|
||||
|
||||
while (fgets(szTemp, sizeof(szTemp), fp)) {
|
||||
if (szTemp[0] == '/' && szTemp[1] == '/') {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!strncmp(szTemp, "codepage=", 9)) {
|
||||
if ((strlen(szTemp) - 10) == 4) {
|
||||
nCodePage = (szTemp[9] - '0') * 1000;
|
||||
nCodePage += (szTemp[10] - '0') * 100;
|
||||
nCodePage += (szTemp[11] - '0') * 10;
|
||||
nCodePage += (szTemp[12] - '0');
|
||||
}
|
||||
if ((strlen(szTemp) - 10) == 3) {
|
||||
nCodePage = (szTemp[9] - '0') * 100;
|
||||
nCodePage += (szTemp[10] - '0') * 10;
|
||||
nCodePage += (szTemp[11] - '0');
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
MultiByteToWideChar(nCodePage, 0, szTemp, -1, szLine, sizeof(szLine) / sizeof(TCHAR));
|
||||
|
||||
int nLen = _tcslen(szLine);
|
||||
TCHAR *Tokens;
|
||||
|
||||
// Get rid of the linefeed at the end
|
||||
if (szLine[nLen - 1] == 10) {
|
||||
szLine[nLen - 1] = 0;
|
||||
nLen--;
|
||||
}
|
||||
|
||||
// Read the file into arrays
|
||||
Tokens = _tcstok(szLine, _T("\t"));
|
||||
while (Tokens != NULL) {
|
||||
if (nTokenPos == 0) {
|
||||
wcscpy(szShortNamesArray[nArrayPos], Tokens);
|
||||
szShortNamesArray[nArrayPos][_tcslen(Tokens)] = _T('\0');
|
||||
}
|
||||
|
||||
if (nTokenPos == 1) {
|
||||
wcscpy(szLongNamesArray[nArrayPos], Tokens);
|
||||
szLongNamesArray[nArrayPos][_tcslen(Tokens)] = _T('\0');
|
||||
}
|
||||
|
||||
Tokens = _tcstok(NULL, _T("\t"));
|
||||
nTokenPos++;
|
||||
}
|
||||
|
||||
nTokenPos = 0;
|
||||
nArrayPos++;
|
||||
}
|
||||
nNumGames = nArrayPos;
|
||||
|
||||
for (int i = 0; i < nNumGames; i++) {
|
||||
BurnLocalisationSetName(TCHARToANSI(szShortNamesArray[i], NULL, 0), szLongNamesArray[i]);
|
||||
}
|
||||
|
||||
// tidy up
|
||||
for (int i = 0; i < MAX_LST_GAMES; i++) {
|
||||
if (szShortNamesArray[i]) {
|
||||
free(szShortNamesArray[i]);
|
||||
szShortNamesArray[i] = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
fclose(fp);
|
||||
}
|
||||
}
|
||||
|
||||
static void BurnerGameListCreateTemplate()
|
||||
{
|
||||
unsigned int nOldDrvSelect = nBurnDrvActive;
|
||||
|
||||
FILE* fp = _tfopen(szGamelistLocalisationTemplate, _T("wt"));
|
||||
if (fp) {
|
||||
_ftprintf(fp, _T("// game list translation template for FB Alpha version 0x%06X\n\n"), nBurnVer);
|
||||
_ftprintf(fp, _T("// codepage=1252\n\n"));
|
||||
|
||||
for (unsigned int i = 0; i < nBurnDrvCount; i++) {
|
||||
nBurnDrvActive = i;
|
||||
_ftprintf(fp, _T("%s\t%s\n"), BurnDrvGetText(DRV_NAME), BurnDrvGetText(DRV_FULLNAME));
|
||||
}
|
||||
|
||||
fclose(fp);
|
||||
}
|
||||
|
||||
nBurnDrvActive = nOldDrvSelect;
|
||||
}
|
||||
|
||||
void BurnerExitGameListLocalisation()
|
||||
{
|
||||
for (int i = 0; i < MAX_LST_GAMES; i++) {
|
||||
if (szLongNamesArray[i]) {
|
||||
free(szLongNamesArray[i]);
|
||||
szLongNamesArray[i] = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// Dialog box to load/save a template
|
||||
|
||||
static TCHAR szFilter[100];
|
||||
|
||||
static void MakeOfn()
|
||||
{
|
||||
_stprintf(szFilter, _T("%s"), FBALoadStringEx(hAppInst, IDS_LOCAL_GL_FILTER, true));
|
||||
memcpy(szFilter + _tcslen(szFilter), _T(" (*.glt)\0*.glt\0\0"), 16 * sizeof(TCHAR));
|
||||
|
||||
memset(&ofn, 0, sizeof(ofn));
|
||||
ofn.lStructSize = sizeof(ofn);
|
||||
ofn.hwndOwner = hScrnWnd;
|
||||
ofn.lpstrFilter = szFilter;
|
||||
ofn.lpstrFile = szGamelistLocalisationTemplate;
|
||||
ofn.nMaxFile = sizeof(szGamelistLocalisationTemplate) / sizeof(TCHAR);
|
||||
ofn.lpstrInitialDir = _T("./config/localisation");
|
||||
ofn.Flags = OFN_NOCHANGEDIR | OFN_HIDEREADONLY;
|
||||
ofn.lpstrDefExt = _T("glt");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
int FBALocaliseGamelistLoadTemplate()
|
||||
{
|
||||
_stprintf(szGamelistLocalisationTemplate, _T("template"));
|
||||
MakeOfn();
|
||||
TCHAR szTitle[100];
|
||||
_stprintf(szTitle, _T("%s"), FBALoadStringEx(hAppInst, IDS_LOCAL_GL_SELECT, true));
|
||||
ofn.lpstrTitle = szTitle;
|
||||
ofn.Flags |= OFN_OVERWRITEPROMPT;
|
||||
|
||||
int bOldPause = bRunPause;
|
||||
bRunPause = 1;
|
||||
int nRet = GetOpenFileName(&ofn);
|
||||
bRunPause = bOldPause;
|
||||
|
||||
if (nRet == 0) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
nGamelistLocalisationActive = true;
|
||||
BurnerDoGameListLocalisation();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int FBALocaliseGamelistCreateTemplate()
|
||||
{
|
||||
_stprintf(szGamelistLocalisationTemplate, _T("template"));
|
||||
MakeOfn();
|
||||
TCHAR szTitle[100];
|
||||
_stprintf(szTitle, _T("%s"), FBALoadStringEx(hAppInst, IDS_LOCAL_GL_CREATE, true));
|
||||
ofn.lpstrTitle = szTitle;
|
||||
ofn.Flags |= OFN_OVERWRITEPROMPT;
|
||||
|
||||
int bOldPause = bRunPause;
|
||||
bRunPause = 1;
|
||||
int nRet = GetSaveFileName(&ofn);
|
||||
bRunPause = bOldPause;
|
||||
|
||||
if (nRet == 0) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
BurnerGameListCreateTemplate();
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -500,11 +500,12 @@ static int AppInit()
|
|||
|
||||
// Init the Burn library
|
||||
BurnLibInit();
|
||||
|
||||
|
||||
// Load config for the application
|
||||
ConfigAppLoad();
|
||||
|
||||
FBALocaliseInit(szLocalisationTemplate);
|
||||
BurnerDoGameListLocalisation();
|
||||
|
||||
if (bMonitorAutoCheck) MonitorAutoCheck();
|
||||
|
||||
|
@ -564,6 +565,7 @@ static int AppExit()
|
|||
#endif
|
||||
|
||||
FBALocaliseExit();
|
||||
BurnerExitGameListLocalisation();
|
||||
|
||||
if (hAccel) {
|
||||
DestroyAcceleratorTable(hAccel);
|
||||
|
|
|
@ -521,6 +521,9 @@
|
|||
#define MENU_INP_PLUGIN_7 10670
|
||||
#define MENU_INP_PLUGIN_8 10671
|
||||
#define MENU_PALETTEVIEWER 10672
|
||||
#define MENU_LANGUAGE_GL_SELECT 10673
|
||||
#define MENU_LANGUAGE_GL_EXPORT 10674
|
||||
#define MENU_LANGUAGE_GL_RESET 10675
|
||||
#define MENU_RES_ARCADE_VERTICAL 10700
|
||||
#define MENU_RES_1_VERTICAL 10701
|
||||
#define MENU_RES_2_VERTICAL 10702
|
||||
|
|
|
@ -122,6 +122,10 @@
|
|||
|
||||
#define IDS_PRESET_SAVED (IDS_STRING + 520)
|
||||
|
||||
#define IDS_LOCAL_GL_CREATE (IDS_STRING + 530)
|
||||
#define IDS_LOCAL_GL_SELECT (IDS_STRING + 532)
|
||||
#define IDS_LOCAL_GL_FILTER (IDS_STRING + 534)
|
||||
|
||||
#define IDS_CD_SELECT_IMAGE (IDS_STRING + 540)
|
||||
#define IDS_CD_SELECT_IMAGE_TITLE (IDS_STRING + 542)
|
||||
#define IDS_CD_SELECT_FILTER (IDS_STRING + 544)
|
||||
|
|
|
@ -1767,6 +1767,21 @@ static void OnCommand(HWND /*hDlg*/, int id, HWND /*hwndCtl*/, UINT codeNotify)
|
|||
POST_INITIALISE_MESSAGE;
|
||||
break;
|
||||
|
||||
case MENU_LANGUAGE_GL_SELECT:
|
||||
if (UseDialogs()) {
|
||||
FBALocaliseGamelistLoadTemplate();
|
||||
}
|
||||
break;
|
||||
case MENU_LANGUAGE_GL_EXPORT:
|
||||
if (UseDialogs()) {
|
||||
FBALocaliseGamelistCreateTemplate();
|
||||
}
|
||||
break;
|
||||
case MENU_LANGUAGE_GL_RESET:
|
||||
szGamelistLocalisationTemplate[0] = _T('\0');
|
||||
nGamelistLocalisationActive = false;
|
||||
break;
|
||||
|
||||
case MENU_PRIORITY_REALTIME:
|
||||
nAppThreadPriority = THREAD_PRIORITY_TIME_CRITICAL;
|
||||
SetThreadPriority(GetCurrentThread(), nAppThreadPriority);
|
||||
|
|
|
@ -122,6 +122,10 @@ BEGIN
|
|||
|
||||
IDS_PRESET_SAVED "The preset file was saved to %s."
|
||||
|
||||
IDS_LOCAL_GL_CREATE "Create gamelist localisation template"
|
||||
IDS_LOCAL_GL_SELECT "Select gamelist localisation template"
|
||||
IDS_LOCAL_GL_FILTER "FB Alpha gamelist localisation templates"
|
||||
|
||||
IDS_CD_SELECT_IMAGE "Select CD-ROM image..."
|
||||
IDS_CD_SELECT_IMAGE_TITLE "Select CD-ROM image"
|
||||
IDS_CD_SELECT_FILTER "CD images"
|
||||
|
|
Loading…
Reference in New Issue