diff --git a/xLights/SeqFileUtilities.cpp b/xLights/SeqFileUtilities.cpp index 7268de022..af530e64c 100644 --- a/xLights/SeqFileUtilities.cpp +++ b/xLights/SeqFileUtilities.cpp @@ -1056,8 +1056,9 @@ void xLightsFrame::OnMenuItemImportEffects(wxCommandEvent& event) } } -void MapXLightsEffects(EffectLayer* target, EffectLayer* src, std::vector& mapped, bool eraseExisting, SequencePackage& xsqPkg, bool lock, const std::map& mapping) -{ +void MapXLightsEffects(EffectLayer* target, EffectLayer* src, std::vector& mapped, + bool eraseExisting, SequencePackage& xsqPkg, + bool lock, const std::map& mapping, bool convertRender) { if (eraseExisting) target->DeleteAllEffects(); @@ -1091,6 +1092,30 @@ void MapXLightsEffects(EffectLayer* target, EffectLayer* src, std::vector(m); if (mg != nullptr) { + + if (convertRender) { + Model* sm = src->GetParentElement()->GetSequenceElements()->GetXLightsFrame()->GetModel(src->GetParentElement()->GetModelName()); + if (sm != nullptr) { + if (sm->GetDisplayAs() != "ModelGroup") { + auto buffer = ef->GetSettings()["B_CHOICE_BufferStyle"]; + if (buffer == "Per Preview" || buffer == "Default" || buffer == "Single Line") { + Replace(settings, "B_CHOICE_BufferStyle=" + buffer, + "B_CHOICE_BufferStyle=Per Model " + buffer); + } else if (buffer.empty()) { + if (Contains(settings, "B_CHOICE_BufferStyle")) { + Replace(settings, "B_CHOICE_BufferStyle=", + "B_CHOICE_BufferStyle=Per Model Default"); + } else { + if (!settings.empty()) { + settings += ","; + } + settings += "B_CHOICE_BufferStyle=Per Model Default"; + } + } + } + } + } + // so is it a per preview render buffer auto rb = ef->GetSettings()["B_CHOICE_BufferStyle"]; if (BufferPanel::CanRenderBufferUseCamera(rb)) { @@ -1132,7 +1157,7 @@ void MapXLightsStrandEffects(EffectLayer* target, const std::string& name, std::map& layerMap, SequenceElements& seqEl, std::vector& mapped, bool eraseExisting, - SequencePackage& xsqPkg, bool lock, const std::map& mapping) + SequencePackage& xsqPkg, bool lock, const std::map& mapping, bool convertRender) { EffectLayer* src = layerMap[name]; if (src == nullptr) { @@ -1144,7 +1169,7 @@ void MapXLightsStrandEffects(EffectLayer* target, const std::string& name, src = srcEl->GetEffectLayer(0); } if (src != nullptr) { - MapXLightsEffects(target, src, mapped, eraseExisting, xsqPkg, lock, mapping); + MapXLightsEffects(target, src, mapped, eraseExisting, xsqPkg, lock, mapping, convertRender); } else { printf("Source strand %s doesn't exist\n", name.c_str()); } @@ -1156,7 +1181,7 @@ void MapXLightsEffects(Element* target, std::map& elementMap, std::map& layerMap, std::vector& mapped, bool eraseExisting, - SequencePackage& xsqPkg, bool lock, const std::map& mapping) + SequencePackage& xsqPkg, bool lock, const std::map& mapping, bool convertRender) { static log4cpp::Category& logger_base = log4cpp::Category::getInstance(std::string("log_base")); if (target->GetType() == ElementType::ELEMENT_TYPE_STRAND) { @@ -1170,7 +1195,7 @@ void MapXLightsEffects(Element* target, Element* el = elementMap[name]; if (src != nullptr) { - MapXLightsEffects(target->GetEffectLayer(0), src, mapped, eraseExisting, xsqPkg, lock, mapping); + MapXLightsEffects(target->GetEffectLayer(0), src, mapped, eraseExisting, xsqPkg, lock, mapping, convertRender); return; } @@ -1189,7 +1214,7 @@ void MapXLightsEffects(Element* target, } for (size_t x = 0; x < el->GetEffectLayerCount(); ++x) { target->GetEffectLayer(x)->SetLayerName(el->GetEffectLayer(x)->GetLayerName()); - MapXLightsEffects(target->GetEffectLayer(x), el->GetEffectLayer(x), mapped, eraseExisting, xsqPkg, lock, mapping); + MapXLightsEffects(target->GetEffectLayer(x), el->GetEffectLayer(x), mapped, eraseExisting, xsqPkg, lock, mapping, convertRender); } } @@ -1352,6 +1377,7 @@ void xLightsFrame::ImportXLights(SequenceElements& se, const std::vectorGetCount() > 0 && _sequenceElements.GetNumberOfTimingElements() == 1 && _sequenceElements.GetTimingElement("New Timing") != nullptr && !_sequenceElements.GetTimingElement("New Timing")->HasEffects()) { @@ -1393,7 +1419,7 @@ void xLightsFrame::ImportXLights(SequenceElements& se, const std::vectorGetEffectLayer(l); std::vector mapped2; - MapXLightsEffects(dst, src, mapped2, dlg.CheckBox_EraseExistingEffects->GetValue(), xsqPkg, lock, mapping); + MapXLightsEffects(dst, src, mapped2, dlg.CheckBox_EraseExistingEffects->GetValue(), xsqPkg, lock, mapping, convertRender); } } } @@ -1415,7 +1441,7 @@ void xLightsFrame::ImportXLights(SequenceElements& se, const std::vector_mapping, se, elementMap, layerMap, mapped, dlg.CheckBox_EraseExistingEffects->GetValue(), xsqPkg, lock, mapping); + MapXLightsEffects(model, m->_mapping, se, elementMap, layerMap, mapped, dlg.CheckBox_EraseExistingEffects->GetValue(), xsqPkg, lock, mapping, convertRender); } } @@ -1432,7 +1458,7 @@ void xLightsFrame::ImportXLights(SequenceElements& se, const std::vectorGetSubModel(str); if (ste != nullptr) { - MapXLightsEffects(ste, s->_mapping, se, elementMap, layerMap, mapped, dlg.CheckBox_EraseExistingEffects->GetValue(), xsqPkg, lock, mapping); + MapXLightsEffects(ste, s->_mapping, se, elementMap, layerMap, mapped, dlg.CheckBox_EraseExistingEffects->GetValue(), xsqPkg, lock, mapping, convertRender); } } } @@ -1450,7 +1476,7 @@ void xLightsFrame::ImportXLights(SequenceElements& se, const std::vectorGetNodeLayer(n, true); if (nl != nullptr) { - MapXLightsStrandEffects(nl, ns->_mapping, layerMap, se, mapped, dlg.CheckBox_EraseExistingEffects->GetValue(), xsqPkg, lock, mapping); + MapXLightsStrandEffects(nl, ns->_mapping, layerMap, se, mapped, dlg.CheckBox_EraseExistingEffects->GetValue(), xsqPkg, lock, mapping, convertRender); } } } diff --git a/xLights/wxsmith/xLightsImportChannelMapDialog.wxs b/xLights/wxsmith/xLightsImportChannelMapDialog.wxs index 12d71ab72..6cf457258 100644 --- a/xLights/wxsmith/xLightsImportChannelMapDialog.wxs +++ b/xLights/wxsmith/xLightsImportChannelMapDialog.wxs @@ -4,7 +4,6 @@ Map Channels 0 - 1 @@ -65,7 +64,7 @@ - 2 + 3 0 @@ -84,6 +83,16 @@ 5 + + + + When mapping model to group, convert render styles to 'Per Model' when applicable + + + wxALL|wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL + 5 + + wxALL|wxEXPAND 1 @@ -147,7 +156,6 @@ - wxALL|wxEXPAND diff --git a/xLights/xLightsImportChannelMapDialog.cpp b/xLights/xLightsImportChannelMapDialog.cpp index e4586506d..f3924ad45 100644 --- a/xLights/xLightsImportChannelMapDialog.cpp +++ b/xLights/xLightsImportChannelMapDialog.cpp @@ -442,6 +442,7 @@ const wxWindowID xLightsImportChannelMapDialog::ID_SPINCTRL1 = wxNewId(); const wxWindowID xLightsImportChannelMapDialog::ID_CHECKBOX1 = wxNewId(); const wxWindowID xLightsImportChannelMapDialog::ID_CHECKBOX11 = wxNewId(); const wxWindowID xLightsImportChannelMapDialog::ID_CHECKBOX4 = wxNewId(); +const wxWindowID xLightsImportChannelMapDialog::ID_CHECKBOX5 = wxNewId(); const wxWindowID xLightsImportChannelMapDialog::ID_CHECKBOX2 = wxNewId(); const wxWindowID xLightsImportChannelMapDialog::ID_STATICTEXT_BLEND_TYPE = wxNewId(); const wxWindowID xLightsImportChannelMapDialog::ID_CHECKBOX3 = wxNewId(); @@ -526,7 +527,7 @@ xLightsImportChannelMapDialog::xLightsImportChannelMapDialog(wxWindow* parent, c CheckBox_MapCCRStrand->SetValue(false); FlexGridSizer1->Add(CheckBox_MapCCRStrand, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5); Sizer1->Add(FlexGridSizer1, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 1); - FlexGridSizer11 = new wxFlexGridSizer(0, 2, 0, 0); + FlexGridSizer11 = new wxFlexGridSizer(0, 3, 0, 0); FlexGridSizer11->AddGrowableCol(0); CheckBox_EraseExistingEffects = new wxCheckBox(Panel1, ID_CHECKBOX11, _("Erase existing effects on imported models"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("ID_CHECKBOX11")); CheckBox_EraseExistingEffects->SetValue(false); @@ -534,6 +535,10 @@ xLightsImportChannelMapDialog::xLightsImportChannelMapDialog(wxWindow* parent, c CheckBox_LockEffects = new wxCheckBox(Panel1, ID_CHECKBOX4, _("Lock effects on import"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("ID_CHECKBOX4")); CheckBox_LockEffects->SetValue(true); FlexGridSizer11->Add(CheckBox_LockEffects, 1, wxALL|wxEXPAND, 5); + CheckBox_ConvertRenderStyle = new wxCheckBox(Panel1, ID_CHECKBOX5, _("Convert Render Style"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("ID_CHECKBOX5")); + CheckBox_ConvertRenderStyle->SetValue(false); + CheckBox_ConvertRenderStyle->SetToolTip(_("When mapping model to group, convert render styles to \'Per Model\' when applicable")); + FlexGridSizer11->Add(CheckBox_ConvertRenderStyle, 1, wxALL|wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL, 5); Sizer1->Add(FlexGridSizer11, 1, wxALL|wxEXPAND, 1); FlexGridSizer_Blend_Mode = new wxFlexGridSizer(0, 2, 0, 0); CheckBox_Import_Blend_Mode = new wxCheckBox(Panel1, ID_CHECKBOX2, _("Import Model Blend Mode"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("ID_CHECKBOX2")); @@ -616,6 +621,7 @@ xLightsImportChannelMapDialog::xLightsImportChannelMapDialog(wxWindow* parent, c OldSizer->SetSizeHints(this); Connect(ID_CHECKBOX1, wxEVT_COMMAND_CHECKBOX_CLICKED, (wxObjectEventFunction)&xLightsImportChannelMapDialog::OnCheckBox_MapCCRStrandClick); + Connect(ID_CHECKBOX5, wxEVT_COMMAND_CHECKBOX_CLICKED, (wxObjectEventFunction)&xLightsImportChannelMapDialog::OnCheckBox_ConvertRenderStyleClick); Connect(ID_CHECKBOX3, wxEVT_COMMAND_CHECKBOX_CLICKED, (wxObjectEventFunction)&xLightsImportChannelMapDialog::OnCheckBoxImportMediaClick); Connect(ID_BUTTON_IMPORT_OPTIONS, wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction)&xLightsImportChannelMapDialog::OnButtonImportOptionsClick); Connect(ID_TEXTCTRL2, wxEVT_COMMAND_TEXT_UPDATED, (wxObjectEventFunction)&xLightsImportChannelMapDialog::OnTextCtrl_FindToText); @@ -663,6 +669,7 @@ xLightsImportChannelMapDialog::xLightsImportChannelMapDialog(wxWindow* parent, c wxConfigBase* config = wxConfigBase::Get(); CheckBox_LockEffects->SetValue(config->ReadBool("ImportEffectsLocked", false)); + CheckBox_ConvertRenderStyle->SetValue(config->ReadBool("ImportEffectsRenderStyle", false)); EnsureWindowHeaderIsOnScreen(this); } @@ -916,6 +923,15 @@ bool xLightsImportChannelMapDialog::IsLockEffects() const return b; } +bool xLightsImportChannelMapDialog::IsConvertRenderStyle() const +{ + wxConfigBase* config = wxConfigBase::Get(); + bool b = CheckBox_ConvertRenderStyle->IsChecked(); + config->Write("ImportEffectsRenderStyle", b); + config->Flush(); + return b; +} + void xLightsImportChannelMapDialog::SetXsqPkg(SequencePackage* xsqPkg) { _xsqPkg = xsqPkg; } @@ -2814,3 +2830,7 @@ void xLightsImportChannelMapDialog::OnClose(wxCloseEvent& event) EndDialog(wxID_CANCEL); } } + +void xLightsImportChannelMapDialog::OnCheckBox_ConvertRenderStyleClick(wxCommandEvent& event) +{ +} diff --git a/xLights/xLightsImportChannelMapDialog.h b/xLights/xLightsImportChannelMapDialog.h index 2208bc9c9..b70638c24 100644 --- a/xLights/xLightsImportChannelMapDialog.h +++ b/xLights/xLightsImportChannelMapDialog.h @@ -382,7 +382,8 @@ class xLightsImportChannelMapDialog: public wxDialog bool InitImport(std::string checkboxText = ""); void SetModelBlending(bool enabled); [[nodiscard]] bool GetImportModelBlending() const; - [[nodiscard]] bool IsLockEffects() const; + [[nodiscard]] bool IsLockEffects() const; + [[nodiscard]] bool IsConvertRenderStyle() const; void SetXsqPkg(SequencePackage* xsqPkg); [[nodiscard]] std::vector const GetChannelNames() const; [[nodiscard]] ImportChannel* GetImportChannel(std::string const& name) const; @@ -399,6 +400,7 @@ class xLightsImportChannelMapDialog: public wxDialog wxButton* Button_Ok; wxButton* Button_UpdateAliases; wxCheckBox* CheckBoxImportMedia; + wxCheckBox* CheckBox_ConvertRenderStyle; wxCheckBox* CheckBox_EraseExistingEffects; wxCheckBox* CheckBox_Import_Blend_Mode; wxCheckBox* CheckBox_LockEffects; @@ -444,6 +446,7 @@ class xLightsImportChannelMapDialog: public wxDialog static const wxWindowID ID_CHECKBOX1; static const wxWindowID ID_CHECKBOX11; static const wxWindowID ID_CHECKBOX4; + static const wxWindowID ID_CHECKBOX5; static const wxWindowID ID_CHECKBOX2; static const wxWindowID ID_STATICTEXT_BLEND_TYPE; static const wxWindowID ID_CHECKBOX3; @@ -488,7 +491,7 @@ class xLightsImportChannelMapDialog: public wxDialog void OnListCtrl_AvailableColumnClick(wxListEvent& event); void OnCheckBox_MapCCRStrandClick(wxCommandEvent& event); void OnButton_AutoMapClick(wxCommandEvent& event); - void OnButton_AutoMapSelClick(wxCommandEvent& event); + void OnButton_AutoMapSelClick(wxCommandEvent& event); void OnListCtrl_AvailableItemActivated(wxListEvent& event); void OnButtonImportOptionsClick(wxCommandEvent& event); void OnCheckBoxImportMediaClick(wxCommandEvent& event); @@ -497,6 +500,7 @@ class xLightsImportChannelMapDialog: public wxDialog void OnButton_UpdateAliasesClick(wxCommandEvent& event); void OnClose(wxCloseEvent& event); void OnInit(wxInitDialogEvent& event); + void OnCheckBox_ConvertRenderStyleClick(wxCommandEvent& event); //*) void RightClickTimingTracks(wxContextMenuEvent& event);