Simplify selection menu, remove overlapping
This commit is contained in:
@@ -77,7 +77,7 @@ combineItemListYouX = map (first $ concat) . flatLookupItems . yourInv
|
||||
|
||||
combineList :: World -> [SelectionItem CombinableItem]
|
||||
combineList w = case combineList' w of
|
||||
[] -> [SelectionInfo ["No possible combinations"] 1 False white 0 0]
|
||||
[] -> [SelectionInfo ["No possible combinations"] 1 False white 0]
|
||||
xs -> xs
|
||||
|
||||
combineList' :: World -> [SelectionItem CombinableItem]
|
||||
@@ -90,7 +90,6 @@ combineList' = map f . combineListInfo
|
||||
, _siIsSelectable = True
|
||||
, _siColor = itemInvColor itm
|
||||
, _siOffX = 0
|
||||
, _siOffY = 0
|
||||
, _siPayload = CombinableItem is itm strs
|
||||
}
|
||||
|
||||
|
||||
@@ -90,7 +90,6 @@ data SelectionItem a
|
||||
, _siIsSelectable :: Bool
|
||||
, _siColor :: Color
|
||||
, _siOffX :: Int
|
||||
, _siOffY :: Int
|
||||
, _siPayload :: a
|
||||
}
|
||||
| SelectionInfo
|
||||
@@ -99,7 +98,6 @@ data SelectionItem a
|
||||
, _siIsSelectable :: Bool
|
||||
, _siColor :: Color
|
||||
, _siOffX :: Int
|
||||
, _siOffY :: Int
|
||||
}
|
||||
|
||||
makeLenses ''ListDisplayParams
|
||||
|
||||
@@ -55,14 +55,14 @@ updateCombineSections w cfig sss =
|
||||
invitms <- w ^? hud . hudElement . diSections . sssSections . ix 0 . ssItems
|
||||
return $ IM.filter (flip (andOrRegex $ regexCombs invitms) str) allcombs
|
||||
showncombs
|
||||
| null filtcombs = IM.singleton 0 $ SelectionInfo ["No possible combinations"] 1 False white 0 0
|
||||
| null filtcombs = IM.singleton 0 $ SelectionInfo ["No possible combinations"] 1 False white 0
|
||||
| otherwise = filtcombs
|
||||
filtinv = fromMaybe mempty $ do
|
||||
str <- mstr
|
||||
return $
|
||||
IM.singleton
|
||||
0
|
||||
(SelectionInfo ["COMBINATIONS FILTER: " ++ str, numfiltitems] 2 True white 0 0)
|
||||
(SelectionInfo ["COMBINATIONS FILTER: " ++ str, numfiltitems] 2 True white 0)
|
||||
mstr = w ^? hud . hudElement . subInventory . ciSections . sssExtra . sssFilters . ix (-1) . _Just
|
||||
numfiltitems = " " ++ show (length allcombs - length filtcombs) ++ " FILTERED"
|
||||
|
||||
@@ -107,7 +107,7 @@ updateDisplaySections w cfig sss =
|
||||
(filtinv, invx) = filtpair (-1) invitems' "INV. "
|
||||
(filtclose, closex) = filtpair 2 coitems' "NEARBY "
|
||||
youx = (1, youitems)
|
||||
youitems = IM.singleton 0 $ SelectionItem [thetext] 1 True invDimColor 2 0 ()
|
||||
youitems = IM.singleton 0 $ SelectionItem [thetext] 1 True invDimColor 2 ()
|
||||
thetext = displayFreeSlots nfreeslots
|
||||
availablelines = getAvailableListLines (invDisplayParams w) cfig
|
||||
coitems' =
|
||||
@@ -131,7 +131,7 @@ updateDisplaySections w cfig sss =
|
||||
return $
|
||||
IM.singleton
|
||||
0
|
||||
(SelectionInfo [filtdescription ++ "FILTER: " ++ str, numfiltitems] 2 True white 0 0)
|
||||
(SelectionInfo [filtdescription ++ "FILTER: " ++ str, numfiltitems] 2 True white 0)
|
||||
itms' = fromMaybe itms $ do
|
||||
str <- mstr
|
||||
return $ IM.filter (plainRegex str) itms
|
||||
@@ -246,25 +246,33 @@ updateSection sis mcsel availablelines ss =
|
||||
| otherwise = tweakfirst shownstrings
|
||||
moredowncolor = fromMaybe white $ allstrings ^? ix (offset + availablelines - 1) . _1
|
||||
allstrings :: [(Color, Picture)]
|
||||
allstrings = IM.elems $ overlapSelectionItems $ IM.elems sis
|
||||
-- allstrings = IM.elems $ overlapSelectionItems $ IM.elems sis
|
||||
allstrings = listSelectionColorPicture sis
|
||||
shownstrings = drop offset allstrings
|
||||
h (_, str) = translate (fromIntegral (_ssIndent ss) * 100) 0 str
|
||||
theindent = replicate (_ssIndent ss) ' '
|
||||
--xtra str = color white . text $ theindent ++ str ++ " MORE " ++ _ssDescriptor ss
|
||||
|
||||
overlapSelectionItems :: [SelectionItem a] -> IM.IntMap (Color, Picture)
|
||||
overlapSelectionItems = go 0
|
||||
listSelectionColorPicture :: Foldable t => t (SelectionItem a) -> [(Color,Picture)]
|
||||
listSelectionColorPicture = foldMap f
|
||||
where
|
||||
go _ [] = mempty
|
||||
go i (si : xs) = doinsert $ go (i + _siHeight si) xs
|
||||
where
|
||||
thecol = _siColor si
|
||||
doinsert m =
|
||||
ifoldr
|
||||
(\j str -> IM.insertWith ihelp (i + j + _siOffY si) (thecol,color thecol (text str)))
|
||||
m
|
||||
(_siPictures si)
|
||||
ihelp (_,x) (col,y) = ( col, x<>y)
|
||||
f si = map g (_siPictures si)
|
||||
where
|
||||
g str = (_siColor si,color (_siColor si) $ text str)
|
||||
|
||||
--overlapSelectionItems :: [SelectionItem a] -> IM.IntMap (Color, Picture)
|
||||
--overlapSelectionItems = go 0
|
||||
-- where
|
||||
-- go _ [] = mempty
|
||||
-- go i (si : xs) = doinsert $ go (i + _siHeight si) xs
|
||||
-- where
|
||||
-- thecol = _siColor si
|
||||
-- doinsert m =
|
||||
-- ifoldr
|
||||
-- (\j str -> IM.insertWith ihelp (i + j) (thecol,color thecol (text str)))
|
||||
-- m
|
||||
-- (_siPictures si)
|
||||
-- ihelp (_,x) (col,y) = ( col, x<>y)
|
||||
|
||||
enterCombineInv :: Configuration -> World -> World
|
||||
enterCombineInv cfig w =
|
||||
@@ -275,7 +283,7 @@ enterCombineInv cfig w =
|
||||
where
|
||||
cm' = IM.fromAscList $ zip [0 ..] $ combineList' w
|
||||
cm
|
||||
| null cm' = IM.singleton 0 $ SelectionInfo ["No possible combinations"] 1 False white 0 0
|
||||
| null cm' = IM.singleton 0 $ SelectionInfo ["No possible combinations"] 1 False white 0
|
||||
| otherwise = cm'
|
||||
sss =
|
||||
SelectionSections
|
||||
@@ -292,7 +300,7 @@ enterCombineInv cfig w =
|
||||
availablelines = getAvailableListLines secondColumnParams cfig
|
||||
filtsection =
|
||||
SelectionSection
|
||||
{ _ssItems = IM.singleton 0 $ SelectionInfo ["No possible combinations"] 1 False white 0 0
|
||||
{ _ssItems = IM.singleton 0 $ SelectionInfo ["No possible combinations"] 1 False white 0
|
||||
, _ssCursor = Nothing
|
||||
, _ssMinSize = 0
|
||||
, _ssOffset = 0
|
||||
|
||||
@@ -21,16 +21,15 @@ invSelectionItem cr i it =
|
||||
, _siIsSelectable = True
|
||||
, _siColor = col
|
||||
, _siOffX = 0
|
||||
, _siOffY = yoff
|
||||
, _siPayload = ()
|
||||
}
|
||||
where
|
||||
anyhotkey = maybe [] ((' ':) .hotkeyToString) (cr ^? crInvHotkeys . ix i)
|
||||
anyequippos = maybe [] (rightPad 8 ' ' . (' ':) . eqPosText) (cr ^? crInvEquipped . ix i)
|
||||
col = itemInvColor it
|
||||
(yoff,pics) = case _itCurseStatus it of
|
||||
UndroppableIdentified -> itemDisplayOffset cr it
|
||||
_ -> itemDisplayOffset cr it
|
||||
pics = case _itCurseStatus it of
|
||||
UndroppableIdentified -> itemDisplay cr it
|
||||
_ -> itemDisplay cr it
|
||||
|
||||
hotkeyToString :: Hotkey -> String
|
||||
hotkeyToString x = case x of
|
||||
@@ -56,7 +55,6 @@ closeObjectToSelectionItem e =
|
||||
, --, _siWidth = 15
|
||||
_siColor = col
|
||||
, _siOffX = 2
|
||||
, _siOffY = 0
|
||||
, _siPayload = ()
|
||||
}
|
||||
where
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
module Dodge.Item.Display (
|
||||
--itemDisplay,
|
||||
itemDisplayOffset,
|
||||
itemDisplay,
|
||||
canAttachTargeting,
|
||||
-- selectedItemDisplay,
|
||||
itemString,
|
||||
itemBaseName,
|
||||
basicItemDisplay,
|
||||
@@ -18,18 +16,6 @@ import Dodge.Module
|
||||
import LensHelp
|
||||
import Padding
|
||||
|
||||
itemDisplayOffset :: Creature -> Item -> (Int, [String])
|
||||
itemDisplayOffset cr itm = case itm ^. itType . iyBase of
|
||||
-- EQUIP (TARGETINGHAT tt)
|
||||
-- | targetItemCanAttachAbove cr itm ->
|
||||
-- ( -1
|
||||
-- , leftPad 15 ' ' (targetingTypeString tt) :
|
||||
-- (itemDisplay cr itm & ix 0 %~ (\s -> itemDisplayPad s (replicate (length (targetingTypeString tt)) '^')))
|
||||
-- )
|
||||
-- EQUIP (TARGETINGHAT tt) ->
|
||||
-- (0, itemDisplay cr itm & ix 0 %~ (\s -> itemDisplayPad s (targetingTypeString tt)))
|
||||
_ -> (0, itemDisplay cr itm)
|
||||
|
||||
canAttachTargeting :: TargetType -> Item -> Bool
|
||||
canAttachTargeting TARGETLASER _ = True
|
||||
canAttachTargeting _ itm =
|
||||
|
||||
@@ -100,7 +100,6 @@ colStrToSelItem (col, str) =
|
||||
, _siIsSelectable = True
|
||||
, _siColor = col
|
||||
, _siOffX = 0
|
||||
, _siOffY = 0
|
||||
, _siPayload = id
|
||||
}
|
||||
|
||||
@@ -121,7 +120,6 @@ menuOptionToSelectionItem w padAmount mo =
|
||||
, _siIsSelectable = isselectable
|
||||
, _siColor = thecol
|
||||
, _siOffX = 0
|
||||
, _siOffY = 0
|
||||
, _siPayload = (f, g)
|
||||
}
|
||||
where
|
||||
|
||||
@@ -99,7 +99,6 @@ drawExamineInventory cfig mtweaki w =
|
||||
, _siIsSelectable = True
|
||||
, _siColor = white
|
||||
, _siOffX = 0
|
||||
, _siOffY = 0
|
||||
, _siPayload = ()
|
||||
}
|
||||
|
||||
@@ -215,7 +214,7 @@ displayTerminal tid cfig w = fromMaybe mempty $ do
|
||||
invHead cfig (_tmTitle tm ++ ":T" ++ show tid)
|
||||
<> drawSelectionList secondColumnParams cfig (thesellist tm)
|
||||
where
|
||||
toselitm (str, col) = SelectionItem [str] 1 True col 0 0 ()
|
||||
toselitm (str, col) = SelectionItem [str] 1 True col 0 ()
|
||||
thesellist tm = defaultSelectionList & slItems .~ thelist tm
|
||||
thelist tm =
|
||||
map toselitm . displayTermInput tm
|
||||
@@ -334,7 +333,6 @@ picsToSelectable pics =
|
||||
, _siIsSelectable = True
|
||||
, _siColor = white
|
||||
, _siOffX = 0
|
||||
, _siOffY = 0
|
||||
, _siPayload = ()
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user