From 989c16dcec984cafabc34a4a4b42d77c1b22376c Mon Sep 17 00:00:00 2001 From: MattNL Date: Wed, 24 Aug 2022 19:20:09 -0400 Subject: [PATCH] Restored ChangeTile functionality --- PCK-Studio/Forms/Editor/AnimationEditor.cs | 4 ++- PCK-Studio/MainForm.cs | 34 +++++++++++++++------- 2 files changed, 26 insertions(+), 12 deletions(-) diff --git a/PCK-Studio/Forms/Editor/AnimationEditor.cs b/PCK-Studio/Forms/Editor/AnimationEditor.cs index 0035d666..92f1ebfe 100644 --- a/PCK-Studio/Forms/Editor/AnimationEditor.cs +++ b/PCK-Studio/Forms/Editor/AnimationEditor.cs @@ -27,7 +27,7 @@ namespace PckStudio.Forms.Editor bool isItem = false; string animationSection => AnimationUtil.GetAnimationSection(isItem); - string TileName = string.Empty; + public string TileName = string.Empty; //int frameCounter = 0; // ported directly from Java Edition code -MattNL @@ -383,6 +383,8 @@ namespace PckStudio.Forms.Editor currentAnimation.BuildTexture().Save(stream, ImageFormat.Png); animationFile.SetData(stream.ToArray()); } + //Reusing this for the tile path + TileName = "res/textures/" + (isItem ? "items/" : "blocks/") + TileName + ".png" ; DialogResult = DialogResult.OK; } diff --git a/PCK-Studio/MainForm.cs b/PCK-Studio/MainForm.cs index 42d5c5bf..c06287e8 100644 --- a/PCK-Studio/MainForm.cs +++ b/PCK-Studio/MainForm.cs @@ -536,21 +536,22 @@ namespace PckStudio if (ofd.ShowDialog() == DialogResult.OK) { using ChangeTile diag = new ChangeTile(); - if (diag.ShowDialog(this) == DialogResult.OK) - { + if (diag.ShowDialog(this) == DialogResult.OK) + { using Image img = new Bitmap(ofd.FileName); var file = AnimationUtil.CreateNewAnimationFile(img, diag.SelectedTile, diag.IsItem); using AnimationEditor animationEditor = new AnimationEditor(file); - if (animationEditor.ShowDialog() == DialogResult.OK) - { + if (animationEditor.ShowDialog() == DialogResult.OK) + { + file.filepath = animationEditor.TileName; currentPCK.Files.Add(file); ReloadMetaTreeView(); BuildMainTreeView(); - saved = false; - } - } - } + saved = false; + } } + } + } } private void treeViewMain_DoubleClick(object sender, EventArgs e) @@ -584,10 +585,15 @@ namespace PckStudio case 2 when file.filepath.StartsWith("res/textures/blocks/") || file.filepath.StartsWith("res/textures/items/"): using (AnimationEditor animationEditor = new AnimationEditor(file)) + { + if (animationEditor.ShowDialog(this) == DialogResult.OK) { - if (animationEditor.ShowDialog(this) == DialogResult.OK) - ReloadMetaTreeView(); + file.filepath = animationEditor.TileName; + ReloadMetaTreeView(); + BuildMainTreeView(); + saved = false; } + } break; @@ -2659,11 +2665,17 @@ namespace PckStudio string filename = Path.GetFileNameWithoutExtension(file.filepath); if ((filename.EndsWith("MipMapLevel2") ||filename.EndsWith("MipMapLevel3")) && currentPCK.TryGetFile(file.filepath.Substring(0, file.filepath.Length - 4 - 12) + ".png", 2, out var baseAnimationFile)) - file = baseAnimationFile; + + file = baseAnimationFile; using AnimationEditor diag = new AnimationEditor(file); if (diag.ShowDialog(this) == DialogResult.OK) + { + file.filepath = diag.TileName; ReloadMetaTreeView(); + BuildMainTreeView(); + saved = false; } + } if (Path.GetFileName(file.filepath) == "audio.pck") {