Make hotkeys assignable to any item, use item id

This commit is contained in:
2024-12-31 09:20:53 +00:00
parent 1e7dcbfded
commit e12e4777b2
8 changed files with 37 additions and 59 deletions
+2 -1
View File
@@ -32,7 +32,8 @@ invSelectionItem indent lw i ci =
}
where
cr = lw ^?! creatures . ix 0
anyhotkey = maybe [] ((' ' :) . hotkeyToString) (lw ^? imHotkeys . ix i)
itid = ci ^. _1 . itID . unNInt
anyhotkey = maybe [] ((' ' :) . hotkeyToString) (lw ^? imHotkeys . unNIntMap . ix itid)
anyequippos = maybe [] (rightPad 8 ' ' . (' ' :) . eqPosText)
(ci ^? _1 . itLocation . ilEquipSite . _Just)
col = itemInvColor ci
+8 -8
View File
@@ -34,7 +34,7 @@ swapInvItems f i w = fromMaybe w $ do
& swapAnyExtraSelection i k
& checkConnection InventorySound disconnectItemS i k
& cWorld . lWorld . creatures . ix 0 %~ updatecreature k
& swaphotkeys k
--x & swaphotkeys k
& updateselection
& worldEventFlags . at InventoryChange ?~ ()
& cWorld . lWorld %~ crUpdateItemLocations 0
@@ -59,19 +59,19 @@ swapInvItems f i w = fromMaybe w $ do
. swapSite i k
. swapSite k i
-- . (crInvHotkeys %~ IM.safeSwapKeys i k)
swaphotkeys k =
swapSite' i k
. swapSite' k i
. (cWorld . lWorld . imHotkeys %~ IM.safeSwapKeys i k)
--x swaphotkeys k =
--x swapSite' i k
--x . swapSite' k i
--x . (cWorld . lWorld . imHotkeys %~ IM.safeSwapKeys i k)
cr = you w
--swapSite a b = case cr ^? crInvEquipped . ix a of
swapSite a b = case cr ^? crInv . ix a . itLocation . ilEquipSite . _Just of
Just epos -> crEquipment . ix epos .~ b
Nothing -> id
--swapSite' a b = case cr ^? crInvHotkeys . ix a of
swapSite' a b = case w ^? cWorld . lWorld . imHotkeys . ix a of
Just epos -> cWorld . lWorld . hotkeys . ix epos .~ b
Nothing -> id
--x swapSite' a b = case w ^? cWorld . lWorld . imHotkeys . ix a of
--x Just epos -> cWorld . lWorld . hotkeys . ix epos .~ b
--x Nothing -> id
swapAnyExtraSelection :: Int -> Int -> World -> World
swapAnyExtraSelection i k w = fromMaybe w $ do