Empty Update/UsingInput
This commit is contained in:
@@ -2,6 +2,8 @@ module Dodge.Creature.YourControl (
|
|||||||
yourControl,
|
yourControl,
|
||||||
) where
|
) where
|
||||||
|
|
||||||
|
import Dodge.Base.You
|
||||||
|
import Dodge.Creature.Impulse.UseItem
|
||||||
import Data.Foldable
|
import Data.Foldable
|
||||||
import qualified Data.Map.Strict as M
|
import qualified Data.Map.Strict as M
|
||||||
import Data.Maybe
|
import Data.Maybe
|
||||||
@@ -26,8 +28,9 @@ yourControl cr w
|
|||||||
w
|
w
|
||||||
& cWorld . lWorld . creatures . ix (_crID cr)
|
& cWorld . lWorld . creatures . ix (_crID cr)
|
||||||
%~ (wasdWithAiming w (_mvSpeed $ _crMvType cr) . mouseActionsCr (_mouseButtons (_input w)))
|
%~ (wasdWithAiming w (_mvSpeed $ _crMvType cr) . mouseActionsCr (_mouseButtons (_input w)))
|
||||||
& updateUsingInput
|
& pressedMBEffectsNoInventory pkeys
|
||||||
where
|
where
|
||||||
|
pkeys = w ^. input . mouseButtons
|
||||||
intopinv = fromMaybe False $ do
|
intopinv = fromMaybe False $ do
|
||||||
subinv <- w ^? hud . hudElement . subInventory
|
subinv <- w ^? hud . hudElement . subInventory
|
||||||
Just $ case subinv of
|
Just $ case subinv of
|
||||||
@@ -113,3 +116,18 @@ mouseActionsCr pkeys cr
|
|||||||
noaction = fromMaybe True $ do
|
noaction = fromMaybe True $ do
|
||||||
theaction <- cr ^? crManipulation . manObject . inInventory . iselAction
|
theaction <- cr ^? crManipulation . manObject . inInventory . iselAction
|
||||||
return $ theaction == NoInvSelAction
|
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,6 +1,6 @@
|
|||||||
{- Functions that affect the world according to what pressed buttons are stored in a Set. -}
|
{- Functions that affect the world according to what pressed buttons are stored in a Set. -}
|
||||||
module Dodge.Update.UsingInput (
|
module Dodge.Update.UsingInput (
|
||||||
updateUsingInput,
|
-- updateUsingInput,
|
||||||
) where
|
) where
|
||||||
|
|
||||||
import Control.Lens
|
import Control.Lens
|
||||||
@@ -18,18 +18,7 @@ import Dodge.Terminal.LeftButton
|
|||||||
import Geometry
|
import Geometry
|
||||||
import SDL
|
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'
|
-- maybeexitcombine w'
|
||||||
-- | ButtonRight `M.member` _mouseButtons (_input w) =
|
-- | ButtonRight `M.member` _mouseButtons (_input w) =
|
||||||
-- (hud . hudElement . subInventory . subInvMap %~ setShownIntMap) $
|
-- (hud . hudElement . subInventory . subInvMap %~ setShownIntMap) $
|
||||||
@@ -37,20 +26,6 @@ pressedMBEffects subinv pkeys w = case subinv of
|
|||||||
-- | otherwise = w' & hud . hudElement . subInventory .~ NoSubInventory
|
-- | 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
|
-- note "sort" on the inventory indices; otherwise
|
||||||
-- lower items may be shifted up and items below these removed instead
|
-- lower items may be shifted up and items below these removed instead
|
||||||
|
|||||||
Reference in New Issue
Block a user