Files
aego/editor/core/props/node.go
sanspie f22242e5aa
ci / release (push) Successful in 5m5s
ci-platforms / build (amd64, windows, windows-2022) (push) Skipped
ci-platforms / build (arm64, darwin, macos-15) (push) Skipped
ci-platforms / build (amd64, darwin, macos-15-intel) (push) Skipped
ci / checks (push) Successful in 4m41s
ci / build (amd64, linux, ubuntu-24.04) (push) Successful in 7m14s
Stage 11g2–11g3: registry texts, CLI and the site in Russian (D348)
The remaining editor strings and undo step names; component, field, enum, setting, diagnostic and Script API texts under schema.*, enum.*, setting.*, diag.* and api.*; the launcher, the in-game Settings View with a Language setting, the CLI and aego schema show --lang. Every documentation page has a .ru.md translation; the site has a full Russian tree with hreflang, a language switch and ru/llms.txt; aego docs check --lang ru. New doc.tutorial and doc.recipe icons. Fix: an animator restored by a rewind prepares its controller before the replayed step.
2026-10-25 15:31:22 +03:00

188 lines
4.8 KiB
Go

package props
import (
"aego/core/ids"
"aego/core/mathx"
"aego/editor/core/history"
"aego/editor/core/history/commands"
"aego/engine/i18n"
"aego/scene"
"aego/scene/mutate"
)
func (a *Access) Rename(tx *history.Transaction, node ids.NodeID, name string) error {
h, err := a.handle(node)
if err != nil {
return err
}
if a.s.Name(h) == name || name == "" {
return nil
}
return a.within(tx, i18n.Tr("editor.history.rename", "Rename"), func(tx *history.Transaction) error {
return tx.Exec(commands.NewMutation(i18n.Tr("editor.history.rename", "Rename"), commands.EnvFor(a.s), mutate.Rename(commands.Ref(node), name)))
})
}
func (a *Access) SetEnabled(tx *history.Transaction, nodes []ids.NodeID, v bool) error {
text := "false"
if v {
text = "true"
}
return a.within(tx, i18n.Tr("editor.history.toggle_enabled", "Toggle Enabled"), func(tx *history.Transaction) error {
for _, n := range nodes {
h, err := a.handle(n)
if err != nil {
return err
}
if a.s.Enabled(h) == v {
continue
}
if err := tx.Exec(commands.NewMutation(i18n.Tr("editor.history.toggle_enabled", "Toggle Enabled"), commands.EnvFor(a.s), mutate.Set(commands.Ref(n), "enabled", text))); err != nil {
return err
}
}
return nil
})
}
func (a *Access) SetLayers(tx *history.Transaction, nodes []ids.NodeID, mask uint64) error {
return a.within(tx, i18n.Tr("editor.history.set_layers", "Set Layers"), func(tx *history.Transaction) error {
for _, n := range nodes {
h, err := a.handle(n)
if err != nil {
return err
}
before := a.s.Layers(h)
if before == mask {
continue
}
if err := tx.Exec(&commands.SetLayers{Node: n, Before: before, After: mask}); err != nil {
return err
}
}
return nil
})
}
func (a *Access) SetSpace(tx *history.Transaction, nodes []ids.NodeID, sp scene.Space) error {
return a.within(tx, i18n.Tr("editor.history.change_space", "Change Space"), func(tx *history.Transaction) error {
for _, n := range nodes {
h, err := a.handle(n)
if err != nil {
return err
}
if a.s.Space(h) == sp {
continue
}
if err := tx.Exec(&commands.SetSpace{Node: n, After: sp}); err != nil {
return err
}
}
return nil
})
}
func (a *Access) EditTransform(tx *history.Transaction, nodes []ids.NodeID, fn func(*scene.Transform2D)) error {
return a.within(tx, i18n.Tr("editor.history.transform", "Transform"), func(tx *history.Transaction) error {
for _, n := range nodes {
h, err := a.handle(n)
if err != nil {
return err
}
if a.s.Space(h) != scene.Space2D {
continue
}
before := a.s.Local(h)
after := before
fn(&after)
if after == before {
continue
}
if err := tx.Exec(&commands.SetTransform{Node: n, Before: before, After: after}); err != nil {
return err
}
}
return nil
})
}
func (a *Access) EditTransform3D(tx *history.Transaction, nodes []ids.NodeID, fn func(*scene.Transform3D)) error {
return a.within(tx, i18n.Tr("editor.history.transform", "Transform"), func(tx *history.Transaction) error {
for _, n := range nodes {
h, err := a.handle(n)
if err != nil {
return err
}
if a.s.Space(h) != scene.Space3D {
continue
}
before := a.s.Local3D(h)
after := before
fn(&after)
if after == before {
continue
}
if err := tx.Exec(&commands.SetTransform3D{Node: n, Before: before, After: after}); err != nil {
return err
}
}
return nil
})
}
func (a *Access) CommonTransform(nodes []ids.NodeID) (scene.Transform2D, [5]bool) {
var first scene.Transform2D
var mixed [5]bool
for i, n := range nodes {
h := a.s.Handle(n)
if h.IsZero() {
continue
}
t := a.s.Local(h)
if i == 0 {
first = t
continue
}
mixed[0] = mixed[0] || t.Position.X != first.Position.X
mixed[1] = mixed[1] || t.Position.Y != first.Position.Y
mixed[2] = mixed[2] || t.Rotation != first.Rotation
mixed[3] = mixed[3] || t.Scale.X != first.Scale.X
mixed[4] = mixed[4] || t.Scale.Y != first.Scale.Y
}
return first, mixed
}
func transform3Values(t scene.Transform3D, euler mathx.Vec3) [9]float32 {
return [9]float32{
t.Position.X, t.Position.Y, t.Position.Z,
euler.X, euler.Y, euler.Z,
t.Scale.X, t.Scale.Y, t.Scale.Z,
}
}
func (a *Access) CommonTransform3D(nodes []ids.NodeID) (scene.Transform3D, mathx.Vec3, [9]bool) {
first := scene.IdentityTransform3D()
var euler mathx.Vec3
var mixed [9]bool
var base [9]float32
seen := false
for _, n := range nodes {
h := a.s.Handle(n)
if h.IsZero() || a.s.Space(h) != scene.Space3D {
continue
}
t := a.s.Local3D(h)
x, y, z := t.Rotation.Euler()
e := mathx.Vec3{X: x, Y: y, Z: z}
vals := transform3Values(t, e)
if !seen {
first, euler, base, seen = t, e, vals, true
continue
}
for i := range vals {
mixed[i] = mixed[i] || vals[i] != base[i]
}
}
return first, euler, mixed
}