Block skipping setup screens

This commit is contained in:
NeilClack
2026-06-18 16:12:24 -05:00
parent b11afe22f0
commit 397d4c9f19
+34 -15
View File
@@ -26,18 +26,20 @@ import (
const ( const (
targetFPS = 60.0 targetFPS = 60.0
volumeStepSize = 16
openGLMajorVersion = 3 openGLMajorVersion = 3
openGLMinorVersion = 3 openGLMinorVersion = 3
apiURL = "https://portal.rhemawavetech.com/api/v1" // volumeStepSize = 16
// apiURL = "https://portal.rhemawavetech.com/api/v1"
) )
type State int type State int
const ( const (
NEEDS_INTERNET State = iota FIRST_RUN State = iota
NEEDS_INTERNET
NEEDS_LICENSE_KEY NEEDS_LICENSE_KEY
NEEDS_EMAIL_ADDRESS NEEDS_EMAIL_ADDRESS
DOWNLOADING_ASSETS
READY READY
) )
@@ -107,10 +109,12 @@ func Run() {
} }
// Populate the initial Config cache OR create defaults // Populate the initial Config cache OR create defaults
firstRun := false
result = DB.First(&initialConfig) result = DB.First(&initialConfig)
if result.Error != nil { if result.Error != nil {
if errors.Is(result.Error, gorm.ErrRecordNotFound) { if errors.Is(result.Error, gorm.ErrRecordNotFound) {
logger.Info("First run detected: Creating default configuration...") logger.Info("First run detected: Creating default configuration...")
firstRun = true
initialConfig = db.AppConfig{ initialConfig = db.AppConfig{
DataDir: dataDir, DataDir: dataDir,
AssetsDir: dataDir, AssetsDir: dataDir,
@@ -138,6 +142,10 @@ func Run() {
DB: DB, DB: DB,
} }
if firstRun {
app.state = FIRST_RUN
}
app.refreshCache() app.refreshCache()
w, h := app.initializeSDLAndOpenGL() w, h := app.initializeSDLAndOpenGL()
@@ -161,13 +169,15 @@ func Run() {
app.runEventLoop() app.runEventLoop()
} }
// checkState keeps watch of the application state and sets pages
// accordingly. This function runs once per
func (app *Application) checkState() { func (app *Application) checkState() {
// app.state is READY so do nothing.
if app.state == READY { if app.state == READY {
return return
} }
// app.state = 0 means that there is no state set // Check if there is an internet connection, and if not, force the WiFi page
// Check for an internet connection first
if !networkIsUp { if !networkIsUp {
if lastNetworkCheckTime.IsZero() || time.Since(lastNetworkCheckTime) >= time.Second { if lastNetworkCheckTime.IsZero() || time.Since(lastNetworkCheckTime) >= time.Second {
networkManager, err := network.New() networkManager, err := network.New()
@@ -189,12 +199,21 @@ func (app *Application) checkState() {
} }
return return
} }
networkIsUp = true // ← internet confirmed, don't check again networkIsUp = true // internet confirmed, don't check again
} else { } else {
return // throttled, and we don't yet know if network is up — can't proceed return // throttled, and we don't yet know if network is up — can't proceed
} }
} }
// Then check for an email address
if app.Config.Load().EmailAddress == "" {
if app.state != NEEDS_EMAIL_ADDRESS {
app.PageRouter.NavigateTo(page.EMAIL_ADDRESS)
app.state = NEEDS_EMAIL_ADDRESS
}
return
}
// Then check for a license key // Then check for a license key
if app.Config.Load().LicenseKey == "" { if app.Config.Load().LicenseKey == "" {
if app.state != NEEDS_LICENSE_KEY { if app.state != NEEDS_LICENSE_KEY {
@@ -204,15 +223,6 @@ func (app *Application) checkState() {
return return
} }
// Finally, check for an email address
if app.Config.Load().EmailAddress == "" {
if app.state != NEEDS_EMAIL_ADDRESS {
app.PageRouter.NavigateTo(page.EMAIL_ADDRESS)
app.state = NEEDS_EMAIL_ADDRESS
}
return
}
app.state = READY app.state = READY
app.PageRouter.NavigateTo(page.HOME) app.PageRouter.NavigateTo(page.HOME)
} }
@@ -428,14 +438,23 @@ func (app *Application) renderFrame() {
func (app *Application) initKeybinds() { func (app *Application) initKeybinds() {
keybinds.Register(sdl.K_F3, sdl.KMOD_NONE, func() { keybinds.Register(sdl.K_F3, sdl.KMOD_NONE, func() {
if app.state != READY {
return
}
app.PageRouter.NavigateTo(page.SETTINGS) app.PageRouter.NavigateTo(page.SETTINGS)
}) })
keybinds.Register(sdl.K_F2, sdl.KMOD_NONE, func() { keybinds.Register(sdl.K_F2, sdl.KMOD_NONE, func() {
if app.state != READY {
return
}
app.PageRouter.NavigateTo(page.SCROLLER) app.PageRouter.NavigateTo(page.SCROLLER)
}) })
keybinds.Register(sdl.K_F1, sdl.KMOD_NONE, func() { keybinds.Register(sdl.K_F1, sdl.KMOD_NONE, func() {
if app.state != READY {
return
}
app.PageRouter.NavigateTo(page.HOME) app.PageRouter.NavigateTo(page.HOME)
}) })