Rename and move addCategory form/popup

This commit is contained in:
miku-666
2023-03-13 16:58:35 +01:00
parent 9461a0a125
commit 97aee9ca6e
9 changed files with 186 additions and 184 deletions

View File

@@ -1,95 +0,0 @@
namespace PckStudio.Forms.Additional_Popups.Audio
{
partial class addCategory
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(addCategory));
this.label2 = new System.Windows.Forms.Label();
this.button1 = new System.Windows.Forms.Button();
this.comboBox1 = new System.Windows.Forms.ComboBox();
this.cancelButton = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// label2
//
resources.ApplyResources(this.label2, "label2");
this.label2.ForeColor = System.Drawing.Color.White;
this.label2.Name = "label2";
//
// button1
//
resources.ApplyResources(this.button1, "button1");
this.button1.ForeColor = System.Drawing.Color.White;
this.button1.Name = "button1";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// comboBox1
//
this.comboBox1.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.comboBox1.FormattingEnabled = true;
resources.ApplyResources(this.comboBox1, "comboBox1");
this.comboBox1.Name = "comboBox1";
//
// cancelButton
//
resources.ApplyResources(this.cancelButton, "cancelButton");
this.cancelButton.ForeColor = System.Drawing.Color.White;
this.cancelButton.Name = "cancelButton";
this.cancelButton.UseVisualStyleBackColor = true;
this.cancelButton.Click += new System.EventHandler(this.cancelButton_Click);
//
// addCategory
//
resources.ApplyResources(this, "$this");
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ControlBox = false;
this.Controls.Add(this.cancelButton);
this.Controls.Add(this.comboBox1);
this.Controls.Add(this.button1);
this.Controls.Add(this.label2);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "addCategory";
this.Resizable = false;
this.ShadowType = MetroFramework.Forms.MetroFormShadowType.DropShadow;
this.Style = MetroFramework.MetroColorStyle.Silver;
this.Theme = MetroFramework.MetroThemeStyle.Dark;
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.ComboBox comboBox1;
private System.Windows.Forms.Button cancelButton;
public System.Windows.Forms.Label label2;
public System.Windows.Forms.Button button1;
}
}

View File

@@ -1,32 +0,0 @@
using System;
using System.Windows.Forms;
// Audio Editor by MattNL
namespace PckStudio.Forms.Additional_Popups.Audio
{
public partial class addCategory : MetroFramework.Forms.MetroForm
{
private string _category = string.Empty;
public string Category => _category;
public addCategory(string[] avalibleCategories)
{
InitializeComponent();
this.FormBorderStyle = FormBorderStyle.None;
comboBox1.Items.AddRange(avalibleCategories);
}
private void button1_Click(object sender, EventArgs e)
{
_category = comboBox1.Text;
DialogResult = DialogResult.OK;
if(comboBox1.SelectedIndex > -1) Close();
}
private void cancelButton_Click(object sender, EventArgs e)
{
DialogResult = DialogResult.Cancel;
Close();
}
}
}

View File

@@ -0,0 +1,96 @@
namespace PckStudio.Forms.Additional_Popups
{
partial class ItemSelectionPopUp
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(ItemSelectionPopUp));
this.label2 = new System.Windows.Forms.Label();
this.okBtn = new System.Windows.Forms.Button();
this.cancelButton = new System.Windows.Forms.Button();
this.ComboBox = new MetroFramework.Controls.MetroComboBox();
this.SuspendLayout();
//
// label2
//
resources.ApplyResources(this.label2, "label2");
this.label2.ForeColor = System.Drawing.Color.White;
this.label2.Name = "label2";
//
// okBtn
//
resources.ApplyResources(this.okBtn, "okBtn");
this.okBtn.ForeColor = System.Drawing.Color.White;
this.okBtn.Name = "okBtn";
this.okBtn.UseVisualStyleBackColor = true;
this.okBtn.Click += new System.EventHandler(this.button1_Click);
//
// cancelButton
//
resources.ApplyResources(this.cancelButton, "cancelButton");
this.cancelButton.ForeColor = System.Drawing.Color.White;
this.cancelButton.Name = "cancelButton";
this.cancelButton.UseVisualStyleBackColor = true;
this.cancelButton.Click += new System.EventHandler(this.cancelButton_Click);
//
// ComboBox
//
this.ComboBox.FormattingEnabled = true;
resources.ApplyResources(this.ComboBox, "ComboBox");
this.ComboBox.Name = "ComboBox";
this.ComboBox.Theme = MetroFramework.MetroThemeStyle.Dark;
this.ComboBox.UseSelectable = true;
//
// ItemSelectionPopUp
//
resources.ApplyResources(this, "$this");
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ControlBox = false;
this.Controls.Add(this.ComboBox);
this.Controls.Add(this.cancelButton);
this.Controls.Add(this.okBtn);
this.Controls.Add(this.label2);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "ItemSelectionPopUp";
this.Resizable = false;
this.ShadowType = MetroFramework.Forms.MetroFormShadowType.DropShadow;
this.Style = MetroFramework.MetroColorStyle.Silver;
this.Theme = MetroFramework.MetroThemeStyle.Dark;
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.Button cancelButton;
public System.Windows.Forms.Label label2;
public System.Windows.Forms.Button okBtn;
private MetroFramework.Controls.MetroComboBox ComboBox;
}
}

