Allow filtering of combinations with mouse click on inventory
This commit is contained in:
@@ -5,10 +5,10 @@ module Dodge.DisplayInventory (
|
||||
updateCombinePositioning,
|
||||
) where
|
||||
|
||||
import Data.Bifunctor
|
||||
import Dodge.Inventory
|
||||
import Control.Applicative
|
||||
import Control.Lens
|
||||
import Control.Monad
|
||||
import Data.Bifunctor
|
||||
import qualified Data.IntMap.Strict as IM
|
||||
import Data.Maybe
|
||||
import Dodge.Base.You
|
||||
@@ -18,10 +18,12 @@ import Dodge.Data.Config
|
||||
import Dodge.Data.DoubleTree
|
||||
import Dodge.Data.SelectionList
|
||||
import Dodge.Data.Universe
|
||||
import Dodge.Inventory
|
||||
import Dodge.Inventory.SelectionList
|
||||
import Dodge.Item.Grammar
|
||||
import Dodge.ListDisplayParams
|
||||
import Dodge.SelectionList
|
||||
import Dodge.SelectionSections
|
||||
import ListHelp
|
||||
import Picture.Base
|
||||
|
||||
@@ -29,13 +31,14 @@ toggleCombineInv :: Universe -> Universe
|
||||
toggleCombineInv uv = case uv ^? uvWorld . hud . hudElement . subInventory of
|
||||
Just CombineInventory{} ->
|
||||
uv & uvWorld . hud . hudElement . subInventory
|
||||
.~ NoSubInventory MouseInvNothing Nothing
|
||||
.~ NoSubInventory MouseInvNothing
|
||||
_ -> uv & uvWorld %~ enterCombineInv (uv ^. uvConfig)
|
||||
|
||||
updateCombinePositioning :: Universe -> Universe
|
||||
updateCombinePositioning u =
|
||||
u & uvWorld . hud . hudElement . subInventory . ciSections
|
||||
%~ updateCombineSections (_uvWorld u) (_uvConfig u)
|
||||
& checkCombineSelectionExists
|
||||
|
||||
updateCombineSections ::
|
||||
World ->
|
||||
@@ -87,11 +90,24 @@ updateInventoryPositioning u =
|
||||
-- this is possibly not completely correct
|
||||
checkInventorySelectionExists :: Universe -> Universe
|
||||
checkInventorySelectionExists u = fromMaybe u $ do
|
||||
(i,j) <- u ^? uvWorld . hud . hudElement . diSelection . _Just
|
||||
(i, j) <- (u ^? uvWorld . hud . hudElement . diSelection . _Just) <|> Just (0, -1)
|
||||
Just $ case u ^? uvWorld . hud . hudElement . diSections . ix i . ssItems . ix j of
|
||||
Nothing -> u & uvWorld %~ scrollAugNextInSection
|
||||
_ -> u
|
||||
|
||||
checkCombineSelectionExists :: Universe -> Universe
|
||||
checkCombineSelectionExists u = fromMaybe u $ do
|
||||
sss <- u ^? uvWorld . hud . hudElement . subInventory . ciSections
|
||||
(i, j) <-
|
||||
u ^? uvWorld . hud . hudElement . subInventory . ciSelection . _Just
|
||||
<|> Just (0, 0)
|
||||
Just $ case u ^? uvWorld . hud . hudElement . subInventory . ciSections . ix i . ssItems . ix j of
|
||||
Nothing ->
|
||||
u & uvWorld . hud . hudElement . subInventory . ciSelection ?~ (0,-1)
|
||||
& uvWorld . hud . hudElement . subInventory . ciSelection
|
||||
%~ scrollSelectionSections (-1) sss
|
||||
_ -> u
|
||||
|
||||
updateDisplaySections ::
|
||||
World ->
|
||||
Configuration ->
|
||||
@@ -137,9 +153,10 @@ updateDisplaySections w cfig =
|
||||
(fmap (first removeindentiffiltering) . allInvLocs $ _crInv cr)
|
||||
-- this clearly deserves refactoring, also check if drawInventory/iextra
|
||||
-- needs it at the same time
|
||||
removeindentiffiltering = if maybe False isFilteringInv (w ^? hud . hudElement . diSections)
|
||||
then const 0
|
||||
else id
|
||||
removeindentiffiltering =
|
||||
if maybe False isFilteringInv (w ^? hud . hudElement . diSections)
|
||||
then const 0
|
||||
else id
|
||||
cr = you w
|
||||
|
||||
filterSectionsPair ::
|
||||
@@ -275,6 +292,8 @@ enterCombineInv cfig w =
|
||||
sss
|
||||
selpos
|
||||
Nothing
|
||||
& hud . hudElement . diInvFilter
|
||||
.~ Nothing
|
||||
where
|
||||
cm' = IM.fromDistinctAscList . zip [0 ..] $ combineList w
|
||||
cm
|
||||
|
||||
Reference in New Issue
Block a user