Make inventory cursor change when dropping items sensible
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
module Dodge.SelectionSections (
|
||||
scrollSelectionSections,
|
||||
nextInSectionSS,
|
||||
ssLookupDown,
|
||||
ssLookupGT,
|
||||
ssSetCursor,
|
||||
@@ -35,6 +36,12 @@ scrollSelectionSections yi sss msel
|
||||
| yi > 0 = foldl' (&) msel $ replicate yi (ssScrollUsing ssLookupUp sss)
|
||||
| otherwise = foldl' (&) msel $ replicate (negate yi) (ssScrollUsing ssLookupDown sss)
|
||||
|
||||
nextInSectionSS ::
|
||||
IM.IntMap (SelectionSection a) ->
|
||||
Maybe (Int, Int) ->
|
||||
Maybe (Int, Int)
|
||||
nextInSectionSS sss = ssScrollUsing ssLookupNextMax sss
|
||||
|
||||
--setFirstPosSelectionSections :: SelectionSections a -> SelectionSections a
|
||||
--setFirstPosSelectionSections sss = fromMaybe sss $ do
|
||||
-- (i, j, _) <- ssLookupMin sss
|
||||
@@ -93,6 +100,22 @@ ssLookupDown i j sss = case ssLookupGT i j sss of
|
||||
Nothing -> ssLookupMin sss
|
||||
x -> x
|
||||
|
||||
ssLookupNextMax ::
|
||||
Int ->
|
||||
Int ->
|
||||
IM.IntMap (SelectionSection a) ->
|
||||
Maybe (Int, Int, SelectionItem a)
|
||||
ssLookupNextMax i j sss = case ssLookupGT i j sss of
|
||||
Just x@(i',j',_) | i' == i && j' > j -> Just x
|
||||
_ -> ssLookupMaxInSection i sss <|> ssLookupDown i j sss
|
||||
|
||||
ssLookupMaxInSection :: Int -> IM.IntMap (SelectionSection a) ->
|
||||
Maybe (Int, Int, SelectionItem a)
|
||||
ssLookupMaxInSection i sss = do
|
||||
ss <- sss ^? ix i . ssItems
|
||||
(j,s) <- IM.lookupMax ss
|
||||
return (i,j,s)
|
||||
|
||||
ssLookupLT ::
|
||||
Int ->
|
||||
Int ->
|
||||
|
||||
Reference in New Issue
Block a user