mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/PCK-Studio.git
synced 2026-06-08 18:47:34 +00:00
AnimationEditor - Refactored and moved import/export function under 'File' menu item
This commit is contained in:
125
PCK-Studio/Forms/Editor/AnimationEditor.Designer.cs
generated
125
PCK-Studio/Forms/Editor/AnimationEditor.Designer.cs
generated
@@ -38,10 +38,14 @@
|
||||
this.menuStrip = new System.Windows.Forms.MenuStrip();
|
||||
this.fileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.saveToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator();
|
||||
this.importToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.importJavaAnimationToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.importGifToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.exportAsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.exportJavaAnimationToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.editToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.bulkAnimationSpeedToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.importJavaAnimationToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.exportJavaAnimationToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.changeTileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.helpToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.howToInterpolation = new System.Windows.Forms.ToolStripMenuItem();
|
||||
@@ -51,13 +55,13 @@
|
||||
this.InterpolationCheckbox = new MetroFramework.Controls.MetroCheckBox();
|
||||
this.AnimationStartStopBtn = new MetroFramework.Controls.MetroButton();
|
||||
this.tileLabel = new MetroFramework.Controls.MetroLabel();
|
||||
this.animationPictureBox = new PckStudio.Forms.Editor.AnimationPictureBox();
|
||||
this.pictureBox1 = new System.Windows.Forms.PictureBox();
|
||||
this.importGifToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.animationPictureBox = new PckStudio.Forms.Editor.AnimationPictureBox();
|
||||
this.animationTextureToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.contextMenuStrip1.SuspendLayout();
|
||||
this.menuStrip.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.animationPictureBox)).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.animationPictureBox)).BeginInit();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// frameTreeView
|
||||
@@ -123,6 +127,7 @@
|
||||
this.helpToolStripMenuItem});
|
||||
this.menuStrip.Location = new System.Drawing.Point(20, 60);
|
||||
this.menuStrip.Name = "menuStrip";
|
||||
this.menuStrip.RenderMode = System.Windows.Forms.ToolStripRenderMode.Professional;
|
||||
this.menuStrip.Size = new System.Drawing.Size(372, 24);
|
||||
this.menuStrip.TabIndex = 14;
|
||||
this.menuStrip.Text = "menuStrip1";
|
||||
@@ -130,7 +135,10 @@
|
||||
// fileToolStripMenuItem
|
||||
//
|
||||
this.fileToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.saveToolStripMenuItem1});
|
||||
this.saveToolStripMenuItem1,
|
||||
this.toolStripSeparator1,
|
||||
this.importToolStripMenuItem,
|
||||
this.exportAsToolStripMenuItem});
|
||||
this.fileToolStripMenuItem.ForeColor = System.Drawing.Color.White;
|
||||
this.fileToolStripMenuItem.Name = "fileToolStripMenuItem";
|
||||
this.fileToolStripMenuItem.Size = new System.Drawing.Size(37, 20);
|
||||
@@ -140,18 +148,59 @@
|
||||
//
|
||||
this.saveToolStripMenuItem1.Image = ((System.Drawing.Image)(resources.GetObject("saveToolStripMenuItem1.Image")));
|
||||
this.saveToolStripMenuItem1.Name = "saveToolStripMenuItem1";
|
||||
this.saveToolStripMenuItem1.Size = new System.Drawing.Size(98, 22);
|
||||
this.saveToolStripMenuItem1.Size = new System.Drawing.Size(180, 22);
|
||||
this.saveToolStripMenuItem1.Text = "Save";
|
||||
this.saveToolStripMenuItem1.Click += new System.EventHandler(this.saveToolStripMenuItem1_Click);
|
||||
//
|
||||
// toolStripSeparator1
|
||||
//
|
||||
this.toolStripSeparator1.Name = "toolStripSeparator1";
|
||||
this.toolStripSeparator1.Size = new System.Drawing.Size(177, 6);
|
||||
//
|
||||
// importToolStripMenuItem
|
||||
//
|
||||
this.importToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.animationTextureToolStripMenuItem,
|
||||
this.importJavaAnimationToolStripMenuItem,
|
||||
this.importGifToolStripMenuItem});
|
||||
this.importToolStripMenuItem.Name = "importToolStripMenuItem";
|
||||
this.importToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
|
||||
this.importToolStripMenuItem.Text = "Import";
|
||||
//
|
||||
// importJavaAnimationToolStripMenuItem
|
||||
//
|
||||
this.importJavaAnimationToolStripMenuItem.Name = "importJavaAnimationToolStripMenuItem";
|
||||
this.importJavaAnimationToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
|
||||
this.importJavaAnimationToolStripMenuItem.Text = "Java Animation";
|
||||
this.importJavaAnimationToolStripMenuItem.Click += new System.EventHandler(this.importJavaAnimationToolStripMenuItem_Click);
|
||||
//
|
||||
// importGifToolStripMenuItem
|
||||
//
|
||||
this.importGifToolStripMenuItem.Name = "importGifToolStripMenuItem";
|
||||
this.importGifToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
|
||||
this.importGifToolStripMenuItem.Text = "Gif";
|
||||
this.importGifToolStripMenuItem.Click += new System.EventHandler(this.importGifToolStripMenuItem_Click);
|
||||
//
|
||||
// exportAsToolStripMenuItem
|
||||
//
|
||||
this.exportAsToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.exportJavaAnimationToolStripMenuItem});
|
||||
this.exportAsToolStripMenuItem.Name = "exportAsToolStripMenuItem";
|
||||
this.exportAsToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
|
||||
this.exportAsToolStripMenuItem.Text = "Export as";
|
||||
//
|
||||
// exportJavaAnimationToolStripMenuItem
|
||||
//
|
||||
this.exportJavaAnimationToolStripMenuItem.Name = "exportJavaAnimationToolStripMenuItem";
|
||||
this.exportJavaAnimationToolStripMenuItem.Size = new System.Drawing.Size(155, 22);
|
||||
this.exportJavaAnimationToolStripMenuItem.Text = "Java Animation";
|
||||
this.exportJavaAnimationToolStripMenuItem.Click += new System.EventHandler(this.exportJavaAnimationToolStripMenuItem_Click);
|
||||
//
|
||||
// editToolStripMenuItem
|
||||
//
|
||||
this.editToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.bulkAnimationSpeedToolStripMenuItem,
|
||||
this.importJavaAnimationToolStripMenuItem,
|
||||
this.exportJavaAnimationToolStripMenuItem,
|
||||
this.changeTileToolStripMenuItem,
|
||||
this.importGifToolStripMenuItem});
|
||||
this.changeTileToolStripMenuItem});
|
||||
this.editToolStripMenuItem.ForeColor = System.Drawing.Color.White;
|
||||
this.editToolStripMenuItem.Name = "editToolStripMenuItem";
|
||||
this.editToolStripMenuItem.Size = new System.Drawing.Size(46, 20);
|
||||
@@ -164,20 +213,6 @@
|
||||
this.bulkAnimationSpeedToolStripMenuItem.Text = "Set Bulk Animation Speed";
|
||||
this.bulkAnimationSpeedToolStripMenuItem.Click += new System.EventHandler(this.bulkAnimationSpeedToolStripMenuItem_Click);
|
||||
//
|
||||
// importJavaAnimationToolStripMenuItem
|
||||
//
|
||||
this.importJavaAnimationToolStripMenuItem.Name = "importJavaAnimationToolStripMenuItem";
|
||||
this.importJavaAnimationToolStripMenuItem.Size = new System.Drawing.Size(210, 22);
|
||||
this.importJavaAnimationToolStripMenuItem.Text = "Import Java Animation";
|
||||
this.importJavaAnimationToolStripMenuItem.Click += new System.EventHandler(this.importJavaAnimationToolStripMenuItem_Click);
|
||||
//
|
||||
// exportJavaAnimationToolStripMenuItem
|
||||
//
|
||||
this.exportJavaAnimationToolStripMenuItem.Name = "exportJavaAnimationToolStripMenuItem";
|
||||
this.exportJavaAnimationToolStripMenuItem.Size = new System.Drawing.Size(210, 22);
|
||||
this.exportJavaAnimationToolStripMenuItem.Text = "Export Java Animation";
|
||||
this.exportJavaAnimationToolStripMenuItem.Click += new System.EventHandler(this.exportJavaAnimationToolStripMenuItem_Click);
|
||||
//
|
||||
// changeTileToolStripMenuItem
|
||||
//
|
||||
this.changeTileToolStripMenuItem.Name = "changeTileToolStripMenuItem";
|
||||
@@ -261,6 +296,16 @@
|
||||
this.tileLabel.Text = "tileLabel";
|
||||
this.tileLabel.Theme = MetroFramework.MetroThemeStyle.Dark;
|
||||
//
|
||||
// pictureBox1
|
||||
//
|
||||
this.pictureBox1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.pictureBox1.Location = new System.Drawing.Point(154, 60);
|
||||
this.pictureBox1.Name = "pictureBox1";
|
||||
this.pictureBox1.Size = new System.Drawing.Size(238, 24);
|
||||
this.pictureBox1.TabIndex = 21;
|
||||
this.pictureBox1.TabStop = false;
|
||||
//
|
||||
// animationPictureBox
|
||||
//
|
||||
this.animationPictureBox.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||
@@ -273,22 +318,12 @@
|
||||
this.animationPictureBox.TabIndex = 16;
|
||||
this.animationPictureBox.TabStop = false;
|
||||
//
|
||||
// pictureBox1
|
||||
// animationTextureToolStripMenuItem
|
||||
//
|
||||
this.pictureBox1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.pictureBox1.Location = new System.Drawing.Point(154, 60);
|
||||
this.pictureBox1.Name = "pictureBox1";
|
||||
this.pictureBox1.Size = new System.Drawing.Size(255, 24);
|
||||
this.pictureBox1.TabIndex = 21;
|
||||
this.pictureBox1.TabStop = false;
|
||||
//
|
||||
// importGifToolStripMenuItem
|
||||
//
|
||||
this.importGifToolStripMenuItem.Name = "importGifToolStripMenuItem";
|
||||
this.importGifToolStripMenuItem.Size = new System.Drawing.Size(210, 22);
|
||||
this.importGifToolStripMenuItem.Text = "Import Gif";
|
||||
this.importGifToolStripMenuItem.Click += new System.EventHandler(this.importGifToolStripMenuItem_Click);
|
||||
this.animationTextureToolStripMenuItem.Name = "animationTextureToolStripMenuItem";
|
||||
this.animationTextureToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
|
||||
this.animationTextureToolStripMenuItem.Text = "Animation Texture";
|
||||
this.animationTextureToolStripMenuItem.Click += new System.EventHandler(this.animationTextureToolStripMenuItem_Click);
|
||||
//
|
||||
// AnimationEditor
|
||||
//
|
||||
@@ -312,8 +347,8 @@
|
||||
this.contextMenuStrip1.ResumeLayout(false);
|
||||
this.menuStrip.ResumeLayout(false);
|
||||
this.menuStrip.PerformLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.animationPictureBox)).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.animationPictureBox)).EndInit();
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
@@ -333,17 +368,21 @@
|
||||
private System.Windows.Forms.ToolStripMenuItem removeFrameToolStripMenuItem;
|
||||
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 System.Windows.Forms.ToolStripMenuItem exportJavaAnimationToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem howToInterpolation;
|
||||
private System.Windows.Forms.ToolStripMenuItem editorControlsToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem setBulkSpedToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem javaAnimationSupportToolStripMenuItem;
|
||||
private System.Windows.Forms.ImageList TextureIcons;
|
||||
private System.Windows.Forms.PictureBox pictureBox1;
|
||||
private System.Windows.Forms.ToolStripMenuItem importToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem importJavaAnimationToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem importGifToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem exportAsToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem exportJavaAnimationToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripSeparator toolStripSeparator1;
|
||||
private System.Windows.Forms.ToolStripMenuItem animationTextureToolStripMenuItem;
|
||||
}
|
||||
}
|
||||
@@ -12,18 +12,20 @@ using PckStudio.Forms.Utilities;
|
||||
using PckStudio.Extensions;
|
||||
using OMI.Formats.Pck;
|
||||
using System.Collections.Generic;
|
||||
using PckStudio.Models;
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace PckStudio.Forms.Editor
|
||||
{
|
||||
public partial class AnimationEditor : MetroForm
|
||||
{
|
||||
PckFile.FileData animationFile;
|
||||
Animation currentAnimation;
|
||||
private PckFile.FileData animationFile;
|
||||
private Animation currentAnimation;
|
||||
|
||||
bool isItem = false;
|
||||
string animationSection => AnimationResources.GetAnimationSection(isItem);
|
||||
private bool isItem = false;
|
||||
private string animationSection => AnimationResources.GetAnimationSection(isItem);
|
||||
|
||||
public string TileName = string.Empty;
|
||||
private string TileName = string.Empty;
|
||||
|
||||
private bool IsEditingSpecial => IsSpecialTile(TileName);
|
||||
|
||||
@@ -40,21 +42,24 @@ namespace PckStudio.Forms.Editor
|
||||
TileName = Path.GetFileNameWithoutExtension(file.Filename);
|
||||
|
||||
bulkAnimationSpeedToolStripMenuItem.Enabled =
|
||||
importJavaAnimationToolStripMenuItem.Enabled =
|
||||
exportJavaAnimationToolStripMenuItem.Enabled =
|
||||
importToolStripMenuItem.Enabled =
|
||||
exportAsToolStripMenuItem.Enabled =
|
||||
InterpolationCheckbox.Visible = !IsEditingSpecial;
|
||||
|
||||
animationFile = file;
|
||||
|
||||
using MemoryStream textureMem = new MemoryStream(animationFile.Data);
|
||||
var texture = new Bitmap(textureMem);
|
||||
var frameTextures = texture.CreateImageList(ImageLayoutDirection.Vertical);
|
||||
if (file.Size > 0)
|
||||
{
|
||||
using MemoryStream textureMem = new MemoryStream(animationFile.Data);
|
||||
var texture = new Bitmap(textureMem);
|
||||
var frameTextures = texture.CreateImageList(ImageLayoutDirection.Vertical);
|
||||
|
||||
currentAnimation = animationFile.Properties.HasProperty("ANIM")
|
||||
? new Animation(frameTextures, animationFile.Properties.GetPropertyValue("ANIM"))
|
||||
: new Animation(frameTextures);
|
||||
currentAnimation = animationFile.Properties.HasProperty("ANIM")
|
||||
? new Animation(frameTextures, animationFile.Properties.GetPropertyValue("ANIM"))
|
||||
: new Animation(frameTextures);
|
||||
}
|
||||
|
||||
foreach (JObject content in AnimationResources.tileData[animationSection].Children())
|
||||
foreach (JObject content in AnimationResources.JsonTileData[animationSection].Children())
|
||||
{
|
||||
var prop = content.Properties().FirstOrDefault(prop => prop.Name == TileName);
|
||||
if (prop is JProperty)
|
||||
@@ -65,12 +70,17 @@ namespace PckStudio.Forms.Editor
|
||||
}
|
||||
LoadAnimationTreeView();
|
||||
}
|
||||
|
||||
private void LoadAnimationTreeView()
|
||||
|
||||
private void LoadAnimationTreeView()
|
||||
{
|
||||
InterpolationCheckbox.Checked = currentAnimation.Interpolate;
|
||||
if (currentAnimation is null)
|
||||
{
|
||||
AnimationStartStopBtn.Enabled = false;
|
||||
return;
|
||||
}
|
||||
AnimationStartStopBtn.Enabled = true;
|
||||
InterpolationCheckbox.Checked = currentAnimation.Interpolate;
|
||||
frameTreeView.Nodes.Clear();
|
||||
// $"Frame: {i}, Frame Time: {Animation.MinimumFrameTime}"
|
||||
TextureIcons.Images.Clear();
|
||||
TextureIcons.Images.AddRange(currentAnimation.GetTextures().ToArray());
|
||||
foreach (var frame in currentAnimation.GetFrames())
|
||||
@@ -125,7 +135,7 @@ namespace PckStudio.Forms.Editor
|
||||
|
||||
private void saveToolStripMenuItem1_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (!IsEditingSpecial)
|
||||
if (!IsEditingSpecial && currentAnimation is not null)
|
||||
{
|
||||
string anim = currentAnimation.BuildAnim();
|
||||
animationFile.Properties.SetProperty("ANIM", anim);
|
||||
@@ -135,10 +145,11 @@ namespace PckStudio.Forms.Editor
|
||||
texture.Save(stream, ImageFormat.Png);
|
||||
animationFile.SetData(stream.ToArray());
|
||||
}
|
||||
//Reusing this for the tile path
|
||||
TileName = "res/textures/" + (isItem ? "items/" : "blocks/") + TileName + ".png" ;
|
||||
animationFile.Filename = "res/textures/" + (isItem ? "items/" : "blocks/") + TileName + ".png" ;
|
||||
DialogResult = DialogResult.OK;
|
||||
return;
|
||||
}
|
||||
DialogResult = DialogResult.OK;
|
||||
DialogResult = DialogResult.Cancel;
|
||||
}
|
||||
|
||||
// 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
|
||||
@@ -272,14 +283,15 @@ namespace PckStudio.Forms.Editor
|
||||
DialogResult query = MessageBox.Show("This feature will replace the existing animation data. It might fail if the selected animation script is invalid. Are you sure that you want to continue?", "Warning", MessageBoxButtons.YesNo);
|
||||
if (query == DialogResult.No) return;
|
||||
|
||||
OpenFileDialog fileDialog = new OpenFileDialog();
|
||||
fileDialog.Title = "Please select a valid Minecaft: Java Edition animation script";
|
||||
|
||||
// It's marked as .png.mcmeta just in case
|
||||
// some weirdo tries to pass a pack.mcmeta or something
|
||||
// -MattNL
|
||||
fileDialog.Filter = "Animation Scripts (*.mcmeta)|*.png.mcmeta";
|
||||
if (fileDialog.ShowDialog(this) != DialogResult.OK) return;
|
||||
OpenFileDialog fileDialog = new OpenFileDialog
|
||||
{
|
||||
Title = "Please select a valid Minecaft: Java Edition animation script",
|
||||
// It's marked as .png.mcmeta just in case
|
||||
// some weirdo tries to pass a pack.mcmeta or something
|
||||
// -MattNL
|
||||
Filter = "Animation Scripts (*.mcmeta)|*.png.mcmeta"
|
||||
};
|
||||
if (fileDialog.ShowDialog(this) != DialogResult.OK) return;
|
||||
Console.WriteLine("Selected Animation Script: " + fileDialog.FileName);
|
||||
|
||||
string textureFile = fileDialog.FileName.Substring(0, fileDialog.FileName.Length - ".mcmeta".Length);
|
||||
@@ -343,28 +355,32 @@ namespace PckStudio.Forms.Editor
|
||||
|
||||
private void changeTileToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
using (ChangeTile diag = new ChangeTile())
|
||||
using (ChangeTile diag = new ChangeTile())
|
||||
if (diag.ShowDialog(this) == DialogResult.OK)
|
||||
{
|
||||
Console.WriteLine(diag.SelectedTile);
|
||||
if (TileName != diag.SelectedTile) isItem = diag.IsItem;
|
||||
TileName = diag.SelectedTile;
|
||||
|
||||
InterpolationCheckbox.Checked =
|
||||
bulkAnimationSpeedToolStripMenuItem.Enabled =
|
||||
importJavaAnimationToolStripMenuItem.Enabled =
|
||||
exportJavaAnimationToolStripMenuItem.Enabled =
|
||||
importToolStripMenuItem.Enabled =
|
||||
exportAsToolStripMenuItem.Enabled =
|
||||
InterpolationCheckbox.Visible = !IsEditingSpecial;
|
||||
|
||||
foreach (JObject content in AnimationResources.tileData[animationSection].Children())
|
||||
{
|
||||
var first = content.Properties().FirstOrDefault(p => p.Name == TileName);
|
||||
if (first is JProperty p) tileLabel.Text = (string)p.Value;
|
||||
}
|
||||
SetTileLabel();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void exportJavaAnimationToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
private void SetTileLabel()
|
||||
{
|
||||
foreach (JObject content in AnimationResources.JsonTileData[animationSection].Children())
|
||||
{
|
||||
var first = content.Properties().FirstOrDefault(p => p.Name == TileName);
|
||||
if (first is JProperty p) tileLabel.Text = (string)p.Value;
|
||||
}
|
||||
}
|
||||
|
||||
private void exportJavaAnimationToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
SaveFileDialog fileDialog = new SaveFileDialog();
|
||||
fileDialog.Title = "Please choose where you want to save your new animation";
|
||||
@@ -383,7 +399,7 @@ namespace PckStudio.Forms.Editor
|
||||
|
||||
private void howToInterpolation_Click(object sender, EventArgs e)
|
||||
{
|
||||
MessageBox.Show("The Interpolation effect is when the animtion smoothly translates between the frames instead of simply displaying the next one. This can be seen with some vanilla Minecraft textures such as Magma and Prismarine.\n\nThe \"Interpolates\" checkbox at the bottom controls this.", "Interpolation");
|
||||
MessageBox.Show("The Interpolation effect is when the animtion smoothly translates between the frames instead of simply displaying the next one. This can be seen with some vanilla Minecraft textures such as Magma and Prismarine.\n\nThe \"Interpolates\" checkbox above the animation controls this.", "Interpolation");
|
||||
}
|
||||
|
||||
private void editorControlsToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
@@ -406,7 +422,8 @@ namespace PckStudio.Forms.Editor
|
||||
private void InterpolationCheckbox_CheckedChanged(object sender, EventArgs e)
|
||||
{
|
||||
// Interpolation flag wasn't being updated when the check box changed, this fixes the issue
|
||||
currentAnimation.Interpolate = InterpolationCheckbox.Checked;
|
||||
if (currentAnimation is not null)
|
||||
currentAnimation.Interpolate = InterpolationCheckbox.Checked;
|
||||
}
|
||||
|
||||
private void AnimationEditor_FormClosing(object sender, FormClosingEventArgs e)
|
||||
@@ -421,7 +438,7 @@ namespace PckStudio.Forms.Editor
|
||||
{
|
||||
OpenFileDialog fileDialog = new OpenFileDialog()
|
||||
{
|
||||
Filter = "GIF|*.gif"
|
||||
Filter = "GIF file|*.gif"
|
||||
};
|
||||
if (fileDialog.ShowDialog(this) != DialogResult.OK)
|
||||
return;
|
||||
@@ -433,7 +450,6 @@ namespace PckStudio.Forms.Editor
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
FrameDimension dimension = new FrameDimension(gif.FrameDimensionsList[0]);
|
||||
int frameCount = gif.GetFrameCount(dimension);
|
||||
|
||||
@@ -447,5 +463,20 @@ namespace PckStudio.Forms.Editor
|
||||
currentAnimation = new Animation(textures);
|
||||
LoadAnimationTreeView();
|
||||
}
|
||||
|
||||
private void animationTextureToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
using var ofd = new OpenFileDialog()
|
||||
{
|
||||
Filter = "PNG Files | *.png",
|
||||
Title = "Select a PNG File",
|
||||
};
|
||||
if (ofd.ShowDialog() != DialogResult.OK)
|
||||
return;
|
||||
Image img = Image.FromFile(ofd.FileName);
|
||||
var textures = img.CreateImageList(ImageLayoutDirection.Vertical);
|
||||
currentAnimation = new Animation(textures);
|
||||
LoadAnimationTreeView();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -356,6 +356,9 @@ namespace PckStudio
|
||||
|
||||
private void HandleTextureFile(PckFile.FileData file)
|
||||
{
|
||||
if (!(file.Filename.StartsWith("res/textures/blocks/") || file.Filename.StartsWith("res/textures/items/")))
|
||||
return;
|
||||
|
||||
if (IsFilePathMipMapped(file.Filename) &&
|
||||
currentPCK.Files.Find(pckfile =>
|
||||
// todo write cleaner ?
|
||||
@@ -367,13 +370,11 @@ namespace PckStudio
|
||||
file = originalAnimationFile;
|
||||
}
|
||||
|
||||
if (!(file.Filename.StartsWith("res/textures/blocks/") || file.Filename.StartsWith("res/textures/items/"))) return;
|
||||
|
||||
using (AnimationEditor animationEditor = new AnimationEditor(file))
|
||||
{
|
||||
if (animationEditor.ShowDialog(this) == DialogResult.OK)
|
||||
{
|
||||
file.Filename = animationEditor.TileName;
|
||||
wasModified = true;
|
||||
BuildMainTreeView();
|
||||
}
|
||||
}
|
||||
@@ -873,37 +874,21 @@ namespace PckStudio
|
||||
|
||||
private void createAnimatedTextureToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
using var ofd = new OpenFileDialog()
|
||||
{
|
||||
Filter = "PNG Files | *.png",
|
||||
Title = "Select a PNG File",
|
||||
};
|
||||
if (ofd.ShowDialog() != DialogResult.OK)
|
||||
return;
|
||||
|
||||
using ChangeTile diag = new ChangeTile();
|
||||
if (diag.ShowDialog(this) != DialogResult.OK)
|
||||
return;
|
||||
|
||||
using Image img = new Bitmap(ofd.FileName);
|
||||
var file = currentPCK.CreateNewFile(
|
||||
var file = new PckFile.FileData(
|
||||
$"res/textures/{AnimationResources.GetAnimationSection(diag.IsItem)}/{diag.SelectedTile}.png",
|
||||
PckFile.FileData.FileType.TextureFile,
|
||||
() =>
|
||||
{
|
||||
using var stream = new MemoryStream();
|
||||
img.Save(stream, ImageFormat.Png);
|
||||
return stream.ToArray();
|
||||
});
|
||||
file.Properties.Add(("ANIM", string.Empty));
|
||||
PckFile.FileData.FileType.TextureFile);
|
||||
|
||||
using AnimationEditor animationEditor = new AnimationEditor(file);
|
||||
if (animationEditor.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
file.Filename = animationEditor.TileName;
|
||||
ReloadMetaTreeView();
|
||||
BuildMainTreeView();
|
||||
wasModified = true;
|
||||
currentPCK.Files.Add(file);
|
||||
BuildMainTreeView();
|
||||
ReloadMetaTreeView();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user