From 29d63070760e62ecbc4e907d2b0902598fb2a75e Mon Sep 17 00:00:00 2001 From: justin Date: Fri, 30 Dec 2022 11:43:29 +0000 Subject: [PATCH] Tweak rewind gun --- src/Dodge/Creature/Impulse/UseItem.hs | 8 ++++---- src/Dodge/Data/Creature.hs | 2 +- src/Dodge/Data/Item/Use/Consumption/LoadAction.hs | 7 +++++++ src/Dodge/Default/Creature.hs | 2 +- src/Dodge/Inventory.hs | 8 ++++---- src/Dodge/ItEffect.hs | 2 +- src/Dodge/Render/HUD.hs | 2 +- src/Dodge/Update.hs | 5 +++-- src/Dodge/Update/UsingInput.hs | 3 ++- 9 files changed, 24 insertions(+), 15 deletions(-) diff --git a/src/Dodge/Creature/Impulse/UseItem.hs b/src/Dodge/Creature/Impulse/UseItem.hs index 6d447c913..dcc7fd9e9 100644 --- a/src/Dodge/Creature/Impulse/UseItem.hs +++ b/src/Dodge/Creature/Impulse/UseItem.hs @@ -65,8 +65,8 @@ itNeedsLoading it = _laLoaded ic == 0 || not (_laPrimed ic) activateEquipmentAt :: RightButtonOptions -> Creature -> World -> World activateEquipmentAt rbo cr = cWorld . lWorld . creatures . ix (_crID cr) %~ case (rbo ^? opActivateEquipment . activateEquipment, rbo ^? opActivateEquipment . deactivateEquipment) of - (Just i, _) -> crLeftInvSel ?~ i - (_, Just _) -> crLeftInvSel .~ Nothing + (Just i, _) -> crLeftInvSel . lisMPos ?~ i + (_, Just _) -> crLeftInvSel . lisMPos .~ Nothing _ -> id toggleEquipmentAt :: RightButtonOptions -> Int -> Creature -> World -> World @@ -114,7 +114,7 @@ useLeftItem cid w | itmIsConsumable = useItem cr w -- I believe this ONLY sets equipment options | itmIsEquipable = useItem cr w -- I believe this ONLY sets equipment options | otherwise = fromMaybe w $ do - invid <- _crLeftInvSel cr + invid <- cr ^. crLeftInvSel . lisMPos itm <- cr ^? crInv . ix invid f <- cr ^? crInv . ix invid . itUse . leftUse return @@ -127,6 +127,6 @@ useLeftItem cid w isJust (cr ^? crInv . ix (crSel cr) . itUse . cUse) itmIsEquipable = isJust (cr ^? crInv . ix (crSel cr) . itUse . equipEffect . eeUse) - && _crLeftInvSel cr /= Just (crSel cr) + && cr ^. crLeftInvSel . lisMPos /= Just (crSel cr) -- TODO determine itmShouldBeUsed with reference to config options diff --git a/src/Dodge/Data/Creature.hs b/src/Dodge/Data/Creature.hs index 0ad640c5f..8866fe117 100644 --- a/src/Dodge/Data/Creature.hs +++ b/src/Dodge/Data/Creature.hs @@ -53,7 +53,7 @@ data Creature = Creature , _crInvLock :: Bool , _crInvEquipped :: IM.IntMap EquipPosition , _crEquipment :: M.Map EquipPosition Int - , _crLeftInvSel :: Maybe Int + , _crLeftInvSel :: LeftInvSel , _crState :: CreatureState , _crCorpse :: CreatureCorpse --Creature -> Corpse -> SPic , _crMaterial :: Material diff --git a/src/Dodge/Data/Item/Use/Consumption/LoadAction.hs b/src/Dodge/Data/Item/Use/Consumption/LoadAction.hs index 5d344719a..1885806c2 100644 --- a/src/Dodge/Data/Item/Use/Consumption/LoadAction.hs +++ b/src/Dodge/Data/Item/Use/Consumption/LoadAction.hs @@ -26,9 +26,16 @@ data InvSelAction | ReloadAction {_actionProgress :: Int, _reloadAction :: LoadAction, _actionHammer :: HammerType} deriving (Eq, Ord, Show, Read) --Generic, Flat) +data LeftInvSel = LeftInvSel + { _lisMPos :: Maybe Int + , _lisActive :: Bool + } + makeLenses ''LoadAction makeLenses ''InvSel +makeLenses ''LeftInvSel makeLenses ''InvSelAction deriveJSON defaultOptions ''LoadAction deriveJSON defaultOptions ''InvSelAction deriveJSON defaultOptions ''InvSel +deriveJSON defaultOptions ''LeftInvSel diff --git a/src/Dodge/Default/Creature.hs b/src/Dodge/Default/Creature.hs index 9960fce97..555f2abaf 100644 --- a/src/Dodge/Default/Creature.hs +++ b/src/Dodge/Default/Creature.hs @@ -29,7 +29,7 @@ defaultCreature = , _crInvCapacity = 25 , _crInvLock = False , _crInvEquipped = mempty - , _crLeftInvSel = Nothing + , _crLeftInvSel = LeftInvSel Nothing False , _crState = defaultState , _crCorpse = MakeDefaultCorpse , _crMaterial = Flesh diff --git a/src/Dodge/Inventory.hs b/src/Dodge/Inventory.hs index f2cd62b13..0e61e8b0b 100644 --- a/src/Dodge/Inventory.hs +++ b/src/Dodge/Inventory.hs @@ -58,7 +58,7 @@ rmInvItem cid invid w = case w ^? getcid . crInv . ix invid . itUse . useAmount & pointcid . crInv %~ f & pointcid . crInvSel %~ stopCrInvSelAction & pointcid . crInvSel . iselPos %~ g - & pointcid . crLeftInvSel %~ g' + & pointcid . crLeftInvSel . lisMPos %~ g' & removeAnySlotEquipment & dounequipfunction & doanyitemeffect @@ -260,7 +260,7 @@ setEquipActivation :: World -> World setEquipActivation w = case w ^? rbOptions . opAllocateEquipment of Just DoNotMoveEquipment -> w Just RemoveEquipment{} -> - case _crLeftInvSel (you w) of + case you w ^. crLeftInvSel . lisMPos of Just i | i == invsel -> w & rbOptions . opActivateEquipment @@ -269,7 +269,7 @@ setEquipActivation w = case w ^? rbOptions . opAllocateEquipment of } _ -> w & rbOptions . opActivateEquipment .~ NoChangeActivateEquipment Just rbos -> - case _crLeftInvSel (you w) of + case you w ^. crLeftInvSel . lisMPos of Just i | i == invsel -> w & rbOptions . opActivateEquipment .~ NoChangeActivateEquipment Just i | invselcanactivate -> @@ -339,7 +339,7 @@ changeSwapInvSel k w where updatecreature = (crInv %~ IM.safeSwapKeys (i `mod` n) swapi) - . (crLeftInvSel . _Just %~ updateLeftInvSel) + . (crLeftInvSel . lisMPos . _Just %~ updateLeftInvSel) . (crInvSel . iselPos %~ (`mod` n) . subtract k) . (crInvEquipped %~ IM.safeSwapKeys i swapi) . swapSite i swapi diff --git a/src/Dodge/ItEffect.hs b/src/Dodge/ItEffect.hs index cc09f406a..20c46c942 100644 --- a/src/Dodge/ItEffect.hs +++ b/src/Dodge/ItEffect.hs @@ -42,7 +42,7 @@ chargeIfInInventory itm cr w = chargeIfEquipped :: Item -> Creature -> World -> World chargeIfEquipped itm cr w - | Just invid == _crLeftInvSel cr = + | Just invid == cr ^. crLeftInvSel . lisMPos = w & ptrWpCharge %~ (min maxcharge . (+ 1)) | otherwise = w & ptrWpCharge .~ 0 diff --git a/src/Dodge/Render/HUD.hs b/src/Dodge/Render/HUD.hs index 73c36fedd..0e477f6bc 100644 --- a/src/Dodge/Render/HUD.hs +++ b/src/Dodge/Render/HUD.hs @@ -121,7 +121,7 @@ drawNoSubInventory cfig w = cfig (Just i) (inventorySelectionList w) - equipcursor = case _crLeftInvSel cr of + equipcursor = case cr ^. crLeftInvSel . lisMPos of Just invid -> f cyan invid (_crInvEquipped cr IM.! invid) _ -> mempty equipcursors = IM.foldMapWithKey (f yellow) (_crInvEquipped cr) diff --git a/src/Dodge/Update.hs b/src/Dodge/Update.hs index 3f64a3114..8760313c9 100644 --- a/src/Dodge/Update.hs +++ b/src/Dodge/Update.hs @@ -196,8 +196,8 @@ functionalUpdate' :: Universe -> Universe functionalUpdate' u = case u ^. uvWorld . cWorld . timeFlow of NormalTimeFlow -> functionalUpdate u ScrollTimeFlow smoothing _ _ _ -> over uvWorld (doTimeScroll smoothing) u - RewindLeftClick 0 _ -> u - RewindLeftClick _ _ -> over uvWorld scrollTimeBack u & uvWorld . cWorld . timeFlow .~ NormalTimeFlow + RewindLeftClick 0 _ -> u & uvWorld . cWorld . timeFlow .~ NormalTimeFlow + RewindLeftClick _ _ -> over uvWorld scrollTimeBack u -- & uvWorld . cWorld . timeFlow .~ NormalTimeFlow _ -> u doTimeScroll :: Int -> World -> World @@ -226,6 +226,7 @@ scrollTimeBack w = case w ^? cWorld . pastWorlds . _head of & cWorld . timeFlow . reverseAmount -~ 1 & cWorld . lWorld .~ lw & pointerToItemLocation (w ^?! cWorld . lWorld . itemLocations . ix i) . itUse . leftConsumption . wpCharge .~ (x -1) + & pointerToItemLocation (w ^?! cWorld . lWorld . itemLocations . ix i) . itUse . leftHammer .~ HammerDown _ -> w where i = w ^?! cWorld . timeFlow . scrollItemLocation diff --git a/src/Dodge/Update/UsingInput.hs b/src/Dodge/Update/UsingInput.hs index 2c6f793b6..f671b0e73 100644 --- a/src/Dodge/Update/UsingInput.hs +++ b/src/Dodge/Update/UsingInput.hs @@ -53,7 +53,8 @@ pressedMBEffectsNoInventory :: M.Map MouseButton Bool -> World -> World pressedMBEffectsNoInventory pkeys w | isDown ButtonLeft && isDown ButtonRight && inTopInv = useItem (you w) w & input . hammers . ix DoubleMouseHam .~ HammerDown - | justPressedDown ButtonLeft && inTopInv + | isDown ButtonLeft && inTopInv + -- | justPressedDown ButtonLeft && inTopInv && w ^?! input . hammers . ix DoubleMouseHam == HammerUp = useLeftItem 0 w | isDown ButtonLeft && inTopInv =