diff --git a/OpenKh.Kh2/Sequence.cs b/OpenKh.Kh2/Sequence.cs index 6c4deccba..286530b69 100644 --- a/OpenKh.Kh2/Sequence.cs +++ b/OpenKh.Kh2/Sequence.cs @@ -1,4 +1,5 @@ using OpenKh.Common; +using System; using System.Collections.Generic; using System.IO; using System.Linq; @@ -48,6 +49,8 @@ private class Header [Data] public Section SpriteGroupDesc { get; set; } [Data] public Section AnimationDesc { get; set; } [Data] public Section AnimationGroupDesc { get; set; } + + [Data] public int UVEnableFlag { get; set; } } public class RawSprite @@ -165,6 +168,7 @@ public class AnimationGroup } public int Unknown04 { get; set; } + public bool UVEnableFlag { get; set; } public List Sprites { get; set; } public List> SpriteGroups { get; set; } public List AnimationGroups { get; set; } @@ -186,6 +190,7 @@ private Sequence(Stream inputStream) throw new InvalidDataException("Invalid header"); Unknown04 = header.Unknown04; + UVEnableFlag = Convert.ToBoolean(header.UVEnableFlag); Sprites = stream.ReadList(header.SpriteDesc.Offset, header.SpriteDesc.Count) .Select(x => new Sprite { @@ -235,6 +240,7 @@ public void Write(Stream stream) SpriteGroupDesc = new Section() { Count = SpriteGroups.Count }, AnimationDesc = new Section() { Count = AnimationGroups.Sum(x => x.Animations.Count) }, AnimationGroupDesc = new Section() { Count = AnimationGroups.Count }, + UVEnableFlag = Convert.ToInt32(UVEnableFlag) }; var index = 0; @@ -243,19 +249,7 @@ public void Write(Stream stream) stream.Position = basePosition + MinimumLength; header.SpriteDesc.Offset = (int)(stream.Position - basePosition); - header.SpritePartDesc.Offset = stream.WriteList(Sprites.Select(x => new RawSprite - { - U0 = x.Left, - V0 = x.Top, - U1 = x.Right, - V1 = x.Bottom, - UScroll = x.UTranslation, - VScroll = x.VTranslation, - ColorLeft = x.ColorLeft, - ColorTop = x.ColorTop, - ColorRight = x.ColorRight, - ColorBottom = x.ColorBottom, - })) + header.SpriteDesc.Offset; + header.SpritePartDesc.Offset = stream.WriteList(Sprites.Select(x => new RawSprite { U0 = x.Left, V0 = x.Top, U1 = x.Right, V1 = x.Bottom, UScroll = x.UTranslation, VScroll = x.VTranslation, ColorLeft = x.ColorLeft, ColorTop = x.ColorTop, ColorRight = x.ColorRight, ColorBottom = x.ColorBottom })) + header.SpriteDesc.Offset; header.SpriteGroupDesc.Offset = stream.WriteList(SpriteGroups.SelectMany(x => x)) + header.SpritePartDesc.Offset; index = 0; diff --git a/OpenKh.Tools.LayoutEditor/AppSequenceEditor.cs b/OpenKh.Tools.LayoutEditor/AppSequenceEditor.cs index ec34e30ba..d818cbf5d 100644 --- a/OpenKh.Tools.LayoutEditor/AppSequenceEditor.cs +++ b/OpenKh.Tools.LayoutEditor/AppSequenceEditor.cs @@ -130,6 +130,7 @@ public void Menu() { ForMenuItem("Sprite groups...", () => _isSpriteGroupEditDialogOpen = true); ForMenuItem("Sprites...", () => _isSpriteEditDialogOpen = true); + ForMenuCheck("Enable UV Animations", () => _sequence.UVEnableFlag, x => _sequence.UVEnableFlag = x); }); } @@ -149,6 +150,10 @@ public bool Run() ImGui.EndPopup(); } + _sequence.Sprites = _sprites + .Select(x => x.Sprite) + .ToList(); + const float SpriteListWidthMul = 1f; const float SpriteListWidthMax = 192f; const float RightWidthMul = 1.5f; diff --git a/OpenKh.Tools.LayoutEditor/Dialogs/SpriteEditDialog.cs b/OpenKh.Tools.LayoutEditor/Dialogs/SpriteEditDialog.cs index cc92cbe57..689846456 100644 --- a/OpenKh.Tools.LayoutEditor/Dialogs/SpriteEditDialog.cs +++ b/OpenKh.Tools.LayoutEditor/Dialogs/SpriteEditDialog.cs @@ -59,6 +59,12 @@ public void Run() DrawCropAtlasTexture(); } + if (ImGui.Button("+")) + _spriteModels.Add(new SpriteModel(new Kh2.Sequence.Sprite(), _spriteDrawing, _atlasTexture, _textureBinder, _settings)); + ImGui.SameLine(); + if (ImGui.Button("-")) + _spriteModels.RemoveAt(_selectedSpriteModel); + ForChild("AtlasTexture", _atlasTexture.Width, _atlasTexture.Height, false, () => { diff --git a/OpenKh.Tools.LayoutEditor/Dialogs/SpriteGroupEditDialog.cs b/OpenKh.Tools.LayoutEditor/Dialogs/SpriteGroupEditDialog.cs index 68fb392a8..e48a677a5 100644 --- a/OpenKh.Tools.LayoutEditor/Dialogs/SpriteGroupEditDialog.cs +++ b/OpenKh.Tools.LayoutEditor/Dialogs/SpriteGroupEditDialog.cs @@ -62,7 +62,7 @@ public void Run() var previewWidth = Math.Min(windowSize / TotalWidthMul * PreviewWidthMul, PreviewWidthMax); var editorWidth = Math.Min(windowSize / TotalWidthMul * EditorWidthMul, EditorWidthMax); - ForChild(nameof(SpriteGroupPreview), previewWidth, 512, true, SpriteGroupPreview); + ForChild(nameof(SpriteGroupPreview), previewWidth + 64, 512, true, SpriteGroupPreview); ImGui.SameLine(); ForChild(nameof(SptiteGroupEditor), editorWidth, 512, false, SptiteGroupEditor);