Move hotkeys out of Creature into LWorld

This commit is contained in:
2024-12-19 15:29:20 +00:00
parent 4526119fcd
commit 910c683eac
11 changed files with 24 additions and 19 deletions
+4 -4
View File
@@ -41,16 +41,16 @@ assignHotkey invid hk lw = fromMaybe lw $ do
moveOldHotkey :: Int -> Hotkey -> LWorld -> LWorld
moveOldHotkey invid hk w = fromMaybe w $ do
oldhk <- w ^? creatures . ix 0 . crInvHotkeys . ix invid
oldhk <- w ^? imHotkeys . ix invid
oldid <- w ^? hotkeys . ix hk
return $ w & setHotkey oldid oldhk
setHotkey :: Int -> Hotkey -> LWorld -> LWorld
setHotkey i hk = (creatures . ix 0 . crInvHotkeys . at i ?~ hk) . (hotkeys . at hk ?~ i)
setHotkey i hk = (imHotkeys . at i ?~ hk) . (hotkeys . at hk ?~ i)
removeHotkey :: Int -> LWorld -> LWorld
removeHotkey invid w = w & creatures . ix 0 . crInvHotkeys . at invid .~ Nothing
removeHotkey invid w = w & imHotkeys . at invid .~ Nothing
& fromMaybe id (do
hk <- w ^? creatures . ix 0 . crInvHotkeys . ix invid
hk <- w ^? imHotkeys . ix invid
return (hotkeys . at hk .~ Nothing)
)