From 76803caf5feb7420d599286fec2f320e10f021bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ed=C3=AAnis=20Freindorfer=20Azevedo?= Date: Wed, 2 Oct 2019 21:34:55 -0300 Subject: [PATCH] [Windows] Enable winsparkle update checker. Remove traces of previous update checker. We use version 0.6.0 available here: https://github.com/vslavik/winsparkle/releases We only support on Windows at the moment using `winspakrle`. So remove this item for other platforms or when disabled in compilation. Signed-off-by: Rafael Kitover --- data/appcast.xml | 33 +++++++++++++++++++++++++++++ src/wx/cmdevents.cpp | 15 +++++++++++++ src/wx/guiinit.cpp | 41 +++++++++--------------------------- src/wx/opts.cpp | 6 ------ src/wx/opts.h | 3 --- src/wx/wxvbam.cpp | 32 ++++++++++++++++++++++++++++ src/wx/xrc/GeneralConfig.xrc | 38 --------------------------------- src/wx/xrc/MainMenu.xrc | 2 +- 8 files changed, 91 insertions(+), 79 deletions(-) create mode 100644 data/appcast.xml diff --git a/data/appcast.xml b/data/appcast.xml new file mode 100644 index 00000000..f6071680 --- /dev/null +++ b/data/appcast.xml @@ -0,0 +1,33 @@ + + + + + https://github.com/visualboyadvance-m/visualboyadvance-m/releases/download/v2.1.4/visualboyadvance-m-Win-64bit.zip + + + + https://github.com/visualboyadvance-m/visualboyadvance-m/releases/download/v2.1.4/visualboyadvance-m-Win-32bit.zip + + + + https://github.com/visualboyadvance-m/visualboyadvance-m/releases/download/v2.1.4/visualboyadvance-m-Mac-64bit.zip + + + + + diff --git a/src/wx/cmdevents.cpp b/src/wx/cmdevents.cpp index ff0a4f56..fde25715 100644 --- a/src/wx/cmdevents.cpp +++ b/src/wx/cmdevents.cpp @@ -2693,6 +2693,21 @@ EVT_HANDLER(Customize, "Customize UI...") update_opts(); } +#ifndef NO_ONLINEUPDATES +#ifdef __WXMSW__ +#include "winsparkle-wrapper.h" +#endif +#endif + +EVT_HANDLER(UpdateEmu, "Check for updates...") +{ +#ifndef NO_ONLINEUPDATES +#ifdef __WXMSW__ + win_sparkle_check_update_with_ui(); +#endif +#endif +} + EVT_HANDLER(FactoryReset, "Factory Reset...") { wxMessageDialog dlg(NULL, wxString(wxT( diff --git a/src/wx/guiinit.cpp b/src/wx/guiinit.cpp index 44c3da10..0ab9e36d 100644 --- a/src/wx/guiinit.cpp +++ b/src/wx/guiinit.cpp @@ -2850,6 +2850,16 @@ bool MainFrame::BindControls() continue; } #endif +#if defined(NO_ONLINEUPDATES) || !defined(__WXMSW__) + if (cmdtab[i].cmd_id == XRCID("UpdateEmu")) + { + if (mi) + mi->GetMenu()->Remove(mi); + cmdtab[i].cmd_id = XRCID("NOOP"); + cmdtab[i].mi = NULL; + continue; + } +#endif if (mi) { // wxgtk provides no way to retrieve stock label/accel @@ -3400,37 +3410,6 @@ bool MainFrame::BindControls() sc->SetValidator(wxUIntValidator(&o)); \ } while (0) { -#ifndef NO_ONLINEUPDATES - // Online Auto Update check frequency - getrbi("UpdateNever", gopts.onlineupdates, 0); - getrbi("UpdateDaily", gopts.onlineupdates, 1); - getrbi("UpdateWeekly", gopts.onlineupdates, 2); -#else - wxWindowList &children = d->GetChildren(); - std::vector forDeletion; - for (wxWindowList::Node *node = children.GetFirst(); node; node = node->GetNext()) - { - wxWindow *current = (wxWindow *)node->GetData(); - if (dynamic_cast(current)) - { - if (((wxStaticText *)current)->GetName() == wxT("OnlineUpdates")) - forDeletion.push_back(current); - } - else if (dynamic_cast(current)) - { - wxString tmp = ((wxRadioButton *)current)->GetName(); - if (tmp == wxT("UpdateNever") || - tmp == wxT("UpdateDaily") || - tmp == wxT("UpdateWeekly")) - forDeletion.push_back(current); - } - } - for (unsigned i = 0; i < forDeletion.size(); ++i) - { - delete forDeletion[i]; - } - std::vector().swap(forDeletion); -#endif // NO_ONLINEUPDATES getrbi("PNG", captureFormat, 0); getrbi("BMP", captureFormat, 1); getsc("RewindInterval", gopts.rewind_interval); diff --git a/src/wx/opts.cpp b/src/wx/opts.cpp index 6849791f..82930614 100644 --- a/src/wx/opts.cpp +++ b/src/wx/opts.cpp @@ -234,9 +234,6 @@ opt_desc opts[] = { BOOLOPT("General/AutoLoadLastState", "", wxTRANSLATE("Automatically load last saved state"), gopts.autoload_state), STROPT("General/BatteryDir", "", wxTRANSLATE("Directory to store game save files (relative paths are relative to ROM; blank is config dir)"), gopts.battery_dir), BOOLOPT("General/FreezeRecent", "", wxTRANSLATE("Freeze recent load list"), gopts.recent_freeze), -#ifndef NO_ONLINEUPDATES - ENUMOPT("General/OnlineUpdates", "", wxTRANSLATE("Automatically check for online updates"), gopts.onlineupdates, wxTRANSLATE("never|daily|weekly")), -#endif // NO_ONLINEUPDATES STROPT("General/RecordingDir", "", wxTRANSLATE("Directory to store A/V and game recordings (relative paths are relative to ROM)"), gopts.recording_dir), INTOPT("General/RewindInterval", "", wxTRANSLATE("Number of seconds between rewind snapshots (0 to disable)"), gopts.rewind_interval, 0, 600), STROPT("General/ScreenshotDir", "", wxTRANSLATE("Directory to store screenshots (relative paths are relative to ROM)"), gopts.scrshot_dir), @@ -361,9 +358,6 @@ opts_t::opts_t() autofire_rate = 1; print_auto_page = true; autoPatch = true; -#ifndef NO_ONLINEUPDATES - onlineupdates = 1; -#endif // NO_ONLINEUPDATES // quick fix for issues #48 and #445 link_host = "127.0.0.1"; } diff --git a/src/wx/opts.h b/src/wx/opts.h index 6ecca174..366ddbdd 100644 --- a/src/wx/opts.h +++ b/src/wx/opts.h @@ -43,9 +43,6 @@ extern struct opts_t { /// General bool autoload_state, autoload_cheats; wxString battery_dir; -#ifndef NO_ONLINEUPDATES - int onlineupdates; -#endif // NO_ONLINEUPDATES long last_update; wxString last_updated_filename; bool recent_freeze; diff --git a/src/wx/wxvbam.cpp b/src/wx/wxvbam.cpp index 44093f60..35cbe65f 100644 --- a/src/wx/wxvbam.cpp +++ b/src/wx/wxvbam.cpp @@ -185,6 +185,25 @@ wxString wxvbamApp::GetAbsolutePath(wxString path) return path; } +#ifndef NO_ONLINEUPDATES +#include "../common/version_cpp.h" + +#ifdef __WXMSW__ +#include "winsparkle-wrapper.h" +#endif // __WXMSW__ + +static void init_check_for_updates() +{ +#ifdef __WXMSW__ + wxString version(vbam_version); + //win_sparkle_set_appcast_url("https://github.com/visualboyadvance-m/visualboyadvance-m/data/appcast.xml"); + win_sparkle_set_appcast_url("https://raw.githubusercontent.com/visualboyadvance-m/visualboyadvance-m/update-checker/data/appcast.xml"); + win_sparkle_set_app_details(L"visualboyadvance-m", L"VisualBoyAdvance-M", version.c_str()); + win_sparkle_init(); +#endif // __WXMSW__ +} +#endif // NO_ONLINEUPDATES + bool wxvbamApp::OnInit() { // set up logging @@ -432,6 +451,14 @@ bool wxvbamApp::OnInit() frame->ShowFullScreen(isFullscreen); frame->Show(true); +#if defined(__WXMSW__) && !defined(NO_ONLINEUPDATES) + winsparkle = new WinSparkleDllWrapper(); +#endif + +#ifndef NO_ONLINEUPDATES + init_check_for_updates(); +#endif + return true; } @@ -680,6 +707,11 @@ wxvbamApp::~wxvbamApp() { home = NULL; } delete overrides; + +#if defined(__WXMSW__) && !defined(NO_ONLINEUPDATES) + win_sparkle_cleanup(); + delete winsparkle; +#endif } MainFrame::MainFrame() diff --git a/src/wx/xrc/GeneralConfig.xrc b/src/wx/xrc/GeneralConfig.xrc index bcd0433e..6a9874e9 100644 --- a/src/wx/xrc/GeneralConfig.xrc +++ b/src/wx/xrc/GeneralConfig.xrc @@ -19,44 +19,6 @@ 5 wxVERTICAL - - - - - - - wxALL|wxALIGN_CENTRE_VERTICAL - 5 - - - - - - - - wxALL - 5 - - - - - - - wxALL - 5 - - - - - - - wxALL - 5 - - wxHORIZONTAL - - wxEXPAND - diff --git a/src/wx/xrc/MainMenu.xrc b/src/wx/xrc/MainMenu.xrc index 5517bd3c..7c9a3d52 100644 --- a/src/wx/xrc/MainMenu.xrc +++ b/src/wx/xrc/MainMenu.xrc @@ -704,10 +704,10 @@ + --> - -->