()
| 66 | } |
| 67 | |
| 68 | func (page *Page) Update() { |
| 69 | |
| 70 | reversed := append([]*Card{}, page.Cards...) |
| 71 | |
| 72 | sort.SliceStable(reversed, func(i, j int) bool { |
| 73 | return j < i |
| 74 | }) |
| 75 | |
| 76 | // We update links out here so they take priority in clicking over the cards themselves. TODO: Optimize this, as this doesn't really need to be done every frame |
| 77 | if page.IsCurrent() { |
| 78 | |
| 79 | for _, card := range reversed { |
| 80 | |
| 81 | for _, link := range card.Links { |
| 82 | link.Update() |
| 83 | } |
| 84 | |
| 85 | } |
| 86 | |
| 87 | } |
| 88 | |
| 89 | for _, card := range reversed { |
| 90 | card.Update() |
| 91 | } |
| 92 | |
| 93 | if page.IsCurrent() { |
| 94 | |
| 95 | // We only want to set the pan and zoom of a page if it's not loading the project (as it sets the page to be current to take screenshots for subpages). |
| 96 | if !page.Project.Loading && !page.IgnoreWritePan { |
| 97 | page.Pan = page.Project.Camera.Position |
| 98 | page.Zoom = page.Project.Camera.Zoom |
| 99 | } |
| 100 | |
| 101 | if page.UpdateStacks { |
| 102 | |
| 103 | // In this loop, the Stacks are subject to change. |
| 104 | for _, card := range page.Cards { |
| 105 | card.Stack.Update() |
| 106 | } |
| 107 | |
| 108 | // From this point, the Stacks should be accurate and usable again. |
| 109 | for _, card := range page.Cards { |
| 110 | card.Stack.PostUpdate() |
| 111 | } |
| 112 | |
| 113 | page.SendMessage(NewMessage(MessageStacksUpdated, nil, nil)) |
| 114 | |
| 115 | page.UpdateStacks = false |
| 116 | |
| 117 | } |
| 118 | |
| 119 | } |
| 120 | |
| 121 | } |
| 122 | |
| 123 | func (page *Page) IsCurrent() bool { |
| 124 | return page.Project.CurrentPage == page |
nothing calls this directly
no test coverage detected