mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/PCK-Studio.git
synced 2026-07-12 15:48:13 +00:00
TextureAtlasEditor - Ordered functions, added better blending handling
This commit is contained in:
115
PCK-Studio/Forms/Editor/TextureAtlasEditor.Designer.cs
generated
115
PCK-Studio/Forms/Editor/TextureAtlasEditor.Designer.cs
generated
@@ -28,8 +28,8 @@
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
MetroFramework.Controls.MetroLabel metroLabel1;
|
||||
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(TextureAtlasEditor));
|
||||
this.variantLabel = new MetroFramework.Controls.MetroLabel();
|
||||
this.menuStrip1 = new System.Windows.Forms.MenuStrip();
|
||||
this.fileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.saveToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
@@ -40,30 +40,29 @@
|
||||
this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel();
|
||||
this.originalPictureBox = new PckStudio.PictureBoxWithInterpolationMode();
|
||||
this.selectTilePictureBox = new PckStudio.Forms.Editor.AnimationPictureBox();
|
||||
this.infoTextBox = new System.Windows.Forms.RichTextBox();
|
||||
this.replaceButton = new MetroFramework.Controls.MetroButton();
|
||||
this.animationButton = new MetroFramework.Controls.MetroButton();
|
||||
this.tileNameLabel = new MetroFramework.Controls.MetroLabel();
|
||||
this.variantComboBox = new MetroFramework.Controls.MetroComboBox();
|
||||
metroLabel1 = new MetroFramework.Controls.MetroLabel();
|
||||
this.menuStrip1.SuspendLayout();
|
||||
this.tableLayoutPanel1.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.originalPictureBox)).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.selectTilePictureBox)).BeginInit();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// metroLabel1
|
||||
// variantLabel
|
||||
//
|
||||
metroLabel1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||
this.variantLabel.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||
| System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
metroLabel1.AutoSize = true;
|
||||
metroLabel1.Location = new System.Drawing.Point(3, 218);
|
||||
metroLabel1.Name = "metroLabel1";
|
||||
metroLabel1.Size = new System.Drawing.Size(112, 33);
|
||||
metroLabel1.TabIndex = 18;
|
||||
metroLabel1.Text = "Variant:";
|
||||
metroLabel1.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
|
||||
metroLabel1.Theme = MetroFramework.MetroThemeStyle.Dark;
|
||||
this.variantLabel.AutoSize = true;
|
||||
this.variantLabel.Location = new System.Drawing.Point(3, 254);
|
||||
this.variantLabel.Name = "variantLabel";
|
||||
this.variantLabel.Size = new System.Drawing.Size(82, 28);
|
||||
this.variantLabel.TabIndex = 18;
|
||||
this.variantLabel.Text = "Variant:";
|
||||
this.variantLabel.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
|
||||
this.variantLabel.Theme = MetroFramework.MetroThemeStyle.Dark;
|
||||
//
|
||||
// menuStrip1
|
||||
//
|
||||
@@ -118,7 +117,7 @@
|
||||
this.applyColorMaskToolStripMenuItem.CheckOnClick = true;
|
||||
this.applyColorMaskToolStripMenuItem.CheckState = System.Windows.Forms.CheckState.Checked;
|
||||
this.applyColorMaskToolStripMenuItem.Name = "applyColorMaskToolStripMenuItem";
|
||||
this.applyColorMaskToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
|
||||
this.applyColorMaskToolStripMenuItem.Size = new System.Drawing.Size(168, 22);
|
||||
this.applyColorMaskToolStripMenuItem.Text = "Apply Color Mask";
|
||||
this.applyColorMaskToolStripMenuItem.CheckedChanged += new System.EventHandler(this.applyColorMaskToolStripMenuItem_CheckedChanged);
|
||||
//
|
||||
@@ -128,7 +127,7 @@
|
||||
this.playAnimationsToolStripMenuItem.CheckOnClick = true;
|
||||
this.playAnimationsToolStripMenuItem.CheckState = System.Windows.Forms.CheckState.Checked;
|
||||
this.playAnimationsToolStripMenuItem.Name = "playAnimationsToolStripMenuItem";
|
||||
this.playAnimationsToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
|
||||
this.playAnimationsToolStripMenuItem.Size = new System.Drawing.Size(168, 22);
|
||||
this.playAnimationsToolStripMenuItem.Text = "Play Animations";
|
||||
this.playAnimationsToolStripMenuItem.CheckedChanged += new System.EventHandler(this.playAnimationsToolStripMenuItem_CheckedChanged);
|
||||
//
|
||||
@@ -137,25 +136,26 @@
|
||||
this.tableLayoutPanel1.AutoSize = true;
|
||||
this.tableLayoutPanel1.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
|
||||
this.tableLayoutPanel1.ColumnCount = 3;
|
||||
this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 20F));
|
||||
this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 20F));
|
||||
this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 15F));
|
||||
this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 25F));
|
||||
this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 60F));
|
||||
this.tableLayoutPanel1.Controls.Add(this.originalPictureBox, 2, 0);
|
||||
this.tableLayoutPanel1.Controls.Add(this.selectTilePictureBox, 0, 0);
|
||||
this.tableLayoutPanel1.Controls.Add(this.infoTextBox, 0, 2);
|
||||
this.tableLayoutPanel1.Controls.Add(this.replaceButton, 0, 4);
|
||||
this.tableLayoutPanel1.Controls.Add(this.animationButton, 0, 3);
|
||||
this.tableLayoutPanel1.Controls.Add(this.variantComboBox, 1, 1);
|
||||
this.tableLayoutPanel1.Controls.Add(metroLabel1, 0, 1);
|
||||
this.tableLayoutPanel1.Controls.Add(this.replaceButton, 0, 5);
|
||||
this.tableLayoutPanel1.Controls.Add(this.animationButton, 0, 4);
|
||||
this.tableLayoutPanel1.Controls.Add(this.tileNameLabel, 0, 1);
|
||||
this.tableLayoutPanel1.Controls.Add(this.variantComboBox, 1, 2);
|
||||
this.tableLayoutPanel1.Controls.Add(this.variantLabel, 0, 2);
|
||||
this.tableLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.tableLayoutPanel1.Location = new System.Drawing.Point(20, 84);
|
||||
this.tableLayoutPanel1.Name = "tableLayoutPanel1";
|
||||
this.tableLayoutPanel1.RowCount = 5;
|
||||
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 38.73288F));
|
||||
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 5.934431F));
|
||||
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 46.11058F));
|
||||
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 4.611058F));
|
||||
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 4.611058F));
|
||||
this.tableLayoutPanel1.RowCount = 6;
|
||||
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 40F));
|
||||
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 5F));
|
||||
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 5F));
|
||||
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 40F));
|
||||
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 5F));
|
||||
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 5F));
|
||||
this.tableLayoutPanel1.Size = new System.Drawing.Size(590, 565);
|
||||
this.tableLayoutPanel1.TabIndex = 17;
|
||||
//
|
||||
@@ -164,10 +164,10 @@
|
||||
this.originalPictureBox.BackColor = System.Drawing.Color.Transparent;
|
||||
this.originalPictureBox.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.originalPictureBox.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.NearestNeighbor;
|
||||
this.originalPictureBox.Location = new System.Drawing.Point(239, 3);
|
||||
this.originalPictureBox.Location = new System.Drawing.Point(238, 3);
|
||||
this.originalPictureBox.Name = "originalPictureBox";
|
||||
this.tableLayoutPanel1.SetRowSpan(this.originalPictureBox, 5);
|
||||
this.originalPictureBox.Size = new System.Drawing.Size(348, 559);
|
||||
this.tableLayoutPanel1.SetRowSpan(this.originalPictureBox, 6);
|
||||
this.originalPictureBox.Size = new System.Drawing.Size(349, 559);
|
||||
this.originalPictureBox.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom;
|
||||
this.originalPictureBox.TabIndex = 4;
|
||||
this.originalPictureBox.TabStop = false;
|
||||
@@ -179,32 +179,18 @@
|
||||
| System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.selectTilePictureBox.BackColor = System.Drawing.Color.Transparent;
|
||||
this.selectTilePictureBox.BlendColor = System.Drawing.Color.White;
|
||||
this.selectTilePictureBox.BlendMode = PckStudio.Extensions.BlendMode.Multiply;
|
||||
this.tableLayoutPanel1.SetColumnSpan(this.selectTilePictureBox, 2);
|
||||
this.selectTilePictureBox.Image = null;
|
||||
this.selectTilePictureBox.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.NearestNeighbor;
|
||||
this.selectTilePictureBox.Location = new System.Drawing.Point(3, 3);
|
||||
this.selectTilePictureBox.Name = "selectTilePictureBox";
|
||||
this.selectTilePictureBox.Size = new System.Drawing.Size(230, 212);
|
||||
this.selectTilePictureBox.Size = new System.Drawing.Size(229, 220);
|
||||
this.selectTilePictureBox.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom;
|
||||
this.selectTilePictureBox.TabIndex = 0;
|
||||
this.selectTilePictureBox.TabStop = false;
|
||||
//
|
||||
// infoTextBox
|
||||
//
|
||||
this.infoTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||
| System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.infoTextBox.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(20)))), ((int)(((byte)(20)))), ((int)(((byte)(20)))));
|
||||
this.infoTextBox.BorderStyle = System.Windows.Forms.BorderStyle.None;
|
||||
this.tableLayoutPanel1.SetColumnSpan(this.infoTextBox, 2);
|
||||
this.infoTextBox.Cursor = System.Windows.Forms.Cursors.Arrow;
|
||||
this.infoTextBox.ForeColor = System.Drawing.SystemColors.Window;
|
||||
this.infoTextBox.Location = new System.Drawing.Point(3, 254);
|
||||
this.infoTextBox.Name = "infoTextBox";
|
||||
this.infoTextBox.ReadOnly = true;
|
||||
this.infoTextBox.Size = new System.Drawing.Size(230, 254);
|
||||
this.infoTextBox.TabIndex = 15;
|
||||
this.infoTextBox.TabStop = false;
|
||||
this.infoTextBox.Text = "";
|
||||
this.selectTilePictureBox.UseBlendColor = true;
|
||||
//
|
||||
// replaceButton
|
||||
//
|
||||
@@ -212,9 +198,9 @@
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.replaceButton.AutoSize = true;
|
||||
this.tableLayoutPanel1.SetColumnSpan(this.replaceButton, 2);
|
||||
this.replaceButton.Location = new System.Drawing.Point(3, 540);
|
||||
this.replaceButton.Location = new System.Drawing.Point(3, 539);
|
||||
this.replaceButton.Name = "replaceButton";
|
||||
this.replaceButton.Size = new System.Drawing.Size(230, 22);
|
||||
this.replaceButton.Size = new System.Drawing.Size(229, 23);
|
||||
this.replaceButton.TabIndex = 14;
|
||||
this.replaceButton.Text = "Replace";
|
||||
this.replaceButton.Theme = MetroFramework.MetroThemeStyle.Dark;
|
||||
@@ -227,24 +213,38 @@
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.animationButton.AutoSize = true;
|
||||
this.tableLayoutPanel1.SetColumnSpan(this.animationButton, 2);
|
||||
this.animationButton.Location = new System.Drawing.Point(3, 514);
|
||||
this.animationButton.Location = new System.Drawing.Point(3, 511);
|
||||
this.animationButton.Name = "animationButton";
|
||||
this.animationButton.Size = new System.Drawing.Size(230, 20);
|
||||
this.animationButton.Size = new System.Drawing.Size(229, 22);
|
||||
this.animationButton.TabIndex = 16;
|
||||
this.animationButton.Text = "Animation";
|
||||
this.animationButton.Theme = MetroFramework.MetroThemeStyle.Dark;
|
||||
this.animationButton.UseSelectable = true;
|
||||
this.animationButton.Click += new System.EventHandler(this.animationButton_Click);
|
||||
//
|
||||
// tileNameLabel
|
||||
//
|
||||
this.tileNameLabel.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.tileNameLabel.AutoSize = true;
|
||||
this.tableLayoutPanel1.SetColumnSpan(this.tileNameLabel, 2);
|
||||
this.tileNameLabel.Location = new System.Drawing.Point(3, 235);
|
||||
this.tileNameLabel.Name = "tileNameLabel";
|
||||
this.tileNameLabel.Size = new System.Drawing.Size(229, 19);
|
||||
this.tileNameLabel.TabIndex = 19;
|
||||
this.tileNameLabel.Text = "TileName";
|
||||
this.tileNameLabel.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
|
||||
this.tileNameLabel.Theme = MetroFramework.MetroThemeStyle.Dark;
|
||||
//
|
||||
// variantComboBox
|
||||
//
|
||||
this.variantComboBox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.variantComboBox.Enabled = false;
|
||||
this.variantComboBox.FormattingEnabled = true;
|
||||
this.variantComboBox.ItemHeight = 23;
|
||||
this.variantComboBox.Location = new System.Drawing.Point(121, 221);
|
||||
this.variantComboBox.Location = new System.Drawing.Point(91, 257);
|
||||
this.variantComboBox.Name = "variantComboBox";
|
||||
this.variantComboBox.Size = new System.Drawing.Size(112, 29);
|
||||
this.variantComboBox.Size = new System.Drawing.Size(141, 29);
|
||||
this.variantComboBox.TabIndex = 17;
|
||||
this.variantComboBox.Theme = MetroFramework.MetroThemeStyle.Dark;
|
||||
this.variantComboBox.UseSelectable = true;
|
||||
@@ -285,12 +285,13 @@
|
||||
private MetroFramework.Controls.MetroButton replaceButton;
|
||||
private PictureBoxWithInterpolationMode originalPictureBox;
|
||||
private System.Windows.Forms.ToolStripMenuItem saveToolStripMenuItem;
|
||||
private System.Windows.Forms.RichTextBox infoTextBox;
|
||||
private MetroFramework.Controls.MetroButton animationButton;
|
||||
private System.Windows.Forms.ToolStripMenuItem extractTileToolStripMenuItem;
|
||||
private MetroFramework.Controls.MetroComboBox variantComboBox;
|
||||
private System.Windows.Forms.ToolStripMenuItem viewToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem applyColorMaskToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem playAnimationsToolStripMenuItem;
|
||||
private MetroFramework.Controls.MetroLabel tileNameLabel;
|
||||
private MetroFramework.Controls.MetroLabel variantLabel;
|
||||
}
|
||||
}
|
||||
@@ -46,25 +46,8 @@ namespace PckStudio
|
||||
}
|
||||
}
|
||||
|
||||
private struct SelectedTile
|
||||
{
|
||||
internal readonly int Index;
|
||||
internal readonly string Name;
|
||||
internal readonly string TextureName;
|
||||
internal readonly Rectangle Area;
|
||||
internal readonly AnimationResources.JsonTileInfo Tile;
|
||||
|
||||
public SelectedTile(int index, string name, string textureName, Rectangle area, AnimationResources.JsonTileInfo tile)
|
||||
{
|
||||
Index = index;
|
||||
Name = name;
|
||||
TextureName = textureName;
|
||||
Area = area;
|
||||
Tile = tile;
|
||||
}
|
||||
}
|
||||
|
||||
private readonly PckFile _pckFile;
|
||||
private ColorContainer _colourTable;
|
||||
private readonly Size _areaSize;
|
||||
private readonly int _rowCount;
|
||||
private readonly int _columnCount;
|
||||
@@ -72,8 +55,20 @@ namespace PckStudio
|
||||
private readonly List<Image> _textures;
|
||||
private readonly List<AnimationResources.JsonTileInfo> _textureInfos;
|
||||
|
||||
private SelectedTile _selectedItem = new SelectedTile();
|
||||
private ColorContainer _colourTable;
|
||||
private SelectedTile _selectedItem;
|
||||
private struct SelectedTile
|
||||
{
|
||||
internal readonly int Index;
|
||||
internal readonly Rectangle Area;
|
||||
internal readonly AnimationResources.JsonTileInfo Tile;
|
||||
|
||||
public SelectedTile(int index, Rectangle area, AnimationResources.JsonTileInfo tile)
|
||||
{
|
||||
Index = index;
|
||||
Area = area;
|
||||
Tile = tile;
|
||||
}
|
||||
}
|
||||
|
||||
private int SelectedIndex
|
||||
{
|
||||
@@ -122,23 +117,26 @@ namespace PckStudio
|
||||
if (selectTilePictureBox.IsPlaying)
|
||||
selectTilePictureBox.Stop();
|
||||
selectTilePictureBox.Image = null;
|
||||
infoTextBox.Text = string.Empty;
|
||||
tileNameLabel.Text = string.Empty;
|
||||
variantComboBox.Items.Clear();
|
||||
variantComboBox.SelectedItem = null;
|
||||
variantComboBox.Enabled = false;
|
||||
selectTilePictureBox.UseBlendColor = false;
|
||||
variantLabel.Visible = false;
|
||||
variantComboBox.Visible = false;
|
||||
|
||||
if (_textureInfos is not null && _textureInfos.IndexInRange(index))
|
||||
{
|
||||
var info = _textureInfos[index];
|
||||
var pos = GetSelectedPoint(index, _rowCount, _columnCount, _imageLayout);
|
||||
var selectedArea = new Rectangle(pos.X * _areaSize.Width, pos.Y * _areaSize.Height, _areaSize.Width, _areaSize.Height);
|
||||
_selectedItem = new SelectedTile(index, info.DisplayName, info.InternalName, selectedArea, info);
|
||||
|
||||
infoTextBox.Text = $"{_selectedItem.Name}\n{_selectedItem.TextureName}";
|
||||
_selectedItem = new SelectedTile(index, selectedArea, info);
|
||||
|
||||
tileNameLabel.Text = $"{_selectedItem.Tile.DisplayName}";
|
||||
}
|
||||
|
||||
bool hasAnimation =
|
||||
_pckFile.Files.TryGetValue($"res/textures/{_atlasType}/{_selectedItem.TextureName}.png", PckFile.FileData.FileType.TextureFile, out var animationFile);
|
||||
_pckFile.Files.TryGetValue($"res/textures/{_atlasType}/{_selectedItem.Tile.InternalName}.png", PckFile.FileData.FileType.TextureFile, out var animationFile);
|
||||
animationButton.Text = hasAnimation ? "Edit Animation" : "Create Animation";
|
||||
replaceButton.Enabled = !hasAnimation;
|
||||
|
||||
@@ -149,6 +147,8 @@ namespace PckStudio
|
||||
using var ms = new MemoryStream(animationFile.Data);
|
||||
var img = Image.FromStream(ms);
|
||||
var textures = img.CreateImageList(ImageLayoutDirection.Vertical);
|
||||
|
||||
selectTilePictureBox.BlendColor = GetBlendColor();
|
||||
var animation = new Internal.Animation(textures, animationFile.Properties.GetPropertyValue("ANIM"));
|
||||
selectTilePictureBox.Start(animation);
|
||||
return;
|
||||
@@ -156,44 +156,23 @@ namespace PckStudio
|
||||
|
||||
if (_textures.IndexInRange(index))
|
||||
{
|
||||
var img = _textures[index];
|
||||
if (applyColorMaskToolStripMenuItem.Checked &&
|
||||
_selectedItem.Tile.HasColourEntry &&
|
||||
!string.IsNullOrWhiteSpace(_selectedItem.Tile.ColourEntry.DefaultName) &&
|
||||
_colourTable is not null &&
|
||||
_colourTable.Colors.FirstOrDefault(entry => entry.Name == _selectedItem.Tile.ColourEntry.DefaultName) is ColorContainer.Color color)
|
||||
{
|
||||
img = img.Blend(color.ColorPallette, BlendMode.Multiply);
|
||||
if (variantComboBox.Enabled = _selectedItem.Tile.ColourEntry.Variants.Length > 1)
|
||||
selectTilePictureBox.BlendColor = color.ColorPallette;
|
||||
if (variantLabel.Visible = variantComboBox.Visible = _selectedItem.Tile.ColourEntry.Variants.Length > 1)
|
||||
{
|
||||
variantComboBox.Items.Clear();
|
||||
variantComboBox.Items.AddRange(_selectedItem.Tile.ColourEntry.Variants);
|
||||
variantComboBox.SelectedItem = _selectedItem.Tile.ColourEntry.DefaultName;
|
||||
}
|
||||
}
|
||||
selectTilePictureBox.Image = img;
|
||||
selectTilePictureBox.Image = _textures[index];
|
||||
}
|
||||
}
|
||||
|
||||
private void originalPictureBox_MouseClick(object sender, MouseEventArgs e)
|
||||
{
|
||||
if (e.Button != MouseButtons.Left)
|
||||
return;
|
||||
|
||||
int index = GetSelectedImageIndex(
|
||||
originalPictureBox.Size,
|
||||
originalPictureBox.Image.Size,
|
||||
_areaSize,
|
||||
e.Location,
|
||||
originalPictureBox.SizeMode,
|
||||
_imageLayout);
|
||||
|
||||
if (index != -1)
|
||||
{
|
||||
SelectedIndex = index;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static int GetSelectedImageIndex(
|
||||
Size pictureBoxSize,
|
||||
Size imageSize,
|
||||
@@ -285,21 +264,6 @@ namespace PckStudio
|
||||
return new Point(x, y);
|
||||
}
|
||||
|
||||
private void replaceButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
OpenFileDialog fileDialog = new OpenFileDialog()
|
||||
{
|
||||
Filter = "PNG Image|*.png",
|
||||
Title = "Select Texture"
|
||||
};
|
||||
|
||||
if (fileDialog.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
var img = Image.FromFile(fileDialog.FileName);
|
||||
SetTile(img);
|
||||
}
|
||||
}
|
||||
|
||||
private void SetTile(Image texture)
|
||||
{
|
||||
var graphicsConfig = new GraphicsConfig()
|
||||
@@ -320,61 +284,39 @@ namespace PckStudio
|
||||
originalPictureBox.Invalidate();
|
||||
}
|
||||
|
||||
private void saveToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
private void ApplyBlend(string colorKey, Image image)
|
||||
{
|
||||
DialogResult = DialogResult.OK;
|
||||
if (variantComboBox.Enabled = _selectedItem.Tile.ColourEntry.Variants.Length > 1)
|
||||
{
|
||||
selectTilePictureBox.BlendColor = FindBlendColorByKey(colorKey);
|
||||
selectTilePictureBox.Image = image;
|
||||
}
|
||||
}
|
||||
|
||||
private void animationButton_Click(object sender, EventArgs e)
|
||||
private Color GetBlendColor()
|
||||
{
|
||||
bool isNewFile;
|
||||
if (isNewFile = !_pckFile.Files.TryGetValue(
|
||||
$"res/textures/{_atlasType}/{_selectedItem.TextureName}.png",
|
||||
PckFile.FileData.FileType.TextureFile, out var file
|
||||
))
|
||||
{
|
||||
file = new PckFile.FileData($"res/textures/{_atlasType}/{_selectedItem.TextureName}.png", PckFile.FileData.FileType.TextureFile);
|
||||
}
|
||||
if (_selectedItem.Tile.HasColourEntry && _selectedItem.Tile.ColourEntry is not null)
|
||||
return FindBlendColorByKey(_selectedItem.Tile.ColourEntry.DefaultName);
|
||||
return Color.White;
|
||||
}
|
||||
|
||||
AnimationEditor animationEditor;
|
||||
if (_selectedItem.Tile.HasColourEntry &&
|
||||
!string.IsNullOrWhiteSpace(_selectedItem.Tile.ColourEntry.DefaultName) &&
|
||||
_colourTable is not null)
|
||||
private Color FindBlendColorByKey(string colorKey)
|
||||
{
|
||||
if (_colourTable is not null &&
|
||||
_selectedItem.Tile.HasColourEntry &&
|
||||
_selectedItem.Tile.ColourEntry is not null)
|
||||
{
|
||||
Color blenColor = Color.White;
|
||||
if (_selectedItem.Tile.ColourEntry.IsWaterColour &&
|
||||
_colourTable.WaterColors.FirstOrDefault(entry => entry.Name == _selectedItem.Tile.ColourEntry.DefaultName) is ColorContainer.WaterColor waterColor)
|
||||
_colourTable.WaterColors.FirstOrDefault(entry => entry.Name == colorKey) is ColorContainer.WaterColor waterColor)
|
||||
{
|
||||
blenColor = waterColor.SurfaceColor;
|
||||
return waterColor.SurfaceColor;
|
||||
}
|
||||
else if (_colourTable.Colors.FirstOrDefault(entry => entry.Name == _selectedItem.Tile.ColourEntry.DefaultName) is ColorContainer.Color color)
|
||||
else if (_colourTable.Colors.FirstOrDefault(entry => entry.Name == colorKey) is ColorContainer.Color color)
|
||||
{
|
||||
blenColor = color.ColorPallette;
|
||||
return color.ColorPallette;
|
||||
}
|
||||
animationEditor = new AnimationEditor(file, blenColor);
|
||||
}
|
||||
else
|
||||
{
|
||||
animationEditor = new AnimationEditor(file);
|
||||
}
|
||||
|
||||
if (animationEditor.ShowDialog() == DialogResult.OK && isNewFile)
|
||||
{
|
||||
_pckFile.Files.Add(file);
|
||||
}
|
||||
}
|
||||
|
||||
private void extractTileToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
SaveFileDialog saveFileDialog = new SaveFileDialog()
|
||||
{
|
||||
Filter = "Tile Texture|*.png",
|
||||
FileName = _selectedItem.TextureName
|
||||
};
|
||||
if (saveFileDialog.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
selectTilePictureBox.Image.Save(saveFileDialog.FileName, ImageFormat.Png);
|
||||
}
|
||||
return Color.White;
|
||||
}
|
||||
|
||||
protected override bool ProcessDialogKey(Keys keyData)
|
||||
@@ -415,33 +357,83 @@ namespace PckStudio
|
||||
return false;
|
||||
}
|
||||
|
||||
private void ApplyBlend(string colorKey, Image image)
|
||||
private void originalPictureBox_MouseClick(object sender, MouseEventArgs e)
|
||||
{
|
||||
Color blendColor = Color.White;
|
||||
if (_selectedItem.Tile.HasColourEntry &&
|
||||
_colourTable is not null)
|
||||
{
|
||||
if (_selectedItem.Tile.ColourEntry.IsWaterColour &&
|
||||
_colourTable.WaterColors.FirstOrDefault(entry => entry.Name == colorKey) is ColorContainer.WaterColor waterColor)
|
||||
{
|
||||
blendColor = waterColor.SurfaceColor;
|
||||
}
|
||||
else if (_colourTable.Colors.FirstOrDefault(entry => entry.Name == colorKey) is ColorContainer.Color color)
|
||||
{
|
||||
blendColor = color.ColorPallette;
|
||||
}
|
||||
if (e.Button != MouseButtons.Left)
|
||||
return;
|
||||
|
||||
if (variantComboBox.Enabled = _selectedItem.Tile.ColourEntry.Variants.Length > 1)
|
||||
{
|
||||
selectTilePictureBox.Image = image.Blend(blendColor, BlendMode.Multiply);
|
||||
}
|
||||
int index = GetSelectedImageIndex(
|
||||
originalPictureBox.Size,
|
||||
originalPictureBox.Image.Size,
|
||||
_areaSize,
|
||||
e.Location,
|
||||
originalPictureBox.SizeMode,
|
||||
_imageLayout);
|
||||
|
||||
if (index != -1)
|
||||
{
|
||||
SelectedIndex = index;
|
||||
}
|
||||
}
|
||||
|
||||
private void replaceButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
OpenFileDialog fileDialog = new OpenFileDialog()
|
||||
{
|
||||
Filter = "PNG Image|*.png",
|
||||
Title = "Select Texture"
|
||||
};
|
||||
|
||||
if (fileDialog.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
var img = Image.FromFile(fileDialog.FileName);
|
||||
SetTile(img);
|
||||
}
|
||||
}
|
||||
|
||||
private void saveToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
DialogResult = DialogResult.OK;
|
||||
}
|
||||
|
||||
private void animationButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
bool isNewFile;
|
||||
if (isNewFile = !_pckFile.Files.TryGetValue(
|
||||
$"res/textures/{_atlasType}/{_selectedItem.Tile.InternalName}.png",
|
||||
PckFile.FileData.FileType.TextureFile, out var file
|
||||
))
|
||||
{
|
||||
file = new PckFile.FileData($"res/textures/{_atlasType}/{_selectedItem.Tile.InternalName}.png", PckFile.FileData.FileType.TextureFile);
|
||||
}
|
||||
|
||||
var animationEditor = new AnimationEditor(file, GetBlendColor());
|
||||
if (animationEditor.ShowDialog() == DialogResult.OK && isNewFile)
|
||||
{
|
||||
_pckFile.Files.Add(file);
|
||||
}
|
||||
}
|
||||
|
||||
private void extractTileToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
SaveFileDialog saveFileDialog = new SaveFileDialog()
|
||||
{
|
||||
Filter = "Tile Texture|*.png",
|
||||
FileName = _selectedItem.Tile.InternalName
|
||||
};
|
||||
if (saveFileDialog.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
selectTilePictureBox.Image.Save(saveFileDialog.FileName, ImageFormat.Png);
|
||||
}
|
||||
}
|
||||
|
||||
private void variantComboBox_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (_selectedItem.Tile.ColourEntry.Variants.IndexInRange(variantComboBox.SelectedIndex))
|
||||
if (_selectedItem.Tile.ColourEntry is not null &&
|
||||
_selectedItem.Tile.ColourEntry.Variants.IndexInRange(variantComboBox.SelectedIndex))
|
||||
{
|
||||
ApplyBlend(_selectedItem.Tile.ColourEntry.Variants[variantComboBox.SelectedIndex], _textures[_selectedItem.Index]);
|
||||
}
|
||||
}
|
||||
|
||||
private void applyColorMaskToolStripMenuItem_CheckedChanged(object sender, EventArgs e)
|
||||
|
||||
@@ -117,9 +117,6 @@
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<metadata name="metroLabel1.GenerateMember" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>False</value>
|
||||
</metadata>
|
||||
<metadata name="menuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>17, 17</value>
|
||||
</metadata>
|
||||
|
||||
Reference in New Issue
Block a user