From 5655b8c3f475aad5b3acb15956d4dc297a19b66e Mon Sep 17 00:00:00 2001 From: KillzXGaming Date: Sat, 28 Sep 2019 19:13:32 -0400 Subject: [PATCH] Fix multiple layout tabs not finding the viewport as active content --- .../Layout/Animation/LytAnimation.cs | 5 ++++ .../FileFormats/Layout/Common.cs | 2 ++ File_Format_Library/GUI/BFLYT/LayoutEditor.cs | 23 +++++++++++++------ 3 files changed, 23 insertions(+), 7 deletions(-) diff --git a/File_Format_Library/FileFormats/Layout/Animation/LytAnimation.cs b/File_Format_Library/FileFormats/Layout/Animation/LytAnimation.cs index a74d72c3..ab0c47db 100644 --- a/File_Format_Library/FileFormats/Layout/Animation/LytAnimation.cs +++ b/File_Format_Library/FileFormats/Layout/Animation/LytAnimation.cs @@ -16,6 +16,11 @@ namespace LayoutBXLYT public List Textures = new List(); + public void UpdateLayout(BxlytHeader heeader) + { + parentLayout = heeader; + } + public override void Reset() { if (parentLayout == null) return; diff --git a/File_Format_Library/FileFormats/Layout/Common.cs b/File_Format_Library/FileFormats/Layout/Common.cs index d0f582d9..232b510a 100644 --- a/File_Format_Library/FileFormats/Layout/Common.cs +++ b/File_Format_Library/FileFormats/Layout/Common.cs @@ -816,6 +816,8 @@ namespace LayoutBXLYT { if (animation == null) animation = new LytAnimation(this, parentLayout); + else + animation.UpdateLayout(parentLayout); return animation; } } diff --git a/File_Format_Library/GUI/BFLYT/LayoutEditor.cs b/File_Format_Library/GUI/BFLYT/LayoutEditor.cs index 1273c8ac..bd142014 100644 --- a/File_Format_Library/GUI/BFLYT/LayoutEditor.cs +++ b/File_Format_Library/GUI/BFLYT/LayoutEditor.cs @@ -455,14 +455,23 @@ namespace LayoutBXLYT private void dockPanel1_ActiveDocumentChanged(object sender, EventArgs e) { - var dockContent = dockPanel1.ActiveDocument as LayoutViewer; - if (dockContent != null) - { - var file = (dockContent).LayoutFile; - ReloadEditors(file); - ActiveViewport = dockContent; + var dockContent = dockPanel1.ActiveDocument as DockContent; + if (dockContent == null) return; - dockContent.UpdateViewport(); + LayoutViewer viewer = null; + foreach (var control in dockContent.Controls) + if (control is LayoutViewer) + viewer = control as LayoutViewer; + + if (viewer != null) + { + var file = viewer.LayoutFile; + ActiveLayout = file; + ReloadEditors(file); + ActiveViewport = viewer; + viewer.UpdateViewport(); + + Console.WriteLine("changed " + ActiveLayout.FileName); } }