Skip to content

Commit

Permalink
Added Custom Color support for specific tiles
Browse files Browse the repository at this point in the history
-Custom Color Tiles are Leather Armor, Potion (Overlay) / Potion Contents, Leather Horse Armor, and Cauldron Water
  • Loading branch information
MattN-L committed Mar 13, 2024
1 parent f2c990b commit 8213fe3
Show file tree
Hide file tree
Showing 4 changed files with 148 additions and 75 deletions.
129 changes: 88 additions & 41 deletions PCK-Studio/Forms/Editor/TextureAtlasEditor.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

51 changes: 50 additions & 1 deletion PCK-Studio/Forms/Editor/TextureAtlasEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,11 @@ private void SetImageDisplayed(int index)
selectTilePictureBox.Start(animation);
}

if (dataTile.Tile.HasColourEntry)
if (setColorButton.Enabled = clearColorButton.Enabled = dataTile.Tile.HasColourEntry)
{
setColorButton.Enabled = clearColorButton.Enabled = dataTile.Tile.ColourEntry.HasCustomColour;
clearColorButton.Enabled = false;

variantComboBox.Enabled = variantLabel.Visible = variantComboBox.Visible = dataTile.Tile.ColourEntry.Variants.Length > 1;

if (dataTile.Tile.ColourEntry.IsWaterColour && _colourTable.WaterColors.Count > 0)
Expand Down Expand Up @@ -472,5 +475,51 @@ private void TextureAtlasEditor_FormClosing(object sender, FormClosingEventArgs
if (selectTilePictureBox.IsPlaying)
selectTilePictureBox.Stop();
}

private void setColorButton_Click(object sender, EventArgs e)
{
ColorDialog colorPick = new ColorDialog();
colorPick.AllowFullOpen = true;
colorPick.AnyColor = true;
colorPick.SolidColorOnly = true;

// custom colors are read as BGR for some reason, so hex values are "backwards"
// values below are the default Minecraft dyed leather armor values for convenience

colorPick.CustomColors = new int[] {
0x262EB0, // Red
0x1D80F9, // Orange
0x3DD8FE, // Yellow
0x1FC780, // Lime
0x167C5E, // Green
0xDAB33A, // Light Blue
0x9C9C16, // Cyan
0xAA443C, // Blue
0xB83289, // Purple
0xBD4EC7, // Magenta
0xAA8BF3, // Pink
0xFEFFF9, // White
0x979D9D, // Light Gray
0x524F47, // Gray
0x211D1D, // Black
0x325483 // Brown
};

if (colorPick.ShowDialog() != DialogResult.OK) return;

selectTilePictureBox.BlendColor = colorPick.Color;
selectTilePictureBox.Image = dataTile.Texture;
variantComboBox.Enabled = false;
clearColorButton.Enabled = true;
}

private void clearColorButton_Click(object sender, EventArgs e)
{
variantComboBox.Enabled = true;

variantComboBox_SelectedIndexChanged(sender, e);

clearColorButton.Enabled = false;
}
}
}
3 changes: 3 additions & 0 deletions PCK-Studio/Internal/Json/ColorEntry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ 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
Loading

0 comments on commit 8213fe3

Please sign in to comment.