Add stopWatch

This commit is contained in:
2022-12-30 12:17:27 +00:00
parent 29d6307076
commit 828c4d9c5b
11 changed files with 70 additions and 22 deletions
+12 -1
View File
@@ -198,7 +198,17 @@ functionalUpdate' u = case u ^. uvWorld . cWorld . timeFlow of
ScrollTimeFlow smoothing _ _ _ -> over uvWorld (doTimeScroll smoothing) u
RewindLeftClick 0 _ -> u & uvWorld . cWorld . timeFlow .~ NormalTimeFlow
RewindLeftClick _ _ -> over uvWorld scrollTimeBack u -- & uvWorld . cWorld . timeFlow .~ NormalTimeFlow
_ -> u
DeathTime {} -> u
PausedTimeFlow _ itmloc -> over uvWorld (pauseTime itmloc) u
pauseTime :: Int -> World -> World
pauseTime itmloc w
| justPressedButtonLeft || outofcharge = w & cWorld . timeFlow .~ NormalTimeFlow
| otherwise = w & pointerToItemLocation (w ^?! cWorld . lWorld . itemLocations . ix itmloc) . itUse . leftConsumption . wpCharge -~ 1
where
justPressedButtonLeft = w ^? input . mouseButtons . ix ButtonLeft == Just False
outofcharge = maybe True (== 0) charge
charge = w ^? pointerToItemLocation (w ^?! cWorld . lWorld . itemLocations . ix itmloc) . itUse . leftConsumption . wpCharge
doTimeScroll :: Int -> World -> World
doTimeScroll smoothing w = case w ^? input . mouseButtons . ix ButtonLeft of
@@ -215,6 +225,7 @@ doTimeScroll' smoothing w = case w ^. input . scrollAmount of
_ | smoothing < 0 -> scrollTimeForward w & cWorld . timeFlow . scrollSmoothing +~ 1
_ -> w
scrollTimeBack :: World -> World
scrollTimeBack w = case w ^? cWorld . pastWorlds . _head of
Nothing -> w