Move inventory filter to different section of selection list
This commit is contained in:
@@ -23,23 +23,30 @@ import Dodge.Data.World
|
||||
updateDisplayInventory :: World -> Configuration -> SelectionSections () -> SelectionSections ()
|
||||
updateDisplayInventory w cfig sss = case cr ^? crManipulation . manObject of
|
||||
Just (InInventory SortInventory) -> sss
|
||||
{ _sssSections = updateSections availablelines ((-1),0) [filtinv,invx ,youx, closex]
|
||||
, _sssSelPos = Just (-1)
|
||||
}
|
||||
Just (InInventory (SelItem i _)) -> sss
|
||||
{ _sssSections = updateSections availablelines (0,i) [invx ,youx, closex]
|
||||
{ _sssSections = updateSections availablelines (0,i) [filtinv,invx ,youx, closex]
|
||||
, _sssSelPos = Just 0
|
||||
}
|
||||
Just SelNothing -> sss
|
||||
{ _sssSections = updateSections availablelines (1,0) [invx ,youx, closex]
|
||||
{ _sssSections = updateSections availablelines (1,0) [filtinv,invx ,youx, closex]
|
||||
, _sssSelPos = Just 1
|
||||
}
|
||||
Just (SelCloseObject i) -> sss
|
||||
{ _sssSections = updateSections availablelines (2,i) [closex, invx ,youx]
|
||||
{ _sssSections = updateSections availablelines (2,i) [filtinv,closex, invx ,youx]
|
||||
, _sssSelPos = Just 2
|
||||
}
|
||||
_ -> error "error when getting cr inv sel"
|
||||
where
|
||||
filtinv = (-1,(filtinvsec,filtinvitems))
|
||||
filtinvsec = undefined
|
||||
filtinvitems = undefined
|
||||
filtinvsec = fromMaybe defaultFiltSection $ sss ^? sssSections . ix (-1)
|
||||
filtinvitems = case cr ^? crManipulation . invRegex . _Just of
|
||||
Just str -> IM.singleton 0 (SelectionRegex ["INV. FILTER: " ++ str,numfiltitems] 2 True white 0)
|
||||
Nothing -> mempty
|
||||
numfiltitems = " " ++ show numfiltitems' ++ " FILTERED"
|
||||
numfiltitems' = length invitems' - length invitems
|
||||
invx = (0,(invsec, invitems))
|
||||
youx = (1,(yousec, youitems))
|
||||
closex = (2,(cosec, coitems))
|
||||
@@ -50,7 +57,10 @@ updateDisplayInventory w cfig sss = case cr ^? crManipulation . manObject of
|
||||
invsec = fromMaybe defaultInvSection $ sss ^? sssSections . ix 0
|
||||
coitems = IM.fromDistinctAscList . zip [0..]
|
||||
$ map (closeObjectToSelectionItem nfreeslots) (w ^. hud . closeObjects)
|
||||
invitems = IM.mapWithKey (invSelectionItem' cr) inv
|
||||
invitems' = IM.mapWithKey (invSelectionItem' cr) inv
|
||||
invitems = case cr ^? crManipulation . invRegex . _Just of
|
||||
Just str -> IM.filter (regexList str . _siPictures) invitems'
|
||||
Nothing -> invitems'
|
||||
cr = you w
|
||||
inv = _crInv (you w)
|
||||
nfreeslots = crNumFreeSlots cr
|
||||
@@ -75,7 +85,6 @@ defaultSS :: SelectionSection ()
|
||||
defaultSS = SelectionSection
|
||||
{ _ssItems = mempty
|
||||
, _ssCursor = Nothing
|
||||
, _ssRegex = EmptyRegex
|
||||
, _ssMinSize = 5
|
||||
, _ssOffset = 0
|
||||
, _ssShownItems = []
|
||||
@@ -89,6 +98,12 @@ defaultCOSection = defaultSS
|
||||
& ssIndent .~ 2
|
||||
& ssDescriptor .~ "CLOSE OBJECTS"
|
||||
|
||||
defaultFiltSection :: SelectionSection ()
|
||||
defaultFiltSection = defaultSS
|
||||
& ssIndent .~ 0
|
||||
& ssDescriptor .~ "INV"
|
||||
& ssMinSize .~ 0
|
||||
|
||||
defaultInvSection :: SelectionSection ()
|
||||
defaultInvSection = defaultSS
|
||||
& ssDescriptor .~ "INVENTORY ITEMS"
|
||||
@@ -103,20 +118,20 @@ updateSection mspos sis' availablelines ss = ss
|
||||
{ _ssItems = sis
|
||||
, _ssCursor = scurs
|
||||
, _ssOffset = offset
|
||||
, _ssMinSize = 5
|
||||
, _ssShownItems = shownitems
|
||||
}
|
||||
where
|
||||
sis = case _ssRegex ss of
|
||||
Regex str -> IM.insert (-1) (f str) $ IM.filter (regexList str . _siPictures) sis'
|
||||
_ -> sis'
|
||||
f str = SelectionRegex
|
||||
{ _siPictures = ["FILTER: " ++ str]
|
||||
, _siHeight = 1
|
||||
, _siIsSelectable = True
|
||||
, _siColor = white
|
||||
, _siOffX = 0
|
||||
}
|
||||
sis = sis'
|
||||
-- case _ssRegex ss of
|
||||
-- Regex str -> IM.insert (-1) (f str) $ IM.filter (regexList str . _siPictures) sis'
|
||||
-- _ -> sis'
|
||||
-- f str = SelectionRegex
|
||||
-- { _siPictures = ["FILTER: " ++ str]
|
||||
-- , _siHeight = 1
|
||||
-- , _siIsSelectable = True
|
||||
-- , _siColor = white
|
||||
-- , _siOffX = 0
|
||||
-- }
|
||||
oldoffset = ss ^. ssOffset
|
||||
scurs = do
|
||||
csel <- mspos
|
||||
@@ -167,7 +182,7 @@ updateSection mspos sis' availablelines ss = ss
|
||||
yousec :: SelectionSection ()
|
||||
yousec = defaultSS
|
||||
& ssCursor ?~ SectionCursor 0 0 1 invDimColor
|
||||
& ssRegex .~ UnavailableRegex
|
||||
-- & ssRegex .~ UnavailableRegex
|
||||
& ssIndent .~ 2
|
||||
& ssMinSize .~ 1
|
||||
& ssDescriptor .~ "YOUR STATUS"
|
||||
|
||||
Reference in New Issue
Block a user