Merge branch 'main' into '3dSkinRenderer'

This commit is contained in:
miku-666
2024-06-21 20:09:53 +02:00
32 changed files with 1474 additions and 889 deletions

View File

@@ -21,15 +21,15 @@ namespace PckStudio.Extensions
{
private const string MipMap = "MipMapLevel";
internal static Image GetTexture(this PckAsset file)
internal static Image GetTexture(this PckAsset asset)
{
if (file.Type != PckAssetType.SkinFile &&
file.Type != PckAssetType.CapeFile &&
file.Type != PckAssetType.TextureFile)
if (asset.Type != PckAssetType.SkinFile &&
asset.Type != PckAssetType.CapeFile &&
asset.Type != PckAssetType.TextureFile)
{
throw new Exception("File is not suitable to contain image data.");
throw new Exception("Asset is not suitable to contain image data.");
}
return file.GetDeserializedData(ImageDeserializer.DefaultDeserializer);
return asset.GetDeserializedData(ImageDeserializer.DefaultDeserializer);
}
/// <summary>
@@ -122,46 +122,46 @@ namespace PckStudio.Extensions
}
}
internal static T GetDeserializedData<T>(this PckAsset file, IPckAssetDeserializer<T> deserializer)
internal static T GetDeserializedData<T>(this PckAsset asset, IPckAssetDeserializer<T> deserializer)
{
return deserializer.Deserialize(file);
return deserializer.Deserialize(asset);
}
internal static T GetData<T>(this PckAsset file, IDataFormatReader<T> formatReader) where T : class
internal static T GetData<T>(this PckAsset asset, IDataFormatReader<T> formatReader) where T : class
{
using var ms = new MemoryStream(file.Data);
using var ms = new MemoryStream(asset.Data);
return formatReader.FromStream(ms);
}
internal static void SetSerializedData<T>(this PckAsset file, T obj, IPckAssetSerializer<T> serializer)
internal static void SetSerializedData<T>(this PckAsset asset, T obj, IPckAssetSerializer<T> serializer)
{
serializer.Serialize(obj, ref file);
serializer.Serialize(obj, ref asset);
}
internal static void SetData(this PckAsset file, IDataFormatWriter formatWriter)
internal static void SetData(this PckAsset asset, IDataFormatWriter formatWriter)
{
using (var stream = new MemoryStream())
{
formatWriter.WriteToStream(stream);
file.SetData(stream.ToArray());
asset.SetData(stream.ToArray());
}
}
internal static void SetTexture(this PckAsset file, Image image)
internal static void SetTexture(this PckAsset asset, Image image)
{
if (file.Type != PckAssetType.SkinFile &&
file.Type != PckAssetType.CapeFile &&
file.Type != PckAssetType.TextureFile)
if (asset.Type != PckAssetType.SkinFile &&
asset.Type != PckAssetType.CapeFile &&
asset.Type != PckAssetType.TextureFile)
{
throw new Exception("File is not suitable to contain image data.");
throw new Exception("Asset is not suitable to contain image data.");
}
file.SetSerializedData(image, ImageSerializer.DefaultSerializer);
asset.SetSerializedData(image, ImageSerializer.DefaultSerializer);
}
internal static bool IsMipmappedFile(this PckAsset file)
internal static bool IsMipmappedFile(this PckAsset asset)
{
// We only want to test the file name itself. ex: "terrainMipMapLevel2"
string name = Path.GetFileNameWithoutExtension(file.Filename);
string name = Path.GetFileNameWithoutExtension(asset.Filename);
// check if last character is a digit (0-9). If not return false
if (!char.IsDigit(name[name.Length - 1]))
@@ -173,15 +173,15 @@ namespace PckStudio.Extensions
return true;
}
internal static string GetNormalPath(this PckAsset file)
internal static string GetNormalPath(this PckAsset asset)
{
if (!file.IsMipmappedFile())
return file.Filename;
string ext = Path.GetExtension(file.Filename);
return file.Filename.Remove(file.Filename.Length - (MipMap.Length + 1) - ext.Length) + ext;
if (!asset.IsMipmappedFile())
return asset.Filename;
string ext = Path.GetExtension(asset.Filename);
return asset.Filename.Remove(asset.Filename.Length - (MipMap.Length + 1) - ext.Length) + ext;
}
internal static void DeserializePropertiesFromString(this PckAsset file, string serializedData)
internal static void DeserializePropertiesFromString(this PckAsset asset, string serializedData)
{
string[] lines = serializedData.Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries);
foreach (string line in lines)
@@ -189,14 +189,14 @@ namespace PckStudio.Extensions
int idx = line.IndexOf(' ');
if (idx == -1 || line.Length - 1 == idx)
continue;
file.AddProperty(line.Substring(0, idx).Replace(":", string.Empty), line.Substring(idx + 1));
asset.AddProperty(line.Substring(0, idx).Replace(":", string.Empty), line.Substring(idx + 1));
}
}
internal static string SerializePropertiesToString(this PckAsset file)
internal static string SerializePropertiesToString(this PckAsset asset)
{
StringBuilder builder = new StringBuilder(file.PropertyCount * 20);
foreach (var property in file.GetProperties())
StringBuilder builder = new StringBuilder(asset.PropertyCount * 20);
foreach (var property in asset.GetProperties())
{
builder.AppendLine(property.Key + ": " + property.Value);
}

View File

@@ -11,20 +11,20 @@ namespace PckStudio.Extensions
{
internal static class PckFileExtensions
{
internal static PckAsset CreateNewFileIf(this PckFile pck, bool condition, string filename, PckAssetType filetype, IDataFormatWriter writer)
internal static PckAsset CreateNewAssetIf(this PckFile pck, bool condition, string filename, PckAssetType filetype, IDataFormatWriter writer)
{
if (condition)
{
return pck.CreateNewFile(filename, filetype, writer);
return pck.CreateNewAsset(filename, filetype, writer);
}
return null;
}
internal static PckAsset CreateNewFile(this PckFile pck, string filename, PckAssetType filetype, IDataFormatWriter writer)
internal static PckAsset CreateNewAsset(this PckFile pck, string filename, PckAssetType filetype, IDataFormatWriter writer)
{
var file = pck.CreateNewFile(filename, filetype);
file.SetData(writer);
return file;
var asset = pck.CreateNewAsset(filename, filetype);
asset.SetData(writer);
return asset;
}
}
}

View File

@@ -1,6 +1,6 @@
namespace PckStudio.Forms
{
partial class CreditsForm
partial class ContributorsForm
{
/// <summary>
/// Required designer variable.
@@ -28,88 +28,47 @@
/// </summary>
private void InitializeComponent()
{
System.Windows.Forms.PictureBox pictureBox1;
MetroFramework.Controls.MetroLabel metroLabel1;
MetroFramework.Controls.MetroLabel metroLabel2;
MetroFramework.Controls.MetroLabel metroLabel3;
MetroFramework.Controls.MetroLabel metroLabel4;
MetroFramework.Controls.MetroLabel metroLabel5;
MetroFramework.Controls.MetroLabel metroLabel6;
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(CreditsForm));
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(ContributorsForm));
this.folderBrowserDialog1 = new System.Windows.Forms.FolderBrowserDialog();
this.buildLabel = new MetroFramework.Controls.MetroLabel();
pictureBox1 = new System.Windows.Forms.PictureBox();
this.contributorsLayoutPanel = new System.Windows.Forms.FlowLayoutPanel();
metroLabel1 = new MetroFramework.Controls.MetroLabel();
metroLabel2 = new MetroFramework.Controls.MetroLabel();
metroLabel3 = new MetroFramework.Controls.MetroLabel();
metroLabel4 = new MetroFramework.Controls.MetroLabel();
metroLabel5 = new MetroFramework.Controls.MetroLabel();
metroLabel6 = new MetroFramework.Controls.MetroLabel();
((System.ComponentModel.ISupportInitialize)(pictureBox1)).BeginInit();
this.SuspendLayout();
//
// pictureBox1
//
pictureBox1.BackColor = System.Drawing.Color.Transparent;
pictureBox1.Enabled = false;
pictureBox1.Image = global::PckStudio.Properties.Resources.Splash;
pictureBox1.Location = new System.Drawing.Point(4, 5);
pictureBox1.Margin = new System.Windows.Forms.Padding(0, 0, 11, 0);
pictureBox1.Name = "pictureBox1";
pictureBox1.Size = new System.Drawing.Size(550, 293);
pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
pictureBox1.TabIndex = 0;
pictureBox1.TabStop = false;
//
// metroLabel1
//
metroLabel1.AutoSize = true;
metroLabel1.Enabled = false;
metroLabel1.Location = new System.Drawing.Point(4, 301);
metroLabel1.Location = new System.Drawing.Point(23, 475);
metroLabel1.Name = "metroLabel1";
metroLabel1.Size = new System.Drawing.Size(250, 19);
metroLabel1.Size = new System.Drawing.Size(168, 19);
metroLabel1.TabIndex = 1;
metroLabel1.Text = "Restored and maintained by PhoenixARC";
metroLabel1.Text = "Maintained by PhoenixARC";
metroLabel1.Theme = MetroFramework.MetroThemeStyle.Dark;
//
// metroLabel2
//
metroLabel2.AutoSize = true;
metroLabel2.Enabled = false;
metroLabel2.Location = new System.Drawing.Point(314, 301);
metroLabel2.Location = new System.Drawing.Point(23, 456);
metroLabel2.Name = "metroLabel2";
metroLabel2.Size = new System.Drawing.Size(269, 19);
metroLabel2.Size = new System.Drawing.Size(368, 19);
metroLabel2.TabIndex = 2;
metroLabel2.Text = "Utilizing the Nobledez Website by Newagent";
metroLabel2.Text = "Originally created and developed by jam1garner && Nobledez";
metroLabel2.Theme = MetroFramework.MetroThemeStyle.Dark;
//
// metroLabel3
//
metroLabel3.AutoSize = true;
metroLabel3.Enabled = false;
metroLabel3.Location = new System.Drawing.Point(314, 339);
metroLabel3.Name = "metroLabel3";
metroLabel3.Size = new System.Drawing.Size(212, 19);
metroLabel3.TabIndex = 3;
metroLabel3.Text = "3D skin renderer by Łukasz Rejman";
metroLabel3.Theme = MetroFramework.MetroThemeStyle.Dark;
//
// metroLabel4
//
metroLabel4.AutoSize = true;
metroLabel4.Enabled = false;
metroLabel4.Location = new System.Drawing.Point(314, 320);
metroLabel4.Name = "metroLabel4";
metroLabel4.Size = new System.Drawing.Size(199, 19);
metroLabel4.TabIndex = 4;
metroLabel4.Text = "3D renderer found by Newagent";
metroLabel4.Theme = MetroFramework.MetroThemeStyle.Dark;
//
// metroLabel5
//
metroLabel5.AutoSize = true;
metroLabel5.Enabled = false;
metroLabel5.Location = new System.Drawing.Point(4, 320);
metroLabel5.Location = new System.Drawing.Point(397, 456);
metroLabel5.Name = "metroLabel5";
metroLabel5.Size = new System.Drawing.Size(300, 19);
metroLabel5.TabIndex = 5;
@@ -120,7 +79,7 @@
//
metroLabel6.AutoSize = true;
metroLabel6.Enabled = false;
metroLabel6.Location = new System.Drawing.Point(4, 339);
metroLabel6.Location = new System.Drawing.Point(397, 475);
metroLabel6.Name = "metroLabel6";
metroLabel6.Size = new System.Drawing.Size(203, 19);
metroLabel6.TabIndex = 6;
@@ -132,40 +91,46 @@
this.buildLabel.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(12)))), ((int)(((byte)(34)))), ((int)(((byte)(56)))));
this.buildLabel.Enabled = false;
this.buildLabel.ForeColor = System.Drawing.SystemColors.Control;
this.buildLabel.Location = new System.Drawing.Point(314, 30);
this.buildLabel.Location = new System.Drawing.Point(473, 6);
this.buildLabel.Name = "buildLabel";
this.buildLabel.Size = new System.Drawing.Size(212, 171);
this.buildLabel.Size = new System.Drawing.Size(212, 54);
this.buildLabel.TabIndex = 7;
this.buildLabel.Text = "Build Information";
this.buildLabel.TextAlign = System.Drawing.ContentAlignment.TopRight;
this.buildLabel.Theme = MetroFramework.MetroThemeStyle.Dark;
this.buildLabel.WrapToLine = true;
//
// CreditsForm
// contributorsLayoutPanel
//
this.contributorsLayoutPanel.AutoScroll = true;
this.contributorsLayoutPanel.Location = new System.Drawing.Point(23, 63);
this.contributorsLayoutPanel.Name = "contributorsLayoutPanel";
this.contributorsLayoutPanel.Size = new System.Drawing.Size(684, 390);
this.contributorsLayoutPanel.TabIndex = 8;
//
// ContributorsForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(585, 364);
this.ClientSize = new System.Drawing.Size(730, 500);
this.Controls.Add(this.contributorsLayoutPanel);
this.Controls.Add(this.buildLabel);
this.Controls.Add(metroLabel6);
this.Controls.Add(metroLabel1);
this.Controls.Add(metroLabel5);
this.Controls.Add(metroLabel4);
this.Controls.Add(metroLabel3);
this.Controls.Add(metroLabel2);
this.Controls.Add(pictureBox1);
this.DisplayHeader = false;
this.ForeColor = System.Drawing.SystemColors.ButtonHighlight;
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.MaximizeBox = false;
this.MaximumSize = new System.Drawing.Size(730, 500);
this.MinimizeBox = false;
this.Name = "CreditsForm";
this.Padding = new System.Windows.Forms.Padding(20, 30, 20, 20);
this.MinimumSize = new System.Drawing.Size(730, 500);
this.Name = "ContributorsForm";
this.Resizable = false;
this.ShadowType = MetroFramework.Forms.MetroFormShadowType.DropShadow;
this.Style = MetroFramework.MetroColorStyle.Black;
this.Text = "programInfo";
this.Style = MetroFramework.MetroColorStyle.Silver;
this.Text = "Contributors";
this.Theme = MetroFramework.MetroThemeStyle.Dark;
((System.ComponentModel.ISupportInitialize)(pictureBox1)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();
@@ -175,5 +140,6 @@
private System.Windows.Forms.FolderBrowserDialog folderBrowserDialog1;
private MetroFramework.Controls.MetroLabel buildLabel;
private System.Windows.Forms.FlowLayoutPanel contributorsLayoutPanel;
}
}

