diff --git a/PCK-Studio/Forms/Additional-Popups/CreateTexturePackPrompt.cs b/PCK-Studio/Forms/Additional-Popups/CreateTexturePackPrompt.cs index 93272581..07654466 100644 --- a/PCK-Studio/Forms/Additional-Popups/CreateTexturePackPrompt.cs +++ b/PCK-Studio/Forms/Additional-Popups/CreateTexturePackPrompt.cs @@ -1,7 +1,7 @@ using System; using System.Windows.Forms; using MetroFramework.Forms; -using PckStudio.Core; +using PckStudio.Core.DLC; namespace PckStudio { diff --git a/PckStudio.Core/DLCBattlePackage.cs b/PckStudio.Core/DLC/DLCBattlePackage.cs similarity index 93% rename from PckStudio.Core/DLCBattlePackage.cs rename to PckStudio.Core/DLC/DLCBattlePackage.cs index 0d67443e..690c26bc 100644 --- a/PckStudio.Core/DLCBattlePackage.cs +++ b/PckStudio.Core/DLC/DLCBattlePackage.cs @@ -6,7 +6,7 @@ using System.Text; using System.Threading.Tasks; using PckStudio.Core.Interfaces; -namespace PckStudio.Core +namespace PckStudio.Core.DLC { internal sealed class DLCBattlePackage : DLCMiniGamePackage { diff --git a/PckStudio.Core/DLCManager.cs b/PckStudio.Core/DLC/DLCManager.cs similarity index 90% rename from PckStudio.Core/DLCManager.cs rename to PckStudio.Core/DLC/DLCManager.cs index c1952c1d..7b103eab 100644 --- a/PckStudio.Core/DLCManager.cs +++ b/PckStudio.Core/DLC/DLCManager.cs @@ -17,7 +17,7 @@ using PckStudio.Core.Deserializer; using PckStudio.Core.Extensions; using PckStudio.Core.Interfaces; -namespace PckStudio.Core +namespace PckStudio.Core.DLC { public sealed class DLCManager { @@ -60,8 +60,8 @@ namespace PckStudio.Core DLCPackageType.MashUpPack => new DLCMashUpPackage(name, "", identifier), //! TODO: implemnt minigame dlc packages -null DLCPackageType.MG01 => new DLCBattlePackage(name, identifier), - DLCPackageType.MG02 => throw new NotImplementedException(), - DLCPackageType.MG03 => throw new NotImplementedException(), + DLCPackageType.MG02 => new DLCMiniGamePackage(name, identifier, packageType, MiniGameId.Tumble), + DLCPackageType.MG03 => new DLCMiniGamePackage(name, identifier, packageType, MiniGameId.Glide), DLCPackageType.Invalid => InvalidDLCPackage.Instance, _ => throw new ArgumentException("Unable to create DLC Package of 'Unknown' type."), }; @@ -88,13 +88,17 @@ namespace PckStudio.Core PckFile pckFile = fileReader.FromStream(stream); - Debug.Assert(pckFile.TryGetAsset("0", PckAssetType.InfoFile, out PckAsset zeroAsset), "Could not find asset named:'0'."); + if (!pckFile.TryGetAsset("0", PckAssetType.InfoFile, out PckAsset zeroAsset)) + { + Trace.TraceError("Could not find asset named:'0'."); + return new UnknownDLCPackage(fileInfo.Name, pckFile); + } int identifier = (zeroAsset?.HasProperty("PACKID") ?? default) ? zeroAsset.GetProperty("PACKID", int.Parse) : -1; if (identifier <= 0 || identifier > GameConstants.MAX_PACK_ID) { Trace.TraceError($"{nameof(identifier)}({identifier}) was out of range!"); - return InvalidDLCPackage.Instance; + return new UnknownDLCPackage(fileInfo.Name, pckFile); } if (_openPackages.ContainsKey(identifier)) @@ -102,7 +106,7 @@ namespace PckStudio.Core LOCFile localisation = pckFile.GetAssetsByType(PckAssetType.LocalisationFile).FirstOrDefault()?.GetData(new LOCFileReader()); if (localisation is null) - return InvalidDLCPackage.Instance; + return new UnknownDLCPackage(fileInfo.Name, pckFile); _localisationFiles.Add(identifier, localisation); IDLCPackage package = ScanForPackageType(fileInfo, identifier, pckFile, localisation, fileReader); @@ -217,9 +221,10 @@ namespace PckStudio.Core Image iconImg = iconnAsset.GetTexture(); DLCTexturePackage.MetaData metaData = new DLCTexturePackage.MetaData(comparisonImg, iconImg); - - bool a = TryGetAtlasFromResourceCategory(dataPck, ResourceCategory.BlockAtlas, out Atlas terrainAtlas); - bool b = TryGetAtlasFromResourceCategory(dataPck, ResourceCategory.ItemAtlas, out Atlas itemAtlas); + bool hasTerrainAtlas = TryGetAtlasFromResourceCategory(dataPck, ResourceCategory.BlockAtlas, out Atlas terrainAtlas); + bool hasItemAtlas = TryGetAtlasFromResourceCategory(dataPck, ResourceCategory.ItemAtlas, out Atlas itemAtlas); + bool hasParticleAtlas = TryGetAtlasFromResourceCategory(dataPck, ResourceCategory.ParticleAtlas, out Atlas particleAtlas); + bool hasPaintingAtlas = TryGetAtlasFromResourceCategory(dataPck, ResourceCategory.PaintingAtlas, out Atlas paintingAtlas); string itemAnimationResourcePath = ResourceLocation.GetPathFromCategory(ResourceCategory.ItemAnimation); if (dataPck != null && diff --git a/PckStudio.Core/DLCMashUpPackage.cs b/PckStudio.Core/DLC/DLCMashUpPackage.cs similarity index 91% rename from PckStudio.Core/DLCMashUpPackage.cs rename to PckStudio.Core/DLC/DLCMashUpPackage.cs index 385b48d4..0514e11d 100644 --- a/PckStudio.Core/DLCMashUpPackage.cs +++ b/PckStudio.Core/DLC/DLCMashUpPackage.cs @@ -7,7 +7,7 @@ using System.Threading.Tasks; using OMI.Formats.GameRule; using PckStudio.Core.Interfaces; -namespace PckStudio.Core +namespace PckStudio.Core.DLC { public sealed class DLCMashUpPackage : DLCPackage { @@ -19,7 +19,7 @@ namespace PckStudio.Core private IList> _audioData; private NamedData _savegameData; - internal DLCMashUpPackage(string name, string description, int identifier, IDLCPackageLocationInfo packageInfo, GameRuleFile gameRule, IDLCPackage parentPackage, IDLCPackage skinPackage = null, IDLCPackage texturePackage = null) + internal DLCMashUpPackage(string name, string description, int identifier, IDLCPackageSerialization packageInfo, GameRuleFile gameRule, IDLCPackage parentPackage, IDLCPackage skinPackage = null, IDLCPackage texturePackage = null) : base(name, identifier, packageInfo, parentPackage) { Description = description; diff --git a/PckStudio.Core/DLCMiniGamePackage.cs b/PckStudio.Core/DLC/DLCMiniGamePackage.cs similarity index 85% rename from PckStudio.Core/DLCMiniGamePackage.cs rename to PckStudio.Core/DLC/DLCMiniGamePackage.cs index 524bf6e8..a3c416dc 100644 --- a/PckStudio.Core/DLCMiniGamePackage.cs +++ b/PckStudio.Core/DLC/DLCMiniGamePackage.cs @@ -6,7 +6,7 @@ using System.Text; using System.Threading.Tasks; using PckStudio.Core.Interfaces; -namespace PckStudio.Core +namespace PckStudio.Core.DLC { internal class DLCMiniGamePackage : DLCPackage { @@ -14,7 +14,7 @@ namespace PckStudio.Core private readonly DLCPackageType _packageType; private readonly MiniGameId _miniGameId; - public DLCMiniGamePackage(string name, int identifier, DLCPackageType packageType, MiniGameId miniGameId, IDLCPackageLocationInfo packageInfo = null, IDLCPackage parentPackage = null) + public DLCMiniGamePackage(string name, int identifier, DLCPackageType packageType, MiniGameId miniGameId, IDLCPackageSerialization packageInfo = null, IDLCPackage parentPackage = null) : base(name, identifier, packageInfo, parentPackage) { _packageType = packageType; diff --git a/PckStudio.Core/DLCPackage.cs b/PckStudio.Core/DLC/DLCPackage.cs similarity index 84% rename from PckStudio.Core/DLCPackage.cs rename to PckStudio.Core/DLC/DLCPackage.cs index 5549c213..cea12ced 100644 --- a/PckStudio.Core/DLCPackage.cs +++ b/PckStudio.Core/DLC/DLCPackage.cs @@ -6,11 +6,11 @@ using System.Text; using System.Threading.Tasks; using PckStudio.Core.Interfaces; -namespace PckStudio.Core +namespace PckStudio.Core.DLC { public abstract class DLCPackage : IDLCPackage { - protected DLCPackage(string name, int identifier, IDLCPackageLocationInfo packageInfo, IDLCPackage parentPackage) + protected DLCPackage(string name, int identifier, IDLCPackageSerialization packageInfo, IDLCPackage parentPackage) { Name = name; Identifier = identifier; @@ -20,7 +20,7 @@ namespace PckStudio.Core public int Identifier { get; } - public IDLCPackageLocationInfo PackageInfo { get; } + public IDLCPackageSerialization PackageInfo { get; } public string Name { get; } = string.Empty; diff --git a/PckStudio.Core/DLCPackageType.cs b/PckStudio.Core/DLC/DLCPackageType.cs similarity index 88% rename from PckStudio.Core/DLCPackageType.cs rename to PckStudio.Core/DLC/DLCPackageType.cs index 333cf391..8f3fb69e 100644 --- a/PckStudio.Core/DLCPackageType.cs +++ b/PckStudio.Core/DLC/DLCPackageType.cs @@ -1,4 +1,4 @@ -namespace PckStudio.Core +namespace PckStudio.Core.DLC { public enum DLCPackageType { diff --git a/PckStudio.Core/DLCSkinPackage.cs b/PckStudio.Core/DLC/DLCSkinPackage.cs similarity index 94% rename from PckStudio.Core/DLCSkinPackage.cs rename to PckStudio.Core/DLC/DLCSkinPackage.cs index bff1bbeb..8c13bd45 100644 --- a/PckStudio.Core/DLCSkinPackage.cs +++ b/PckStudio.Core/DLC/DLCSkinPackage.cs @@ -5,7 +5,7 @@ using System.Linq; using PckStudio.Core.Interfaces; using PckStudio.Core.Skin; -namespace PckStudio.Core +namespace PckStudio.Core.DLC { public enum DLCSkinPackageOrder { @@ -20,7 +20,7 @@ namespace PckStudio.Core private readonly Dictionary _skins; - internal DLCSkinPackage(string name, int identifier, IEnumerable skins, IDLCPackageLocationInfo packageInfo, IDLCPackage parentPackage) + internal DLCSkinPackage(string name, int identifier, IEnumerable skins, IDLCPackageSerialization packageInfo, IDLCPackage parentPackage) : base(name, identifier, packageInfo, parentPackage) { _skins = skins.ToDictionary(skin => skin.Identifier); diff --git a/PckStudio.Core/DLCTexturePackage.cs b/PckStudio.Core/DLC/DLCTexturePackage.cs similarity index 98% rename from PckStudio.Core/DLCTexturePackage.cs rename to PckStudio.Core/DLC/DLCTexturePackage.cs index 24957a2a..ab9a7d01 100644 --- a/PckStudio.Core/DLCTexturePackage.cs +++ b/PckStudio.Core/DLC/DLCTexturePackage.cs @@ -14,7 +14,7 @@ using OMI.Workers.Color; using PckStudio.Core.Interfaces; using PckStudio.Core.Properties; -namespace PckStudio.Core +namespace PckStudio.Core.DLC { public sealed class DLCTexturePackage : DLCPackage { @@ -85,7 +85,7 @@ namespace PckStudio.Core Image[] blockEntityBreakImages, IDictionary itemAnimations, IDictionary blockAnimations, - IDLCPackageLocationInfo packageInfo, + IDLCPackageSerialization packageInfo, IDLCPackage parentPackage ) : base(name, identifier, packageInfo, parentPackage) diff --git a/PckStudio.Core/InvalidDLCPackage.cs b/PckStudio.Core/DLC/InvalidDLCPackage.cs similarity index 88% rename from PckStudio.Core/InvalidDLCPackage.cs rename to PckStudio.Core/DLC/InvalidDLCPackage.cs index e4456f21..1eee2c4d 100644 --- a/PckStudio.Core/InvalidDLCPackage.cs +++ b/PckStudio.Core/DLC/InvalidDLCPackage.cs @@ -5,14 +5,14 @@ using System.Text; using System.Threading.Tasks; using PckStudio.Core.Interfaces; -namespace PckStudio.Core +namespace PckStudio.Core.DLC { // Dummy class internal sealed class InvalidDLCPackage : DLCPackage { internal static IDLCPackage Instance { get; } = new InvalidDLCPackage(); - private InvalidDLCPackage(string name, int identifier, IDLCPackageLocationInfo packageInfo, IDLCPackage parentPackage) + private InvalidDLCPackage(string name, int identifier, IDLCPackageSerialization packageInfo, IDLCPackage parentPackage) : base(name, identifier, packageInfo, parentPackage) { } diff --git a/PckStudio.Core/DLC/UnknownDLCPackage.cs b/PckStudio.Core/DLC/UnknownDLCPackage.cs new file mode 100644 index 00000000..f86e4fc6 --- /dev/null +++ b/PckStudio.Core/DLC/UnknownDLCPackage.cs @@ -0,0 +1,23 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using OMI.Formats.Pck; +using PckStudio.Core.Interfaces; + +namespace PckStudio.Core.DLC +{ + public sealed class UnknownDLCPackage : DLCPackage + { + public PckFile PckFile { get; } + + public UnknownDLCPackage(string name, PckFile pckFile) + : base(name ?? nameof(UnknownDLCPackage), -1, default, default) + { + PckFile = pckFile; + } + + public override DLCPackageType GetDLCPackageType() => DLCPackageType.Unknown; + } +} diff --git a/PckStudio.Core/Interfaces/IDLCPackage.cs b/PckStudio.Core/Interfaces/IDLCPackage.cs index 82ec6910..addd4a1d 100644 --- a/PckStudio.Core/Interfaces/IDLCPackage.cs +++ b/PckStudio.Core/Interfaces/IDLCPackage.cs @@ -8,9 +8,9 @@ bool IsRootPackage { get; } - IDLCPackageLocationInfo PackageInfo { get; } + IDLCPackageSerialization PackageInfo { get; } - DLCPackageType GetDLCPackageType(); + DLC.DLCPackageType GetDLCPackageType(); IDLCPackage ParentPackage { get; } } diff --git a/PckStudio.Core/Interfaces/IDLCPackageLocationInfo.cs b/PckStudio.Core/Interfaces/IDLCPackageSerialization.cs similarity index 54% rename from PckStudio.Core/Interfaces/IDLCPackageLocationInfo.cs rename to PckStudio.Core/Interfaces/IDLCPackageSerialization.cs index 01425d20..b3e4d94b 100644 --- a/PckStudio.Core/Interfaces/IDLCPackageLocationInfo.cs +++ b/PckStudio.Core/Interfaces/IDLCPackageSerialization.cs @@ -1,6 +1,6 @@ namespace PckStudio.Core.Interfaces { - public interface IDLCPackageLocationInfo + public interface IDLCPackageSerialization { } diff --git a/PckStudio.Core/PckStudio.Core.csproj b/PckStudio.Core/PckStudio.Core.csproj index 00d514ea..212494d4 100644 --- a/PckStudio.Core/PckStudio.Core.csproj +++ b/PckStudio.Core/PckStudio.Core.csproj @@ -65,13 +65,14 @@ - - - - - - - + + + + + + + + @@ -108,14 +109,14 @@ - + - + @@ -144,7 +145,7 @@ - +