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