Files
aego/art/templates.go
T
sanspie 50be5c04bc
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
Stage 12.5: Art Workspace and asset authoring
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.
2026-11-15 10:37:50 +03:00

78 lines
2.4 KiB
Go

package art
import (
"crypto/rand"
"embed"
"encoding/hex"
"fmt"
"slices"
)
// EffectTemplateProperty is preserved by the ordinary document serializer. It
// selects a built-in particle preset, not executable code or an external path.
const EffectTemplateProperty = "aego.effectTemplate"
type EffectTemplate struct {
ID string `json:"id"`
NameEN string `json:"nameEN"`
NameRU string `json:"nameRU"`
ParticlePreset string `json:"particlePreset"`
}
var effectTemplates = []EffectTemplate{
{"dust", "Dust", "Пыль", "Dust"},
{"spark", "Spark", "Искры", "Spark"},
{"smoke", "Smoke", "Дым", "Smoke"},
{"explosion", "Explosion", "Взрыв", "Explosion"},
{"fire", "Fire", "Огонь", "Fire"},
{"hit-flash", "Hit Flash", "Вспышка удара", "HitFlash"},
{"magic-projectile", "Magic Projectile", "Магический снаряд", "MagicProjectile"},
{"trail", "Trail", "След", "Trail"},
}
//go:embed res/effects
var effectSources embed.FS
// EffectTemplates returns detached, localized catalogue entries shared by all
// hosts. The actual editable artwork is embedded once beside the Art Core.
func EffectTemplates() []EffectTemplate { return slices.Clone(effectTemplates) }
func EffectTemplateOf(id string) (EffectTemplate, bool) {
for _, template := range effectTemplates {
if template.ID == id {
return template, true
}
}
return EffectTemplate{}, false
}
// EffectTemplateBytes returns an independent copy of the versioned starter
// document. Release builders can distribute these exact, reproducible bytes.
func EffectTemplateBytes(id string) ([]byte, error) {
if _, ok := EffectTemplateOf(id); !ok {
return nil, fmt.Errorf("art: unknown effect template %q", id)
}
return effectSources.ReadFile("res/effects/" + id + SourceExtension)
}
// NewEffectDocument makes a fully independent drawing with a new document
// identity. Cels, palettes and pixels use the normal decoder and COW model;
// editing one instance never modifies another instance or the starter bytes.
func NewEffectDocument(id string, limits Limits) (*Document, error) {
data, err := EffectTemplateBytes(id)
if err != nil {
return nil, err
}
doc, err := Decode(data, limits)
if err != nil {
return nil, err
}
var identity [16]byte
if _, err = rand.Read(identity[:]); err != nil {
doc.Close()
return nil, err
}
doc.id = hex.EncodeToString(identity[:])
return doc, nil
}