Get rid of world hammers

This commit is contained in:
2023-01-16 01:52:12 +00:00
parent 43e3c1fe4c
commit 5810c2262a
9 changed files with 40 additions and 86 deletions
+15 -28
View File
@@ -3,6 +3,8 @@ module Dodge.Update.UsingInput (
updateUsingInput,
) where
import Dodge.Combine
import SelectionIntMap
import Dodge.Data.Combine
import Dodge.Data.SelectionList
import Control.Lens
@@ -27,46 +29,32 @@ updateUsingInput w = case w ^. hud . hudElement of
pressedMBEffects :: SubInventory -> M.Map MouseButton Bool -> World -> World
pressedMBEffects subinv pkeys w = case subinv of
NoSubInventory
| ButtonLeft `M.member` pkeys && w ^?! input . hammers . ix SubInvHam /= HammerUp ->
w & input . hammers . ix SubInvHam .~ HammerDown
| otherwise -> pressedMBEffectsNoInventory pkeys w
NoSubInventory -> pressedMBEffectsNoInventory pkeys w
CombineInventory SelectionIntMap {_smSelPos = mi, _smRegexInput = False}
| pkeys ^? ix ButtonLeft == Just False ->
maybeexitcombine (maybe id doCombine mi w) & input . hammers . ix SubInvHam .~ HammerDown
| lbinitialpress -> maybeexitcombine (maybe id doCombine mi w)
CombineInventory SelectionIntMap {_smRegexInput = True}
| pkeys ^? ix ButtonLeft == Just False
-> w & hud . hudElement . subInventory . subInvMap . smRegexInput .~ False
| lbinitialpress -> w & hud . hudElement . subInventory . subInvMap . smRegexInput .~ False
DisplayTerminal tmid
| pkeys ^? ix ButtonLeft == Just False && inTermFocus w ->
| lbinitialpress && inTermFocus w ->
doTerminalEffectLB (w ^?! cWorld . lWorld . terminals . ix tmid) w
& input . hammers . ix SubInvHam .~ HammerDown
| pkeys ^? ix ButtonLeft == Just False ->
| lbinitialpress ->
w & cWorld . lWorld . terminals . ix tmid . tmInput . tiFocus %~ const True
& input . hammers . ix SubInvHam .~ HammerDown
_
| ButtonLeft `M.member` pkeys ->
w & input . hammers . ix SubInvHam .~ HammerDown
_ -> w
where
maybeexitcombine
| ButtonRight `M.member` _mouseButtons (_input w) = id
| otherwise = hud . hudElement . subInventory .~ NoSubInventory
lbinitialpress = pkeys ^? ix ButtonLeft == Just False
maybeexitcombine w'
| ButtonRight `M.member` _mouseButtons (_input w)
= (hud . hudElement . subInventory . subInvMap %~ setShownIntMap)
$ (hud . hudElement . subInventory . subInvMap . smItems .~ combineList w') w'
| 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 & input . hammers . ix DoubleMouseHam .~ HammerDown
| isDown ButtonLeft && inTopInv
&& w ^?! input . hammers . ix DoubleMouseHam == HammerUp =
useLeftItem 0 w
| isDown ButtonLeft && inTopInv =
w & input . hammers . ix DoubleMouseHam .~ HammerDown
| isDown ButtonRight && inTopInv = 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)
| isDown ButtonLeft = w & input . hammers . ix DoubleMouseHam .~ HammerDown
| otherwise = w
where
inTopInv = case w ^. hud . hudElement of
@@ -81,7 +69,6 @@ doCombine :: Int -> World -> World
doCombine i w = case w ^? hud . hudElement . subInventory . subInvMap . smShownItems . ix i . siPayload of
Nothing -> w
Just (CombinableItem is it _) ->
-- set (hud . hudElement) (DisplayInventory NoSubInventory)
selectinv --enterCombineInv
. createPutItem it
$ foldr (rmInvItem 0) w (sort is)