Simplify check if inventory selection exists

This commit is contained in:
2024-11-26 17:20:07 +00:00
parent e1f5049e0f
commit dc5c62e8ff
2 changed files with 59 additions and 59 deletions
+4 -3
View File
@@ -92,11 +92,12 @@ 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, mempty)
Just $ case u ^? uvWorld . hud . hudElement . diSections . ix i . ssItems . ix j of
checkInventorySelectionExists u = case u ^? uvWorld . hud . hudElement . diSections . ix i . ssItems . ix j of
Nothing -> u & uvWorld %~ scrollAugNextInSection
_ -> u
where
(i,j,_) = fromMaybe (0,-1,mempty)
$ u ^? uvWorld . hud . hudElement . diSelection . _Just
checkCombineSelectionExists :: Universe -> Universe
checkCombineSelectionExists u = fromMaybe u $ do