mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/PCK-Studio.git
synced 2026-06-14 21:41:52 +00:00
Rename every variable-/parameter-/propertyname of type PckAsset from 'file' to 'asset'
This commit is contained in:
@@ -19,57 +19,57 @@ 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);
|
||||
}
|
||||
|
||||
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]))
|
||||
@@ -81,15 +81,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)
|
||||
@@ -97,14 +97,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);
|
||||
}
|
||||
|
||||
@@ -22,9 +22,9 @@ namespace PckStudio.Extensions
|
||||
|
||||
internal static PckAsset CreateNewFile(this PckFile pck, string filename, PckAssetType filetype, IDataFormatWriter writer)
|
||||
{
|
||||
var file = pck.CreateNewFile(filename, filetype);
|
||||
file.SetData(writer);
|
||||
return file;
|
||||
var asset = pck.CreateNewFile(filename, filetype);
|
||||
asset.SetData(writer);
|
||||
return asset;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
{
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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.TryGetFile("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();
|
||||
}
|
||||
|
||||
@@ -17,13 +17,13 @@ namespace PckStudio.Popups
|
||||
{
|
||||
public partial class AddNewSkin : MetroFramework.Forms.MetroForm
|
||||
{
|
||||
public PckAsset SkinFile => skin;
|
||||
public PckAsset CapeFile => cape;
|
||||
public bool HasCape => cape is not null;
|
||||
public PckAsset SkinAsset => _skin;
|
||||
public PckAsset CapeAsset => _cape;
|
||||
public bool HasCape => _cape is not null;
|
||||
|
||||
private LOCFile currentLoc;
|
||||
private PckAsset skin = new PckAsset("dlcskinXYXYXYXY", PckAssetType.SkinFile);
|
||||
private PckAsset cape;
|
||||
private PckAsset _skin = new PckAsset("dlcskinXYXYXYXY", PckAssetType.SkinFile);
|
||||
private PckAsset _cape;
|
||||
private SkinANIM anim = new SkinANIM();
|
||||
private Random rng = new Random();
|
||||
|
||||
@@ -226,8 +226,8 @@ namespace PckStudio.Popups
|
||||
return;
|
||||
}
|
||||
capePictureBox.Image = Image.FromFile(ofd.FileName);
|
||||
cape ??= new PckAsset("dlccapeXYXYXYXY", PckAssetType.CapeFile);
|
||||
cape.SetData(File.ReadAllBytes(ofd.FileName));
|
||||
_cape ??= new PckAsset("dlccapeXYXYXYXY", PckAssetType.CapeFile);
|
||||
_cape.SetData(File.ReadAllBytes(ofd.FileName));
|
||||
contextMenuCape.Items[0].Text = "Replace";
|
||||
capeLabel.Visible = false;
|
||||
contextMenuCape.Visible = true;
|
||||
@@ -243,35 +243,35 @@ namespace PckStudio.Popups
|
||||
return;
|
||||
}
|
||||
string skinId = _skinId.ToString("d08");
|
||||
skin.Filename = $"dlcskin{skinId}.png";
|
||||
skin.AddProperty("DISPLAYNAME", textSkinName.Text);
|
||||
_skin.Filename = $"dlcskin{skinId}.png";
|
||||
_skin.AddProperty("DISPLAYNAME", textSkinName.Text);
|
||||
|
||||
if (currentLoc is not null)
|
||||
{
|
||||
string skinDisplayNameLocKey = $"IDS_dlcskin{skinId}_DISPLAYNAME";
|
||||
skin.AddProperty("DISPLAYNAMEID", skinDisplayNameLocKey);
|
||||
_skin.AddProperty("DISPLAYNAMEID", skinDisplayNameLocKey);
|
||||
currentLoc.AddLocKey(skinDisplayNameLocKey, textSkinName.Text);
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(textThemeName.Text))
|
||||
{
|
||||
skin.AddProperty("THEMENAME", textThemeName.Text);
|
||||
_skin.AddProperty("THEMENAME", textThemeName.Text);
|
||||
if (currentLoc is not null)
|
||||
{
|
||||
skin.AddProperty("THEMENAMEID", $"IDS_dlcskin{skinId}_THEMENAME");
|
||||
_skin.AddProperty("THEMENAMEID", $"IDS_dlcskin{skinId}_THEMENAME");
|
||||
currentLoc.AddLocKey($"IDS_dlcskin{skinId}_THEMENAME", textThemeName.Text);
|
||||
}
|
||||
}
|
||||
skin.AddProperty("ANIM", anim);
|
||||
skin.AddProperty("GAME_FLAGS", "0x18");
|
||||
skin.AddProperty("FREE", "1");
|
||||
_skin.AddProperty("ANIM", anim);
|
||||
_skin.AddProperty("GAME_FLAGS", "0x18");
|
||||
_skin.AddProperty("FREE", "1");
|
||||
|
||||
if (HasCape)
|
||||
{
|
||||
cape.Filename = $"dlccape{skinId}.png";
|
||||
skin.AddProperty("CAPEPATH", cape.Filename);
|
||||
_cape.Filename = $"dlccape{skinId}.png";
|
||||
_skin.AddProperty("CAPEPATH", _cape.Filename);
|
||||
}
|
||||
skin.SetTexture(skinPictureBox.Image);
|
||||
_skin.SetTexture(skinPictureBox.Image);
|
||||
DialogResult = DialogResult.OK;
|
||||
Close();
|
||||
}
|
||||
@@ -288,9 +288,9 @@ namespace PckStudio.Popups
|
||||
if (MessageBox.Show(this, "Create your own custom skin model?", "", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1) != DialogResult.Yes)
|
||||
return;
|
||||
|
||||
skin.SetTexture(Resources.classic_template);
|
||||
_skin.SetTexture(Resources.classic_template);
|
||||
|
||||
using generateModel generate = new generateModel(skin);
|
||||
using generateModel generate = new generateModel(_skin);
|
||||
|
||||
if (generate.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using OMI;
|
||||
using DiscordRPC;
|
||||
using OMI;
|
||||
using OMI.Formats.Pck;
|
||||
using OMI.Workers.Pck;
|
||||
using PckStudio.Extensions;
|
||||
@@ -44,20 +45,20 @@ namespace PckStudio.Popups
|
||||
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));
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@ namespace PckStudio.Forms
|
||||
left,
|
||||
}
|
||||
|
||||
private PckAsset _file;
|
||||
private PckAsset _asset;
|
||||
private SkinANIM _ANIM;
|
||||
|
||||
private static Color _backgroundColor = Color.FromArgb(0xff, 0x50, 0x50, 0x50);
|
||||
@@ -126,22 +126,22 @@ namespace PckStudio.Forms
|
||||
}
|
||||
}
|
||||
|
||||
public generateModel(PckAsset file)
|
||||
public generateModel(PckAsset asset)
|
||||
{
|
||||
MessageBox.Show(this, "This feature is now considered deprecated and will no longer recieve updates. A better alternative is currently under development. Use at your own risk.", "Deprecated Feature", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
|
||||
InitializeComponent();
|
||||
|
||||
_file = file;
|
||||
if (file.Size > 0)
|
||||
_asset = asset;
|
||||
if (asset.Size > 0)
|
||||
{
|
||||
using (var ms = new MemoryStream(file.Data))
|
||||
using (var ms = new MemoryStream(asset.Data))
|
||||
{
|
||||
uvPictureBox.Image = Image.FromStream(ms);
|
||||
}
|
||||
}
|
||||
comboParent.Items.Clear();
|
||||
comboParent.Items.AddRange(ValidModelBoxTypes);
|
||||
LoadData(file);
|
||||
LoadData(asset);
|
||||
}
|
||||
private static readonly Regex sWhitespace = new Regex(@"\s+");
|
||||
public static string ReplaceWhitespace(string input, string replacement)
|
||||
@@ -149,9 +149,9 @@ namespace PckStudio.Forms
|
||||
return sWhitespace.Replace(input, replacement);
|
||||
}
|
||||
|
||||
private void LoadData(PckAsset file)
|
||||
private void LoadData(PckAsset asset)
|
||||
{
|
||||
comboParent.Enabled = file.GetMultipleProperties("BOX").All(kv => {
|
||||
comboParent.Enabled = asset.GetMultipleProperties("BOX").All(kv => {
|
||||
var box = SkinBOX.FromString(kv.Value);
|
||||
if (ValidModelBoxTypes.Contains(box.Type))
|
||||
{
|
||||
@@ -160,7 +160,7 @@ namespace PckStudio.Forms
|
||||
}
|
||||
return false;
|
||||
});
|
||||
file.GetMultipleProperties("OFFSET").All(kv => {
|
||||
asset.GetMultipleProperties("OFFSET").All(kv => {
|
||||
string[] offset = ReplaceWhitespace(kv.Value, ",").TrimEnd('\n', '\r', ' ').Split(',');
|
||||
if (offset.Length < 3)
|
||||
return false;
|
||||
@@ -176,7 +176,7 @@ namespace PckStudio.Forms
|
||||
return false;
|
||||
});
|
||||
|
||||
_ANIM = file.GetProperty("ANIM", SkinANIM.FromString);
|
||||
_ANIM = asset.GetProperty("ANIM", SkinANIM.FromString);
|
||||
UpdateListView();
|
||||
Rerender();
|
||||
}
|
||||
@@ -1094,7 +1094,7 @@ namespace PckStudio.Forms
|
||||
{
|
||||
foreach (var part in modelBoxes)
|
||||
{
|
||||
_file.AddProperty("BOX", part);
|
||||
_asset.AddProperty("BOX", part);
|
||||
}
|
||||
|
||||
//Bitmap bitmap2 = new Bitmap(64, 64);
|
||||
|
||||
@@ -9,6 +9,6 @@ namespace PckStudio.Interfaces
|
||||
{
|
||||
internal interface IPckAssetDeserializer<T>
|
||||
{
|
||||
public T Deserialize(PckAsset file);
|
||||
public T Deserialize(PckAsset asset);
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
2
PCK-Studio/MainForm.Designer.cs
generated
2
PCK-Studio/MainForm.Designer.cs
generated
@@ -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
Reference in New Issue
Block a user