Implement generalised storing of position for mouse presses

This commit is contained in:
2023-03-26 23:00:07 +01:00
parent e5906eefa3
commit ee89ac9b00
10 changed files with 27 additions and 39 deletions
+3 -2
View File
@@ -121,11 +121,12 @@ pressedMBEffectsTopInventory pkeys w
| isDown SDL.ButtonLeft && inTopInv = doTopInvLeftClick (you w) w
| isDown SDL.ButtonMiddle =
w & wCam . camRot -~ rotation
& input . clickMousePos .~ _mousePos (_input w)
| otherwise = w
where
inTopInv = case w ^. hud . hudElement of
DisplayInventory {_subInventory = NoSubInventory} -> True
_ -> False
isDown but = but `M.member` pkeys
rotation = angleBetween (_mousePos (_input w)) (_clickMousePos (_input w))
theinput = w ^. input
rotation = fromMaybe 0
$ angleBetween (theinput ^. mousePos) <$> (theinput ^. heldPos . at SDL.ButtonMiddle)