// package ui contains the Fyne GUI bootstrap and wiring. package ui import ( "fyne.io/fyne/v2" "fyne.io/fyne/v2/app" "gitea.mrixs.me/Mrixs/MrixsCraft-launcher/internal/auth" "gitea.mrixs.me/Mrixs/MrixsCraft-launcher/internal/config" "gitea.mrixs.me/Mrixs/MrixsCraft-launcher/internal/ui/screens" "gitea.mrixs.me/Mrixs/MrixsCraft-launcher/internal/ui/theme" ) // Launch initialises the Fyne application with the Minecraft theme and shows the main window. func Launch(client *auth.Client, session *auth.Session, settings config.Settings) { a := app.New() a.Settings().SetTheme(&theme.MinecraftTheme{}) w := a.NewWindow("MrixsCraft") w.Resize(fyne.NewSize(float32(settings.Width), float32(settings.Height))) w.CenterOnScreen() // TODO: fetch from /api/servers.json serverList := []screens.Modpack{ {Slug: "hitech", Name: "HiTech 1.21"}, {Slug: "vanilla", Name: "Vanilla 1.20"}, } onPlay := func() { // TODO: launch selected modpack } onSettings := func() { screens.SettingsScreen(w, func(memoryMB int, extraArgs string) { settings.MemoryMB = memoryMB settings.ExtraArgs = extraArgs _ = config.Save(settings) }) } content := screens.MainScreen(w, client, session, serverList, onPlay, onSettings) w.SetContent(content) // If no session, show login modal after the window is rendered. if session == nil { w.Show() screens.LoginScreen(w, client, func(sess *auth.Session) { // Refresh UI with logged-in state. content := screens.MainScreen(w, client, sess, serverList, onPlay, onSettings) w.SetContent(content) }) } w.ShowAndRun() }