Remove left click/hotkey item data types

This commit is contained in:
2024-12-19 21:55:18 +00:00
parent 910c683eac
commit 3da9490dd4
34 changed files with 708 additions and 883 deletions
+12 -3
View File
@@ -2,6 +2,10 @@ module Dodge.Creature.YourControl (
yourControl,
) where
import Dodge.Data.ComposedItem
import Dodge.HeldUse
import Dodge.Data.DoubleTree
import Dodge.Item.Grammar
import Control.Monad
import Data.Foldable
import qualified Data.Map.Strict as M
@@ -39,14 +43,19 @@ yourControl _ w
handleHotkeys :: World -> World
handleHotkeys w
| SDL.ButtonRight `M.member` _mouseButtons (_input w) = foldl' tryAssignHotkey w allHotkeys
-- | SDL.ButtonRight `M.member` _mouseButtons (_input w)
| SDL.ScancodeLShift `M.member` _pressedKeys (_input w)
|| SDL.ScancodeRShift `M.member` _pressedKeys (_input w)
= foldl' tryAssignHotkey w allHotkeys
| otherwise = foldl' useHotKey w (M.intersection thehotkeys (w ^. input . pressedKeys))
where
--thehotkeys = M.mapKeys hotkeyToScancode $ w ^?! cWorld . lWorld . creatures . ix 0 . crHotkeys
thehotkeys = M.mapKeys hotkeyToScancode $ w ^. cWorld . lWorld . hotkeys
useHotKey :: World -> Int -> World
useHotKey w invid = useItemHotkey 0 invid w
useHotKey w invid = fromMaybe w $ do
cr <- w ^? cWorld . lWorld . creatures . ix 0
itmloc <- allInvLocs (cr ^. crInv) ^? ix invid . _2 . locLDT
return $ heldEffectNoHammerCheck (bimap (^. iatType) (^. _1) itmloc) cr w
allHotkeys :: [SDL.Scancode]
allHotkeys = map hotkeyToScancode [minBound .. maxBound]