mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/PCK-Studio.git
synced 2026-07-13 09:18:09 +00:00
Core - Move DLC classes into DLC namespace and folder & rename 'IDLCPackageLocationInfo' to 'IDLCPackageSerialization'
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
using System;
|
||||
using System.Windows.Forms;
|
||||
using MetroFramework.Forms;
|
||||
using PckStudio.Core;
|
||||
using PckStudio.Core.DLC;
|
||||
|
||||
namespace PckStudio
|
||||
{
|
||||
|
||||
@@ -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
|
||||
{
|
||||
@@ -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 &&
|
||||
@@ -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<NamedData<byte[]>> _audioData;
|
||||
private NamedData<byte[]> _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;
|
||||
@@ -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;
|
||||
@@ -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;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
namespace PckStudio.Core
|
||||
namespace PckStudio.Core.DLC
|
||||
{
|
||||
public enum DLCPackageType
|
||||
{
|
||||
@@ -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<SkinIdentifier, Skin.Skin> _skins;
|
||||
|
||||
internal DLCSkinPackage(string name, int identifier, IEnumerable<Skin.Skin> skins, IDLCPackageLocationInfo packageInfo, IDLCPackage parentPackage)
|
||||
internal DLCSkinPackage(string name, int identifier, IEnumerable<Skin.Skin> skins, IDLCPackageSerialization packageInfo, IDLCPackage parentPackage)
|
||||
: base(name, identifier, packageInfo, parentPackage)
|
||||
{
|
||||
_skins = skins.ToDictionary(skin => skin.Identifier);
|
||||
@@ -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<string, Animation> itemAnimations,
|
||||
IDictionary<string, Animation> blockAnimations,
|
||||
IDLCPackageLocationInfo packageInfo,
|
||||
IDLCPackageSerialization packageInfo,
|
||||
IDLCPackage parentPackage
|
||||
)
|
||||
: base(name, identifier, packageInfo, parentPackage)
|
||||
@@ -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)
|
||||
{
|
||||
}
|
||||
23
PckStudio.Core/DLC/UnknownDLCPackage.cs
Normal file
23
PckStudio.Core/DLC/UnknownDLCPackage.cs
Normal file
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -8,9 +8,9 @@
|
||||
|
||||
bool IsRootPackage { get; }
|
||||
|
||||
IDLCPackageLocationInfo PackageInfo { get; }
|
||||
IDLCPackageSerialization PackageInfo { get; }
|
||||
|
||||
DLCPackageType GetDLCPackageType();
|
||||
DLC.DLCPackageType GetDLCPackageType();
|
||||
|
||||
IDLCPackage ParentPackage { get; }
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
namespace PckStudio.Core.Interfaces
|
||||
{
|
||||
public interface IDLCPackageLocationInfo
|
||||
public interface IDLCPackageSerialization
|
||||
{
|
||||
|
||||
}
|
||||
@@ -65,13 +65,14 @@
|
||||
<Compile Include="Deserializer\AnimationDeserializer.cs" />
|
||||
<Compile Include="Deserializer\AtlasDeserializer.cs" />
|
||||
<Compile Include="Deserializer\ImageDeserializer.cs" />
|
||||
<Compile Include="DLCBattlePackage.cs" />
|
||||
<Compile Include="DLCManager.cs" />
|
||||
<Compile Include="DLCMashUpPackage.cs" />
|
||||
<Compile Include="DLCMiniGamePackage.cs" />
|
||||
<Compile Include="DLCPackage.cs" />
|
||||
<Compile Include="DLCSkinPackage.cs" />
|
||||
<Compile Include="DLCTexturePackage.cs" />
|
||||
<Compile Include="DLC\DLCBattlePackage.cs" />
|
||||
<Compile Include="DLC\DLCManager.cs" />
|
||||
<Compile Include="DLC\DLCMashUpPackage.cs" />
|
||||
<Compile Include="DLC\DLCMiniGamePackage.cs" />
|
||||
<Compile Include="DLC\DLCPackage.cs" />
|
||||
<Compile Include="DLC\DLCSkinPackage.cs" />
|
||||
<Compile Include="DLC\DLCTexturePackage.cs" />
|
||||
<Compile Include="DLC\UnknownDLCPackage.cs" />
|
||||
<Compile Include="Extensions\AnimationExtensions.cs" />
|
||||
<Compile Include="Extensions\BlendMode.cs" />
|
||||
<Compile Include="Extensions\BoundingBoxExtensions.cs" />
|
||||
@@ -108,14 +109,14 @@
|
||||
<Compile Include="GameRule\UpdatePlayer.cs" />
|
||||
<Compile Include="GameRule\WorldPosition.cs" />
|
||||
<Compile Include="Interfaces\IDLCPackage.cs" />
|
||||
<Compile Include="Interfaces\IDLCPackageLocationInfo.cs" />
|
||||
<Compile Include="Interfaces\IDLCPackageSerialization.cs" />
|
||||
<Compile Include="Interfaces\IEditor.cs" />
|
||||
<Compile Include="Interfaces\IModelImportProvider.cs" />
|
||||
<Compile Include="Interfaces\IPckAssetDeserializer.cs" />
|
||||
<Compile Include="Interfaces\IPckAssetSerializer.cs" />
|
||||
<Compile Include="Interfaces\ISaveContext.cs" />
|
||||
<Compile Include="Interfaces\ITryGetSet.cs" />
|
||||
<Compile Include="InvalidDLCPackage.cs" />
|
||||
<Compile Include="DLC\InvalidDLCPackage.cs" />
|
||||
<Compile Include="IO\3DST\3DSTextureReader.cs" />
|
||||
<Compile Include="IO\3DST\3DSTextureWriter.cs" />
|
||||
<Compile Include="IO\3DST\TextureCodec.cs" />
|
||||
@@ -144,7 +145,7 @@
|
||||
<Compile Include="Misc\OpenFolderDialog.cs" />
|
||||
<Compile Include="NamedData.cs" />
|
||||
<Compile Include="PackInfo.cs" />
|
||||
<Compile Include="DLCPackageType.cs" />
|
||||
<Compile Include="DLC\DLCPackageType.cs" />
|
||||
<Compile Include="ResourceCategory.cs" />
|
||||
<Compile Include="ResourceLocation.cs" />
|
||||
<Compile Include="Serializer\AnimationSerializer.cs" />
|
||||
|
||||
Reference in New Issue
Block a user