Start collapsing manipulated item code with selection code

This commit is contained in:
2026-05-14 14:24:57 +01:00
parent 59d128f87a
commit 06b984c2e5
21 changed files with 86 additions and 64 deletions
+5 -1
View File
@@ -208,7 +208,8 @@ dropItem cr invid w =
youDropItem :: World -> World
youDropItem w = fromMaybe w $ do
curpos <-
w ^? hud . manObject . imSelectedItem . unNInt
mi
--revise2 w ^? hud . manObject . imSelectedItem . unNInt
--revise1 cr ^? crManipulation . manObject . imSelectedItem . unNInt
<|> fmap fst (IM.lookupMax (cr ^. crInv . unNIntMap))
guard $ not $ w ^. cWorld . lWorld . lInvLock
@@ -217,6 +218,9 @@ youDropItem w = fromMaybe w $ do
AtEase -> dropItem cr curpos w
where
cr = you w
mi = do
Sel 0 i <- w^?hud.diSelection._Just
return i
-- placeholder, remember to deal with two handed weapon twist
-- should throw all attached items?
-1
View File
@@ -22,7 +22,6 @@ import qualified Data.IntMap.Strict as IM
import Linear
import Control.Lens
import Dodge.Creature.Test
import Dodge.Data.Creature
import Dodge.Data.Equipment.Misc
import Geometry
import qualified Quaternion as Q
-1
View File
@@ -10,7 +10,6 @@ import Dodge.Data.World
import Dodge.Data.Equipment.Misc
import qualified Data.Map.Strict as M
import NewInt
import Dodge.Data.LWorld
import Data.Maybe
--import qualified IntMapHelp as IM
import qualified Data.IntMap.Strict as IM
+7 -5
View File
@@ -38,9 +38,10 @@ handleHotkeys :: World -> World
handleHotkeys w
| ispressed SDL.ScancodeLShift || ispressed SDL.ScancodeRShift
, (hk : _) <- mapMaybe scancodeToHotkey . M.keys $ pkeys
, Just invid <- w ^? hud . manObject . imSelectedItem
, Just (Sel 0 invid) <- w ^. hud .diSelection
--revise2 , Just invid <- w ^? hud . manObject . imSelectedItem
--revise1 , Just invid <- lw ^? creatures . ix 0 . crManipulation . manObject . imSelectedItem
, Just itid <- lw ^? creatures . ix 0 . crInv . ix invid =
, Just itid <- lw ^? creatures . ix 0 . crInv . ix (NInt invid) =
w & cWorld . lWorld %~ assignHotkey (NInt itid) hk
| ispressed SDL.ScancodeLCtrl || ispressed SDL.ScancodeRCtrl
, (hk : _) <- mapMaybe scancodeToHotkey . M.keys $ pkeys
@@ -212,7 +213,8 @@ tryClickUse pkeys w = fromMaybe w $ do
ltime <- pkeys ^? ix SDL.ButtonLeft
rtime <- pkeys ^? ix SDL.ButtonRight
guard $ ltime <= rtime
case w ^?hud. manObject . imSelectedItem . unNInt of
case w ^.hud.diSelection of
--revise2 case w ^?hud. manObject . imSelectedItem . unNInt of
--revise1 case w ^? cWorld . lWorld . creatures . ix 0 . crManipulation . manObject . imSelectedItem . unNInt of
Just invid -> useItem invid ltime w
Nothing -> interactWithCloseObj <$> getSelectedCloseObj w ?? w
Just (Sel 0 invid) -> useItem invid ltime w
_ -> interactWithCloseObj <$> getSelectedCloseObj w ?? w