Allow scrolling within a larger selection to not remove larger selection

This commit is contained in:
2024-11-25 17:20:09 +00:00
parent 83bcf3c0f7
commit 669f9667f1
16 changed files with 233 additions and 200 deletions
+7 -7
View File
@@ -52,7 +52,7 @@ updateCombineSections w cfig =
updateSectionsPositioning
(const 5)
(const 0)
(w ^? hud . hudElement . subInventory . ciSelection . _Just)
(fmap (\(x,y,_) -> (x,y)) $ w ^? hud . hudElement . subInventory . ciSelection . _Just)
(getAvailableListLines secondColumnParams cfig)
[(0, sclose), (-1, sfclose)]
where
@@ -93,7 +93,7 @@ updateInventoryPositioning u =
-- this is possibly not completely correct
checkInventorySelectionExists :: Universe -> Universe
checkInventorySelectionExists u = fromMaybe u $ do
(i, j) <- (u ^? uvWorld . hud . hudElement . diSelection . _Just) <|> Just (0, -1)
(i, j,_) <- (u ^? uvWorld . hud . hudElement . diSelection . _Just) <|> Just (0, -1, mempty)
Just $ case u ^? uvWorld . hud . hudElement . diSections . ix i . ssItems . ix j of
Nothing -> u & uvWorld %~ scrollAugNextInSection
_ -> u
@@ -101,12 +101,12 @@ checkInventorySelectionExists u = fromMaybe u $ do
checkCombineSelectionExists :: Universe -> Universe
checkCombineSelectionExists u = fromMaybe u $ do
sss <- u ^? uvWorld . hud . hudElement . subInventory . ciSections
(i, j) <-
(i, j, _) <-
u ^? uvWorld . hud . hudElement . subInventory . ciSelection . _Just
<|> Just (0, 0)
<|> Just (0, 0, mempty)
Just $ case u ^? uvWorld . hud . hudElement . subInventory . ciSections . ix i . ssItems . ix j of
Nothing ->
u & uvWorld . hud . hudElement . subInventory . ciSelection ?~ (0, -1)
u & uvWorld . hud . hudElement . subInventory . ciSelection ?~ (0, -1,mempty)
& uvWorld . hud . hudElement . subInventory . ciSelection
%~ scrollSelectionSections (-1) sss
_ -> u
@@ -137,7 +137,7 @@ updateDisplaySections w cfig =
[statushead,statusdisplay,invhead,invx,youx, nearbyhead, closex
,interfaceshead,interfaces]
where
mselpos = w ^? hud . hudElement . diSelection . _Just
mselpos = fmap (\(x,y,_) -> (x,y)) $ w ^? hud . hudElement . diSelection . _Just
invfiltcurs = mselpos ^? _Just . _1 == Just (-1)
(sfinv, sinv) =
filterSectionsPair invfiltcurs plainRegex invitems "INVENTORY" $
@@ -356,7 +356,7 @@ enterCombineInv cfig w =
| otherwise = cm'
selpos
| null cm' = Nothing
| otherwise = Just (0, 0)
| otherwise = Just (0, 0,mempty)
filtsection =
SelectionSection
{ _ssItems = mempty