From 05691832152ed06dc9a91df0cbe80619f7ef35ac Mon Sep 17 00:00:00 2001 From: miku-666 <74728189+NessieHax@users.noreply.github.com> Date: Tue, 25 Jun 2024 18:26:29 +0200 Subject: [PATCH] Add 'Validate Skin Dimension' setting --- PCK-Studio/App.config | 3 +++ PCK-Studio/Forms/AppSettingsForm.Designer.cs | 17 +++++++++++++++++ PCK-Studio/Forms/AppSettingsForm.cs | 6 ++++++ PCK-Studio/Forms/Editor/CustomSkinEditor.cs | 3 ++- PCK-Studio/Properties/Settings.Designer.cs | 12 ++++++++++++ PCK-Studio/Properties/Settings.settings | 3 +++ 6 files changed, 43 insertions(+), 1 deletion(-) diff --git a/PCK-Studio/App.config b/PCK-Studio/App.config index f3cb4efa..dbbf8ebc 100644 --- a/PCK-Studio/App.config +++ b/PCK-Studio/App.config @@ -80,6 +80,9 @@ False + + True + diff --git a/PCK-Studio/Forms/AppSettingsForm.Designer.cs b/PCK-Studio/Forms/AppSettingsForm.Designer.cs index 977513d6..f84f10d7 100644 --- a/PCK-Studio/Forms/AppSettingsForm.Designer.cs +++ b/PCK-Studio/Forms/AppSettingsForm.Designer.cs @@ -37,6 +37,7 @@ this.showPresenceCheckBox = new MetroFramework.Controls.MetroCheckBox(); this.grf_paramKeyComboBoxCheckBox = new MetroFramework.Controls.MetroCheckBox(); this.usePrereleaseCheckBox = new MetroFramework.Controls.MetroCheckBox(); + this.validateSkinDimenssionCheckBox = new MetroFramework.Controls.MetroCheckBox(); this.SuspendLayout(); // // autoSaveCheckBox @@ -144,11 +145,26 @@ this.usePrereleaseCheckBox.UseSelectable = true; this.usePrereleaseCheckBox.Visible = false; // + // validateSkinDimenssionCheckBox + // + this.validateSkinDimenssionCheckBox.AutoSize = true; + this.validateSkinDimenssionCheckBox.Location = new System.Drawing.Point(23, 190); + this.validateSkinDimenssionCheckBox.Name = "validateSkinDimenssionCheckBox"; + this.validateSkinDimenssionCheckBox.Size = new System.Drawing.Size(149, 15); + this.validateSkinDimenssionCheckBox.Style = MetroFramework.MetroColorStyle.White; + this.validateSkinDimenssionCheckBox.TabIndex = 7; + this.validateSkinDimenssionCheckBox.Text = "Validate Skin Dimension"; + this.validateSkinDimenssionCheckBox.Theme = MetroFramework.MetroThemeStyle.Dark; + this.SettingToolTip.SetToolTip(this.validateSkinDimenssionCheckBox, "Use a combobox instead of typing the parameter key name"); + this.validateSkinDimenssionCheckBox.UseSelectable = true; + this.validateSkinDimenssionCheckBox.CheckedChanged += new System.EventHandler(this.validateSkinDimenssionCheckBox_CheckedChanged); + // // AppSettingsForm // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(527, 270); + this.Controls.Add(this.validateSkinDimenssionCheckBox); this.Controls.Add(this.usePrereleaseCheckBox); this.Controls.Add(this.grf_paramKeyComboBoxCheckBox); this.Controls.Add(this.showPresenceCheckBox); @@ -181,5 +197,6 @@ private MetroFramework.Controls.MetroCheckBox showPresenceCheckBox; private MetroFramework.Controls.MetroCheckBox grf_paramKeyComboBoxCheckBox; private MetroFramework.Controls.MetroCheckBox usePrereleaseCheckBox; + private MetroFramework.Controls.MetroCheckBox validateSkinDimenssionCheckBox; } } \ No newline at end of file diff --git a/PCK-Studio/Forms/AppSettingsForm.cs b/PCK-Studio/Forms/AppSettingsForm.cs index b62445a0..79b2baad 100644 --- a/PCK-Studio/Forms/AppSettingsForm.cs +++ b/PCK-Studio/Forms/AppSettingsForm.cs @@ -55,6 +55,11 @@ namespace PckStudio.Forms Settings.Default.UsePrerelease = usePrereleaseCheckBox.Checked; } + private void validateSkinDimenssionCheckBox_CheckedChanged(object sender, EventArgs e) + { + Settings.Default.ValidateImageDimension = validateSkinDimenssionCheckBox.Checked; + } + private void LoadCheckboxState(CheckBox checkBox, EventHandler eventHandler, bool state) { checkBox.CheckedChanged -= eventHandler; @@ -71,6 +76,7 @@ namespace PckStudio.Forms LoadCheckboxState(autoUpdateCheckBox, autoUpdateCheckBox_CheckedChanged, Settings.Default.AutoUpdate); LoadCheckboxState(usePrereleaseCheckBox, usePrereleaseCheckBox_CheckedChanged, Settings.Default.UsePrerelease); LoadCheckboxState(grf_paramKeyComboBoxCheckBox, grf_paramKeyComboBoxCheckBox_CheckedChanged, Settings.Default.UseComboBoxForGRFParameter); + LoadCheckboxState(validateSkinDimenssionCheckBox, validateSkinDimenssionCheckBox_CheckedChanged, Settings.Default.ValidateImageDimension); } private void AppBehaviorSettingsForm_FormClosing(object sender, FormClosingEventArgs e) diff --git a/PCK-Studio/Forms/Editor/CustomSkinEditor.cs b/PCK-Studio/Forms/Editor/CustomSkinEditor.cs index b3424346..12201fae 100644 --- a/PCK-Studio/Forms/Editor/CustomSkinEditor.cs +++ b/PCK-Studio/Forms/Editor/CustomSkinEditor.cs @@ -11,6 +11,7 @@ using PckStudio.Internal; using PckStudio.Extensions; using PckStudio.Internal.Skin; using PckStudio.Forms.Additional_Popups; +using PckStudio.Properties; namespace PckStudio.Forms.Editor { @@ -239,7 +240,7 @@ namespace PckStudio.Forms.Editor { var img = e.NewTexture; // Skins can only be a 1:1 ratio (base 64x64) or a 2:1 ratio (base 64x32) - if (img.Width != img.Height && img.Height != img.Width / 2) + if (Settings.Default.ValidateImageDimension && img.Width != img.Height && img.Height != img.Width / 2) { e.Cancel = true; MessageBox.Show("The selected image does not suit a skin texture.", "Invalid image dimensions.", MessageBoxButtons.OK, MessageBoxIcon.Error); diff --git a/PCK-Studio/Properties/Settings.Designer.cs b/PCK-Studio/Properties/Settings.Designer.cs index 8acf7cc9..373c6428 100644 --- a/PCK-Studio/Properties/Settings.Designer.cs +++ b/PCK-Studio/Properties/Settings.Designer.cs @@ -126,5 +126,17 @@ namespace PckStudio.Properties { this["RecentFiles"] = value; } } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("True")] + public bool ValidateImageDimension { + get { + return ((bool)(this["ValidateImageDimension"])); + } + set { + this["ValidateImageDimension"] = value; + } + } } } diff --git a/PCK-Studio/Properties/Settings.settings b/PCK-Studio/Properties/Settings.settings index 1003231b..381b0bd1 100644 --- a/PCK-Studio/Properties/Settings.settings +++ b/PCK-Studio/Properties/Settings.settings @@ -29,5 +29,8 @@ + + True + \ No newline at end of file