mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/PCK-Studio.git
synced 2026-07-13 19:08:07 +00:00
Made special conditions when editing compass and clock textures
This commit is contained in:
@@ -156,15 +156,22 @@ namespace PckStudio.Forms.Editor
|
||||
return animationData.TrimEnd(',');
|
||||
}
|
||||
|
||||
public Image BuildTexture()
|
||||
public Image BuildTexture(AnimationEditor ae)
|
||||
{
|
||||
int width = frameTextures[0].Width;
|
||||
int height = frameTextures[0].Height;
|
||||
if (width != height) throw new Exception("Invalid size");
|
||||
var img = new Bitmap(width, height * FrameTextureCount);
|
||||
|
||||
bool isClockOrCompass = ae.TileName == "clock" || ae.TileName == "compass";
|
||||
|
||||
List<Image> linearImages = new List<Image>();
|
||||
foreach (TreeNode n in ae.frameTreeView.Nodes) linearImages.Add(frameTextures[n.ImageIndex]);
|
||||
|
||||
var img = new Bitmap(width, height * (isClockOrCompass ? linearImages.Count : FrameTextureCount));
|
||||
int pos_y = 0;
|
||||
|
||||
using (var g = Graphics.FromImage(img))
|
||||
frameTextures.ForEach(texture =>
|
||||
(isClockOrCompass ? linearImages : frameTextures).ForEach(texture =>
|
||||
{
|
||||
g.DrawImage(texture, 0, pos_y);
|
||||
pos_y += height;
|
||||
@@ -244,6 +251,13 @@ namespace PckStudio.Forms.Editor
|
||||
|
||||
isItem = file.Filename.Split('/').Contains("items");
|
||||
TileName = Path.GetFileNameWithoutExtension(file.Filename);
|
||||
|
||||
InterpolationCheckbox.Visible = !(TileName == "clock" || TileName == "compass");
|
||||
InterpolationCheckbox.Checked = InterpolationCheckbox.Visible;
|
||||
bulkAnimationSpeedToolStripMenuItem.Enabled = InterpolationCheckbox.Visible;
|
||||
importJavaAnimationToolStripMenuItem.Enabled = InterpolationCheckbox.Visible;
|
||||
exportJavaAnimationToolStripMenuItem.Enabled = InterpolationCheckbox.Visible;
|
||||
|
||||
animationFile = file;
|
||||
|
||||
using MemoryStream textureMem = new MemoryStream(animationFile.Data);
|
||||
@@ -326,10 +340,10 @@ namespace PckStudio.Forms.Editor
|
||||
{
|
||||
|
||||
string anim = currentAnimation.BuildAnim();
|
||||
animationFile.Properties.SetProperty("ANIM", anim);
|
||||
animationFile.Properties.SetProperty("ANIM", TileName == "clock" || TileName == "compass" ? "" : anim);
|
||||
using (var stream = new MemoryStream())
|
||||
{
|
||||
currentAnimation.BuildTexture().Save(stream, ImageFormat.Png);
|
||||
currentAnimation.BuildTexture(this).Save(stream, ImageFormat.Png);
|
||||
animationFile.SetData(stream.ToArray());
|
||||
}
|
||||
//Reusing this for the tile path
|
||||
@@ -435,7 +449,7 @@ namespace PckStudio.Forms.Editor
|
||||
diag.SaveBtn.Text = "Add";
|
||||
if (diag.ShowDialog(this) == DialogResult.OK)
|
||||
{
|
||||
currentAnimation.AddFrame(diag.FrameTextureIndex, diag.FrameTime);
|
||||
currentAnimation.AddFrame(diag.FrameTextureIndex, TileName == "clock" || TileName == "compass" ? 1 : diag.FrameTime);
|
||||
LoadAnimationTreeView();
|
||||
}
|
||||
}
|
||||
@@ -551,6 +565,13 @@ namespace PckStudio.Forms.Editor
|
||||
Console.WriteLine(diag.SelectedTile);
|
||||
if (TileName != diag.SelectedTile) isItem = diag.IsItem;
|
||||
TileName = diag.SelectedTile;
|
||||
|
||||
InterpolationCheckbox.Visible = !(TileName == "clock" || TileName == "compass");
|
||||
InterpolationCheckbox.Checked = InterpolationCheckbox.Visible;
|
||||
bulkAnimationSpeedToolStripMenuItem.Enabled = InterpolationCheckbox.Visible;
|
||||
importJavaAnimationToolStripMenuItem.Enabled = InterpolationCheckbox.Visible;
|
||||
exportJavaAnimationToolStripMenuItem.Enabled = InterpolationCheckbox.Visible;
|
||||
|
||||
foreach (JObject content in AnimationUtil.tileData[animationSection].Children())
|
||||
{
|
||||
var first = content.Properties().FirstOrDefault(p => p.Name == TileName);
|
||||
@@ -583,7 +604,7 @@ namespace PckStudio.Forms.Editor
|
||||
mcmeta["animation"] = animation;
|
||||
File.WriteAllText(fileDialog.FileName, JsonConvert.SerializeObject(mcmeta, Formatting.Indented));
|
||||
string fn = fileDialog.FileName;
|
||||
currentAnimation.BuildTexture().Save(fn.Remove(fn.Length - 7));
|
||||
currentAnimation.BuildTexture(this).Save(fn.Remove(fn.Length - 7));
|
||||
MessageBox.Show("Your animation was successfully exported at " + fn, "Successful export");
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user