diff --git a/src/libslic3r/AppConfig.cpp b/src/libslic3r/AppConfig.cpp index 879a05dfb..286938518 100644 --- a/src/libslic3r/AppConfig.cpp +++ b/src/libslic3r/AppConfig.cpp @@ -24,7 +24,7 @@ namespace Slic3r { static const std::string VENDOR_PREFIX = "vendor:"; static const std::string MODEL_PREFIX = "model:"; -static const std::string VERSION_CHECK_URL = "https://files.prusa3d.com/wp-content/uploads/repository/PrusaSlicer-settings-master/live/PrusaSlicer.version"; +static const std::string VERSION_CHECK_URL = "https://api.github.com/repos/supermerill/superslicer/releases"; const std::string AppConfig::SECTION_FILAMENTS = "filaments"; const std::string AppConfig::SECTION_MATERIALS = "sla_materials"; @@ -61,7 +61,7 @@ void AppConfig::set_defaults() set("freecad_path", "."); if (get("version_check").empty()) - set("version_check", "0"); + set("version_check", "1"); if (get("preset_update").empty()) set("preset_update", "0"); diff --git a/src/libslic3r/libslic3r_version.h.in b/src/libslic3r/libslic3r_version.h.in index 26a67362b..a0bfb3097 100644 --- a/src/libslic3r/libslic3r_version.h.in +++ b/src/libslic3r/libslic3r_version.h.in @@ -4,6 +4,7 @@ #define SLIC3R_APP_NAME "@SLIC3R_APP_NAME@" #define SLIC3R_APP_KEY "@SLIC3R_APP_KEY@" #define SLIC3R_VERSION "@SLIC3R_VERSION@" +#define SLIC3R_VERSION_FULL "@SLIC3R_VERSION_FULL@" #define SLIC3R_BUILD_ID "@SLIC3R_BUILD_ID@" #endif /* __SLIC3R_VERSION_H */ diff --git a/src/slic3r/GUI/AboutDialog.cpp b/src/slic3r/GUI/AboutDialog.cpp index 63e920087..11c065940 100644 --- a/src/slic3r/GUI/AboutDialog.cpp +++ b/src/slic3r/GUI/AboutDialog.cpp @@ -253,7 +253,7 @@ AboutDialog::AboutDialog() // version { - auto version_string = _L("Version")+ " " + std::string(SLIC3R_VERSION); + auto version_string = _L("Version")+ " " + std::string(SLIC3R_VERSION_FULL); wxStaticText* version = new wxStaticText(this, wxID_ANY, version_string.c_str(), wxDefaultPosition, wxDefaultSize); wxFont version_font = GetFont(); #ifdef __WXMSW__ diff --git a/src/slic3r/GUI/GUI_App.cpp b/src/slic3r/GUI/GUI_App.cpp index 10504fc13..aa84e2748 100644 --- a/src/slic3r/GUI/GUI_App.cpp +++ b/src/slic3r/GUI/GUI_App.cpp @@ -244,7 +244,7 @@ private: #endif // ENABLE_GCODE_VIEWER // dynamically get the version to display - version = _L("Version") + " " + std::string(SLIC3R_VERSION); + version = _L("Version") + " " + std::string(SLIC3R_VERSION_FULL); // credits infornation credits = title + " " + _L("is based on PrusaSlicer by Prusa and Slic3r by Alessandro Ranellucci and the RepRap community.") + "\n\n" + @@ -806,7 +806,7 @@ bool GUI_App::on_init_inner() } #endif // ENABLE_GCODE_VIEWER - app_config->set("version", SLIC3R_VERSION); + app_config->set("version", SLIC3R_VERSION_FULL); app_config->save(); wxInitAllImageHandlers(); @@ -846,19 +846,19 @@ bool GUI_App::on_init_inner() if (is_editor()) { #endif // ENABLE_GCODE_VIEWER #ifdef __WXMSW__ - associate_3mf_files(); + associate_3mf_files(); #endif // __WXMSW__ - preset_updater = new PresetUpdater(); + preset_updater = new PresetUpdater(); Bind(EVT_SLIC3R_VERSION_ONLINE, [this](const wxCommandEvent& evt) { app_config->set("version_online", into_u8(evt.GetString())); app_config->save(); if (this->plater_ != nullptr) { - if (*Semver::parse(SLIC3R_VERSION) < *Semver::parse(into_u8(evt.GetString()))) { + //if (*Semver::parse(SLIC3R_VERSION_FULL) < *Semver::parse(into_u8(evt.GetString()))) { this->plater_->get_notification_manager()->push_notification(NotificationType::NewAppAvailable, *(this->plater_->get_current_canvas3D())); - } + //} } - }); + }); #if ENABLE_GCODE_VIEWER } else { diff --git a/src/slic3r/GUI/NotificationManager.cpp b/src/slic3r/GUI/NotificationManager.cpp index a1bb48d2b..1a4ad988a 100644 --- a/src/slic3r/GUI/NotificationManager.cpp +++ b/src/slic3r/GUI/NotificationManager.cpp @@ -6,6 +6,8 @@ #include "GLCanvas3D.hpp" #include "ImGuiWrapper.hpp" +#include "libslic3r/AppConfig.hpp" + #include "wxExtensions.hpp" #include @@ -626,7 +628,7 @@ bool NotificationManager::PopNotification::on_text_click() wxPostEvent(m_evt_handler, PresetUpdateAvailableClickedEvent(EVT_PRESET_UPDATE_AVAILABLE_CLICKED)); break; case NotificationType::NewAppAvailable: - wxLaunchDefaultBrowser("https://github.com/prusa3d/PrusaSlicer/releases"); + wxLaunchDefaultBrowser("https://github.com/supermerill/SuperSlicer/releases/tag/" + Slic3r::GUI::get_app_config()->get("version_online")); break; default: break; diff --git a/src/slic3r/GUI/SysInfoDialog.cpp b/src/slic3r/GUI/SysInfoDialog.cpp index ceadd8153..3a15ff9a0 100644 --- a/src/slic3r/GUI/SysInfoDialog.cpp +++ b/src/slic3r/GUI/SysInfoDialog.cpp @@ -39,7 +39,7 @@ std::string get_main_info(bool format_as_html) #else out << b_start << SLIC3R_APP_NAME << b_end << line_end; #endif // ENABLE_GCODE_VIEWER - out << b_start << "Version: " << b_end << SLIC3R_VERSION << line_end; + out << b_start << "Version: " << b_end << SLIC3R_VERSION_FULL << line_end; #if ENABLE_GCODE_VIEWER out << b_start << "Build: " << b_end << (wxGetApp().is_editor() ? SLIC3R_BUILD_ID : GCODEVIEWER_BUILD_ID) << line_end; #else diff --git a/src/slic3r/GUI/UpdateDialogs.cpp b/src/slic3r/GUI/UpdateDialogs.cpp index 1c18872f7..dd5f4506d 100644 --- a/src/slic3r/GUI/UpdateDialogs.cpp +++ b/src/slic3r/GUI/UpdateDialogs.cpp @@ -37,7 +37,7 @@ static const std::string CONFIG_UPDATE_WIKI_URL("https://github.com/prusa3d/Prus MsgUpdateSlic3r::MsgUpdateSlic3r(const Semver &ver_current, const Semver &ver_online) : MsgDialog(nullptr, _(L("Update available")), wxString::Format(_(L("New version of %s is available")), SLIC3R_APP_NAME)) { - const bool dev_version = ver_online.prerelease() != nullptr; + const bool dev_version = true;// ver_online.prerelease() != nullptr; // SuperSlicer is always a dev version auto *versions = new wxFlexGridSizer(2, 0, VERT_SPACING); versions->Add(new wxStaticText(this, wxID_ANY, _(L("Current version:")))); @@ -222,7 +222,7 @@ MsgDataIncompatible::MsgDataIncompatible(const std::unordered_mapWrap(CONTENT_WIDTH * wxGetApp().em_unit()); content_sizer->Add(text); - auto *text2 = new wxStaticText(this, wxID_ANY, wxString::Format(_(L("This %s version: %s")), SLIC3R_APP_NAME, SLIC3R_VERSION)); + auto *text2 = new wxStaticText(this, wxID_ANY, wxString::Format(_(L("This %s version: %s")), SLIC3R_APP_NAME, SLIC3R_VERSION_FULL)); text2->Wrap(CONTENT_WIDTH * wxGetApp().em_unit()); content_sizer->Add(text2); content_sizer->AddSpacer(VERT_SPACING); diff --git a/src/slic3r/Utils/PresetUpdater.cpp b/src/slic3r/Utils/PresetUpdater.cpp index d2880c4f8..1aec70634 100644 --- a/src/slic3r/Utils/PresetUpdater.cpp +++ b/src/slic3r/Utils/PresetUpdater.cpp @@ -246,7 +246,6 @@ void PresetUpdater::priv::sync_version() const BOOST_LOG_TRIVIAL(info) << format("Downloading %1% online version from: `%2%`", SLIC3R_APP_NAME, version_check_url); Http::get(version_check_url) - .size_limit(SLIC3R_VERSION_BODY_MAX) .on_progress([this](Http::Progress, bool &cancel) { cancel = this->cancel; }) @@ -258,21 +257,38 @@ void PresetUpdater::priv::sync_version() const error); }) .on_complete([&](std::string body, unsigned /* http_status */) { - boost::trim(body); - const auto nl_pos = body.find_first_of("\n\r"); - if (nl_pos != std::string::npos) { - body.resize(nl_pos); + boost::property_tree::ptree root; + std::stringstream json_stream(body); + boost::property_tree::read_json(json_stream, root); + bool i_am_pre = false; + std::string best_pre = "1"; + std::string best_release = "1"; + std::string best_pre_url; + std::string best_release_url; + for (auto json_version : root) { + std::string tag = json_version.second.get("tag_name"); + if (SLIC3R_VERSION_FULL == tag) + i_am_pre = json_version.second.get("prerelease"); + if (json_version.second.get("prerelease")) { + if (best_pre < tag) { + best_pre = tag; + best_pre_url = json_version.second.get("html_url"); + } + } else { + if (best_release < tag) { + best_release = tag; + best_release_url = json_version.second.get("html_url"); + } + } } - if (! Semver::parse(body)) { - BOOST_LOG_TRIVIAL(warning) << format("Received invalid contents from `%1%`: Not a correct semver: `%2%`", SLIC3R_APP_NAME, body); + if ((i_am_pre ? best_pre : best_release) <= SLIC3R_VERSION_FULL) return; - } - BOOST_LOG_TRIVIAL(info) << format("Got %1% online version: `%2%`. Sending to GUI thread...", SLIC3R_APP_NAME, body); + BOOST_LOG_TRIVIAL(info) << format("Got %1% online version: `%2%`. Sending to GUI thread...", SLIC3R_APP_NAME, i_am_pre? best_pre:best_release); wxCommandEvent* evt = new wxCommandEvent(EVT_SLIC3R_VERSION_ONLINE); - evt->SetString(GUI::from_u8(body)); + evt->SetString(i_am_pre ? best_pre : best_release); GUI::wxGetApp().QueueEvent(evt); }) .perform_sync(); diff --git a/version.inc b/version.inc index 7110057e7..205b30b3c 100644 --- a/version.inc +++ b/version.inc @@ -4,6 +4,7 @@ set(SLIC3R_APP_NAME "SuperSlicer") set(SLIC3R_APP_KEY "SuperSlicer") set(SLIC3R_VERSION "2.3.55") -set(SLIC3R_BUILD_ID "SuperSlicer_${SLIC3R_RC_VERSION}") +set(SLIC3R_VERSION_FULL "2.3.55.1") +set(SLIC3R_BUILD_ID "SuperSlicer_${SLIC3R_VERSION_FULL}") set(SLIC3R_RC_VERSION "2,3,55,1") -set(SLIC3R_RC_VERSION_DOTS "2.3.55.1") +set(SLIC3R_RC_VERSION_DOTS "${SLIC3R_VERSION_FULL}")