Continue inventory refactor
This commit is contained in:
@@ -13,7 +13,6 @@ import Control.Lens
|
||||
import Control.Monad
|
||||
import Data.Bifunctor
|
||||
import qualified Data.IntMap.Strict as IM
|
||||
--import qualified Data.List as List
|
||||
import Data.Maybe
|
||||
import Data.Monoid
|
||||
import Dodge.Base.You
|
||||
@@ -135,7 +134,8 @@ updateDisplaySections w cfig =
|
||||
displayIndents
|
||||
mselpos
|
||||
(getAvailableListLines (invDisplayParams w) cfig)
|
||||
[statushead,statusdisplay,invhead,invx,youx, nearbyhead, closex]
|
||||
[statushead,statusdisplay,invhead,invx,youx, nearbyhead, closex
|
||||
,interfaceshead,interfaces]
|
||||
where
|
||||
mselpos = w ^? hud . hudElement . diSelection . _Just
|
||||
invfiltcurs = mselpos ^? _Just . _1 == Just (-1)
|
||||
@@ -152,6 +152,11 @@ updateDisplaySections w cfig =
|
||||
then if null sclose then (2,mempty) else makehead "NEARBY ITEMS" 2
|
||||
else filtclose
|
||||
youx = (1, youitems)
|
||||
interfaceshead = if null btitems then (4,mempty) else makehead "NEARBY INTERFACES" 4
|
||||
interfaces = (5,btitems)
|
||||
btitems =
|
||||
IM.fromDistinctAscList . zip [0 ..] $
|
||||
mapMaybe (closeButtonToSelectionItem w) (w ^. hud . closeInterfaces)
|
||||
makehead str i = (i,IM.singleton 0 $ SelectionInfo [str] 1 False white 0)
|
||||
statushead = (-4,IM.singleton 0 $ SelectionInfo ["STATUS"] 1 False white 0)
|
||||
statusdisplay = (-3,IM.singleton 0 $ SelectionInfo ["HEALTH: "++show (_crHP cr)] 1 False white 0)
|
||||
@@ -160,7 +165,7 @@ updateDisplaySections w cfig =
|
||||
thetext = displayFreeSlots (crNumFreeSlots cr)
|
||||
closeitms =
|
||||
IM.fromDistinctAscList . zip [0 ..] $
|
||||
map closeItemToSelectionItem (w ^. hud . closeItems)
|
||||
mapMaybe (closeItemToSelectionItem w) (w ^. hud . closeItems)
|
||||
invitems =
|
||||
IM.mapWithKey
|
||||
(\k (indent, x) -> invSelectionItem indent cr k (x ^. locLDT . ldtValue))
|
||||
@@ -269,7 +274,6 @@ updateSectionsPositioning f h mselpos allavailablelines lsss sss =
|
||||
guard $ k == k'
|
||||
return i
|
||||
ls = IM.fromList lsss
|
||||
-- h = IM.intersectionWith ($)
|
||||
-- defaults non-existing offsets to 0
|
||||
g = merge (mapMissing (const ($ 0))) dropMissing (zipWithMatched (const ($)))
|
||||
lk = maybe [] ((: []) . fst) mselpos
|
||||
@@ -308,11 +312,9 @@ updateSection indent mcsel sis availablelines oldoffset =
|
||||
pos | pos == 0 || length allstrings <= availablelines -> 0
|
||||
pos | pos - 1 < oldoffset -> pos - 1
|
||||
pos | maxcsel == csel -> pos - availablelines + xselsize
|
||||
pos
|
||||
| pos + 1 + xselsize - availablelines > oldoffset ->
|
||||
pos | pos + 1 + xselsize - availablelines > oldoffset ->
|
||||
pos - availablelines + 1 + xselsize
|
||||
_
|
||||
| length allstrings - oldoffset < availablelines ->
|
||||
_ | length allstrings - oldoffset < availablelines ->
|
||||
length allstrings - availablelines
|
||||
_ -> oldoffset
|
||||
tweakfirst (x : xs)
|
||||
|
||||
Reference in New Issue
Block a user