View File

@@ -0,0 +1,44 @@
using System;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
using MetroFramework.Forms;
using PckStudio.Internal;
using PckStudio.ToolboxItems;
namespace PckStudio.Forms
{
public partial class ContributorsForm : MetroForm
{
public ContributorsForm()
{
InitializeComponent();
#if false
Task.Run(GetContributors);
#endif
string buildConfig = "";
#if BETA
buildConfig = "Beta";
#elif DEBUG
buildConfig = "Debug";
#elif RELEASE
buildConfig = "Release";
#else
buildConfig = "unknown";
#endif
buildLabel.Text = $"Verion: {Application.ProductVersion}\nBuild Config: {buildConfig}\nBranch: {CommitInfo.BranchName}@{CommitInfo.CommitHash}";
}
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
foreach (var contributorsName in ApplicationScope.Contributors)
{
if (InvokeRequired)
Invoke(() => contributorsLayoutPanel.Controls.Add(new GithubUserPanel(contributorsName)));
else
contributorsLayoutPanel.Controls.Add(new GithubUserPanel(contributorsName));
}
}
}
}

View File

@@ -117,21 +117,12 @@
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="pictureBox1.GenerateMember" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>False</value>
</metadata>
<metadata name="metroLabel1.GenerateMember" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>False</value>
</metadata>
<metadata name="metroLabel2.GenerateMember" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>False</value>
</metadata>
<metadata name="metroLabel3.GenerateMember" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>False</value>
</metadata>
<metadata name="metroLabel4.GenerateMember" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>False</value>
</metadata>
<metadata name="metroLabel5.GenerateMember" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>False</value>
</metadata>

