mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-11 13:17:00 -04:00
Change tabs to two spaces.
This commit is contained in:
+118
-118
@@ -26,37 +26,37 @@ DECLARE_TYPEOF_COLLECTION(PackageDependencyP);
|
||||
|
||||
#if !USE_OLD_STYLE_UPDATE_CHECKER
|
||||
|
||||
/// Information on the latest available versions
|
||||
class VersionData : public IntrusivePtrBase<VersionData> {
|
||||
public:
|
||||
vector<PackageDependencyP> packages; ///< Available packages + versions
|
||||
String new_updates_url; ///< updates url has moved?
|
||||
|
||||
DECLARE_REFLECTION();
|
||||
};
|
||||
/// Information on the latest available versions
|
||||
class VersionData : public IntrusivePtrBase<VersionData> {
|
||||
public:
|
||||
vector<PackageDependencyP> packages; ///< Available packages + versions
|
||||
String new_updates_url; ///< updates url has moved?
|
||||
|
||||
DECLARE_REFLECTION();
|
||||
};
|
||||
|
||||
IMPLEMENT_REFLECTION_NO_SCRIPT(VersionData) {
|
||||
REFLECT_NO_SCRIPT(packages);
|
||||
REFLECT_NO_SCRIPT(new_updates_url);
|
||||
}
|
||||
IMPLEMENT_REFLECTION_NO_SCRIPT(VersionData) {
|
||||
REFLECT_NO_SCRIPT(packages);
|
||||
REFLECT_NO_SCRIPT(new_updates_url);
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
/// Information on the latest available version
|
||||
class VersionData : public IntrusivePtrBase<VersionData> {
|
||||
public:
|
||||
Version version; ///< Latest version number of MSE
|
||||
String description; ///< html description of the latest MSE release
|
||||
String new_updates_url; ///< updates url has moved?
|
||||
|
||||
DECLARE_REFLECTION();
|
||||
};
|
||||
/// Information on the latest available version
|
||||
class VersionData : public IntrusivePtrBase<VersionData> {
|
||||
public:
|
||||
Version version; ///< Latest version number of MSE
|
||||
String description; ///< html description of the latest MSE release
|
||||
String new_updates_url; ///< updates url has moved?
|
||||
|
||||
DECLARE_REFLECTION();
|
||||
};
|
||||
|
||||
IMPLEMENT_REFLECTION(VersionData) {
|
||||
REFLECT(version);
|
||||
REFLECT(description);
|
||||
REFLECT(new_updates_url);
|
||||
}
|
||||
IMPLEMENT_REFLECTION(VersionData) {
|
||||
REFLECT(version);
|
||||
REFLECT(description);
|
||||
REFLECT(new_updates_url);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -69,20 +69,20 @@ volatile bool checking_updates = false;
|
||||
|
||||
bool update_data_found() { return !!update_version_data; }
|
||||
bool update_available() {
|
||||
if (!update_version_data) return false;
|
||||
#if !USE_OLD_STYLE_UPDATE_CHECKER
|
||||
// updates to any installed package?
|
||||
FOR_EACH_CONST(p, update_version_data->packages) {
|
||||
if (!settings.check_updates_all && p->package != mse_package) continue;
|
||||
Version v;
|
||||
if (package_manager.installedVersion(p->package, v) && v < p->version) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
#else
|
||||
return update_version_data->version > app_version;
|
||||
#endif
|
||||
if (!update_version_data) return false;
|
||||
#if !USE_OLD_STYLE_UPDATE_CHECKER
|
||||
// updates to any installed package?
|
||||
FOR_EACH_CONST(p, update_version_data->packages) {
|
||||
if (!settings.check_updates_all && p->package != mse_package) continue;
|
||||
Version v;
|
||||
if (package_manager.installedVersion(p->package, v) && v < p->version) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
#else
|
||||
return update_version_data->version > app_version;
|
||||
#endif
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------- : Update checking
|
||||
@@ -92,63 +92,63 @@ bool update_available() {
|
||||
// If not, displays a message
|
||||
class CheckUpdateThread : public wxThread {
|
||||
public:
|
||||
virtual void* Entry() {
|
||||
Work();
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void Work() {
|
||||
if (checking_updates) return; // don't check multiple times simultaniously
|
||||
checking_updates = true;
|
||||
try {
|
||||
#if !USE_OLD_STYLE_UPDATE_CHECKER
|
||||
String& the_url = settings.package_versions_url;
|
||||
#else
|
||||
String& the_url = settings.updates_url;
|
||||
#endif
|
||||
wxURL url(the_url);
|
||||
wxInputStream* isP = url.GetInputStream();
|
||||
if (!isP) return; // failed to get data
|
||||
InputStreamP is(isP);
|
||||
// Read version data
|
||||
// ignore errors for forwards compatability
|
||||
VersionDataP version_data;
|
||||
Reader reader(is, nullptr, _("updates"), true);
|
||||
reader.handle(version_data);
|
||||
// has the updates url changed?
|
||||
if (!version_data->new_updates_url.empty()) {
|
||||
the_url = version_data->new_updates_url;
|
||||
}
|
||||
// Make available
|
||||
update_version_data = version_data;
|
||||
} catch (...) {
|
||||
// ignore all errors, we don't want problems if update checking fails
|
||||
}
|
||||
checking_updates = false;
|
||||
}
|
||||
virtual void* Entry() {
|
||||
Work();
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void Work() {
|
||||
if (checking_updates) return; // don't check multiple times simultaniously
|
||||
checking_updates = true;
|
||||
try {
|
||||
#if !USE_OLD_STYLE_UPDATE_CHECKER
|
||||
String& the_url = settings.package_versions_url;
|
||||
#else
|
||||
String& the_url = settings.updates_url;
|
||||
#endif
|
||||
wxURL url(the_url);
|
||||
wxInputStream* isP = url.GetInputStream();
|
||||
if (!isP) return; // failed to get data
|
||||
InputStreamP is(isP);
|
||||
// Read version data
|
||||
// ignore errors for forwards compatability
|
||||
VersionDataP version_data;
|
||||
Reader reader(is, nullptr, _("updates"), true);
|
||||
reader.handle(version_data);
|
||||
// has the updates url changed?
|
||||
if (!version_data->new_updates_url.empty()) {
|
||||
the_url = version_data->new_updates_url;
|
||||
}
|
||||
// Make available
|
||||
update_version_data = version_data;
|
||||
} catch (...) {
|
||||
// ignore all errors, we don't want problems if update checking fails
|
||||
}
|
||||
checking_updates = false;
|
||||
}
|
||||
};
|
||||
|
||||
void check_updates() {
|
||||
if (settings.check_updates == CHECK_ALWAYS) {
|
||||
check_updates_now();
|
||||
} else if (settings.check_updates == CHECK_IF_CONNECTED) {
|
||||
// only if internet connection exists
|
||||
wxDialUpManager* dum = wxDialUpManager::Create();
|
||||
if (dum->IsOk() && dum->IsOnline()) {
|
||||
check_updates_now();
|
||||
}
|
||||
delete dum;
|
||||
}
|
||||
if (settings.check_updates == CHECK_ALWAYS) {
|
||||
check_updates_now();
|
||||
} else if (settings.check_updates == CHECK_IF_CONNECTED) {
|
||||
// only if internet connection exists
|
||||
wxDialUpManager* dum = wxDialUpManager::Create();
|
||||
if (dum->IsOk() && dum->IsOnline()) {
|
||||
check_updates_now();
|
||||
}
|
||||
delete dum;
|
||||
}
|
||||
}
|
||||
|
||||
void check_updates_now(bool async) {
|
||||
if (async) {
|
||||
CheckUpdateThread* thread = new CheckUpdateThread;
|
||||
thread->Create();
|
||||
thread->Run();
|
||||
} else {
|
||||
CheckUpdateThread::Work();
|
||||
}
|
||||
if (async) {
|
||||
CheckUpdateThread* thread = new CheckUpdateThread;
|
||||
thread->Create();
|
||||
thread->Run();
|
||||
} else {
|
||||
CheckUpdateThread::Work();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -156,9 +156,9 @@ void check_updates_now(bool async) {
|
||||
#if !USE_OLD_STYLE_UPDATE_CHECKER
|
||||
|
||||
void show_update_dialog(Window* parent) {
|
||||
if (!update_available() || shown_dialog) return; // we already have the latest version, or this has already been displayed.
|
||||
shown_dialog = true;
|
||||
(new PackagesWindow(parent))->Show();
|
||||
if (!update_available() || shown_dialog) return; // we already have the latest version, or this has already been displayed.
|
||||
shown_dialog = true;
|
||||
(new PackagesWindow(parent))->Show();
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------- : Dialog (old style)
|
||||
@@ -168,33 +168,33 @@ void show_update_dialog(Window* parent) {
|
||||
|
||||
// A HTML control that opens all pages in an actual browser
|
||||
struct HtmlWindowToBrowser : public wxHtmlWindow {
|
||||
HtmlWindowToBrowser(Window* parent, int id, const wxPoint& pos, const wxSize& size, long flags)
|
||||
: wxHtmlWindow(parent, id, pos, size, flags)
|
||||
{}
|
||||
|
||||
virtual void OnLinkClicked(const wxHtmlLinkInfo& info) {
|
||||
wxLaunchDefaultBrowser( info.GetHref() );
|
||||
}
|
||||
HtmlWindowToBrowser(Window* parent, int id, const wxPoint& pos, const wxSize& size, long flags)
|
||||
: wxHtmlWindow(parent, id, pos, size, flags)
|
||||
{}
|
||||
|
||||
virtual void OnLinkClicked(const wxHtmlLinkInfo& info) {
|
||||
wxLaunchDefaultBrowser( info.GetHref() );
|
||||
}
|
||||
};
|
||||
|
||||
void show_update_dialog(Window* parent) {
|
||||
if (!update_available() || shown_dialog) return; // we already have the latest version, or this has already been displayed.
|
||||
// Show update dialog
|
||||
wxDialog* dlg = new wxDialog(parent, wxID_ANY, _TITLE_("updates available"), wxDefaultPosition);
|
||||
// controls
|
||||
wxHtmlWindow* html = new HtmlWindowToBrowser(dlg, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxHW_SCROLLBAR_AUTO | wxBORDER_THEME);
|
||||
html->SetPage(update_version_data->description);
|
||||
wxButton* close = new wxButton(dlg, wxID_OK, _BUTTON_("close"));
|
||||
close->SetDefault();
|
||||
// layout
|
||||
wxSizer* s = new wxBoxSizer(wxVERTICAL);
|
||||
s->Add(html, 1, wxEXPAND | wxALL, 8);
|
||||
s->Add(close, 0, wxALIGN_RIGHT | (wxALL & ~wxTOP), 8);
|
||||
dlg->SetSizer(s);
|
||||
dlg->SetSize(400,400);
|
||||
dlg->Show();
|
||||
// And never show it again this run
|
||||
shown_dialog = true;
|
||||
if (!update_available() || shown_dialog) return; // we already have the latest version, or this has already been displayed.
|
||||
// Show update dialog
|
||||
wxDialog* dlg = new wxDialog(parent, wxID_ANY, _TITLE_("updates available"), wxDefaultPosition);
|
||||
// controls
|
||||
wxHtmlWindow* html = new HtmlWindowToBrowser(dlg, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxHW_SCROLLBAR_AUTO | wxBORDER_THEME);
|
||||
html->SetPage(update_version_data->description);
|
||||
wxButton* close = new wxButton(dlg, wxID_OK, _BUTTON_("close"));
|
||||
close->SetDefault();
|
||||
// layout
|
||||
wxSizer* s = new wxBoxSizer(wxVERTICAL);
|
||||
s->Add(html, 1, wxEXPAND | wxALL, 8);
|
||||
s->Add(close, 0, wxALIGN_RIGHT | (wxALL & ~wxTOP), 8);
|
||||
dlg->SetSizer(s);
|
||||
dlg->SetSize(400,400);
|
||||
dlg->Show();
|
||||
// And never show it again this run
|
||||
shown_dialog = true;
|
||||
}
|
||||
|
||||
#endif // !USE_OLD_STYLE_UPDATE_CHECKER
|
||||
|
||||
Reference in New Issue
Block a user