Added a "Update ROM databases" command to the Help menu which downloads and updates the No-Intro dat files.
This commit is contained in:
parent
c03825dc74
commit
5b61aace22
File diff suppressed because it is too large
Load Diff
|
@ -2,6 +2,7 @@
|
||||||
#define __STDC_LIMIT_MACROS // required for ffmpeg
|
#define __STDC_LIMIT_MACROS // required for ffmpeg
|
||||||
#define __STDC_CONSTANT_MACROS // required for ffmpeg
|
#define __STDC_CONSTANT_MACROS // required for ffmpeg
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "wxvbam.h"
|
#include "wxvbam.h"
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <wx/aboutdlg.h>
|
#include <wx/aboutdlg.h>
|
||||||
|
@ -11,6 +12,7 @@
|
||||||
#include <wx/regex.h>
|
#include <wx/regex.h>
|
||||||
#include <wx/numdlg.h>
|
#include <wx/numdlg.h>
|
||||||
#include <wx/progdlg.h>
|
#include <wx/progdlg.h>
|
||||||
|
|
||||||
#ifndef NO_FFMPEG
|
#ifndef NO_FFMPEG
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#include <libavformat/avformat.h>
|
#include <libavformat/avformat.h>
|
||||||
|
@ -2504,6 +2506,18 @@ EVT_HANDLER(Translate, "Translations")
|
||||||
wxLaunchDefaultBrowser(wxT("http://www.transifex.com/projects/p/vba-m"));
|
wxLaunchDefaultBrowser(wxT("http://www.transifex.com/projects/p/vba-m"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
EVT_HANDLER(UpdateRDB, "Update ROM database")
|
||||||
|
{
|
||||||
|
int ret = wxMessageBox(_("This will download and update two GBA No-Intro DAT files. Do you want to continue?"),
|
||||||
|
_("Confirm Update"), wxYES_NO | wxICON_EXCLAMATION);
|
||||||
|
|
||||||
|
if (ret == wxYES)
|
||||||
|
{
|
||||||
|
DownloadFile(_T("sourceforge.net"), _T("/p/vbam/code/HEAD/tree/trunk/data/Nintendo%20-%20Game%20Boy%20Advance.zip?format=raw"));
|
||||||
|
DownloadFile(_T("sourceforge.net"), _T("/p/vbam/code/HEAD/tree/trunk/data/Nintendo%20-%20Game%20Boy%20Advance%20%28Scene%29.zip?format=raw"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// was About
|
// was About
|
||||||
EVT_HANDLER(wxID_ABOUT, "About...")
|
EVT_HANDLER(wxID_ABOUT, "About...")
|
||||||
{
|
{
|
||||||
|
|
|
@ -15,6 +15,8 @@
|
||||||
#include <wx/txtstrm.h>
|
#include <wx/txtstrm.h>
|
||||||
#include <wx/cmdline.h>
|
#include <wx/cmdline.h>
|
||||||
#include <wx/regex.h>
|
#include <wx/regex.h>
|
||||||
|
#include <wx/protocol/http.h>
|
||||||
|
#include <wx/zipstrm.h>
|
||||||
|
|
||||||
// The built-in xrc file
|
// The built-in xrc file
|
||||||
#include "builtin-xrc.h"
|
#include "builtin-xrc.h"
|
||||||
|
@ -221,6 +223,7 @@ bool wxvbamApp::OnInit()
|
||||||
if (!fn.IsFileReadable())
|
if (!fn.IsFileReadable())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
data_path = config_path[i];
|
||||||
wxStringOutputStream sos;
|
wxStringOutputStream sos;
|
||||||
wxFileInputStream fis(fn.GetFullPath());
|
wxFileInputStream fis(fn.GetFullPath());
|
||||||
// not the most efficient thing to do: read entire file into a string
|
// not the most efficient thing to do: read entire file into a string
|
||||||
|
@ -564,6 +567,52 @@ void MainFrame::OnMenu(wxContextMenuEvent &event)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainFrame::DownloadFile(wxString host, wxString url)
|
||||||
|
{
|
||||||
|
wxHTTP get;
|
||||||
|
get.SetHeader(_T("Content-type"), _T("text/html; charset=utf-8"));
|
||||||
|
get.SetTimeout(10);
|
||||||
|
|
||||||
|
while (!get.Connect(host))
|
||||||
|
wxSleep(5);
|
||||||
|
|
||||||
|
wxApp::IsMainLoopRunning();
|
||||||
|
wxInputStream* httpStream = get.GetInputStream(url);
|
||||||
|
|
||||||
|
if (get.GetError() == wxPROTO_NOERR)
|
||||||
|
{
|
||||||
|
if (httpStream != NULL)
|
||||||
|
{
|
||||||
|
wxZipInputStream zip(httpStream);
|
||||||
|
wxZipEntry* entry;
|
||||||
|
|
||||||
|
while (entry = zip.GetNextEntry())
|
||||||
|
{
|
||||||
|
// access meta-data
|
||||||
|
wxFileName name(wxGetApp().data_path, entry->GetName(), wxEmptyString);
|
||||||
|
|
||||||
|
// read 'zip' to access the entry's data
|
||||||
|
if (!entry->IsDir())
|
||||||
|
{
|
||||||
|
zip.OpenEntry(*entry);
|
||||||
|
|
||||||
|
if (zip.CanRead())
|
||||||
|
{
|
||||||
|
wxFileOutputStream file(name.GetFullPath());
|
||||||
|
|
||||||
|
if (file.IsOk())
|
||||||
|
{
|
||||||
|
zip.Read(file);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
get.Close();
|
||||||
|
}
|
||||||
|
|
||||||
void MainFrame::SetJoystick()
|
void MainFrame::SetJoystick()
|
||||||
{
|
{
|
||||||
bool anyjoy = false;
|
bool anyjoy = false;
|
||||||
|
|
|
@ -82,6 +82,8 @@ public:
|
||||||
wxFileName rom_database;
|
wxFileName rom_database;
|
||||||
wxFileName rom_database_scene;
|
wxFileName rom_database_scene;
|
||||||
|
|
||||||
|
wxString data_path;
|
||||||
|
|
||||||
MainFrame* frame;
|
MainFrame* frame;
|
||||||
// use this to get ms since program lauch
|
// use this to get ms since program lauch
|
||||||
wxStopWatch timer;
|
wxStopWatch timer;
|
||||||
|
@ -308,6 +310,9 @@ private:
|
||||||
wxDialog* LoadXRCDialog(const char* name);
|
wxDialog* LoadXRCDialog(const char* name);
|
||||||
// Load a named wxDialog from the XRC file
|
// Load a named wxDialog from the XRC file
|
||||||
wxDialog* LoadXRCropertySheetDialog(const char* name);
|
wxDialog* LoadXRCropertySheetDialog(const char* name);
|
||||||
|
|
||||||
|
void DownloadFile(wxString host, wxString url);
|
||||||
|
|
||||||
#include "cmdhandlers.h"
|
#include "cmdhandlers.h"
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -610,6 +610,9 @@
|
||||||
<object class="wxMenuItem" name="Translate">
|
<object class="wxMenuItem" name="Translate">
|
||||||
<label>Translations</label>
|
<label>Translations</label>
|
||||||
</object>
|
</object>
|
||||||
|
<object class="wxMenuItem" name="UpdateRDB">
|
||||||
|
<label>Update ROM database</label>
|
||||||
|
</object>
|
||||||
<object class="separator"/>
|
<object class="separator"/>
|
||||||
<object class="wxMenuItem" name="wxID_ABOUT"/>
|
<object class="wxMenuItem" name="wxID_ABOUT"/>
|
||||||
</object>
|
</object>
|
||||||
|
|
Loading…
Reference in New Issue