From 6a922ea9138c896405f5e0a6d7952e605f6c866a Mon Sep 17 00:00:00 2001 From: SoftFever Date: Sat, 8 Mar 2025 23:33:08 +0800 Subject: [PATCH] init --- resources/web/guide/23/23.js | 79 +++++++++++++++++++++++++++++-- src/slic3r/GUI/WebGuideDialog.cpp | 24 ++++++++-- 2 files changed, 95 insertions(+), 8 deletions(-) diff --git a/resources/web/guide/23/23.js b/resources/web/guide/23/23.js index d7f0bf8e93..c7525ebb62 100644 --- a/resources/web/guide/23/23.js +++ b/resources/web/guide/23/23.js @@ -220,6 +220,9 @@ function SortUI() //------ if(SelectNumber==0) ChooseDefaultFilament(); + + // After building the UI, setup filament click handlers + SetupFilamentClickHandlers(); } @@ -253,7 +256,7 @@ function ChooseAllFilament() { let bCheck=$("#FilatypeList input:first").prop("checked"); $("#FilatypeList input").prop("checked",bCheck); - + SortFilament(); } @@ -429,6 +432,12 @@ function ChooseDefaultFilament() $(OneFF).prop("checked",true); } + // Keep this part since we're checking filaments + let currentPrinters = GetSelectedPrinters(); + $("#ItemBlockArea input:checked").each(function() { + $(this).data("selectedPrinters", currentPrinters); + }); + ShowNotice(0); } @@ -436,11 +445,16 @@ function SelectAllFilament( nShow ) { if( nShow==0 ) { - $('#ItemBlockArea .MItem:visible input').prop("checked",false); + $('#ItemBlockArea .MItem:visible input').prop("checked",false).each(function() { + $(this).removeData("selectedPrinters"); + }); } else { - $('#ItemBlockArea .MItem:visible input').prop("checked",true); + let currentPrinters = GetSelectedPrinters(); + $('#ItemBlockArea .MItem:visible input').prop("checked",true).each(function() { + $(this).data("selectedPrinters", currentPrinters); + }); } } @@ -471,16 +485,33 @@ function ResponseFilamentResult() } let FilaArray=new Array(); + let FilaInfo = {}; + for(let n=0;nHide(); m_browser->SetSize(0, 0); + m_browser->EnableAccessToDevTools(); + SetSizer(topsizer); @@ -447,11 +449,25 @@ void GuideFrame::OnScriptMessage(wxWebViewEvent &evt) for (int m = 0; m < nF; m++) { std::string fName = fSelected[m]; - - m_ProfileJson["filament"][fName]["selected"] = 1; + // check if fNmae is in j["data"]["filamentInfo"][fName]["selectedPrinters"] + if (m_ProfileJson["filament"].find(fName) != m_ProfileJson["filament"].end()) + m_ProfileJson["filament"][fName]["selected"] = 1; + m_ProfileJson["filament"][fName]["enabled_printers"] = j["data"]["filamentInfo"][fName]["selectedPrinters"]; + } + + // Save profile json to file (for debugging purposes) + boost::filesystem::path profile_path = boost::filesystem::path(Slic3r::data_dir()) / "cached_profile.json"; + + try { + std::ofstream profile_file(profile_path.string()); + if (profile_file.is_open()) { + profile_file << m_ProfileJson.dump(4); + profile_file.close(); + BOOST_LOG_TRIVIAL(debug) << __FUNCTION__ << ": Saved profile to " << profile_path.string(); + } + } catch (const std::exception& e) { + BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << ": Failed to save profile: " << e.what(); } - } - else if (strCmd == "user_guide_finish") { SaveProfile(); std::string oldregion = m_ProfileJson["region"];