View File

@@ -0,0 +1,31 @@
using System;
using System.Windows.Forms;
// Audio Editor by MattNL
namespace PckStudio.Forms.Additional_Popups
{
public partial class ItemSelectionPopUp : MetroFramework.Forms.MetroForm
{
public string SelectedItem => DialogResult == DialogResult.OK ? ComboBox.Text : string.Empty;
public ItemSelectionPopUp(string[] items)
{
InitializeComponent();
ComboBox.Items.AddRange(items);
}
private void button1_Click(object sender, EventArgs e)
{
if(ComboBox.SelectedIndex > -1)
cancelButton_Click(sender, e);
DialogResult = DialogResult.OK;
}
private void cancelButton_Click(object sender, EventArgs e)
{
DialogResult = DialogResult.Cancel;
Close();
}
}
}

View File

@@ -123,16 +123,16 @@
</data>
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<data name="label2.Location" type="System.Drawing.Point, System.Drawing">
<value>5, 41</value>
<value>15, 41</value>
</data>
<data name="label2.Size" type="System.Drawing.Size, System.Drawing">
<value>49, 13</value>
<value>35, 13</value>
</data>
<data name="label2.TabIndex" type="System.Int32, mscorlib">
<value>3</value>
</data>
<data name="label2.Text" xml:space="preserve">
<value>Category</value>
<value>Items:</value>
</data>
<data name="&gt;&gt;label2.Name" xml:space="preserve">
<value>label2</value>
@@ -147,54 +147,33 @@
<value>3</value>
</data>
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="button1.FlatStyle" type="System.Windows.Forms.FlatStyle, System.Windows.Forms">
<data name="okBtn.FlatStyle" type="System.Windows.Forms.FlatStyle, System.Windows.Forms">
<value>Flat</value>
</data>
<data name="button1.Location" type="System.Drawing.Point, System.Drawing">
<data name="okBtn.Location" type="System.Drawing.Point, System.Drawing">
<value>54, 76</value>
</data>
<data name="button1.Size" type="System.Drawing.Size, System.Drawing">
<data name="okBtn.Size" type="System.Drawing.Size, System.Drawing">
<value>75, 23</value>
</data>
<data name="button1.TabIndex" type="System.Int32, mscorlib">
<data name="okBtn.TabIndex" type="System.Int32, mscorlib">
<value>4</value>
</data>
<data name="button1.Text" xml:space="preserve">
<data name="okBtn.Text" xml:space="preserve">
<value>Add</value>
</data>
<data name="&gt;&gt;button1.Name" xml:space="preserve">
<value>button1</value>
<data name="&gt;&gt;okBtn.Name" xml:space="preserve">
<value>okBtn</value>
</data>
<data name="&gt;&gt;button1.Type" xml:space="preserve">
<data name="&gt;&gt;okBtn.Type" xml:space="preserve">
<value>System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;button1.Parent" xml:space="preserve">
<data name="&gt;&gt;okBtn.Parent" xml:space="preserve">
<value>$this</value>
</data>
<data name="&gt;&gt;button1.ZOrder" xml:space="preserve">
<data name="&gt;&gt;okBtn.ZOrder" xml:space="preserve">
<value>2</value>
</data>
<data name="comboBox1.Location" type="System.Drawing.Point, System.Drawing">
<value>60, 38</value>
</data>
<data name="comboBox1.Size" type="System.Drawing.Size, System.Drawing">
<value>192, 21</value>
</data>
<data name="comboBox1.TabIndex" type="System.Int32, mscorlib">
<value>5</value>
</data>
<data name="&gt;&gt;comboBox1.Name" xml:space="preserve">
<value>comboBox1</value>
</data>
<data name="&gt;&gt;comboBox1.Type" xml:space="preserve">
<value>System.Windows.Forms.ComboBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;comboBox1.Parent" xml:space="preserve">
<value>$this</value>
</data>
<data name="&gt;&gt;comboBox1.ZOrder" xml:space="preserve">
<value>1</value>
</data>
<data name="cancelButton.FlatStyle" type="System.Windows.Forms.FlatStyle, System.Windows.Forms">
<value>Flat</value>
</data>
@@ -223,6 +202,30 @@
<value>$this</value>
</data>
<data name="&gt;&gt;cancelButton.ZOrder" xml:space="preserve">
<value>1</value>
</data>
<data name="ComboBox.ItemHeight" type="System.Int32, mscorlib">
<value>23</value>
</data>
<data name="ComboBox.Location" type="System.Drawing.Point, System.Drawing">
<value>60, 34</value>
</data>
<data name="ComboBox.Size" type="System.Drawing.Size, System.Drawing">
<value>192, 29</value>
</data>
<data name="ComboBox.TabIndex" type="System.Int32, mscorlib">
<value>7</value>
</data>
<data name="&gt;&gt;ComboBox.Name" xml:space="preserve">
<value>ComboBox</value>
</data>
<data name="&gt;&gt;ComboBox.Type" xml:space="preserve">
<value>MetroFramework.Controls.MetroComboBox, MetroFramework, Version=1.4.0.0, Culture=neutral, PublicKeyToken=5f91a84759bf584a</value>
</data>
<data name="&gt;&gt;ComboBox.Parent" xml:space="preserve">
<value>$this</value>
</data>
<data name="&gt;&gt;ComboBox.ZOrder" xml:space="preserve">
<value>0</value>
</data>
<metadata name="$this.Localizable" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
@@ -2458,7 +2461,7 @@
<value>CenterParent</value>
</data>
<data name="&gt;&gt;$this.Name" xml:space="preserve">
<value>addCategory</value>
<value>ItemSelectionPopUp</value>
</data>
<data name="&gt;&gt;$this.Type" xml:space="preserve">
<value>MetroFramework.Forms.MetroForm, MetroFramework, Version=1.4.0.0, Culture=neutral, PublicKeyToken=5f91a84759bf584a</value>

