From e1fd6641128cb2c335e23bd28d331bae9aa166f0 Mon Sep 17 00:00:00 2001 From: KillzXGaming Date: Wed, 16 Oct 2019 20:15:36 -0400 Subject: [PATCH] Few more additions Start to impliment a muunt editor. This plans to use the 2D engine i've been using with layouts mixed with 3d to fully edit object and path placements. Start to add pane copying. Brlyt improvements with window pane support. Add bflyt texture combiner UI. --- .../BFRES/Bfres Structs/SubFiles/FTEX.cs | 2 + .../FileFormats/Layout/BxlytToGL.cs | 10 + .../FileFormats/Layout/CAFE/BFLAN.cs | 3 +- .../FileFormats/Layout/CAFE/BFLYT.cs | 67 +------ .../FileFormats/Layout/Common.cs | 59 ++++++ .../FileFormats/Layout/Rev/BRLYT.cs | 49 +++-- .../File_Format_Library.csproj | 19 ++ .../PaneMatTextureCombiner.Designer.cs | 109 ++++++++++- .../Materials/PaneMatTextureCombiner.cs | 51 ++++++ .../Materials/PaneMatTextureCombiner.resx | 120 ++++++++++++ File_Format_Library/GUI/BFLYT/LayoutEditor.cs | 16 +- File_Format_Library/GUI/BFLYT/LayoutViewer.cs | 49 ++++- .../CourseMuunt2D/MuuntEditor.Designer.cs | 171 ++++++++++++++++++ .../GUI/Byaml/CourseMuunt2D/MuuntEditor.cs | 22 +++ .../GUI/Byaml/CourseMuunt2D/MuuntEditor.resx | 126 +++++++++++++ .../Byaml/CourseMuunt2D/MuuntEditorDocker.cs | 13 ++ .../GUI/Byaml/CourseMuunt2D/TrackEditor2D.cs | 17 ++ .../Generics/Texture/GenericTexture.cs | 2 + .../IO/Extensions/StringExtension.cs | 8 +- Switch_Toolbox_Library/Util/Util.cs | 9 +- 20 files changed, 837 insertions(+), 85 deletions(-) create mode 100644 File_Format_Library/GUI/BFLYT/Editor/Materials/PaneMatTextureCombiner.resx create mode 100644 File_Format_Library/GUI/Byaml/CourseMuunt2D/MuuntEditor.Designer.cs create mode 100644 File_Format_Library/GUI/Byaml/CourseMuunt2D/MuuntEditor.cs create mode 100644 File_Format_Library/GUI/Byaml/CourseMuunt2D/MuuntEditor.resx create mode 100644 File_Format_Library/GUI/Byaml/CourseMuunt2D/MuuntEditorDocker.cs create mode 100644 File_Format_Library/GUI/Byaml/CourseMuunt2D/TrackEditor2D.cs diff --git a/File_Format_Library/FileFormats/BFRES/Bfres Structs/SubFiles/FTEX.cs b/File_Format_Library/FileFormats/BFRES/Bfres Structs/SubFiles/FTEX.cs index e735e2bf..aa1c8075 100644 --- a/File_Format_Library/FileFormats/BFRES/Bfres Structs/SubFiles/FTEX.cs +++ b/File_Format_Library/FileFormats/BFRES/Bfres Structs/SubFiles/FTEX.cs @@ -634,6 +634,8 @@ namespace Bfres.Structs case TEX_FORMAT.R32G32B32A32_SINT: return GX2SurfaceFormat.TC_R32_G32_B32_A32_SInt; case TEX_FORMAT.L8: return GX2SurfaceFormat.TC_R8_UNorm; case TEX_FORMAT.LA8: return GX2SurfaceFormat.TC_R8_G8_UNorm; + case TEX_FORMAT.RGB565: return GX2SurfaceFormat.TCS_R5_G6_B5_UNorm; + case TEX_FORMAT.R5G5B5_UNORM: return GX2SurfaceFormat.TC_R5_G5_B5_A1_UNorm; default: throw new Exception($"Cannot convert format {texFormat}"); } diff --git a/File_Format_Library/FileFormats/Layout/BxlytToGL.cs b/File_Format_Library/FileFormats/Layout/BxlytToGL.cs index c2c85746..3b8909dd 100644 --- a/File_Format_Library/FileFormats/Layout/BxlytToGL.cs +++ b/File_Format_Library/FileFormats/Layout/BxlytToGL.cs @@ -1089,6 +1089,16 @@ namespace LayoutBXLYT mat.Shader = new BflytShader((Cafe.BFLYT.Material)mat); mat.Shader.Compile(); } + else if (mat is BRLYT.Material) + { + mat.Shader = new BrlytShader((BRLYT.Material)mat); + mat.Shader.Compile(); + } + else if (mat is BCLYT.Material) + { + mat.Shader = new BclytShader((BCLYT.Material)mat); + mat.Shader.Compile(); + } } mat.Shader.Enable(); diff --git a/File_Format_Library/FileFormats/Layout/CAFE/BFLAN.cs b/File_Format_Library/FileFormats/Layout/CAFE/BFLAN.cs index 33e50dd0..f0be3fba 100644 --- a/File_Format_Library/FileFormats/Layout/CAFE/BFLAN.cs +++ b/File_Format_Library/FileFormats/Layout/CAFE/BFLAN.cs @@ -199,6 +199,7 @@ namespace LayoutBXLYT public class PAT1 : BxlanPAT1 { private byte[] UnknownData; + private byte flags; public PAT1() @@ -267,8 +268,6 @@ namespace LayoutBXLYT public class PAI1 : BxlanPAI1 { - - public PAI1() { Textures = new List(); diff --git a/File_Format_Library/FileFormats/Layout/CAFE/BFLYT.cs b/File_Format_Library/FileFormats/Layout/CAFE/BFLYT.cs index c755ff6e..880ef4d8 100644 --- a/File_Format_Library/FileFormats/Layout/CAFE/BFLYT.cs +++ b/File_Format_Library/FileFormats/Layout/CAFE/BFLYT.cs @@ -1154,7 +1154,7 @@ namespace LayoutBXLYT.Cafe LoadDefaults(); Name = name; - Content = new WindowContent(header, this.Name); + Content = new BxlytWindowContent(header, this.Name); UseOneMaterialForAll = true; UseVertexColorForAll = true; WindowKind = WindowKind.Around; @@ -1368,7 +1368,7 @@ namespace LayoutBXLYT.Cafe WindowKind = (WindowKind)((_flag >> 2) & 3); reader.SeekBegin(pos + contentOffset); - Content = new WindowContent(reader, header); + Content = new BxlytWindowContent(reader, header); reader.SeekBegin(pos + frameOffsetTbl); @@ -1402,7 +1402,7 @@ namespace LayoutBXLYT.Cafe writer.Write(0); writer.WriteUint32Offset(_ofsContentPos, pos); - ((WindowContent)Content).Write(writer); + Content.Write(writer); if (WindowFrames.Count > 0) { @@ -1417,67 +1417,6 @@ namespace LayoutBXLYT.Cafe } } } - - public class WindowContent : BxlytWindowContent - { - private Header LayoutFile; - - public WindowContent(Header header, string name) { - LayoutFile = header; - ColorTopLeft = STColor8.White; - ColorTopRight = STColor8.White; - ColorBottomLeft = STColor8.White; - ColorBottomRight = STColor8.White; - - TexCoords.Add(new TexCoord()); - - //Add new material - Material = new Material($"{name}_C", header); - MaterialIndex = (ushort)header.AddMaterial(Material); - } - - public WindowContent(FileReader reader, Header header) - { - LayoutFile = header; - - ColorTopLeft = reader.ReadColor8RGBA(); - ColorTopRight = reader.ReadColor8RGBA(); - ColorBottomLeft = reader.ReadColor8RGBA(); - ColorBottomRight = reader.ReadColor8RGBA(); - MaterialIndex = reader.ReadUInt16(); - byte UVCount = reader.ReadByte(); - reader.ReadByte(); //padding - - for (int i = 0; i < UVCount; i++) - TexCoords.Add(new TexCoord() - { - TopLeft = reader.ReadVec2SY(), - TopRight = reader.ReadVec2SY(), - BottomLeft = reader.ReadVec2SY(), - BottomRight = reader.ReadVec2SY(), - }); - - Material = LayoutFile.MaterialList.Materials[MaterialIndex]; - } - - public void Write(FileWriter writer) - { - writer.Write(ColorTopLeft); - writer.Write(ColorTopRight); - writer.Write(ColorBottomLeft); - writer.Write(ColorBottomRight); - writer.Write(MaterialIndex); - writer.Write((byte)TexCoords.Count); - writer.Write((byte)0); - foreach (var texCoord in TexCoords) - { - writer.Write(texCoord.TopLeft); - writer.Write(texCoord.TopRight); - writer.Write(texCoord.BottomLeft); - writer.Write(texCoord.BottomRight); - } - } - } } public class ALI1 : PAN1 diff --git a/File_Format_Library/FileFormats/Layout/Common.cs b/File_Format_Library/FileFormats/Layout/Common.cs index cf509820..119f8fab 100644 --- a/File_Format_Library/FileFormats/Layout/Common.cs +++ b/File_Format_Library/FileFormats/Layout/Common.cs @@ -1118,6 +1118,65 @@ namespace LayoutBXLYT public virtual BxlytMaterial Material { get; set; } public List TexCoords = new List(); + + private BxlytHeader LayoutFile; + + public BxlytWindowContent(BxlytHeader header, string name) + { + LayoutFile = header; + ColorTopLeft = STColor8.White; + ColorTopRight = STColor8.White; + ColorBottomLeft = STColor8.White; + ColorBottomRight = STColor8.White; + + TexCoords.Add(new TexCoord()); + + //Add new material + Material = header.CreateNewMaterial($"{name}_C"); + MaterialIndex = (ushort)header.AddMaterial(Material); + } + + public BxlytWindowContent(FileReader reader, BxlytHeader header) + { + LayoutFile = header; + + ColorTopLeft = reader.ReadColor8RGBA(); + ColorTopRight = reader.ReadColor8RGBA(); + ColorBottomLeft = reader.ReadColor8RGBA(); + ColorBottomRight = reader.ReadColor8RGBA(); + MaterialIndex = reader.ReadUInt16(); + byte UVCount = reader.ReadByte(); + reader.ReadByte(); //padding + + for (int i = 0; i < UVCount; i++) + TexCoords.Add(new TexCoord() + { + TopLeft = reader.ReadVec2SY(), + TopRight = reader.ReadVec2SY(), + BottomLeft = reader.ReadVec2SY(), + BottomRight = reader.ReadVec2SY(), + }); + + Material = LayoutFile.GetMaterial(MaterialIndex); + } + + public void Write(FileWriter writer) + { + writer.Write(ColorTopLeft); + writer.Write(ColorTopRight); + writer.Write(ColorBottomLeft); + writer.Write(ColorBottomRight); + writer.Write(MaterialIndex); + writer.Write((byte)TexCoords.Count); + writer.Write((byte)0); + foreach (var texCoord in TexCoords) + { + writer.Write(texCoord.TopLeft); + writer.Write(texCoord.TopRight); + writer.Write(texCoord.BottomLeft); + writer.Write(texCoord.BottomRight); + } + } } public class BxlytWindowFrame diff --git a/File_Format_Library/FileFormats/Layout/Rev/BRLYT.cs b/File_Format_Library/FileFormats/Layout/Rev/BRLYT.cs index 398e24a9..e68b8f5f 100644 --- a/File_Format_Library/FileFormats/Layout/Rev/BRLYT.cs +++ b/File_Format_Library/FileFormats/Layout/Rev/BRLYT.cs @@ -194,6 +194,10 @@ namespace LayoutBXLYT return panes; } + public override BxlytMaterial GetMaterial(ushort index) { + return MaterialList.Materials[index]; + } + public override List GetMaterials() { List materials = new List(); @@ -328,7 +332,7 @@ namespace LayoutBXLYT currentPane = partsPanel; break; case "wnd1": - var windowPanel = new WND1(reader); + var windowPanel = new WND1(this, reader); AddPaneToTable(windowPanel); SetPane(windowPanel, parentPane); @@ -678,7 +682,7 @@ namespace LayoutBXLYT LoadDefaults(); Name = name; - Content = new WindowContent(header, this.Name); + Content = new BxlytWindowContent(header, this.Name); UseOneMaterialForAll = true; UseVertexColorForAll = true; WindowKind = WindowKind.Around; @@ -702,9 +706,40 @@ namespace LayoutBXLYT SetFrames(header); } - public WND1(FileReader reader) : base(reader) + public WND1(Header header, FileReader reader) : base(reader) { + layoutHeader = header; + WindowFrames = new List(); + long pos = reader.Position - 0x4C; + + StretchLeft = reader.ReadUInt16(); + StretchRight = reader.ReadUInt16(); + StretchTop = reader.ReadUInt16(); + StretchBottm = reader.ReadUInt16(); + FrameElementLeft = reader.ReadUInt16(); + FrameElementRight = reader.ReadUInt16(); + FrameElementTop = reader.ReadUInt16(); + FrameElementBottm = reader.ReadUInt16(); + FrameCount = reader.ReadByte(); + _flag = reader.ReadByte(); + reader.ReadUInt16();//padding + uint contentOffset = reader.ReadUInt32(); + uint frameOffsetTbl = reader.ReadUInt32(); + + WindowKind = (WindowKind)((_flag >> 2) & 3); + + reader.SeekBegin(pos + contentOffset); + Content = new BxlytWindowContent(reader, header); + + reader.SeekBegin(pos + frameOffsetTbl); + + var offsets = reader.ReadUInt32s(FrameCount); + foreach (int offset in offsets) + { + reader.SeekBegin(pos + offset); + WindowFrames.Add(new BxlytWindowFrame(reader, header)); + } } public override void Write(FileWriter writer, LayoutHeader header) @@ -713,14 +748,6 @@ namespace LayoutBXLYT } } - public class WindowContent : BxlytWindowContent - { - public WindowContent(Header header, string name) - { - - } - } - public class BND1 : PAN1, IBoundryPane { public BND1() : base() diff --git a/File_Format_Library/File_Format_Library.csproj b/File_Format_Library/File_Format_Library.csproj index 919fadcf..d680e6e5 100644 --- a/File_Format_Library/File_Format_Library.csproj +++ b/File_Format_Library/File_Format_Library.csproj @@ -648,6 +648,16 @@ SmoothNormalsMultiMeshForm.cs + + Form + + + MuuntEditor.cs + + + Form + + UserControl @@ -1353,6 +1363,9 @@ PaneMatBlending.cs + + PaneMatTextureCombiner.cs + PaneEditor.cs @@ -1587,6 +1600,9 @@ BotwActorEditorControl.cs + + MuuntEditor.cs + TurboMunntEditor.cs @@ -1822,5 +1838,8 @@ + + + \ No newline at end of file diff --git a/File_Format_Library/GUI/BFLYT/Editor/Materials/PaneMatTextureCombiner.Designer.cs b/File_Format_Library/GUI/BFLYT/Editor/Materials/PaneMatTextureCombiner.Designer.cs index f7e328d2..e1bd5ec3 100644 --- a/File_Format_Library/GUI/BFLYT/Editor/Materials/PaneMatTextureCombiner.Designer.cs +++ b/File_Format_Library/GUI/BFLYT/Editor/Materials/PaneMatTextureCombiner.Designer.cs @@ -28,10 +28,117 @@ /// private void InitializeComponent() { - components = new System.ComponentModel.Container(); + this.tevStageCB = new Toolbox.Library.Forms.STComboBox(); + this.stLabel1 = new Toolbox.Library.Forms.STLabel(); + this.tevColorModeCB = new Toolbox.Library.Forms.STComboBox(); + this.stLabel2 = new Toolbox.Library.Forms.STLabel(); + this.stLabel3 = new Toolbox.Library.Forms.STLabel(); + this.tevAlphaModeCB = new Toolbox.Library.Forms.STComboBox(); + this.tevBasicPanel = new Toolbox.Library.Forms.STPanel(); + this.tevBasicPanel.SuspendLayout(); + this.SuspendLayout(); + // + // tevStageCB + // + this.tevStageCB.BorderColor = System.Drawing.Color.Empty; + this.tevStageCB.BorderStyle = System.Windows.Forms.ButtonBorderStyle.Solid; + this.tevStageCB.ButtonColor = System.Drawing.Color.Empty; + this.tevStageCB.FormattingEnabled = true; + this.tevStageCB.IsReadOnly = false; + this.tevStageCB.Location = new System.Drawing.Point(53, 17); + this.tevStageCB.Name = "tevStageCB"; + this.tevStageCB.Size = new System.Drawing.Size(155, 21); + this.tevStageCB.TabIndex = 1; + this.tevStageCB.SelectedIndexChanged += new System.EventHandler(this.tevStageCB_SelectedIndexChanged); + // + // stLabel1 + // + this.stLabel1.AutoSize = true; + this.stLabel1.Location = new System.Drawing.Point(4, 20); + this.stLabel1.Name = "stLabel1"; + this.stLabel1.Size = new System.Drawing.Size(43, 13); + this.stLabel1.TabIndex = 2; + this.stLabel1.Text = "Stages:"; + // + // tevColorModeCB + // + this.tevColorModeCB.BorderColor = System.Drawing.Color.Empty; + this.tevColorModeCB.BorderStyle = System.Windows.Forms.ButtonBorderStyle.Solid; + this.tevColorModeCB.ButtonColor = System.Drawing.Color.Empty; + this.tevColorModeCB.FormattingEnabled = true; + this.tevColorModeCB.IsReadOnly = false; + this.tevColorModeCB.Location = new System.Drawing.Point(6, 60); + this.tevColorModeCB.Name = "tevColorModeCB"; + this.tevColorModeCB.Size = new System.Drawing.Size(155, 21); + this.tevColorModeCB.TabIndex = 3; + this.tevColorModeCB.SelectedIndexChanged += new System.EventHandler(this.tevColorModeCB_SelectedIndexChanged); + // + // stLabel2 + // + this.stLabel2.AutoSize = true; + this.stLabel2.Location = new System.Drawing.Point(3, 33); + this.stLabel2.Name = "stLabel2"; + this.stLabel2.Size = new System.Drawing.Size(78, 13); + this.stLabel2.TabIndex = 4; + this.stLabel2.Text = "Color Blending:"; + // + // stLabel3 + // + this.stLabel3.AutoSize = true; + this.stLabel3.Location = new System.Drawing.Point(3, 110); + this.stLabel3.Name = "stLabel3"; + this.stLabel3.Size = new System.Drawing.Size(81, 13); + this.stLabel3.TabIndex = 6; + this.stLabel3.Text = "Alpha Blending:"; + // + // tevAlphaModeCB + // + this.tevAlphaModeCB.BorderColor = System.Drawing.Color.Empty; + this.tevAlphaModeCB.BorderStyle = System.Windows.Forms.ButtonBorderStyle.Solid; + this.tevAlphaModeCB.ButtonColor = System.Drawing.Color.Empty; + this.tevAlphaModeCB.FormattingEnabled = true; + this.tevAlphaModeCB.IsReadOnly = false; + this.tevAlphaModeCB.Location = new System.Drawing.Point(6, 137); + this.tevAlphaModeCB.Name = "tevAlphaModeCB"; + this.tevAlphaModeCB.Size = new System.Drawing.Size(155, 21); + this.tevAlphaModeCB.TabIndex = 5; + this.tevAlphaModeCB.SelectedIndexChanged += new System.EventHandler(this.tevAlphaModeCB_SelectedIndexChanged); + // + // tevBasicPanel + // + this.tevBasicPanel.Controls.Add(this.stLabel2); + this.tevBasicPanel.Controls.Add(this.stLabel3); + this.tevBasicPanel.Controls.Add(this.tevColorModeCB); + this.tevBasicPanel.Controls.Add(this.tevAlphaModeCB); + this.tevBasicPanel.Location = new System.Drawing.Point(3, 44); + this.tevBasicPanel.Name = "tevBasicPanel"; + this.tevBasicPanel.Size = new System.Drawing.Size(299, 265); + this.tevBasicPanel.TabIndex = 7; + // + // PaneMatTextureCombiner + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.Controls.Add(this.tevBasicPanel); + this.Controls.Add(this.stLabel1); + this.Controls.Add(this.tevStageCB); + this.Name = "PaneMatTextureCombiner"; + this.Size = new System.Drawing.Size(305, 312); + this.tevBasicPanel.ResumeLayout(false); + this.tevBasicPanel.PerformLayout(); + this.ResumeLayout(false); + this.PerformLayout(); + } #endregion + + private Toolbox.Library.Forms.STComboBox tevStageCB; + private Toolbox.Library.Forms.STLabel stLabel1; + private Toolbox.Library.Forms.STComboBox tevColorModeCB; + private Toolbox.Library.Forms.STLabel stLabel2; + private Toolbox.Library.Forms.STLabel stLabel3; + private Toolbox.Library.Forms.STComboBox tevAlphaModeCB; + private Toolbox.Library.Forms.STPanel tevBasicPanel; } } diff --git a/File_Format_Library/GUI/BFLYT/Editor/Materials/PaneMatTextureCombiner.cs b/File_Format_Library/GUI/BFLYT/Editor/Materials/PaneMatTextureCombiner.cs index 22035272..c18ee27f 100644 --- a/File_Format_Library/GUI/BFLYT/Editor/Materials/PaneMatTextureCombiner.cs +++ b/File_Format_Library/GUI/BFLYT/Editor/Materials/PaneMatTextureCombiner.cs @@ -14,6 +14,7 @@ namespace LayoutBXLYT { private PaneEditor ParentEditor; private BxlytMaterial ActiveMaterial; + private bool loaded = false; public PaneMatTextureCombiner() { @@ -24,6 +25,56 @@ namespace LayoutBXLYT { ActiveMaterial = material; ParentEditor = paneEditor; + + tevStageCB.Items.Clear(); + tevColorModeCB.ResetBind(); + tevAlphaModeCB.ResetBind(); + + if (material.TevStages?.Length > 0) + { + tevBasicPanel.Show(); + + for (int i = 0; i < material.TevStages.Length; i++) + tevStageCB.Items.Add($"Stage [{i}]"); + + tevStageCB.SelectedIndex = 0; + } + else + { + tevBasicPanel.Hide(); + } + } + + private void tevStageCB_SelectedIndexChanged(object sender, EventArgs e) + { + if (tevStageCB.SelectedIndex >= 0) + { + int index = tevStageCB.SelectedIndex; + var tevStage = ActiveMaterial.TevStages[index]; + tevColorModeCB.Bind(typeof(TevMode), tevStage, "ColorMode"); + tevAlphaModeCB.Bind(typeof(TevMode), tevStage, "AlphaMode"); + tevColorModeCB.SelectedItem = tevStage.ColorMode; + tevAlphaModeCB.SelectedItem = tevStage.AlphaMode; + } + } + + private void tevColorModeCB_SelectedIndexChanged(object sender, EventArgs e) { + UpdateTevStage(); + } + + private void tevAlphaModeCB_SelectedIndexChanged(object sender, EventArgs e) { + UpdateTevStage(); + } + + private void UpdateTevStage() + { + if (!loaded || tevStageCB.SelectedIndex < 0) return; + + int index = tevStageCB.SelectedIndex; + var tevStage = ActiveMaterial.TevStages[index]; + + tevStage.ColorMode = (TevMode)tevColorModeCB.SelectedItem; + tevStage.AlphaMode = (TevMode)tevColorModeCB.SelectedItem; } } } diff --git a/File_Format_Library/GUI/BFLYT/Editor/Materials/PaneMatTextureCombiner.resx b/File_Format_Library/GUI/BFLYT/Editor/Materials/PaneMatTextureCombiner.resx new file mode 100644 index 00000000..1af7de15 --- /dev/null +++ b/File_Format_Library/GUI/BFLYT/Editor/Materials/PaneMatTextureCombiner.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/File_Format_Library/GUI/BFLYT/LayoutEditor.cs b/File_Format_Library/GUI/BFLYT/LayoutEditor.cs index ad8c2057..74b2b6e9 100644 --- a/File_Format_Library/GUI/BFLYT/LayoutEditor.cs +++ b/File_Format_Library/GUI/BFLYT/LayoutEditor.cs @@ -1067,6 +1067,18 @@ namespace LayoutBXLYT return pane; } + public void AddNewPastedPane(BasePane pane) + { + string name = pane.Name; + string numberedEnd = pane.Name.Split('_').LastOrDefault().Replace("_", string.Empty); + if (numberedEnd.All(char.IsDigit)) + name = name.Replace(numberedEnd, string.Empty); + + pane.Name = RenamePane(name); + pane.NodeWrapper = LayoutHierarchy.CreatePaneWrapper(pane); + ActiveLayout.AddPane(pane, pane.Parent); + } + public BasePane AddNewNullPane() { BasePane pane = null; @@ -1084,8 +1096,8 @@ namespace LayoutBXLYT private string RenamePane(string name) { - List names = ActiveLayout.PaneLookup.Values.ToList().Select(o => o.Name).ToList(); - return Utils.RenameDuplicateString(names, name); ; + List names = ActiveLayout.PaneLookup.Keys.ToList(); + return Utils.RenameDuplicateString(names, name, 0, 2); } #endregion diff --git a/File_Format_Library/GUI/BFLYT/LayoutViewer.cs b/File_Format_Library/GUI/BFLYT/LayoutViewer.cs index 78d2794e..d2c1dda2 100644 --- a/File_Format_Library/GUI/BFLYT/LayoutViewer.cs +++ b/File_Format_Library/GUI/BFLYT/LayoutViewer.cs @@ -34,6 +34,8 @@ namespace LayoutBXLYT private LayoutEditor ParentEditor; + private List CopiedPanes = new List(); + private RenderableTex backgroundTex; public BxlytHeader LayoutFile; public List LayoutFiles = new List(); @@ -840,7 +842,6 @@ namespace LayoutBXLYT createPanes.DropDownItems.Add(new STToolStripItem("Text Box Pane", CreateTextPaneAction)); createPanes.DropDownItems.Add(new STToolStripItem("Window Pane", CreateWindowPaneAction)); createPanes.DropDownItems.Add(new STToolStripItem("Boundry Pane", CreateBoundryPaneAction)); - var hitPanes = GetHitPanes(LayoutFile.RootPane, coords.X, coords.Y, new List()); for (int i = 0; i < hitPanes.Count; i++) selectOverlapping.DropDownItems.Add( @@ -853,6 +854,8 @@ namespace LayoutBXLYT if (SelectedPanes.Count > 0) { stContextMenuStrip1.Items.Add(new STToolStripSeparator()); + stContextMenuStrip1.Items.Add(new STToolStripItem("Copy", CopyPaneAction)); + stContextMenuStrip1.Items.Add(new STToolStripItem("Paste", PastePaneAction)); 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)); @@ -890,6 +893,40 @@ namespace LayoutBXLYT SetupNewPane(pane, pickOriginMouse); } + private void CopyPaneAction(object sender, EventArgs e) { + CopyPanes(); + } + + private void PastePaneAction(object sender, EventArgs e) { + PastePanes(); + } + + private void CopyPanes() + { + return; + + CopiedPanes.Clear(); + foreach (var pane in SelectedPanes) + { + var copiedPane = pane.Copy(); + CopiedPanes.Add(copiedPane); + } + } + + private void PastePanes() + { + return; + + SelectedPanes.Clear(); + foreach (var pane in CopiedPanes) + { + ParentEditor.AddNewPastedPane(pane); + SelectedPanes.Add(pane); + } + + glControl1.Invalidate(); + } + private void SetupNewPane(BasePane pane, Point point) { if (pane == null) return; @@ -1343,6 +1380,16 @@ namespace LayoutBXLYT ParentEditor.UpdateUndo(); glControl1.Invalidate(); } + else if (e.Control && e.KeyCode == Keys.C) // Ctrl + C copy + { + CopyPanes(); + glControl1.Invalidate(); + } + else if (e.Control && e.KeyCode == Keys.V) // Ctrl + V paste + { + PastePanes(); + glControl1.Invalidate(); + } else if (e.KeyCode == Keys.Delete) { DeleteSelectedPanes(); diff --git a/File_Format_Library/GUI/Byaml/CourseMuunt2D/MuuntEditor.Designer.cs b/File_Format_Library/GUI/Byaml/CourseMuunt2D/MuuntEditor.Designer.cs new file mode 100644 index 00000000..51a88ced --- /dev/null +++ b/File_Format_Library/GUI/Byaml/CourseMuunt2D/MuuntEditor.Designer.cs @@ -0,0 +1,171 @@ +namespace FirstPlugin.Forms +{ + partial class MuuntEditor + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.dockPanel1 = new WeifenLuo.WinFormsUI.Docking.DockPanel(); + this.stMenuStrip1 = new Toolbox.Library.Forms.STMenuStrip(); + this.fileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.editToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.viewToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.toggle3DViewToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.openToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.saveToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.saveAsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.stToolStrip1 = new Toolbox.Library.Forms.STToolStrip(); + this.toolStripButton1 = new System.Windows.Forms.ToolStripButton(); + this.stMenuStrip1.SuspendLayout(); + this.stToolStrip1.SuspendLayout(); + this.SuspendLayout(); + // + // dockPanel1 + // + this.dockPanel1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.dockPanel1.Location = new System.Drawing.Point(0, 52); + this.dockPanel1.Name = "dockPanel1"; + this.dockPanel1.Size = new System.Drawing.Size(471, 363); + this.dockPanel1.TabIndex = 0; + // + // stMenuStrip1 + // + this.stMenuStrip1.HighlightSelectedTab = false; + this.stMenuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.fileToolStripMenuItem, + this.editToolStripMenuItem, + this.viewToolStripMenuItem}); + this.stMenuStrip1.Location = new System.Drawing.Point(0, 0); + this.stMenuStrip1.Name = "stMenuStrip1"; + this.stMenuStrip1.Size = new System.Drawing.Size(471, 24); + this.stMenuStrip1.TabIndex = 2; + this.stMenuStrip1.Text = "stMenuStrip1"; + // + // fileToolStripMenuItem + // + this.fileToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.openToolStripMenuItem, + this.saveToolStripMenuItem, + this.saveAsToolStripMenuItem}); + this.fileToolStripMenuItem.Name = "fileToolStripMenuItem"; + this.fileToolStripMenuItem.Size = new System.Drawing.Size(37, 20); + this.fileToolStripMenuItem.Text = "File"; + // + // editToolStripMenuItem + // + this.editToolStripMenuItem.Name = "editToolStripMenuItem"; + this.editToolStripMenuItem.Size = new System.Drawing.Size(39, 20); + this.editToolStripMenuItem.Text = "Edit"; + // + // viewToolStripMenuItem + // + this.viewToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.toggle3DViewToolStripMenuItem}); + this.viewToolStripMenuItem.Name = "viewToolStripMenuItem"; + this.viewToolStripMenuItem.Size = new System.Drawing.Size(44, 20); + this.viewToolStripMenuItem.Text = "View"; + // + // toggle3DViewToolStripMenuItem + // + this.toggle3DViewToolStripMenuItem.Name = "toggle3DViewToolStripMenuItem"; + this.toggle3DViewToolStripMenuItem.Size = new System.Drawing.Size(180, 22); + this.toggle3DViewToolStripMenuItem.Text = "Toggle 3D View"; + // + // openToolStripMenuItem + // + this.openToolStripMenuItem.Name = "openToolStripMenuItem"; + this.openToolStripMenuItem.Size = new System.Drawing.Size(180, 22); + this.openToolStripMenuItem.Text = "Open"; + // + // saveToolStripMenuItem + // + this.saveToolStripMenuItem.Name = "saveToolStripMenuItem"; + this.saveToolStripMenuItem.Size = new System.Drawing.Size(180, 22); + this.saveToolStripMenuItem.Text = "Save"; + // + // saveAsToolStripMenuItem + // + this.saveAsToolStripMenuItem.Name = "saveAsToolStripMenuItem"; + this.saveAsToolStripMenuItem.Size = new System.Drawing.Size(180, 22); + this.saveAsToolStripMenuItem.Text = "Save As"; + // + // stToolStrip1 + // + this.stToolStrip1.HighlightSelectedTab = false; + this.stToolStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.toolStripButton1}); + this.stToolStrip1.Location = new System.Drawing.Point(0, 24); + this.stToolStrip1.Name = "stToolStrip1"; + this.stToolStrip1.Size = new System.Drawing.Size(471, 25); + this.stToolStrip1.TabIndex = 3; + this.stToolStrip1.Text = "stToolStrip1"; + // + // toolStripButton1 + // + this.toolStripButton1.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; + this.toolStripButton1.Image = global::FirstPlugin.Properties.Resources.ViewportIconDisable; + this.toolStripButton1.ImageTransparentColor = System.Drawing.Color.Magenta; + this.toolStripButton1.Name = "toolStripButton1"; + this.toolStripButton1.Size = new System.Drawing.Size(23, 22); + this.toolStripButton1.Text = "toolStripButton1"; + // + // MuuntEditor + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(471, 412); + this.Controls.Add(this.stToolStrip1); + this.Controls.Add(this.dockPanel1); + this.Controls.Add(this.stMenuStrip1); + this.MainMenuStrip = this.stMenuStrip1; + this.Name = "MuuntEditor"; + this.Text = "MarioKartMuuntEditor"; + this.stMenuStrip1.ResumeLayout(false); + this.stMenuStrip1.PerformLayout(); + this.stToolStrip1.ResumeLayout(false); + this.stToolStrip1.PerformLayout(); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private WeifenLuo.WinFormsUI.Docking.DockPanel dockPanel1; + private Toolbox.Library.Forms.STMenuStrip stMenuStrip1; + private System.Windows.Forms.ToolStripMenuItem fileToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem openToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem saveToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem saveAsToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem editToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem viewToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem toggle3DViewToolStripMenuItem; + private Toolbox.Library.Forms.STToolStrip stToolStrip1; + private System.Windows.Forms.ToolStripButton toolStripButton1; + } +} \ No newline at end of file diff --git a/File_Format_Library/GUI/Byaml/CourseMuunt2D/MuuntEditor.cs b/File_Format_Library/GUI/Byaml/CourseMuunt2D/MuuntEditor.cs new file mode 100644 index 00000000..c8ecf4e1 --- /dev/null +++ b/File_Format_Library/GUI/Byaml/CourseMuunt2D/MuuntEditor.cs @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; +using Toolbox.Library.Forms; +using WeifenLuo.WinFormsUI.Docking; + +namespace FirstPlugin.Forms +{ + public partial class MuuntEditor : Form + { + public MuuntEditor() + { + InitializeComponent(); + } + } +} diff --git a/File_Format_Library/GUI/Byaml/CourseMuunt2D/MuuntEditor.resx b/File_Format_Library/GUI/Byaml/CourseMuunt2D/MuuntEditor.resx new file mode 100644 index 00000000..3eaa8931 --- /dev/null +++ b/File_Format_Library/GUI/Byaml/CourseMuunt2D/MuuntEditor.resx @@ -0,0 +1,126 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 17, 17 + + + 141, 17 + + \ No newline at end of file diff --git a/File_Format_Library/GUI/Byaml/CourseMuunt2D/MuuntEditorDocker.cs b/File_Format_Library/GUI/Byaml/CourseMuunt2D/MuuntEditorDocker.cs new file mode 100644 index 00000000..71c9b7af --- /dev/null +++ b/File_Format_Library/GUI/Byaml/CourseMuunt2D/MuuntEditorDocker.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using WeifenLuo.WinFormsUI.Docking; + +namespace FirstPlugin.Forms +{ + public class MuuntEditorDocker : DockContent + { + } +} diff --git a/File_Format_Library/GUI/Byaml/CourseMuunt2D/TrackEditor2D.cs b/File_Format_Library/GUI/Byaml/CourseMuunt2D/TrackEditor2D.cs new file mode 100644 index 00000000..e8267090 --- /dev/null +++ b/File_Format_Library/GUI/Byaml/CourseMuunt2D/TrackEditor2D.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Toolbox.Library.Forms; +using Toolbox.Library; +using OpenTK; +using OpenTK.Graphics.OpenGL; + +namespace FirstPlugin.Turbo +{ + public class MuuntEditor2D + { + + } +} diff --git a/Switch_Toolbox_Library/Generics/Texture/GenericTexture.cs b/Switch_Toolbox_Library/Generics/Texture/GenericTexture.cs index 03c22100..1109ee5c 100644 --- a/Switch_Toolbox_Library/Generics/Texture/GenericTexture.cs +++ b/Switch_Toolbox_Library/Generics/Texture/GenericTexture.cs @@ -340,6 +340,8 @@ namespace Toolbox.Library { TEX_FORMAT.B5G5R5A1_UNORM, new FormatInfo(2, 1, 1, 1, TargetBuffer.Color) }, { TEX_FORMAT.B8G8R8A8_UNORM, new FormatInfo(4, 1, 1, 1, TargetBuffer.Color) }, { TEX_FORMAT.B8G8R8A8_UNORM_SRGB, new FormatInfo(4, 1, 1, 1, TargetBuffer.Color) }, + { TEX_FORMAT.R5G5B5_UNORM, new FormatInfo(2, 1, 1, 1, TargetBuffer.Color) }, + { TEX_FORMAT.R10G10B10A2_UINT, new FormatInfo(4, 1, 1, 1, TargetBuffer.Color) }, { TEX_FORMAT.R10G10B10A2_UNORM, new FormatInfo(4, 1, 1, 1, TargetBuffer.Color) }, diff --git a/Switch_Toolbox_Library/IO/Extensions/StringExtension.cs b/Switch_Toolbox_Library/IO/Extensions/StringExtension.cs index e109d40f..1b690238 100644 --- a/Switch_Toolbox_Library/IO/Extensions/StringExtension.cs +++ b/Switch_Toolbox_Library/IO/Extensions/StringExtension.cs @@ -2,7 +2,7 @@ using System.Collections.Generic; using System.Linq; using System.Text; -using System.Threading.Tasks; +using System.Text.RegularExpressions; using System.IO; namespace System @@ -26,6 +26,12 @@ namespace System return normalizedPath.StartsWith(normalizedBaseDirPath, StringComparison.OrdinalIgnoreCase); } + public static string RemoveNumbersAtEnd(this string str) + { + Regex rgx = new Regex(@"\d+$"); + return rgx.Replace(str, string.Empty); + } + /// /// Returns with the minimal concatenation of (starting from end) that /// results in satisfying .EndsWith(ending). diff --git a/Switch_Toolbox_Library/Util/Util.cs b/Switch_Toolbox_Library/Util/Util.cs index 23888ca2..c445d44f 100644 --- a/Switch_Toolbox_Library/Util/Util.cs +++ b/Switch_Toolbox_Library/Util/Util.cs @@ -178,14 +178,17 @@ namespace Toolbox.Library return data.Skip((int)offset).Take((int)length).ToArray(); } - public static string RenameDuplicateString(List strings, string oldString, int index = 0) + public static string RenameDuplicateString(List strings, string oldString, int index = 0, int numDigits = 1) { if (strings.Contains(oldString)) { - string NewString = $"{oldString}_{index++}"; + string key = $"{index++}"; + if (numDigits == 2) + key = string.Format("{0:00}", key); + string NewString = $"{oldString}_{key}"; if (strings.Contains(NewString)) - return RenameDuplicateString(strings, oldString, index); + return RenameDuplicateString(strings, oldString, index, numDigits); else return NewString; }