From 9469ebc3fd4aea5d85c3199c220e451fe1fa1b92 Mon Sep 17 00:00:00 2001 From: MattN-L Date: Thu, 14 Mar 2024 18:54:57 -0400 Subject: [PATCH] Added Slider for XP Orb colors --- .../Editor/TextureAtlasEditor.Designer.cs | 132 ++++++++++++------ PCK-Studio/Forms/Editor/TextureAtlasEditor.cs | 27 ++-- 2 files changed, 100 insertions(+), 59 deletions(-) diff --git a/PCK-Studio/Forms/Editor/TextureAtlasEditor.Designer.cs b/PCK-Studio/Forms/Editor/TextureAtlasEditor.Designer.cs index 0fdbfdd5..3833e018 100644 --- a/PCK-Studio/Forms/Editor/TextureAtlasEditor.Designer.cs +++ b/PCK-Studio/Forms/Editor/TextureAtlasEditor.Designer.cs @@ -33,11 +33,11 @@ this.menuStrip1 = new System.Windows.Forms.MenuStrip(); this.fileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.saveToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.extractTileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.viewToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.applyColorMaskToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.playAnimationsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel(); + this.colorSliderLabel = new MetroFramework.Controls.MetroLabel(); this.originalPictureBox = new PckStudio.ToolboxItems.InterpolationPictureBox(); this.selectTilePictureBox = new PckStudio.ToolboxItems.AnimationPictureBox(); this.replaceButton = new MetroFramework.Controls.MetroButton(); @@ -46,6 +46,8 @@ this.setColorButton = new MetroFramework.Controls.MetroButton(); this.animationButton = new MetroFramework.Controls.MetroButton(); this.clearColorButton = new MetroFramework.Controls.MetroButton(); + this.colorSlider = new MetroFramework.Controls.MetroTrackBar(); + this.metroButton1 = new MetroFramework.Controls.MetroButton(); this.menuStrip1.SuspendLayout(); this.tableLayoutPanel1.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.originalPictureBox)).BeginInit(); @@ -58,12 +60,12 @@ | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); this.variantLabel.AutoSize = true; - this.variantLabel.Location = new System.Drawing.Point(3, 232); + this.variantLabel.Location = new System.Drawing.Point(3, 254); this.variantLabel.Name = "variantLabel"; - this.variantLabel.Size = new System.Drawing.Size(55, 25); + this.variantLabel.Size = new System.Drawing.Size(208, 24); this.variantLabel.TabIndex = 18; this.variantLabel.Text = "Variant:"; - this.variantLabel.TextAlign = System.Drawing.ContentAlignment.MiddleRight; + this.variantLabel.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; this.variantLabel.Theme = MetroFramework.MetroThemeStyle.Dark; // // menuStrip1 @@ -82,8 +84,7 @@ // this.fileToolStripMenuItem.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(20)))), ((int)(((byte)(20)))), ((int)(((byte)(20))))); this.fileToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.saveToolStripMenuItem, - this.extractTileToolStripMenuItem}); + this.saveToolStripMenuItem}); this.fileToolStripMenuItem.ForeColor = System.Drawing.SystemColors.Menu; this.fileToolStripMenuItem.Name = "fileToolStripMenuItem"; this.fileToolStripMenuItem.Size = new System.Drawing.Size(37, 20); @@ -96,13 +97,6 @@ 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(180, 22); - this.extractTileToolStripMenuItem.Text = "Extract Tile"; - this.extractTileToolStripMenuItem.Click += new System.EventHandler(this.extractTileToolStripMenuItem_Click); - // // viewToolStripMenuItem // this.viewToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { @@ -141,34 +135,52 @@ this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 10.43842F)); this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 26.09603F)); this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 63.46555F)); + this.tableLayoutPanel1.Controls.Add(this.variantComboBox, 0, 2); + this.tableLayoutPanel1.Controls.Add(this.variantLabel, 0, 2); + this.tableLayoutPanel1.Controls.Add(this.colorSliderLabel, 0, 3); this.tableLayoutPanel1.Controls.Add(this.originalPictureBox, 2, 0); this.tableLayoutPanel1.Controls.Add(this.selectTilePictureBox, 0, 0); - this.tableLayoutPanel1.Controls.Add(this.replaceButton, 0, 6); + this.tableLayoutPanel1.Controls.Add(this.replaceButton, 0, 7); 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.Controls.Add(this.setColorButton, 0, 4); - this.tableLayoutPanel1.Controls.Add(this.animationButton, 1, 6); + this.tableLayoutPanel1.Controls.Add(this.animationButton, 1, 7); this.tableLayoutPanel1.Controls.Add(this.clearColorButton, 1, 4); + this.tableLayoutPanel1.Controls.Add(this.colorSlider, 1, 3); + this.tableLayoutPanel1.Controls.Add(this.metroButton1, 0, 6); this.tableLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill; this.tableLayoutPanel1.Location = new System.Drawing.Point(20, 84); this.tableLayoutPanel1.Name = "tableLayoutPanel1"; - this.tableLayoutPanel1.RowCount = 7; - this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 38.09524F)); - this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 4.761905F)); - this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 4.761905F)); - this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 38.09524F)); - this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 4.761905F)); - this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 4.761905F)); - this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 4.761905F)); - this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F)); - this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F)); - this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F)); + this.tableLayoutPanel1.RowCount = 8; + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 36.3643F)); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 4.545537F)); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 4.545537F)); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 36.3643F)); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 4.545537F)); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 4.543719F)); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 4.545537F)); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 4.545537F)); this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F)); this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F)); this.tableLayoutPanel1.Size = new System.Drawing.Size(590, 565); this.tableLayoutPanel1.TabIndex = 17; // + // colorSliderLabel + // + this.colorSliderLabel.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.colorSliderLabel.AutoSize = true; + this.colorSliderLabel.BackColor = System.Drawing.Color.Transparent; + this.colorSliderLabel.Location = new System.Drawing.Point(3, 246); + this.colorSliderLabel.Name = "colorSliderLabel"; + this.colorSliderLabel.Size = new System.Drawing.Size(55, 198); + this.colorSliderLabel.TabIndex = 19; + this.colorSliderLabel.Text = "Color Range:"; + this.colorSliderLabel.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + this.colorSliderLabel.Theme = MetroFramework.MetroThemeStyle.Dark; + this.colorSliderLabel.Visible = false; + this.colorSliderLabel.WrapToLine = true; + // // originalPictureBox // this.originalPictureBox.BackColor = System.Drawing.Color.Transparent; @@ -176,8 +188,8 @@ this.originalPictureBox.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.NearestNeighbor; this.originalPictureBox.Location = new System.Drawing.Point(217, 3); this.originalPictureBox.Name = "originalPictureBox"; - this.tableLayoutPanel1.SetRowSpan(this.originalPictureBox, 7); - this.originalPictureBox.Size = new System.Drawing.Size(370, 533); + this.tableLayoutPanel1.SetRowSpan(this.originalPictureBox, 8); + this.originalPictureBox.Size = new System.Drawing.Size(370, 534); this.originalPictureBox.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom; this.originalPictureBox.TabIndex = 4; this.originalPictureBox.TabStop = false; @@ -196,7 +208,7 @@ 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(208, 201); + this.selectTilePictureBox.Size = new System.Drawing.Size(208, 192); this.selectTilePictureBox.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom; this.selectTilePictureBox.TabIndex = 0; this.selectTilePictureBox.TabStop = false; @@ -208,11 +220,11 @@ | System.Windows.Forms.AnchorStyles.Right))); this.replaceButton.AutoSize = true; this.tableLayoutPanel1.SetColumnSpan(this.replaceButton, 2); - this.replaceButton.Location = new System.Drawing.Point(3, 517); + this.replaceButton.Location = new System.Drawing.Point(3, 519); this.replaceButton.Name = "replaceButton"; - this.replaceButton.Size = new System.Drawing.Size(208, 19); + this.replaceButton.Size = new System.Drawing.Size(208, 18); this.replaceButton.TabIndex = 14; - this.replaceButton.Text = "Replace"; + this.replaceButton.Text = "Replace Tile on Atlas"; this.replaceButton.Theme = MetroFramework.MetroThemeStyle.Dark; this.replaceButton.UseSelectable = true; this.replaceButton.Click += new System.EventHandler(this.replaceButton_Click); @@ -223,23 +235,25 @@ | System.Windows.Forms.AnchorStyles.Right))); this.tileNameLabel.AutoSize = true; this.tableLayoutPanel1.SetColumnSpan(this.tileNameLabel, 2); - this.tileNameLabel.Location = new System.Drawing.Point(3, 213); + this.tileNameLabel.Location = new System.Drawing.Point(3, 203); this.tileNameLabel.Name = "tileNameLabel"; - this.tileNameLabel.Size = new System.Drawing.Size(208, 19); + this.tileNameLabel.Size = new System.Drawing.Size(208, 43); this.tileNameLabel.TabIndex = 19; this.tileNameLabel.Text = "TileName"; this.tileNameLabel.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; this.tileNameLabel.Theme = MetroFramework.MetroThemeStyle.Dark; + this.tileNameLabel.WrapToLine = true; // // variantComboBox // this.variantComboBox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right))); + this.tableLayoutPanel1.SetColumnSpan(this.variantComboBox, 2); this.variantComboBox.Enabled = false; this.variantComboBox.FormattingEnabled = true; this.variantComboBox.ItemHeight = 23; - this.variantComboBox.Location = new System.Drawing.Point(64, 235); + this.variantComboBox.Location = new System.Drawing.Point(3, 287); this.variantComboBox.Name = "variantComboBox"; - this.variantComboBox.Size = new System.Drawing.Size(147, 29); + this.variantComboBox.Size = new System.Drawing.Size(208, 29); this.variantComboBox.TabIndex = 17; this.variantComboBox.Theme = MetroFramework.MetroThemeStyle.Dark; this.variantComboBox.UseSelectable = true; @@ -249,9 +263,9 @@ // this.setColorButton.Anchor = System.Windows.Forms.AnchorStyles.Left; this.tableLayoutPanel1.SetColumnSpan(this.setColorButton, 2); - this.setColorButton.Location = new System.Drawing.Point(3, 467); + this.setColorButton.Location = new System.Drawing.Point(3, 447); this.setColorButton.Name = "setColorButton"; - this.setColorButton.Size = new System.Drawing.Size(208, 19); + this.setColorButton.Size = new System.Drawing.Size(208, 18); this.setColorButton.TabIndex = 25; this.setColorButton.Text = "Set Custom Colour"; this.setColorButton.Theme = MetroFramework.MetroThemeStyle.Dark; @@ -264,9 +278,9 @@ | System.Windows.Forms.AnchorStyles.Right))); this.animationButton.AutoSize = true; this.tableLayoutPanel1.SetColumnSpan(this.animationButton, 2); - this.animationButton.Location = new System.Drawing.Point(3, 542); + this.animationButton.Location = new System.Drawing.Point(3, 543); this.animationButton.Name = "animationButton"; - this.animationButton.Size = new System.Drawing.Size(208, 20); + this.animationButton.Size = new System.Drawing.Size(208, 19); this.animationButton.TabIndex = 16; this.animationButton.Text = "Animation"; this.animationButton.Theme = MetroFramework.MetroThemeStyle.Dark; @@ -277,15 +291,41 @@ // this.clearColorButton.Anchor = System.Windows.Forms.AnchorStyles.Left; this.tableLayoutPanel1.SetColumnSpan(this.clearColorButton, 2); - this.clearColorButton.Location = new System.Drawing.Point(3, 492); + this.clearColorButton.Location = new System.Drawing.Point(3, 471); this.clearColorButton.Name = "clearColorButton"; - this.clearColorButton.Size = new System.Drawing.Size(208, 19); + this.clearColorButton.Size = new System.Drawing.Size(208, 18); this.clearColorButton.TabIndex = 24; this.clearColorButton.Text = "Clear Custom Colour"; this.clearColorButton.Theme = MetroFramework.MetroThemeStyle.Dark; this.clearColorButton.UseSelectable = true; this.clearColorButton.Click += new System.EventHandler(this.clearColorButton_Click); // + // colorSlider + // + this.colorSlider.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom))); + this.colorSlider.BackColor = System.Drawing.Color.Transparent; + this.colorSlider.Location = new System.Drawing.Point(64, 249); + this.colorSlider.Maximum = 255; + this.colorSlider.Name = "colorSlider"; + this.colorSlider.Size = new System.Drawing.Size(147, 192); + this.colorSlider.TabIndex = 26; + this.colorSlider.Text = "metroTrackBar1"; + this.colorSlider.Theme = MetroFramework.MetroThemeStyle.Dark; + this.colorSlider.Value = 0; + this.colorSlider.Visible = false; + this.colorSlider.ValueChanged += new System.EventHandler(this.colorSlider_ValueChanged); + // + // metroButton1 + // + this.tableLayoutPanel1.SetColumnSpan(this.metroButton1, 2); + this.metroButton1.Location = new System.Drawing.Point(3, 495); + this.metroButton1.Name = "metroButton1"; + this.metroButton1.Size = new System.Drawing.Size(208, 18); + this.metroButton1.TabIndex = 27; + this.metroButton1.Text = "Extract Tile from Atlas"; + this.metroButton1.Theme = MetroFramework.MetroThemeStyle.Dark; + this.metroButton1.UseSelectable = true; + // // TextureAtlasEditor // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); @@ -323,7 +363,6 @@ private PckStudio.ToolboxItems.InterpolationPictureBox originalPictureBox; private System.Windows.Forms.ToolStripMenuItem saveToolStripMenuItem; 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; @@ -332,5 +371,8 @@ private MetroFramework.Controls.MetroLabel variantLabel; private MetroFramework.Controls.MetroButton clearColorButton; private MetroFramework.Controls.MetroButton setColorButton; + private MetroFramework.Controls.MetroTrackBar colorSlider; + private MetroFramework.Controls.MetroLabel colorSliderLabel; + private MetroFramework.Controls.MetroButton metroButton1; } } \ No newline at end of file diff --git a/PCK-Studio/Forms/Editor/TextureAtlasEditor.cs b/PCK-Studio/Forms/Editor/TextureAtlasEditor.cs index 21b9eb4e..81334a5a 100644 --- a/PCK-Studio/Forms/Editor/TextureAtlasEditor.cs +++ b/PCK-Studio/Forms/Editor/TextureAtlasEditor.cs @@ -374,10 +374,14 @@ namespace PckStudio.Forms.Editor return Color.White; } - int xp_orb_red = 0x0; - bool xp_orb_reverse = false; private Color FindBlendColorByKey(string colorKey) { + // Experience Orbs are hardcoded within a range and do not have color table entries + if (colorSliderLabel.Visible = colorSlider.Visible = colorKey == "experience_orb") + { + return Color.FromArgb(colorSlider.Value, 255, 0); + } + if (_colourTable is not null && dataTile.Tile.HasColourEntry && dataTile.Tile.ColourEntry is not null) @@ -396,17 +400,6 @@ namespace PckStudio.Forms.Editor } } - // Experience Orbs are hardcoded within a range and do not have color table entries - if (colorKey == "experience_orb") - { - if (xp_orb_red == 0) xp_orb_reverse = false; - if (xp_orb_red == 0xFF) xp_orb_reverse = true; - - xp_orb_red += xp_orb_reverse ? -0x05 : 0x05; - - return Color.FromArgb(xp_orb_red, 255, 0); - } - return Color.White; } @@ -415,7 +408,7 @@ namespace PckStudio.Forms.Editor switch (keyData) { case Keys.R: - // Reselects the specific tile. Can be held to for cycling through colors for XP orbs + // Refreshes the specific tile SelectedIndex = _selectedTile.Index; return true; case Keys.Left: @@ -579,5 +572,11 @@ namespace PckStudio.Forms.Editor clearColorButton.Enabled = false; } + + private void colorSlider_ValueChanged(object sender, EventArgs e) + { + selectTilePictureBox.BlendColor = GetBlendColor(); + selectTilePictureBox.Image = dataTile.Texture; + } } } \ No newline at end of file