Empty Update/UsingInput

This commit is contained in:
2023-02-19 12:27:16 +00:00
parent b615d6ce57
commit 1028fa7d88
2 changed files with 20 additions and 27 deletions
+19 -1
View File
@@ -2,6 +2,8 @@ module Dodge.Creature.YourControl (
yourControl,
) where
import Dodge.Base.You
import Dodge.Creature.Impulse.UseItem
import Data.Foldable
import qualified Data.Map.Strict as M
import Data.Maybe
@@ -26,8 +28,9 @@ yourControl cr w
w
& cWorld . lWorld . creatures . ix (_crID cr)
%~ (wasdWithAiming w (_mvSpeed $ _crMvType cr) . mouseActionsCr (_mouseButtons (_input w)))
& updateUsingInput
& pressedMBEffectsNoInventory pkeys
where
pkeys = w ^. input . mouseButtons
intopinv = fromMaybe False $ do
subinv <- w ^? hud . hudElement . subInventory
Just $ case subinv of
@@ -113,3 +116,18 @@ mouseActionsCr pkeys cr
noaction = fromMaybe True $ do
theaction <- cr ^? crManipulation . manObject . inInventory . iselAction
return $ theaction == NoInvSelAction
pressedMBEffectsNoInventory :: M.Map SDL.MouseButton Bool -> World -> World
pressedMBEffectsNoInventory pkeys w
| isDown SDL.ButtonLeft && isDown SDL.ButtonRight && inTopInv = useItem (you w) w
| isDown SDL.ButtonLeft && inTopInv = useLeftItem 0 w
| isDown SDL.ButtonMiddle =
w & cWorld . camPos . camRot -~ rotation
& input . clickMousePos .~ _mousePos (_input w)
| otherwise = w
where
inTopInv = case w ^. hud . hudElement of
DisplayInventory {_subInventory = NoSubInventory} -> True
_ -> False
isDown but = but `M.member` pkeys
rotation = angleBetween (_mousePos (_input w)) (_clickMousePos (_input w))
+1 -26
View File
@@ -1,6 +1,6 @@
{- Functions that affect the world according to what pressed buttons are stored in a Set. -}
module Dodge.Update.UsingInput (
updateUsingInput,
-- updateUsingInput,
) where
import Control.Lens
@@ -18,18 +18,7 @@ import Dodge.Terminal.LeftButton
import Geometry
import SDL
updateUsingInput :: World -> World
updateUsingInput w = case w ^. hud . hudElement of
DisplayInventory {_subInventory = subinv} ->
pressedMBEffects subinv (_mouseButtons (_input w)) w
DisplayCarte -> w
pressedMBEffects :: SubInventory -> M.Map MouseButton Bool -> World -> World
pressedMBEffects subinv pkeys w = case subinv of
NoSubInventory -> pressedMBEffectsNoInventory pkeys w
_ -> w
where
lbinitialpress = pkeys ^? ix ButtonLeft == Just False
-- maybeexitcombine w'
-- | ButtonRight `M.member` _mouseButtons (_input w) =
-- (hud . hudElement . subInventory . subInvMap %~ setShownIntMap) $
@@ -37,20 +26,6 @@ pressedMBEffects subinv pkeys w = case subinv of
-- | otherwise = w' & hud . hudElement . subInventory .~ NoSubInventory
pressedMBEffectsNoInventory :: M.Map MouseButton Bool -> World -> World
pressedMBEffectsNoInventory pkeys w
| isDown ButtonLeft && isDown ButtonRight && inTopInv = useItem (you w) w
| isDown ButtonLeft && inTopInv = useLeftItem 0 w
| isDown ButtonMiddle =
w & cWorld . camPos . camRot -~ rotation
& input . clickMousePos .~ _mousePos (_input w)
| otherwise = w
where
inTopInv = case w ^. hud . hudElement of
DisplayInventory {_subInventory = NoSubInventory} -> True
_ -> False
isDown but = but `M.member` pkeys
rotation = angleBetween (_mousePos (_input w)) (_clickMousePos (_input w))
-- note "sort" on the inventory indices; otherwise
-- lower items may be shifted up and items below these removed instead