From 6bc40a94a7bebcee275c9a2025f07adad51f3ea2 Mon Sep 17 00:00:00 2001 From: KillzXGaming Date: Mon, 11 Nov 2019 16:54:39 -0500 Subject: [PATCH] Add batch editing panes if multiple are selected. --- .../FileFormats/Layout/Common.cs | 10 ++++++ .../GUI/BFLYT/Editor/BasePaneEditor.cs | 20 ++++++++++++ .../GUI/BFLYT/Editor/BasePictureboxEditor.cs | 11 +++++++ .../Editor/Materials/PaneMatColorEditor.cs | 18 +++++++++++ .../Materials/PaneMatTextureMapsEditor.cs | 31 +++++++++++++++++++ .../GUI/BFLYT/Editor/PaneEditor.cs | 5 +++ File_Format_Library/GUI/BFLYT/LayoutEditor.cs | 5 +++ 7 files changed, 100 insertions(+) diff --git a/File_Format_Library/FileFormats/Layout/Common.cs b/File_Format_Library/FileFormats/Layout/Common.cs index 59828872..320e9234 100644 --- a/File_Format_Library/FileFormats/Layout/Common.cs +++ b/File_Format_Library/FileFormats/Layout/Common.cs @@ -92,6 +92,14 @@ namespace LayoutBXLYT } } + public BxlytMaterial TryGetActiveMaterial() + { + if (this is IPicturePane) + return ((IPicturePane)this).Material; + + return null; + } + [DisplayName("Translate"), CategoryAttribute("Pane")] public Vector3F Translate { get; set; } @@ -2015,6 +2023,8 @@ namespace LayoutBXLYT } } + + public virtual void AddTexture(string texture) { int index = ParentLayout.AddTexture(texture); diff --git a/File_Format_Library/GUI/BFLYT/Editor/BasePaneEditor.cs b/File_Format_Library/GUI/BFLYT/Editor/BasePaneEditor.cs index 8069c094..695b40d7 100644 --- a/File_Format_Library/GUI/BFLYT/Editor/BasePaneEditor.cs +++ b/File_Format_Library/GUI/BFLYT/Editor/BasePaneEditor.cs @@ -193,6 +193,11 @@ namespace LayoutBXLYT if (!Loaded) return; ActivePane.Alpha = (byte)alphaUD.Value; + //Apply to all selected panes + foreach (BasePane pane in parentEditor.SelectedPanes) + pane.Alpha = (byte)alphaUD.Value; + + parentEditor.PropertyChanged?.Invoke(sender, e); } @@ -241,6 +246,12 @@ namespace LayoutBXLYT ActivePane.originY = OriginY.Center; } + //Apply to all selected panes + foreach (BasePane pane in parentEditor.SelectedPanes) { + pane.originX = ActivePane.originX; + pane.originY = ActivePane.originY; + } + SetOrientation(); IsRadioOrientationEdited = false; @@ -300,6 +311,15 @@ namespace LayoutBXLYT ActivePane.ParentOriginY = OriginY.Center; } + //Apply to all selected panes + foreach (BasePane pane in parentEditor.SelectedPanes) { + if (!pane.IsRoot && !pane.ParentIsRoot) + { + pane.ParentOriginX = ActivePane.ParentOriginX; + pane.ParentOriginY = ActivePane.ParentOriginY; + } + } + SetParentOrientation(); IsRadioOrientationEdited = false; diff --git a/File_Format_Library/GUI/BFLYT/Editor/BasePictureboxEditor.cs b/File_Format_Library/GUI/BFLYT/Editor/BasePictureboxEditor.cs index 9ab1c949..9a5e81f5 100644 --- a/File_Format_Library/GUI/BFLYT/Editor/BasePictureboxEditor.cs +++ b/File_Format_Library/GUI/BFLYT/Editor/BasePictureboxEditor.cs @@ -68,6 +68,17 @@ namespace LayoutBXLYT ActivePane.ColorBottomLeft.Color = vertexColorBox1.BottomLeftColor; ActivePane.ColorBottomRight.Color = vertexColorBox1.BottomRightColor; + //Apply to all selected panes + foreach (BasePane pane in parentEditor.SelectedPanes) + { + if (pane is IPicturePane) { + ((IPicturePane)pane).ColorTopLeft.Color = vertexColorBox1.TopLeftColor; + ((IPicturePane)pane).ColorTopRight.Color = vertexColorBox1.TopRightColor; + ((IPicturePane)pane).ColorBottomLeft.Color = vertexColorBox1.BottomLeftColor; + ((IPicturePane)pane).ColorBottomRight.Color = vertexColorBox1.BottomRightColor; + } + } + parentEditor.PropertyChanged?.Invoke(sender, e); } diff --git a/File_Format_Library/GUI/BFLYT/Editor/Materials/PaneMatColorEditor.cs b/File_Format_Library/GUI/BFLYT/Editor/Materials/PaneMatColorEditor.cs index ac1b6075..2e6eccd3 100644 --- a/File_Format_Library/GUI/BFLYT/Editor/Materials/PaneMatColorEditor.cs +++ b/File_Format_Library/GUI/BFLYT/Editor/Materials/PaneMatColorEditor.cs @@ -55,6 +55,15 @@ namespace LayoutBXLYT { whiteColorPB.Color = colorDlg.NewColor; ActiveMaterial.WhiteColor.Color = colorDlg.NewColor; + + //Apply to all selected panes + foreach (BasePane pane in ParentEditor.SelectedPanes) + { + var mat = pane.TryGetActiveMaterial(); + if (mat != null) + mat.WhiteColor.Color = colorDlg.NewColor; + } + ParentEditor.PropertyChanged?.Invoke(sender, e); }; colorDlg.Show(); @@ -78,6 +87,15 @@ namespace LayoutBXLYT { blackColorBP.Color = colorDlg.NewColor; ActiveMaterial.BlackColor.Color = colorDlg.NewColor; + + //Apply to all selected panes + foreach (BasePane pane in ParentEditor.SelectedPanes) + { + var mat = pane.TryGetActiveMaterial(); + if (mat != null) + mat.BlackColor.Color = colorDlg.NewColor; + } + ParentEditor.PropertyChanged?.Invoke(sender, e); }; colorDlg.Show(); diff --git a/File_Format_Library/GUI/BFLYT/Editor/Materials/PaneMatTextureMapsEditor.cs b/File_Format_Library/GUI/BFLYT/Editor/Materials/PaneMatTextureMapsEditor.cs index 5becd4a3..d8d687f7 100644 --- a/File_Format_Library/GUI/BFLYT/Editor/Materials/PaneMatTextureMapsEditor.cs +++ b/File_Format_Library/GUI/BFLYT/Editor/Materials/PaneMatTextureMapsEditor.cs @@ -288,6 +288,14 @@ namespace LayoutBXLYT string newTexture = selector.GetSelectedTexture(); ActiveMaterial.AddTexture(newTexture); + //Apply to all selected panes + foreach (BasePane pane in ParentEditor.SelectedPanes) + { + var mat = pane.TryGetActiveMaterial(); + if (mat != null && mat != ActiveMaterial && mat.TextureMaps?.Length != 3) + mat.AddTexture(newTexture); + } + ReloadTexture(); ParentEditor.PropertyChanged?.Invoke(sender, e); } @@ -313,6 +321,19 @@ namespace LayoutBXLYT texMap.Name = newTexture; ReloadTexture(); ParentEditor.PropertyChanged?.Invoke(sender, e); + + //Apply to all selected panes + foreach (BasePane pane in ParentEditor.SelectedPanes) + { + var mat = pane.TryGetActiveMaterial(); + if (mat != null && mat != ActiveMaterial) + { + if (mat.TextureMaps?.Length > SelectedIndex) + mat.TextureMaps[SelectedIndex] = texMap; + else + mat.AddTexture(newTexture); + } + } } } } @@ -320,8 +341,18 @@ namespace LayoutBXLYT private void removebtn_Click(object sender, EventArgs e) { if (ActiveMaterial.TextureMaps.Length > SelectedIndex && SelectedIndex >= 0) + { ActiveMaterial.TextureMaps = ActiveMaterial.TextureMaps.RemoveAt(SelectedIndex); + //Apply to all selected panes + foreach (BasePane pane in ParentEditor.SelectedPanes) + { + var mat = pane.TryGetActiveMaterial(); + if (mat != null && mat != ActiveMaterial && mat.TextureMaps?.Length > SelectedIndex) + mat.TextureMaps = mat.TextureMaps.RemoveAt(SelectedIndex); + } + } + if (ActiveMaterial.TextureMaps.Length == 0) { SelectedIndex = -1; diff --git a/File_Format_Library/GUI/BFLYT/Editor/PaneEditor.cs b/File_Format_Library/GUI/BFLYT/Editor/PaneEditor.cs index 15baddf6..c97d7e15 100644 --- a/File_Format_Library/GUI/BFLYT/Editor/PaneEditor.cs +++ b/File_Format_Library/GUI/BFLYT/Editor/PaneEditor.cs @@ -28,6 +28,11 @@ namespace LayoutBXLYT return ParentEditor.GetTextures(); } + public List SelectedPanes + { + get { return ParentEditor.SelectedPanes; } + } + public void Reset() { stToolStrip1.Items.Clear(); diff --git a/File_Format_Library/GUI/BFLYT/LayoutEditor.cs b/File_Format_Library/GUI/BFLYT/LayoutEditor.cs index d874ecaa..c6325124 100644 --- a/File_Format_Library/GUI/BFLYT/LayoutEditor.cs +++ b/File_Format_Library/GUI/BFLYT/LayoutEditor.cs @@ -35,6 +35,11 @@ namespace LayoutBXLYT public List AnimationFiles = new List(); public List SelectedAnimations = new List(); + public List SelectedPanes + { + get { return ActiveViewport?.SelectedPanes; } + } + private BxlytHeader ActiveLayout; private BxlanHeader ActiveAnimation;