()
| 16 | } |
| 17 | |
| 18 | func (selection *Selection) Update() { |
| 19 | |
| 20 | if globals.State == StateNeutral { |
| 21 | |
| 22 | if globals.Mouse.Button(sdl.BUTTON_LEFT).Pressed() { |
| 23 | |
| 24 | PlayUISound(UISoundTypeTap) |
| 25 | |
| 26 | selection.BoxSelecting = true |
| 27 | selection.BoxStart = globals.Mouse.WorldPosition() |
| 28 | } |
| 29 | |
| 30 | if selection.BoxSelecting && globals.Mouse.Button(sdl.BUTTON_LEFT).Released() { |
| 31 | |
| 32 | selectionRect := NewCorrectingRect(selection.BoxStart.X, selection.BoxStart.Y, globals.Mouse.WorldPosition().X, globals.Mouse.WorldPosition().Y).SDLRect() |
| 33 | |
| 34 | if !globals.Keybindings.Pressed(KBAddToSelection) && !globals.Keybindings.Pressed(KBRemoveFromSelection) { |
| 35 | selection.Clear() |
| 36 | } |
| 37 | |
| 38 | if globals.Keybindings.Pressed(KBRemoveFromSelection) { |
| 39 | |
| 40 | for _, card := range selection.Page.Cards { |
| 41 | if RectIntersecting(card.Rect, selectionRect) { |
| 42 | selection.Remove(card) |
| 43 | } |
| 44 | } |
| 45 | |
| 46 | } else { |
| 47 | |
| 48 | for _, card := range selection.Page.Cards { |
| 49 | if RectIntersecting(card.Rect, selectionRect) { |
| 50 | selection.Add(card) |
| 51 | } |
| 52 | } |
| 53 | |
| 54 | } |
| 55 | |
| 56 | selection.BoxSelecting = false |
| 57 | |
| 58 | } |
| 59 | |
| 60 | } |
| 61 | |
| 62 | } |
| 63 | |
| 64 | func (selection *Selection) Add(card *Card) { |
| 65 | if !card.selected { |
nothing calls this directly
no test coverage detected