Cleanup
This commit is contained in:
@@ -13,39 +13,38 @@ import Control.Lens
|
||||
|
||||
updateUsingInput :: World -> World
|
||||
updateUsingInput w = case _hudElement $ _hud w of
|
||||
DisplayInventory {} -> updatePressedButtons (_mouseButtons w) w
|
||||
DisplayCarte -> updatePressedButtonsCarte (_mouseButtons w) w
|
||||
DisplayInventory {} -> updatePressedButtons (_mouseButtons w) w
|
||||
DisplayCarte -> updatePressedButtonsCarte (_mouseButtons w) w
|
||||
|
||||
updatePressedButtons :: S.Set MouseButton -> World -> World
|
||||
updatePressedButtons pkeys w
|
||||
| lbPressed && rbPressed && inTopInv = useItem (you w) w
|
||||
| lbPressed &&
|
||||
(inTopInv || _timeFlow w == RewindingLastFrame)
|
||||
| isDown ButtonLeft && isDown ButtonRight && inTopInv
|
||||
= useItem (you w) w
|
||||
| isDown ButtonLeft && (inTopInv || _timeFlow w == RewindingLastFrame)
|
||||
= useLeftItem (_yourID w) w
|
||||
| mbPressed = w & clickMousePos .~ _mousePos w
|
||||
& cameraRot -~ rotation
|
||||
| isDown ButtonMiddle
|
||||
= w & cameraRot -~ rotation
|
||||
& clickMousePos .~ _mousePos w
|
||||
| otherwise = w
|
||||
where
|
||||
inTopInv = case _hudElement (_hud w) of
|
||||
inTopInv = case _hudElement (_hud w) of
|
||||
DisplayInventory NoSubInventory -> True
|
||||
_ -> False
|
||||
lbPressed = ButtonLeft `S.member` pkeys
|
||||
rbPressed = ButtonRight `S.member` pkeys
|
||||
mbPressed = ButtonMiddle `S.member` pkeys
|
||||
rotation = angleBetween (_mousePos w) (_clickMousePos w)
|
||||
isDown but = but `S.member` pkeys
|
||||
rotation = angleBetween (_mousePos w) (_clickMousePos w)
|
||||
|
||||
updatePressedButtonsCarte :: S.Set MouseButton -> World -> World
|
||||
updatePressedButtonsCarte pkeys w
|
||||
| rbPressed = w & clickMousePos .~ _mousePos w
|
||||
& hud . carteCenter %~ (-.- trans)
|
||||
| lbPressed = w & clickMousePos .~ _mousePos w
|
||||
& hud . carteRot -~ rot
|
||||
& hud . carteZoom *~ czoom
|
||||
| isDown ButtonRight = w
|
||||
& clickMousePos .~ _mousePos w
|
||||
& hud . carteCenter %~ (-.- trans)
|
||||
| isDown ButtonLeft = w
|
||||
& clickMousePos .~ _mousePos w
|
||||
& hud . carteRot -~ rot
|
||||
& hud . carteZoom *~ czoom
|
||||
| otherwise = w
|
||||
where
|
||||
lbPressed = ButtonLeft `S.member` pkeys
|
||||
rbPressed = ButtonRight `S.member` pkeys
|
||||
--mbPressed = ButtonMiddle `S.member` pkeys
|
||||
rot = angleBetween (_mousePos w) (_clickMousePos w)
|
||||
czoom = magV (_mousePos w) / magV (_clickMousePos w)
|
||||
trans = rotateV (_carteRot (_hud w)) $ (1 / _carteZoom (_hud w)) *.* (_mousePos w -.- _clickMousePos w)
|
||||
isDown but = but `S.member` pkeys
|
||||
rot = angleBetween (_mousePos w) (_clickMousePos w)
|
||||
czoom = magV (_mousePos w) / magV (_clickMousePos w)
|
||||
trans = rotateV (_carteRot (_hud w)) $ 1 / _carteZoom (_hud w) *.* (_mousePos w -.- _clickMousePos w)
|
||||
|
||||
Reference in New Issue
Block a user