Implement custom at and ix for NewInt types
This commit is contained in:
@@ -1,6 +1,4 @@
|
||||
module Dodge.AssignHotkey (
|
||||
assignHotkey,
|
||||
) where
|
||||
module Dodge.AssignHotkey (assignHotkey) where
|
||||
|
||||
import Dodge.Data.Equipment.Misc
|
||||
import Control.Lens
|
||||
@@ -11,11 +9,12 @@ import NewInt
|
||||
-- it is not obvious to me whether hotkeys should belong to LWorld, CWorld or
|
||||
-- World
|
||||
assignHotkey :: NewInt ItmInt -> Hotkey -> LWorld -> LWorld
|
||||
assignHotkey (NInt itid) hk lw = lw
|
||||
assignHotkey i hk lw = lw
|
||||
& handleoldposition
|
||||
& hotkeys . at hk ?~ NInt itid
|
||||
& imHotkeys . unNIntMap . at itid ?~ hk
|
||||
& hotkeys . at hk ?~ i
|
||||
-- & imHotkeys . unNIntMap . at itid ?~ hk
|
||||
& imHotkeys . at i ?~ hk
|
||||
where
|
||||
handleoldposition = fromMaybe id $ do
|
||||
olditid <- lw ^? hotkeys . ix hk . unNInt
|
||||
return $ imHotkeys . unNIntMap . at olditid .~ Nothing
|
||||
oldi <- lw ^? hotkeys . ix hk
|
||||
return $ imHotkeys . at oldi .~ Nothing
|
||||
|
||||
Reference in New Issue
Block a user