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.
105 lines
3.1 KiB
Go
105 lines
3.1 KiB
Go
package editor
|
|
|
|
import (
|
|
"bytes"
|
|
"fmt"
|
|
"path"
|
|
"strings"
|
|
|
|
"aego/art"
|
|
"aego/asset/pipeline"
|
|
"aego/editor/core/assetops"
|
|
"aego/editor/core/context"
|
|
"aego/editor/core/document"
|
|
"aego/engine/i18n"
|
|
)
|
|
|
|
// A PNG is not an Art Document. Conversion creates a separate source and does
|
|
// not replace the original or reassign any SpriteRenderer or sliced frames.
|
|
func canCopyPNGToArt(ed *context.Editor, doc *document.AssetDocument) bool {
|
|
if ed == nil || ed.Pipeline == nil || ed.Docs == nil || doc == nil || !strings.EqualFold(path.Ext(doc.Path), ".png") {
|
|
return false
|
|
}
|
|
rel, ok := ed.Pipeline.PathOf(doc.Asset)
|
|
return ok && rel == doc.Path
|
|
}
|
|
|
|
func askPNGArtCopy(ed *context.Editor, doc *document.AssetDocument) error {
|
|
if !canCopyPNGToArt(ed, doc) {
|
|
return fmt.Errorf("image: a project PNG source is required")
|
|
}
|
|
pl, docs, project := ed.Pipeline, ed.Docs, ed.Project
|
|
before, err := pl.SourceBytes(doc.Path)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
if before == nil {
|
|
return fmt.Errorf("image: PNG source no longer exists")
|
|
}
|
|
drawing, err := art.ImportPNG(before, art.DefaultLimits())
|
|
if err != nil {
|
|
return err
|
|
}
|
|
defer drawing.Close()
|
|
encoded, err := drawing.Encode()
|
|
if err != nil {
|
|
return err
|
|
}
|
|
stem := strings.TrimSuffix(path.Base(doc.Path), path.Ext(doc.Path))
|
|
defaultPath := assetops.UniqueFile(ed, path.Dir(doc.Path), stem, art.SourceExtension)
|
|
ed.Ask(context.Question{
|
|
Title: i18n.Tr("editor.art.png_edit_copy", "Edit as .aeart copy…"),
|
|
Message: i18n.Tr("editor.art.png_copy_notice", "Whole PNG only; the original and scene stay unchanged."),
|
|
Fields: []string{i18n.Tr("editor.art.source_path", "Source path")},
|
|
Values: []string{defaultPath},
|
|
Buttons: []string{i18n.Tr("editor.art.create", "Create"), i18n.Tr("editor.art.cancel", "Cancel")},
|
|
Submit: func(values []string) {
|
|
if len(values) != 1 {
|
|
return
|
|
}
|
|
fail := func(err error) { ed.Notify(context.LevelError, err.Error()) }
|
|
if ed.Pipeline != pl || ed.Docs != docs || ed.Project != project || docs.AssetDocument(doc.Asset) != doc {
|
|
fail(fmt.Errorf("image: project or document changed before creating the copy"))
|
|
return
|
|
}
|
|
target := strings.TrimSpace(values[0])
|
|
if !strings.EqualFold(path.Ext(target), art.SourceExtension) {
|
|
fail(fmt.Errorf("image: editable copy must use .aeart"))
|
|
return
|
|
}
|
|
current, err := pl.SourceBytes(doc.Path)
|
|
if err != nil {
|
|
fail(err)
|
|
return
|
|
}
|
|
if current == nil || !bytes.Equal(before, current) {
|
|
fail(fmt.Errorf("image: PNG source changed before creating the copy"))
|
|
return
|
|
}
|
|
edits, err := newArtCopyEdits(pl, target, encoded)
|
|
if err != nil {
|
|
fail(err)
|
|
return
|
|
}
|
|
// Keep the original image unchanged throughout import, not just while
|
|
// the confirmation dialog is open.
|
|
edits = append(edits, pipeline.SourceEdit{Path: doc.Path, Before: before, After: before})
|
|
batch, err := pl.ApplySources(edits, false)
|
|
if err != nil {
|
|
fail(err)
|
|
return
|
|
}
|
|
ed.ApplyBatch(batch)
|
|
id, ok := pl.Lookup(target)
|
|
if !ok {
|
|
fail(fmt.Errorf("image: editable copy is not in the asset index"))
|
|
return
|
|
}
|
|
if _, err := ed.OpenAsset(id); err != nil {
|
|
fail(err)
|
|
}
|
|
},
|
|
})
|
|
return nil
|
|
}
|