Skip to content

Commit

Permalink
Make course selector into a popup modal
Browse files Browse the repository at this point in the history
  • Loading branch information
ExplosBlue committed Nov 20, 2023
1 parent 7b6d398 commit 1709a2b
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions Fushigi/ui/widgets/CourseSelect.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ internal class CourseSelect
float worldNameSize = 12f;
GL gl;
Action<string> selectCourseCallback;
bool isOpen = true;

public CourseSelect(GL gl, Action<string> selectCourseCallback, string? selectedCourseName = null)
{
Expand All @@ -30,9 +31,17 @@ public CourseSelect(GL gl, Action<string> selectCourseCallback, string? selected

public void Draw()
{
ImGui.PushStyleVar(ImGuiStyleVar.WindowMinSize, thumbnailSize * 1.2f);
Vector2 center = ImGui.GetMainViewport().GetCenter();
ImGui.SetNextWindowPos(center, ImGuiCond.Appearing, new Vector2(0.5f, 0.5f));

if (!ImGui.Begin("Select Course"))
ImGui.PushStyleVar(ImGuiStyleVar.WindowMinSize, thumbnailSize * 1.25f);

if (isOpen && !ImGui.IsPopupOpen("Select Course"))
{
ImGui.OpenPopup("Select Course");
}

if (!ImGui.BeginPopupModal("Select Course", ref isOpen))
{
return;
}
Expand All @@ -43,7 +52,7 @@ public void Draw()

DrawCourses();

ImGui.End();
ImGui.EndPopup();
}

void DrawTabs()
Expand Down

0 comments on commit 1709a2b

Please sign in to comment.