Allow jumping to hotkey selection

This commit is contained in:
2025-01-01 12:04:39 +00:00
parent 91111fc89c
commit 0915e04b56
2 changed files with 8 additions and 4 deletions
+7
View File
@@ -2,6 +2,7 @@ module Dodge.Creature.YourControl (
yourControl,
) where
import Dodge.Inventory
import Data.Foldable
import qualified Data.Map.Strict as M
import Data.Maybe
@@ -40,6 +41,12 @@ handleHotkeys w
invid <- w ^? cWorld . lWorld . creatures . ix 0 . crManipulation . manObject . imSelectedItem
itid <- w ^? cWorld . lWorld . creatures . ix 0 . crInv . ix invid . itID
return $ w & cWorld . lWorld %~ \lw -> foldl' (flip $ assignHotkey itid) lw hks
| SDL.ScancodeLCtrl `M.member` _pressedKeys (_input w)
|| SDL.ScancodeRCtrl `M.member` _pressedKeys (_input w) = fromMaybe w $ do
hk <- listToMaybe . mapMaybe scancodeToHotkey $ M.keys $ w ^. input . pressedKeys
itid <- w ^? cWorld . lWorld . hotkeys . ix hk . unNInt
invid <- w ^? cWorld . lWorld . itemLocations . ix itid . ilInvID
return $ w & augInvDirectSelect (0,invid,mempty)
| otherwise =
M.foldl'
useHotkey