This commit is contained in:
2024-12-19 22:10:18 +00:00
parent 3da9490dd4
commit 2b5a81fd11
5 changed files with 81 additions and 94 deletions
+13 -13
View File
@@ -2,10 +2,6 @@ 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
@@ -13,9 +9,13 @@ import Data.Maybe
import Dodge.Base.Coordinate
import Dodge.Creature.Impulse.Movement
import Dodge.Creature.Impulse.UseItem
import Dodge.Data.ComposedItem
import Dodge.Data.DoubleTree
import Dodge.Data.World
import Dodge.HeldUse
import Dodge.Hotkey
import Dodge.InputFocus
import Dodge.Item.Grammar
import Dodge.WASD
import Geometry
import LensHelp
@@ -43,16 +43,15 @@ yourControl _ w
handleHotkeys :: World -> World
handleHotkeys w
-- | 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))
| 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 . hotkeys
useHotKey :: World -> Int -> World
useHotKey w invid = fromMaybe w $ do
useHotkey :: World -> Int -> World
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
@@ -132,7 +131,8 @@ wasdTwist cr
(TwoHandOver, 0) ->
return $ cr & crTwist .~ twistamount * pi & crDir -~ twistamount * pi
_ -> Nothing
| otherwise = cr
| otherwise =
cr
& crDir +~ _crTwist cr
& crTwist .~ 0 --remove twistk
where
@@ -173,7 +173,7 @@ mouseActionsCr pkeys
pressedMBEffectsTopInventory :: M.Map SDL.MouseButton Int -> World -> World
pressedMBEffectsTopInventory pkeys w
| isDown SDL.ButtonLeft && isDown SDL.ButtonRight && inTopInv = youhammerdown $ useRootItem 0 w
-- | isDown SDL.ButtonLeft && inTopInv = youhammerdown $ useItemLeftClick (you w) w
-- | isDown SDL.ButtonLeft && inTopInv = youhammerdown $ useItemLeftClick (you w) w
| isDown SDL.ButtonMiddle = w & wCam . camRot -~ rotation
| otherwise = w
where