From cae8dda315b130e2e7a57a50a54ada46919fded5 Mon Sep 17 00:00:00 2001 From: miku-666 <74728189+NessieHax@users.noreply.github.com> Date: Mon, 10 Nov 2025 04:37:52 +0100 Subject: [PATCH] Rename 'PckEditor' to 'PckAssetBrowserEditor' --- ...r.cs => PckAssetBrowserEditor.Designer.cs} | 4 +- ...{PckEditor.cs => PckAssetBrowserEditor.cs} | 26 ++-- ...Editor.resx => PckAssetBrowserEditor.resx} | 0 PCK-Studio/MainForm.cs | 111 ++++-------------- PCK-Studio/PckStudio.csproj | 10 +- PckStudio.Core/PackInfo.cs | 33 ++---- 6 files changed, 54 insertions(+), 130 deletions(-) rename PCK-Studio/Controls/{PckEditor.Designer.cs => PckAssetBrowserEditor.Designer.cs} (99%) rename PCK-Studio/Controls/{PckEditor.cs => PckAssetBrowserEditor.cs} (99%) rename PCK-Studio/Controls/{PckEditor.resx => PckAssetBrowserEditor.resx} (100%) diff --git a/PCK-Studio/Controls/PckEditor.Designer.cs b/PCK-Studio/Controls/PckAssetBrowserEditor.Designer.cs similarity index 99% rename from PCK-Studio/Controls/PckEditor.Designer.cs rename to PCK-Studio/Controls/PckAssetBrowserEditor.Designer.cs index a5351572..221b9c09 100644 --- a/PCK-Studio/Controls/PckEditor.Designer.cs +++ b/PCK-Studio/Controls/PckAssetBrowserEditor.Designer.cs @@ -2,7 +2,7 @@ namespace PckStudio.Controls { - partial class PckEditor + partial class PckAssetBrowserEditor { /// /// Required designer variable. @@ -32,7 +32,7 @@ namespace PckStudio.Controls { this.components = new System.ComponentModel.Container(); System.Windows.Forms.PictureBox logoPictureBox; - System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(PckEditor)); + System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(PckAssetBrowserEditor)); this.pckFileLabel = new MetroFramework.Controls.MetroLabel(); this.labelImageSize = new MetroFramework.Controls.MetroLabel(); this.fileEntryCountLabel = new MetroFramework.Controls.MetroLabel(); diff --git a/PCK-Studio/Controls/PckEditor.cs b/PCK-Studio/Controls/PckAssetBrowserEditor.cs similarity index 99% rename from PCK-Studio/Controls/PckEditor.cs rename to PCK-Studio/Controls/PckAssetBrowserEditor.cs index c29e6f84..7a4a5f5d 100644 --- a/PCK-Studio/Controls/PckEditor.cs +++ b/PCK-Studio/Controls/PckAssetBrowserEditor.cs @@ -35,24 +35,24 @@ using PckStudio.Internal; using PckStudio.Popups; using PckStudio.Properties; +using PckStudio.Json; +using PckStudio.Rendering; +using PckStudio.ModelSupport; +using PckStudio.Core; +using PckStudio.Core.Json; +using PckStudio.Core.Skin; using PckStudio.Core.Deserializer; using PckStudio.Core.Serializer; -using PckStudio.Core.Json; using PckStudio.Core.FileFormats; -using PckStudio.Core.Skin; -using PckStudio.Rendering; -using PckStudio.Core; -using PckStudio.ModelSupport; -using PckStudio.Json; using PckStudio.Core.IO.PckAudio; using PckStudio.Core.IO._3DST; using PckStudio.Core.Misc; +using PckStudio.Core.DLC; namespace PckStudio.Controls { - internal partial class PckEditor : EditorControl + internal partial class PckAssetBrowserEditor : EditorControl { - private string _location = string.Empty; private readonly OMI.ByteOrder _originalEndianness; @@ -78,15 +78,15 @@ namespace PckStudio.Controls private readonly Dictionary> _pckAssetTypeHandler; - public PckEditor(PackInfo packInfo, ISaveContext saveContext) + public PckAssetBrowserEditor(PackInfo packInfo, ISaveContext saveContext) : base(packInfo, saveContext) { InitializeComponent(); _onModifiedChangeDelegate = OnModify; - _originalEndianness = packInfo.Endianness; - _currentEndianness = packInfo.Endianness; + _originalEndianness = packInfo.ByteOrder; + _currentEndianness = packInfo.ByteOrder; - LittleEndianCheckBox.Visible = packInfo.AllowEndianSwap; + LittleEndianCheckBox.Visible = packInfo.AllowByteOrderSwap; treeViewMain.TreeViewNodeSorter = new PckNodeSorter(); @@ -213,7 +213,7 @@ namespace PckStudio.Controls if (asset.Size <= 0) { - Trace.TraceInformation($"[{nameof(PckEditor)}:{nameof(HandleTextureFile)}] '{asset.Filename}' size is 0."); + Trace.TraceInformation($"[{nameof(PckAssetBrowserEditor)}:{nameof(HandleTextureFile)}] '{asset.Filename}' size is 0."); return; } diff --git a/PCK-Studio/Controls/PckEditor.resx b/PCK-Studio/Controls/PckAssetBrowserEditor.resx similarity index 100% rename from PCK-Studio/Controls/PckEditor.resx rename to PCK-Studio/Controls/PckAssetBrowserEditor.resx diff --git a/PCK-Studio/MainForm.cs b/PCK-Studio/MainForm.cs index 8c31c33a..1f334468 100644 --- a/PCK-Studio/MainForm.cs +++ b/PCK-Studio/MainForm.cs @@ -11,20 +11,21 @@ using OMI.Formats.Languages; using OMI.Workers.Pck; using OMI.Workers.GameRule; using OMI.Workers.Language; -using PckStudio.Properties; -using PckStudio.Forms; -using PckStudio.Forms.Additional_Popups; -using PckStudio.Core.Misc; -using PckStudio.Forms.Features; -using PckStudio.Core.Extensions; -using PckStudio.Popups; -using PckStudio.External.API.Miles; -using PckStudio.Internal.App; -using PckStudio.Interfaces; using PckStudio.Controls; +using PckStudio.External.API.Miles; +using PckStudio.Forms; +using PckStudio.Forms.Features; +using PckStudio.Forms.Additional_Popups; +using PckStudio.Interfaces; using PckStudio.Internal; +using PckStudio.Internal.App; +using PckStudio.Popups; +using PckStudio.Properties; using PckStudio.Core; using PckStudio.Core.App; +using PckStudio.Core.DLC; +using PckStudio.Core.Extensions; +using PckStudio.Core.Interfaces; namespace PckStudio { @@ -59,9 +60,13 @@ namespace PckStudio public void LoadPckFromFile(string filepath) { - Core.Interfaces.IDLCPackage dlcPackage = DLCManager.Default.OpenDLCPackage(filepath); + IDLCPackage dlcPackage = DLCManager.Default.OpenDLCPackage(filepath); Debug.WriteLine(dlcPackage?.GetDLCPackageType()); - AddEditorPage(filepath); + if (dlcPackage is null) + return; + SaveToRecentFiles(filepath); + if (dlcPackage.GetDLCPackageType() == DLCPackageType.Unknown) + AddEditorPage(dlcPackage); } internal void OpenNewPckTab(string caption, string identifier, PackInfo packInfo, ISaveContext saveContext) @@ -71,92 +76,28 @@ namespace PckStudio tabControl.SelectTab(openTabPages[identifier]); return; } - var editor = new PckEditor(packInfo, saveContext); + var editor = new PckAssetBrowserEditor(packInfo, saveContext); AddPage(caption, identifier, editor); } private void AddEditorPage(string caption, string identifier, PackInfo packInfo, ISaveContext saveContext = null) { saveContext ??= GetDefaultSaveContext("./new.pck", "PCK (Minecraft Console Package)"); - var editor = new PckEditor(packInfo, saveContext); + var editor = new PckAssetBrowserEditor(packInfo, saveContext); AddPage(caption, identifier, editor); } - private PckFile ReadPck(string filePath, OMI.ByteOrder byteOrder) + private void AddEditorPage(IDLCPackage dlcPackage) { - var pckReader = new PckFileReader(byteOrder); - return pckReader.FromFile(filePath); - } - - private bool TryOpenPck(string filepath, out PackInfo packInfo) - { - if (!File.Exists(filepath) || !filepath.EndsWith(".pck")) - { - packInfo = PackInfo.Empty; - return false; + PackInfo packInfo = PackInfo.Create((dlcPackage as UnknownDLCPackage).PckFile, default, false); + ISaveContext saveContext = GetDefaultSaveContext("", "PCK (Minecraft Console Package)"); + var editor = new PckAssetBrowserEditor(packInfo, saveContext); + TabPage page = AddPage(dlcPackage.Name, dlcPackage.Name, editor); } - try - { - OMI.ByteOrder byteOrder = OMI.ByteOrder.BigEndian; - PckFile pckFile = ReadPck(filepath, byteOrder); - packInfo = PackInfo.Create(pckFile, byteOrder, true); - return packInfo.IsValid; - } - catch (OverflowException) - { - try - { - // if failed, attempt again in the reverse. THEN throw an error if failed - OMI.ByteOrder byteOrder = OMI.ByteOrder.LittleEndian; - PckFile pckFile = ReadPck(filepath, byteOrder); - packInfo = PackInfo.Create(pckFile, byteOrder, true); - return packInfo.IsValid; - } - catch (OverflowException ex) - { - MessageBox.Show(this, "Failed to open pck", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); - Debug.WriteLine(ex.Message); - } - } - catch - { - MessageBox.Show(this, "Failed to open pck. There's two common reasons for this:\n" + - "1. The file is audio/music cues PCK file. Please use the specialized editor while inside of a pck file.\n" + - "2. We're aware of an issue where a pck file might fail to load because it contains multiple entries with the same path.", - "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); - } - packInfo = PackInfo.Empty; - return false; - } - - private void AddEditorPage(string filepath) - { - if (!File.Exists(filepath) && !filepath.EndsWith(".pck")) - { - Trace.TraceError($"[{nameof(AddEditorPage)}] Invalid filepath({filepath})"); - return; - } - - if (openTabPages.ContainsKey(filepath)) - { - tabControl.SelectTab(openTabPages[filepath]); - return; - } - SaveToRecentFiles(filepath); - - if (TryOpenPck(filepath, out PackInfo packInfo)) - { - ISaveContext saveContext = GetDefaultSaveContext(filepath, "PCK (Minecraft Console Package)"); - var editor = new PckEditor(packInfo, saveContext); - TabPage page = AddPage(Path.GetFileName(filepath), filepath, editor); - return; - } - MessageBox.Show(string.Format("Failed to load {0}", Path.GetFileName(filepath)), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); - } private static ISaveContext GetDefaultSaveContext(string filepath, string description) { - return new DelegatedFileSaveContext(filepath, false, new FileDialogFilter(description, "*"+Path.GetExtension(filepath)),(packInfo, stream) => new PckFileWriter(packInfo.File, packInfo.Endianness).WriteToStream(stream)); + return new DelegatedFileSaveContext(filepath, false, new FileDialogFilter(description, "*"+Path.GetExtension(filepath)),(packInfo, stream) => new PckFileWriter(packInfo.File, packInfo.ByteOrder).WriteToStream(stream)); } private TabPage AddPage(string caption, string identifier, Control control) @@ -434,7 +375,7 @@ namespace PckStudio if (TryGetCurrentEditor(out IEditor editor)) { using AdvancedOptions advanced = new AdvancedOptions(editor.EditorValue.File); - advanced.IsLittleEndian = editor.EditorValue.Endianness == OMI.ByteOrder.LittleEndian; + advanced.IsLittleEndian = editor.EditorValue.ByteOrder == OMI.ByteOrder.LittleEndian; if (advanced.ShowDialog() == DialogResult.OK) { editor.UpdateView(); diff --git a/PCK-Studio/PckStudio.csproj b/PCK-Studio/PckStudio.csproj index a19172de..6d098fae 100644 --- a/PCK-Studio/PckStudio.csproj +++ b/PCK-Studio/PckStudio.csproj @@ -146,11 +146,11 @@ Form - + UserControl - - PckEditor.cs + + PckAssetBrowserEditor.cs Form @@ -395,8 +395,8 @@ - - PckEditor.cs + + PckAssetBrowserEditor.cs FilterPrompt.cs diff --git a/PckStudio.Core/PackInfo.cs b/PckStudio.Core/PackInfo.cs index df451b8c..e40f4b0f 100644 --- a/PckStudio.Core/PackInfo.cs +++ b/PckStudio.Core/PackInfo.cs @@ -8,38 +8,21 @@ namespace PckStudio.Core public static readonly PackInfo Empty = new PackInfo(default, default, default); public bool IsValid { get; } public PckFile File { get; } - public OMI.ByteOrder Endianness { get; } + public OMI.ByteOrder ByteOrder { get; } - - //public enum PackType - //{ - // Unknown = -1, - // SkinPack, - // TexturePack, - // MashUpPack - //} + public bool AllowByteOrderSwap { get; } - //public PackType Type { get; } - - public bool AllowEndianSwap { get; } - - public static PackInfo Create(PckFile file, OMI.ByteOrder endianness, bool allowEndianSwap) + public static PackInfo Create(PckFile file, OMI.ByteOrder byteOrder, bool allowByteOrderSwap) { - return new PackInfo(file, endianness, allowEndianSwap); + return new PackInfo(file, byteOrder, allowByteOrderSwap); } - private PackInfo(PckFile file, OMI.ByteOrder endianness, bool allowEndianSwap) + private PackInfo(PckFile file, OMI.ByteOrder byteOrder, bool allowByteOrderSwap) { File = file; - Endianness = endianness; - AllowEndianSwap = allowEndianSwap; - //Type = GetPackType(); - IsValid = file is not null && Enum.IsDefined(typeof(OMI.ByteOrder), endianness); // && Type != PackType.Unknown; + ByteOrder = byteOrder; + AllowByteOrderSwap = allowByteOrderSwap; + IsValid = file is not null && Enum.IsDefined(typeof(OMI.ByteOrder), byteOrder); } - - //private PackType GetPackType() - //{ - // return PackType.SkinPack; - //} } } \ No newline at end of file