Move towards removing some default display sections
This commit is contained in:
@@ -164,7 +164,8 @@ defaultDisplayInventory :: HUDElement
|
||||
defaultDisplayInventory =
|
||||
DisplayInventory
|
||||
{ _subInventory = NoSubInventory
|
||||
, _diSections = defaultInvSections
|
||||
--, _diSections = defaultInvSections
|
||||
, _diSections = mempty
|
||||
, _diSelection = Just (1,0)
|
||||
, _diSelectionExtra = mempty
|
||||
, _diInvFilter = mempty
|
||||
|
||||
@@ -7,12 +7,13 @@ module Dodge.DisplayInventory (
|
||||
updateCombinePositioning,
|
||||
) where
|
||||
|
||||
import Data.IntMap.Merge.Strict
|
||||
import Control.Applicative
|
||||
import Control.Lens
|
||||
import Control.Monad
|
||||
import Data.Bifunctor
|
||||
import qualified Data.IntMap.Strict as IM
|
||||
import qualified Data.List as List
|
||||
--import qualified Data.List as List
|
||||
import Data.Maybe
|
||||
import Data.Monoid
|
||||
import Dodge.Base.You
|
||||
@@ -29,7 +30,7 @@ import Dodge.Item.Grammar
|
||||
import Dodge.ListDisplayParams
|
||||
import Dodge.SelectionList
|
||||
import Dodge.SelectionSections
|
||||
import ListHelp
|
||||
import qualified ListHelp as List
|
||||
import Picture.Base
|
||||
|
||||
toggleCombineInv :: Universe -> Universe
|
||||
@@ -54,6 +55,7 @@ updateCombineSections w cfig =
|
||||
(w ^? hud . hudElement . subInventory . ciSelection . _Just)
|
||||
(getAvailableListLines secondColumnParams cfig)
|
||||
[(0, sclose), (-1, sfclose)]
|
||||
(IM.fromAscList [(-1,0),(0,0)])
|
||||
where
|
||||
filtcurs = w ^? hud . hudElement . subInventory . ciSelection . _Just . _1 == Just (-1)
|
||||
(sfclose, sclose) =
|
||||
@@ -76,7 +78,7 @@ regexCombs inv ci str = case str of
|
||||
return $ regexList str' $ _siPictures si'
|
||||
|
||||
andOrRegex :: (a -> String -> Bool) -> a -> String -> Bool
|
||||
andOrRegex f x = all (orRegex f x) . wordsBy '&'
|
||||
andOrRegex f x = all (orRegex f x) . List.wordsBy '&'
|
||||
|
||||
orRegex :: (a -> String -> Bool) -> a -> String -> Bool
|
||||
orRegex f x str = case words str of
|
||||
@@ -126,6 +128,7 @@ updateDisplaySections w cfig =
|
||||
mselpos
|
||||
(getAvailableListLines (invDisplayParams w) cfig)
|
||||
[filtinv, filtclose, invx, youx, closex]
|
||||
(IM.fromAscList [(-1,0),(0,2),(1,0),(2,0),(3,2)])
|
||||
where
|
||||
mselpos = w ^? hud . hudElement . diSelection . _Just
|
||||
invfiltcurs = mselpos ^? _Just . _1 == Just (-1)
|
||||
@@ -196,9 +199,11 @@ displayFreeSlots x = case x of
|
||||
_ -> show x ++ " FREE SLOTS"
|
||||
|
||||
sectionsDesiredLines ::
|
||||
IM.IntMap (SelectionSection a) ->
|
||||
-- IM.IntMap (SelectionSection a) ->
|
||||
IM.IntMap (IM.IntMap (SelectionItem a)) ->
|
||||
IM.IntMap Int
|
||||
sectionsDesiredLines = fmap $ alaf Sum foldMap _siHeight . _ssItems
|
||||
sectionsDesiredLines = fmap $ alaf Sum foldMap _siHeight
|
||||
--sectionsDesiredLines = fmap $ alaf Sum foldMap _siHeight . _ssItems
|
||||
|
||||
sectionsSizes ::
|
||||
Int -> -- total available lines
|
||||
@@ -242,39 +247,44 @@ updateSectionsPositioning ::
|
||||
Maybe (Int, Int) ->
|
||||
Int ->
|
||||
[(Int, IM.IntMap (SelectionItem a))] ->
|
||||
IM.IntMap Int ->
|
||||
IM.IntMap (SelectionSection a) ->
|
||||
IM.IntMap (SelectionSection a)
|
||||
updateSectionsPositioning f mselpos allavailablelines lsss sss =
|
||||
IM.intersectionWith updateSection ls mss `h` ssizes `h` sss
|
||||
updateSectionsPositioning f mselpos allavailablelines lsss indents sss =
|
||||
IM.intersectionWith updateSection ls mss `h` ssizes `g` offsets `h` indents
|
||||
where
|
||||
mss = IM.mapWithKey m sss
|
||||
offsets = fmap _ssOffset sss
|
||||
mss = IM.mapWithKey m ssizes
|
||||
m k _ = do
|
||||
(k', i) <- mselpos
|
||||
guard $ k == k'
|
||||
return i
|
||||
ls = IM.fromList lsss
|
||||
h = IM.intersectionWith ($)
|
||||
g = merge (mapMissing (const ($ 0))) dropMissing (zipWithMatched (const ($)))
|
||||
lk = fromMaybe [] $ fmap ((: []) . fst) mselpos
|
||||
ssizes =
|
||||
sectionsSizes
|
||||
allavailablelines
|
||||
f
|
||||
lk
|
||||
$ sectionsDesiredLines $ IM.intersectionWith (set ssItems) ls sss
|
||||
$ sectionsDesiredLines ls
|
||||
|
||||
updateSection ::
|
||||
IM.IntMap (SelectionItem a) ->
|
||||
Maybe Int ->
|
||||
Int ->
|
||||
SelectionSection a ->
|
||||
Int ->
|
||||
Int ->
|
||||
SelectionSection a
|
||||
updateSection sis mcsel availablelines ss =
|
||||
ss
|
||||
& ssItems .~ sis
|
||||
& ssOffset .~ offset
|
||||
& ssShownItems .~ tweakfirst shownitems
|
||||
updateSection sis mcsel availablelines oldoffset indent =
|
||||
SelectionSection
|
||||
{ _ssItems = sis
|
||||
, _ssOffset = offset
|
||||
, _ssShownItems = tweakfirst shownitems
|
||||
, _ssIndent = indent
|
||||
}
|
||||
where
|
||||
oldoffset = ss ^. ssOffset
|
||||
nocursoroffset =
|
||||
if length allstrings - oldoffset <= availablelines
|
||||
then max 0 (length allstrings - availablelines)
|
||||
@@ -297,7 +307,6 @@ updateSection sis mcsel availablelines ss =
|
||||
_ -> oldoffset
|
||||
tweakfirst (x : xs)
|
||||
| offset > 0 =
|
||||
--color moreupcolor (text (theindent ++ replicate 15 (toEnum 30))) :
|
||||
color moreupcolor (text (replicate 15 (toEnum 30))) :
|
||||
xs
|
||||
| otherwise = x : xs
|
||||
@@ -305,14 +314,12 @@ updateSection sis mcsel availablelines ss =
|
||||
moreupcolor = fromMaybe white $ allstrings ^? ix offset . _1
|
||||
shownitems
|
||||
| length shownstrings > availablelines =
|
||||
map h (take (availablelines - 1) shownstrings)
|
||||
-- ++ [color moredowncolor . text $ theindent ++ replicate 15 (toEnum 31)]
|
||||
map snd (take (availablelines - 1) shownstrings)
|
||||
++ [color moredowncolor . text $ replicate 15 (toEnum 31)]
|
||||
| otherwise = map h shownstrings
|
||||
| otherwise = map snd shownstrings
|
||||
moredowncolor = fromMaybe white $ allstrings ^? ix (offset + availablelines - 1) . _1
|
||||
allstrings = listSelectionColorPicture sis
|
||||
shownstrings = drop offset allstrings
|
||||
h (_, str) = str
|
||||
|
||||
listSelectionColorPicture :: Foldable t => t (SelectionItem a) -> [(Color, Picture)]
|
||||
listSelectionColorPicture = foldMap f
|
||||
@@ -330,8 +337,7 @@ enterCombineInv cfig w =
|
||||
, _ciSelection = selpos
|
||||
, _ciFilter = Nothing
|
||||
}
|
||||
& hud . hudElement . diInvFilter
|
||||
.~ Nothing
|
||||
& hud . hudElement . diInvFilter .~ Nothing
|
||||
where
|
||||
cm' = IM.fromDistinctAscList . zip [0 ..] $ combineList w
|
||||
cm
|
||||
@@ -354,12 +360,8 @@ enterCombineInv cfig w =
|
||||
cm
|
||||
(Just 0)
|
||||
availablelines
|
||||
SelectionSection
|
||||
{ _ssItems = cm
|
||||
, _ssOffset = 0
|
||||
, _ssShownItems = mempty
|
||||
, _ssIndent = 0
|
||||
}
|
||||
0
|
||||
0
|
||||
|
||||
regexList :: String -> [String] -> Bool
|
||||
regexList x = any (isInfixOf x)
|
||||
regexList x = any (List.isInfixOf x)
|
||||
|
||||
Reference in New Issue
Block a user