-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathmain.go
executable file
·70 lines (54 loc) · 1.77 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
//go:build linux || windows
// https://go.googlesource.com/proposal/+/master/design/draft-gobuild.md
// $ go mod init oddstream.games/gosol
// $ go mod tidy
// the package defining a command (an executable Go program) always has the name main
// this is a signal to go build that it must invoke the linker to make an executable file
package main
import (
"flag"
"log"
"os"
// load png decoder in main package
_ "image/png"
"github.com/hajimehoshi/ebiten/v2"
sol "oddstream.games/gosol/sol"
"oddstream.games/gosol/util"
)
func main() {
log.SetFlags(0)
// pearl from the mudbank: don't have any flags that will overwrite ThePreferences
flag.BoolVar(&sol.DebugMode, "debug", false, "turn debug graphics on")
flag.BoolVar(&sol.NoGameLoad, "noload", false, "do not load saved game when starting")
flag.BoolVar(&sol.NoGameSave, "nosave", false, "do not save game before exit")
flag.BoolVar(&sol.NoScrunch, "noscrunch", false, "do not scrunch cards")
flag.Parse()
if sol.DebugMode {
for i, a := range os.Args {
log.Println(i, a)
}
}
// ebiten panics if a window to maximize is not resizable
ebiten.SetWindowResizingMode(ebiten.WindowResizingModeEnabled)
// if ebiten.IsWindowMaximized() || ebiten.IsWindowMinimized() {
// // GNOME (maybe) annoyingly keeps maximizing the window
// ebiten.RestoreWindow()
// }
{
x, y := ebiten.ScreenSizeInFullscreen()
n := util.Max(x, y)
ebiten.SetWindowSize(n/2, n/2)
}
ebiten.SetWindowIcon(sol.WindowIcons())
ebiten.SetWindowTitle("Go Solitaire")
sol.NewGame() // sets sol.TheGame
if err := ebiten.RunGame(sol.TheGame); err != nil {
log.Fatal(err)
}
// we come here if the user closed the window with the x button
// println("main exit")
if !sol.NoGameSave {
sol.TheGame.Baize.Save()
}
sol.TheGame.Settings.Save()
}