Implement simple indenting in selection menu

This commit is contained in:
2024-09-12 18:14:52 +01:00
parent 4dedba8d30
commit e69abf1715
8 changed files with 226 additions and 217 deletions
+3 -8
View File
@@ -9,10 +9,9 @@ module Dodge.DisplayInventory (
updateCombinePositioning,
) where
import Dodge.Data.DoubleTree
import Control.Monad
import qualified Data.IntMap.Strict as IM
import qualified Data.IntMap.Merge.Strict as MIM
--import qualified Data.IntMap.Merge.Strict as MIM
import Data.Maybe
import Dodge.Base.You
import Dodge.Combine
@@ -116,9 +115,8 @@ updateDisplaySections w cfig sss =
map closeObjectToSelectionItem (w ^. hud . closeObjects)
--invitems' = MIM.merge MIM.dropMissing MIM.dropMissing (MIM.zipWithMatched $ const addindent) indents $ IM.mapWithKey (invSelectionItem cr) inv
invitems' = IM.mapWithKey (invSelectionItem cr) inv
addindent x y = y & siPictures %~ map (x ++)
cr = you w
inv = _crInv (you w)
inv = invIndentIM $ _crInv (you w)
--indents = indentInv inv
--inv = indentInv $ _crInv (you w)
nfreeslots = crNumFreeSlots cr
@@ -150,7 +148,7 @@ updateInventorySectionItems w =
where
f olditems = fromMaybe olditems $ do
cr <- w ^? cWorld . lWorld . creatures . ix 0
invitms <- IM.mapWithKey (invSelectionItem cr) <$> cr ^? crInv
invitms <- IM.mapWithKey (invSelectionItem' cr) <$> cr ^? crInv
return $ case w ^? hud . hudElement . diSections . sssExtra . sssFilters . ix (-1) . _Just of
Just str -> IM.filter (plainRegex str) invitms
_ -> invitms
@@ -250,9 +248,6 @@ updateSection sis mcsel availablelines ss =
h (_, str) = translate (fromIntegral (_ssIndent ss) * 100) 0 str
theindent = replicate (_ssIndent ss) ' '
displaySelectionSection :: SelectionSection a -> Picture
displaySelectionSection ss = undefined
listSelectionColorPicture :: Foldable t => t (SelectionItem a) -> [(Color,Picture)]
listSelectionColorPicture = foldMap f
where