FBA can now connect to the website, pull a list of localisation templates, populate a combobox, and pull the selected template from the site
This commit is contained in:
parent
5a850d8d7b
commit
673161750d
|
@ -3,9 +3,9 @@ alldir += burner burner/win32 dep/kaillera/client dep/libs/libpng dep/libs/lib7
|
|||
intf/perfcount intf/perfcount/win32 dep/generated
|
||||
|
||||
depobj += about.o bzip.o cona.o debugger.o drv.o dwmapi_core.o dynhuff.o fba_kaillera.o gameinfo.o image_win32.o inpc.o \
|
||||
inpcheat.o inpd.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 \
|
||||
inpcheat.o inpd.o inpdipsw.o inps.o ips_manager.o localise.o localise_download.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 \
|
||||
\
|
||||
|
|
|
@ -91,7 +91,7 @@ ifdef UNICODE
|
|||
# lib = -lunicows
|
||||
endif
|
||||
|
||||
lib += -luser32 -lgdi32 -lcomdlg32 -lcomctl32 -lshell32 -lwinmm -lshlwapi -ladvapi32 -lsetupapi -lole32 -luuid
|
||||
lib += -luser32 -lgdi32 -lcomdlg32 -lcomctl32 -lshell32 -lwinmm -lshlwapi -ladvapi32 -lsetupapi -lole32 -luuid -lwininet
|
||||
|
||||
|
||||
depobj += resource.o \
|
||||
|
|
|
@ -104,7 +104,7 @@ ifdef UNICODE
|
|||
# lib = -lunicows
|
||||
endif
|
||||
|
||||
lib += -luser32 -lgdi32 -lcomdlg32 -lcomctl32 -lshell32 -lwinmm -lshlwapi -ladvapi32 -lsetupapi -lole32 -luuid
|
||||
lib += -luser32 -lgdi32 -lcomdlg32 -lcomctl32 -lshell32 -lwinmm -lshlwapi -ladvapi32 -lsetupapi -lole32 -luuid -lwininet
|
||||
|
||||
|
||||
depobj += resource.o \
|
||||
|
|
|
@ -107,7 +107,7 @@ ifdef UNICODE
|
|||
# lib = unicows.lib
|
||||
endif
|
||||
|
||||
lib += user32.lib gdi32.lib comdlg32.lib comctl32.lib shell32.lib winmm.lib ole32.lib shlwapi.lib advapi32.lib setupapi.lib
|
||||
lib += user32.lib gdi32.lib comdlg32.lib comctl32.lib shell32.lib winmm.lib ole32.lib shlwapi.lib advapi32.lib setupapi.lib wininet.lib
|
||||
|
||||
ifdef BUILD_X86_ASM
|
||||
autobj += hq3xs.o hq_shared32.o
|
||||
|
|
|
@ -733,6 +733,18 @@ BEGIN
|
|||
DEFPUSHBUTTON "Close",IDCANCEL,456,351,60,14
|
||||
END
|
||||
|
||||
IDD_DOWNLOAD_LOCAL DIALOGEX 0, 0, 168, 48
|
||||
STYLE DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
||||
CAPTION "Download Localisation Template"
|
||||
FONT 8, "MS Shell Dlg", 0, 0, 0x1
|
||||
BEGIN
|
||||
GROUPBOX "",IDC_STATIC1,2,0,164,28
|
||||
LTEXT "Language:", IDC_LOCAL_DOWNLOAD_LANG, 8, 10, 40, 10, SS_CENTERIMAGE
|
||||
COMBOBOX IDC_CHOOSE_LIST, 60, 9, 100, 128, CBS_DROPDOWNLIST | WS_CHILD | WS_VISIBLE | WS_TABSTOP | WS_VSCROLL
|
||||
CONTROL "Cancel",IDCANCEL,"Button",WS_TABSTOP,44,30,58,14
|
||||
CONTROL "OK",IDOK,"Button",WS_TABSTOP,107,30,58,14
|
||||
END
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Menu
|
||||
|
@ -991,6 +1003,7 @@ BEGIN
|
|||
MENUITEM "Select UI language...", MENU_LANGUAGE_SELECT
|
||||
MENUITEM "Export UI translation template...", MENU_LANGUAGE_EXPORT
|
||||
MENUITEM "Reset UI default language", MENU_LANGUAGE_RESET
|
||||
MENUITEM "Download UI language...", MENU_LANGUAGE_DOWNLOAD
|
||||
END
|
||||
POPUP "Gamelist language"
|
||||
BEGIN
|
||||
|
|
|
@ -453,6 +453,9 @@ int GetIpsNumActivePatches();
|
|||
int IpsManagerCreate(HWND hParentWND);
|
||||
void IpsPatchExit();
|
||||
|
||||
// localise_download.cpp
|
||||
int LocaliseDownloadCreate(HWND hParentWND);
|
||||
|
||||
// Misc
|
||||
#define _TtoA(a) TCHARToANSI(a, NULL, 0)
|
||||
#define _AtoT(a) ANSIToTCHAR(a, NULL, 0)
|
||||
|
|
|
@ -0,0 +1,182 @@
|
|||
#include "burner.h"
|
||||
#include <wininet.h>
|
||||
#include <shlobj.h>
|
||||
|
||||
#define MAX_LANGUAGES 64
|
||||
|
||||
static HWND hLocalDownDlg = NULL;
|
||||
static HWND hParent = NULL;
|
||||
|
||||
static int langCodes[MAX_LANGUAGES];
|
||||
|
||||
static void LocaliseDownloadExit()
|
||||
{
|
||||
hParent = NULL;
|
||||
|
||||
memset(langCodes, 0, MAX_LANGUAGES * sizeof(int));
|
||||
|
||||
EndDialog(hLocalDownDlg, 0);
|
||||
}
|
||||
|
||||
static INT32 LocaliseDownloadInit()
|
||||
{
|
||||
HINTERNET connect = InternetOpen(_T("MyBrowser"), INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0);
|
||||
|
||||
if (!connect) {
|
||||
MessageBox(hLocalDownDlg, FBALoadStringEx(hAppInst, IDS_ERR_LOCAL_FAIL_CONNECT, true), FBALoadStringEx(hAppInst, IDS_ERR_ERROR, true), MB_OK);
|
||||
return 1;
|
||||
}
|
||||
|
||||
HINTERNET OpenAddress = InternetOpenUrl(connect, _T("http://www.fbalpha.com/localisationinfo/"), NULL, 0, INTERNET_FLAG_PRAGMA_NOCACHE | INTERNET_FLAG_KEEP_CONNECTION, 0);
|
||||
if (!OpenAddress) {
|
||||
MessageBox(hLocalDownDlg, FBALoadStringEx(hAppInst, IDS_ERR_LOCAL_FAIL_OPEN_URL, true), FBALoadStringEx(hAppInst, IDS_ERR_ERROR, true), MB_OK);
|
||||
InternetCloseHandle(connect);
|
||||
return 1;
|
||||
}
|
||||
|
||||
char DataReceived[4096];
|
||||
DWORD NumberOfBytesRead = 0;
|
||||
InternetReadFile(OpenAddress, DataReceived, 4096, &NumberOfBytesRead);
|
||||
|
||||
DataReceived[NumberOfBytesRead] = '\0';
|
||||
|
||||
char *Tokens;
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
Tokens = strtok(DataReceived, ":^");
|
||||
while (Tokens != NULL) {
|
||||
if (i & 1) {
|
||||
SendDlgItemMessage(hLocalDownDlg, IDC_CHOOSE_LIST, CB_ADDSTRING, 0, (LPARAM)ANSIToTCHAR(Tokens, NULL, 0));
|
||||
} else {
|
||||
langCodes[j] = atoi(Tokens);
|
||||
j++;
|
||||
}
|
||||
|
||||
i++;
|
||||
Tokens = strtok(NULL, ":^");
|
||||
}
|
||||
|
||||
SendDlgItemMessage(hLocalDownDlg, IDC_CHOOSE_LIST, CB_SETCURSEL, (WPARAM)0, (LPARAM)0);
|
||||
|
||||
InternetCloseHandle(OpenAddress);
|
||||
InternetCloseHandle(connect);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int LocaliseDownloadOkay()
|
||||
{
|
||||
TCHAR szTitle[256];
|
||||
TCHAR szFilter[256];
|
||||
|
||||
int nIndex = SendMessage(GetDlgItem(hLocalDownDlg, IDC_CHOOSE_LIST), CB_GETCURSEL, 0, 0);
|
||||
SendMessage(GetDlgItem(hLocalDownDlg, IDC_CHOOSE_LIST), CB_GETLBTEXT, (WPARAM)nIndex, (LPARAM)szChoice);
|
||||
|
||||
_sntprintf(szTitle, 256, FBALoadStringEx(hAppInst, IDS_LOCAL_GL_SELECT, true));
|
||||
|
||||
_stprintf(szFilter, FBALoadStringEx(hAppInst, IDS_LOCAL_GL_FILTER, true));
|
||||
memcpy(szFilter + _tcslen(szFilter), _T(" (*.flt)\0*.flt\0\0"), 16 * sizeof(TCHAR));
|
||||
|
||||
memset(&ofn, 0, sizeof(ofn));
|
||||
ofn.lStructSize = sizeof(ofn);
|
||||
ofn.hwndOwner = hScrnWnd;
|
||||
ofn.lpstrFilter = szFilter;
|
||||
ofn.lpstrFile = szChoice;
|
||||
ofn.nMaxFile = sizeof(szChoice) / sizeof(TCHAR);
|
||||
ofn.lpstrInitialDir = _T(".");
|
||||
ofn.Flags = OFN_NOCHANGEDIR | OFN_HIDEREADONLY;
|
||||
ofn.lpstrDefExt = _T("dat");
|
||||
ofn.lpstrTitle = szTitle;
|
||||
ofn.Flags |= OFN_OVERWRITEPROMPT;
|
||||
|
||||
if (GetSaveFileName(&ofn) == 0) return 1;
|
||||
|
||||
FILE *fFlt = NULL;
|
||||
|
||||
if ((fFlt = _tfopen(szChoice, _T("wb"))) == 0) return 1;
|
||||
|
||||
HINTERNET connect = InternetOpen(_T("MyBrowser"), INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0);
|
||||
|
||||
if (!connect) {
|
||||
MessageBox(hLocalDownDlg, FBALoadStringEx(hAppInst, IDS_ERR_LOCAL_FAIL_CONNECT, true), FBALoadStringEx(hAppInst, IDS_ERR_ERROR, true), MB_OK);
|
||||
return 1;
|
||||
}
|
||||
|
||||
TCHAR url[256];
|
||||
_sntprintf(url, 256, _T("http://www.fbalpha.com/localisation/downloadtemplates/%i/"), langCodes[nIndex]);
|
||||
|
||||
HINTERNET OpenAddress = InternetOpenUrl(connect, url, NULL, 0, INTERNET_FLAG_PRAGMA_NOCACHE | INTERNET_FLAG_KEEP_CONNECTION, 0);
|
||||
if (!OpenAddress) {
|
||||
MessageBox(hLocalDownDlg, FBALoadStringEx(hAppInst, IDS_ERR_LOCAL_FAIL_OPEN_URL, true), FBALoadStringEx(hAppInst, IDS_ERR_ERROR, true), MB_OK);
|
||||
InternetCloseHandle(connect);
|
||||
return 1;
|
||||
}
|
||||
|
||||
char DataReceived[4096];
|
||||
DWORD NumberOfBytesRead = 0;
|
||||
while (InternetReadFile(OpenAddress, DataReceived, 4096, &NumberOfBytesRead) && NumberOfBytesRead) {
|
||||
fwrite(DataReceived, sizeof(char), NumberOfBytesRead, fFlt);
|
||||
}
|
||||
|
||||
InternetCloseHandle(OpenAddress);
|
||||
InternetCloseHandle(connect);
|
||||
|
||||
fclose(fFlt);
|
||||
|
||||
FBALocaliseInit(szChoice);
|
||||
POST_INITIALISE_MESSAGE;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static INT_PTR CALLBACK DefInpProc(HWND hDlg, UINT Msg, WPARAM wParam, LPARAM /*lParam*/)
|
||||
{
|
||||
switch (Msg) {
|
||||
case WM_INITDIALOG: {
|
||||
hLocalDownDlg = hDlg;
|
||||
|
||||
if (LocaliseDownloadInit() == 1) SendMessage(hDlg, WM_CLOSE, 0, 0);
|
||||
|
||||
WndInMid(hDlg, hScrnWnd);
|
||||
SetFocus(hDlg); // Enable Esc=close
|
||||
break;
|
||||
}
|
||||
|
||||
case WM_COMMAND: {
|
||||
int wID = LOWORD(wParam);
|
||||
int Notify = HIWORD(wParam);
|
||||
|
||||
if (Notify == BN_CLICKED) {
|
||||
switch (wID) {
|
||||
case IDOK: {
|
||||
LocaliseDownloadOkay();
|
||||
SendMessage(hDlg, WM_CLOSE, 0, 0);
|
||||
break;
|
||||
}
|
||||
|
||||
case IDCANCEL: {
|
||||
SendMessage(hDlg, WM_CLOSE, 0, 0);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case WM_CLOSE: {
|
||||
LocaliseDownloadExit();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int LocaliseDownloadCreate(HWND hParentWND)
|
||||
{
|
||||
hParent = hParentWND;
|
||||
|
||||
FBADialogBox(hAppInst, MAKEINTRESOURCE(IDD_DOWNLOAD_LOCAL), hParent, (DLGPROC)DefInpProc);
|
||||
return 1;
|
||||
}
|
|
@ -889,7 +889,7 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE, LPSTR lpCmdLine, int nShowCmd
|
|||
}
|
||||
|
||||
#if !defined (DONT_DISPLAY_SPLASH)
|
||||
if (lpCmdLine[0] == 0) SplashCreate();
|
||||
// if (lpCmdLine[0] == 0) SplashCreate();
|
||||
#endif
|
||||
|
||||
nAppShowCmd = nShowCmd;
|
||||
|
|
|
@ -47,6 +47,7 @@
|
|||
#define IDD_NCD_DLG 79
|
||||
#define IDD_NCD_COVER_DLG 80
|
||||
#define IDD_GAMEINFO 81
|
||||
#define IDD_DOWNLOAD_LOCAL 82
|
||||
|
||||
#define IDR_MENU 100
|
||||
#define IDR_MENU_BLITTER_1 110
|
||||
|
@ -178,6 +179,7 @@
|
|||
#define IDC_RESOLUTION 20136
|
||||
#define IDC_CHECKUNAVAILABLE 20137
|
||||
#define IDC_SYSINFO_LOG_SAVE 20138
|
||||
#define IDC_LOCAL_DOWNLOAD_LANG 20139
|
||||
|
||||
#define IDC_DRVCOUNT 20200
|
||||
#define IDC_TREE2 20201
|
||||
|
@ -514,6 +516,7 @@
|
|||
#define MENU_ENABLECHEAT 10306
|
||||
#define MENU_LANGUAGE_SELECT 10307
|
||||
#define MENU_LANGUAGE_EXPORT 10308
|
||||
#define MENU_LANGUAGE_DOWNLOAD 10309
|
||||
#define MENU_PRIORITY_REALTIME 10310
|
||||
#define MENU_PRIORITY_HIGH 10311
|
||||
#define MENU_PRIORITY_ABOVE_NORMAL 10312
|
||||
|
|
|
@ -352,3 +352,6 @@
|
|||
#define IDS_ERR_NO_DRIVER_SEL_SLOT1 (IDS_ERROR + 114)
|
||||
#define IDS_ERR_NON_WORKING (IDS_ERROR + 116)
|
||||
#define IDS_ERR_CDEMU_INI_FAIL (IDS_ERROR + 118)
|
||||
|
||||
#define IDS_ERR_LOCAL_FAIL_CONNECT (IDS_ERROR + 150)
|
||||
#define IDS_ERR_LOCAL_FAIL_OPEN_URL (IDS_ERROR + 152)
|
||||
|
|
|
@ -1836,6 +1836,11 @@ static void OnCommand(HWND /*hDlg*/, int id, HWND /*hwndCtl*/, UINT codeNotify)
|
|||
FBALocaliseInit(szLocalisationTemplate);
|
||||
POST_INITIALISE_MESSAGE;
|
||||
break;
|
||||
case MENU_LANGUAGE_DOWNLOAD:
|
||||
if (UseDialogs()) {
|
||||
LocaliseDownloadCreate(hScrnWnd);
|
||||
}
|
||||
break;
|
||||
|
||||
case MENU_LANGUAGE_GL_SELECT:
|
||||
if (UseDialogs()) {
|
||||
|
|
|
@ -352,4 +352,7 @@ BEGIN
|
|||
IDS_ERR_NO_DRIVER_SEL_SLOT1 "No driver has been selected for slot 1."
|
||||
IDS_ERR_NON_WORKING "This game isn't working. Load it anyway?"
|
||||
IDS_ERR_CDEMU_INI_FAIL "Couldn't initialise CD emulation."
|
||||
|
||||
IDS_ERR_LOCAL_FAIL_CONNECT "Failed to connect to Internet"
|
||||
IDS_ERR_LOCAL_FAIL_OPEN_URL "Failed to access FB Alpha website"
|
||||
END
|
||||
|
|
Loading…
Reference in New Issue