-
Notifications
You must be signed in to change notification settings - Fork 84
/
renderable.go
40 lines (35 loc) · 1005 Bytes
/
renderable.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
package debugtools
import (
"github.com/oakmound/oak/v3/render"
"golang.org/x/sync/syncmap"
)
var (
debugMap syncmap.Map
)
// SetDebugRenderable stores a renderable under a name in a package global map.
// this is used by some built in debugConsole helper functions.
func SetDebugRenderable(rName string, r render.Renderable) {
debugMap.Store(rName, r)
}
// GetDebugRenderable returns whatever renderable is stored under the input
// string, if any.
func GetDebugRenderable(rName string) (render.Renderable, bool) {
r, ok := debugMap.Load(rName)
if r == nil {
return nil, false
}
return r.(render.Renderable), ok
}
// EnumerateDebugRenderableKeys lists all registered renderables by key.
// It does not check to see if the associated renderables are still valid in any respect.
func EnumerateDebugRenderableKeys() []string {
keys := []string{}
debugMap.Range(func(k, v interface{}) bool {
key, ok := k.(string)
if ok {
keys = append(keys, key)
}
return true
})
return keys
}