MCPcopy Create free account
hub / github.com/SolarLune/masterplan / Update

Method Update

selection.go:18–62  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

16}
17
18func (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
64func (selection *Selection) Add(card *Card) {
65 if !card.selected {

Callers

nothing calls this directly

Calls 11

ClearMethod · 0.95
RemoveMethod · 0.95
AddMethod · 0.95
PlayUISoundFunction · 0.85
NewCorrectingRectFunction · 0.85
RectIntersectingFunction · 0.85
ButtonMethod · 0.80
WorldPositionMethod · 0.80
ReleasedMethod · 0.80
SDLRectMethod · 0.80
PressedMethod · 0.45

Tested by

no test coverage detected