Rename app to radiantwave: embed and provision assets, drop proclamations
This commit is contained in:
@@ -2,6 +2,7 @@ package application
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"io/fs"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"time"
|
||||
@@ -10,6 +11,7 @@ import (
|
||||
"github.com/veandco/go-sdl2/sdl"
|
||||
"github.com/veandco/go-sdl2/ttf"
|
||||
"gorm.io/gorm"
|
||||
"rhemawavetech.com/rhemawave/internal/assets"
|
||||
"rhemawavetech.com/rhemawave/internal/db"
|
||||
"rhemawavetech.com/rhemawave/internal/download"
|
||||
"rhemawavetech.com/rhemawave/internal/fontManager"
|
||||
@@ -59,11 +61,16 @@ type Application struct {
|
||||
var lastNetworkCheckTime time.Time
|
||||
var networkIsUp bool
|
||||
|
||||
// DataDirFor returns the per-user data directory for the application.
|
||||
func DataDirFor(homeDir string) string {
|
||||
return filepath.Join(homeDir, ".local", "share", "radiantwave")
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// Main Entry Point
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
func Run() {
|
||||
func Run(bundled fs.FS) {
|
||||
var err error
|
||||
var homeDir string
|
||||
var dataDir string
|
||||
@@ -79,7 +86,7 @@ func Run() {
|
||||
return
|
||||
}
|
||||
|
||||
dataDir = filepath.Join(homeDir, ".local", "share", "rhemawave")
|
||||
dataDir = DataDirFor(homeDir)
|
||||
if err := os.MkdirAll(dataDir, 0755); err != nil {
|
||||
logger.Error("unable to create data directory %s %v", dataDir, err)
|
||||
return
|
||||
@@ -137,6 +144,16 @@ func Run() {
|
||||
|
||||
logger.AddDatabase(DB)
|
||||
|
||||
// Ensure bundled static assets (fonts, shaders, tos) are present in the
|
||||
// assets directory before any manager tries to load them.
|
||||
config, err := db.GetConfig(DB)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
if err := assets.Provision(bundled, config.AssetsDir); err != nil {
|
||||
logger.Error("failed to provision bundled assets into %s: %v", config.AssetsDir, err)
|
||||
}
|
||||
|
||||
app := &Application{
|
||||
DB: DB,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user