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