Skip to content

Commit

Permalink
fix bbl camera #1091 #1830
Browse files Browse the repository at this point in the history
  • Loading branch information
SoftFever committed Aug 20, 2023
1 parent 01f9438 commit 789a68d
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/libslic3r/Time.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ inline std::string utc_timestamp()
return utc_timestamp(get_current_time_utc());
}

inline std::string local_timestamp() {
return time2str(get_current_time_utc(), TimeZone::local, TimeFormat::gcode);
inline std::string local_timestamp(TimeFormat fmt = TimeFormat::gcode) {
return time2str(get_current_time_utc(), TimeZone::local, fmt);
}

// String to time_t function. Returns time_t(-1) if fails to parse the input.
Expand Down
27 changes: 25 additions & 2 deletions src/slic3r/GUI/wxMediaCtrl2.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
#include "wxMediaCtrl2.h"
#include "libslic3r/Time.hpp"
#include "I18N.hpp"
#include "GUI_App.hpp"
#include <boost/filesystem/operations.hpp>
#include <winuser.h>
#ifdef __WIN32__
#include <versionhelpers.h>
#include <wx/msw/registry.h>
Expand Down Expand Up @@ -72,14 +75,34 @@ void wxMediaCtrl2::Load(wxURI url)
std::string data_dir_str = Slic3r::data_dir();
boost::filesystem::path data_dir_path(data_dir_str);
auto dll_path = data_dir_path / "plugins" / "BambuSource.dll";

if (boost::filesystem::exists(dll_path)) {
CallAfter(
[dll_path] {
int res = wxMessageBox(_L("BambuSource has not correctly been registered for media playing! Press Yes to re-register it."), _L("Error"), wxYES_NO);
int res = wxMessageBox(_L("BambuSource has not correctly been registered for media playing! Press Yes to re-register it. You will be promoted twice"), _L("Error"), wxYES_NO);
if (res == wxYES) {
wstring quoted_dll_path = L"\"" + dll_path.wstring() + "\"";
std::string regContent = R"(Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\bambu]
"Source Filter"="{233E64FB-2041-4A6C-AFAB-FF9BCF83E7AA}"
)";

auto reg_path = (fs::temp_directory_path() / fs::unique_path()).replace_extension(".reg");
std::ofstream temp_reg_file(reg_path.c_str());
if (!temp_reg_file) {
return false;
}
temp_reg_file << regContent;
temp_reg_file.close();
auto sei_params = L"/q /s " + reg_path.wstring();
SHELLEXECUTEINFO sei{sizeof(sei), SEE_MASK_NOCLOSEPROCESS, NULL, L"open",
L"regedit", sei_params.c_str(),SW_HIDE,SW_HIDE};
::ShellExecuteEx(&sei);

wstring quoted_dll_path = L"\"" + dll_path.wstring() + L"\"";
SHELLEXECUTEINFO info{sizeof(info), 0, NULL, L"runas", L"regsvr32", quoted_dll_path.c_str(), SW_HIDE };
::ShellExecuteEx(&info);
fs::remove(reg_path);

}
});
} else {
Expand Down

0 comments on commit 789a68d

Please sign in to comment.