Start moving hotkeys out from creatures into world

This commit is contained in:
2024-12-19 15:16:47 +00:00
parent 11b5ef74c5
commit 4526119fcd
11 changed files with 131 additions and 108 deletions
+5 -3
View File
@@ -40,9 +40,10 @@ yourControl _ w
handleHotkeys :: World -> World
handleHotkeys w
| SDL.ButtonRight `M.member` _mouseButtons (_input w) = foldl' tryAssignHotkey w allHotkeys
| otherwise = foldl' useHotKey w (M.intersection hotkeys (w ^. input . pressedKeys))
| otherwise = foldl' useHotKey w (M.intersection thehotkeys (w ^. input . pressedKeys))
where
hotkeys = M.mapKeys hotkeyToScancode $ w ^?! cWorld . lWorld . creatures . ix 0 . crHotkeys
--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
@@ -87,7 +88,8 @@ tryAssignHotkey w sc = fromMaybe w $ do
guard (pt == InitialPress)
cr <- w ^? cWorld . lWorld . creatures . ix 0
itid <- cr ^? crManipulation . manObject . imSelectedItem
return $ w & cWorld . lWorld . creatures . ix 0 %~ assignHotkey itid (scancodeToHotkey sc)
--return $ w & cWorld . lWorld . creatures . ix 0 %~ assignHotkey itid (scancodeToHotkey sc)
return $ w & cWorld . lWorld %~ assignHotkey itid (scancodeToHotkey sc)
{- | The order of these MAY be important, in particular the setting of crMvAim
within wasdMovement should probably be done first