-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.go
123 lines (103 loc) · 3.32 KB
/
app.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
120
121
122
123
package main
import (
"context"
"fmt"
configuration "mojo/backend/configs"
"mojo/backend/scripts"
"path/filepath"
)
// App struct
type App struct {
ctx context.Context
}
// NewApp creates a new App application struct
func NewApp() *App {
return &App{}
}
var modConfig = configuration.ModConfig()
// startup is called at application startup
func (a *App) startup(ctx context.Context) {
// Perform your setup here
a.ctx = ctx
}
// domReady is called after front-end resources have been loaded
func (a App) domReady(ctx context.Context) {
// Add your action here
}
// beforeClose is called when the application is about to quit,
// either by clicking the window close button or calling runtime.Quit.
// Returning true will cause the application to continue, false will continue shutdown as normal.
func (a *App) beforeClose(ctx context.Context) (prevent bool) {
return false
}
// shutdown is called at application termination
func (a *App) shutdown(ctx context.Context) {
// Perform your teardown here
}
// Greet returns a greeting for the given name
func (a *App) Greet(name string) string {
return fmt.Sprintf("Hello %s, It's show time!", name)
}
func (a *App) BuildModsInLocal(selectedModKeys []string, buildCombinedMod bool) error {
if len(selectedModKeys) == 0 {
return fmt.Errorf("No mods selected for building")
}
if buildCombinedMod {
modFileName := modConfig.CombinedMod.Replacements["modFolderName"] + ".mod"
if err := scripts.BuildModFile(config.ModBuildPathLocal, modFileName); err != nil {
fmt.Println("Error while processing mojo.mod file")
return err
}
modBuildPath := filepath.Join(config.ModBuildPathLocal, modConfig.CombinedMod.Replacements["modFolderName"])
err := scripts.BuildCombinedMod(modBuildPath, selectedModKeys)
if err != nil {
fmt.Printf("Error building combined mod in local: %v \n", err)
return err
}
} else {
err := scripts.BuildLooseMods(config.ModBuildPathLocal, selectedModKeys)
if err != nil {
fmt.Printf("Error building selected mod(s) in local: %v \n", err)
return err
}
}
return nil
}
func (a *App) BuildModsInGame(selectedModKeys []string, buildCombinedMod bool) error {
if len(selectedModKeys) == 0 {
return fmt.Errorf("No mods selected for building")
}
if buildCombinedMod {
modFileName := modConfig.CombinedMod.Replacements["modFolderName"] + ".mod"
if err := scripts.BuildModFile(config.GameCustomModPath, modFileName); err != nil {
fmt.Println("Error while processing mojo.mod file")
return err
}
modBuildPath := filepath.Join(config.GameCustomModPath, modConfig.CombinedMod.Replacements["modFolderName"])
err := scripts.BuildCombinedMod(modBuildPath, selectedModKeys)
if err != nil {
fmt.Printf("Error building combined mod in local: %v \n", err)
return err
}
} else {
err := scripts.BuildLooseMods(config.GameCustomModPath, selectedModKeys)
if err != nil {
fmt.Printf("Error building selected mod(s) in local: %v \n", err)
return err
}
}
return nil
}
// TODO: change "pull" to "sync"
func (a *App) PullCk3GameFiles() error {
err := scripts.Pull(config.Ck3PullMapping)
if err != nil {
fmt.Printf("Error pulling CK3 game files: %v \n", err)
return err
}
fmt.Printf("📦 Pulled CK3 game files to %s \n", config.ModCk3Path)
return nil
}
func (a *App) GetModList() (*configuration.ModType, error) {
return modConfig, nil
}