Count mouse button press time up from 0

This commit is contained in:
2023-04-27 11:39:42 +01:00
parent 9972e0fdea
commit 5b1212e4f6
6 changed files with 10 additions and 10 deletions
+1 -1
View File
@@ -55,7 +55,7 @@ itemEffect cr it w = case it ^. itUse of
tryReload :: Creature -> Item -> Input -> (World -> World) -> World -> World
tryReload cr it theinput f
| cid == 0 && itNeedsLoading it && _mouseButtons theinput M.!? SDL.ButtonLeft == Just 1 =
| cid == 0 && itNeedsLoading it && _mouseButtons theinput M.!? SDL.ButtonLeft == Just 0 =
cWorld . lWorld . creatures . ix cid %~ crToggleReloading
| otherwise =
(runIdentity . pointerToItemLocation (_itLocation it) (return . (itUse . heldHammer .~ HammerDown)))
+1 -1
View File
@@ -64,7 +64,7 @@ handleMouseButtonEvent :: MouseButtonEventData -> Input -> Input
handleMouseButtonEvent mbev theinput = case mouseButtonEventMotion mbev of
Released -> theinput & mouseButtons . at thebutton .~ Nothing
Pressed -> theinput
& mouseButtons . at thebutton ?~ 1
& mouseButtons . at thebutton ?~ 0
& clickPos . at thebutton ?~ (theinput ^. mousePos)
-- note that mouse button down events are NOT repeating
where
+3 -3
View File
@@ -91,7 +91,7 @@ updateUniverseFirst u =
setClickWorldPos :: Universe -> M.Map MouseButton Point2
setClickWorldPos u = fmap
(const (screenToWorldPos (u ^. uvWorld . wCam) (u ^. uvWorld . input . mousePos)))
(M.filter (== 1) $ u ^. uvWorld . input . mouseButtons)
(M.filter (== 0) $ u ^. uvWorld . input . mouseButtons)
updateWorldEventFlags :: Universe -> Universe
updateWorldEventFlags u =
@@ -162,13 +162,13 @@ pauseTime itmloc w
| justPressedButtonLeft || outofcharge = w & timeFlow .~ NormalTimeFlow
| otherwise = w & pointerToItemLocation (w ^?! cWorld . lWorld . itemLocations . ix itmloc) . itUse . leftConsumption . wpCharge -~ 1
where
justPressedButtonLeft = w ^? input . mouseButtons . ix ButtonLeft == Just 1
justPressedButtonLeft = w ^? input . mouseButtons . ix ButtonLeft == Just 0
outofcharge = maybe True (== 0) charge
charge = w ^? pointerToItemLocation (w ^?! cWorld . lWorld . itemLocations . ix itmloc) . itUse . leftConsumption . wpCharge
doItemTimeScroll :: Int -> World -> World
doItemTimeScroll smoothing w = case w ^? input . mouseButtons . ix ButtonLeft of
Just 1 -> w & timeFlow .~ NormalTimeFlow
Just 0 -> w & timeFlow .~ NormalTimeFlow
_ -> doTimeScroll smoothing w
doTimeScroll :: Int -> World -> World
+1 -1
View File
@@ -47,7 +47,7 @@ updateFloatingCamera cfig w = w
translateFloatingCamera :: Input -> Camera -> Camera
translateFloatingCamera theinput cam = fromMaybe cam $ do
presstime <- theinput ^. mouseButtons . at ButtonLeft
guard $ presstime > 1
guard $ presstime > 0
hpos <- theinput ^? heldPos . ix ButtonLeft
let thetran =
screenToWorldPos cam hpos
+2 -2
View File
@@ -61,7 +61,7 @@ updateUseInputInGame u = case u ^. uvWorld . hud . hudElement of
where
w = u ^. uvWorld
pkeys = u ^. uvWorld . input . pressedKeys
lbinitialpress = u ^? uvWorld . input . mouseButtons . ix ButtonLeft == Just 1
lbinitialpress = u ^? uvWorld . input . mouseButtons . ix ButtonLeft == Just 0
updatePressedButtonsCarte :: World -> World
updatePressedButtonsCarte w = updatePressedButtonsCarte' (_mouseButtons (_input w)) w
@@ -152,7 +152,7 @@ doRegexInput u i sss
any
((== Just InitialPress) . (`M.lookup` pkeys))
[ScancodeReturn, ScancodeSlash]
endmouse = (Just 1 == ) $ u ^? uvWorld . input . mouseButtons . ix ButtonLeft
endmouse = (Just 0 == ) $ u ^? uvWorld . input . mouseButtons . ix ButtonLeft
backspacetonothing =
sss ^? sssExtra . sssFilters . ix i . _Just == Just ""
&& ScancodeBackspace `M.lookup` pkeys == Just InitialPress
+2 -2
View File
@@ -60,12 +60,12 @@ mouseClickOptionsList :: ScreenLayer -> Universe -> Universe
mouseClickOptionsList screen u = fromMaybe u $ do
sl <- screen ^? scSelectionList
Just $ case u ^. uvWorld . input . mouseButtons . at ButtonLeft of
Just 1 -> fromMaybe u $ do
Just 0 -> fromMaybe u $ do
i <- sl ^. slSelPos
f <- sl ^? slItems . ix i . siPayload . _1
return $ f u
_ -> case u ^. uvWorld . input . mouseButtons . at ButtonRight of
Just 1 -> fromMaybe u $ do
Just 0 -> fromMaybe u $ do
i <- sl ^. slSelPos
f <- sl ^? slItems . ix i . siPayload . _2
return $ f u