forked from Wieku/danser-go
-
Notifications
You must be signed in to change notification settings - Fork 2
/
manager.go
146 lines (134 loc) · 2.79 KB
/
manager.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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
package settings
import (
"encoding/json"
"os"
"strconv"
)
var fileStorage *fileformat
var fileName string
func initDefaults() {
Version = SETTINGSVERSION
General = &general{os.Getenv("localappdata") + string(os.PathSeparator) + "osu!" + string(os.PathSeparator) + "Songs" + string(os.PathSeparator)}
VSplayer = &vsplayer{
&playerinfo{
1,
false,
"",
"",
},
&playerinfoUI{
6,
14,
696,
false,
false,
true,
1000,
false,
false,
false,
1.3,
0.6,
},
&recordinfoUI{
"who are you",
"1970.01.01",
1019,
35,
18,
0.5,
},
&diffinfoUI{
true,
1049,
678,
18,
0.8,
},
&playerfieldUI{
200,
25,
13,
false,
},
&mapinfo{
"title",
"difficulty",
},
&mods{
false,
false,
false,
false,
false,
},
&knockout{
true,
false,
2000,
36,
1.5,
},
&replayandcache{
"replays\\",
"cache\\",
true,
false,
},
&errorfix{
false,
"error.err",
},
&skin{
false,
"skin\\",
0,
},
}
Graphics = &graphics{1920, 1080, 1280, 720, true, false, 1000, 16}
Audio = &audio{0.5, 0.5, 0.5, 0, false, false}
Beat = &beat{1.2}
Cursor = &cursor{&color{true, 8, &hsv{0, 1.0, 1.0}, false, 0, false, 0, 0}, true, -36, true, true, -36.0, false, 18, true, true, false, 0.4, 0.5, 2000, 1, 0.4, 0.9}
Objects = &objects{5, 0.3, true, true, &color{true, 8, &hsv{0, 1.0, 1.0}, false, 0, true, 100.0, 0}, -1, 1.2, true, 30, 50, true, true, true, true, true, 0.0, false, &color{false, 8, &hsv{0, 0.0, 1.0}, false, 0, true, 100.0, 0}, true, 18, true}
Playfield = &playfield{5, 2, 5, 0, 0.95, 0.95, true, 0, 0.6, 0.6, 0, 1, 0, true, 1, true, true, 0.8, 1.1, 0, false, 2, true, true, 0.3, &bloom{0.0, 0.6, 0.7}}
Dance = &dance{Bezier: &bezier{60, 3}, Flower: &flower{true, 90, 0.666, 130, 90, -1, 0.7, false}, HalfCircle: &circular{1, 130}}
fileStorage = &fileformat{&Version, General, VSplayer, Graphics, Audio, Beat, Cursor, Objects, Playfield, Dance}
}
func LoadSettings(version int) bool {
initDefaults()
fileName = "settings"
if version > 0 {
fileName += "-" + strconv.FormatInt(int64(version), 10)
}
fileName += ".json"
file, err := os.Open(fileName)
defer file.Close()
if os.IsNotExist(err) {
saveSettings(fileName)
return true
} else if err != nil {
panic(err)
} else {
load(file)
saveSettings(fileName) //this is done to save additions from the current format
}
return false
}
func load(file *os.File) {
decoder := json.NewDecoder(file)
decoder.Decode(fileStorage)
}
func Save() {
saveSettings(fileName)
}
func saveSettings(path string) {
file, err := os.Create(path)
defer file.Close()
if err != nil && !os.IsExist(err) {
panic(err)
}
Version = SETTINGSVERSION
encoder := json.NewEncoder(file)
encoder.SetIndent("", "\t")
encoder.Encode(fileStorage)
}