This commit is contained in:
2026-05-23 06:45:18 +01:00
parent af0ec78eae
commit 9ad48ff310
5 changed files with 52 additions and 31 deletions
+19 -1
View File
@@ -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() {