Add batch editing panes if multiple are selected.

This commit is contained in:
KillzXGaming 2019-11-11 16:54:39 -05:00
parent 50191e4679
commit 6bc40a94a7
7 changed files with 100 additions and 0 deletions

View file

@ -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);

View file

@ -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;

View file

@ -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);
}

View file

@ -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();

View file

@ -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;

View file

@ -28,6 +28,11 @@ namespace LayoutBXLYT
return ParentEditor.GetTextures();
}
public List<BasePane> SelectedPanes
{
get { return ParentEditor.SelectedPanes; }
}
public void Reset()
{
stToolStrip1.Items.Clear();

View file

@ -35,6 +35,11 @@ namespace LayoutBXLYT
public List<BxlanHeader> AnimationFiles = new List<BxlanHeader>();
public List<BxlanHeader> SelectedAnimations = new List<BxlanHeader>();
public List<BasePane> SelectedPanes
{
get { return ActiveViewport?.SelectedPanes; }
}
private BxlytHeader ActiveLayout;
private BxlanHeader ActiveAnimation;