Add all the working BCRES stuff.

This commit is contained in:
KillzXGaming 2019-05-09 14:49:11 -04:00
parent a65486b7cf
commit 6f1a8ab816
19 changed files with 760 additions and 30 deletions

View file

@ -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<Type> types = new List<Type>();
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<T>(ResDict<T> 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;
}
}
}

View file

@ -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<string, STGenericWrapper> ResourceNodes = new Dictionary<string, STGenericWrapper>();
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);
}
}
}

View file

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

View file

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

View file

@ -111,6 +111,7 @@ namespace FirstPlugin
List<Type> Formats = new List<Type>();
Formats.Add(typeof(SARC));
Formats.Add(typeof(BFRES));
Formats.Add(typeof(BCRES));
Formats.Add(typeof(BNTX));
Formats.Add(typeof(BEA));
Formats.Add(typeof(BYAML));

View file

@ -55,6 +55,9 @@
<HintPath>..\Toolbox\Lib\BarsLibrary.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="BcresLibrary">
<HintPath>..\Toolbox\Lib\BcresLibrary.dll</HintPath>
</Reference>
<Reference Include="BezelEngineArchive_Lib">
<HintPath>..\Toolbox\Lib\BezelEngineArchive_Lib.dll</HintPath>
<Private>False</Private>
@ -201,6 +204,10 @@
<Compile Include="FileFormats\Audio\MP3.cs" />
<Compile Include="FileFormats\Audio\Ogg.cs" />
<Compile Include="FileFormats\Audio\WAV.cs" />
<Compile Include="FileFormats\BCRES\BCRES.cs" />
<Compile Include="FileFormats\BCRES\Wrappers\BCRESGroupNode.cs" />
<Compile Include="FileFormats\BCRES\Wrappers\CMDLWrapper.cs" />
<Compile Include="FileFormats\BCRES\Wrappers\TXOBWrapper.cs" />
<Compile Include="FileFormats\BFRES\BFRESGroupNode.cs" />
<Compile Include="FileFormats\BFRES\BFRESAnimFolder.cs" />
<Compile Include="FileFormats\BFRES\gfxEnum.cs" />
@ -1180,5 +1187,6 @@
<ItemGroup>
<None Include="Resources\ViewportIconDisable.png" />
</ItemGroup>
<ItemGroup />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

View file

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

View file

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

View file

@ -117,15 +117,15 @@
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="stContextMenuStrip2.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>184, 17</value>
</metadata>
<metadata name="toolTip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>351, 17</value>
</metadata>
<metadata name="stContextMenuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
<metadata name="stContextMenuStrip2.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>184, 17</value>
</metadata>
<metadata name="$this.TrayHeight" type="System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>108</value>
</metadata>

View file

@ -18,6 +18,10 @@ namespace Switch_Toolbox.Library.IO
/// <returns></returns>
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;

View file

@ -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<uint> mipOffsets = new List<uint>();
List<byte[]> Swizzled = new List<byte[]>();
if (MipCount == 0)
MipCount = 1;
for (int mipLevel = 0; mipLevel < MipCount; mipLevel++)
{
var result = TextureHelper.GetCurrentMipSize(Width, Height, blkWidth, blkHeight, bpp, mipLevel);

114
Toolbox/GUI/GithubUpdateDialog.Designer.cs generated Normal file
View file

@ -0,0 +1,114 @@
namespace Toolbox
{
partial class GithubUpdateDialog
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
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;
}
}

View file

@ -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<GitHubCommit> Commits)
{
foreach (var commit in Commits)
{
listViewCustom1.Items.Add(commit.Commit.Message).SubItems.Add(commit.Commit.Author.Date.DateTime.ToString());
}
}
}
}

View file

@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View file

@ -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": ""
}
}
}

Binary file not shown.

Binary file not shown.

View file

@ -82,6 +82,12 @@
<Compile Include="GUI\GithubIssueDialog.Designer.cs">
<DependentUpon>GithubIssueDialog.cs</DependentUpon>
</Compile>
<Compile Include="GUI\GithubUpdateDialog.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="GUI\GithubUpdateDialog.Designer.cs">
<DependentUpon>GithubUpdateDialog.cs</DependentUpon>
</Compile>
<Compile Include="GUI\NodeWrappers.cs" />
<Compile Include="GUI\PluginManager.cs">
<SubType>Form</SubType>
@ -120,6 +126,9 @@
<EmbeddedResource Include="GUI\GithubIssueDialog.resx">
<DependentUpon>GithubIssueDialog.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="GUI\GithubUpdateDialog.resx">
<DependentUpon>GithubUpdateDialog.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="GUI\PluginManager.resx">
<DependentUpon>PluginManager.cs</DependentUpon>
</EmbeddedResource>
@ -253,6 +262,9 @@
<Content Include="Lib\BarsLibrary.dll">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Lib\BcresLibrary.dll">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Lib\Be.Windows.Forms.HexBox.dll">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>

View file

@ -15,6 +15,7 @@ namespace Toolbox
static Release[] releases;
public static bool CanUpdate = false;
public static Release LatestRelease;
public static List<GitHubCommit> CommitList = new List<GitHubCommit>();
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<Release> Releases = new List<Release>();