From c645cef9edd4c4958e8d783e57020ea0e48fe984 Mon Sep 17 00:00:00 2001 From: MattN-L Date: Sun, 10 Mar 2024 16:40:25 -0400 Subject: [PATCH] Added Classic Water variant support --- .../Editor/TextureAtlasEditor.Designer.cs | 8 +- PCK-Studio/Forms/Editor/TextureAtlasEditor.cs | 55 ++++++------ PCK-Studio/Resources/tileData.json | 90 ++++++++++++++++++- 3 files changed, 118 insertions(+), 35 deletions(-) diff --git a/PCK-Studio/Forms/Editor/TextureAtlasEditor.Designer.cs b/PCK-Studio/Forms/Editor/TextureAtlasEditor.Designer.cs index 0b9c0290..9487197b 100644 --- a/PCK-Studio/Forms/Editor/TextureAtlasEditor.Designer.cs +++ b/PCK-Studio/Forms/Editor/TextureAtlasEditor.Designer.cs @@ -90,14 +90,14 @@ // saveToolStripMenuItem // this.saveToolStripMenuItem.Name = "saveToolStripMenuItem"; - this.saveToolStripMenuItem.Size = new System.Drawing.Size(131, 22); + this.saveToolStripMenuItem.Size = new System.Drawing.Size(180, 22); this.saveToolStripMenuItem.Text = "Save"; this.saveToolStripMenuItem.Click += new System.EventHandler(this.saveToolStripMenuItem_Click); // // extractTileToolStripMenuItem // this.extractTileToolStripMenuItem.Name = "extractTileToolStripMenuItem"; - this.extractTileToolStripMenuItem.Size = new System.Drawing.Size(131, 22); + this.extractTileToolStripMenuItem.Size = new System.Drawing.Size(180, 22); this.extractTileToolStripMenuItem.Text = "Extract Tile"; this.extractTileToolStripMenuItem.Click += new System.EventHandler(this.extractTileToolStripMenuItem_Click); // @@ -117,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(168, 22); + this.applyColorMaskToolStripMenuItem.Size = new System.Drawing.Size(180, 22); this.applyColorMaskToolStripMenuItem.Text = "Apply Color Mask"; this.applyColorMaskToolStripMenuItem.CheckedChanged += new System.EventHandler(this.applyColorMaskToolStripMenuItem_CheckedChanged); // @@ -127,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(168, 22); + this.playAnimationsToolStripMenuItem.Size = new System.Drawing.Size(180, 22); this.playAnimationsToolStripMenuItem.Text = "Play Animations"; this.playAnimationsToolStripMenuItem.CheckedChanged += new System.EventHandler(this.playAnimationsToolStripMenuItem_CheckedChanged); // diff --git a/PCK-Studio/Forms/Editor/TextureAtlasEditor.cs b/PCK-Studio/Forms/Editor/TextureAtlasEditor.cs index 99cb4972..fe569733 100644 --- a/PCK-Studio/Forms/Editor/TextureAtlasEditor.cs +++ b/PCK-Studio/Forms/Editor/TextureAtlasEditor.cs @@ -164,21 +164,26 @@ namespace PckStudio.Forms.Editor selectTilePictureBox.Start(animation); } - if (variantComboBox.Enabled = variantLabel.Visible = variantComboBox.Visible = - dataTile.Tile.HasColourEntry && dataTile.Tile.ColourEntry.Variants.Length > 1) + if (variantComboBox.Enabled = variantLabel.Visible = variantComboBox.Visible = + dataTile.Tile.HasColourEntry) { - variantComboBox.Items.AddRange(dataTile.Tile.ColourEntry.Variants); - variantComboBox.SelectedItem = dataTile.Tile.ColourEntry.DefaultName; - } - else if(variantComboBox.Enabled = variantLabel.Visible = variantComboBox.Visible = - dataTile.Tile.HasColourEntry && dataTile.Tile.ColourEntry.IsWaterColour && _colourTable.WaterColors.Count > 0) - { - foreach (var col in _colourTable.WaterColors) + if (dataTile.Tile.ColourEntry.IsWaterColour && _colourTable.WaterColors.Count > 0) { - variantComboBox.Items.Add(col.Name); + foreach (var col in _colourTable.WaterColors) + { + if(!variantComboBox.Items.Contains(col.Name)) + variantComboBox.Items.Add(col.Name); + } + + dataTile.Tile.ColourEntry.DefaultName = _colourTable.WaterColors[0].Name; } - variantComboBox.SelectedItem = _colourTable.WaterColors[0].Name; + if (dataTile.Tile.ColourEntry.Variants.Length > 1) + { + variantComboBox.Items.AddRange(dataTile.Tile.ColourEntry.Variants); + } + + variantComboBox.SelectedItem = dataTile.Tile.ColourEntry.DefaultName; } } @@ -317,15 +322,18 @@ namespace PckStudio.Forms.Editor dataTile.Tile.HasColourEntry && dataTile.Tile.ColourEntry is not null) { - if (dataTile.Tile.ColourEntry.IsWaterColour && - _colourTable.WaterColors.FirstOrDefault(entry => entry.Name == colorKey) is ColorContainer.WaterColor waterColor) + // basic way to check for classic water colors + if(!dataTile.Tile.ColourEntry.IsWaterColour || colorKey.StartsWith("Water_")) + { + if (_colourTable.Colors.FirstOrDefault(entry => entry.Name == colorKey) is ColorContainer.Color color) + { + return color.ColorPallette; + } + } + else if (_colourTable.WaterColors.FirstOrDefault(entry => entry.Name == colorKey) is ColorContainer.WaterColor waterColor) { return waterColor.SurfaceColor; } - else if (_colourTable.Colors.FirstOrDefault(entry => entry.Name == colorKey) is ColorContainer.Color color) - { - return color.ColorPallette; - } } return Color.White; } @@ -442,20 +450,13 @@ namespace PckStudio.Forms.Editor private void variantComboBox_SelectedIndexChanged(object sender, EventArgs e) { - if (dataTile.Tile.ColourEntry is not null && - dataTile.Tile.ColourEntry.Variants.IndexInRange(variantComboBox.SelectedIndex)) + if (dataTile.Tile.ColourEntry is not null) { - string colorKey = dataTile.Tile.ColourEntry.IsWaterColour ? variantComboBox.SelectedValue.ToString() : dataTile.Tile.ColourEntry.Variants[variantComboBox.SelectedIndex]; + string colorKey = variantComboBox.SelectedItem.ToString(); + selectTilePictureBox.BlendColor = FindBlendColorByKey(colorKey); selectTilePictureBox.Image = dataTile.Texture; } - else if(dataTile.Tile.ColourEntry is not null && - dataTile.Tile.ColourEntry.IsWaterColour) - { - string colorKey = variantComboBox.GetItemText(variantComboBox.SelectedItem); - selectTilePictureBox.BlendColor = FindBlendColorByKey(colorKey); - selectTilePictureBox.Image = dataTile.Texture; - } } private void applyColorMaskToolStripMenuItem_CheckedChanged(object sender, EventArgs e) diff --git a/PCK-Studio/Resources/tileData.json b/PCK-Studio/Resources/tileData.json index 9bbd3d12..d617d7a5 100644 --- a/PCK-Studio/Resources/tileData.json +++ b/PCK-Studio/Resources/tileData.json @@ -1001,8 +1001,49 @@ "hasColourEntry": true, "colourEntry": { "isWaterColour": true, - "defaultName": "", - "variants": [] + "defaultName": "Water_Plains", + "variants": [ + "Water_Ocean", + "Water_Plains", + "Water_Desert", + "Water_ExtremeHills", + "Water_Forest", + "Water_Taiga", + "Water_Swampland", + "Water_River", + "Water_Hell", + "Water_Sky", + "Water_FrozenOcean", + "Water_FrozenRiver", + "Water_IcePlains", + "Water_IceMountains", + "Water_MushroomIsland", + "Water_MushroomIslandShore", + "Water_Beach", + "Water_DesertHills", + "Water_ForestHills", + "Water_TaigaHills", + "Water_ExtremeHillsEdge", + "Water_Jungle", + "Water_JungleHills", + "Water_JungleEdge", + "Water_DeepOcean", + "Water_StoneBeach", + "Water_ColdBeach", + "Water_BirchForest", + "Water_BirchForestHills", + "Water_RoofedForest", + "Water_ColdTaiga", + "Water_ColdTaigaHills", + "Water_MegaTaiga", + "Water_MegaTaigaHills", + "Water_ExtremeHillsPlus", + "Water_Savanna", + "Water_SavannaPlateau", + "Water_Mesa", + "Water_MesaPlateauF", + "Water_MesaPlateau" + ] } }, { @@ -1011,8 +1052,49 @@ "hasColourEntry": true, "colourEntry": { "isWaterColour": true, - "defaultName": "", - "variants": [] + "defaultName": "Water_Plains", + "variants": [ + "Water_Ocean", + "Water_Plains", + "Water_Desert", + "Water_ExtremeHills", + "Water_Forest", + "Water_Taiga", + "Water_Swampland", + "Water_River", + "Water_Hell", + "Water_Sky", + "Water_FrozenOcean", + "Water_FrozenRiver", + "Water_IcePlains", + "Water_IceMountains", + "Water_MushroomIsland", + "Water_MushroomIslandShore", + "Water_Beach", + "Water_DesertHills", + "Water_ForestHills", + "Water_TaigaHills", + "Water_ExtremeHillsEdge", + "Water_Jungle", + "Water_JungleHills", + "Water_JungleEdge", + "Water_DeepOcean", + "Water_StoneBeach", + "Water_ColdBeach", + "Water_BirchForest", + "Water_BirchForestHills", + "Water_RoofedForest", + "Water_ColdTaiga", + "Water_ColdTaigaHills", + "Water_MegaTaiga", + "Water_MegaTaigaHills", + "Water_ExtremeHillsPlus", + "Water_Savanna", + "Water_SavannaPlateau", + "Water_Mesa", + "Water_MesaPlateauF", + "Water_MesaPlateau" + ] } }, {