-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
61 lines (50 loc) · 1.2 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
package main
import (
"github.com/leaanthony/mewn"
"github.com/noahbjohnson/smapi-manager/backend"
"github.com/wailsapp/wails"
"log"
)
// TODO: customize or randomize
const addr = ":53494"
const title = "Stardew Mod Manager"
func newWebview() (app *wails.App, err error) {
js := mewn.String("./frontend/build/static/js/main.js")
css := mewn.String("./frontend/build/static/css/main.css")
app = wails.CreateApp(&wails.AppConfig{
Width: 1024,
Height: 768,
Title: title,
JS: js,
CSS: css,
Colour: "#131313",
})
return app, err
}
func openSmapiInstall() error {
return backend.OpenSmapiInstall()
}
func hasSmapi() (bool, error) {
return backend.HasSMAPI()
}
func loadMods() ([]backend.Mod, error) {
return backend.LoadMods(backend.GameDir()), nil
}
func main() {
// Load defaults and/or config file
backend.InitializeConfig()
// Start the API server in the background
err := backend.StartAPI(addr)
if err != nil {
log.Fatalln("Failed to start API", err)
}
// Create the webview window
app, err := newWebview()
if err != nil {
log.Fatalln("Failed to bind functions to frontend", err)
}
app.Bind(openSmapiInstall)
app.Bind(hasSmapi)
app.Bind(loadMods)
err = app.Run()
}