Commit before moving button press events from events into your control

This commit is contained in:
2022-06-29 12:12:45 +01:00
parent 5501d6f9b5
commit 4b8155ae16
8 changed files with 55 additions and 28 deletions
+18 -4
View File
@@ -17,19 +17,33 @@ updateUsingInput w = case _hudElement $ _hud w of
DisplayInventory {} -> updatePressedButtons (_mouseButtons w) w
DisplayCarte -> updatePressedButtonsCarte (_mouseButtons w) w
-- ugly check for subinventory inventory hammer, this should change
updatePressedButtons :: M.Map MouseButton Bool -> World -> World
updatePressedButtons pkeys w
updatePressedButtons pkeys w
| ButtonLeft `M.member` pkeys &&
(inSubInv || w ^?! hammers . ix SubInvHam /= HammerUp)
= undefined --w & hammers . ix SubInvHam .~ HammerDown
| otherwise = updatePressedButtons' pkeys w
where
inSubInv = case _hudElement (_hud w) of
DisplayInventory NoSubInventory -> False
DisplayInventory _ -> True
_ -> False
updatePressedButtons' :: M.Map MouseButton Bool -> World -> World
updatePressedButtons' pkeys w
| isDown ButtonLeft && isDown ButtonRight && inTopInv
= useItem (you w) w & doubleMouseHammer .~ HammerDown
= useItem (you w) w & hammers . ix DoubleMouseHam .~ HammerDown
| isDown ButtonLeft && (inTopInv || _timeFlow w == RewindingLastFrame)
&& _doubleMouseHammer w == HammerUp
&& w ^?! hammers . ix DoubleMouseHam == HammerUp
= useLeftItem (_yourID w) w
| isDown ButtonLeft && (inTopInv || _timeFlow w == RewindingLastFrame)
= w & doubleMouseHammer .~ HammerDown
= w & hammers . ix DoubleMouseHam .~ HammerDown
| isDown ButtonRight && inTopInv = w
| isDown ButtonMiddle
= w & cameraRot -~ rotation
& clickMousePos .~ _mousePos w
| isDown ButtonLeft = w & hammers . ix DoubleMouseHam .~ HammerDown
| otherwise = w
where
inTopInv = case _hudElement (_hud w) of