Skip to content

Commit

Permalink
make sure to always focus on the MainArea when a course is loaded
Browse files Browse the repository at this point in the history
  • Loading branch information
jupahe64 committed Nov 7, 2023
1 parent db70304 commit 2abbf87
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion Fushigi/ui/widgets/CourseScene.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ namespace Fushigi.ui.widgets
class CourseScene
{
Dictionary<CourseArea, LevelViewport> viewports = [];
Dictionary<CourseArea, LevelViewport>? lastCreatedViewports;
LevelViewport activeViewport;

readonly Course course;
Expand Down Expand Up @@ -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()))
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit 2abbf87

Please sign in to comment.