View File

@@ -1,26 +0,0 @@
using System;
using System.Windows.Forms;
using MetroFramework.Forms;
using PckStudio.Internal;
namespace PckStudio.Forms
{
public partial class CreditsForm : MetroForm
{
public CreditsForm()
{
InitializeComponent();
string buildConfig = "";
#if BETA
buildConfig = "Beta";
#elif DEBUG
buildConfig = "Debug";
#elif RELEASE
buildConfig = "Release";
#else
buildConfig = "unknown";
#endif
buildLabel.Text = $"Verion: {Application.ProductVersion}\nBuild Config: {buildConfig}\nBranch: {CommitInfo.BranchName}@{CommitInfo.CommitHash}";
}
}
}

View File

@@ -28,8 +28,8 @@ namespace PckStudio.Forms.Editor
public partial class AudioEditor : MetroForm
{
public string defaultType = "yes";
PckAudioFile audioFile = null;
PckAsset audioPCK;
PckAudioFile _audioFile = null;
PckAsset _audioAsset;
bool _isLittleEndian = false;
MainForm parent = null;
@@ -63,7 +63,7 @@ namespace PckStudio.Forms.Editor
return (PckAudioFile.AudioCategory.EAudioType)Categories.IndexOf(category);
}
public AudioEditor(PckAsset file, bool isLittleEndian)
public AudioEditor(PckAsset asset, bool isLittleEndian)
{
InitializeComponent();
@@ -71,11 +71,11 @@ namespace PckStudio.Forms.Editor
_isLittleEndian = isLittleEndian;
audioPCK = file;
using (var stream = new MemoryStream(file.Data))
_audioAsset = asset;
using (var stream = new MemoryStream(asset.Data))
{
var reader = new PckAudioFileReader(isLittleEndian ? OMI.Endianness.LittleEndian : OMI.Endianness.BigEndian);
audioFile = reader.FromStream(stream);
_audioFile = reader.FromStream(stream);
}
SetUpTree();
@@ -86,7 +86,7 @@ namespace PckStudio.Forms.Editor
treeView1.BeginUpdate();
treeView1.Nodes.Clear();
foreach (var category in audioFile.Categories)
foreach (var category in _audioFile.Categories)
{
// fix songs with directories using backslash instead of forward slash
// Songs with a backslash instead of a forward slash would not play in RPCS3
@@ -96,7 +96,7 @@ namespace PckStudio.Forms.Editor
if (category.audioType == PckAudioFile.AudioCategory.EAudioType.Creative)
{
if (category.Name == "include_overworld" &&
audioFile.TryGetCategory(PckAudioFile.AudioCategory.EAudioType.Overworld, out PckAudioFile.AudioCategory overworldCategory))
_audioFile.TryGetCategory(PckAudioFile.AudioCategory.EAudioType.Overworld, out PckAudioFile.AudioCategory overworldCategory))
{
foreach (var name in category.SongNames.ToList())
{
@@ -112,7 +112,7 @@ namespace PckStudio.Forms.Editor
treeNode.Tag = category;
treeView1.Nodes.Add(treeNode);
}
playOverworldInCreative.Enabled = audioFile.HasCategory(PckAudioFile.AudioCategory.EAudioType.Creative);
playOverworldInCreative.Enabled = _audioFile.HasCategory(PckAudioFile.AudioCategory.EAudioType.Creative);
treeView1.EndUpdate();
}
@@ -141,15 +141,15 @@ namespace PckStudio.Forms.Editor
private void addCategoryStripMenuItem_Click(object sender, EventArgs e)
{
string[] available = Categories.FindAll(str => !audioFile.HasCategory(GetCategoryId(str))).ToArray();
string[] available = Categories.FindAll(str => !_audioFile.HasCategory(GetCategoryId(str))).ToArray();
if (available.Length > 0)
{
using ItemSelectionPopUp add = new ItemSelectionPopUp(available);
if (add.ShowDialog(this) == DialogResult.OK)
audioFile.AddCategory(GetCategoryId(add.SelectedItem));
_audioFile.AddCategory(GetCategoryId(add.SelectedItem));
else return;
var category = audioFile.GetCategory(GetCategoryId(add.SelectedItem));
var category = _audioFile.GetCategory(GetCategoryId(add.SelectedItem));
if (GetCategoryId(add.SelectedItem) == PckAudioFile.AudioCategory.EAudioType.Creative)
{
@@ -190,7 +190,7 @@ namespace PckStudio.Forms.Editor
private void removeCategoryStripMenuItem_Click(object sender, EventArgs e)
{
if (treeView1.SelectedNode is TreeNode main &&
audioFile.RemoveCategory(GetCategoryId(treeView1.SelectedNode.Text)))
_audioFile.RemoveCategory(GetCategoryId(treeView1.SelectedNode.Text)))
{
if(GetCategoryId(treeView1.SelectedNode.Text) == PckAudioFile.AudioCategory.EAudioType.Creative)
{
@@ -360,18 +360,18 @@ namespace PckStudio.Forms.Editor
private void saveToolStripMenuItem1_Click(object sender, EventArgs e)
{
if (!audioFile.HasCategory(PckAudioFile.AudioCategory.EAudioType.Overworld) ||
!audioFile.HasCategory(PckAudioFile.AudioCategory.EAudioType.Nether) ||
!audioFile.HasCategory(PckAudioFile.AudioCategory.EAudioType.End))
if (!_audioFile.HasCategory(PckAudioFile.AudioCategory.EAudioType.Overworld) ||
!_audioFile.HasCategory(PckAudioFile.AudioCategory.EAudioType.Nether) ||
!_audioFile.HasCategory(PckAudioFile.AudioCategory.EAudioType.End))
{
MessageBox.Show(this, "Your changes were not saved. The game will crash when loading your pack if the Overworld, Nether and End categories don't all exist with at least one valid song.", "Mandatory Categories Missing");
return;
}
PckAudioFile.AudioCategory overworldCategory = audioFile.GetCategory(PckAudioFile.AudioCategory.EAudioType.Overworld);
PckAudioFile.AudioCategory overworldCategory = _audioFile.GetCategory(PckAudioFile.AudioCategory.EAudioType.Overworld);
bool songs_missing = false;
foreach (var category in audioFile.Categories)
foreach (var category in _audioFile.Categories)
{
if (category.SongNames.Count < 1)
{
@@ -410,7 +410,7 @@ namespace PckStudio.Forms.Editor
return;
}
audioPCK.SetData(new PckAudioFileWriter(audioFile, _isLittleEndian ? OMI.Endianness.LittleEndian : OMI.Endianness.BigEndian));
_audioAsset.SetData(new PckAudioFileWriter(_audioFile, _isLittleEndian ? OMI.Endianness.LittleEndian : OMI.Endianness.BigEndian));
DialogResult = DialogResult.OK;
}
@@ -433,7 +433,7 @@ namespace PckStudio.Forms.Editor
DialogResult dr = MessageBox.Show(this, "This will delete all unused BINKA songs in the Data directory. This cannot be undone. Are you sure you want to continue?", "Warning", MessageBoxButtons.YesNo);
if (dr != DialogResult.Yes) return;
var totalSongList = new List<string>();
foreach (string song in audioFile.Categories.SelectMany(cat => cat.SongNames))
foreach (string song in _audioFile.Categories.SelectMany(cat => cat.SongNames))
{
Console.WriteLine(song);
totalSongList.Add(song);
@@ -525,7 +525,7 @@ namespace PckStudio.Forms.Editor
if (string.IsNullOrEmpty(ofn.FileName)) return; // Return if name is null or if the user cancels
var totalSongList = new List<string>();
foreach (string song in audioFile.Categories.SelectMany(cat => cat.SongNames))
foreach (string song in _audioFile.Categories.SelectMany(cat => cat.SongNames))
{
totalSongList.Add(song);
}
@@ -573,18 +573,18 @@ namespace PckStudio.Forms.Editor
{
if (!(treeView1.SelectedNode is TreeNode t && t.Tag is PckAudioFile.AudioCategory category)) return;
string[] available = Categories.FindAll(str => !audioFile.HasCategory(GetCategoryId(str))).ToArray();
string[] available = Categories.FindAll(str => !_audioFile.HasCategory(GetCategoryId(str))).ToArray();
if (available.Length > 0)
{
using ItemSelectionPopUp add = new ItemSelectionPopUp(available);
add.ButtonText = "Save";
if (add.ShowDialog(this) != DialogResult.OK) return;
audioFile.RemoveCategory(category.audioType);
_audioFile.RemoveCategory(category.audioType);
audioFile.AddCategory(category.parameterType, GetCategoryId(add.SelectedItem), category.audioType == PckAudioFile.AudioCategory.EAudioType.Overworld && playOverworldInCreative.Checked ? "include_overworld" : "");
_audioFile.AddCategory(category.parameterType, GetCategoryId(add.SelectedItem), category.audioType == PckAudioFile.AudioCategory.EAudioType.Overworld && playOverworldInCreative.Checked ? "include_overworld" : "");
var newCategory = audioFile.GetCategory(GetCategoryId(add.SelectedItem));
var newCategory = _audioFile.GetCategory(GetCategoryId(add.SelectedItem));
category.SongNames.ForEach(c => newCategory.SongNames.Add(c));
@@ -603,7 +603,7 @@ namespace PckStudio.Forms.Editor
if (treeView1.Nodes.Count < 1 || !parent.CreateDataFolder()) return;
string musicdir = Path.Combine(parent.GetDataPath(), "Music");
Directory.CreateDirectory(musicdir);
foreach (var category in audioFile.Categories)
foreach (var category in _audioFile.Categories)
{
for (var i = 0; i < category.SongNames.Count; i++) // using standard for loop so the list can be modified
{

View File

@@ -21,7 +21,7 @@ namespace PckStudio.Forms.Editor
public partial class BehaviourEditor : MetroForm
{
// Behaviours File Format research by Miku and MattNL
private readonly PckAsset _file;
private readonly PckAsset _asset;
BehaviourFile behaviourFile;
private readonly List<EntityInfo> BehaviourData = Entities.BehaviourInfos;
@@ -54,15 +54,15 @@ namespace PckStudio.Forms.Editor
treeView1.EndUpdate();
}
public BehaviourEditor(PckAsset file)
public BehaviourEditor(PckAsset asset)
{
InitializeComponent();
saveToolStripMenuItem1.Visible = !Settings.Default.AutoSaveChanges;
_file = file;
_asset = asset;
using (var stream = new MemoryStream(file.Data))
using (var stream = new MemoryStream(asset.Data))
{
var reader = new BehavioursReader();
behaviourFile = reader.FromStream(stream);
@@ -255,7 +255,7 @@ namespace PckStudio.Forms.Editor
}
}
_file.SetData(new BehavioursWriter(behaviourFile));
_asset.SetData(new BehavioursWriter(behaviourFile));
DialogResult = DialogResult.OK;
}

View File

@@ -19,22 +19,22 @@ namespace PckStudio.Forms.Editor
ColorContainer colourfile;
string clipboard_color = "#FFFFFF";
private readonly PckAsset _file;
private readonly PckAsset _asset;
List<TreeNode> colorCache = new List<TreeNode>();
List<TreeNode> waterCache = new List<TreeNode>();
List<TreeNode> underwaterCache = new List<TreeNode>();
List<TreeNode> fogCache = new List<TreeNode>();
public COLEditor(PckAsset file)
public COLEditor(PckAsset asset)
{
InitializeComponent();
saveToolStripMenuItem1.Visible = !Settings.Default.AutoSaveChanges;
_file = file;
_asset = asset;
using(var stream = new MemoryStream(file.Data))
using(var stream = new MemoryStream(asset.Data))
{
var reader = new COLFileReader();
colourfile = reader.FromStream(stream);
@@ -288,7 +288,7 @@ namespace PckStudio.Forms.Editor
private void saveToolStripMenuItem1_Click(object sender, EventArgs e)
{
_file.SetData(new COLFileWriter(colourfile));
_asset.SetData(new COLFileWriter(colourfile));
DialogResult = DialogResult.OK;
}

View File

@@ -19,13 +19,13 @@ namespace PckStudio.Forms.Editor
{
DataTable tbl;
LOCFile currentLoc;
PckAsset _file;
PckAsset _asset;
public LOCEditor(PckAsset file)
public LOCEditor(PckAsset asset)
{
InitializeComponent();
_file = file;
using (var ms = new MemoryStream(file.Data))
_asset = asset;
using (var ms = new MemoryStream(asset.Data))
{
var reader = new LOCFileReader();
currentLoc = reader.FromStream(ms);
@@ -145,7 +145,7 @@ namespace PckStudio.Forms.Editor
private void saveToolStripMenuItem_Click(object sender, EventArgs e)
{
_file.SetData(new LOCFileWriter(currentLoc, 2));
_asset.SetData(new LOCFileWriter(currentLoc, 2));
DialogResult = DialogResult.OK;
}

View File

@@ -19,7 +19,7 @@ namespace PckStudio.Forms.Editor
public partial class MaterialsEditor : MetroForm
{
// Materials File Format research by PhoenixARC
private readonly PckAsset _file;
private readonly PckAsset _asset;
MaterialContainer materialFile;
private readonly List<EntityInfo> MaterialData = Entities.BehaviourInfos;
@@ -64,12 +64,12 @@ namespace PckStudio.Forms.Editor
treeView1.EndUpdate();
}
public MaterialsEditor(PckAsset file)
public MaterialsEditor(PckAsset asset)
{
InitializeComponent();
_file = file;
_asset = asset;
using (var stream = new MemoryStream(file.Data))
using (var stream = new MemoryStream(asset.Data))
{
var reader = new MaterialFileReader();
materialFile = reader.FromStream(stream);
@@ -136,7 +136,7 @@ namespace PckStudio.Forms.Editor
materialFile.Add(mat);
}
_file.SetData(new MaterialFileWriter(materialFile));
_asset.SetData(new MaterialFileWriter(materialFile));
DialogResult = DialogResult.OK;
}

View File

@@ -170,10 +170,10 @@ namespace PckStudio.Forms.Editor
private bool AcquireColorTable(PckFile pckFile)
{
if (pckFile.TryGetFile("colours.col", PckAssetType.ColourTableFile, out var colFile) &&
colFile.Size > 0)
if (pckFile.TryGetAsset("colours.col", PckAssetType.ColourTableFile, out var colAsset) &&
colAsset.Size > 0)
{
using var ms = new MemoryStream(colFile.Data);
using var ms = new MemoryStream(colAsset.Data);
var reader = new COLFileReader();
_colourTable = reader.FromStream(ms);
return true;
@@ -243,18 +243,18 @@ namespace PckStudio.Forms.Editor
if (animationButton.Enabled = _atlasType == "blocks" || _atlasType == "items")
{
PckAsset animationFile;
PckAsset animationAsset;
bool hasAnimation =
_pckFile.TryGetValue($"res/textures/{_atlasType}/{dataTile.Tile.InternalName}.png", PckAssetType.TextureFile, out animationFile) ||
_pckFile.TryGetValue($"res/textures/{_atlasType}/{dataTile.Tile.InternalName}.tga", PckAssetType.TextureFile, out animationFile);
_pckFile.TryGetValue($"res/textures/{_atlasType}/{dataTile.Tile.InternalName}.png", PckAssetType.TextureFile, out animationAsset) ||
_pckFile.TryGetValue($"res/textures/{_atlasType}/{dataTile.Tile.InternalName}.tga", PckAssetType.TextureFile, out animationAsset);
animationButton.Text = hasAnimation ? "Edit Animation" : "Create Animation";
if (playAnimationsToolStripMenuItem.Checked &&
hasAnimation &&
animationFile.Size > 0)
animationAsset.Size > 0)
{
var animation = animationFile.GetDeserializedData(AnimationDeserializer.DefaultDeserializer);
var animation = animationAsset.GetDeserializedData(AnimationDeserializer.DefaultDeserializer);
selectTilePictureBox.Image = animation.CreateAnimationImage();
selectTilePictureBox.Start();
}

View File

@@ -1,4 +1,5 @@
using OMI;
using DiscordRPC;
using OMI;
using OMI.Formats.Pck;
using OMI.Workers.Pck;
using PckStudio.Extensions;
@@ -37,27 +38,27 @@ namespace PckStudio.Popups
{
if (fileTypeComboBox.SelectedIndex >= 0 && fileTypeComboBox.SelectedIndex <= 13)
{
applyBulkProperties(_pckFile.GetFiles(), fileTypeComboBox.SelectedIndex - 1);
applyBulkProperties(_pckFile.GetAssets(), fileTypeComboBox.SelectedIndex - 1);
DialogResult = DialogResult.OK;
return;
}
MessageBox.Show(this, "Please select a filetype before applying");
}
private void applyBulkProperties(IReadOnlyCollection<PckAsset> files, int index)
private void applyBulkProperties(IReadOnlyCollection<PckAsset> assets, int index)
{
foreach (PckAsset file in files)
foreach (PckAsset asset in assets)
{
if (file.Type == PckAssetType.TexturePackInfoFile ||
file.Type == PckAssetType.SkinDataFile)
if (asset.Type == PckAssetType.TexturePackInfoFile ||
asset.Type == PckAssetType.SkinDataFile)
{
try
{
var reader = new PckFileReader(_endianness);
using var ms = new MemoryStream(file.Data);
using var ms = new MemoryStream(asset.Data);
PckFile subPCK = reader.FromStream(ms);
applyBulkProperties(subPCK.GetFiles(), index);
file.SetData(new PckFileWriter(subPCK, _endianness));
applyBulkProperties(subPCK.GetAssets(), index);
asset.SetData(new PckFileWriter(subPCK, _endianness));
}
catch (OverflowException ex)
{
@@ -65,9 +66,9 @@ namespace PckStudio.Popups
}
}
if (index == -1 || (Enum.IsDefined(typeof(PckAssetType), index) && (int)file.Type == index))
if (index == -1 || (Enum.IsDefined(typeof(PckAssetType), index) && (int)asset.Type == index))
{
file.AddProperty(propertyKeyTextBox.Text, propertyValueTextBox.Text);
asset.AddProperty(propertyKeyTextBox.Text, propertyValueTextBox.Text);
}
}

View File

@@ -9,6 +9,6 @@ namespace PckStudio.Interfaces
{
internal interface IPckAssetDeserializer<T>
{
public T Deserialize(PckAsset file);
public T Deserialize(PckAsset asset);
}
}

View File

@@ -9,6 +9,6 @@ namespace PckStudio.Interfaces
{
internal interface IPckAssetSerializer<T>
{
public void Serialize(T obj, ref PckAsset file);
public void Serialize(T obj, ref PckAsset asset);
}
}

View File

@@ -7,6 +7,8 @@ using PckStudio.Extensions;
using System.Globalization;
using PckStudio.Internal.Json;
using PckStudio.Internal.Misc;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace PckStudio.Internal
{
@@ -14,6 +16,8 @@ namespace PckStudio.Internal
{
public static FileCacher DataCacher { get; private set; }
public static Octokit.RepositoryContributor[] Contributors { get; private set; }
private static Image[] _entityImages;
public static Image[] EntityImages => _entityImages;
@@ -41,8 +45,17 @@ namespace PckStudio.Internal
_ = Tiles.PaintingImageList;
SettingsManager.Initialize();
CultureInfo.CurrentCulture = CultureInfo.InvariantCulture;
Task.Run(GetContributors);
}
Profiler.Stop();
}
internal static void GetContributors()
{
var ghClient = new Octokit.GitHubClient(new Octokit.ProductHeaderValue(Application.ProductName + "Credits"));
var allContributorsAct = ghClient.Repository.GetAllContributors("PhoenixARC", "-PCK-Studio");
allContributorsAct.Wait();
Contributors = allContributorsAct.Result.ToArray();
}
}
}

View File

@@ -16,14 +16,14 @@ namespace PckStudio.Internal.Deserializer
{
public static readonly AnimationDeserializer DefaultDeserializer = new AnimationDeserializer();
public Animation Deserialize(PckAsset file)
public Animation Deserialize(PckAsset asset)
{
_ = file ?? throw new ArgumentNullException(nameof(file));
if (file.Size > 0)
_ = asset ?? throw new ArgumentNullException(nameof(asset));
if (asset.Size > 0)
{
var texture = file.GetTexture();
var texture = asset.GetTexture();
var frameTextures = texture.Split(ImageLayoutDirection.Vertical);
var _animation = new Animation(frameTextures, file.GetProperty("ANIM"));
var _animation = new Animation(frameTextures, asset.GetProperty("ANIM"));
return _animation;
}
return Animation.CreateEmpty();

View File

@@ -18,19 +18,19 @@ namespace PckStudio.Internal.Deserializer
public static readonly ImageDeserializer DefaultDeserializer = new ImageDeserializer();
private static Image EmptyImage = new Bitmap(1, 1, PixelFormat.Format32bppArgb);
public Image Deserialize(PckAsset file)
public Image Deserialize(PckAsset asset)
{
using var stream = new MemoryStream(file.Data);
using var stream = new MemoryStream(asset.Data);
try
{
if (Path.GetExtension(file.Filename) == ".tga")
if (Path.GetExtension(asset.Filename) == ".tga")
return TGADeserializer.DeserializeFromStream(stream);
else
return Image.FromStream(stream);
}
catch (Exception ex)
{
Trace.TraceError($"Failed to read image from pck file data({file.Filename}).");
Trace.TraceError($"Failed to read image from pck file data({asset.Filename}).");
Debug.WriteLine(ex.Message);
return EmptyImage;
}

View File

@@ -15,8 +15,8 @@ namespace PckStudio.Internal
private bool CheckForSkinAndCapeFiles(TreeNode node)
{
return node.TryGetTagData(out PckAsset file) &&
(file.Type == PckAssetType.SkinFile || file.Type == PckAssetType.CapeFile);
return node.TryGetTagData(out PckAsset asset) &&
(asset.Type == PckAssetType.SkinFile || asset.Type == PckAssetType.CapeFile);
}
public int Compare(object x, object y)

View File

@@ -17,12 +17,12 @@ namespace PckStudio.Internal.Serializer
{
public static readonly AnimationSerializer DefaultSerializer = new AnimationSerializer();
public void Serialize(Animation animation, ref PckAsset file)
public void Serialize(Animation animation, ref PckAsset asset)
{
string anim = animation.BuildAnim();
file.SetProperty("ANIM", anim);
asset.SetProperty("ANIM", anim);
var texture = animation.BuildTexture();
file.SetTexture(texture);
asset.SetTexture(texture);
}
}
}

View File

@@ -17,20 +17,20 @@ namespace PckStudio.Internal.Serializer
{
public static readonly ImageSerializer DefaultSerializer = new ImageSerializer();
public void Serialize(Image obj, ref PckAsset file)
public void Serialize(Image obj, ref PckAsset asset)
{
var stream = new MemoryStream();
try
{
if (Path.GetExtension(file.Filename) == ".tga")
if (Path.GetExtension(asset.Filename) == ".tga")
TGASerializer.SerializeToStream(stream, obj);
else
obj.Save(stream, ImageFormat.Png);
file.SetData(stream.ToArray());
asset.SetData(stream.ToArray());
}
catch (Exception ex)
{
Trace.TraceError($"Failed to serialize image to pck file data({file.Filename}).");
Trace.TraceError($"Failed to serialize image to pck file data({asset.Filename}).");
Debug.WriteLine(ex.Message);
}
}

View File

@@ -89,12 +89,12 @@
this.texturePackToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.mashUpPackToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.openToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.recentlyOpenToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.packSettingsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.fullBoxSupportToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.saveToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem();
this.saveToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.closeToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.recentlyOpenToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.exitToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.editToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.quickChangeToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
@@ -534,13 +534,13 @@
this.fileToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.newToolStripMenuItem,
this.openToolStripMenuItem,
this.packSettingsToolStripMenuItem,
this.saveToolStripMenuItem1,
this.saveToolStripMenuItem,
this.closeToolStripMenuItem,
toolStripSeparator2,
this.recentlyOpenToolStripMenuItem,
toolStripSeparator4,
this.closeToolStripMenuItem,
this.packSettingsToolStripMenuItem,
this.saveToolStripMenuItem1,
this.saveToolStripMenuItem,
this.exitToolStripMenuItem});
this.fileToolStripMenuItem.ForeColor = System.Drawing.Color.Silver;
this.fileToolStripMenuItem.Name = "fileToolStripMenuItem";
@@ -579,6 +579,11 @@
this.openToolStripMenuItem.Name = "openToolStripMenuItem";
this.openToolStripMenuItem.Click += new System.EventHandler(this.openToolStripMenuItem_Click);
//
// recentlyOpenToolStripMenuItem
//
resources.ApplyResources(this.recentlyOpenToolStripMenuItem, "recentlyOpenToolStripMenuItem");
this.recentlyOpenToolStripMenuItem.Name = "recentlyOpenToolStripMenuItem";
//
// packSettingsToolStripMenuItem
//
this.packSettingsToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
@@ -608,19 +613,14 @@
//
// closeToolStripMenuItem
//
this.closeToolStripMenuItem.Name = "closeToolStripMenuItem";
resources.ApplyResources(this.closeToolStripMenuItem, "closeToolStripMenuItem");
this.closeToolStripMenuItem.Name = "closeToolStripMenuItem";
this.closeToolStripMenuItem.Click += new System.EventHandler(this.closeToolStripMenuItem_Click);
//
// recentlyOpenToolStripMenuItem
//
this.recentlyOpenToolStripMenuItem.Name = "recentlyOpenToolStripMenuItem";
resources.ApplyResources(this.recentlyOpenToolStripMenuItem, "recentlyOpenToolStripMenuItem");
//
// exitToolStripMenuItem
//
this.exitToolStripMenuItem.Name = "exitToolStripMenuItem";
resources.ApplyResources(this.exitToolStripMenuItem, "exitToolStripMenuItem");
this.exitToolStripMenuItem.Name = "exitToolStripMenuItem";
this.exitToolStripMenuItem.Click += new System.EventHandler(this.exitToolStripMenuItem_Click);
//
// editToolStripMenuItem
@@ -648,8 +648,8 @@
//
// openPckManagerToolStripMenuItem
//
this.openPckManagerToolStripMenuItem.Name = "openPckManagerToolStripMenuItem";
resources.ApplyResources(this.openPckManagerToolStripMenuItem, "openPckManagerToolStripMenuItem");
this.openPckManagerToolStripMenuItem.Name = "openPckManagerToolStripMenuItem";
this.openPckManagerToolStripMenuItem.Click += new System.EventHandler(this.openPckManagerToolStripMenuItem_Click);
//
// convertMusicFilesToolStripMenuItem
@@ -1116,7 +1116,7 @@
this.treeViewMain.PathSeparator = "/";
this.treeViewMain.BeforeLabelEdit += new System.Windows.Forms.NodeLabelEditEventHandler(this.treeViewMain_BeforeLabelEdit);
this.treeViewMain.ItemDrag += new System.Windows.Forms.ItemDragEventHandler(this.treeViewMain_ItemDrag);
this.treeViewMain.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(this.selectNode);
this.treeViewMain.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(this.treeViewMain_AfterSelect);
this.treeViewMain.DragDrop += new System.Windows.Forms.DragEventHandler(this.treeViewMain_DragDrop);
this.treeViewMain.DragEnter += new System.Windows.Forms.DragEventHandler(this.treeViewMain_DragEnter);
this.treeViewMain.DragOver += new System.Windows.Forms.DragEventHandler(this.treeViewMain_DragOver);

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -134,6 +134,12 @@
<Reference Include="WindowsFormsIntegration" />
</ItemGroup>
<ItemGroup>
<Compile Include="Forms\ContributorsForm.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Forms\ContributorsForm.Designer.cs">
<DependentUpon>ContributorsForm.cs</DependentUpon>
</Compile>
<Compile Include="Extensions\OpenTkMatrixExtensions.cs" />
<Compile Include="Internal\IO\PSM\PSMFileReader.cs" />
<Compile Include="Internal\IO\PSM\PSMFileWriter.cs" />
@@ -209,6 +215,12 @@
<Compile Include="ToolboxItems\BlendPictureBox.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="ToolboxItems\GithubUserPanel.cs">
<SubType>UserControl</SubType>
</Compile>
<Compile Include="ToolboxItems\GithubUserPanel.Designer.cs">
<DependentUpon>GithubUserPanel.cs</DependentUpon>
</Compile>
<Compile Include="ToolboxItems\InterpolationPictureBox.cs">
<SubType>Component</SubType>
</Compile>
@@ -450,14 +462,11 @@
</Compile>
<Compile Include="Internal\PckNodeSorter.cs" />
<Compile Include="Program.cs" />
<Compile Include="Forms\CreditsForm.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Forms\CreditsForm.Designer.cs">
<DependentUpon>CreditsForm.cs</DependentUpon>
</Compile>
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Internal\IO\3DST\TextureCodec.cs" />
<EmbeddedResource Include="Forms\ContributorsForm.resx">
<DependentUpon>ContributorsForm.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Forms\Features\CemuPanel.resx">
<DependentUpon>CemuPanel.cs</DependentUpon>
</EmbeddedResource>
@@ -585,9 +594,6 @@
<DependentUpon>AudioEditor.cs</DependentUpon>
<SubType>Designer</SubType>
</EmbeddedResource>
<EmbeddedResource Include="Forms\CreditsForm.resx">
<DependentUpon>CreditsForm.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>PublicResXFileCodeGenerator</Generator>
<SubType>Designer</SubType>
@@ -596,6 +602,9 @@
<EmbeddedResource Include="Rendering\SkinRenderer.resx">
<DependentUpon>SkinRenderer.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="ToolboxItems\GithubUserPanel.resx">
<DependentUpon>GithubUserPanel.cs</DependentUpon>
</EmbeddedResource>
<None Include="CommunityKey.snk" />
<None Include="Properties\app.manifest" />
<None Include="Properties\Settings.settings">
@@ -658,7 +667,6 @@
<None Include="Resources\external\Xbox.png" />
<None Include="Resources\external\PS3.png" />
<None Include="Resources\external\WiiU.png" />
<None Include="Resources\Splash.png" />
<None Include="Resources\pckOpen.png" />
<None Include="Resources\pckDrop.png" />
<None Include="Resources\binka\binka_encode.exe" />
@@ -746,6 +754,9 @@
<PackageReference Include="OpenTK.GLControl">
<Version>3.3.3</Version>
</PackageReference>
<PackageReference Include="Octokit">
<Version>12.0.0</Version>
</PackageReference>
<PackageReference Include="System.ValueTuple">
<Version>4.5.0</Version>
</PackageReference>

View File

@@ -1269,16 +1269,6 @@ namespace PckStudio.Properties {
}
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary>
public static System.Drawing.Bitmap Splash {
get {
object obj = ResourceManager.GetObject("Splash", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary>

View File

@@ -283,9 +283,6 @@
<data name="explosions_atlas" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\atlases\explosion.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="Splash" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\Splash.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="WiiU" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\external\WiiU.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 134 KiB

View File

@@ -0,0 +1,90 @@
namespace PckStudio.ToolboxItems
{
partial class GithubUserPanel
{
/// <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 Component 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.userPictureBox = new System.Windows.Forms.PictureBox();
this.userNameLabel = new MetroFramework.Controls.MetroLabel();
this.aboutButton = new MetroFramework.Controls.MetroButton();
((System.ComponentModel.ISupportInitialize)(this.userPictureBox)).BeginInit();
this.SuspendLayout();
//
// userPictureBox
//
this.userPictureBox.BackColor = System.Drawing.Color.Transparent;
this.userPictureBox.Location = new System.Drawing.Point(8, 34);
this.userPictureBox.Name = "userPictureBox";
this.userPictureBox.Size = new System.Drawing.Size(100, 100);
this.userPictureBox.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom;
this.userPictureBox.TabIndex = 0;
this.userPictureBox.TabStop = false;
//
// userNameLabel
//
this.userNameLabel.FontSize = MetroFramework.MetroLabelSize.Tall;
this.userNameLabel.Location = new System.Drawing.Point(8, 6);
this.userNameLabel.Name = "userNameLabel";
this.userNameLabel.Size = new System.Drawing.Size(100, 25);
this.userNameLabel.TabIndex = 0;
this.userNameLabel.Text = "user name";
this.userNameLabel.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
this.userNameLabel.Theme = MetroFramework.MetroThemeStyle.Dark;
//
// aboutButton
//
this.aboutButton.Location = new System.Drawing.Point(8, 140);
this.aboutButton.Name = "aboutButton";
this.aboutButton.Size = new System.Drawing.Size(100, 23);
this.aboutButton.TabIndex = 0;
this.aboutButton.Text = "about button";
this.aboutButton.Theme = MetroFramework.MetroThemeStyle.Dark;
this.aboutButton.UseSelectable = true;
//
// GithubUserPanel
//
this.Controls.Add(this.userPictureBox);
this.Controls.Add(this.aboutButton);
this.Controls.Add(this.userNameLabel);
this.MaximumSize = new System.Drawing.Size(115, 170);
this.MinimumSize = new System.Drawing.Size(115, 170);
this.Name = "GithubUserPanel";
this.Padding = new System.Windows.Forms.Padding(5);
this.Size = new System.Drawing.Size(115, 170);
this.Theme = MetroFramework.MetroThemeStyle.Dark;
((System.ComponentModel.ISupportInitialize)(this.userPictureBox)).EndInit();
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.PictureBox userPictureBox;
private MetroFramework.Controls.MetroLabel userNameLabel;
private MetroFramework.Controls.MetroButton aboutButton;
}
}

View File

@@ -0,0 +1,79 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Linq;
using System.Text;
using Octokit;
using MetroFramework.Controls;
using System.Drawing;
using System.Net;
using System.IO;
using System.Threading.Tasks;
using PckStudio.Internal;
using System.Drawing.Imaging;
namespace PckStudio.ToolboxItems
{
public partial class GithubUserPanel : MetroUserControl
{
private Author _contributor;
public GithubUserPanel()
{
InitializeComponent();
}
public GithubUserPanel(Author contributor) : this()
{
_contributor = contributor;
}
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
if (DesignMode)
return;
Visible = false;
Task.Run(LoadAuthor);
}
private void LoadAuthor()
{
// TODO: find a better way to check if the avatar has changed since last cache.
string cacheKey = Convert.ToBase64String(Encoding.Default.GetBytes(_contributor.AvatarUrl));
if (!ApplicationScope.DataCacher.HasFileCached(cacheKey))
{
using (WebClient webClient = new WebClient())
{
Stream avatarImgStream = webClient.OpenRead(_contributor.AvatarUrl);
MemoryStream ms = new MemoryStream();
new Bitmap(avatarImgStream).Save(ms, ImageFormat.Png);
avatarImgStream.Flush();
avatarImgStream.Dispose();
ApplicationScope.DataCacher.Cache(ms.ToArray(), cacheKey);
}
}
Image avatarUserImg = Image.FromFile(ApplicationScope.DataCacher.GetCachedFilepath(cacheKey));
Action setUiElements = () =>
{
userPictureBox.Image = avatarUserImg;
userNameLabel.Text = _contributor.Login;
aboutButton.Text = "Github profile";
aboutButton.Click += (s, e) => Process.Start(_contributor.HtmlUrl);
Visible = true;
};
if (InvokeRequired)
{
Invoke(setUiElements);
return;
}
setUiElements();
}
}
}

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>

2
Vendor/OMI-Lib vendored