Skip to content

Commit

Permalink
Merge main into '3dSkinRenderer'
Browse files Browse the repository at this point in the history
  • Loading branch information
NessieHax committed Jul 6, 2024
2 parents c1d7ce6 + 642261c commit 8341151
Show file tree
Hide file tree
Showing 11 changed files with 235 additions and 226 deletions.
5 changes: 5 additions & 0 deletions PCK-Studio/Extensions/ColorExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ internal static Vector4 Normalize(this Color color)
return new Vector4(color.R / 255f, color.G / 255f, color.B / 255f, color.A / 255f);
}

internal static int ToBGR(this Color color)
{
return color.B << 16 | color.G << 8 | color.R;
}

internal static byte BlendValues(byte source, byte overlay, BlendMode blendType)
{
return (byte)MathExtensions.Clamp(BlendValues(source / 255f, overlay / 255f, blendType) * 255, 0, 255);
Expand Down
294 changes: 135 additions & 159 deletions PCK-Studio/Forms/Editor/TextureAtlasEditor.cs

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions PCK-Studio/Internal/Deserializer/ImageDeserializer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,15 @@ namespace PckStudio.Internal.Deserializer
internal sealed class ImageDeserializer : IPckAssetDeserializer<Image>
{
public static readonly ImageDeserializer DefaultDeserializer = new ImageDeserializer();
// TODO: replace empty image with image displaying something went wrong
private static Image EmptyImage = new Bitmap(1, 1, PixelFormat.Format32bppArgb);

public Image Deserialize(PckAsset asset)
{
_ = asset ?? throw new ArgumentNullException(nameof(asset));
if (asset.Size == 0)
return EmptyImage;

using var stream = new MemoryStream(asset.Data);
try
{
Expand Down
32 changes: 32 additions & 0 deletions PCK-Studio/Internal/GameConstants.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace PckStudio.Internal
{
internal static class GameConstants
{
// See: https://minecraft.fandom.com/wiki/Dye#Color_values for more information.
public static readonly Color[] DyeColors = [
Color.FromArgb(0xf9fffe), // White
Color.FromArgb(0xf9801d), // Orange
Color.FromArgb(0xc74ebd), // Magenta
Color.FromArgb(0x3ab3da), // Light Blue
Color.FromArgb(0xfed83d), // Yellow
Color.FromArgb(0x80c71f), // Lime
Color.FromArgb(0xf38baa), // Pink
Color.FromArgb(0x474f52), // Gray
Color.FromArgb(0x9d9d97), // Light Gray
Color.FromArgb(0x169c9c), // Cyan
Color.FromArgb(0x8932b8), // Purple
Color.FromArgb(0x3c44aa), // Blue
Color.FromArgb(0x835432), // Brown
Color.FromArgb(0x5e7c16), // Green
Color.FromArgb(0xb02e26), // Red
Color.FromArgb(0x1d1d21), // Black
];
}
}
3 changes: 0 additions & 3 deletions PCK-Studio/Internal/Json/ColorEntry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@ internal class JsonColorEntry
[JsonProperty("isWaterColour", DefaultValueHandling = DefaultValueHandling.Populate)]
public bool IsWaterColour { get; set; }

[JsonProperty("hasCustomColour", DefaultValueHandling = DefaultValueHandling.Populate)]
public bool HasCustomColour { get; set; }

[JsonProperty("variants", DefaultValueHandling = DefaultValueHandling.Populate)]
public string[] Variants { get; set; }
}
Expand Down
7 changes: 5 additions & 2 deletions PCK-Studio/Internal/Json/TileInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,20 @@ internal class JsonTileInfo
public string InternalName { get; set; }

[JsonProperty("width")]
public int Width { get; set; } = 1;
public int TileWidth { get; set; } = 1;

[JsonProperty("height")]
public int Height { get; set; } = 1;
public int TileHeight { get; set; } = 1;

[JsonProperty("hasColourEntry", DefaultValueHandling = DefaultValueHandling.Populate)]
public bool HasColourEntry { get; set; }

[JsonProperty("colourEntry", DefaultValueHandling = DefaultValueHandling.Populate)]
public JsonColorEntry ColourEntry { get; set; }

[JsonProperty("allowCustomColour", DefaultValueHandling = DefaultValueHandling.Populate)]
public bool AllowCustomColour { get; set; }

public JsonTileInfo(string displayName, string internalName)
{
DisplayName = displayName;
Expand Down
2 changes: 1 addition & 1 deletion PCK-Studio/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,7 @@ private void HandleTextureFile(PckAsset asset)
}

ResourceLocation resourceLocation = ResourceLocation.GetFromPath(asset.Filename);
Debug.WriteLine("Handling Resource file: " + resourceLocation.ToString());
Debug.WriteLine("Handling Resource file: " + resourceLocation?.ToString());
if (resourceLocation is null || resourceLocation.Category == ResourceCategory.Unknown)
return;

Expand Down
1 change: 1 addition & 0 deletions PCK-Studio/PckStudio.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@
<Compile Include="Extensions\OpenTkMatrixExtensions.cs" />
<Compile Include="Internal\IO\PSM\PSMFileReader.cs" />
<Compile Include="Internal\IO\PSM\PSMFileWriter.cs" />
<Compile Include="Internal\GameConstants.cs" />
<Compile Include="Internal\IO\TGA\TGADeserializer.cs" />
<Compile Include="Internal\IO\TGA\TGASerializer.cs" />
<Compile Include="Extensions\LocFileExtensions.cs" />
Expand Down
4 changes: 2 additions & 2 deletions PCK-Studio/Resources/atlases/blockData.json
Original file line number Diff line number Diff line change
Expand Up @@ -2317,11 +2317,11 @@
{
"internalName": "cauldron_water",
"displayName": "Cauldron Water",
"allowCustomColour": true,
"hasColourEntry": true,
"colourEntry": {
"hasCustomColour": true,
"defaultName": "Cauldron_Water",
"variants": [
"variants": [
"Cauldron_Water",
"Effect_MovementSpeed",
"Effect_MovementSlowDown",
Expand Down
21 changes: 8 additions & 13 deletions PCK-Studio/Resources/atlases/itemData.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
{
"internalName": "helmetCloth",
"displayName": "Leather Cap",
"allowCustomColour": true,
"hasColourEntry": true,
"colourEntry": {
"hasCustomColour": true,
"defaultName": "Armour_Default_Leather_Colour",
"variants": [ "Armour_Default_Leather_Colour" ]
}
Expand Down Expand Up @@ -75,9 +75,9 @@
{
"internalName": "chestplateCloth",
"displayName": "Leather Tunic",
"allowCustomColour": true,
"hasColourEntry": true,
"colourEntry": {
"hasCustomColour": true,
"defaultName": "Armour_Default_Leather_Colour",
"variants": [ "Armour_Default_Leather_Colour" ]
}
Expand Down Expand Up @@ -145,9 +145,9 @@
{
"internalName": "leggingsCloth",
"displayName": "Leather Pants",
"allowCustomColour": true,
"hasColourEntry": true,
"colourEntry": {
"hasCustomColour": true,
"defaultName": "Armour_Default_Leather_Colour",
"variants": [ "Armour_Default_Leather_Colour" ]
}
Expand Down Expand Up @@ -215,9 +215,9 @@
{
"internalName": "bootsCloth",
"displayName": "Leather Boots",
"allowCustomColour": true,
"hasColourEntry": true,
"colourEntry": {
"hasCustomColour": true,
"defaultName": "Armour_Default_Leather_Colour",
"variants": [ "Armour_Default_Leather_Colour" ]
}
Expand Down Expand Up @@ -593,11 +593,11 @@
{
"internalName": "potion_contents",
"displayName": "Potion (Overlay)",
"allowCustomColour": true,
"hasColourEntry": true,
"colourEntry": {
"defaultName": "Potion_BaseColour",
"hasCustomColour": true,
"variants": [
"variants": [
"Potion_BaseColour",
"Effect_MovementSpeed",
"Effect_MovementSlowDown",
Expand Down Expand Up @@ -1013,12 +1013,7 @@
{
"internalName": "fireworks_charge_overlay",
"displayName": "Firework Star (Overlay)",
"hasColourEntry": true,
"colourEntry": {
"hasCustomColour": true,
"defaultName": "",
"variants": [""]
}
"allowCustomColour": true
},
{
"internalName": "netherquartz",
Expand Down Expand Up @@ -1099,9 +1094,9 @@
{
"internalName": "leather_horse_armor_base",
"displayName": "Leather Horse Armor",
"allowCustomColour": true,
"hasColourEntry": true,
"colourEntry": {
"hasCustomColour": true,
"defaultName": "Armour_Default_Leather_Colour",
"variants": [ "Armour_Default_Leather_Colour" ]
}
Expand Down
Loading

0 comments on commit 8341151

Please sign in to comment.