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
+1 -4
View File
@@ -26,10 +26,7 @@ import qualified IntMapHelp as IM
import qualified Data.Map.Strict as M
testStringInit :: Universe -> [String]
testStringInit u =
map show (u ^.. uvWorld . cWorld . lWorld . projectiles . each . pjPos)
<>
map show (u ^.. uvWorld . cWorld . lWorld . projectiles . each . pjVel)
testStringInit u = [show $ u ^? uvWorld . hud . hudElement . diSelection . _Just]
--testStringInit u = foldMap prettyShort $ u ^. uvWorld . cWorld . lWorld . projectiles
-- (map (show . _ebPos) $ u ^. uvWorld . cWorld . lWorld . energyBalls)
-- <>