mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-07-28 21:32:11 +00:00
Implement support for loading custom plugin binaries
This commit is contained in:
@@ -3225,7 +3225,8 @@ __retry:
|
||||
std::string loaded_version = Slic3r::NetworkAgent::get_version();
|
||||
if (app_config && !loaded_version.empty() && loaded_version != "00.00.00.00") {
|
||||
std::string config_version = app_config->get_network_plugin_version();
|
||||
if (config_version != loaded_version) {
|
||||
std::string config_base = BBL::extract_base_version(config_version);
|
||||
if (config_base != loaded_version) {
|
||||
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << ": syncing config version from " << config_version << " to loaded " << loaded_version;
|
||||
app_config->set(SETTING_NETWORK_PLUGIN_VERSION, loaded_version);
|
||||
app_config->save();
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
#include "Tab.hpp"
|
||||
#include "libslic3r/Utils.hpp"
|
||||
#include "libslic3r/Model.hpp"
|
||||
#include "libslic3r/AppConfig.hpp"
|
||||
#include "slic3r/Utils/bambu_networking.hpp"
|
||||
|
||||
#include <wx/app.h>
|
||||
#include <wx/button.h>
|
||||
@@ -525,10 +527,22 @@ void MonitorPanel::jump_to_LiveView()
|
||||
|
||||
void MonitorPanel::update_network_version_footer()
|
||||
{
|
||||
std::string network_ver = Slic3r::NetworkAgent::get_version();
|
||||
if (!network_ver.empty()) {
|
||||
m_tabpanel->SetFooterText(wxString::Format("Network plugin v%s", network_ver));
|
||||
std::string binary_version = Slic3r::NetworkAgent::get_version();
|
||||
if (binary_version.empty())
|
||||
return;
|
||||
|
||||
std::string configured_version = wxGetApp().app_config->get_network_plugin_version();
|
||||
std::string suffix = BBL::extract_suffix(configured_version);
|
||||
std::string configured_base = BBL::extract_base_version(configured_version);
|
||||
|
||||
wxString footer_text;
|
||||
if (!suffix.empty() && configured_base == binary_version) {
|
||||
footer_text = wxString::Format("Network plugin v%s (%s)", binary_version, suffix);
|
||||
} else {
|
||||
footer_text = wxString::Format("Network plugin v%s", binary_version);
|
||||
}
|
||||
|
||||
m_tabpanel->SetFooterText(footer_text);
|
||||
}
|
||||
|
||||
} // GUI
|
||||
|
||||
@@ -211,11 +211,17 @@ void NetworkPluginDownloadDialog::setup_version_selector()
|
||||
wxDefaultPosition, wxSize(FromDIP(380), FromDIP(28)), 0, nullptr, wxCB_READONLY);
|
||||
m_version_combo->SetFont(::Label::Body_13);
|
||||
|
||||
for (size_t i = 0; i < BBL::AVAILABLE_NETWORK_VERSIONS_COUNT; ++i) {
|
||||
const auto& ver = BBL::AVAILABLE_NETWORK_VERSIONS[i];
|
||||
wxString label = wxString::FromUTF8(ver.display_name);
|
||||
if (ver.is_latest) {
|
||||
label += wxString(" ") + _L("(Latest)");
|
||||
m_available_versions = BBL::get_all_available_versions();
|
||||
for (size_t i = 0; i < m_available_versions.size(); ++i) {
|
||||
const auto& ver = m_available_versions[i];
|
||||
wxString label;
|
||||
if (!ver.suffix.empty()) {
|
||||
label = wxString::FromUTF8("\xE2\x94\x94 ") + wxString::FromUTF8(ver.display_name);
|
||||
} else {
|
||||
label = wxString::FromUTF8(ver.display_name);
|
||||
if (ver.is_latest) {
|
||||
label += wxString(" ") + _L("(Latest)");
|
||||
}
|
||||
}
|
||||
m_version_combo->Append(label);
|
||||
}
|
||||
@@ -230,19 +236,19 @@ std::string NetworkPluginDownloadDialog::get_selected_version() const
|
||||
}
|
||||
|
||||
int selection = m_version_combo->GetSelection();
|
||||
if (selection < 0 || selection >= static_cast<int>(BBL::AVAILABLE_NETWORK_VERSIONS_COUNT)) {
|
||||
if (selection < 0 || selection >= static_cast<int>(m_available_versions.size())) {
|
||||
return "";
|
||||
}
|
||||
|
||||
return BBL::AVAILABLE_NETWORK_VERSIONS[selection].version;
|
||||
return m_available_versions[selection].version;
|
||||
}
|
||||
|
||||
void NetworkPluginDownloadDialog::on_download(wxCommandEvent& evt)
|
||||
{
|
||||
int selection = m_version_combo ? m_version_combo->GetSelection() : 0;
|
||||
if (selection >= 0 && selection < static_cast<int>(BBL::AVAILABLE_NETWORK_VERSIONS_COUNT)) {
|
||||
const char* warning = BBL::AVAILABLE_NETWORK_VERSIONS[selection].warning;
|
||||
if (warning) {
|
||||
if (selection >= 0 && selection < static_cast<int>(m_available_versions.size())) {
|
||||
const std::string& warning = m_available_versions[selection].warning;
|
||||
if (!warning.empty()) {
|
||||
MessageDialog warn_dlg(this, wxString::FromUTF8(warning), _L("Warning"), wxOK | wxCANCEL | wxICON_WARNING);
|
||||
if (warn_dlg.ShowModal() != wxID_OK) {
|
||||
return;
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#include "MsgDialog.hpp"
|
||||
#include "Widgets/ComboBox.hpp"
|
||||
#include "Widgets/Button.hpp"
|
||||
#include "slic3r/Utils/bambu_networking.hpp"
|
||||
#include <wx/collpane.h>
|
||||
|
||||
namespace Slic3r {
|
||||
@@ -52,6 +53,7 @@ private:
|
||||
wxCollapsiblePane* m_details_pane{nullptr};
|
||||
std::string m_error_message;
|
||||
std::string m_error_details;
|
||||
std::vector<BBL::NetworkLibraryVersionInfo> m_available_versions;
|
||||
};
|
||||
|
||||
class NetworkPluginRestartDialog : public DPIDialog
|
||||
|
||||
@@ -1371,13 +1371,23 @@ void PreferencesDialog::create_items()
|
||||
std::string current_version = app_config->get("network_plugin_version");
|
||||
int current_selection = 0;
|
||||
|
||||
for (size_t i = 0; i < BBL::AVAILABLE_NETWORK_VERSIONS_COUNT; i++) {
|
||||
wxString label = wxString::FromUTF8(BBL::AVAILABLE_NETWORK_VERSIONS[i].display_name);
|
||||
if (BBL::AVAILABLE_NETWORK_VERSIONS[i].is_latest) {
|
||||
m_available_versions = BBL::get_all_available_versions();
|
||||
|
||||
for (size_t i = 0; i < m_available_versions.size(); i++) {
|
||||
const auto& ver = m_available_versions[i];
|
||||
wxString label;
|
||||
|
||||
if (!ver.suffix.empty()) {
|
||||
label = wxString::FromUTF8("\xE2\x94\x94 ") + wxString::FromUTF8(ver.display_name);
|
||||
} else {
|
||||
label = wxString::FromUTF8(ver.display_name);
|
||||
}
|
||||
|
||||
if (ver.is_latest) {
|
||||
label += " " + _L("(Latest)");
|
||||
}
|
||||
m_network_version_combo->Append(label);
|
||||
if (current_version == BBL::AVAILABLE_NETWORK_VERSIONS[i].version) {
|
||||
if (current_version == ver.version) {
|
||||
current_selection = i;
|
||||
}
|
||||
}
|
||||
@@ -1387,8 +1397,9 @@ void PreferencesDialog::create_items()
|
||||
|
||||
m_network_version_combo->GetDropDown().Bind(wxEVT_COMBOBOX, [this](wxCommandEvent& e) {
|
||||
int selection = e.GetSelection();
|
||||
if (selection >= 0 && selection < (int)BBL::AVAILABLE_NETWORK_VERSIONS_COUNT) {
|
||||
std::string new_version = BBL::AVAILABLE_NETWORK_VERSIONS[selection].version;
|
||||
if (selection >= 0 && selection < (int)m_available_versions.size()) {
|
||||
const auto& selected_ver = m_available_versions[selection];
|
||||
std::string new_version = selected_ver.version;
|
||||
std::string old_version = app_config->get_network_plugin_version();
|
||||
if (old_version.empty()) {
|
||||
old_version = BBL::get_latest_network_version();
|
||||
@@ -1400,9 +1411,8 @@ void PreferencesDialog::create_items()
|
||||
if (new_version != old_version) {
|
||||
BOOST_LOG_TRIVIAL(info) << "Network plugin version changed from " << old_version << " to " << new_version;
|
||||
|
||||
const char* warning = BBL::AVAILABLE_NETWORK_VERSIONS[selection].warning;
|
||||
if (warning) {
|
||||
MessageDialog warn_dlg(this, wxString::FromUTF8(warning), _L("Warning"), wxOK | wxCANCEL | wxICON_WARNING);
|
||||
if (!selected_ver.warning.empty()) {
|
||||
MessageDialog warn_dlg(this, wxString::FromUTF8(selected_ver.warning), _L("Warning"), wxOK | wxCANCEL | wxICON_WARNING);
|
||||
if (warn_dlg.ShowModal() != wxID_OK) {
|
||||
app_config->set(SETTING_NETWORK_PLUGIN_VERSION, old_version);
|
||||
app_config->save();
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
#include "Widgets/CheckBox.hpp"
|
||||
#include "Widgets/TextInput.hpp"
|
||||
#include "Widgets/TabCtrl.hpp"
|
||||
#include "slic3r/Utils/bambu_networking.hpp"
|
||||
|
||||
namespace Slic3r { namespace GUI {
|
||||
|
||||
@@ -70,6 +71,7 @@ public:
|
||||
::CheckBox * m_legacy_networking_ckeckbox = {nullptr};
|
||||
::ComboBox * m_network_version_combo = {nullptr};
|
||||
wxBoxSizer * m_network_version_sizer = {nullptr};
|
||||
std::vector<BBL::NetworkLibraryVersionInfo> m_available_versions;
|
||||
|
||||
wxString m_developer_mode_def;
|
||||
wxString m_internal_developer_mode_def;
|
||||
|
||||
Reference in New Issue
Block a user