From 1028fa7d88c0b1152b32148bb89a1c7f9735ae1f Mon Sep 17 00:00:00 2001 From: justin Date: Sun, 19 Feb 2023 12:27:16 +0000 Subject: [PATCH] Empty Update/UsingInput --- src/Dodge/Creature/YourControl.hs | 20 +++++++++++++++++++- src/Dodge/Update/UsingInput.hs | 27 +-------------------------- 2 files changed, 20 insertions(+), 27 deletions(-) diff --git a/src/Dodge/Creature/YourControl.hs b/src/Dodge/Creature/YourControl.hs index 23e15a01b..c7a35fcc7 100644 --- a/src/Dodge/Creature/YourControl.hs +++ b/src/Dodge/Creature/YourControl.hs @@ -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)) diff --git a/src/Dodge/Update/UsingInput.hs b/src/Dodge/Update/UsingInput.hs index fa762b21a..6b7fedd56 100644 --- a/src/Dodge/Update/UsingInput.hs +++ b/src/Dodge/Update/UsingInput.hs @@ -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