View File

@@ -15,6 +15,7 @@ using PckStudio.Classes.IO.PCK;
using PckStudio.Forms.Additional_Popups.Audio;
using OMI.Formats.Languages;
using OMI.Formats.Pck;
using PckStudio.Forms.Additional_Popups;
// Audio Editor by MattNL
// additional work and optimization by Miku-666
@@ -129,12 +130,12 @@ namespace PckStudio.Forms.Editor
string[] available = Categories.FindAll(str => !audioFile.HasCategory(GetCategoryId(str))).ToArray();
if (available.Length > 0)
{
using addCategory add = new addCategory(available);
using ItemSelectionPopUp add = new ItemSelectionPopUp(available);
if (add.ShowDialog() == DialogResult.OK)
audioFile.AddCategory(GetCategoryId(add.Category));
audioFile.AddCategory(GetCategoryId(add.SelectedItem));
else return;
var category = audioFile.GetCategory(GetCategoryId(add.Category));
var category = audioFile.GetCategory(GetCategoryId(add.SelectedItem));
TreeNode treeNode = new TreeNode(GetCategoryFromId(category.audioType), (int)category.audioType, (int)category.audioType);
treeNode.Tag = category;
treeView1.Nodes.Add(treeNode);
@@ -557,15 +558,15 @@ namespace PckStudio.Forms.Editor
string[] available = Categories.FindAll(str => !audioFile.HasCategory(GetCategoryId(str))).ToArray();
if (available.Length > 0)
{
using addCategory add = new addCategory(available);
add.button1.Text = "Save";
using ItemSelectionPopUp add = new ItemSelectionPopUp(available);
add.okBtn.Text = "Save";
if (add.ShowDialog() != DialogResult.OK) return;
audioFile.RemoveCategory(category.audioType);
audioFile.AddCategory(category.parameterType, GetCategoryId(add.Category), category.audioType == PCKAudioFile.AudioCategory.EAudioType.Overworld && playOverworldInCreative.Checked ? "include_overworld" : "");
audioFile.AddCategory(category.parameterType, GetCategoryId(add.SelectedItem), category.audioType == PCKAudioFile.AudioCategory.EAudioType.Overworld && playOverworldInCreative.Checked ? "include_overworld" : "");
var newCategory = audioFile.GetCategory(GetCategoryId(add.Category));
var newCategory = audioFile.GetCategory(GetCategoryId(add.SelectedItem));
category.SongNames.ForEach(c => newCategory.SongNames.Add(c));

View File

@@ -4,14 +4,13 @@ using System.Drawing;
using System.IO;
using System.Linq;
using System.Windows.Forms;
using PckStudio.Classes.FileTypes;
using PckStudio.Forms.Additional_Popups.Grf;
using PckStudio.Classes.Misc;
using OMI.Formats.GameRule;
using OMI.Workers.GameRule;
using System.Diagnostics;
using PckStudio.Forms.Additional_Popups.Audio;
using OMI.Formats.Pck;
using PckStudio.Forms.Additional_Popups;
namespace PckStudio.Forms.Editor
{
@@ -28,11 +27,11 @@ namespace PckStudio.Forms.Editor
private void PromptForCompressionType()
{
addCategory dialog = new addCategory(compressionTypeComboBox.Items.Cast<string>().ToArray());
ItemSelectionPopUp dialog = new ItemSelectionPopUp(compressionTypeComboBox.Items.Cast<string>().ToArray());
dialog.label2.Text = "Type";
dialog.button1.Text = "Ok";
dialog.okBtn.Text = "Ok";
if (dialog.ShowDialog() == DialogResult.OK)
compressionTypeComboBox.SelectedIndex = compressionTypeComboBox.Items.IndexOf(dialog.Category);
compressionTypeComboBox.SelectedIndex = compressionTypeComboBox.Items.IndexOf(dialog.SelectedItem);
}
public GameRuleFileEditor(PckFile.FileData file) : this()

View File

@@ -5,6 +5,7 @@ using System.Linq;
using System.IO;
using System.Windows.Forms;
using PckStudio.Classes.Utils;
using PckStudio.Forms.Additional_Popups;
namespace PckStudio.Forms.Utilities.Skins
{
@@ -261,15 +262,13 @@ namespace PckStudio.Forms.Utilities.Skins
private void templateButton_Click(object sender, EventArgs e)
{
// Recycling the AddCategory popup to handle the ANIM templates (:
// diag.Category will be the ANIM codes
var diag = new Additional_Popups.Audio.addCategory(Templates.Keys.ToArray());
var diag = new ItemSelectionPopUp(Templates.Keys.ToArray());
diag.label2.Text = "Presets";
diag.button1.Text = "Load";
diag.okBtn.Text = "Load";
if (diag.ShowDialog() != DialogResult.OK) return;
var templateANIM = Templates[diag.Category];
var templateANIM = Templates[diag.SelectedItem];
DialogResult prompt = MessageBox.Show(this, "Would you like to add this preset's effects to your current ANIM? Otherwise all of your effects will be cleared. Either choice can be undone by pressing \"Restore ANIM\".", "", MessageBoxButtons.YesNo);
if (prompt == DialogResult.Yes) anim |= templateANIM;
else anim = templateANIM;

View File

@@ -301,11 +301,11 @@
<Compile Include="Forms\Additional-Popups\Audio\creditsEditor.Designer.cs">
<DependentUpon>creditsEditor.cs</DependentUpon>
</Compile>
<Compile Include="Forms\Additional-Popups\Audio\addCategory.cs">
<Compile Include="Forms\Additional-Popups\ItemSelectionPopUp.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Forms\Additional-Popups\Audio\addCategory.Designer.cs">
<DependentUpon>addCategory.cs</DependentUpon>
<Compile Include="Forms\Additional-Popups\ItemSelectionPopUp.Designer.cs">
<DependentUpon>ItemSelectionPopUp.cs</DependentUpon>
</Compile>
<Compile Include="Forms\Skins-And-Textures\addMeta.cs">
<SubType>Form</SubType>
@@ -521,8 +521,8 @@
<DependentUpon>creditsEditor.cs</DependentUpon>
<SubType>Designer</SubType>
</EmbeddedResource>
<EmbeddedResource Include="Forms\Additional-Popups\Audio\addCategory.resx">
<DependentUpon>addCategory.cs</DependentUpon>
<EmbeddedResource Include="Forms\Additional-Popups\ItemSelectionPopUp.resx">
<DependentUpon>ItemSelectionPopUp.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Forms\Skins-And-Textures\addMeta.ja.resx">
<DependentUpon>addMeta.cs</DependentUpon>