diff --git a/BrawlboxHelper/Syroot.NintenTools.NSW.Bfres.dll b/BrawlboxHelper/Syroot.NintenTools.NSW.Bfres.dll index dd7a7162..78e1fe6f 100644 Binary files a/BrawlboxHelper/Syroot.NintenTools.NSW.Bfres.dll and b/BrawlboxHelper/Syroot.NintenTools.NSW.Bfres.dll differ diff --git a/BrawlboxHelper/Syroot.NintenTools.NSW.Bfres.pdb b/BrawlboxHelper/Syroot.NintenTools.NSW.Bfres.pdb index 63e8bf10..9e77bfc0 100644 Binary files a/BrawlboxHelper/Syroot.NintenTools.NSW.Bfres.pdb and b/BrawlboxHelper/Syroot.NintenTools.NSW.Bfres.pdb differ diff --git a/File_Format_Library/FileFormats/Byaml/BYAML.cs b/File_Format_Library/FileFormats/Byaml/BYAML.cs index 1aa1dd60..77f27bda 100644 --- a/File_Format_Library/FileFormats/Byaml/BYAML.cs +++ b/File_Format_Library/FileFormats/Byaml/BYAML.cs @@ -10,7 +10,6 @@ using Toolbox.Library.Forms; using Toolbox.Library.IO; using ByamlExt.Byaml; using ByamlExt; -using FirstPlugin.Turbo; namespace FirstPlugin { @@ -166,6 +165,13 @@ namespace FirstPlugin editor.FileFormat = this; editor.Text = FileName; editor.Dock = DockStyle.Fill; + + /* if (FileName.Contains("_muunt")) + { + var muuntEditor = new MuuntEditor.MuuntEditor(); + muuntEditor.LoadByaml(data.RootNode, FileName); + muuntEditor.Show(); + }*/ return editor; } diff --git a/File_Format_Library/FileFormats/Layout/CAFE/BFLAN.cs b/File_Format_Library/FileFormats/Layout/CAFE/BFLAN.cs index f0be3fba..f5b91ab5 100644 --- a/File_Format_Library/FileFormats/Layout/CAFE/BFLAN.cs +++ b/File_Format_Library/FileFormats/Layout/CAFE/BFLAN.cs @@ -273,6 +273,12 @@ namespace LayoutBXLYT Textures = new List(); } + public override BxlanPaiEntry AddEntry(string name, byte target) { + var entry = new PaiEntry(name, target); + Entries.Add(entry); + return entry; + } + public PAI1(FileReader reader, Header header) { long startPos = reader.Position - 8; @@ -342,6 +348,18 @@ namespace LayoutBXLYT public class PaiEntry : BxlanPaiEntry { + public override BxlanPaiTag AddEntry(string tag) { + var paiTag = new PaiTag(tag); + Tags.Add(paiTag); + return paiTag; + } + + public PaiEntry(string name, byte target) + { + Name = name; + Target = (AnimationTarget)target; + } + public PaiEntry(FileReader reader, Header header) { long startPos = reader.Position; @@ -383,6 +401,11 @@ namespace LayoutBXLYT { private uint Unknown {get;set;} + public PaiTag(string tag) + { + Tag = tag; + } + public PaiTag(FileReader reader, BxlanHeader header, AnimationTarget target) { if ((byte)target == 2) diff --git a/File_Format_Library/FileFormats/Layout/Common.cs b/File_Format_Library/FileFormats/Layout/Common.cs index 14868445..e5a538e6 100644 --- a/File_Format_Library/FileFormats/Layout/Common.cs +++ b/File_Format_Library/FileFormats/Layout/Common.cs @@ -1420,12 +1420,27 @@ namespace LayoutBXLYT public ushort FrameSize; public bool Loop; - public List Textures { get; set; } + public bool ContainsEntry(string name) + { + return Entries.Any(x => x.Name == name); + } + + public virtual BxlanPaiEntry AddEntry(string name, byte target) + { + return new BxlanPaiEntry(); + } + + public List Textures { get; set; } = new List(); public List Entries = new List(); } public class BxlanPaiEntry { + public virtual BxlanPaiTag AddEntry(string tag) + { + return new BxlanPaiTag(); + } + [DisplayName("Name"), CategoryAttribute("Animation")] public string Name { get; set; } @@ -1447,6 +1462,29 @@ namespace LayoutBXLYT Tag = tag; } + public BxlanPaiTagEntry CreateTarget(object TargetType, byte interpolationType) + { + byte target = (byte)TargetType; + string tagType = Tag.Remove(0, 1); + switch (Tag) + { + case "LPA": + return new LPATagEntry(target, interpolationType); + case "LTS": + return new LTSTagEntry(target, interpolationType); + case "LVI": + return new LVITagEntry(target, interpolationType); + case "LVC": + return new LVCTagEntry(target, interpolationType); + case "LMC": + return new LMCTagEntry(target, interpolationType); + case "LTP": + return new LTPTagEntry(target, interpolationType); + default: + return new BxlanPaiTagEntry(target, interpolationType); + } + } + public List Entries = new List(); public string Tag; @@ -1456,7 +1494,7 @@ namespace LayoutBXLYT get { return TypeDefine.ContainsKey(Tag) ? TypeDefine[Tag] : Tag; } } - public Dictionary TypeDefine = new Dictionary() + public static Dictionary TypeDefine = new Dictionary() { {"FLPA","PaneSRT" }, {"FLVI","Visibility" }, @@ -1504,6 +1542,7 @@ namespace LayoutBXLYT set { AnimationTarget = (byte)value; } } + public LPATagEntry(byte target, byte curveType) : base(target, curveType) { } public LPATagEntry(FileReader reader, BxlanHeader header) : base(reader, header) { } } @@ -1517,6 +1556,7 @@ namespace LayoutBXLYT set { AnimationTarget = (byte)value; } } + public LTSTagEntry(byte target, byte curveType) : base(target, curveType) { } public LTSTagEntry(FileReader reader, BxlanHeader header) : base(reader, header) { } } @@ -1530,6 +1570,7 @@ namespace LayoutBXLYT set { AnimationTarget = (byte)value; } } + public LVITagEntry(byte target, byte curveType) : base(target, curveType) { } public LVITagEntry(FileReader reader, BxlanHeader header) : base(reader, header) { } } @@ -1543,6 +1584,7 @@ namespace LayoutBXLYT set { AnimationTarget = (byte)value; } } + public LVCTagEntry(byte target, byte curveType) : base(target, curveType) { } public LVCTagEntry(FileReader reader, BxlanHeader header) : base(reader, header) { } } @@ -1556,6 +1598,7 @@ namespace LayoutBXLYT set { AnimationTarget = (byte)value; } } + public LMCTagEntry(byte target, byte curveType) : base(target, curveType) { } public LMCTagEntry(FileReader reader, BxlanHeader header) : base(reader, header) { } } @@ -1569,6 +1612,7 @@ namespace LayoutBXLYT set { AnimationTarget = (byte)value; } } + public LTPTagEntry(byte target, byte curveType) : base(target, curveType) { } public LTPTagEntry(FileReader reader, BxlanHeader header) : base(reader, header) { } } @@ -1590,6 +1634,11 @@ namespace LayoutBXLYT public List KeyFrames = new List(); + public BxlanPaiTagEntry(byte target, byte curveType) + { + AnimationTarget = target; + CurveType = (CurveType)curveType; + } public BxlanPaiTagEntry(FileReader reader, BxlanHeader header) { @@ -1659,6 +1708,13 @@ namespace LayoutBXLYT [DisplayName("Value"), CategoryAttribute("Key Frame")] public float Value { get; set; } + public KeyFrame(float frame) + { + Frame = frame; + Value = 0; + Slope = 0; + } + public KeyFrame(FileReader reader, CurveType curveType) { switch (curveType) @@ -1718,7 +1774,7 @@ namespace LayoutBXLYT public virtual Dictionary GetTextures { get; } [Browsable(false)] - public virtual List Textures { get; } + public virtual List Textures { get; } [Browsable(false)] public virtual List Fonts { get; } diff --git a/File_Format_Library/File_Format_Library.csproj b/File_Format_Library/File_Format_Library.csproj index d680e6e5..c059e424 100644 --- a/File_Format_Library/File_Format_Library.csproj +++ b/File_Format_Library/File_Format_Library.csproj @@ -354,16 +354,34 @@ + + Form + + + AddAnimGroupDialog.cs + + + Form + + + AddGroupTypeDialog.cs + + + Form + + + AddGroupTargetDialog.cs + Form LayoutAnimEditor.cs - + Form - + LayoutAnimEditorBasic.cs @@ -648,16 +666,40 @@ SmoothNormalsMultiMeshForm.cs - + + + + + + + + Form - + MuuntEditor.cs - + Form - + + UserControl + + + Form + + + MuuntObjectList.cs + + + Form + + + MuuntPropertiesEditor.cs + + + + UserControl @@ -853,39 +895,39 @@ TexPatternMaterialEditor.cs - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + UserControl - + TurboMunntEditor.cs - - - - - + + + + + UserControl @@ -1339,10 +1381,19 @@ BffntEditor.cs + + AddAnimGroupDialog.cs + + + AddGroupTypeDialog.cs + + + AddGroupTargetDialog.cs + LayoutAnimEditor.cs - + LayoutAnimEditorBasic.cs @@ -1600,10 +1651,16 @@ BotwActorEditorControl.cs - + MuuntEditor.cs - + + MuuntObjectList.cs + + + MuuntPropertiesEditor.cs + + TurboMunntEditor.cs @@ -1801,6 +1858,7 @@ + diff --git a/File_Format_Library/GUI/BFLYT/Animations/Basic/AddAnimGroupDialog.Designer.cs b/File_Format_Library/GUI/BFLYT/Animations/Basic/AddAnimGroupDialog.Designer.cs new file mode 100644 index 00000000..b472827d --- /dev/null +++ b/File_Format_Library/GUI/BFLYT/Animations/Basic/AddAnimGroupDialog.Designer.cs @@ -0,0 +1,141 @@ +namespace LayoutBXLYT +{ + partial class AddAnimGroupDialog + { + /// + /// 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.typeCB = new Toolbox.Library.Forms.STComboBox(); + this.stTextBox1 = new Toolbox.Library.Forms.STTextBox(); + this.objectTargetsCB = new Toolbox.Library.Forms.STComboBox(); + this.stLabel1 = new Toolbox.Library.Forms.STLabel(); + this.stLabel2 = new Toolbox.Library.Forms.STLabel(); + this.stButton1 = new Toolbox.Library.Forms.STButton(); + this.contentContainer.SuspendLayout(); + this.SuspendLayout(); + // + // contentContainer + // + this.contentContainer.Controls.Add(this.stButton1); + this.contentContainer.Controls.Add(this.stLabel2); + this.contentContainer.Controls.Add(this.stLabel1); + this.contentContainer.Controls.Add(this.objectTargetsCB); + this.contentContainer.Controls.Add(this.stTextBox1); + this.contentContainer.Controls.Add(this.typeCB); + this.contentContainer.Size = new System.Drawing.Size(375, 155); + this.contentContainer.Controls.SetChildIndex(this.typeCB, 0); + this.contentContainer.Controls.SetChildIndex(this.stTextBox1, 0); + this.contentContainer.Controls.SetChildIndex(this.objectTargetsCB, 0); + this.contentContainer.Controls.SetChildIndex(this.stLabel1, 0); + this.contentContainer.Controls.SetChildIndex(this.stLabel2, 0); + this.contentContainer.Controls.SetChildIndex(this.stButton1, 0); + // + // typeCB + // + this.typeCB.BorderColor = System.Drawing.Color.Empty; + this.typeCB.BorderStyle = System.Windows.Forms.ButtonBorderStyle.Solid; + this.typeCB.ButtonColor = System.Drawing.Color.Empty; + this.typeCB.FormattingEnabled = true; + this.typeCB.IsReadOnly = false; + this.typeCB.Location = new System.Drawing.Point(74, 45); + this.typeCB.Name = "typeCB"; + this.typeCB.Size = new System.Drawing.Size(285, 21); + this.typeCB.TabIndex = 11; + this.typeCB.SelectedIndexChanged += new System.EventHandler(this.typeCB_SelectedIndexChanged); + // + // stTextBox1 + // + this.stTextBox1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.stTextBox1.Location = new System.Drawing.Point(74, 83); + this.stTextBox1.Name = "stTextBox1"; + this.stTextBox1.Size = new System.Drawing.Size(145, 20); + this.stTextBox1.TabIndex = 12; + // + // objectTargetsCB + // + this.objectTargetsCB.BorderColor = System.Drawing.Color.Empty; + this.objectTargetsCB.BorderStyle = System.Windows.Forms.ButtonBorderStyle.Solid; + this.objectTargetsCB.ButtonColor = System.Drawing.Color.Empty; + this.objectTargetsCB.FormattingEnabled = true; + this.objectTargetsCB.IsReadOnly = false; + this.objectTargetsCB.Location = new System.Drawing.Point(225, 82); + this.objectTargetsCB.Name = "objectTargetsCB"; + this.objectTargetsCB.Size = new System.Drawing.Size(134, 21); + this.objectTargetsCB.TabIndex = 13; + this.objectTargetsCB.SelectedIndexChanged += new System.EventHandler(this.objectTargetsCB_SelectedIndexChanged); + // + // stLabel1 + // + this.stLabel1.AutoSize = true; + this.stLabel1.Location = new System.Drawing.Point(34, 48); + this.stLabel1.Name = "stLabel1"; + this.stLabel1.Size = new System.Drawing.Size(34, 13); + this.stLabel1.TabIndex = 14; + this.stLabel1.Text = "Type:"; + // + // stLabel2 + // + this.stLabel2.AutoSize = true; + this.stLabel2.Location = new System.Drawing.Point(34, 85); + this.stLabel2.Name = "stLabel2"; + this.stLabel2.Size = new System.Drawing.Size(38, 13); + this.stLabel2.TabIndex = 15; + this.stLabel2.Text = "Name:"; + // + // stButton1 + // + this.stButton1.DialogResult = System.Windows.Forms.DialogResult.OK; + this.stButton1.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.stButton1.Location = new System.Drawing.Point(291, 123); + this.stButton1.Name = "stButton1"; + this.stButton1.Size = new System.Drawing.Size(75, 23); + this.stButton1.TabIndex = 16; + this.stButton1.Text = "Ok"; + this.stButton1.UseVisualStyleBackColor = false; + // + // AddAnimGroupDialog + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(381, 160); + this.Name = "AddAnimGroupDialog"; + this.Text = "Add Group"; + this.contentContainer.ResumeLayout(false); + this.contentContainer.PerformLayout(); + this.ResumeLayout(false); + + } + + #endregion + + private Toolbox.Library.Forms.STButton stButton1; + private Toolbox.Library.Forms.STLabel stLabel2; + private Toolbox.Library.Forms.STLabel stLabel1; + private Toolbox.Library.Forms.STComboBox objectTargetsCB; + private Toolbox.Library.Forms.STTextBox stTextBox1; + private Toolbox.Library.Forms.STComboBox typeCB; + } +} \ No newline at end of file diff --git a/File_Format_Library/GUI/BFLYT/Animations/Basic/AddAnimGroupDialog.cs b/File_Format_Library/GUI/BFLYT/Animations/Basic/AddAnimGroupDialog.cs new file mode 100644 index 00000000..64d4dda0 --- /dev/null +++ b/File_Format_Library/GUI/BFLYT/Animations/Basic/AddAnimGroupDialog.cs @@ -0,0 +1,64 @@ +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; + +namespace LayoutBXLYT +{ + public partial class AddAnimGroupDialog : STForm + { + private BxlanPAI1 AnimInfo; + private BxlytHeader ParentLayout; + + public AddAnimGroupDialog(BxlanPAI1 bxlanPai, BxlytHeader parentLayout) + { + InitializeComponent(); + CanResize = false; + + AnimInfo = bxlanPai; + ParentLayout = parentLayout; + + typeCB.LoadEnum(typeof(AnimationTarget)); + typeCB.SelectedIndex = 0; + } + + public BxlanPaiEntry AddEntry() + { + return AnimInfo.AddEntry(stTextBox1.Text, (byte)typeCB.SelectedItem); + } + + private void typeCB_SelectedIndexChanged(object sender, EventArgs e) + { + if (ParentLayout != null && typeCB.SelectedItem is AnimationTarget) + { + objectTargetsCB.Items.Clear(); + if ((AnimationTarget)typeCB.SelectedItem == AnimationTarget.Pane) + { + foreach (var pane in ParentLayout.PaneLookup.Keys) + if (!AnimInfo.ContainsEntry(pane)) + objectTargetsCB.Items.Add(pane); + } + else if ((AnimationTarget)typeCB.SelectedItem == AnimationTarget.Material) + { + foreach (var mat in ParentLayout.GetMaterials()) + if (!AnimInfo.ContainsEntry(mat.Name)) + objectTargetsCB.Items.Add(mat.Name); + } + + if (objectTargetsCB.Items.Count > 0) + objectTargetsCB.SelectedIndex = 0; + } + } + + private void objectTargetsCB_SelectedIndexChanged(object sender, EventArgs e) + { + stTextBox1.Text = (string)objectTargetsCB.SelectedItem; + } + } +} diff --git a/File_Format_Library/GUI/BFLYT/Animations/LayoutAnimEditorBasic.resx b/File_Format_Library/GUI/BFLYT/Animations/Basic/AddAnimGroupDialog.resx similarity index 100% rename from File_Format_Library/GUI/BFLYT/Animations/LayoutAnimEditorBasic.resx rename to File_Format_Library/GUI/BFLYT/Animations/Basic/AddAnimGroupDialog.resx diff --git a/File_Format_Library/GUI/BFLYT/Animations/Basic/AddGroupTargetDialog.Designer.cs b/File_Format_Library/GUI/BFLYT/Animations/Basic/AddGroupTargetDialog.Designer.cs new file mode 100644 index 00000000..26651da5 --- /dev/null +++ b/File_Format_Library/GUI/BFLYT/Animations/Basic/AddGroupTargetDialog.Designer.cs @@ -0,0 +1,128 @@ +namespace LayoutBXLYT +{ + partial class AddGroupTargetDialog + { + /// + /// 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.targetCB = new Toolbox.Library.Forms.STComboBox(); + this.stLabel1 = new Toolbox.Library.Forms.STLabel(); + this.stButton1 = new Toolbox.Library.Forms.STButton(); + this.stLabel2 = new Toolbox.Library.Forms.STLabel(); + this.curveTypeCB = new Toolbox.Library.Forms.STComboBox(); + this.contentContainer.SuspendLayout(); + this.SuspendLayout(); + // + // contentContainer + // + this.contentContainer.Controls.Add(this.stLabel2); + this.contentContainer.Controls.Add(this.curveTypeCB); + this.contentContainer.Controls.Add(this.stButton1); + this.contentContainer.Controls.Add(this.stLabel1); + this.contentContainer.Controls.Add(this.targetCB); + this.contentContainer.Size = new System.Drawing.Size(316, 143); + this.contentContainer.Controls.SetChildIndex(this.targetCB, 0); + this.contentContainer.Controls.SetChildIndex(this.stLabel1, 0); + this.contentContainer.Controls.SetChildIndex(this.stButton1, 0); + this.contentContainer.Controls.SetChildIndex(this.curveTypeCB, 0); + this.contentContainer.Controls.SetChildIndex(this.stLabel2, 0); + // + // targetCB + // + this.targetCB.BorderColor = System.Drawing.Color.Empty; + this.targetCB.BorderStyle = System.Windows.Forms.ButtonBorderStyle.Solid; + this.targetCB.ButtonColor = System.Drawing.Color.Empty; + this.targetCB.FormattingEnabled = true; + this.targetCB.IsReadOnly = false; + this.targetCB.Location = new System.Drawing.Point(96, 35); + this.targetCB.Name = "targetCB"; + this.targetCB.Size = new System.Drawing.Size(208, 21); + this.targetCB.TabIndex = 11; + // + // stLabel1 + // + this.stLabel1.AutoSize = true; + this.stLabel1.Location = new System.Drawing.Point(20, 38); + this.stLabel1.Name = "stLabel1"; + this.stLabel1.Size = new System.Drawing.Size(41, 13); + this.stLabel1.TabIndex = 12; + this.stLabel1.Text = "Target:"; + // + // stButton1 + // + this.stButton1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.stButton1.DialogResult = System.Windows.Forms.DialogResult.OK; + this.stButton1.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.stButton1.Location = new System.Drawing.Point(232, 111); + this.stButton1.Name = "stButton1"; + this.stButton1.Size = new System.Drawing.Size(75, 23); + this.stButton1.TabIndex = 13; + this.stButton1.Text = "Ok"; + this.stButton1.UseVisualStyleBackColor = false; + // + // stLabel2 + // + this.stLabel2.AutoSize = true; + this.stLabel2.Location = new System.Drawing.Point(20, 65); + this.stLabel2.Name = "stLabel2"; + this.stLabel2.Size = new System.Drawing.Size(68, 13); + this.stLabel2.TabIndex = 15; + this.stLabel2.Text = "Curve Type::"; + // + // curveTypeCB + // + this.curveTypeCB.BorderColor = System.Drawing.Color.Empty; + this.curveTypeCB.BorderStyle = System.Windows.Forms.ButtonBorderStyle.Solid; + this.curveTypeCB.ButtonColor = System.Drawing.Color.Empty; + this.curveTypeCB.FormattingEnabled = true; + this.curveTypeCB.IsReadOnly = false; + this.curveTypeCB.Location = new System.Drawing.Point(96, 62); + this.curveTypeCB.Name = "curveTypeCB"; + this.curveTypeCB.Size = new System.Drawing.Size(208, 21); + this.curveTypeCB.TabIndex = 14; + // + // AddGroupTargetDialog + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(322, 148); + this.Name = "AddGroupTargetDialog"; + this.Text = "Add Target"; + this.contentContainer.ResumeLayout(false); + this.contentContainer.PerformLayout(); + this.ResumeLayout(false); + + } + + #endregion + + private Toolbox.Library.Forms.STLabel stLabel1; + private Toolbox.Library.Forms.STComboBox targetCB; + private Toolbox.Library.Forms.STLabel stLabel2; + private Toolbox.Library.Forms.STComboBox curveTypeCB; + private Toolbox.Library.Forms.STButton stButton1; + } +} \ No newline at end of file diff --git a/File_Format_Library/GUI/BFLYT/Animations/Basic/AddGroupTargetDialog.cs b/File_Format_Library/GUI/BFLYT/Animations/Basic/AddGroupTargetDialog.cs new file mode 100644 index 00000000..70609307 --- /dev/null +++ b/File_Format_Library/GUI/BFLYT/Animations/Basic/AddGroupTargetDialog.cs @@ -0,0 +1,81 @@ +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; + +namespace LayoutBXLYT +{ + public partial class AddGroupTargetDialog : STForm + { + private BxlanPaiTag activeTag; + + public AddGroupTargetDialog() + { + InitializeComponent(); + CanResize = false; + } + + public bool LoadTag(BxlanPaiTag group) + { + activeTag = group; + + curveTypeCB.LoadEnum(typeof(CurveType)); + curveTypeCB.SelectedItem = CurveType.Hermite; + + //Go through each group type + //If either all targets are used, or is not supported we will return false + if (group.Type == "PaneSRT") + return LoadEnum(typeof(LPATarget)); + else if (group.Type == "Visibility") + return LoadEnum(typeof(LVITarget)); + else if (group.Type == "TextureSRT") + return LoadEnum(typeof(LTSTarget)); + else if (group.Type == "VertexColor") + return LoadEnum(typeof(LVCTarget)); + else if (group.Type == "TexturePattern") + return LoadEnum(typeof(LTPTarget)); + else if (group.Type == "IndTextureSRT") + return LoadEnum(typeof(LIMTarget)); + else if (group.Type == "AlphaTest") + { + + } + else if (group.Type == "FontShadow") + return LoadEnum(typeof(LCTTarget)); + else if (group.Type == "PerCharacterTransformCurve") + { + + } + + return false; + } + + private bool LoadEnum(Type type) + { + targetCB.Items.Clear(); + var enums = Enum.GetValues(type); + foreach (var val in Enum.GetValues(type)) + { + if (!activeTag.Entries.Any(x => byte.Equals((byte)val, x.AnimationTarget))) + targetCB.Items.Add(val); + } + + if (targetCB.Items.Count > 0) + targetCB.SelectedIndex = 0; + + //Check if it loaded enums properly + return targetCB.Items.Count > 0; + } + + public BxlanPaiTagEntry GetGroupTarget() + { + return activeTag.CreateTarget(targetCB.SelectedItem, (byte)curveTypeCB.SelectedItem); + } + } +} diff --git a/File_Format_Library/GUI/BFLYT/Animations/Basic/AddGroupTargetDialog.resx b/File_Format_Library/GUI/BFLYT/Animations/Basic/AddGroupTargetDialog.resx new file mode 100644 index 00000000..1af7de15 --- /dev/null +++ b/File_Format_Library/GUI/BFLYT/Animations/Basic/AddGroupTargetDialog.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/Animations/Basic/AddGroupTypeDialog.Designer.cs b/File_Format_Library/GUI/BFLYT/Animations/Basic/AddGroupTypeDialog.Designer.cs new file mode 100644 index 00000000..02ad549b --- /dev/null +++ b/File_Format_Library/GUI/BFLYT/Animations/Basic/AddGroupTypeDialog.Designer.cs @@ -0,0 +1,98 @@ +namespace LayoutBXLYT +{ + partial class AddGroupTypeDialog + { + /// + /// 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.stComboBox1 = new Toolbox.Library.Forms.STComboBox(); + this.stLabel1 = new Toolbox.Library.Forms.STLabel(); + this.stButton1 = new Toolbox.Library.Forms.STButton(); + this.contentContainer.SuspendLayout(); + this.SuspendLayout(); + // + // contentContainer + // + this.contentContainer.Controls.Add(this.stButton1); + this.contentContainer.Controls.Add(this.stLabel1); + this.contentContainer.Controls.Add(this.stComboBox1); + this.contentContainer.Size = new System.Drawing.Size(278, 112); + this.contentContainer.Controls.SetChildIndex(this.stComboBox1, 0); + this.contentContainer.Controls.SetChildIndex(this.stLabel1, 0); + this.contentContainer.Controls.SetChildIndex(this.stButton1, 0); + // + // stComboBox1 + // + this.stComboBox1.BorderColor = System.Drawing.Color.Empty; + this.stComboBox1.BorderStyle = System.Windows.Forms.ButtonBorderStyle.Solid; + this.stComboBox1.ButtonColor = System.Drawing.Color.Empty; + this.stComboBox1.FormattingEnabled = true; + this.stComboBox1.IsReadOnly = false; + this.stComboBox1.Location = new System.Drawing.Point(74, 45); + this.stComboBox1.Name = "stComboBox1"; + this.stComboBox1.Size = new System.Drawing.Size(196, 21); + this.stComboBox1.TabIndex = 11; + // + // stLabel1 + // + this.stLabel1.AutoSize = true; + this.stLabel1.Location = new System.Drawing.Point(23, 48); + this.stLabel1.Name = "stLabel1"; + this.stLabel1.Size = new System.Drawing.Size(34, 13); + this.stLabel1.TabIndex = 12; + this.stLabel1.Text = "Type:"; + // + // stButton1 + // + this.stButton1.DialogResult = System.Windows.Forms.DialogResult.OK; + this.stButton1.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.stButton1.Location = new System.Drawing.Point(195, 81); + this.stButton1.Name = "stButton1"; + this.stButton1.Size = new System.Drawing.Size(75, 23); + this.stButton1.TabIndex = 13; + this.stButton1.Text = "Ok"; + this.stButton1.UseVisualStyleBackColor = false; + // + // AddGroupTypeDialog + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(284, 117); + this.Name = "AddGroupTypeDialog"; + this.Text = "Add Group Type"; + this.contentContainer.ResumeLayout(false); + this.contentContainer.PerformLayout(); + this.ResumeLayout(false); + + } + + #endregion + + private Toolbox.Library.Forms.STButton stButton1; + private Toolbox.Library.Forms.STLabel stLabel1; + private Toolbox.Library.Forms.STComboBox stComboBox1; + } +} \ No newline at end of file diff --git a/File_Format_Library/GUI/BFLYT/Animations/Basic/AddGroupTypeDialog.cs b/File_Format_Library/GUI/BFLYT/Animations/Basic/AddGroupTypeDialog.cs new file mode 100644 index 00000000..b32bb0da --- /dev/null +++ b/File_Format_Library/GUI/BFLYT/Animations/Basic/AddGroupTypeDialog.cs @@ -0,0 +1,39 @@ +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; + +namespace LayoutBXLYT +{ + public partial class AddGroupTypeDialog : STForm + { + private BxlanPaiEntry ActiveGroup; + + public AddGroupTypeDialog(BxlanPaiEntry animGroup) + { + InitializeComponent(); + CanResize = false; + ActiveGroup = animGroup; + + foreach (var tagDefine in BxlanPaiTag.TypeDefine) + { + if (!animGroup.Tags.Any(x => x.Tag == tagDefine.Key )) + stComboBox1.Items.Add(tagDefine.Value); + } + + stComboBox1.SelectedIndex = 0; + } + + public BxlanPaiTag AddEntry() + { + var tagValue = BxlanPaiTag.TypeDefine.FirstOrDefault(x => x.Value == (string)stComboBox1.SelectedItem).Key; + return ActiveGroup.AddEntry(tagValue); + } + } +} diff --git a/File_Format_Library/GUI/BFLYT/Animations/Basic/AddGroupTypeDialog.resx b/File_Format_Library/GUI/BFLYT/Animations/Basic/AddGroupTypeDialog.resx new file mode 100644 index 00000000..1af7de15 --- /dev/null +++ b/File_Format_Library/GUI/BFLYT/Animations/Basic/AddGroupTypeDialog.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/Animations/LayoutAnimEditorBasic.Designer.cs b/File_Format_Library/GUI/BFLYT/Animations/Basic/LayoutAnimEditorBasic.Designer.cs similarity index 92% rename from File_Format_Library/GUI/BFLYT/Animations/LayoutAnimEditorBasic.Designer.cs rename to File_Format_Library/GUI/BFLYT/Animations/Basic/LayoutAnimEditorBasic.Designer.cs index 681918ad..55a3c3c4 100644 --- a/File_Format_Library/GUI/BFLYT/Animations/LayoutAnimEditorBasic.Designer.cs +++ b/File_Format_Library/GUI/BFLYT/Animations/Basic/LayoutAnimEditorBasic.Designer.cs @@ -62,6 +62,9 @@ this.treeView1.Size = new System.Drawing.Size(266, 450); this.treeView1.TabIndex = 0; this.treeView1.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(this.treeView1_AfterSelect); + this.treeView1.NodeMouseClick += new System.Windows.Forms.TreeNodeMouseClickEventHandler(this.treeView1_NodeMouseClick); + this.treeView1.KeyDown += new System.Windows.Forms.KeyEventHandler(this.treeView1_KeyPress); + this.treeView1.MouseClick += new System.Windows.Forms.MouseEventHandler(this.treeView1_MouseClick); // // stPropertyGrid1 // diff --git a/File_Format_Library/GUI/BFLYT/Animations/LayoutAnimEditorBasic.cs b/File_Format_Library/GUI/BFLYT/Animations/Basic/LayoutAnimEditorBasic.cs similarity index 50% rename from File_Format_Library/GUI/BFLYT/Animations/LayoutAnimEditorBasic.cs rename to File_Format_Library/GUI/BFLYT/Animations/Basic/LayoutAnimEditorBasic.cs index f2136ff3..e3508eab 100644 --- a/File_Format_Library/GUI/BFLYT/Animations/LayoutAnimEditorBasic.cs +++ b/File_Format_Library/GUI/BFLYT/Animations/Basic/LayoutAnimEditorBasic.cs @@ -14,6 +14,7 @@ namespace LayoutBXLYT { public partial class LayoutAnimEditorBasic : LayoutDocked { + private BxlytHeader ParentLayout; private BxlanHeader ActiveAnim; public EventHandler OnPropertyChanged; @@ -26,8 +27,9 @@ namespace LayoutBXLYT splitContainer1.BackColor = FormThemes.BaseTheme.FormBackColor; } - public void LoadAnim(BxlanHeader bxlan) + public void LoadAnim(BxlanHeader bxlan, BxlytHeader parentLayout = null) { + ParentLayout = parentLayout; LoadAnimations(bxlan, new TreeNode(bxlan.FileName) { Tag = bxlan }); } @@ -42,7 +44,7 @@ namespace LayoutBXLYT { var header = bxlan as BxlanHeader; var pat1 = new TreeNode("Tag Info") { Tag = header.AnimationTag }; - var pai1 = new TreeNode("Animation Info") { Tag = header.AnimationInfo }; + var pai1 = new AnimInfoWrapper("Animation Info", ParentLayout) { Tag = header.AnimationInfo }; for (int i = 0; i < header.AnimationInfo.Entries.Count; i++) LoadAnimationEntry(header.AnimationInfo.Entries[i], pai1); @@ -54,12 +56,12 @@ namespace LayoutBXLYT private void LoadAnimationEntry(BxlanPaiEntry entry, TreeNode root) { - var nodeEntry = new TreeNode(entry.Name) { Tag = entry }; + var nodeEntry = new GroupAnimWrapper(entry.Name) { Tag = entry }; root.Nodes.Add(nodeEntry); for (int i = 0; i < entry.Tags.Count; i++) { - var nodeTag = new TreeNode(entry.Tags[i].Type) { Tag = entry.Tags[i] }; + var nodeTag = new GroupWrapper(entry.Tags[i].Type) { Tag = entry.Tags[i] }; nodeEntry.Nodes.Add(nodeTag); for (int j = 0; j < entry.Tags[i].Entries.Count; j++) LoadTagEntry(entry.Tags[i].Entries[j], nodeTag, j); @@ -68,12 +70,12 @@ namespace LayoutBXLYT private void LoadTagEntry(BxlanPaiTagEntry entry, TreeNode root, int index) { - var nodeEntry = new TreeNode(entry.TargetName) { Tag = entry }; + var nodeEntry = new GroupTargetWrapper(entry.TargetName) { Tag = entry }; root.Nodes.Add(nodeEntry); for (int i = 0; i < entry.KeyFrames.Count; i++) { - var keyNode = new TreeNode($"Key Frame {i}") { Tag = entry.KeyFrames[i] }; + var keyNode = new KeyNodeWrapper($"Key Frame {i}") { Tag = entry.KeyFrames[i] }; nodeEntry.Nodes.Add(keyNode); } } @@ -94,6 +96,43 @@ namespace LayoutBXLYT ActiveAnim.FileInfo.CanSave = true; } + public class AnimInfoWrapper : TreeNode, IContextMenuNode + { + private BxlytHeader ParentLayout; + public BxlanPAI1 bxlanPai => (BxlanPAI1)Tag; + + public AnimInfoWrapper(string text, BxlytHeader parentLayout) + { + Text = text; + ParentLayout = parentLayout; + } + + public ToolStripItem[] GetContextMenuItems() + { + List Items = new List(); + Items.Add(new ToolStripMenuItem("Add Animation Group", null, AddGroup, Keys.Control | Keys.A)); + Items.Add(new ToolStripMenuItem("Clear Groups", null, ClearGroups, Keys.Control | Keys.C)); + return Items.ToArray(); + } + + private void AddGroup(object sender, EventArgs e) + { + AddAnimGroupDialog dlg = new AddAnimGroupDialog(bxlanPai, ParentLayout); + if (dlg.ShowDialog() == DialogResult.OK) + { + var entry = dlg.AddEntry(); + var nodeEntry = new GroupAnimWrapper(entry.Name) { Tag = entry }; + Nodes.Add(nodeEntry); + } + } + + private void ClearGroups(object sender, EventArgs e) + { + bxlanPai.Entries.Clear(); + Nodes.Clear(); + } + } + public class GroupAnimWrapper : TreeNode, IContextMenuNode { public BxlanPaiEntry PaiEntry => (BxlanPaiEntry)Tag; @@ -112,7 +151,13 @@ namespace LayoutBXLYT private void AddGroup(object sender, EventArgs e) { - + AddGroupTypeDialog dlg = new AddGroupTypeDialog(PaiEntry); + if (dlg.ShowDialog() == DialogResult.OK) + { + var tag = dlg.AddEntry(); + var nodeEntry = new GroupWrapper(tag.Type) { Tag = tag }; + Nodes.Add(nodeEntry); + } } private void ClearGroups(object sender, EventArgs e) @@ -124,6 +169,8 @@ namespace LayoutBXLYT public class GroupWrapper : TreeNode, IContextMenuNode { + public BxlanPaiEntry ParentPaiEntry => (BxlanPaiEntry)Parent.Tag; + public BxlanPaiTag GroupTag => (BxlanPaiTag)Tag; public GroupWrapper(string text) { @@ -140,18 +187,31 @@ namespace LayoutBXLYT private void AddTarget(object sender, EventArgs e) { + AddGroupTargetDialog dlg = new AddGroupTargetDialog(); + bool canLoad = dlg.LoadTag(GroupTag); + if (dlg.ShowDialog() == DialogResult.OK && canLoad) + { + BxlanPaiTagEntry target = dlg.GetGroupTarget(); + target.Index = (byte)GroupTag.Entries.Count; + GroupTag.Entries.Add(target); + var nodeEntry = new GroupTargetWrapper(target.TargetName) { Tag = target }; + Nodes.Add(nodeEntry); + } } private void ClearTargets(object sender, EventArgs e) { - + GroupTag.Entries.Clear(); + Nodes.Clear(); } } public class GroupTargetWrapper : TreeNode, IContextMenuNode { + public BxlanPaiTag GroupTag => (BxlanPaiTag)Parent.Tag; + public BxlanPaiTagEntry TypeTag => (BxlanPaiTagEntry)Tag; public GroupTargetWrapper(string text) { @@ -161,30 +221,55 @@ namespace LayoutBXLYT public ToolStripItem[] GetContextMenuItems() { List Items = new List(); - Items.Add(new ToolStripMenuItem("Add Keyframe", null, AddeKey, Keys.Control | Keys.A)); + Items.Add(new ToolStripMenuItem("Add Keyframe", null, AddKey, Keys.Control | Keys.A)); Items.Add(new ToolStripMenuItem("Remove Target", null, RemoveTarget, Keys.Delete)); Items.Add(new ToolStripMenuItem("Clear Keys", null, RemoveKeys, Keys.Control | Keys.C)); return Items.ToArray(); } - private void AddeKey(object sender, EventArgs e) + private void AddKey(object sender, EventArgs e) { + float frame = 0; + if (TypeTag.KeyFrames.Count > 0) + frame = TypeTag.KeyFrames.Max(k => k.Frame) + 1; + var keyFrame = new KeyFrame(frame); + var keyNode = new KeyNodeWrapper($"Key Frame {TypeTag.KeyFrames.Count}") + { Tag = keyFrame }; + + TypeTag.KeyFrames.Add(keyFrame); + Nodes.Add(keyNode); } private void RemoveKeys(object sender, EventArgs e) { - + TypeTag.KeyFrames.Clear(); + Nodes.Clear(); } private void RemoveTarget(object sender, EventArgs e) { + GroupTag.Entries.Remove(TypeTag); + Parent.Nodes.Remove(this); + } + public void UpdateKeys(TreeNode removedNode) + { + int index = 0; + foreach (TreeNode node in Nodes) + { + if (node == removedNode) + continue; + + node.Text = $"Key Frame {index++}"; + } } } public class KeyNodeWrapper : TreeNode, IContextMenuNode { + public BxlanPaiTagEntry TypeTag => (BxlanPaiTagEntry)Parent.Tag; + public KeyFrame KeyFrame => (KeyFrame)Tag; public KeyNodeWrapper(string text) { @@ -194,13 +279,53 @@ namespace LayoutBXLYT public ToolStripItem[] GetContextMenuItems() { List Items = new List(); - Items.Add(new ToolStripMenuItem("Rename Actor Files (Odyssey)", null, RemoveKey, Keys.Delete)); + Items.Add(new ToolStripMenuItem("Remove Key", null, RemoveKey, Keys.Delete)); return Items.ToArray(); } private void RemoveKey(object sender, EventArgs e) { + TypeTag.KeyFrames.Remove(KeyFrame); + ((GroupTargetWrapper)Parent).UpdateKeys(this); + Parent.Nodes.Remove(this); + } + } + private void treeView1_MouseClick(object sender, MouseEventArgs e) + { + if (e.Button == MouseButtons.Left) + { + + } + } + + private void treeView1_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e) + { + if (e.Button == MouseButtons.Right) { + if (e.Node is IContextMenuNode) + { + STContextMenuStrip contextMenu = new STContextMenuStrip(); + contextMenu.Items.AddRange(((IContextMenuNode)e.Node).GetContextMenuItems()); + contextMenu.Show(Cursor.Position); + } + } + } + + private void treeView1_KeyPress(object sender, KeyEventArgs e) + { + if (treeView1.SelectedNode != null && treeView1.SelectedNode is IContextMenuNode) + { + IContextMenuNode node = (IContextMenuNode)treeView1.SelectedNode; + + var Items = node.GetContextMenuItems(); + foreach (ToolStripItem toolstrip in Items) + { + if (toolstrip is ToolStripMenuItem) + { + if (((ToolStripMenuItem)toolstrip).ShortcutKeys == e.KeyData) + toolstrip.PerformClick(); + } + } } } } diff --git a/File_Format_Library/GUI/BFLYT/Animations/Basic/LayoutAnimEditorBasic.resx b/File_Format_Library/GUI/BFLYT/Animations/Basic/LayoutAnimEditorBasic.resx new file mode 100644 index 00000000..1af7de15 --- /dev/null +++ b/File_Format_Library/GUI/BFLYT/Animations/Basic/LayoutAnimEditorBasic.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 fe5e2a5b..064f4899 100644 --- a/File_Format_Library/GUI/BFLYT/LayoutEditor.cs +++ b/File_Format_Library/GUI/BFLYT/LayoutEditor.cs @@ -51,7 +51,8 @@ namespace LayoutBXLYT { InitializeComponent(); - chkAutoKey.Hide(); + chkAutoKey.Enabled = false; + chkAutoKey.ForeColor = FormThemes.BaseTheme.FormForeColor; CustomMapper = new LayoutCustomPaneMapper(); @@ -415,7 +416,7 @@ namespace LayoutBXLYT public void ShowBxlanEditor(BxlanHeader bxlan) { LayoutAnimEditorBasic editor = new LayoutAnimEditorBasic(); - editor.LoadAnim(bxlan); + editor.LoadAnim(bxlan, ActiveLayout); editor.OnPropertyChanged += AnimPropertyChanged; editor.Show(this); @@ -1122,9 +1123,9 @@ namespace LayoutBXLYT { Runtime.LayoutEditor.AnimationEditMode = editorModeCB.SelectedIndex == 1; if (Runtime.LayoutEditor.AnimationEditMode) - chkAutoKey.Show(); + chkAutoKey.Enabled = true; else - chkAutoKey.Hide(); + chkAutoKey.Enabled = false; if (LayoutPaneEditor != null) LayoutPaneEditor.ReloadEditor(); diff --git a/File_Format_Library/GUI/Byaml/CourseMuunt/Base/BasePathGroup.cs b/File_Format_Library/GUI/Byaml/CourseMuunt/Base/BasePathGroup.cs deleted file mode 100644 index 8d32b744..00000000 --- a/File_Format_Library/GUI/Byaml/CourseMuunt/Base/BasePathGroup.cs +++ /dev/null @@ -1,11 +0,0 @@ -using System.Collections.Generic; - -namespace FirstPlugin.Turbo.CourseMuuntStructs -{ - public class BasePathGroup - { - public bool ConnectGroups = true; - - public List PathPoints = new List(); - } -} diff --git a/File_Format_Library/GUI/Byaml/CourseMuunt2D/TrackEditor2D.cs b/File_Format_Library/GUI/Byaml/CourseMuunt2D/TrackEditor2D.cs deleted file mode 100644 index e8267090..00000000 --- a/File_Format_Library/GUI/Byaml/CourseMuunt2D/TrackEditor2D.cs +++ /dev/null @@ -1,17 +0,0 @@ -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/File_Format_Library/GUI/Byaml/MuuntEditor/Interfaces/IDrawableObject.cs b/File_Format_Library/GUI/Byaml/MuuntEditor/Interfaces/IDrawableObject.cs new file mode 100644 index 00000000..6adb9dc4 --- /dev/null +++ b/File_Format_Library/GUI/Byaml/MuuntEditor/Interfaces/IDrawableObject.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using OpenTK; + +namespace FirstPlugin.MuuntEditor +{ + public interface IDrawableObject + { + void Draw(Matrix4 mvp); + } +} diff --git a/File_Format_Library/GUI/Byaml/MuuntEditor/Interfaces/IMuuntLoader.cs b/File_Format_Library/GUI/Byaml/MuuntEditor/Interfaces/IMuuntLoader.cs new file mode 100644 index 00000000..96a715c9 --- /dev/null +++ b/File_Format_Library/GUI/Byaml/MuuntEditor/Interfaces/IMuuntLoader.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace FirstPlugin.MuuntEditor +{ + public interface IMuuntLoader + { + List Groups { get; set; } + + bool Identify(dynamic byml, string fileName); + void Load(dynamic byml); + } +} diff --git a/File_Format_Library/GUI/Byaml/CourseMuunt2D/MuuntEditorDocker.cs b/File_Format_Library/GUI/Byaml/MuuntEditor/Interfaces/IdrawableContainer.cs similarity index 53% rename from File_Format_Library/GUI/Byaml/CourseMuunt2D/MuuntEditorDocker.cs rename to File_Format_Library/GUI/Byaml/MuuntEditor/Interfaces/IdrawableContainer.cs index 71c9b7af..f40d61d8 100644 --- a/File_Format_Library/GUI/Byaml/CourseMuunt2D/MuuntEditorDocker.cs +++ b/File_Format_Library/GUI/Byaml/MuuntEditor/Interfaces/IdrawableContainer.cs @@ -3,11 +3,11 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; -using WeifenLuo.WinFormsUI.Docking; -namespace FirstPlugin.Forms +namespace FirstPlugin.MuuntEditor { - public class MuuntEditorDocker : DockContent + public interface IDrawableContainer { + IDrawableObject Drawable { get; } } } diff --git a/File_Format_Library/GUI/Byaml/MuuntEditor/MapObject.cs b/File_Format_Library/GUI/Byaml/MuuntEditor/MapObject.cs new file mode 100644 index 00000000..86071e9c --- /dev/null +++ b/File_Format_Library/GUI/Byaml/MuuntEditor/MapObject.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.ComponentModel; + +namespace FirstPlugin.MuuntEditor +{ + public class MapObject : PropertyObject + { + public IDrawableObject Drawable { get; set; } + } +} diff --git a/File_Format_Library/GUI/Byaml/CourseMuunt2D/MuuntEditor.Designer.cs b/File_Format_Library/GUI/Byaml/MuuntEditor/MuuntEditor.Designer.cs similarity index 94% rename from File_Format_Library/GUI/Byaml/CourseMuunt2D/MuuntEditor.Designer.cs rename to File_Format_Library/GUI/Byaml/MuuntEditor/MuuntEditor.Designer.cs index 51a88ced..df5c85f5 100644 --- a/File_Format_Library/GUI/Byaml/CourseMuunt2D/MuuntEditor.Designer.cs +++ b/File_Format_Library/GUI/Byaml/MuuntEditor/MuuntEditor.Designer.cs @@ -1,4 +1,4 @@ -namespace FirstPlugin.Forms +namespace FirstPlugin.MuuntEditor { partial class MuuntEditor { @@ -31,12 +31,12 @@ 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.editToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.viewToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.toggle3DViewToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.stToolStrip1 = new Toolbox.Library.Forms.STToolStrip(); this.toolStripButton1 = new System.Windows.Forms.ToolStripButton(); this.stMenuStrip1.SuspendLayout(); @@ -48,9 +48,9 @@ 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.Location = new System.Drawing.Point(0, 48); this.dockPanel1.Name = "dockPanel1"; - this.dockPanel1.Size = new System.Drawing.Size(471, 363); + this.dockPanel1.Size = new System.Drawing.Size(574, 349); this.dockPanel1.TabIndex = 0; // // stMenuStrip1 @@ -62,7 +62,7 @@ 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.Size = new System.Drawing.Size(574, 24); this.stMenuStrip1.TabIndex = 2; this.stMenuStrip1.Text = "stMenuStrip1"; // @@ -76,6 +76,24 @@ this.fileToolStripMenuItem.Size = new System.Drawing.Size(37, 20); this.fileToolStripMenuItem.Text = "File"; // + // openToolStripMenuItem + // + this.openToolStripMenuItem.Name = "openToolStripMenuItem"; + this.openToolStripMenuItem.Size = new System.Drawing.Size(114, 22); + this.openToolStripMenuItem.Text = "Open"; + // + // saveToolStripMenuItem + // + this.saveToolStripMenuItem.Name = "saveToolStripMenuItem"; + this.saveToolStripMenuItem.Size = new System.Drawing.Size(114, 22); + this.saveToolStripMenuItem.Text = "Save"; + // + // saveAsToolStripMenuItem + // + this.saveAsToolStripMenuItem.Name = "saveAsToolStripMenuItem"; + this.saveAsToolStripMenuItem.Size = new System.Drawing.Size(114, 22); + this.saveAsToolStripMenuItem.Text = "Save As"; + // // editToolStripMenuItem // this.editToolStripMenuItem.Name = "editToolStripMenuItem"; @@ -93,27 +111,9 @@ // toggle3DViewToolStripMenuItem // this.toggle3DViewToolStripMenuItem.Name = "toggle3DViewToolStripMenuItem"; - this.toggle3DViewToolStripMenuItem.Size = new System.Drawing.Size(180, 22); + this.toggle3DViewToolStripMenuItem.Size = new System.Drawing.Size(155, 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; @@ -121,7 +121,7 @@ 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.Size = new System.Drawing.Size(574, 25); this.stToolStrip1.TabIndex = 3; this.stToolStrip1.Text = "stToolStrip1"; // @@ -138,13 +138,14 @@ // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(471, 412); + this.ClientSize = new System.Drawing.Size(574, 394); this.Controls.Add(this.stToolStrip1); this.Controls.Add(this.dockPanel1); this.Controls.Add(this.stMenuStrip1); + this.IsMdiContainer = true; this.MainMenuStrip = this.stMenuStrip1; this.Name = "MuuntEditor"; - this.Text = "MarioKartMuuntEditor"; + this.Text = "Map Unit Editor"; this.stMenuStrip1.ResumeLayout(false); this.stMenuStrip1.PerformLayout(); this.stToolStrip1.ResumeLayout(false); diff --git a/File_Format_Library/GUI/Byaml/MuuntEditor/MuuntEditor.cs b/File_Format_Library/GUI/Byaml/MuuntEditor/MuuntEditor.cs new file mode 100644 index 00000000..dc8e9352 --- /dev/null +++ b/File_Format_Library/GUI/Byaml/MuuntEditor/MuuntEditor.cs @@ -0,0 +1,109 @@ +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; +using FirstPlugin; + +namespace FirstPlugin.MuuntEditor +{ + public partial class MuuntEditor : Form + { + public List Groups = new List(); + public EventHandler ObjectSelected; + + private List Plugins = new List(); + + private dynamic ActiveByml; + + private MuuntEditor2D Viewport2D; + private MuuntObjectList ObjectList; + private MuuntPropertiesEditor PropertiesEditor; + + public MuuntEditor() + { + InitializeComponent(); + + ThemeBase theme = new VS2015DarkTheme(); + if (FormThemes.ActivePreset == FormThemes.Preset.White) + theme = new VS2015LightTheme(); + + this.dockPanel1.Theme = theme; + this.dockPanel1.BackColor = FormThemes.BaseTheme.FormBackColor; + this.BackColor = FormThemes.BaseTheme.FormBackColor; + + Plugins.Add(new TrackMuuntLoader()); + + ObjectSelected += OnObjectSelected; + } + + public void LoadByaml(dynamic byml, string fileName) { + ActiveByml = byml; + LoadPlugins(byml, fileName); + + LoadPanels(); + } + + private void LoadPanels() + { + ShowObjectList(); + ShowPropertiesEditor(); + } + + private void LoadPlugins(dynamic byml, string fileName) + { + for (int i = 0; i < Plugins.Count; i++) { + if (Plugins[i].Identify(byml, fileName)) { + Plugins[i].Load(byml); + Groups = Plugins[i].Groups; + } + } + + LoadViewport(); + } + + private void LoadViewport() + { + DockContent dockContent = new DockContent(); + Viewport2D = new MuuntEditor2D(this); + Viewport2D.Dock = DockStyle.Fill; + dockContent.Controls.Add(Viewport2D); + + dockContent.Show(dockPanel1, DockState.Document); + dockContent.DockHandler.AllowEndUserDocking = false; + } + + private void ShowObjectList() + { + if (ObjectList != null) + return; + + ObjectList = new MuuntObjectList(this); + ObjectList.LoadObjects(Groups); + ObjectList.Show(dockPanel1, DockState.DockLeft); + } + + private void ShowPropertiesEditor() + { + if (PropertiesEditor != null) + return; + + PropertiesEditor = new MuuntPropertiesEditor(this); + + if (ObjectList != null) + PropertiesEditor.Show(ObjectList.Pane, DockAlignment.Bottom, 0.5); + PropertiesEditor.Show(dockPanel1, DockState.DockLeft); + } + + private void OnObjectSelected(object sender, EventArgs e) + { + + } + } +} diff --git a/File_Format_Library/GUI/Byaml/CourseMuunt2D/MuuntEditor.resx b/File_Format_Library/GUI/Byaml/MuuntEditor/MuuntEditor.resx similarity index 100% rename from File_Format_Library/GUI/Byaml/CourseMuunt2D/MuuntEditor.resx rename to File_Format_Library/GUI/Byaml/MuuntEditor/MuuntEditor.resx diff --git a/File_Format_Library/GUI/Byaml/MuuntEditor/MuuntEditor2D.cs b/File_Format_Library/GUI/Byaml/MuuntEditor/MuuntEditor2D.cs new file mode 100644 index 00000000..ec0c1258 --- /dev/null +++ b/File_Format_Library/GUI/Byaml/MuuntEditor/MuuntEditor2D.cs @@ -0,0 +1,52 @@ +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.MuuntEditor +{ + public class MuuntEditor2D : Viewport2D + { + private MuuntEditor ParentEditor; + + public MuuntEditor2D(MuuntEditor editor) + { + ParentEditor = editor; + } + + public override void RenderSceme() + { + foreach (var group in ParentEditor.Groups) + { + if (group is IDrawableContainer) + ((IDrawableContainer)group).Drawable?.Draw(Camera.ModelMatrix); + } + } + + public override List GetPickableObjects() + { + List picks = new List(); + foreach (var group in ParentEditor.Groups) + { + foreach (var obj in group.Objects) + { + if (obj is IPickable2DObject) + picks.Add((IPickable2DObject)obj); + + foreach (var subobj in obj.SubObjects) + { + if (subobj is IPickable2DObject) + picks.Add((IPickable2DObject)subobj); + } + } + } + + return picks; + } + } +} diff --git a/File_Format_Library/GUI/Byaml/MuuntEditor/MuuntEditorDocker.cs b/File_Format_Library/GUI/Byaml/MuuntEditor/MuuntEditorDocker.cs new file mode 100644 index 00000000..fe0a7cc0 --- /dev/null +++ b/File_Format_Library/GUI/Byaml/MuuntEditor/MuuntEditorDocker.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using WeifenLuo.WinFormsUI.Docking; +using Toolbox.Library.Forms; + +namespace FirstPlugin.MuuntEditor +{ + public class MuuntEditorDocker : DockContent + { + public MuuntEditorDocker() + { + BackColor = FormThemes.BaseTheme.FormBackColor; + ForeColor = FormThemes.BaseTheme.FormForeColor; + } + } +} diff --git a/File_Format_Library/GUI/Byaml/MuuntEditor/MuuntObjectList.Designer.cs b/File_Format_Library/GUI/Byaml/MuuntEditor/MuuntObjectList.Designer.cs new file mode 100644 index 00000000..3293c4d6 --- /dev/null +++ b/File_Format_Library/GUI/Byaml/MuuntEditor/MuuntObjectList.Designer.cs @@ -0,0 +1,79 @@ +namespace FirstPlugin.MuuntEditor +{ + partial class MuuntObjectList + { + /// + /// 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.stComboBox1 = new Toolbox.Library.Forms.STComboBox(); + this.listViewCustom1 = new Toolbox.Library.Forms.ListViewCustom(); + this.SuspendLayout(); + // + // stComboBox1 + // + this.stComboBox1.BorderColor = System.Drawing.Color.Empty; + this.stComboBox1.BorderStyle = System.Windows.Forms.ButtonBorderStyle.Solid; + this.stComboBox1.ButtonColor = System.Drawing.Color.Empty; + this.stComboBox1.FormattingEnabled = true; + this.stComboBox1.IsReadOnly = false; + this.stComboBox1.Location = new System.Drawing.Point(12, 12); + this.stComboBox1.Name = "stComboBox1"; + this.stComboBox1.Size = new System.Drawing.Size(257, 21); + this.stComboBox1.TabIndex = 0; + // + // listViewCustom1 + // + this.listViewCustom1.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.listViewCustom1.BorderStyle = System.Windows.Forms.BorderStyle.None; + this.listViewCustom1.HideSelection = false; + this.listViewCustom1.Location = new System.Drawing.Point(12, 39); + this.listViewCustom1.Name = "listViewCustom1"; + this.listViewCustom1.OwnerDraw = true; + this.listViewCustom1.Size = new System.Drawing.Size(257, 265); + this.listViewCustom1.TabIndex = 1; + this.listViewCustom1.UseCompatibleStateImageBehavior = false; + // + // MuuntObjectList + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(281, 316); + this.Controls.Add(this.listViewCustom1); + this.Controls.Add(this.stComboBox1); + this.Name = "MuuntObjectList"; + this.Text = "MuuntObjectList"; + this.ResumeLayout(false); + + } + + #endregion + + private Toolbox.Library.Forms.STComboBox stComboBox1; + private Toolbox.Library.Forms.ListViewCustom listViewCustom1; + } +} \ No newline at end of file diff --git a/File_Format_Library/GUI/Byaml/MuuntEditor/MuuntObjectList.cs b/File_Format_Library/GUI/Byaml/MuuntEditor/MuuntObjectList.cs new file mode 100644 index 00000000..20829476 --- /dev/null +++ b/File_Format_Library/GUI/Byaml/MuuntEditor/MuuntObjectList.cs @@ -0,0 +1,31 @@ +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; + +namespace FirstPlugin.MuuntEditor +{ + public partial class MuuntObjectList : MuuntEditorDocker + { + private MuuntEditor ParentEditor; + + public MuuntObjectList(MuuntEditor editor) + { + InitializeComponent(); + ParentEditor = editor; + } + + public void LoadObjects(List groups) + { + for (int i = 0; i < groups.Count; i++) + { + stComboBox1.Items.Add(groups[i].Name); + } + } + } +} diff --git a/File_Format_Library/GUI/Byaml/MuuntEditor/MuuntObjectList.resx b/File_Format_Library/GUI/Byaml/MuuntEditor/MuuntObjectList.resx new file mode 100644 index 00000000..1af7de15 --- /dev/null +++ b/File_Format_Library/GUI/Byaml/MuuntEditor/MuuntObjectList.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/Byaml/MuuntEditor/MuuntPropertiesEditor.Designer.cs b/File_Format_Library/GUI/Byaml/MuuntEditor/MuuntPropertiesEditor.Designer.cs new file mode 100644 index 00000000..e3d90414 --- /dev/null +++ b/File_Format_Library/GUI/Byaml/MuuntEditor/MuuntPropertiesEditor.Designer.cs @@ -0,0 +1,46 @@ +namespace FirstPlugin.MuuntEditor +{ + partial class MuuntPropertiesEditor + { + /// + /// 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.SuspendLayout(); + // + // MuuntPropertiesEditor + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(395, 314); + this.Name = "MuuntPropertiesEditor"; + this.Text = "Properties Editor"; + this.ResumeLayout(false); + + } + + #endregion + } +} \ No newline at end of file diff --git a/File_Format_Library/GUI/Byaml/CourseMuunt2D/MuuntEditor.cs b/File_Format_Library/GUI/Byaml/MuuntEditor/MuuntPropertiesEditor.cs similarity index 55% rename from File_Format_Library/GUI/Byaml/CourseMuunt2D/MuuntEditor.cs rename to File_Format_Library/GUI/Byaml/MuuntEditor/MuuntPropertiesEditor.cs index c8ecf4e1..e6cea57f 100644 --- a/File_Format_Library/GUI/Byaml/CourseMuunt2D/MuuntEditor.cs +++ b/File_Format_Library/GUI/Byaml/MuuntEditor/MuuntPropertiesEditor.cs @@ -7,16 +7,17 @@ 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 +namespace FirstPlugin.MuuntEditor { - public partial class MuuntEditor : Form + public partial class MuuntPropertiesEditor : MuuntEditorDocker { - public MuuntEditor() + private MuuntEditor ParentEditor; + + public MuuntPropertiesEditor(MuuntEditor editor) { InitializeComponent(); + ParentEditor = editor; } } } diff --git a/File_Format_Library/GUI/Byaml/MuuntEditor/MuuntPropertiesEditor.resx b/File_Format_Library/GUI/Byaml/MuuntEditor/MuuntPropertiesEditor.resx new file mode 100644 index 00000000..1af7de15 --- /dev/null +++ b/File_Format_Library/GUI/Byaml/MuuntEditor/MuuntPropertiesEditor.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/Byaml/MuuntEditor/ObjectGroup.cs b/File_Format_Library/GUI/Byaml/MuuntEditor/ObjectGroup.cs new file mode 100644 index 00000000..1710b03f --- /dev/null +++ b/File_Format_Library/GUI/Byaml/MuuntEditor/ObjectGroup.cs @@ -0,0 +1,32 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace FirstPlugin.MuuntEditor +{ + public class ObjectGroup + { + public ObjectGroup() { } + + public ObjectGroup(string name) { + Name = name; + } + + public ObjectGroup(string name, PropertyObject property) { + Name = name; + Objects.Add(property); + } + + /// + /// Name of the group. + /// + public string Name { get; set; } + + /// + /// List of properties in the group. + /// + public virtual List Objects { get; } = new List(); + } +} diff --git a/File_Format_Library/GUI/Byaml/MuuntEditor/Plugins/MK8/PathDrawableContainer.cs b/File_Format_Library/GUI/Byaml/MuuntEditor/Plugins/MK8/PathDrawableContainer.cs new file mode 100644 index 00000000..899e455c --- /dev/null +++ b/File_Format_Library/GUI/Byaml/MuuntEditor/Plugins/MK8/PathDrawableContainer.cs @@ -0,0 +1,39 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using FirstPlugin.Turbo.CourseMuuntStructs; + +namespace FirstPlugin.MuuntEditor +{ + public class PathDrawableContainer : ObjectGroup, IDrawableContainer + { + public PathDrawableContainer(string name) { + Name = name; + } + + public List PathGroups + { + get + { + var groups = new List(); + foreach (var group in Objects) + groups.Add((BasePathGroup)group); + return groups; + } + } + + private IDrawableObject drawable; + public IDrawableObject Drawable + { + get + { + if (drawable == null) + drawable = new RenderablePath(PathGroups); + + return drawable; + } + } + } +} diff --git a/File_Format_Library/GUI/Byaml/MuuntEditor/Plugins/MK8/TrackMuuntLoader.cs b/File_Format_Library/GUI/Byaml/MuuntEditor/Plugins/MK8/TrackMuuntLoader.cs new file mode 100644 index 00000000..d2b208df --- /dev/null +++ b/File_Format_Library/GUI/Byaml/MuuntEditor/Plugins/MK8/TrackMuuntLoader.cs @@ -0,0 +1,50 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using FirstPlugin.Turbo.CourseMuuntStructs; +using FirstPlugin.Turbo; + +namespace FirstPlugin.MuuntEditor +{ + public class TrackMuuntLoader : IMuuntLoader + { + public List Groups { get; set; } + + public bool Identify(dynamic byml, string fileName) + { + return fileName.Contains("_muunt"); + } + + public void Load(dynamic byml) + { + var courseMuunt = new CourseMuuntScene(byml); + + Groups = new List(); + Groups.Add(new ObjectGroup("Scene Properties", new PropertyObject() + { + Name = "", + Prop = (Dictionary)byml, + })); + + PathDrawableContainer lapPaths = new PathDrawableContainer("Lap Paths"); + PathDrawableContainer enemyPaths = new PathDrawableContainer("Enemy Paths"); + Groups.Add(lapPaths); + Groups.Add(enemyPaths); + + for (int i = 0; i < courseMuunt.LapPaths.Count; i++) + { + courseMuunt.LapPaths[i].Name = $"Group [{i}]"; + lapPaths.Objects.Add(courseMuunt.LapPaths[i]); + } + + for (int i = 0; i < courseMuunt.EnemyPaths.Count; i++) + { + courseMuunt.EnemyPaths[i].Name = $"Group [{i}]"; + enemyPaths.Objects.Add(courseMuunt.EnemyPaths[i]); + } + + } + } +} diff --git a/File_Format_Library/GUI/Byaml/MuuntEditor/PropertyGridConverters.cs b/File_Format_Library/GUI/Byaml/MuuntEditor/PropertyGridConverters.cs new file mode 100644 index 00000000..b2b7babd --- /dev/null +++ b/File_Format_Library/GUI/Byaml/MuuntEditor/PropertyGridConverters.cs @@ -0,0 +1,268 @@ +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using System.ComponentModel; +using System.Collections; +using System.Linq; + +namespace FirstPlugin.MuuntEditor +{ + public class PropertyGridTypes + { + public static Dictionary CustomClassConverter = new Dictionary(); + + public static class GetTypeConv + { + public static TypeConverter Get(string _key, dynamic _obj) + { + if (_obj == null) return new NullConverter(); + else if (CustomClassConverter.ContainsKey(_obj.GetType())) + return Activator.CreateInstance(CustomClassConverter[_obj.GetType()]); + else if (_obj is IDictionary) + { + if (_obj.Keys.Count == 3 && _obj.ContainsKey("X") && _obj.ContainsKey("Y") && _obj.ContainsKey("Z")) return new Vector3DDictionaryConverter(); + return new DictionaryConverter(); + } + else if (_obj is IList) return new ArrayNodeConverter(); + else return TypeDescriptor.GetConverter(_obj); + } + } + + public class NullConverter : System.ComponentModel.TypeConverter + { + public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext context, Type sourceType) + { + return false; + } + + public override object ConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value) + { + return (string)value; + } + + public override object ConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destinationType) + { + return ""; + } + } + + public class Vector3DDictionaryConverter : System.ComponentModel.TypeConverter + { + public override bool GetPropertiesSupported(ITypeDescriptorContext context) => true; + + public override PropertyDescriptorCollection GetProperties(ITypeDescriptorContext context, object value, Attribute[] attributes) + { + ArrayList properties = new ArrayList(); + foreach (string e in ((Dictionary)value).Keys) + { + properties.Add(new DictionaryConverter.DictionaryPropertyDescriptor((Dictionary)value, e)); + } + + PropertyDescriptor[] props = + (PropertyDescriptor[])properties.ToArray(typeof(PropertyDescriptor)); + + return new PropertyDescriptorCollection(props); + } + + public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext context, Type sourceType) => sourceType == typeof(string); + + public override object ConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value) + { + string[] tokens = ((string)value).Split(';'); + IDictionary dict = new Dictionary(); + dict["X"] = Single.Parse(tokens[0]); + dict["Y"] = Single.Parse(tokens[1]); + dict["Z"] = Single.Parse(tokens[2]); + return dict; + } + + public override object ConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destinationType) + { + var v = value as IDictionary; + if (v == null) //MultiMergeCollection workaround + { + var values = new float[3]; + int count = 0; + foreach (object o in (ICollection)value) + values[count++] = ((KeyValuePair)o).Value; + return $"{Math.Round(values[0], 2)}; {Math.Round(values[1], 2)}; {Math.Round(values[2], 2)}"; + } + return $"{Math.Round(v["X"], 2)}; {Math.Round(v["Y"], 2)}; {Math.Round(v["Z"], 2)}"; + } + } + + public class DictionaryConverter : System.ComponentModel.TypeConverter + { + public override bool GetPropertiesSupported(ITypeDescriptorContext context) + { + return true; + } + + public override object ConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destinationType) + { + return ""; + } + + public override PropertyDescriptorCollection GetProperties(ITypeDescriptorContext context, object value, Attribute[] attributes) + { + ArrayList properties = new ArrayList(); + foreach (string e in ((Dictionary)value).Keys) + { + properties.Add(new DictionaryPropertyDescriptor((Dictionary)value, e)); + } + + PropertyDescriptor[] props = + (PropertyDescriptor[])properties.ToArray(typeof(PropertyDescriptor)); + + return new PropertyDescriptorCollection(props); + } + + public class DictionaryPropertyDescriptor : PropertyDescriptor //TODO Fix JIS encoding + { + IDictionary _dictionary; + string _key; + + public override TypeConverter Converter + { + get + { + return GetTypeConv.Get(_key, _dictionary[_key]); + } + } + + internal DictionaryPropertyDescriptor(IDictionary d, string key) + : base(key, null) + { + _dictionary = d; + _key = key; + } + + public override Type PropertyType + { + get { return _dictionary[_key] == null ? typeof(string) : _dictionary[_key].GetType(); } + } + + public override void SetValue(object component, object value) + { + _dictionary[_key] = value; + } + + public override object GetValue(object component) + { + return _dictionary[_key]; + } + + public override bool IsReadOnly + { + get { return false; } + } + + public override Type ComponentType + { + get { return null; } + } + + public override bool CanResetValue(object component) + { + return false; + } + + public override void ResetValue(object component) + { + } + + public override bool ShouldSerializeValue(object component) + { + return false; + } + } + } + + public class ArrayNodeConverter : System.ComponentModel.TypeConverter + { + public override object ConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destinationType) + { + return ""; + } + + public override bool GetPropertiesSupported(ITypeDescriptorContext context) + { + return true; + } + + public override PropertyDescriptorCollection GetProperties(ITypeDescriptorContext context, object value, Attribute[] attributes) + { + ArrayList properties = new ArrayList(); + for (int i = 0; i < ((List)value).Count; i++) + { + properties.Add(new ArrayPropertyDescriptor(((List)value)[i], "Item " + i.ToString() + " :")); + } + + PropertyDescriptor[] props = + (PropertyDescriptor[])properties.ToArray(typeof(PropertyDescriptor)); + + return new PropertyDescriptorCollection(props); + } + + public class ArrayPropertyDescriptor : PropertyDescriptor //TODO Fix JIS encoding + { + dynamic _obj; + string _key; + + public override TypeConverter Converter + { + get + { + return GetTypeConv.Get(_key, _obj); + } + } + + internal ArrayPropertyDescriptor(dynamic obj, string key) + : base(key, null) + { + _obj = obj; + _key = key; + } + + public override Type PropertyType + { + get { return _obj == null ? typeof(string) : _obj.GetType(); } + } + + public override void SetValue(object component, object value) + { + _obj = value; + } + + public override object GetValue(object component) + { + return _obj; + } + + public override bool IsReadOnly + { + get { return false; } + } + + public override Type ComponentType + { + get { return null; } + } + + public override bool CanResetValue(object component) + { + return false; + } + + public override void ResetValue(object component) + { + } + + public override bool ShouldSerializeValue(object component) + { + return false; + } + } + } + } +} diff --git a/File_Format_Library/GUI/Byaml/MuuntEditor/PropertyObject.cs b/File_Format_Library/GUI/Byaml/MuuntEditor/PropertyObject.cs new file mode 100644 index 00000000..df3f245f --- /dev/null +++ b/File_Format_Library/GUI/Byaml/MuuntEditor/PropertyObject.cs @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.ComponentModel; + +namespace FirstPlugin.MuuntEditor +{ + public class PropertyObject + { + /// + /// Child properties to be added to the tree. + /// + public virtual List SubObjects { get; } = new List(); + + /// + /// The name of the property + /// + public string Name { get; set; } + + [TypeConverter(typeof(PropertyGridTypes.DictionaryConverter))] + public Dictionary Prop { get; set; } + } +} diff --git a/File_Format_Library/GUI/Byaml/CourseMuunt/Base/BaseControlPoint.cs b/File_Format_Library/GUI/Byaml/TurboCourseMuunt/Base/BaseControlPoint.cs similarity index 100% rename from File_Format_Library/GUI/Byaml/CourseMuunt/Base/BaseControlPoint.cs rename to File_Format_Library/GUI/Byaml/TurboCourseMuunt/Base/BaseControlPoint.cs diff --git a/File_Format_Library/GUI/Byaml/CourseMuunt/Base/BaseObjPt.cs b/File_Format_Library/GUI/Byaml/TurboCourseMuunt/Base/BaseObjPt.cs similarity index 100% rename from File_Format_Library/GUI/Byaml/CourseMuunt/Base/BaseObjPt.cs rename to File_Format_Library/GUI/Byaml/TurboCourseMuunt/Base/BaseObjPt.cs diff --git a/File_Format_Library/GUI/Byaml/TurboCourseMuunt/Base/BasePathGroup.cs b/File_Format_Library/GUI/Byaml/TurboCourseMuunt/Base/BasePathGroup.cs new file mode 100644 index 00000000..5ddb1167 --- /dev/null +++ b/File_Format_Library/GUI/Byaml/TurboCourseMuunt/Base/BasePathGroup.cs @@ -0,0 +1,22 @@ +using System.Collections.Generic; +using FirstPlugin.MuuntEditor; + +namespace FirstPlugin.Turbo.CourseMuuntStructs +{ + public class BasePathGroup : PropertyObject + { + public bool ConnectGroups = true; + + public List PathPoints = new List(); + + public override List SubObjects + { + get { + var props = new List(); + foreach (var path in PathPoints) + props.Add(path); + return props; + } + } + } +} diff --git a/File_Format_Library/GUI/Byaml/CourseMuunt/Base/BasePathPoint.cs b/File_Format_Library/GUI/Byaml/TurboCourseMuunt/Base/BasePathPoint.cs similarity index 76% rename from File_Format_Library/GUI/Byaml/CourseMuunt/Base/BasePathPoint.cs rename to File_Format_Library/GUI/Byaml/TurboCourseMuunt/Base/BasePathPoint.cs index 4c73d64b..0272e9d7 100644 --- a/File_Format_Library/GUI/Byaml/CourseMuunt/Base/BasePathPoint.cs +++ b/File_Format_Library/GUI/Byaml/TurboCourseMuunt/Base/BasePathPoint.cs @@ -3,10 +3,12 @@ using System.Collections.Generic; using System.ComponentModel; using OpenTK; using GL_EditorFramework.EditorDrawables; +using FirstPlugin.MuuntEditor; +using Toolbox.Library; namespace FirstPlugin.Turbo.CourseMuuntStructs { - public class BasePathPoint : IObject + public class BasePathPoint : PropertyObject, IObject, IPickable2DObject { public Action OnPathMoved; @@ -20,15 +22,51 @@ namespace FirstPlugin.Turbo.CourseMuuntStructs } } + public bool IsSelected { get; set; } + public bool IsHovered { get; set; } + + public bool IsHit(float X, float Y) + { + return new STRectangle(Translate.X, Translate.Z, 40, 40).IsHit((int)X, (int)Y); + + for (int i = 0; i <= 300; i++) + { + double angle = 2 * Math.PI * i / 300; + double x = Math.Cos(angle); + double y = Math.Sin(angle); + + if (angle < 90) + { + + } + if (angle < 90 && angle < 180) + { + + } + if (angle < 270) + { + + } + if (angle < 360) + { + + } + } + + return false; + } + + public void PickTranslate(float X, float Y, float Z) + { + Translate = new Vector3(X, Y, Z); + } + public const string N_Translate = "Translate"; public const string N_Rotate = "Rotate"; public const string N_Scale = "Scale"; public const string N_Id = "UnitIdNum"; public const string N_ObjectID = "ObjId"; - [Browsable(false)] - public Dictionary Prop { get; set; } = new Dictionary(); - public dynamic this[string name] { get diff --git a/File_Format_Library/GUI/Byaml/CourseMuunt/Base/PointID.cs b/File_Format_Library/GUI/Byaml/TurboCourseMuunt/Base/PointID.cs similarity index 100% rename from File_Format_Library/GUI/Byaml/CourseMuunt/Base/PointID.cs rename to File_Format_Library/GUI/Byaml/TurboCourseMuunt/Base/PointID.cs diff --git a/File_Format_Library/GUI/Byaml/CourseMuunt/Base/RenderableConnectedMapPoints.cs b/File_Format_Library/GUI/Byaml/TurboCourseMuunt/Base/RenderableConnectedMapPoints.cs similarity index 100% rename from File_Format_Library/GUI/Byaml/CourseMuunt/Base/RenderableConnectedMapPoints.cs rename to File_Format_Library/GUI/Byaml/TurboCourseMuunt/Base/RenderableConnectedMapPoints.cs diff --git a/File_Format_Library/GUI/Byaml/CourseMuunt/Base/RenderablePathPoint.cs b/File_Format_Library/GUI/Byaml/TurboCourseMuunt/Base/RenderablePathPoint.cs similarity index 100% rename from File_Format_Library/GUI/Byaml/CourseMuunt/Base/RenderablePathPoint.cs rename to File_Format_Library/GUI/Byaml/TurboCourseMuunt/Base/RenderablePathPoint.cs diff --git a/File_Format_Library/GUI/Byaml/CourseMuunt/CourseMuuntStructs.cs b/File_Format_Library/GUI/Byaml/TurboCourseMuunt/CourseMuuntStructs.cs similarity index 100% rename from File_Format_Library/GUI/Byaml/CourseMuunt/CourseMuuntStructs.cs rename to File_Format_Library/GUI/Byaml/TurboCourseMuunt/CourseMuuntStructs.cs diff --git a/File_Format_Library/GUI/Byaml/CourseMuunt/IObject.cs b/File_Format_Library/GUI/Byaml/TurboCourseMuunt/IObject.cs similarity index 100% rename from File_Format_Library/GUI/Byaml/CourseMuunt/IObject.cs rename to File_Format_Library/GUI/Byaml/TurboCourseMuunt/IObject.cs diff --git a/File_Format_Library/GUI/Byaml/CourseMuunt/IntroCamera.cs b/File_Format_Library/GUI/Byaml/TurboCourseMuunt/IntroCamera.cs similarity index 100% rename from File_Format_Library/GUI/Byaml/CourseMuunt/IntroCamera.cs rename to File_Format_Library/GUI/Byaml/TurboCourseMuunt/IntroCamera.cs diff --git a/File_Format_Library/GUI/Byaml/CourseMuunt/Paths/EnemyPaths.cs b/File_Format_Library/GUI/Byaml/TurboCourseMuunt/Paths/EnemyPaths.cs similarity index 95% rename from File_Format_Library/GUI/Byaml/CourseMuunt/Paths/EnemyPaths.cs rename to File_Format_Library/GUI/Byaml/TurboCourseMuunt/Paths/EnemyPaths.cs index a5f8cc97..7fcc2f80 100644 --- a/File_Format_Library/GUI/Byaml/CourseMuunt/Paths/EnemyPaths.cs +++ b/File_Format_Library/GUI/Byaml/TurboCourseMuunt/Paths/EnemyPaths.cs @@ -27,9 +27,6 @@ namespace FirstPlugin.Turbo.CourseMuuntStructs } } - [Browsable(false)] - public Dictionary Prop { get; set; } = new Dictionary(); - public int EnemyPathGroupId { get { return this[N_EnemyPathGroup] != null ? this[N_EnemyPathGroup] : -1; } diff --git a/File_Format_Library/GUI/Byaml/CourseMuunt/Paths/GliderPaths.cs b/File_Format_Library/GUI/Byaml/TurboCourseMuunt/Paths/GliderPaths.cs similarity index 100% rename from File_Format_Library/GUI/Byaml/CourseMuunt/Paths/GliderPaths.cs rename to File_Format_Library/GUI/Byaml/TurboCourseMuunt/Paths/GliderPaths.cs diff --git a/File_Format_Library/GUI/Byaml/CourseMuunt/Paths/GravityPaths.cs b/File_Format_Library/GUI/Byaml/TurboCourseMuunt/Paths/GravityPaths.cs similarity index 100% rename from File_Format_Library/GUI/Byaml/CourseMuunt/Paths/GravityPaths.cs rename to File_Format_Library/GUI/Byaml/TurboCourseMuunt/Paths/GravityPaths.cs diff --git a/File_Format_Library/GUI/Byaml/CourseMuunt/Paths/ItemPaths.cs b/File_Format_Library/GUI/Byaml/TurboCourseMuunt/Paths/ItemPaths.cs similarity index 100% rename from File_Format_Library/GUI/Byaml/CourseMuunt/Paths/ItemPaths.cs rename to File_Format_Library/GUI/Byaml/TurboCourseMuunt/Paths/ItemPaths.cs diff --git a/File_Format_Library/GUI/Byaml/CourseMuunt/Paths/JugemPath.cs b/File_Format_Library/GUI/Byaml/TurboCourseMuunt/Paths/JugemPath.cs similarity index 100% rename from File_Format_Library/GUI/Byaml/CourseMuunt/Paths/JugemPath.cs rename to File_Format_Library/GUI/Byaml/TurboCourseMuunt/Paths/JugemPath.cs diff --git a/File_Format_Library/GUI/Byaml/CourseMuunt/Paths/LapPaths.cs b/File_Format_Library/GUI/Byaml/TurboCourseMuunt/Paths/LapPaths.cs similarity index 100% rename from File_Format_Library/GUI/Byaml/CourseMuunt/Paths/LapPaths.cs rename to File_Format_Library/GUI/Byaml/TurboCourseMuunt/Paths/LapPaths.cs diff --git a/File_Format_Library/GUI/Byaml/CourseMuunt/Paths/ObjPath.cs b/File_Format_Library/GUI/Byaml/TurboCourseMuunt/Paths/ObjPath.cs similarity index 100% rename from File_Format_Library/GUI/Byaml/CourseMuunt/Paths/ObjPath.cs rename to File_Format_Library/GUI/Byaml/TurboCourseMuunt/Paths/ObjPath.cs diff --git a/File_Format_Library/GUI/Byaml/CourseMuunt/Paths/Paths.cs b/File_Format_Library/GUI/Byaml/TurboCourseMuunt/Paths/Paths.cs similarity index 100% rename from File_Format_Library/GUI/Byaml/CourseMuunt/Paths/Paths.cs rename to File_Format_Library/GUI/Byaml/TurboCourseMuunt/Paths/Paths.cs diff --git a/File_Format_Library/GUI/Byaml/CourseMuunt/Paths/PullPath.cs b/File_Format_Library/GUI/Byaml/TurboCourseMuunt/Paths/PullPath.cs similarity index 100% rename from File_Format_Library/GUI/Byaml/CourseMuunt/Paths/PullPath.cs rename to File_Format_Library/GUI/Byaml/TurboCourseMuunt/Paths/PullPath.cs diff --git a/File_Format_Library/GUI/Byaml/CourseMuunt/Paths/RenderableConnectedPaths.cs b/File_Format_Library/GUI/Byaml/TurboCourseMuunt/Paths/RenderableConnectedPaths.cs similarity index 100% rename from File_Format_Library/GUI/Byaml/CourseMuunt/Paths/RenderableConnectedPaths.cs rename to File_Format_Library/GUI/Byaml/TurboCourseMuunt/Paths/RenderableConnectedPaths.cs diff --git a/File_Format_Library/GUI/Byaml/CourseMuunt/Paths/ReturnPoint.cs b/File_Format_Library/GUI/Byaml/TurboCourseMuunt/Paths/ReturnPoint.cs similarity index 100% rename from File_Format_Library/GUI/Byaml/CourseMuunt/Paths/ReturnPoint.cs rename to File_Format_Library/GUI/Byaml/TurboCourseMuunt/Paths/ReturnPoint.cs diff --git a/File_Format_Library/GUI/Byaml/CourseMuunt/Paths/SteerAssistPath.cs b/File_Format_Library/GUI/Byaml/TurboCourseMuunt/Paths/SteerAssistPath.cs similarity index 100% rename from File_Format_Library/GUI/Byaml/CourseMuunt/Paths/SteerAssistPath.cs rename to File_Format_Library/GUI/Byaml/TurboCourseMuunt/Paths/SteerAssistPath.cs diff --git a/File_Format_Library/GUI/Byaml/TurboCourseMuunt/RenderablePath.cs b/File_Format_Library/GUI/Byaml/TurboCourseMuunt/RenderablePath.cs new file mode 100644 index 00000000..efdfe77c --- /dev/null +++ b/File_Format_Library/GUI/Byaml/TurboCourseMuunt/RenderablePath.cs @@ -0,0 +1,67 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Drawing; +using OpenTK; +using OpenTK.Graphics.OpenGL; +using FirstPlugin.Turbo.CourseMuuntStructs; +using Toolbox.Library; + +namespace FirstPlugin.MuuntEditor +{ + /// + /// Represets a path with multiple grouped points that connect to each other + /// + public class RenderablePath : IDrawableObject + { + public Color LineColor = Color.Green; + + public List PathGroups = new List(); + + public RenderablePath(List pathGroups) + { + PathGroups = pathGroups; + } + + public void Draw(Matrix4 mvp) + { + for (int i = 0; i < PathGroups.Count; i++) + { + foreach (var path in PathGroups[i].PathPoints) + { + var translate = new Vector3(path.Translate.X, path.Translate.Z, path.Translate.Y); + + if (path.IsSelected) + Render2D.DrawFilledCircle(new Vector2(translate.X, translate.Y), Color.Green, 30, 40, true); + else if (path.IsHovered) + Render2D.DrawFilledCircle(new Vector2(translate.X, translate.Y), Color.Yellow, 40, 40, true); + else + Render2D.DrawFilledCircle(new Vector2(translate.X, translate.Y), Color.Red, 30, 40, true); + + GL.LineWidth(2f); + foreach (var nextPt in path.NextPoints) + { + var nextTranslate = PathGroups[nextPt.PathID].PathPoints[nextPt.PtID].Translate; + + GL.Color3(LineColor); + GL.Begin(PrimitiveType.Lines); + GL.Vertex3(translate); + GL.Vertex3(nextTranslate.X, nextTranslate.Z, nextTranslate.Y); + GL.End(); + } + foreach (var prevPt in path.PrevPoints) + { + var prevTranslate = PathGroups[prevPt.PathID].PathPoints[prevPt.PtID].Translate; + + GL.Color3(LineColor); + GL.Begin(PrimitiveType.Lines); + GL.Vertex3(translate); + GL.Vertex3(prevTranslate.X, prevTranslate.Z, prevTranslate.Y); + GL.End(); + } + } + } + } + } +} diff --git a/File_Format_Library/GUI/Byaml/CourseMuunt/TurboMunntEditor.Designer.cs b/File_Format_Library/GUI/Byaml/TurboCourseMuunt/TurboMunntEditor.Designer.cs similarity index 100% rename from File_Format_Library/GUI/Byaml/CourseMuunt/TurboMunntEditor.Designer.cs rename to File_Format_Library/GUI/Byaml/TurboCourseMuunt/TurboMunntEditor.Designer.cs diff --git a/File_Format_Library/GUI/Byaml/CourseMuunt/TurboMunntEditor.cs b/File_Format_Library/GUI/Byaml/TurboCourseMuunt/TurboMunntEditor.cs similarity index 100% rename from File_Format_Library/GUI/Byaml/CourseMuunt/TurboMunntEditor.cs rename to File_Format_Library/GUI/Byaml/TurboCourseMuunt/TurboMunntEditor.cs diff --git a/File_Format_Library/GUI/Byaml/CourseMuunt/TurboMunntEditor.resx b/File_Format_Library/GUI/Byaml/TurboCourseMuunt/TurboMunntEditor.resx similarity index 100% rename from File_Format_Library/GUI/Byaml/CourseMuunt/TurboMunntEditor.resx rename to File_Format_Library/GUI/Byaml/TurboCourseMuunt/TurboMunntEditor.resx diff --git a/File_Format_Library/GUI/Byaml/CourseMuunt/Wrappers/PathCollectionNode.cs b/File_Format_Library/GUI/Byaml/TurboCourseMuunt/Wrappers/PathCollectionNode.cs similarity index 100% rename from File_Format_Library/GUI/Byaml/CourseMuunt/Wrappers/PathCollectionNode.cs rename to File_Format_Library/GUI/Byaml/TurboCourseMuunt/Wrappers/PathCollectionNode.cs diff --git a/File_Format_Library/GUI/Byaml/CourseMuunt/Wrappers/PathGroupNode.cs b/File_Format_Library/GUI/Byaml/TurboCourseMuunt/Wrappers/PathGroupNode.cs similarity index 100% rename from File_Format_Library/GUI/Byaml/CourseMuunt/Wrappers/PathGroupNode.cs rename to File_Format_Library/GUI/Byaml/TurboCourseMuunt/Wrappers/PathGroupNode.cs diff --git a/File_Format_Library/GUI/Byaml/CourseMuunt/Wrappers/PathPointNode.cs b/File_Format_Library/GUI/Byaml/TurboCourseMuunt/Wrappers/PathPointNode.cs similarity index 100% rename from File_Format_Library/GUI/Byaml/CourseMuunt/Wrappers/PathPointNode.cs rename to File_Format_Library/GUI/Byaml/TurboCourseMuunt/Wrappers/PathPointNode.cs diff --git a/File_Format_Library/GUI/Byaml/CourseMuunt/Wrappers/ProbeLightingEntryWrapper.cs b/File_Format_Library/GUI/Byaml/TurboCourseMuunt/Wrappers/ProbeLightingEntryWrapper.cs similarity index 100% rename from File_Format_Library/GUI/Byaml/CourseMuunt/Wrappers/ProbeLightingEntryWrapper.cs rename to File_Format_Library/GUI/Byaml/TurboCourseMuunt/Wrappers/ProbeLightingEntryWrapper.cs diff --git a/File_Format_Library/GUI/Byaml/CourseMuunt/Wrappers/ProbeLightingWrapper.cs b/File_Format_Library/GUI/Byaml/TurboCourseMuunt/Wrappers/ProbeLightingWrapper.cs similarity index 100% rename from File_Format_Library/GUI/Byaml/CourseMuunt/Wrappers/ProbeLightingWrapper.cs rename to File_Format_Library/GUI/Byaml/TurboCourseMuunt/Wrappers/ProbeLightingWrapper.cs diff --git a/Switch_Toolbox_Library/Forms/Custom/BarSlider/BarSlider.cs b/Switch_Toolbox_Library/Forms/Custom/BarSlider/BarSlider.cs index 90754139..40872c7e 100644 --- a/Switch_Toolbox_Library/Forms/Custom/BarSlider/BarSlider.cs +++ b/Switch_Toolbox_Library/Forms/Custom/BarSlider/BarSlider.cs @@ -1752,8 +1752,8 @@ namespace BarSlider if (TextEditorActive) return; - if (prevPos.X != 0 && prevPos.Y != 0) - Cursor.Position = prevPos; + // if (prevPos.X != 0 && prevPos.Y != 0) + // Cursor.Position = prevPos; // Cursor.Show(); base.OnKeyUp(e); diff --git a/Switch_Toolbox_Library/Forms/Custom/STComboBox.cs b/Switch_Toolbox_Library/Forms/Custom/STComboBox.cs index 7a133c8b..f8c6e9cf 100644 --- a/Switch_Toolbox_Library/Forms/Custom/STComboBox.cs +++ b/Switch_Toolbox_Library/Forms/Custom/STComboBox.cs @@ -57,6 +57,12 @@ namespace Toolbox.Library.Forms InitializeComponent(); } + public void LoadEnum(Type type) + { + DataBindings.Clear(); + DataSource = Enum.GetValues(type); + } + private bool IsTextReadOnly = true; public void SetAsReadOnly() diff --git a/Switch_Toolbox_Library/Forms/Editors/UV/UVEditorForm.cs b/Switch_Toolbox_Library/Forms/Editors/UV/UVEditorForm.cs index 53566029..5f120746 100644 --- a/Switch_Toolbox_Library/Forms/Editors/UV/UVEditorForm.cs +++ b/Switch_Toolbox_Library/Forms/Editors/UV/UVEditorForm.cs @@ -19,6 +19,8 @@ namespace Toolbox.Library.Forms public void LoadEditor(List Drawables) { + if (Drawables == null) return; + uvEditor1.Materials.Clear(); uvEditor1.Textures.Clear(); uvEditor1.Objects.Clear(); diff --git a/Switch_Toolbox_Library/OpenGL/IPickableObject.cs b/Switch_Toolbox_Library/OpenGL/IPickableObject.cs new file mode 100644 index 00000000..fde81b17 --- /dev/null +++ b/Switch_Toolbox_Library/OpenGL/IPickableObject.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Toolbox.Library +{ + public interface IPickable2DObject + { + bool IsHit(float X, float Y); + bool IsSelected { get; set; } + bool IsHovered { get; set; } + void PickTranslate(float X, float Y, float Z); + } +} diff --git a/Switch_Toolbox_Library/OpenGL/OpenGLHelper.cs b/Switch_Toolbox_Library/OpenGL/OpenGLHelper.cs index 9ab0dc71..d8bff0fd 100644 --- a/Switch_Toolbox_Library/OpenGL/OpenGLHelper.cs +++ b/Switch_Toolbox_Library/OpenGL/OpenGLHelper.cs @@ -11,7 +11,7 @@ namespace Toolbox.Library { public class OpenGLHelper { - public static Point convertScreenToWorldCoords(int x, int y) + public static Point convertScreenToWorldCoords(int x, int y, bool isTopDown = false) { int[] viewport = new int[4]; Matrix4 modelViewMatrix, projectionMatrix; @@ -21,11 +21,13 @@ namespace Toolbox.Library Vector2 mouse; mouse.X = x; mouse.Y = y; - Vector4 vector = UnProject(ref projectionMatrix, modelViewMatrix, new Size(viewport[2], viewport[3]), mouse); + Vector4 vector = UnProject(ref projectionMatrix, modelViewMatrix, new Size(viewport[2], viewport[3]), mouse, isTopDown); Point coords = new Point((int)vector.X, (int)vector.Y); + return coords; } - public static Vector4 UnProject(ref Matrix4 projection, Matrix4 view, Size viewport, Vector2 mouse) + + public static Vector4 UnProject(ref Matrix4 projection, Matrix4 view, Size viewport, Vector2 mouse, bool isTopDown) { Vector4 vec; @@ -34,6 +36,12 @@ namespace Toolbox.Library vec.Z = 0; vec.W = 1.0f; + if (isTopDown) + { + vec.Y = 0; + vec.Z = -(2.0f * mouse.Y / (float)viewport.Height - 1); + } + Matrix4 viewInv = Matrix4.Invert(view); Matrix4 projInv = Matrix4.Invert(projection); diff --git a/Switch_Toolbox_Library/OpenGL/Render2D.cs b/Switch_Toolbox_Library/OpenGL/Render2D.cs index 0a49a091..f86aebab 100644 --- a/Switch_Toolbox_Library/OpenGL/Render2D.cs +++ b/Switch_Toolbox_Library/OpenGL/Render2D.cs @@ -27,11 +27,34 @@ namespace Toolbox.Library GL.PopMatrix(); } - public static void DrawCircle(Vector2 Position, Color color) + public static void DrawFilledCircle(Vector2 Position, Color color, float radius = 300, byte transparency = 255, bool outline = false) { GL.PushMatrix(); GL.Translate(Position.X, Position.Y, 0); - GL.Scale(300,300,1); + GL.Scale(radius, radius, 1); + + GL.Color4(color.R, color.G, color.B, transparency); + GL.Begin(PrimitiveType.TriangleFan); + for (int i = 0; i <= 300; i++) + { + double angle = 2 * Math.PI * i / 300; + double x = Math.Cos(angle); + double y = Math.Sin(angle); + GL.Vertex2(x, y); + } + GL.End(); + + GL.PopMatrix(); + + if (outline) + DrawCircle(Position, color.Darken(20), radius); + } + + public static void DrawCircle(Vector2 Position, Color color, float radius = 300) + { + GL.PushMatrix(); + GL.Translate(Position.X, Position.Y, 0); + GL.Scale(radius, radius, 1); GL.Color4(color); GL.Begin(PrimitiveType.LineLoop); diff --git a/Switch_Toolbox_Library/OpenGL/STRectangle.cs b/Switch_Toolbox_Library/OpenGL/STRectangle.cs new file mode 100644 index 00000000..72e19c42 --- /dev/null +++ b/Switch_Toolbox_Library/OpenGL/STRectangle.cs @@ -0,0 +1,46 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Toolbox.Library +{ + public class STRectangle + { + public int LeftPoint; + public int RightPoint; + public int TopPoint; + public int BottomPoint; + + public STRectangle(float posX, float posY, float width, float height) + { + LeftPoint = (int)(posX - (width / 2)); + RightPoint = (int)(posX + (width / 2)); + TopPoint = (int)(posY + (height / 2)); + BottomPoint = (int)(posY - (height / 2)); + } + + public STRectangle(int left, int right, int top, int bottom) + { + LeftPoint = left; + RightPoint = right; + TopPoint = top; + BottomPoint = bottom; + } + + public bool IsHit(int X, int Y) + { + bool isInBetweenX = (X > LeftPoint) && (X < RightPoint) || + (X < LeftPoint) && (X > RightPoint); + + bool isInBetweenY = (Y > BottomPoint) && (Y < TopPoint) || + (Y < BottomPoint) && (Y > TopPoint); + + if (isInBetweenX && isInBetweenY) + return true; + else + return false; + } + } +} diff --git a/Switch_Toolbox_Library/OpenGL/Viewport2D.cs b/Switch_Toolbox_Library/OpenGL/Viewport2D.cs index a9b7fa3c..3761b8e4 100644 --- a/Switch_Toolbox_Library/OpenGL/Viewport2D.cs +++ b/Switch_Toolbox_Library/OpenGL/Viewport2D.cs @@ -15,7 +15,7 @@ namespace Toolbox.Library.Forms { public class Viewport2D : UserControl { - public virtual bool UseOrtho { get; set; } = false; + public virtual bool UseOrtho { get; set; } = true; public virtual bool UseGrid { get; set; } = true; public Camera2D Camera = new Camera2D(); @@ -40,6 +40,8 @@ namespace Toolbox.Library.Forms private GLControl glControl1; private Color BackgroundColor = Color.FromArgb(40, 40, 40); + private List SelectedObjects = new List(); + public Viewport2D() { glControl1 = new GLControl(); @@ -109,6 +111,22 @@ namespace Toolbox.Library.Forms } } + public virtual List GetPickableObjects() + { + return new List(); + } + + private List SearchHit(float X, float Y) + { + List picks = new List(); + foreach (var pickObj in GetPickableObjects()) + { + if (pickObj.IsHit(X, Y)) + picks.Add(pickObj); + } + return picks; + } + private void SetupScene() { GL.Enable(EnableCap.Blend); @@ -125,6 +143,17 @@ namespace Toolbox.Library.Forms RenderSceme(); + if (showSelectionBox) + { + GL.Begin(PrimitiveType.LineLoop); + GL.Color4(Color.Red); + GL.Vertex2(SelectionBox.LeftPoint, SelectionBox.BottomPoint); + GL.Vertex2(SelectionBox.RightPoint, SelectionBox.BottomPoint); + GL.Vertex2(SelectionBox.RightPoint, SelectionBox.TopPoint); + GL.Vertex2(SelectionBox.LeftPoint, SelectionBox.TopPoint); + GL.End(); + } + if (UseOrtho) GL.PopMatrix(); @@ -132,13 +161,54 @@ namespace Toolbox.Library.Forms glControl1.SwapBuffers(); } + private STRectangle SelectionBox; + + private bool showSelectionBox = false; + + private void DrawSelectionBox(Point point1, Point point2) + { + SelectedObjects.Clear(); + + int left = point1.X; + int right = point2.X; + int top = point1.Y; + int bottom = point2.Y; + //Determine each point direction to see what is left/right/top/bottom + if (bottom > top) + { + top = point2.Y; + bottom = point1.Y; + } + if (left > right) + { + right = point1.X; + left = point2.X; + } + + showSelectionBox = true; + SelectionBox = new STRectangle(left, right, top, bottom); + + SetupScene(); + } + public virtual void RenderSceme() { } + private Point pickOriginMouse; private Point originMouse; private bool mouseCameraDown; + private bool isPicked; + private bool mouseDown = false; + + private Vector2 GetMouseCoords(Point screenMouse) + { + RenderEditor(); + var coords = OpenGLHelper.convertScreenToWorldCoords(screenMouse.X, screenMouse.Y); + GL.PopMatrix(); + return new Vector2(coords.X, coords.Y); + } private void glControl1_MouseDown(object sender, MouseEventArgs e) { @@ -149,6 +219,33 @@ namespace Toolbox.Library.Forms mouseCameraDown = true; glControl1.Invalidate(); } + else if (e.Button == MouseButtons.Left) + { + mouseDown = true; + + var mouseCoords = GetMouseCoords(e.Location); + + var picks = SearchHit(mouseCoords.X, mouseCoords.Y); + if (picks.Count > 0) + { + if (!SelectedObjects.Contains(picks[0])) + { + if (Control.ModifierKeys != Keys.Control) + UnselectAll(); + + SelectedObjects.Add(picks[0]); + + picks[0].IsSelected = true; + } + + isPicked = true; + } + else if (Control.ModifierKeys != Keys.Control) + UnselectAll(); + + pickOriginMouse = e.Location; + glControl1.Invalidate(); + } } private void glControl1_MouseUp(object sender, MouseEventArgs e) @@ -156,21 +253,64 @@ namespace Toolbox.Library.Forms if (e.Button == MouseButtons.Left || e.Button == MouseButtons.Middle) { mouseCameraDown = false; + mouseDown = false; + isPicked = false; + showSelectionBox = false; + + glControl1.Invalidate(); } } + private void UnselectAll() + { + foreach (var pick in SelectedObjects) + pick.IsSelected = false; + + SelectedObjects.Clear(); + } + private void glControl1_MouseMove(object sender, MouseEventArgs e) { + var mouseCoords = GetMouseCoords(e.Location); + var picks = SearchHit(mouseCoords.X, mouseCoords.Y); + + if (picks.Count > 0) + { + if (!picks[0].IsSelected) + { + picks[0].IsHovered = true; + + glControl1.Invalidate(); + } + } + else + { + foreach (var obj in GetPickableObjects()) + obj.IsHovered = false; + + glControl1.Invalidate(); + } + if (mouseCameraDown) { var pos = new Vector2(e.Location.X - originMouse.X, e.Location.Y - originMouse.Y); Camera.Position.X += pos.X; - Camera.Position.Y += pos.Y; + Camera.Position.Y -= pos.Y; originMouse = e.Location; glControl1.Invalidate(); } + + if (mouseDown && !isPicked) + { + RenderEditor(); + var temp = e.Location; + var curPos = OpenGLHelper.convertScreenToWorldCoords(temp.X, temp.Y); + var prevPos = OpenGLHelper.convertScreenToWorldCoords(pickOriginMouse.X, pickOriginMouse.Y); + + DrawSelectionBox(prevPos, curPos); + } } private void glControl1_Resize(object sender, EventArgs e) diff --git a/Switch_Toolbox_Library/Toolbox_Library.csproj b/Switch_Toolbox_Library/Toolbox_Library.csproj index bce4ef82..89e16094 100644 --- a/Switch_Toolbox_Library/Toolbox_Library.csproj +++ b/Switch_Toolbox_Library/Toolbox_Library.csproj @@ -393,7 +393,9 @@ + + UserControl diff --git a/Toolbox/Gl_EditorFramework.dll b/Toolbox/Gl_EditorFramework.dll index 23740d72..61e205a4 100644 Binary files a/Toolbox/Gl_EditorFramework.dll and b/Toolbox/Gl_EditorFramework.dll differ diff --git a/Toolbox/Gl_EditorFramework.pdb b/Toolbox/Gl_EditorFramework.pdb index c9b2dbef..b75cd71d 100644 Binary files a/Toolbox/Gl_EditorFramework.pdb and b/Toolbox/Gl_EditorFramework.pdb differ diff --git a/Toolbox/Lib/Syroot.NintenTools.NSW.Bfres.dll b/Toolbox/Lib/Syroot.NintenTools.NSW.Bfres.dll index dd7a7162..78e1fe6f 100644 Binary files a/Toolbox/Lib/Syroot.NintenTools.NSW.Bfres.dll and b/Toolbox/Lib/Syroot.NintenTools.NSW.Bfres.dll differ diff --git a/Toolbox/Lib/Syroot.NintenTools.NSW.Bfres.pdb b/Toolbox/Lib/Syroot.NintenTools.NSW.Bfres.pdb index 63e8bf10..9e77bfc0 100644 Binary files a/Toolbox/Lib/Syroot.NintenTools.NSW.Bfres.pdb and b/Toolbox/Lib/Syroot.NintenTools.NSW.Bfres.pdb differ