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_CONSTANT_MACROS // required for ffmpeg
|
||||
#endif
|
||||
|
||||
#include "wxvbam.h"
|
||||
#include <algorithm>
|
||||
#include <wx/aboutdlg.h>
|
||||
|
@ -11,6 +12,7 @@
|
|||
#include <wx/regex.h>
|
||||
#include <wx/numdlg.h>
|
||||
#include <wx/progdlg.h>
|
||||
|
||||
#ifndef NO_FFMPEG
|
||||
extern "C" {
|
||||
#include <libavformat/avformat.h>
|
||||
|
@ -2504,6 +2506,18 @@ EVT_HANDLER(Translate, "Translations")
|
|||
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
|
||||
EVT_HANDLER(wxID_ABOUT, "About...")
|
||||
{
|
||||
|
|
|
@ -15,6 +15,8 @@
|
|||
#include <wx/txtstrm.h>
|
||||
#include <wx/cmdline.h>
|
||||
#include <wx/regex.h>
|
||||
#include <wx/protocol/http.h>
|
||||
#include <wx/zipstrm.h>
|
||||
|
||||
// The built-in xrc file
|
||||
#include "builtin-xrc.h"
|
||||
|
@ -221,6 +223,7 @@ bool wxvbamApp::OnInit()
|
|||
if (!fn.IsFileReadable())
|
||||
continue;
|
||||
|
||||
data_path = config_path[i];
|
||||
wxStringOutputStream sos;
|
||||
wxFileInputStream fis(fn.GetFullPath());
|
||||
// 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()
|
||||
{
|
||||
bool anyjoy = false;
|
||||
|
|
|
@ -82,6 +82,8 @@ public:
|
|||
wxFileName rom_database;
|
||||
wxFileName rom_database_scene;
|
||||
|
||||
wxString data_path;
|
||||
|
||||
MainFrame* frame;
|
||||
// use this to get ms since program lauch
|
||||
wxStopWatch timer;
|
||||
|
@ -308,6 +310,9 @@ private:
|
|||
wxDialog* LoadXRCDialog(const char* name);
|
||||
// Load a named wxDialog from the XRC file
|
||||
wxDialog* LoadXRCropertySheetDialog(const char* name);
|
||||
|
||||
void DownloadFile(wxString host, wxString url);
|
||||
|
||||
#include "cmdhandlers.h"
|
||||
};
|
||||
|
||||
|
|
|
@ -610,6 +610,9 @@
|
|||
<object class="wxMenuItem" name="Translate">
|
||||
<label>Translations</label>
|
||||
</object>
|
||||
<object class="wxMenuItem" name="UpdateRDB">
|
||||
<label>Update ROM database</label>
|
||||
</object>
|
||||
<object class="separator"/>
|
||||
<object class="wxMenuItem" name="wxID_ABOUT"/>
|
||||
</object>
|
||||
|
|
Loading…
Reference in New Issue