ci-platforms / windows amd64 smoke (push) Skipped
ci / release (push) Successful in 8m58s
ci-platforms / darwin amd64 smoke (push) Skipped
ci-platforms / darwin arm64 smoke (push) Skipped
ci / checks (push) Successful in 4m46s
ci / build (amd64, linux, ubuntu-24.04) (push) Successful in 13m28s
35 lines
863 B
Go
35 lines
863 B
Go
package animedit
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"aego/editor/core/document"
|
|
)
|
|
|
|
// WithDocuments blocks scene-bound Timeline/Animator writes over dirty or conflicting standalone sources and reloads clean DocumentManager views after successful writes.
|
|
func WithDocuments(files Files, docs *document.Manager) Files {
|
|
return documentFiles{Files: files, docs: docs}
|
|
}
|
|
|
|
type documentFiles struct {
|
|
Files
|
|
docs *document.Manager
|
|
}
|
|
|
|
func (f documentFiles) Write(rel string, data []byte) error {
|
|
var d *document.ScriptDocument
|
|
if f.docs != nil {
|
|
d = f.docs.Script(rel)
|
|
}
|
|
if d != nil && (d.Dirty() || d.Conflict) {
|
|
return fmt.Errorf("animation source has unsaved or conflicting edits: %s; save or reload it before editing the timeline", rel)
|
|
}
|
|
if err := f.Files.Write(rel, data); err != nil {
|
|
return err
|
|
}
|
|
if d != nil {
|
|
return f.docs.ReloadScript(d)
|
|
}
|
|
return nil
|
|
}
|