MCPcopy Create free account
hub / github.com/SolarLune/masterplan / init

Function init

sound.go:191–232  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

189var uiSounds = map[UISoundType][]string{}
190
191func init() {
192
193 filepath.Walk(LocalRelativePath("assets/sounds/snddev_sine/"), func(path string, info fs.FileInfo, err error) error {
194
195 if info.IsDir() {
196 return nil
197 }
198
199 filename := filepath.Base(path)
200 ext := filepath.Ext(path)
201 fnNoExt := ""
202
203 ni := strings.LastIndex(filename, "_")
204
205 numberedPortion := ""
206
207 if ni >= 0 {
208 numberedPortion = filename[ni+1 : strings.Index(filename, ext)]
209 fnNoExt = filename[:ni]
210 }
211
212 numbered := false
213
214 // Not "sound_type_00.wav", but rather "sound_type.wav"; not numbered
215 if _, err := strconv.Atoi(numberedPortion); err == nil {
216 numbered = true
217 }
218
219 if !numbered {
220 fnNoExt = filename[:strings.Index(filename, ext)]
221 }
222
223 if _, ok := uiSounds[UISoundType(fnNoExt)]; !ok {
224 uiSounds[UISoundType(fnNoExt)] = []string{}
225 }
226
227 uiSounds[UISoundType(fnNoExt)] = append(uiSounds[UISoundType(fnNoExt)], path)
228
229 return nil
230 })
231
232}
233
234const (
235 UISoundTypeSelect UISoundType = "select"

Callers

nothing calls this directly

Calls 3

LocalRelativePathFunction · 0.85
UISoundTypeTypeAlias · 0.85
IndexMethod · 0.45

Tested by

no test coverage detected