Reorganise/cleanup
This commit is contained in:
@@ -3,7 +3,7 @@ module Dodge.DisplayInventory
|
||||
( updateDisplayInventory
|
||||
, defaultSS
|
||||
, defaultFiltSection
|
||||
, defaultDisplaySections
|
||||
-- , defaultDisplaySections
|
||||
, updateSection
|
||||
) where
|
||||
|
||||
@@ -26,8 +26,8 @@ import Dodge.Data.World
|
||||
|
||||
updateDisplayInventory :: World -> Configuration -> SelectionSections () -> SelectionSections ()
|
||||
updateDisplayInventory w cfig sss = case cr ^? crManipulation . manObject of
|
||||
Just mo -> updateSectionsPositioning
|
||||
(sss & sssSelPos ?~ manObjIndex mo)
|
||||
Just mo -> sss & sssSections %~ updateSectionsPositioning
|
||||
(sss ^. sssExtra . sssSelPos)
|
||||
availablelines
|
||||
(addorder mo)
|
||||
_ -> error "error when getting cr inv sel"
|
||||
@@ -38,8 +38,8 @@ updateDisplayInventory w cfig sss = case cr ^? crManipulation . manObject of
|
||||
SelNothing -> reverse [filtinv,filtclose,invx ,youx, closex]
|
||||
InNearby SortNearby -> reverse [filtinv,filtclose,closex, invx ,youx]
|
||||
InNearby SelCloseObject {} -> reverse [filtinv,filtclose,closex, invx ,youx]
|
||||
(filtinv,invx) = filtpair (-1) (hud . hudElement . diSections . fssFilters . ix (-1) . _Just) invitems' "INV. "
|
||||
(filtclose,closex) = filtpair 2 (hud . hudElement . diSections . fssFilters . ix 2 . _Just) coitems' "NEARBY "
|
||||
(filtinv,invx) = filtpair (-1) (hud . hudElement . diSections . sssExtra . sssFilters . ix (-1) . _Just) invitems' "INV. "
|
||||
(filtclose,closex) = filtpair 2 (hud . hudElement . diSections . sssExtra . sssFilters . ix 2 . _Just) coitems' "NEARBY "
|
||||
youx = (1, youitems)
|
||||
youitems = IM.singleton 0 $ SelectionItem [thetext] 1 True invDimColor 2 ()
|
||||
thetext = displayFreeSlots nfreeslots
|
||||
@@ -72,31 +72,33 @@ displayFreeSlots x = case x of
|
||||
_ -> show x ++ " FREE SLOTS"
|
||||
|
||||
updateSectionsPositioning
|
||||
:: SelectionSections a
|
||||
-> Int -> [(Int,IM.IntMap (SelectionItem a))]
|
||||
-> SelectionSections a
|
||||
updateSectionsPositioning sss _ [] = sss & sssSections .~ mempty
|
||||
updateSectionsPositioning sss allavailablelines ((k,y) : xs)
|
||||
= previoussections & sssSections %~ IM.insert k ss
|
||||
:: Maybe (Int,Int)
|
||||
-> Int
|
||||
-> [(Int,IM.IntMap (SelectionItem a))]
|
||||
-> IM.IntMap (SelectionSection a)
|
||||
-> IM.IntMap (SelectionSection a)
|
||||
updateSectionsPositioning _ _ [] _ = mempty
|
||||
updateSectionsPositioning mselpos allavailablelines ((k,y) : xs) sss
|
||||
= IM.insert k ss previoussections
|
||||
where
|
||||
mscel = do
|
||||
(i,j) <- sss ^? sssSelPos . _Just
|
||||
(i,j) <- mselpos
|
||||
guard $ i == k
|
||||
return j
|
||||
ss = updateSection y mscel linesleft x
|
||||
x = sss ^?! sssSections . ix k
|
||||
x = sss ^?! ix k
|
||||
availablelines = allavailablelines - _ssMinSize x
|
||||
linesleft = allavailablelines - sum (fmap linestaken $ _sssSections previoussections)
|
||||
linesleft = allavailablelines - sum (fmap linestaken $ previoussections)
|
||||
linestaken ss' = max (length $ _ssShownItems ss') (_ssMinSize ss')
|
||||
previoussections = updateSectionsPositioning sss availablelines xs
|
||||
previoussections = updateSectionsPositioning mselpos availablelines xs sss
|
||||
|
||||
manObjIndex :: ManipulatedObject -> (Int,Int)
|
||||
manObjIndex mo = case mo of
|
||||
InInventory SortInventory -> (-1, 0)
|
||||
InInventory (SelItem i _) -> (0, i)
|
||||
SelNothing -> (1,0)
|
||||
InNearby SortNearby -> (2,0)
|
||||
InNearby (SelCloseObject i) -> (3,i)
|
||||
--manObjIndex :: ManipulatedObject -> (Int,Int)
|
||||
--manObjIndex mo = case mo of
|
||||
-- InInventory SortInventory -> (-1, 0)
|
||||
-- InInventory (SelItem i _) -> (0, i)
|
||||
-- SelNothing -> (1,0)
|
||||
-- InNearby SortNearby -> (2,0)
|
||||
-- InNearby (SelCloseObject i) -> (3,i)
|
||||
|
||||
updateSection
|
||||
:: IM.IntMap (SelectionItem a)
|
||||
|
||||
Reference in New Issue
Block a user