diff --git a/internal/ctl/moving.go b/internal/ctl/moving.go index b216504..cc3a3ca 100644 --- a/internal/ctl/moving.go +++ b/internal/ctl/moving.go @@ -324,11 +324,20 @@ func (m *MovingWall) layoutGroup(group cfg.Group, startZ int, instances []int) { func (m *MovingWall) layoutObs() { m.obs.BatchAsync(obs.SerialFrame, func(b *obs.Batch) { visible := make([]bool, len(m.instances)) + var minIndex int = 1e2 + for i := len(m.hitboxes) - 1; i >= 0; i -= 1 { + h := m.hitboxes[i] + name := fmt.Sprintf("Wall MC %d", h.id+1) + idx := b.GetSceneItemIndex("Wall", name) + if minIndex > idx { + minIndex = idx + } + } for i := len(m.hitboxes) - 1; i >= 0; i -= 1 { h := m.hitboxes[i] visible[h.id] = true name := fmt.Sprintf("Wall MC %d", h.id+1) - b.SetItemIndex("Wall", name, 0) + b.SetItemIndex("Wall", name, minIndex) b.SetItemBounds( "Wall", name, diff --git a/internal/obs/batch.go b/internal/obs/batch.go index 533554a..86cd125 100644 --- a/internal/obs/batch.go +++ b/internal/obs/batch.go @@ -49,6 +49,14 @@ func (b *Batch) SetItemIndex(scene, name string, index int) { b.requests = append(b.requests, req) } +func (b *Batch) GetSceneItemIndex(scene, name string) int { + idx, err := b.client.GetSceneItemIndex(scene, name) + if err != nil { + panic(batchError{err}) + } + return idx +} + func (b *Batch) SetItemVisibility(scene, name string, visible bool) { id, err := b.client.getSceneItemId(scene, name) if err != nil {