-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathconfig.go
55 lines (46 loc) · 1017 Bytes
/
config.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
package main
import (
"encoding/json"
"image"
inputviewer "ivan/input-viewer"
"ivan/tracker"
"os"
)
type config struct {
Binds map[string]string
Items []tracker.Item
ZoneItemMap [9][9]string
Locations []string // woth/barren "simple" locations
AlwaysHints map[string]image.Point
DungeonInputMedallionOrder, DungeonInputDungeonKP []string
InputViewer inputviewer.Config
Dimensions struct {
ItemTracker image.Rectangle
Timer image.Rectangle
HintTracker image.Rectangle
}
}
func (c config) windowSize() image.Point {
var ret image.Rectangle
for _, v := range []image.Rectangle{
c.Dimensions.ItemTracker,
c.Dimensions.Timer,
c.Dimensions.HintTracker,
} {
ret = ret.Union(v)
}
return ret.Size()
}
func loadConfig(path string) (config, error) {
f, err := os.Open(path)
if err != nil {
return config{}, err
}
defer f.Close()
var ret config
dec := json.NewDecoder(f)
if err := dec.Decode(&ret); err != nil {
return config{}, err
}
return ret, nil
}