-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
119 lines (103 loc) · 2.68 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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
package main
import (
"embed"
"github.com/leaanthony/u"
"github.com/wailsapp/wails/v2"
"github.com/wailsapp/wails/v2/pkg/logger"
"github.com/wailsapp/wails/v2/pkg/options"
"github.com/wailsapp/wails/v2/pkg/options/assetserver"
"github.com/wailsapp/wails/v2/pkg/options/linux"
"github.com/wailsapp/wails/v2/pkg/options/mac"
"github.com/wailsapp/wails/v2/pkg/options/windows"
"modm8/backend/app"
"modm8/backend/game"
"modm8/backend/nexus"
"modm8/backend/thunderstore"
"modm8/backend/runners/steam"
)
//go:embed all:frontend/dist
var assets embed.FS
type IList []interface{}
func NewWindowsOptions(gpuAccel bool) *windows.Options {
return &windows.Options{
WindowIsTranslucent: true,
WebviewIsTransparent: true,
BackdropType: windows.Mica,
ResizeDebounceMS: 1,
WebviewUserDataPath: app.ConfigDir(),
WebviewGpuIsDisabled: !gpuAccel,
}
}
func NewLinuxOptions() *linux.Options {
return &linux.Options{
WindowIsTranslucent: true,
WebviewGpuPolicy: linux.WebviewGpuPolicyOnDemand,
ProgramName: "modm8",
}
}
func NewMacOptions() *mac.Options {
return &mac.Options{
TitleBar: mac.TitleBarHiddenInset(),
Appearance: mac.NSAppearanceNameDarkAqua,
WindowIsTranslucent: true,
WebviewIsTransparent: true,
Preferences: &mac.Preferences{
TabFocusesLinks: u.False,
},
}
}
func main() {
modm8 := app.NewApp()
errs := modm8.Init()
if len(errs) > 0 {
for _, err := range errs {
println("Error occurred:", err)
}
}
modm8.Settings.Apply()
nexusAPI := nexus.NewAPI(modm8.Ctx)
tsAPI := thunderstore.NewAPI(modm8.Ctx)
tsTools := thunderstore.NewTools()
gameManager := game.NewManager()
steamRunner := steam.NewRunner()
err := wails.Run(&options.App{
Title: "modm8",
Width: int(modm8.Persistence.Window.Width),
Height: int(modm8.Persistence.Window.Height),
MinWidth: 850,
MinHeight: 500,
AssetServer: &assetserver.Options{
Assets: assets,
},
Frameless: true,
EnableDefaultContextMenu: false,
OnStartup: modm8.Startup,
OnBeforeClose: modm8.OnBeforeClose,
OnShutdown: modm8.Shutdown,
SingleInstanceLock: &options.SingleInstanceLock{
UniqueId: "7465fe36-08e3-478b-853b-0f8676f724b7",
},
Mac: NewMacOptions(),
Linux: NewLinuxOptions(),
Windows: NewWindowsOptions(modm8.Settings.Performance.GPUAcceleration),
LogLevel: logger.INFO,
Bind: IList{
modm8,
modm8.Settings,
modm8.Persistence,
modm8.Utils,
tsAPI,
tsTools,
nexusAPI,
gameManager,
steamRunner,
},
EnumBind: IList{
app.UpdateBehaviours,
app.GameSelectionLayouts,
},
})
if err != nil {
println("Error: ", err.Error())
}
}