From 2abbf877cfaa10a0710d5a5e721de7397abce7ed Mon Sep 17 00:00:00 2001 From: jupahe64 Date: Tue, 7 Nov 2023 04:19:23 +0100 Subject: [PATCH] make sure to always focus on the MainArea when a course is loaded --- Fushigi/ui/widgets/CourseScene.cs | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/Fushigi/ui/widgets/CourseScene.cs b/Fushigi/ui/widgets/CourseScene.cs index 26dd84bf..3fe215ee 100644 --- a/Fushigi/ui/widgets/CourseScene.cs +++ b/Fushigi/ui/widgets/CourseScene.cs @@ -25,6 +25,7 @@ namespace Fushigi.ui.widgets class CourseScene { Dictionary viewports = []; + Dictionary? lastCreatedViewports; LevelViewport activeViewport; readonly Course course; @@ -87,8 +88,11 @@ public void DrawUI(GL gl) ImGui.DockSpace(0x100, ImGui.GetContentRegionAvail()); - foreach (var (area, viewport) in viewports) + for (int i = 0; i < course.GetAreaCount(); i++) { + var area = course.GetArea(i); + var viewport = viewports[area]; + ImGui.SetNextWindowDockID(0x100, ImGuiCond.Once); if (ImGui.Begin(area.GetName())) @@ -125,6 +129,22 @@ public void DrawUI(GL gl) } } + if (lastCreatedViewports != viewports) + { + for (int i = 0; i < course.GetAreaCount(); i++) + { + var area = course.GetArea(i); + if(area.mActorHolder.GetActors().Any(x=>x.mActorName=="PlayerLocator")) + { + ImGui.SetWindowFocus(area.GetName()); + break; + } + + } + + lastCreatedViewports = viewports; + } + if (activeViewport.mEditContext.SelectionVersion != selectionVersionBefore) { DeselectAll();