Update AudioEditor Component names

This commit is contained in:
miku-666
2022-06-11 07:40:05 +02:00
parent 5d19d32f9e
commit db7a9cd072
3 changed files with 2610 additions and 121 deletions

View File

@@ -42,18 +42,18 @@
this.importJavaAnimationToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.changeTileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.helpToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.metroCheckBox1 = new MetroFramework.Controls.MetroCheckBox();
this.metroButton1 = new MetroFramework.Controls.MetroButton();
this.InterpolationCheckbox = new MetroFramework.Controls.MetroCheckBox();
this.AnimationPlayBtn = new MetroFramework.Controls.MetroButton();
this.timer1 = new System.Windows.Forms.Timer(this.components);
this.metroButton2 = new MetroFramework.Controls.MetroButton();
this.AnimationStopBtn = new MetroFramework.Controls.MetroButton();
this.tileLabel = new MetroFramework.Controls.MetroLabel();
this.metroCheckBox2 = new MetroFramework.Controls.MetroCheckBox();
this.MipMapCheckbox = new MetroFramework.Controls.MetroCheckBox();
this.metroLabel1 = new MetroFramework.Controls.MetroLabel();
this.numericUpDown1 = new System.Windows.Forms.NumericUpDown();
this.MipMapNumericUpDown = new System.Windows.Forms.NumericUpDown();
this.pictureBoxWithInterpolationMode1 = new PckStudio.PictureBoxWithInterpolationMode();
this.contextMenuStrip1.SuspendLayout();
this.menuStrip.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.MipMapNumericUpDown)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.pictureBoxWithInterpolationMode1)).BeginInit();
this.SuspendLayout();
//
@@ -176,47 +176,47 @@
this.helpToolStripMenuItem.Text = "Help";
this.helpToolStripMenuItem.Click += new System.EventHandler(this.helpToolStripMenuItem_Click);
//
// metroCheckBox1
// InterpolationCheckbox
//
this.metroCheckBox1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.metroCheckBox1.AutoSize = true;
this.metroCheckBox1.Location = new System.Drawing.Point(188, 317);
this.metroCheckBox1.Name = "metroCheckBox1";
this.metroCheckBox1.Size = new System.Drawing.Size(204, 15);
this.metroCheckBox1.TabIndex = 17;
this.metroCheckBox1.Text = "Interpolates (not simulated above)";
this.metroCheckBox1.Theme = MetroFramework.MetroThemeStyle.Dark;
this.metroCheckBox1.UseSelectable = true;
this.InterpolationCheckbox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.InterpolationCheckbox.AutoSize = true;
this.InterpolationCheckbox.Location = new System.Drawing.Point(188, 317);
this.InterpolationCheckbox.Name = "InterpolationCheckbox";
this.InterpolationCheckbox.Size = new System.Drawing.Size(204, 15);
this.InterpolationCheckbox.TabIndex = 17;
this.InterpolationCheckbox.Text = "Interpolates (not simulated above)";
this.InterpolationCheckbox.Theme = MetroFramework.MetroThemeStyle.Dark;
this.InterpolationCheckbox.UseSelectable = true;
//
// metroButton1
// AnimationPlayBtn
//
this.metroButton1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.metroButton1.Location = new System.Drawing.Point(188, 291);
this.metroButton1.Name = "metroButton1";
this.metroButton1.Size = new System.Drawing.Size(99, 24);
this.metroButton1.TabIndex = 18;
this.metroButton1.Text = "Play Animation";
this.metroButton1.Theme = MetroFramework.MetroThemeStyle.Dark;
this.metroButton1.UseSelectable = true;
this.metroButton1.Click += new System.EventHandler(this.metroButton1_Click);
this.AnimationPlayBtn.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.AnimationPlayBtn.Location = new System.Drawing.Point(188, 291);
this.AnimationPlayBtn.Name = "AnimationPlayBtn";
this.AnimationPlayBtn.Size = new System.Drawing.Size(99, 24);
this.AnimationPlayBtn.TabIndex = 18;
this.AnimationPlayBtn.Text = "Play Animation";
this.AnimationPlayBtn.Theme = MetroFramework.MetroThemeStyle.Dark;
this.AnimationPlayBtn.UseSelectable = true;
this.AnimationPlayBtn.Click += new System.EventHandler(this.metroButton1_Click);
//
// timer1
//
this.timer1.Interval = 1;
this.timer1.Tick += new System.EventHandler(this.animate);
//
// metroButton2
// AnimationStopBtn
//
this.metroButton2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.metroButton2.Enabled = false;
this.metroButton2.Location = new System.Drawing.Point(293, 291);
this.metroButton2.Name = "metroButton2";
this.metroButton2.Size = new System.Drawing.Size(99, 24);
this.metroButton2.TabIndex = 19;
this.metroButton2.Text = "Stop Animation";
this.metroButton2.Theme = MetroFramework.MetroThemeStyle.Dark;
this.metroButton2.UseSelectable = true;
this.metroButton2.Click += new System.EventHandler(this.metroButton2_Click);
this.AnimationStopBtn.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.AnimationStopBtn.Enabled = false;
this.AnimationStopBtn.Location = new System.Drawing.Point(293, 291);
this.AnimationStopBtn.Name = "AnimationStopBtn";
this.AnimationStopBtn.Size = new System.Drawing.Size(99, 24);
this.AnimationStopBtn.TabIndex = 19;
this.AnimationStopBtn.Text = "Stop Animation";
this.AnimationStopBtn.Theme = MetroFramework.MetroThemeStyle.Dark;
this.AnimationStopBtn.UseSelectable = true;
this.AnimationStopBtn.Click += new System.EventHandler(this.metroButton2_Click);
//
// tileLabel
//
@@ -230,18 +230,18 @@
this.tileLabel.Text = "tileLabel";
this.tileLabel.Theme = MetroFramework.MetroThemeStyle.Dark;
//
// metroCheckBox2
// MipMapCheckbox
//
this.metroCheckBox2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.metroCheckBox2.AutoSize = true;
this.metroCheckBox2.Location = new System.Drawing.Point(20, 312);
this.metroCheckBox2.Name = "metroCheckBox2";
this.metroCheckBox2.Size = new System.Drawing.Size(128, 15);
this.metroCheckBox2.TabIndex = 21;
this.metroCheckBox2.Text = "Is Mip Map Texture?";
this.metroCheckBox2.Theme = MetroFramework.MetroThemeStyle.Dark;
this.metroCheckBox2.UseSelectable = true;
this.metroCheckBox2.CheckedChanged += new System.EventHandler(this.metroCheckBox2_CheckedChanged);
this.MipMapCheckbox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.MipMapCheckbox.AutoSize = true;
this.MipMapCheckbox.Location = new System.Drawing.Point(20, 312);
this.MipMapCheckbox.Name = "MipMapCheckbox";
this.MipMapCheckbox.Size = new System.Drawing.Size(128, 15);
this.MipMapCheckbox.TabIndex = 21;
this.MipMapCheckbox.Text = "Is Mip Map Texture?";
this.MipMapCheckbox.Theme = MetroFramework.MetroThemeStyle.Dark;
this.MipMapCheckbox.UseSelectable = true;
this.MipMapCheckbox.CheckedChanged += new System.EventHandler(this.metroCheckBox2_CheckedChanged);
//
// metroLabel1
//
@@ -255,31 +255,31 @@
this.metroLabel1.Theme = MetroFramework.MetroThemeStyle.Dark;
this.metroLabel1.Visible = false;
//
// numericUpDown1
// MipMapNumericUpDown
//
this.numericUpDown1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.numericUpDown1.BackColor = System.Drawing.Color.Black;
this.numericUpDown1.ForeColor = System.Drawing.SystemColors.Window;
this.numericUpDown1.Location = new System.Drawing.Point(127, 330);
this.numericUpDown1.Maximum = new decimal(new int[] {
this.MipMapNumericUpDown.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.MipMapNumericUpDown.BackColor = System.Drawing.Color.Black;
this.MipMapNumericUpDown.ForeColor = System.Drawing.SystemColors.Window;
this.MipMapNumericUpDown.Location = new System.Drawing.Point(127, 330);
this.MipMapNumericUpDown.Maximum = new decimal(new int[] {
3,
0,
0,
0});
this.numericUpDown1.Minimum = new decimal(new int[] {
this.MipMapNumericUpDown.Minimum = new decimal(new int[] {
2,
0,
0,
0});
this.numericUpDown1.Name = "numericUpDown1";
this.numericUpDown1.Size = new System.Drawing.Size(44, 20);
this.numericUpDown1.TabIndex = 23;
this.numericUpDown1.Value = new decimal(new int[] {
this.MipMapNumericUpDown.Name = "MipMapNumericUpDown";
this.MipMapNumericUpDown.Size = new System.Drawing.Size(44, 20);
this.MipMapNumericUpDown.TabIndex = 23;
this.MipMapNumericUpDown.Value = new decimal(new int[] {
2,
0,
0,
0});
this.numericUpDown1.Visible = false;
this.MipMapNumericUpDown.Visible = false;
//
// pictureBoxWithInterpolationMode1
//
@@ -299,16 +299,17 @@
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(412, 362);
this.Controls.Add(this.metroButton2);
this.Controls.Add(this.metroButton1);
this.Controls.Add(this.numericUpDown1);
this.Controls.Add(this.AnimationStopBtn);
this.Controls.Add(this.AnimationPlayBtn);
this.Controls.Add(this.MipMapNumericUpDown);
this.Controls.Add(this.metroLabel1);
this.Controls.Add(this.metroCheckBox2);
this.Controls.Add(this.MipMapCheckbox);
this.Controls.Add(this.tileLabel);
this.Controls.Add(this.metroCheckBox1);
this.Controls.Add(this.InterpolationCheckbox);
this.Controls.Add(this.pictureBoxWithInterpolationMode1);
this.Controls.Add(this.treeView1);
this.Controls.Add(this.menuStrip);
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.Name = "AnimationEditor";
this.Style = MetroFramework.MetroColorStyle.Silver;
this.Text = "Animation Editor";
@@ -316,7 +317,7 @@
this.contextMenuStrip1.ResumeLayout(false);
this.menuStrip.ResumeLayout(false);
this.menuStrip.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.MipMapNumericUpDown)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.pictureBoxWithInterpolationMode1)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();
@@ -330,21 +331,21 @@
private System.Windows.Forms.ToolStripMenuItem fileToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem saveToolStripMenuItem1;
private PictureBoxWithInterpolationMode pictureBoxWithInterpolationMode1;
private MetroFramework.Controls.MetroCheckBox metroCheckBox1;
private MetroFramework.Controls.MetroButton metroButton1;
private MetroFramework.Controls.MetroCheckBox InterpolationCheckbox;
private MetroFramework.Controls.MetroButton AnimationPlayBtn;
private System.Windows.Forms.ContextMenuStrip contextMenuStrip1;
private System.Windows.Forms.ToolStripMenuItem addFrameToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem removeFrameToolStripMenuItem;
private System.Windows.Forms.Timer timer1;
private MetroFramework.Controls.MetroButton metroButton2;
private MetroFramework.Controls.MetroButton AnimationStopBtn;
private System.Windows.Forms.ToolStripMenuItem editToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem bulkAnimationSpeedToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem importJavaAnimationToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem helpToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem changeTileToolStripMenuItem;
private MetroFramework.Controls.MetroLabel tileLabel;
private MetroFramework.Controls.MetroCheckBox metroCheckBox2;
private MetroFramework.Controls.MetroCheckBox MipMapCheckbox;
private MetroFramework.Controls.MetroLabel metroLabel1;
private System.Windows.Forms.NumericUpDown numericUpDown1;
private System.Windows.Forms.NumericUpDown MipMapNumericUpDown;
}
}

View File

@@ -29,13 +29,13 @@ namespace PckStudio
{
Tuple<string, string> frameData = e.Node.Tag as Tuple<string, string>;
Console.WriteLine(frameData.Item1 + " --- " + frameData.Item2);
if (metroButton1.Enabled)
if (AnimationPlayBtn.Enabled)
{
pictureBoxWithInterpolationMode1.Image = frames[Int16.Parse(frameData.Item1)];
pictureBoxWithInterpolationMode1.Image = frames[short.Parse(frameData.Item1)];
}
}
public AnimationEditor(TreeView treeViewIn, String createdFileName = "")
public AnimationEditor(TreeView treeViewIn, string createdFileName = "")
{
InitializeComponent();
treeViewMain = treeViewIn;
@@ -48,8 +48,8 @@ namespace PckStudio
{
string mipMapLvl = newTileName.Last().ToString();
newTileName = newTileName.Substring(0, newTileName.Length - 12);
metroCheckBox2.Checked = true;
numericUpDown1.Value = Int16.Parse(mipMapLvl);
MipMapCheckbox.Checked = true;
MipMapNumericUpDown.Value = short.Parse(mipMapLvl);
}
}
else
@@ -63,7 +63,7 @@ namespace PckStudio
diag.ShowDialog(this);
Console.WriteLine(diag.SelectedTile);
newTileName = diag.SelectedTile;
if (newTileName == "") this.Close();
if (newTileName == "") Close();
isItem = diag.IsItem;
diag.Dispose();
}
@@ -71,10 +71,10 @@ namespace PckStudio
List<string> strEntries = new List<string>();
List<string> strEntryData = new List<string>();
bool has_anim_tag = false;
string anim_data = string.Empty;
foreach (var entry in mf.properties)
{
if (entry.Item1 == "ANIM") has_anim_tag = true;
if (entry.Item1 == "ANIM") anim_data = entry.Item2;
strEntries.Add(entry.Item2);
strEntryData.Add(entry.Item2);
}
@@ -97,24 +97,17 @@ namespace PckStudio
if (strEntries.Find(entry => entry == "ANIM") == null) anim = "";
else anim = strEntryData[strEntries.FindIndex(entry => entry == "ANIM")];
Console.WriteLine("ANIMATION DATA: " + anim);
if (anim.StartsWith("#"))
if (InterpolationCheckbox.Checked = anim.StartsWith("#"))
{
Console.WriteLine("Interpolate: true");
metroCheckBox1.Checked = true;
anim = anim.Remove(0, 1);
}
else
{
Console.WriteLine("Interpolate: false");
metroCheckBox1.Checked = false;
}
frameCount = texture.Height / texture.Width;
if (!String.IsNullOrEmpty(anim))
if (!string.IsNullOrEmpty(anim))
{
string[] animData = anim.Split(new char[] { ',' });
if (String.IsNullOrEmpty(animData.Last())) animData = animData.Take(animData.Length - 1).ToArray();
string[] animData = anim.Split(',');
if (string.IsNullOrEmpty(animData.Last())) animData = animData.Take(animData.Length - 1).ToArray();
foreach (string frame in animData)
{
string[] frameData = frame.Split(new char[] { '*' });
@@ -129,7 +122,7 @@ namespace PckStudio
if (i == 0)
{
outData = data;
if (String.IsNullOrEmpty(data)) throw new System.Exception("Invalid animation data");
if (string.IsNullOrEmpty(data)) throw new Exception("Invalid animation data");
label = "Frame: ";
currentFrame = outData;
}
@@ -140,7 +133,7 @@ namespace PckStudio
// frame time parameter for certain frames. This will detect that and place the last frame time in its place.
// This is accurate to console edition behavior.
// - MattNL
if (String.IsNullOrEmpty(data)) outData = lastFrameTime;
if (string.IsNullOrEmpty(data)) outData = lastFrameTime;
label = ", Frame Time: ";
currentFrameTime = outData;
}
@@ -220,9 +213,9 @@ namespace PckStudio
timer1.Interval = Int16.Parse(currentFrameData.Item2) * 50;
animCurrentFrame++;
if (metroCheckBox1.Checked)
if (InterpolationCheckbox.Checked)
{
img = frames[Int16.Parse(currentFrameData.Item1)];
img = frames[short.Parse(currentFrameData.Item1)];
nextFrame = animCurrentFrame + 1;
if (nextFrame > frameCount - 1) nextFrame = 0;
Console.WriteLine(nextFrame);
@@ -311,15 +304,15 @@ namespace PckStudio
//animCurrentFrameTime = 0;
//animCurrentTotalFrameTime = -1;
//frameCounter = 0;
metroButton1.Enabled = false;
metroButton2.Enabled = true;
AnimationPlayBtn.Enabled = false;
AnimationStopBtn.Enabled = true;
timer1.Start();
}
private void metroButton2_Click(object sender, EventArgs e)
{
metroButton1.Enabled = true;
metroButton2.Enabled = false;
AnimationPlayBtn.Enabled = true;
AnimationStopBtn.Enabled = false;
timer1.Stop();
}
@@ -333,14 +326,7 @@ namespace PckStudio
foreach (TreeNode node in treeNode.Nodes)
{
if (node.Text.ToLower() == name.ToLower()) return node;
else
{
TreeNode nodeChild = FindNodeByName(node, name);
if (nodeChild != null)
{
return nodeChild;
}
}
return FindNodeByName(node, name);
}
return null;
}
@@ -350,11 +336,7 @@ namespace PckStudio
foreach (TreeNode node in treeView.Nodes)
{
if (node.Text.ToLower() == name.ToLower()) return node;
else
{
TreeNode nodeChild = FindNodeByName(node, name);
if (nodeChild != null) return nodeChild;
}
return FindNodeByName(node, name);
}
return null;
}
@@ -407,21 +389,21 @@ namespace PckStudio
private void saveToolStripMenuItem1_Click(object sender, EventArgs e)
{
using (MemoryStream m = new MemoryStream())
using (var stream = new MemoryStream())
{
texture.Save(m, texture.RawFormat);
mf.SetData(m.ToArray());
texture.Save(stream, texture.RawFormat);
mf.SetData(stream.ToArray());
}
if (metroCheckBox2.Checked)
if (MipMapCheckbox.Checked)
{
newTileName += (string)("MipMapLevel" + numericUpDown1.Value.ToString());
newTileName += "MipMapLevel" + MipMapNumericUpDown.Value.ToString();
}
if (!create && treeViewMain.SelectedNode.Tag != null) treeViewMain.SelectedNode.Text = newTileName + ".png";
string animationData = "";
if (metroCheckBox1.Checked) animationData += "#"; // does the animation interpolate?
if (InterpolationCheckbox.Checked) animationData += "#"; // does the animation interpolate?
foreach (TreeNode node in treeView1.Nodes)
{
Tuple<string, string> frameData = node.Tag as Tuple<string, string>;
@@ -471,7 +453,7 @@ namespace PckStudio
addNodeToAnimationsFolder(newNode);
}
if(metroCheckBox2.Checked) newTileName = newTileName.Substring(0, newTileName.Length - 12);
if(MipMapCheckbox.Checked) newTileName = newTileName.Substring(0, newTileName.Length - 12);
}
// Most of the code below is modified code from this link: https://docs.microsoft.com/en-us/dotnet/api/system.windows.forms.treeview.itemdrag?view=windowsdesktop-6.0
@@ -647,7 +629,7 @@ namespace PckStudio
if (mcmeta["animation"]["frametime"] != null &&
mcmeta["animation"]["frametime"].Type == JTokenType.Integer) frameTime = (int)mcmeta["animation"]["frametime"];
if (mcmeta["animation"]["interpolate"] != null &&
mcmeta["animation"]["interpolate"].Type == JTokenType.Boolean && (Boolean)mcmeta["animation"]["interpolate"] == true) metroCheckBox1.Checked = true;
mcmeta["animation"]["interpolate"].Type == JTokenType.Boolean && (Boolean)mcmeta["animation"]["interpolate"] == true) InterpolationCheckbox.Checked = true;
if (mcmeta["animation"]["frames"] != null &&
mcmeta["animation"]["frames"].Type == JTokenType.Array)
{
@@ -735,8 +717,8 @@ namespace PckStudio
private void metroCheckBox2_CheckedChanged(object sender, EventArgs e)
{
metroLabel1.Visible = metroCheckBox2.Checked;
numericUpDown1.Visible = metroCheckBox2.Checked;
metroLabel1.Visible = MipMapCheckbox.Checked;
MipMapNumericUpDown.Visible = MipMapCheckbox.Checked;
}
}
}