diff --git a/src/Dodge/Creature/YourControl.hs b/src/Dodge/Creature/YourControl.hs index 00d028297..4f0927484 100644 --- a/src/Dodge/Creature/YourControl.hs +++ b/src/Dodge/Creature/YourControl.hs @@ -40,7 +40,8 @@ yourControl _ w handleHotkeys :: World -> World handleHotkeys w | ispressed SDL.ScancodeLShift || ispressed SDL.ScancodeRShift - , Just hk <- listToMaybe . mapMaybe scancodeToHotkey . M.keys $ w ^. input . pressedKeys + , Just hk <- + listToMaybe . mapMaybe scancodeToHotkey . M.keys $ w ^. input . pressedKeys , Just invid <- lw ^? creatures . ix 0 . crManipulation . manObject . imSelectedItem , Just itid <- lw ^? creatures . ix 0 . crInv . ix invid . itID = w & cWorld . lWorld %~ assignHotkey itid hk @@ -50,7 +51,7 @@ handleHotkeys w w ^. input . pressedKeys , Just itid <- lw ^? hotkeys . ix hk . unNInt , Just invid <- lw ^? itemLocations . ix itid . ilInvID = - w & augInvDirectSelect (0, invid, mempty) + w & invSetSelectionPos 0 invid | otherwise = M.foldl' useHotkey diff --git a/src/Dodge/Inventory.hs b/src/Dodge/Inventory.hs index 9c2059a0d..50b1a37cf 100644 --- a/src/Dodge/Inventory.hs +++ b/src/Dodge/Inventory.hs @@ -4,7 +4,8 @@ module Dodge.Inventory ( destroyInvItem, updateCloseObjects, changeSwapSel, - augInvDirectSelect, + invSetSelection, + invSetSelectionPos, scrollAugInvSel, crNumFreeSlots, setInvPosFromSS, @@ -176,14 +177,25 @@ changeSwapWith f w = case w ^? hud . hudElement . diSelection . _Just of Just (5, i, _) -> w & changeSwapOther ispCloseButton 5 f i _ -> w -augInvDirectSelect :: (Int, Int, IS.IntSet) -> World -> World -augInvDirectSelect sel w = +invSetSelection :: (Int, Int, IS.IntSet) -> World -> World +invSetSelection sel w = w & hud . hudElement . diSelection ?~ sel & worldEventFlags . at InventoryChange ?~ () & setInvPosFromSS & cWorld . lWorld %~ crUpdateItemLocations 0 +invSetSelectionPos :: Int -> Int -> World -> World +invSetSelectionPos i j w = + w + & hud . hudElement . diSelection %~ f + & worldEventFlags . at InventoryChange ?~ () + & setInvPosFromSS + & cWorld . lWorld %~ crUpdateItemLocations 0 + where + f Nothing = Just (i,j,mempty) + f (Just (_,_,s)) = Just (i,j,s) + scrollAugInvSel :: Int -> World -> World scrollAugInvSel yi w | yi == 0 = w diff --git a/src/Dodge/Update/Input/InGame.hs b/src/Dodge/Update/Input/InGame.hs index edd11b343..4c21db9f8 100644 --- a/src/Dodge/Update/Input/InGame.hs +++ b/src/Dodge/Update/Input/InGame.hs @@ -175,7 +175,7 @@ updateMouseReleaseInGame w = case w ^. input . mouseContext of & hud . hudElement . diSelection . _Just . _3 %~ const mempty OverInvDragSelect ssel (Just esel) -> w & input . mouseContext .~ MouseInGame - & augInvDirectSelect (f (fst ssel, esel) (h ssel esel)) + & invSetSelection (f (fst ssel, esel) (h ssel esel)) _ -> w where getuniques x y = IS.union x y IS.\\ IS.intersection x y @@ -278,7 +278,7 @@ startDrag :: (Int, Int) -> Configuration -> World -> World startDrag (a, b) cfig w = setcontext $ case w ^? hud . hudElement . diSelection . _Just of Just (i,_,xs) | i == a && b `IS.member` xs -> w - _ -> augInvDirectSelect (a, b, IS.singleton b) w + _ -> invSetSelection (a, b, IS.singleton b) w where setcontext = input . mouseContext .~ OverInvDrag a (Just (a, b)) above bneath above = inverseSelSecYint (yint - 1) =<< w ^? hud . hudElement . diSections