ci-platforms / darwin amd64 smoke (push) Skipped
GitHub / linux amd64 native GitHub-hosted native CI: success
ci-platforms / windows amd64 smoke (push) Skipped
GitHub / windows amd64 native GitHub-hosted native CI: success
GitHub / darwin arm64 native GitHub-hosted native CI: success
GitHub / darwin amd64 native GitHub-hosted native CI: success
ci / checks (push) Failing after 1h21m34s
ci / native-authoring (push) Skipped
ci-platforms / darwin arm64 smoke (push) Skipped
github-native / gitea-pending (push) Skipped
github-native / darwin amd64 native (push) Skipped
github-native / linux amd64 native (push) Skipped
github-native / windows amd64 native (push) Skipped
github-native / darwin arm64 native (push) Skipped
github-native / gitea-result (push) Skipped
ci / build (amd64, linux, ubuntu-24.04) (push) Successful in 12m4s
ci / release (push) Skipped
Add dockable Art tools, animation and previews, guarded asset workflows, and the Web Asset Studio built on the shared Art Core. Expand English and Russian documentation, interactive Try scenes, examples and editor icons. Add audio waveform navigation, source analysis, guarded previews and a browser Worker mixer. Preserve source changes and recovery with bounded checks, and strengthen native, browser and interoperability CI. Prepare version 0.12.5 and manually built native artifact candidates. Fix the production site image demo build dependency. Reuse immutable scene indices when capturing keyframes. Wait for real Persist save/load completion in component tests. Stabilize browser Game View captures outside pointer hover. Aseprite interchange and persistent Audio EDL recovery remain limited; the artifact workflow does not publish releases or change stable.
74 lines
1.7 KiB
Go
74 lines
1.7 KiB
Go
package playground
|
|
|
|
import (
|
|
"io/fs"
|
|
"path"
|
|
"sort"
|
|
"strings"
|
|
"sync"
|
|
"time"
|
|
|
|
"aego/contracts/persistence"
|
|
"aego/engine"
|
|
"aego/platform"
|
|
"aego/save"
|
|
)
|
|
|
|
// UseMemorySaves gives e a save store kept in memory, for runs in a browser page that must not touch the visitor's storage.
|
|
func UseMemorySaves(e *engine.Engine) {
|
|
e.SetService(persistence.StoreID, save.NewStoreFS("saves", &memUser{files: map[string][]byte{}}))
|
|
}
|
|
|
|
type memUser struct {
|
|
mu sync.RWMutex
|
|
files map[string][]byte
|
|
}
|
|
|
|
func (m *memUser) ReadFile(p string) ([]byte, error) {
|
|
m.mu.RLock()
|
|
defer m.mu.RUnlock()
|
|
data, ok := m.files[path.Clean(p)]
|
|
if !ok {
|
|
return nil, fs.ErrNotExist
|
|
}
|
|
return append([]byte(nil), data...), nil
|
|
}
|
|
|
|
func (m *memUser) WriteFile(p string, data []byte) error {
|
|
m.mu.Lock()
|
|
defer m.mu.Unlock()
|
|
m.files[path.Clean(p)] = append([]byte(nil), data...)
|
|
return nil
|
|
}
|
|
|
|
func (m *memUser) Remove(p string) error {
|
|
m.mu.Lock()
|
|
defer m.mu.Unlock()
|
|
delete(m.files, path.Clean(p))
|
|
return nil
|
|
}
|
|
|
|
func (m *memUser) Stat(p string) (platform.UserEntry, error) {
|
|
m.mu.RLock()
|
|
defer m.mu.RUnlock()
|
|
data, ok := m.files[path.Clean(p)]
|
|
if !ok {
|
|
return platform.UserEntry{}, fs.ErrNotExist
|
|
}
|
|
return platform.UserEntry{Name: path.Base(p), Size: int64(len(data)), Mod: time.Time{}}, nil
|
|
}
|
|
|
|
func (m *memUser) List(dir string) ([]platform.UserEntry, error) {
|
|
m.mu.RLock()
|
|
defer m.mu.RUnlock()
|
|
prefix := path.Clean(dir) + "/"
|
|
var out []platform.UserEntry
|
|
for p, data := range m.files {
|
|
if rest, ok := strings.CutPrefix(p, prefix); ok && !strings.Contains(rest, "/") {
|
|
out = append(out, platform.UserEntry{Name: rest, Size: int64(len(data))})
|
|
}
|
|
}
|
|
sort.Slice(out, func(i, j int) bool { return out[i].Name < out[j].Name })
|
|
return out, nil
|
|
}
|