This repository has been archived by the owner on Aug 23, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathmain.go
97 lines (91 loc) · 2.04 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
// +build !js
package main
import (
"flag"
"fmt"
"log"
"os"
"runtime"
)
func main() {
optSolarized := flag.Bool("s", false, "Use true 16-color solarized palette")
optVersion := flag.Bool("v", false, "print version number")
optCenteredCamera := flag.Bool("c", false, "centered camera")
color8 := false
if runtime.GOOS == "windows" {
color8 = true
}
opt8colors := flag.Bool("o", color8, "use only 8-color palette")
opt256colors := flag.Bool("x", !color8, "use xterm 256-color palette (solarized approximation)")
optNoAnim := flag.Bool("n", false, "no animations")
optReplay := flag.String("r", "", "path to replay file")
flag.Parse()
if *optSolarized {
SolarizedPalette()
} else if color8 && !*opt256colors || !color8 && *opt8colors {
SolarizedPalette()
Simple8ColorPalette()
}
if *optVersion {
fmt.Println(Version)
os.Exit(0)
}
if *optReplay != "" {
err := Replay(*optReplay)
if err != nil {
log.Printf("boohu: replay: %v\n", err)
os.Exit(1)
}
os.Exit(0)
}
if *optCenteredCamera {
CenteredCamera = true
}
if *optNoAnim {
DisableAnimations = true
}
ui := &gameui{}
g := &game{}
ui.g = g
err := ui.Init()
if err != nil {
fmt.Fprintf(os.Stderr, "boohu: %v\n", err)
os.Exit(1)
}
defer ui.Close()
LinkColors()
GameConfig.DarkLOS = true
load, err := g.LoadConfig()
var cfgerrstr string
var cfgreseterr string
if load && err != nil {
cfgerrstr = fmt.Sprintf("Error loading config: %s", err.Error())
err = g.SaveConfig()
if err != nil {
cfgreseterr = fmt.Sprintf("Error resetting config: %s", err.Error())
}
} else if load {
CustomKeys = true
}
ApplyConfig()
ui.PostConfig()
ui.DrawWelcome()
load, err = g.Load()
if !load {
g.InitLevel()
} else if err != nil {
g.InitLevel()
g.PrintfStyled("Error: %v", logError, err)
g.PrintStyled("Could not load saved game… starting new game.", logError)
} else {
ui.DrawBufferInit()
}
if cfgerrstr != "" {
g.PrintStyled(cfgerrstr, logError)
}
if cfgreseterr != "" {
g.PrintStyled(cfgreseterr, logError)
}
g.ui = ui
g.EventLoop()
}