mirror of
https://github.com/KillzXGaming/Switch-Toolbox
synced 2024-11-10 07:04:36 +00:00
Add more layout editor features
Add pane deleting via right clicking them. Added pane overlap select from right click (displays all panes at position of the mouse). Add option to hide and show all hidden panes from right click menu.
This commit is contained in:
parent
45a2466e86
commit
00ba993fa1
10 changed files with 222 additions and 4 deletions
|
@ -36,6 +36,7 @@ namespace BrawlboxHelper
|
||||||
{
|
{
|
||||||
CLR0Node clr0 = NodeFactory.FromFile(null, FileName) as CLR0Node;
|
CLR0Node clr0 = NodeFactory.FromFile(null, FileName) as CLR0Node;
|
||||||
|
|
||||||
|
|
||||||
ResU.ShaderParamAnim fshu = new ResU.ShaderParamAnim();
|
ResU.ShaderParamAnim fshu = new ResU.ShaderParamAnim();
|
||||||
fshu.FrameCount = clr0.FrameCount;
|
fshu.FrameCount = clr0.FrameCount;
|
||||||
fshu.Name = clr0.Name;
|
fshu.Name = clr0.Name;
|
||||||
|
@ -48,7 +49,10 @@ namespace BrawlboxHelper
|
||||||
|
|
||||||
//Set mat anims and then calculate data after
|
//Set mat anims and then calculate data after
|
||||||
foreach (var entry in clr0.Children)
|
foreach (var entry in clr0.Children)
|
||||||
fshu.ShaderParamMatAnims.Add(Clr0Entry2ShaderMatAnim(clr0, (CLR0MaterialNode)entry));
|
{
|
||||||
|
if (entry is CLR0MaterialNode)
|
||||||
|
fshu.ShaderParamMatAnims.Add(Clr0Entry2ShaderMatAnim(clr0, (CLR0MaterialNode)entry));
|
||||||
|
}
|
||||||
|
|
||||||
fshu.BakedSize = CalculateBakeSize(fshu);
|
fshu.BakedSize = CalculateBakeSize(fshu);
|
||||||
fshu.BindIndices = SetIndices(fshu);
|
fshu.BindIndices = SetIndices(fshu);
|
||||||
|
|
Binary file not shown.
Binary file not shown.
|
@ -1264,6 +1264,35 @@ namespace LayoutBXLYT
|
||||||
if (!PaneLookup.ContainsKey(pane.Name))
|
if (!PaneLookup.ContainsKey(pane.Name))
|
||||||
PaneLookup.Add(pane.Name, pane);
|
PaneLookup.Add(pane.Name, pane);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void AddPane(BasePane pane, BasePane parent)
|
||||||
|
{
|
||||||
|
if (parent == null) return;
|
||||||
|
|
||||||
|
if (!PaneLookup.ContainsKey(pane.Name))
|
||||||
|
PaneLookup.Add(pane.Name, pane);
|
||||||
|
|
||||||
|
parent.Childern.Add(pane);
|
||||||
|
parent.NodeWrapper.Nodes.Add(pane.NodeWrapper);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void RemovePanes(List<BasePane> panes)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < panes.Count; i++)
|
||||||
|
{
|
||||||
|
if (PaneLookup.ContainsKey(panes[i].Name))
|
||||||
|
PaneLookup.Remove(panes[i].Name);
|
||||||
|
|
||||||
|
if (panes[i].Parent == null)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
var parent = panes[i].Parent;
|
||||||
|
parent.Childern.Remove(panes[i]);
|
||||||
|
|
||||||
|
parent.NodeWrapper.Nodes.Remove(panes[i].NodeWrapper);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class BxlytMaterial
|
public class BxlytMaterial
|
||||||
|
|
|
@ -440,6 +440,11 @@ namespace LayoutBXLYT
|
||||||
dockContent.Show(dockPanel1, DockState.DockBottom);
|
dockContent.Show(dockPanel1, DockState.DockBottom);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void UpdateHiearchyTree()
|
||||||
|
{
|
||||||
|
LayoutHierarchy?.UpdateTree();
|
||||||
|
}
|
||||||
|
|
||||||
private void OnAnimationPlaying(object sender, EventArgs e)
|
private void OnAnimationPlaying(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
if (LayoutAnimEditor != null)
|
if (LayoutAnimEditor != null)
|
||||||
|
|
|
@ -83,6 +83,11 @@ namespace LayoutBXLYT
|
||||||
treeView1.Refresh();
|
treeView1.Refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void UpdateTree()
|
||||||
|
{
|
||||||
|
treeView1.Refresh();
|
||||||
|
}
|
||||||
|
|
||||||
public void Reset()
|
public void Reset()
|
||||||
{
|
{
|
||||||
treeView1.Nodes.Clear();
|
treeView1.Nodes.Clear();
|
||||||
|
|
|
@ -38,6 +38,58 @@ namespace LayoutBXLYT
|
||||||
IRevertAction Revert();
|
IRevertAction Revert();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class UndoActionPaneHide : IRevertAction
|
||||||
|
{
|
||||||
|
private bool hidePane = true;
|
||||||
|
public List<BasePane> targetPanes = new List<BasePane>();
|
||||||
|
public UndoActionPaneHide(List<BasePane> panes, bool hide = true)
|
||||||
|
{
|
||||||
|
targetPanes = panes;
|
||||||
|
hidePane = hide;
|
||||||
|
|
||||||
|
foreach (var pane in targetPanes)
|
||||||
|
pane.DisplayInEditor = !hidePane;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IRevertAction Revert()
|
||||||
|
{
|
||||||
|
foreach (var pane in targetPanes)
|
||||||
|
pane.DisplayInEditor = hidePane;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class UndoActionPaneDelete : IRevertAction
|
||||||
|
{
|
||||||
|
public BxlytHeader layoutFile;
|
||||||
|
public List<PaneInfo> targetPanes = new List<PaneInfo>();
|
||||||
|
public UndoActionPaneDelete(List<BasePane> panes, BxlytHeader header)
|
||||||
|
{
|
||||||
|
layoutFile = header;
|
||||||
|
for (int i = 0; i < panes.Count; i++)
|
||||||
|
targetPanes.Add(new PaneInfo(panes[i]));
|
||||||
|
}
|
||||||
|
|
||||||
|
public IRevertAction Revert()
|
||||||
|
{
|
||||||
|
for (int i = 0; i < targetPanes.Count; i++)
|
||||||
|
layoutFile.AddPane(targetPanes[i].Pane, targetPanes[i].Parent);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public class PaneInfo
|
||||||
|
{
|
||||||
|
public BasePane Parent;
|
||||||
|
public BasePane Pane;
|
||||||
|
|
||||||
|
public PaneInfo(BasePane pane)
|
||||||
|
{
|
||||||
|
Pane = pane;
|
||||||
|
Parent = pane.Parent;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public class UndoActionTransform : IRevertAction
|
public class UndoActionTransform : IRevertAction
|
||||||
{
|
{
|
||||||
public Vector3F Translate;
|
public Vector3F Translate;
|
||||||
|
|
|
@ -28,7 +28,9 @@
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private void InitializeComponent()
|
private void InitializeComponent()
|
||||||
{
|
{
|
||||||
|
this.components = new System.ComponentModel.Container();
|
||||||
this.glControl1 = new OpenTK.GLControl();
|
this.glControl1 = new OpenTK.GLControl();
|
||||||
|
this.stContextMenuStrip1 = new Toolbox.Library.Forms.STContextMenuStrip(this.components);
|
||||||
this.SuspendLayout();
|
this.SuspendLayout();
|
||||||
//
|
//
|
||||||
// glControl1
|
// glControl1
|
||||||
|
@ -48,6 +50,11 @@
|
||||||
this.glControl1.MouseUp += new System.Windows.Forms.MouseEventHandler(this.glControl1_MouseUp);
|
this.glControl1.MouseUp += new System.Windows.Forms.MouseEventHandler(this.glControl1_MouseUp);
|
||||||
this.glControl1.Resize += new System.EventHandler(this.glControl1_Resize);
|
this.glControl1.Resize += new System.EventHandler(this.glControl1_Resize);
|
||||||
//
|
//
|
||||||
|
// stContextMenuStrip1
|
||||||
|
//
|
||||||
|
this.stContextMenuStrip1.Name = "stContextMenuStrip1";
|
||||||
|
this.stContextMenuStrip1.Size = new System.Drawing.Size(61, 4);
|
||||||
|
//
|
||||||
// LayoutViewer
|
// LayoutViewer
|
||||||
//
|
//
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||||
|
@ -62,5 +69,6 @@
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
private OpenTK.GLControl glControl1;
|
private OpenTK.GLControl glControl1;
|
||||||
|
private Toolbox.Library.Forms.STContextMenuStrip stContextMenuStrip1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,6 +9,7 @@ using System.Threading.Tasks;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
using OpenTK.Graphics.OpenGL;
|
using OpenTK.Graphics.OpenGL;
|
||||||
using OpenTK;
|
using OpenTK;
|
||||||
|
using Toolbox.Library.Forms;
|
||||||
using Toolbox.Library;
|
using Toolbox.Library;
|
||||||
using Toolbox.Library.Rendering;
|
using Toolbox.Library.Rendering;
|
||||||
using Toolbox.Library.IO;
|
using Toolbox.Library.IO;
|
||||||
|
@ -716,19 +717,103 @@ namespace LayoutBXLYT
|
||||||
ParentEditor.UpdateHiearchyNodeSelection(hitPane);
|
ParentEditor.UpdateHiearchyNodeSelection(hitPane);
|
||||||
|
|
||||||
isPicked = true;
|
isPicked = true;
|
||||||
}
|
} //Check edge hit and control key (multi selecting panes)
|
||||||
else if (!hasEdgeHit)
|
else if (!hasEdgeHit && Control.ModifierKeys != Keys.Control)
|
||||||
SelectedPanes.Clear();
|
SelectedPanes.Clear();
|
||||||
|
|
||||||
pickOriginMouse = e.Location;
|
pickOriginMouse = e.Location;
|
||||||
|
|
||||||
RenderScene();
|
RenderScene();
|
||||||
}
|
}
|
||||||
|
else if (e.Button == MouseButtons.Right)
|
||||||
|
{
|
||||||
|
RenderEditor();
|
||||||
|
var coords = convertScreenToWorldCoords(e.Location.X, e.Location.Y);
|
||||||
|
|
||||||
|
GL.PopMatrix();
|
||||||
|
|
||||||
|
//Add a content menu
|
||||||
|
var selectOverlapping = new STToolStripItem("Select Overlapping");
|
||||||
|
var createPanes = new STToolStripItem("Create Pane");
|
||||||
|
createPanes.DropDownItems.Add(new STToolStripItem("Null Pane"));
|
||||||
|
createPanes.DropDownItems.Add(new STToolStripItem("Picture Pane"));
|
||||||
|
createPanes.DropDownItems.Add(new STToolStripItem("Text Box Pane "));
|
||||||
|
createPanes.DropDownItems.Add(new STToolStripItem("Window Pane"));
|
||||||
|
createPanes.DropDownItems.Add(new STToolStripItem("Boundry Pane"));
|
||||||
|
|
||||||
|
var hitPanes = GetHitPanes(LayoutFile.RootPane, coords.X, coords.Y, new List<BasePane>());
|
||||||
|
for (int i = 0; i < hitPanes.Count; i++)
|
||||||
|
selectOverlapping.DropDownItems.Add(
|
||||||
|
new STToolStripItem(hitPanes[i].Name, SelectOverlappingAction));
|
||||||
|
|
||||||
|
stContextMenuStrip1.Items.Clear();
|
||||||
|
stContextMenuStrip1.Items.Add(createPanes);
|
||||||
|
stContextMenuStrip1.Items.Add(selectOverlapping);
|
||||||
|
|
||||||
|
if (SelectedPanes.Count > 0)
|
||||||
|
{
|
||||||
|
stContextMenuStrip1.Items.Add(new STToolStripSeparator());
|
||||||
|
stContextMenuStrip1.Items.Add(new STToolStripItem("Edit Group"));
|
||||||
|
stContextMenuStrip1.Items.Add(new STToolStripItem("Delete Selected Panes",DeletePaneAction ));
|
||||||
|
stContextMenuStrip1.Items.Add(new STToolStripItem("Hide Selected Panes", HidePaneAction));
|
||||||
|
stContextMenuStrip1.Items.Add(new STToolStripItem("Show All Hidden Panes", ShowAllPaneAction));
|
||||||
|
}
|
||||||
|
|
||||||
|
stContextMenuStrip1.Show(Cursor.Position);
|
||||||
|
}
|
||||||
|
|
||||||
Console.WriteLine("SelectedPanes " + SelectedPanes.Count);
|
Console.WriteLine("SelectedPanes " + SelectedPanes.Count);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void DeletePaneAction(object sender, EventArgs e) {
|
||||||
|
DeleteSelectedPanes();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void HidePaneAction(object sender, EventArgs e) {
|
||||||
|
HideSelectedPanes();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ShowAllPaneAction(object sender, EventArgs e) {
|
||||||
|
ShowHiddenPanes();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void HideSelectedPanes()
|
||||||
|
{
|
||||||
|
UndoManger.AddToUndo(new LayoutUndoManager.UndoActionPaneHide(SelectedPanes));
|
||||||
|
ParentEditor?.UpdateHiearchyTree();
|
||||||
|
glControl1.Invalidate();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ShowHiddenPanes()
|
||||||
|
{
|
||||||
|
UndoManger.AddToUndo(new LayoutUndoManager.UndoActionPaneHide(LayoutFile.PaneLookup.Values.ToList(), false));
|
||||||
|
ParentEditor?.UpdateHiearchyTree();
|
||||||
|
glControl1.Invalidate();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void DeleteSelectedPanes()
|
||||||
|
{
|
||||||
|
UndoManger.AddToUndo(new LayoutUndoManager.UndoActionPaneDelete(SelectedPanes, LayoutFile));
|
||||||
|
LayoutFile.RemovePanes(SelectedPanes);
|
||||||
|
ParentEditor?.UpdateHiearchyTree();
|
||||||
|
glControl1.Invalidate();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void SelectOverlappingAction(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
var toolMenu = sender as STToolStripItem;
|
||||||
|
if (toolMenu != null)
|
||||||
|
{
|
||||||
|
string name = toolMenu.Text;
|
||||||
|
SelectedPanes.Clear();
|
||||||
|
|
||||||
|
if (LayoutFile.PaneLookup.ContainsKey(name))
|
||||||
|
SelectedPanes.Add(LayoutFile.PaneLookup[name]);
|
||||||
|
|
||||||
|
glControl1.Invalidate();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void SearchHit(BasePane pane, int X, int Y, ref BasePane SelectedPane)
|
private void SearchHit(BasePane pane, int X, int Y, ref BasePane SelectedPane)
|
||||||
{
|
{
|
||||||
bool isVisible = pane.Visible;
|
bool isVisible = pane.Visible;
|
||||||
|
@ -750,6 +835,29 @@ namespace LayoutBXLYT
|
||||||
SearchHit(childPane, X, Y, ref SelectedPane);
|
SearchHit(childPane, X, Y, ref SelectedPane);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private List<BasePane> GetHitPanes(BasePane pane, int X, int Y, List<BasePane> SelectedPanes)
|
||||||
|
{
|
||||||
|
bool isVisible = pane.Visible;
|
||||||
|
if (!Runtime.LayoutEditor.DisplayPicturePane && pane is IPicturePane)
|
||||||
|
isVisible = false;
|
||||||
|
if (!Runtime.LayoutEditor.DisplayWindowPane && pane is IWindowPane)
|
||||||
|
isVisible = false;
|
||||||
|
if (!Runtime.LayoutEditor.DisplayBoundryPane && pane is IBoundryPane)
|
||||||
|
isVisible = false;
|
||||||
|
if (!Runtime.LayoutEditor.DisplayTextPane && pane is ITextPane)
|
||||||
|
isVisible = false;
|
||||||
|
if (!Runtime.LayoutEditor.DisplayNullPane && pane.IsNullPane)
|
||||||
|
isVisible = false;
|
||||||
|
|
||||||
|
if (isVisible && pane.DisplayInEditor && pane.IsHit(X, Y) && pane.Name != "RootPane")
|
||||||
|
SelectedPanes.Add(pane);
|
||||||
|
|
||||||
|
foreach (var childPane in pane.Childern)
|
||||||
|
SelectedPanes = GetHitPanes(childPane, X, Y, SelectedPanes);
|
||||||
|
|
||||||
|
return SelectedPanes;
|
||||||
|
}
|
||||||
|
|
||||||
private PickAction SearchEdgePicking(BasePane pane, int X, int Y)
|
private PickAction SearchEdgePicking(BasePane pane, int X, int Y)
|
||||||
{
|
{
|
||||||
var transformed = pane.CreateRectangle().GetTransformedRectangle(pane.Parent, pane.Translate, pane.Scale);
|
var transformed = pane.CreateRectangle().GetTransformedRectangle(pane.Parent, pane.Translate, pane.Scale);
|
||||||
|
@ -1023,6 +1131,10 @@ namespace LayoutBXLYT
|
||||||
ParentEditor.UpdateUndo();
|
ParentEditor.UpdateUndo();
|
||||||
glControl1.Invalidate();
|
glControl1.Invalidate();
|
||||||
}
|
}
|
||||||
|
else if (e.KeyCode == Keys.Delete)
|
||||||
|
{
|
||||||
|
DeleteSelectedPanes();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -117,4 +117,7 @@
|
||||||
<resheader name="writer">
|
<resheader name="writer">
|
||||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
</resheader>
|
</resheader>
|
||||||
|
<metadata name="stContextMenuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||||
|
<value>17, 17</value>
|
||||||
|
</metadata>
|
||||||
</root>
|
</root>
|
Loading…
Reference in a new issue