Continue inventory work
This commit is contained in:
@@ -50,7 +50,8 @@ updateDisplayInventory w cfig sss = case cr ^? crManipulation . manObject of
|
|||||||
Just str -> IM.singleton 0 (SelectionRegex ["INV. FILTER: " ++ str,numfiltitems] 2 True white 0)
|
Just str -> IM.singleton 0 (SelectionRegex ["INV. FILTER: " ++ str,numfiltitems] 2 True white 0)
|
||||||
Nothing -> mempty
|
Nothing -> mempty
|
||||||
filtclose = (2,(filtclosesec,filtcloseitems))
|
filtclose = (2,(filtclosesec,filtcloseitems))
|
||||||
filtclosesec = fromMaybe defaultFiltSection $ sss ^? sssSections . ix 2
|
filtclosesec = fromMaybe (defaultFiltSection & ssIndent .~ 2)
|
||||||
|
$ sss ^? sssSections . ix 2
|
||||||
filtcloseitems = case cr ^? crManipulation . closeRegex . _Just of
|
filtcloseitems = case cr ^? crManipulation . closeRegex . _Just of
|
||||||
Just str -> IM.singleton 0 (SelectionRegex ["NEARBY FILTER: " ++ str,numfiltclose] 2 True white 0)
|
Just str -> IM.singleton 0 (SelectionRegex ["NEARBY FILTER: " ++ str,numfiltclose] 2 True white 0)
|
||||||
Nothing -> mempty
|
Nothing -> mempty
|
||||||
@@ -67,7 +68,7 @@ updateDisplayInventory w cfig sss = case cr ^? crManipulation . manObject of
|
|||||||
cosec = fromMaybe defaultCOSection $ sss ^? sssSections . ix 2
|
cosec = fromMaybe defaultCOSection $ sss ^? sssSections . ix 2
|
||||||
invsec = fromMaybe defaultInvSection $ sss ^? sssSections . ix 0
|
invsec = fromMaybe defaultInvSection $ sss ^? sssSections . ix 0
|
||||||
coitems' = IM.fromDistinctAscList . zip [0..]
|
coitems' = IM.fromDistinctAscList . zip [0..]
|
||||||
$ map (closeObjectToSelectionItem nfreeslots) (w ^. hud . closeObjects)
|
$ map closeObjectToSelectionItem (w ^. hud . closeObjects)
|
||||||
coitems = case cr ^? crManipulation . closeRegex . _Just of
|
coitems = case cr ^? crManipulation . closeRegex . _Just of
|
||||||
Just str -> IM.filter (regexList str . _siPictures) coitems'
|
Just str -> IM.filter (regexList str . _siPictures) coitems'
|
||||||
Nothing -> coitems'
|
Nothing -> coitems'
|
||||||
@@ -82,8 +83,8 @@ updateDisplayInventory w cfig sss = case cr ^? crManipulation . manObject of
|
|||||||
displayFreeSlots :: Int -> String
|
displayFreeSlots :: Int -> String
|
||||||
displayFreeSlots x = case x of
|
displayFreeSlots x = case x of
|
||||||
0 -> "INVENTORY FULL"
|
0 -> "INVENTORY FULL"
|
||||||
1 -> " +1 FREE SLOT"
|
1 -> "1 FREE SLOT"
|
||||||
_ -> " +" ++ show x ++ " FREE SLOTS"
|
_ -> show x ++ " FREE SLOTS"
|
||||||
|
|
||||||
updateSections :: Int -> (Int, Int) -> [(Int,(SelectionSection a,IM.IntMap (SelectionItem a)))]
|
updateSections :: Int -> (Int, Int) -> [(Int,(SelectionSection a,IM.IntMap (SelectionItem a)))]
|
||||||
-> IM.IntMap (SelectionSection a)
|
-> IM.IntMap (SelectionSection a)
|
||||||
@@ -169,7 +170,7 @@ updateSection mspos sis' availablelines ss = ss
|
|||||||
allstrings = foldMap g sis
|
allstrings = foldMap g sis
|
||||||
mustrestrict = length allstrings > availablelines
|
mustrestrict = length allstrings > availablelines
|
||||||
shownstrings = drop offset allstrings
|
shownstrings = drop offset allstrings
|
||||||
h (col,str) = color col . text $ str
|
h (col,str) = color col . text $ theindent ++ str
|
||||||
theindent = replicate (_ssIndent ss) ' '
|
theindent = replicate (_ssIndent ss) ' '
|
||||||
hdown = color white . text $ theindent ++ ">>> MORE " ++ _ssDescriptor ss
|
hdown = color white . text $ theindent ++ ">>> MORE " ++ _ssDescriptor ss
|
||||||
hup = color white . text $ theindent ++ "<<< MORE " ++ _ssDescriptor ss
|
hup = color white . text $ theindent ++ "<<< MORE " ++ _ssDescriptor ss
|
||||||
|
|||||||
@@ -157,7 +157,7 @@ selSecSelPos i j sss = do
|
|||||||
. fmap (length . _siPictures)
|
. fmap (length . _siPictures)
|
||||||
. fst $ IM.split j (ss ^. ssItems)
|
. fst $ IM.split j (ss ^. ssItems)
|
||||||
where
|
where
|
||||||
secpos = sum . fmap (length . _ssItems) . fst $ IM.split i $ sss ^. sssSections
|
secpos = sum . fmap (length . _ssShownItems) . fst $ IM.split i $ sss ^. sssSections
|
||||||
|
|
||||||
selNumPos :: ManipulatedObject -> World -> Maybe Int
|
selNumPos :: ManipulatedObject -> World -> Maybe Int
|
||||||
selNumPos mo w = w ^? hud . hudElement . diSections >>=
|
selNumPos mo w = w ^? hud . hudElement . diSections >>=
|
||||||
|
|||||||
@@ -5,8 +5,6 @@ module Dodge.Inventory.SelectionList
|
|||||||
)
|
)
|
||||||
where
|
where
|
||||||
|
|
||||||
--import Dodge.Default.SelectionList
|
|
||||||
import Dodge.Inventory.Color
|
|
||||||
import Dodge.Item.Display
|
import Dodge.Item.Display
|
||||||
import Dodge.Inventory.ItemSpace
|
import Dodge.Inventory.ItemSpace
|
||||||
import Picture.Base
|
import Picture.Base
|
||||||
@@ -54,8 +52,8 @@ invSelectionItem cr (i,it) = SelectionItem
|
|||||||
_ | cr ^? crManipulation . manObject . inInventory . ispItem == Just i -> selectedItemDisplay cr it
|
_ | cr ^? crManipulation . manObject . inInventory . ispItem == Just i -> selectedItemDisplay cr it
|
||||||
_ -> itemDisplay it
|
_ -> itemDisplay it
|
||||||
--
|
--
|
||||||
closeObjectToSelectionItem :: Int -> Either FloorItem Button -> SelectionItem ()
|
closeObjectToSelectionItem :: Either FloorItem Button -> SelectionItem ()
|
||||||
closeObjectToSelectionItem n e = SelectionItem
|
closeObjectToSelectionItem e = SelectionItem
|
||||||
{ _siPictures = pics
|
{ _siPictures = pics
|
||||||
, _siHeight = length pics
|
, _siHeight = length pics
|
||||||
, _siIsSelectable = True
|
, _siIsSelectable = True
|
||||||
@@ -65,21 +63,9 @@ closeObjectToSelectionItem n e = SelectionItem
|
|||||||
, _siPayload = ()
|
, _siPayload = ()
|
||||||
}
|
}
|
||||||
where
|
where
|
||||||
(pics,col) = closeObjectToTextPictures' n e
|
(pics,col) = closeObjectToTextPictures e
|
||||||
--
|
--
|
||||||
closeObjectToTextPictures' :: Int -> Either FloorItem Button -> ([String],Color)
|
closeObjectToTextPictures :: Either FloorItem Button -> ([String],Color)
|
||||||
closeObjectToTextPictures' nfreeslots e = case e of
|
closeObjectToTextPictures e = case e of
|
||||||
Left flit -> let it = _flIt flit
|
Left flit -> let it = _flIt flit in ( itemDisplay it, _itInvColor it)
|
||||||
in (map textindent $ itemDisplay it, thecol it)
|
Right bt -> ([_btText bt], yellow)
|
||||||
Right bt -> ([textindent $ _btText bt], yellow)
|
|
||||||
where
|
|
||||||
textindent = (replicate clObjIntIn ' ' ++)
|
|
||||||
thecol it
|
|
||||||
| nfreeslots >= itSlotsTaken it = _itInvColor it
|
|
||||||
| otherwise = invDimColor
|
|
||||||
--
|
|
||||||
clObjIntIn :: Int
|
|
||||||
clObjIntIn = 2
|
|
||||||
--
|
|
||||||
--clObjFloatIn :: Float
|
|
||||||
--clObjFloatIn = fromIntegral clObjIntIn * 9
|
|
||||||
|
|||||||
+5
-28
@@ -77,25 +77,12 @@ inventoryDisplay sss w cfig = listPicturesAtScaleOff
|
|||||||
cfig
|
cfig
|
||||||
0
|
0
|
||||||
pics
|
pics
|
||||||
<> color thecolor thecursor
|
<> thecursor'
|
||||||
where
|
where
|
||||||
thecolor = fromMaybe white $ do
|
thecursor' = fromMaybe mempty $ do
|
||||||
spos <- _sssSelPos sss
|
i <- sss ^? sssSelPos . _Just
|
||||||
sss ^? sssSections . ix spos . ssCursor . _Just . scurColor
|
j <- sss ^? sssSections . ix i . ssCursor . _Just . scurSel
|
||||||
thecursor = fromMaybe mempty $ do
|
return $ selSecDrawCursor 15 [North,South,West] cfig ldps sss i j
|
||||||
sectype <- you w ^? crManipulation . manObject
|
|
||||||
let secnum = case sectype of
|
|
||||||
InInventory SortInventory -> negate 1
|
|
||||||
InInventory {} -> 0
|
|
||||||
SelNothing{} -> 1
|
|
||||||
InNearby SortNearby -> 2
|
|
||||||
InNearby{} -> 3
|
|
||||||
xint <- sss ^? sssSections . ix secnum . ssIndent
|
|
||||||
spos <- _sssSelPos sss
|
|
||||||
let y = sum . fmap (length . _ssShownItems) . fst . IM.split spos $ _sssSections sss
|
|
||||||
yint <- sss ^? sssSections . ix spos . ssCursor . _Just . scurPos
|
|
||||||
csize <- sss ^? sssSections . ix spos . ssCursor . _Just . scurSize
|
|
||||||
return $ listCursorDisplayParams ldps [North,South,West] cfig (yint + y) xint white 15 csize
|
|
||||||
ldps = invDisplayParams w
|
ldps = invDisplayParams w
|
||||||
pics = foldMap _ssShownItems (_sssSections sss)
|
pics = foldMap _ssShownItems (_sssSections sss)
|
||||||
|
|
||||||
@@ -331,16 +318,6 @@ lnkMidPosInvSelsCol cfig w i col = winScale cfig
|
|||||||
hh = halfHeight cfig
|
hh = halfHeight cfig
|
||||||
hw = halfWidth cfig
|
hw = halfWidth cfig
|
||||||
|
|
||||||
topCursorTypeWidth ::
|
|
||||||
(Float -> Float -> Configuration -> Int -> Int -> Color -> Int -> Int -> Picture) ->
|
|
||||||
Int ->
|
|
||||||
Configuration ->
|
|
||||||
World ->
|
|
||||||
Int ->
|
|
||||||
Picture
|
|
||||||
topCursorTypeWidth ctype width cfig w i =
|
|
||||||
ctype 0 0 cfig (fromMaybe 0 (selNumPos (InInventory (SelItem i NoInvSelAction)) w)) 0 (selNumCol i w) width (invSelSize (InInventory (SelItem i NoInvSelAction)) w)
|
|
||||||
|
|
||||||
determineInvSelCursorWidth :: World -> Int
|
determineInvSelCursorWidth :: World -> Int
|
||||||
determineInvSelCursorWidth w = case _rbOptions w of
|
determineInvSelCursorWidth w = case _rbOptions w of
|
||||||
NoRightButtonOptions -> topInvW
|
NoRightButtonOptions -> topInvW
|
||||||
|
|||||||
Reference in New Issue
Block a user