diff --git a/Switch_FileFormatsMain/FileFormats/BCRES/BCRES.cs b/Switch_FileFormatsMain/FileFormats/BCRES/BCRES.cs new file mode 100644 index 00000000..f7c1cf02 --- /dev/null +++ b/Switch_FileFormatsMain/FileFormats/BCRES/BCRES.cs @@ -0,0 +1,95 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Switch_Toolbox; +using System.Windows.Forms; +using Switch_Toolbox.Library; +using BcresLibrary; + +namespace FirstPlugin +{ + public class BCRES : TreeNodeFile, IFileFormat + { + public FileType FileType { get; set; } = FileType.Layout; + + public bool CanSave { get; set; } + public string[] Description { get; set; } = new string[] { "BCRES" }; + public string[] Extension { get; set; } = new string[] { "*.bcres" }; + public string FileName { get; set; } + public string FilePath { get; set; } + public IFileInfo IFileInfo { get; set; } + + public bool Identify(System.IO.Stream stream) + { + using (var reader = new Switch_Toolbox.Library.IO.FileReader(stream, true)) + { + return reader.CheckSignature(4, "CGFX"); + } + } + + public Type[] Types + { + get + { + List types = new List(); + return types.ToArray(); + } + } + + public BcresFile BcresFile; + + public void Load(System.IO.Stream stream) + { + Text = FileName; + BcresFile = new BcresFile(stream); + + AddNodeGroup(BcresFile.Data.Models, new BCRESGroupNode(BCRESGroupType.Models)); + AddNodeGroup(BcresFile.Data.Textures, new BCRESGroupNode(BCRESGroupType.Textures)); + AddNodeGroup(BcresFile.Data.Lookups, new BCRESGroupNode(BCRESGroupType.Lookups)); + AddNodeGroup(BcresFile.Data.Shaders, new BCRESGroupNode(BCRESGroupType.Shaders)); + AddNodeGroup(BcresFile.Data.Cameras, new BCRESGroupNode(BCRESGroupType.Cameras)); + AddNodeGroup(BcresFile.Data.Fogs, new BCRESGroupNode(BCRESGroupType.Fogs)); + AddNodeGroup(BcresFile.Data.Scenes, new BCRESGroupNode(BCRESGroupType.Scenes)); + AddNodeGroup(BcresFile.Data.SkeletalAnims, new BCRESGroupNode(BCRESGroupType.SkeletalAnim)); + AddNodeGroup(BcresFile.Data.MaterialAnims, new BCRESGroupNode(BCRESGroupType.MaterialAnim)); + AddNodeGroup(BcresFile.Data.VisibiltyAnims, new BCRESGroupNode(BCRESGroupType.VisibiltyAnim)); + AddNodeGroup(BcresFile.Data.CameraAnims, new BCRESGroupNode(BCRESGroupType.CameraAnim)); + AddNodeGroup(BcresFile.Data.LightAnims, new BCRESGroupNode(BCRESGroupType.LightAnim)); + AddNodeGroup(BcresFile.Data.EmitterAnims, new BCRESGroupNode(BCRESGroupType.EmitterAnim)); + AddNodeGroup(BcresFile.Data.Particles, new BCRESGroupNode(BCRESGroupType.Particles)); + } + + private void AddNodeGroup(ResDict SubSections, BCRESGroupNode Folder) + where T : CtrObject, new() + { + if (SubSections == null || SubSections.Count == 0) + return; + + Nodes.Add(Folder); + + foreach (CtrObject section in SubSections.Values) + { + switch (Folder.Type) + { + case BCRESGroupType.Models: + Folder.AddNode(new CMDLWrapper((Model)section)); + break; + case BCRESGroupType.Textures: + Folder.AddNode(new TXOBWrapper((Texture)section)); + break; + } + } + } + + public void Unload() + { + + } + public byte[] Save() + { + return null; + } + } +} diff --git a/Switch_FileFormatsMain/FileFormats/BCRES/Wrappers/BCRESGroupNode.cs b/Switch_FileFormatsMain/FileFormats/BCRES/Wrappers/BCRESGroupNode.cs new file mode 100644 index 00000000..2cc37d17 --- /dev/null +++ b/Switch_FileFormatsMain/FileFormats/BCRES/Wrappers/BCRESGroupNode.cs @@ -0,0 +1,96 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Switch_Toolbox.Library.NodeWrappers; +using Switch_Toolbox.Library.Forms; + +namespace FirstPlugin +{ + public enum BCRESGroupType + { + Models, + Textures, + Lookups, + Materials, + Shaders, + Cameras, + Lights, + Fogs, + Scenes, + SkeletalAnim, + MaterialAnim, + VisibiltyAnim, + CameraAnim, + LightAnim, + EmitterAnim, + Particles, + } + + public class BCRESGroupNode : STGenericWrapper + { + public Dictionary ResourceNodes = new Dictionary(); + + public BCRESGroupType Type; + + public BCRESGroupNode() : base() + { + ImageKey = "folder"; + + LoadContextMenus(); + } + + public BCRESGroupNode(string name) : base() { Text = name; } + public BCRESGroupNode(BCRESGroupType type) : base() { Type = type; SetNameByType(); } + + public override void LoadContextMenus() + { + ContextMenuStrip = new STContextMenuStrip(); + + CanExport = false; + CanReplace = false; + CanRename = false; + CanDelete = false; + } + + public void SetNameByType() + { + Text = SetName(); + } + + private string SetName() + { + switch (Type) + { + case BCRESGroupType.Models: return "Models"; + case BCRESGroupType.Textures: return "Textures"; + case BCRESGroupType.Lookups: return "Lookups"; + case BCRESGroupType.Materials: return "Materials"; + case BCRESGroupType.Shaders: return "Shaders"; + case BCRESGroupType.Cameras: return "Cameras"; + case BCRESGroupType.Lights: return "Lights"; + case BCRESGroupType.Fogs: return "Fogs"; + case BCRESGroupType.Scenes: return "Scenes"; + case BCRESGroupType.SkeletalAnim: return "Skeletal Animations"; + case BCRESGroupType.MaterialAnim: return "Material Animations"; + case BCRESGroupType.VisibiltyAnim: return "Visibilty Animations"; + case BCRESGroupType.CameraAnim: return "Camera Animations"; + case BCRESGroupType.LightAnim: return "Light Animations"; + case BCRESGroupType.EmitterAnim: return "Emitter Animations"; + case BCRESGroupType.Particles: return "Particles"; + default: + throw new System.Exception("Unknown type? " + Type); + } + } + + public void AddNode(STGenericWrapper node) + { + if (node.Text == string.Empty) + throw new System.Exception("Text invalid. Must not be empty! "); + + Nodes.Add(node); + ResourceNodes.Add(node.Text, node); + } + } +} diff --git a/Switch_FileFormatsMain/FileFormats/BCRES/Wrappers/CMDLWrapper.cs b/Switch_FileFormatsMain/FileFormats/BCRES/Wrappers/CMDLWrapper.cs new file mode 100644 index 00000000..737f3e7b --- /dev/null +++ b/Switch_FileFormatsMain/FileFormats/BCRES/Wrappers/CMDLWrapper.cs @@ -0,0 +1,36 @@ +using System; +using System.Collections.Generic; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; +using Switch_Toolbox.Library; +using BcresLibrary; + +namespace FirstPlugin +{ + public class CMDLWrapper : STGenericModel + { + public CMDLWrapper() + { + ImageKey = "Model"; + SelectedImageKey = "Model"; + } + public CMDLWrapper(Model model) : base() { LoadModel(model); } + + internal Model Model; + + public override void OnClick(TreeView treeview) + { + + } + + public void LoadModel(Model model) + { + Model = model; + + Text = model.Name; + } + } +} diff --git a/Switch_FileFormatsMain/FileFormats/BCRES/Wrappers/TXOBWrapper.cs b/Switch_FileFormatsMain/FileFormats/BCRES/Wrappers/TXOBWrapper.cs new file mode 100644 index 00000000..83cc73b2 --- /dev/null +++ b/Switch_FileFormatsMain/FileFormats/BCRES/Wrappers/TXOBWrapper.cs @@ -0,0 +1,102 @@ +using System; +using System.Collections.Generic; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; +using Switch_Toolbox.Library; +using BcresLibrary; +using Switch_Toolbox.Library.Forms; + +namespace FirstPlugin +{ + public class TXOBWrapper : STGenericTexture + { + public TXOBWrapper() + { + ImageKey = "Texture"; + SelectedImageKey = "Texture"; + } + public TXOBWrapper(Texture texture) : base() { LoadTexture(texture); } + + internal Texture Texture; + + public override TEX_FORMAT[] SupportedFormats + { + get + { + return new TEX_FORMAT[] + { + + }; + } + } + + public override void OnClick(TreeView treeview) + { + UpdateEditor(); + } + + private void UpdateEditor() + { + ImageEditorBase editor = (ImageEditorBase)LibraryGUI.Instance.GetActiveContent(typeof(ImageEditorBase)); + if (editor == null) + { + editor = new ImageEditorBase(); + editor.Dock = DockStyle.Fill; + LibraryGUI.Instance.LoadEditor(editor); + } + + Properties prop = new Properties(); + prop.Width = Width; + prop.Height = Height; + prop.Depth = Depth; + prop.MipCount = MipCount; + prop.ArrayCount = ArrayCount; + prop.ImageSize = (uint)Texture.Images[0].ImageData.Length; + prop.Format = Format; + + editor.Text = Text; + editor.LoadProperties(prop); + editor.LoadImage(this); + } + + public void LoadTexture(Texture texture) + { + ImageKey = "Texture"; + SelectedImageKey = "Texture"; + + Texture = texture; + + Text = texture.Name; + + //Cube maps will use multiple images + //Break at the end as we only need the first part for generic things + foreach (var image in texture.Images) + { + Width = image.Width; + Height = image.Height; + MipCount = image.MipCount; + Format = CTR_3DS.ConvertPICAToGenericFormat( + (CTR_3DS.PICASurfaceFormat)image.ImageFormat); + + break; + } + } + + public override bool CanEdit { get; set; } = false; + + public override void SetImageData(Bitmap bitmap, int ArrayLevel) + { + throw new NotImplementedException(); + } + + public override byte[] GetImageData(int ArrayLevel = 0, int MipLevel = 0) + { + PlatformSwizzle = PlatformSwizzle.Platform_3DS; + + return Texture.Images[ArrayLevel].ImageData; + } + } +} diff --git a/Switch_FileFormatsMain/Main.cs b/Switch_FileFormatsMain/Main.cs index 071a1684..3185e675 100644 --- a/Switch_FileFormatsMain/Main.cs +++ b/Switch_FileFormatsMain/Main.cs @@ -111,6 +111,7 @@ namespace FirstPlugin List Formats = new List(); Formats.Add(typeof(SARC)); Formats.Add(typeof(BFRES)); + Formats.Add(typeof(BCRES)); Formats.Add(typeof(BNTX)); Formats.Add(typeof(BEA)); Formats.Add(typeof(BYAML)); diff --git a/Switch_FileFormatsMain/Switch_FileFormatsMain.csproj b/Switch_FileFormatsMain/Switch_FileFormatsMain.csproj index 64cbbdf4..195ab330 100644 --- a/Switch_FileFormatsMain/Switch_FileFormatsMain.csproj +++ b/Switch_FileFormatsMain/Switch_FileFormatsMain.csproj @@ -55,6 +55,9 @@ ..\Toolbox\Lib\BarsLibrary.dll False + + ..\Toolbox\Lib\BcresLibrary.dll + ..\Toolbox\Lib\BezelEngineArchive_Lib.dll False @@ -201,6 +204,10 @@ + + + + @@ -1180,5 +1187,6 @@ + \ No newline at end of file diff --git a/Switch_Toolbox_Library/Forms/Editors/ImageEditor/ImageEditorBase.Designer.cs b/Switch_Toolbox_Library/Forms/Editors/ImageEditor/ImageEditorBase.Designer.cs index abeab9af..fd03685a 100644 --- a/Switch_Toolbox_Library/Forms/Editors/ImageEditor/ImageEditorBase.Designer.cs +++ b/Switch_Toolbox_Library/Forms/Editors/ImageEditor/ImageEditorBase.Designer.cs @@ -30,10 +30,11 @@ { this.components = new System.ComponentModel.Container(); this.splitContainer1 = new System.Windows.Forms.SplitContainer(); - this.toolTip1 = new System.Windows.Forms.ToolTip(this.components); this.stPanel2 = new Switch_Toolbox.Library.Forms.STPanel(); this.stPanel1 = new Switch_Toolbox.Library.Forms.STPanel(); this.stPanel4 = new Switch_Toolbox.Library.Forms.STPanel(); + this.stPanel5 = new Switch_Toolbox.Library.Forms.STPanel(); + this.bottomLabel = new Switch_Toolbox.Library.Forms.STLabel(); this.pictureBoxCustom1 = new Cyotek.Windows.Forms.ImageBox(); this.stPanel3 = new Switch_Toolbox.Library.Forms.STPanel(); this.alphaBtn = new Switch_Toolbox.Library.Forms.STButton(); @@ -72,19 +73,18 @@ this.adjustmentsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.hueToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.brightnessContrastToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.toolTip1 = new System.Windows.Forms.ToolTip(this.components); this.stContextMenuStrip2 = new Switch_Toolbox.Library.Forms.STContextMenuStrip(this.components); this.copyImageToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.bottomLabel = new Switch_Toolbox.Library.Forms.STLabel(); - this.stPanel5 = new Switch_Toolbox.Library.Forms.STPanel(); ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit(); this.splitContainer1.Panel1.SuspendLayout(); this.splitContainer1.SuspendLayout(); this.stPanel1.SuspendLayout(); this.stPanel4.SuspendLayout(); + this.stPanel5.SuspendLayout(); this.stPanel3.SuspendLayout(); this.stContextMenuStrip1.SuspendLayout(); this.stContextMenuStrip2.SuspendLayout(); - this.stPanel5.SuspendLayout(); this.SuspendLayout(); // // splitContainer1 @@ -141,11 +141,29 @@ this.stPanel4.Size = new System.Drawing.Size(514, 425); this.stPanel4.TabIndex = 8; // + // stPanel5 + // + this.stPanel5.Controls.Add(this.bottomLabel); + this.stPanel5.Dock = System.Windows.Forms.DockStyle.Bottom; + this.stPanel5.Location = new System.Drawing.Point(0, 405); + this.stPanel5.Name = "stPanel5"; + this.stPanel5.Size = new System.Drawing.Size(514, 20); + this.stPanel5.TabIndex = 1; + // + // bottomLabel + // + this.bottomLabel.AutoSize = true; + this.bottomLabel.Location = new System.Drawing.Point(-1, 4); + this.bottomLabel.Name = "bottomLabel"; + this.bottomLabel.Size = new System.Drawing.Size(0, 13); + this.bottomLabel.TabIndex = 18; + // // pictureBoxCustom1 // this.pictureBoxCustom1.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.pictureBoxCustom1.ContextMenuStrip = this.stContextMenuStrip2; this.pictureBoxCustom1.Location = new System.Drawing.Point(0, 0); this.pictureBoxCustom1.Name = "pictureBoxCustom1"; this.pictureBoxCustom1.Size = new System.Drawing.Size(514, 406); @@ -520,23 +538,6 @@ this.copyImageToolStripMenuItem.Text = "Copy Image"; this.copyImageToolStripMenuItem.Click += new System.EventHandler(this.copyImageToolStripMenuItem_Click); // - // bottomLabel - // - this.bottomLabel.AutoSize = true; - this.bottomLabel.Location = new System.Drawing.Point(-1, 4); - this.bottomLabel.Name = "bottomLabel"; - this.bottomLabel.Size = new System.Drawing.Size(0, 13); - this.bottomLabel.TabIndex = 18; - // - // stPanel5 - // - this.stPanel5.Controls.Add(this.bottomLabel); - this.stPanel5.Dock = System.Windows.Forms.DockStyle.Bottom; - this.stPanel5.Location = new System.Drawing.Point(0, 405); - this.stPanel5.Name = "stPanel5"; - this.stPanel5.Size = new System.Drawing.Size(514, 20); - this.stPanel5.TabIndex = 1; - // // ImageEditorBase // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); @@ -550,13 +551,13 @@ this.stPanel1.ResumeLayout(false); this.stPanel1.PerformLayout(); this.stPanel4.ResumeLayout(false); + this.stPanel5.ResumeLayout(false); + this.stPanel5.PerformLayout(); this.stPanel3.ResumeLayout(false); this.stPanel3.PerformLayout(); this.stContextMenuStrip1.ResumeLayout(false); this.stContextMenuStrip1.PerformLayout(); this.stContextMenuStrip2.ResumeLayout(false); - this.stPanel5.ResumeLayout(false); - this.stPanel5.PerformLayout(); this.ResumeLayout(false); } diff --git a/Switch_Toolbox_Library/Forms/Editors/ImageEditor/ImageEditorBase.cs b/Switch_Toolbox_Library/Forms/Editors/ImageEditor/ImageEditorBase.cs index bd7f63f4..625f5f66 100644 --- a/Switch_Toolbox_Library/Forms/Editors/ImageEditor/ImageEditorBase.cs +++ b/Switch_Toolbox_Library/Forms/Editors/ImageEditor/ImageEditorBase.cs @@ -340,7 +340,7 @@ namespace Switch_Toolbox.Library.Forms DecodeProcessFinished = false; - PushImage(Properties.Resources.LoadingImage); + // PushImage(Properties.Resources.LoadingImage); var image = ActiveTexture.GetBitmap(CurArrayDisplayLevel, CurMipDisplayLevel); @@ -1146,13 +1146,24 @@ namespace Switch_Toolbox.Library.Forms private void SetZoomSetting() { - if (!IsFinished) - return; + if (pictureBoxCustom1.InvokeRequired) + { + pictureBoxCustom1.Invoke(new MethodInvoker( + delegate () + { + ApplyZoom(); + })); + } + else + ApplyZoom(); + } + private void ApplyZoom() + { if (Runtime.ImageEditor.EnableImageZoom) { pictureBoxCustom1.AllowZoom = true; - pictureBoxCustom1.AllowClickZoom = true; + pictureBoxCustom1.AllowClickZoom = false; pictureBoxCustom1.SizeMode = Cyotek.Windows.Forms.ImageBoxSizeMode.Normal; } else diff --git a/Switch_Toolbox_Library/Forms/Editors/ImageEditor/ImageEditorBase.resx b/Switch_Toolbox_Library/Forms/Editors/ImageEditor/ImageEditorBase.resx index 8a8b6301..6edb1efb 100644 --- a/Switch_Toolbox_Library/Forms/Editors/ImageEditor/ImageEditorBase.resx +++ b/Switch_Toolbox_Library/Forms/Editors/ImageEditor/ImageEditorBase.resx @@ -117,15 +117,15 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + 184, 17 + 351, 17 17, 17 - - 184, 17 - 108 diff --git a/Switch_Toolbox_Library/IO/STFileSaver.cs b/Switch_Toolbox_Library/IO/STFileSaver.cs index 25957f85..ee0ca2e9 100644 --- a/Switch_Toolbox_Library/IO/STFileSaver.cs +++ b/Switch_Toolbox_Library/IO/STFileSaver.cs @@ -18,6 +18,10 @@ namespace Switch_Toolbox.Library.IO /// public static void SaveFileFormat(IFileFormat FileFormat, string FileName, bool EnableDialog = true) { + //These always get created on loading a file,however not on creating a new file + if (FileFormat.IFileInfo == null) + throw new System.Exception("Make sure to impliment a IFileInfo instance if a format is being created!"); + Cursor.Current = Cursors.WaitCursor; FileFormat.FilePath = FileName; diff --git a/Switch_Toolbox_Library/Swizzling/GX2.cs b/Switch_Toolbox_Library/Swizzling/GX2.cs index ea65c7f6..452bad3b 100644 --- a/Switch_Toolbox_Library/Swizzling/GX2.cs +++ b/Switch_Toolbox_Library/Swizzling/GX2.cs @@ -488,6 +488,7 @@ namespace Switch_Toolbox.Library var surfOut = getSurfaceInfo((GX2SurfaceFormat)Format, Width, Height, Depth, SurfaceDim, TileMode, AAMode, 0); Console.WriteLine("Imported surfSize" + surfOut.surfSize); Console.WriteLine("Imported data block" + imageData.Length); + Console.WriteLine("GX2SurfaceFormat " + (GX2SurfaceFormat)Format); uint imageSize = (uint)surfOut.surfSize; uint alignment = surfOut.baseAlign; @@ -520,12 +521,20 @@ namespace Switch_Toolbox.Library if (TileMode == 0) TileMode = GX2.getDefaultGX2TileMode((uint)SurfaceDim, Width, Height, 1, (uint)Format, 0, 1); + uint tilingDepth = surfOut.depth; + + if (TileMode == 3) + tilingDepth /= 4; + int tiling1dLevel = 0; bool tiling1dLevelSet = false; List mipOffsets = new List(); List Swizzled = new List(); + if (MipCount == 0) + MipCount = 1; + for (int mipLevel = 0; mipLevel < MipCount; mipLevel++) { var result = TextureHelper.GetCurrentMipSize(Width, Height, blkWidth, blkHeight, bpp, mipLevel); diff --git a/Toolbox/GUI/GithubUpdateDialog.Designer.cs b/Toolbox/GUI/GithubUpdateDialog.Designer.cs new file mode 100644 index 00000000..78950e61 --- /dev/null +++ b/Toolbox/GUI/GithubUpdateDialog.Designer.cs @@ -0,0 +1,114 @@ +namespace Toolbox +{ + partial class GithubUpdateDialog + { + /// + /// 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.stButton1 = new Switch_Toolbox.Library.Forms.STButton(); + this.stButton2 = new Switch_Toolbox.Library.Forms.STButton(); + this.listViewCustom1 = new Switch_Toolbox.Library.Forms.ListViewCustom(); + this.columnHeader1 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.columnHeader2 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.contentContainer.SuspendLayout(); + this.SuspendLayout(); + // + // contentContainer + // + this.contentContainer.Controls.Add(this.listViewCustom1); + this.contentContainer.Controls.Add(this.stButton2); + this.contentContainer.Controls.Add(this.stButton1); + this.contentContainer.Controls.SetChildIndex(this.stButton1, 0); + this.contentContainer.Controls.SetChildIndex(this.stButton2, 0); + this.contentContainer.Controls.SetChildIndex(this.listViewCustom1, 0); + // + // stButton1 + // + this.stButton1.DialogResult = System.Windows.Forms.DialogResult.Cancel; + this.stButton1.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.stButton1.Location = new System.Drawing.Point(459, 361); + this.stButton1.Name = "stButton1"; + this.stButton1.Size = new System.Drawing.Size(75, 23); + this.stButton1.TabIndex = 11; + this.stButton1.Text = "Cancel"; + this.stButton1.UseVisualStyleBackColor = false; + // + // stButton2 + // + this.stButton2.DialogResult = System.Windows.Forms.DialogResult.OK; + this.stButton2.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.stButton2.Location = new System.Drawing.Point(378, 361); + this.stButton2.Name = "stButton2"; + this.stButton2.Size = new System.Drawing.Size(75, 23); + this.stButton2.TabIndex = 12; + this.stButton2.Text = "Ok"; + this.stButton2.UseVisualStyleBackColor = false; + // + // listViewCustom1 + // + this.listViewCustom1.BorderStyle = System.Windows.Forms.BorderStyle.None; + this.listViewCustom1.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { + this.columnHeader1, + this.columnHeader2}); + this.listViewCustom1.FullRowSelect = true; + this.listViewCustom1.Location = new System.Drawing.Point(3, 31); + this.listViewCustom1.Name = "listViewCustom1"; + this.listViewCustom1.OwnerDraw = true; + this.listViewCustom1.Size = new System.Drawing.Size(540, 324); + this.listViewCustom1.TabIndex = 13; + this.listViewCustom1.UseCompatibleStateImageBehavior = false; + this.listViewCustom1.View = System.Windows.Forms.View.Details; + // + // columnHeader1 + // + this.columnHeader1.Text = "Message"; + this.columnHeader1.Width = 172; + // + // columnHeader2 + // + this.columnHeader2.Text = "Date"; + // + // GithubUpdateDialog + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(549, 398); + this.Name = "GithubUpdateDialog"; + this.Text = "Github Update"; + this.contentContainer.ResumeLayout(false); + this.ResumeLayout(false); + + } + + #endregion + + private Switch_Toolbox.Library.Forms.STButton stButton1; + private Switch_Toolbox.Library.Forms.STButton stButton2; + private Switch_Toolbox.Library.Forms.ListViewCustom listViewCustom1; + private System.Windows.Forms.ColumnHeader columnHeader1; + private System.Windows.Forms.ColumnHeader columnHeader2; + } +} \ No newline at end of file diff --git a/Toolbox/GUI/GithubUpdateDialog.cs b/Toolbox/GUI/GithubUpdateDialog.cs new file mode 100644 index 00000000..fdd1ca44 --- /dev/null +++ b/Toolbox/GUI/GithubUpdateDialog.cs @@ -0,0 +1,30 @@ +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 Switch_Toolbox.Library.Forms; +using Octokit; + +namespace Toolbox +{ + public partial class GithubUpdateDialog : STForm + { + public GithubUpdateDialog() + { + InitializeComponent(); + } + + public void LoadCommits(List Commits) + { + foreach (var commit in Commits) + { + listViewCustom1.Items.Add(commit.Commit.Message).SubItems.Add(commit.Commit.Author.Date.DateTime.ToString()); + } + } + } +} diff --git a/Toolbox/GUI/GithubUpdateDialog.resx b/Toolbox/GUI/GithubUpdateDialog.resx new file mode 100644 index 00000000..1af7de15 --- /dev/null +++ b/Toolbox/GUI/GithubUpdateDialog.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/Toolbox/Lib/BcresLibrary.deps.json b/Toolbox/Lib/BcresLibrary.deps.json new file mode 100644 index 00000000..39ac481f --- /dev/null +++ b/Toolbox/Lib/BcresLibrary.deps.json @@ -0,0 +1,75 @@ +{ + "runtimeTarget": { + "name": ".NETStandard,Version=v2.0/", + "signature": "cfe1dc2a80602aef150a12815387068463a61a0d" + }, + "compilationOptions": {}, + "targets": { + ".NETStandard,Version=v2.0": {}, + ".NETStandard,Version=v2.0/": { + "BcresLibrary/1.0.0": { + "dependencies": { + "NETStandard.Library": "2.0.3", + "Syroot.BinaryData": "2.0.1.0", + "Syroot.Maths": "1.5.3.0" + }, + "runtime": { + "BcresLibrary.dll": {} + } + }, + "Microsoft.NETCore.Platforms/1.1.0": {}, + "NETStandard.Library/2.0.3": { + "dependencies": { + "Microsoft.NETCore.Platforms": "1.1.0" + } + }, + "Syroot.BinaryData/2.0.1.0": { + "runtime": { + "Syroot.BinaryData.dll": { + "assemblyVersion": "2.0.1.0", + "fileVersion": "2.0.1.0" + } + } + }, + "Syroot.Maths/1.5.3.0": { + "runtime": { + "Syroot.Maths.dll": { + "assemblyVersion": "1.5.3.0", + "fileVersion": "1.5.3.0" + } + } + } + } + }, + "libraries": { + "BcresLibrary/1.0.0": { + "type": "project", + "serviceable": false, + "sha512": "" + }, + "Microsoft.NETCore.Platforms/1.1.0": { + "type": "package", + "serviceable": true, + "sha512": "sha512-kz0PEW2lhqygehI/d6XsPCQzD7ff7gUJaVGPVETX611eadGsA3A877GdSlU0LRVMCTH/+P3o2iDTak+S08V2+A==", + "path": "microsoft.netcore.platforms/1.1.0", + "hashPath": "microsoft.netcore.platforms.1.1.0.nupkg.sha512" + }, + "NETStandard.Library/2.0.3": { + "type": "package", + "serviceable": true, + "sha512": "sha512-st47PosZSHrjECdjeIzZQbzivYBJFv6P2nv4cj2ypdI204DO+vZ7l5raGMiX4eXMJ53RfOIg+/s4DHVZ54Nu2A==", + "path": "netstandard.library/2.0.3", + "hashPath": "netstandard.library.2.0.3.nupkg.sha512" + }, + "Syroot.BinaryData/2.0.1.0": { + "type": "reference", + "serviceable": false, + "sha512": "" + }, + "Syroot.Maths/1.5.3.0": { + "type": "reference", + "serviceable": false, + "sha512": "" + } + } +} \ No newline at end of file diff --git a/Toolbox/Lib/BcresLibrary.dll b/Toolbox/Lib/BcresLibrary.dll new file mode 100644 index 00000000..d21361d6 Binary files /dev/null and b/Toolbox/Lib/BcresLibrary.dll differ diff --git a/Toolbox/Lib/BcresLibrary.pdb b/Toolbox/Lib/BcresLibrary.pdb new file mode 100644 index 00000000..c6a183cb Binary files /dev/null and b/Toolbox/Lib/BcresLibrary.pdb differ diff --git a/Toolbox/Toolbox.csproj b/Toolbox/Toolbox.csproj index 44a996e6..a404eacb 100644 --- a/Toolbox/Toolbox.csproj +++ b/Toolbox/Toolbox.csproj @@ -82,6 +82,12 @@ GithubIssueDialog.cs + + Form + + + GithubUpdateDialog.cs + Form @@ -120,6 +126,9 @@ GithubIssueDialog.cs + + GithubUpdateDialog.cs + PluginManager.cs @@ -253,6 +262,9 @@ PreserveNewest + + PreserveNewest + PreserveNewest diff --git a/Toolbox/UpdateProgram.cs b/Toolbox/UpdateProgram.cs index 37df1313..b164797d 100644 --- a/Toolbox/UpdateProgram.cs +++ b/Toolbox/UpdateProgram.cs @@ -15,6 +15,7 @@ namespace Toolbox static Release[] releases; public static bool CanUpdate = false; public static Release LatestRelease; + public static List CommitList = new List(); public static void CheckLatest() { @@ -22,6 +23,7 @@ namespace Toolbox { var client = new GitHubClient(new ProductHeaderValue("ST_UpdateTool")); GetReleases(client).Wait(); + GetCommits(client).Wait(); foreach (Release latest in releases) { @@ -45,6 +47,20 @@ namespace Toolbox Console.WriteLine($"Failed to get latest update\n{ex.ToString()}"); } } + static async Task GetCommits(GitHubClient client) + { + var options = new ApiOptions + { + PageSize = 5, + PageCount = 1 + }; + + foreach (GitHubCommit c in await client.Repository.Commit.GetAll("KillzXGaming", "Switch-Toolbox", options)) + { + CommitList.Add(c); + } + } + static async Task GetReleases(GitHubClient client) { List Releases = new List();