Cleanup
This commit is contained in:
@@ -8,13 +8,13 @@ module Dodge.DisplayInventory (
|
||||
toggleCombineInv,
|
||||
) where
|
||||
|
||||
import Data.IntSet (IntSet)
|
||||
import Control.Applicative
|
||||
import Control.Lens
|
||||
import Control.Monad
|
||||
import Data.Bifunctor
|
||||
import Data.IntMap.Merge.Strict
|
||||
import qualified Data.IntMap.Strict as IM
|
||||
import Data.IntSet (IntSet)
|
||||
import Data.Maybe
|
||||
import Data.Monoid
|
||||
import Dodge.Base.You
|
||||
@@ -86,28 +86,26 @@ updateInventoryPositioning :: Universe -> Universe
|
||||
updateInventoryPositioning u =
|
||||
u & uvWorld . hud . hudElement . diSections
|
||||
%~ updateDisplaySections (_uvWorld u) (_uvConfig u)
|
||||
& checkInventorySelectionExists
|
||||
& uvWorld
|
||||
%~ checkInventorySelectionExists
|
||||
|
||||
checkInventorySelectionExists :: Universe -> Universe
|
||||
checkInventorySelectionExists u =
|
||||
case u ^? uvWorld . hud . hudElement . diSections . ix i . ssItems . ix j of
|
||||
Nothing -> u & uvWorld %~ scrollAugNextInSection
|
||||
_ -> u
|
||||
checkInventorySelectionExists :: World -> World
|
||||
checkInventorySelectionExists w =
|
||||
case w ^? hud . hudElement . diSections . ix i . ssItems . ix j of
|
||||
Nothing -> scrollAugNextInSection w
|
||||
_ -> w
|
||||
where
|
||||
(i, j, _) =
|
||||
fromMaybe (1, -1, mempty) $
|
||||
u ^? uvWorld . hud . hudElement . diSelection . _Just
|
||||
(i, j, _) = fromMaybe (1, -1, mempty) $ w ^? hud . hudElement . diSelection . _Just
|
||||
|
||||
checkCombineSelectionExists :: SubInventory -> SubInventory
|
||||
checkCombineSelectionExists u = fromMaybe u $ do
|
||||
sss <- u ^? ciSections
|
||||
(i, j, _) <- u ^? ciSelection . _Just <|> Just (0, 0, mempty)
|
||||
Just $ case u ^? ciSections . ix i . ssItems . ix j of
|
||||
Nothing ->
|
||||
u & ciSelection ?~ (0, -1, mempty)
|
||||
& ciSelection
|
||||
%~ scrollSelectionSections (-1) sss
|
||||
_ -> u
|
||||
checkCombineSelectionExists si
|
||||
| Just sss <- si ^? ciSections
|
||||
, Just (i, j, _) <- si ^? ciSelection . _Just <|> Just (0, 0, mempty)
|
||||
, isNothing $ si ^? ciSections . ix i . ssItems . ix j =
|
||||
si & ciSelection ?~ (0, -1, mempty)
|
||||
& ciSelection
|
||||
%~ scrollSelectionSections (-1) sss
|
||||
| otherwise = si
|
||||
|
||||
displaySectionsSizes :: Int -> Int
|
||||
displaySectionsSizes 0 = 10
|
||||
|
||||
Reference in New Issue
Block a user