-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.go
113 lines (88 loc) · 3.18 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
package main
import (
"flag"
"fmt"
"os"
"golang.org/x/exp/slog"
)
const (
// defaultProtonVersion stores the most stable reported Proton version for Homeworld
defaultProtonVersion = "4.11"
// applicationName matches the name of the binary produced that end-users will see
applicationName = "hwrc-proton-launcher"
// Steam ID of Homeworld Remastered in the library
appID = 244160
)
var (
// defaultSteamPaths contains a list of common locations that steam is found on a system
defaultSteamPaths = []string{
"$HOME/.local/share/Steam",
"$HOME/.steam/steam",
}
// fixes not found installation path on Manjaro (HomeworldRM is affected only)
defaultInstallPaths = []string{
"$HOME/.local/share/Steam/steamapps/common/Homeworld/HomeworldRM/bin/Release",
"$HOME/.local/share/Steam/steamapps/common/Homeworld/HomeworldRM/Bin/Release",
}
flagWindowed bool
flagModPath string
flagHelp bool
flagVerbose bool
)
func main() {
flag.BoolVar(&flagWindowed, "w", false, "Windowed mode")
flag.BoolVar(&flagHelp, "help", false, "Display this help")
flag.BoolVar(&flagVerbose, "v", false, "Display verbose output, for debugging purposes")
flag.StringVar(&flagModPath, "m", "", "Load mod at the given `modPath` (see below for details)")
flag.Parse()
if flagVerbose {
log := slog.NewTextHandler(os.Stderr, &slog.HandlerOptions{Level: slog.LevelDebug})
slog.SetDefault(slog.New(log))
}
var fn func(*steam) error
if flagHelp {
help()
os.Exit(1)
} else if len(flag.Args()) > 0 {
fn = cli
} else {
fn = ui
}
s, err := newSteam()
if err != nil {
slog.Error(err.Error())
os.Exit(2)
}
if err := fn(s); err != nil {
slog.Error(err.Error())
os.Exit(3)
}
}
// help displays the help text for the application
func help() {
fmt.Println(applicationName + " [OPTIONS] [GAME]")
fmt.Println("")
flag.PrintDefaults()
fmt.Println(`
This is a launcher application for the Steam version of Homeworld Remastered Collection. It can be used as a replacement for Gearbox's launcher which has Linux compatibility issues.
WARNING: Steam must be running already before running this tool.
GAME:
` + fmt.Sprintf("%-10s", hw1cla) + ` Homeworld 1 Classic
` + fmt.Sprintf("%-10s", hw2cla) + ` Homeworld 2 Classic
` + fmt.Sprintf("%-10s", hw1rem) + ` Homeworld 1 Remastered
` + fmt.Sprintf("%-10s", hw2rem) + ` Homeworld 2 Remastered
` + fmt.Sprintf("%-10s", hwmp) + ` Homeworld Remastered Multiplayer
Loading a mod:
The option '-m' requires a path to the mod file. The path can be an absolute path, or a relative path to the game DATAWORKSHOPSMODS folder. The following folders should be available:
- <STEAM PATH>/steamapps/common/Homeworld/HomeworldRM/DATAWORKSHOPMODS
- <STEAM PATH>/steamapps/common/Homeworld/Homeworld2Classic/DATAWORKSHOPMODS
For example, to load the Homeworld Remastered 2.3 Players Patch using a relative path (provided the mod file and any parent folder are in the DATAWORKSHOPSMODS folder):
` + applicationName + ` hw1rem -m 1190476337/2.3PlayersPatch.big`)
}
// cli runs the game with the expectation that configuration is coming from the CLI arguments
func cli(s *steam) error {
// Figure out the game arguments
game := flag.Arg(0)
// Run the game!
return s.run(game)
}