From cdc4a84d4b9a3d5ab7aa7423b859eec52c3d8108 Mon Sep 17 00:00:00 2001 From: justin Date: Sat, 25 Mar 2023 10:10:47 +0000 Subject: [PATCH] Commit before attempting to split ItemUse into prism + lenses --- src/Dodge/Creature/Impulse/UseItem.hs | 10 +++++----- src/Dodge/Creature/YourControl.hs | 6 +++--- src/Dodge/Update/Input/ScreenLayer.hs | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/Dodge/Creature/Impulse/UseItem.hs b/src/Dodge/Creature/Impulse/UseItem.hs index 270b383c5..90e6d04e8 100644 --- a/src/Dodge/Creature/Impulse/UseItem.hs +++ b/src/Dodge/Creature/Impulse/UseItem.hs @@ -4,9 +4,9 @@ module Dodge.Creature.Impulse.UseItem ( itemEffect, ) where +import Control.Lens import Control.Monad import Data.Foldable -import Control.Lens import qualified Data.Map.Strict as M import Data.Maybe import Dodge.Cuse @@ -25,8 +25,9 @@ useItem cr' w = fromMaybe (f w) $ do cr <- w ^? cWorld . lWorld . creatures . ix (_crID cr') itRef <- cr ^? crManipulation . manObject . inInventory . ispItem it <- cr ^? crInv . ix itRef - return $ itemEffect cr it w - & worldEventFlags . at InventoryChange ?~ () + return $ + itemEffect cr it w + & worldEventFlags . at InventoryChange ?~ () where f = cWorld . lWorld . creatures . ix (_crID cr') . crHammerPosition .~ HammerDown @@ -129,13 +130,12 @@ useLeftItem cid w = fromMaybe w $ do if itmIsConsumable || itmIsEquipable then return $ useItem cr w -- I believe this ONLY sets equipment options else do - invid <- cr ^. crLeftInvSel . lisMPos + invid <- cr ^. crLeftInvSel . lisMPos itm <- cr ^? crInv . ix invid f <- cr ^? crInv . ix invid . itUse . leftUse return . (runIdentity . pointerToItemLocation (_itLocation itm) (return . (itUse . leftHammer .~ HammerDown))) . useL f itm cr $ w - -- TODO determine itmShouldBeUsed with reference to config options diff --git a/src/Dodge/Creature/YourControl.hs b/src/Dodge/Creature/YourControl.hs index 56cd8a1a3..b8177f079 100644 --- a/src/Dodge/Creature/YourControl.hs +++ b/src/Dodge/Creature/YourControl.hs @@ -26,7 +26,7 @@ yourControl cr w w & cWorld . lWorld . creatures . ix (_crID cr) %~ (wasdWithAiming w (_mvSpeed $ _crMvType cr) . mouseActionsCr (_mouseButtons (_input w))) - & pressedMBEffectsNoInventory pkeys + & pressedMBEffectsTopInventory pkeys where pkeys = w ^. input . mouseButtons intopinv = fromMaybe False $ do @@ -115,8 +115,8 @@ mouseActionsCr pkeys cr theaction <- cr ^? crManipulation . manObject . inInventory . iselAction return $ theaction == NoInvSelAction -pressedMBEffectsNoInventory :: M.Map SDL.MouseButton Bool -> World -> World -pressedMBEffectsNoInventory pkeys w +pressedMBEffectsTopInventory :: M.Map SDL.MouseButton Bool -> World -> World +pressedMBEffectsTopInventory pkeys w | isDown SDL.ButtonLeft && isDown SDL.ButtonRight && inTopInv = useItem (you w) w | isDown SDL.ButtonLeft && inTopInv = useLeftItem 0 w | isDown SDL.ButtonMiddle = diff --git a/src/Dodge/Update/Input/ScreenLayer.hs b/src/Dodge/Update/Input/ScreenLayer.hs index 74b85ce41..49cf9768e 100644 --- a/src/Dodge/Update/Input/ScreenLayer.hs +++ b/src/Dodge/Update/Input/ScreenLayer.hs @@ -79,7 +79,7 @@ mouseOverSelectionList :: mouseOverSelectionList ldps screen u | x > xl && x < xr && ylower == yupper - && (mmoving || (_scDisplayTime screen == 0)) + && (mmoving || (_scDisplayTime screen <= 1)) -- slight hack && ylower >= 0 && ylower < ymax && isselectable =