diff --git a/src/Dodge/Update.hs b/src/Dodge/Update.hs index 5497c0f92..e5c94f276 100644 --- a/src/Dodge/Update.hs +++ b/src/Dodge/Update.hs @@ -62,9 +62,15 @@ import SDL import Sound.Data import StrictHelp -{- For most menus the only way to change the world is using event handling. -} updateUniverse :: Universe -> Universe -updateUniverse u +updateUniverse = updateUniverseLast . updateUniverseFirst + +updateUniverseLast :: Universe -> Universe +updateUniverseLast = over uvWorld (mouseButtons . each .~ True) -- to determine if the mouse button is held + +{- For most menus the only way to change the world is using event handling. -} +updateUniverseFirst :: Universe -> Universe +updateUniverseFirst u | concurrentblocking = u | otherwise = case _uvScreenLayers u of (OptionScreen{_scOptionFlag = GameOverOptions} : _) -> @@ -93,7 +99,12 @@ functionalUpdate' u = case u ^. uvWorld . timeFlow of _ -> u doTimeScroll :: Int -> World -> World -doTimeScroll smoothing w = case w ^. scrollAmount of +doTimeScroll smoothing w = case w ^? mouseButtons . ix ButtonLeft of + Just False -> w & timeFlow .~ NormalTimeFlow + _ -> doTimeScroll' smoothing w + +doTimeScroll' :: Int -> World -> World +doTimeScroll' smoothing w = case w ^. scrollAmount of x | x > 1 -> w & scrollTimeBack & timeFlow . scrollSmoothing .~ 20 x | x > 0 -> w & scrollTimeBack & timeFlow . scrollSmoothing %~ max 0 x | x < (-1) -> w & scrollTimeForward & timeFlow . scrollSmoothing .~ negate 20 @@ -123,17 +134,17 @@ scrollTimeForward w = case w ^? timeFlow . futureWorlds . _head of w & timeFlow . futureWorlds %~ tail & cwTime . pastWorlds .:~ _cWorld w & cWorld .~ cw - & timeFlow . reverseAmount +~ 1 - & pointerToItemLocation (w ^?! cWorld . itemLocations . ix i) . itUse . leftConsumption . wpCharge +~ 1 + & timeFlow . reverseAmount .~ ramount + & pointerToItemLocation (w ^?! cWorld . itemLocations . ix i) . itUse . leftConsumption . wpCharge .~ ramount where i = w ^?! timeFlow . scrollItemLocation + ramount = (w ^?! timeFlow . reverseAmount) + 1 -- | The update step. functionalUpdate :: Universe -> Universe functionalUpdate w = checkEndGame -- . updateRandGen - . over uvWorld (mouseButtons . each .~ True) -- to determine if the mouse button is held . over uvWorld (cwTime . worldClock +~ 1) . over uvWorld updateWorldSelect -- . over uvWorld doRewind diff --git a/src/Dodge/Update/UsingInput.hs b/src/Dodge/Update/UsingInput.hs index 587211abf..cb134da3d 100644 --- a/src/Dodge/Update/UsingInput.hs +++ b/src/Dodge/Update/UsingInput.hs @@ -53,7 +53,7 @@ pressedMBEffectsNoInventory :: M.Map MouseButton Bool -> World -> World pressedMBEffectsNoInventory pkeys w | isDown ButtonLeft && isDown ButtonRight && inTopInv = useItem (you w) w & hammers . ix DoubleMouseHam .~ HammerDown - | isDown ButtonLeft && inTopInv + | justPressedDown ButtonLeft && inTopInv && w ^?! hammers . ix DoubleMouseHam == HammerUp = useLeftItem (_yourID (_cWorld w)) w | isDown ButtonLeft && inTopInv = @@ -68,6 +68,7 @@ pressedMBEffectsNoInventory pkeys w inTopInv = case _hudElement (_hud (_cWorld w)) of DisplayInventory NoSubInventory -> True _ -> False + justPressedDown but = (pkeys ^. at but) == Just False isDown but = but `M.member` pkeys rotation = angleBetween (_mousePos w) (_clickMousePos w)