a
This commit is contained in:
@@ -4,6 +4,7 @@ import (
|
||||
_ "embed"
|
||||
"github.com/diamondburned/gotk4/pkg/gdk/v4"
|
||||
"github.com/diamondburned/gotk4/pkg/gdkpixbuf/v2"
|
||||
"sync"
|
||||
)
|
||||
|
||||
//go:embed debug.png
|
||||
@@ -146,11 +147,28 @@ var failBytes []byte
|
||||
//go:embed assets/please_wait.gif
|
||||
var pleaseWaitBytes []byte
|
||||
|
||||
// var clientAssets map[string]gdk.Paintabler = make(map[string]gdk.Paintabler)
|
||||
var clientAssets sync.Map
|
||||
|
||||
func loadAsset(key string, data []byte) {
|
||||
loader := gdkpixbuf.NewPixbufLoader()
|
||||
loader.Write(data)
|
||||
loader.Close()
|
||||
clientAssets[key] = gdk.NewTextureForPixbuf(loader.Pixbuf())
|
||||
clientAssets.Store(key, gdk.NewTextureForPixbuf(loader.Pixbuf()))
|
||||
}
|
||||
|
||||
func clientAssetsLoad(key string) gdk.Paintabler {
|
||||
dat, ok := clientAssets.Load(key)
|
||||
if !ok {
|
||||
return nil
|
||||
}
|
||||
|
||||
paintable, ok := dat.(gdk.Paintabler)
|
||||
if !ok {
|
||||
return nil
|
||||
}
|
||||
|
||||
return paintable
|
||||
}
|
||||
|
||||
func init() {
|
||||
|
||||
Reference in New Issue
Block a user