Separate selection list items from display parameters

This commit is contained in:
2022-12-23 12:22:57 +00:00
parent 6ac4e5d669
commit b072dc9e9a
10 changed files with 141 additions and 132 deletions
+35 -26
View File
@@ -49,34 +49,40 @@ drawInGameHUD subinv uv =
w = _uvWorld uv
cfig = _uvConfig uv
defaultListDisplayParams :: ListDisplayParams
defaultListDisplayParams = ListDisplayParams
{ _ldpVerticalGap = 10
, _ldpScale = 1
, _ldpPosX = 0
, _ldpPosY = 0
, _ldpCursorType = NoCursor
, _ldpWidth = FixedSelectionWidth 15
, _ldpSizeRestriction = NoSelectionSizeRestriction
}
defaultSelectionList :: SelectionList
defaultSelectionList = SelectionList
{ _slVerticalGap = 10
, _slScale = 1
, _slPosX = 0
, _slPosY = 0
, _slItems = []
, _slShownItems = []
{_slItems = []
, _slSelPos = Nothing
, _slCursorType = NoCursor
, _slWidth = FixedSelectionWidth 15
, _slLength = 0
, _slSizeRestriction = NoSelectionSizeRestriction
}
subInvListDisplayParams :: ListDisplayParams
subInvListDisplayParams = ListDisplayParams
{ _ldpVerticalGap = 10
, _ldpScale = 1
, _ldpPosX = subInvX
, _ldpPosY = 60
, _ldpCursorType = NoCursor
, _ldpWidth = FixedSelectionWidth 15
, _ldpSizeRestriction = NoSelectionSizeRestriction
}
subInvSelectionList :: SelectionList
subInvSelectionList = SelectionList
{ _slVerticalGap = 10
, _slScale = 1
, _slPosX = subInvX
, _slPosY = 60
, _slItems = []
, _slShownItems = []
{ _slItems = []
, _slSelPos = Nothing
, _slCursorType = NoCursor
, _slWidth = FixedSelectionWidth 15
, _slLength = 0
, _slSizeRestriction = NoSelectionSizeRestriction
}
inventorySelectionList :: World -> [SelectionItem]
@@ -98,18 +104,21 @@ inventoryCursorPos subinv w = case subinv of
CombineInventory {} -> Nothing
_ -> Just $ yourInvSel w
inventoryDisplay :: SubInventory -> Configuration -> World -> Picture
inventoryDisplay subinv cfig w = drawSelectionList cfig $
defaultSelectionList & slItems .~ inventorySelectionList w
& slWidth .~ FixedSelectionWidth topInvW
& slCursorType .~ BorderCursor (Set.fromList selcursortype)
& slSelPos .~ inventoryCursorPos subinv w
& slWidth .~ FixedSelectionWidth (determineInvSelCursorWidth w)
invDisplayParams :: World -> ListDisplayParams
invDisplayParams w = defaultListDisplayParams
& ldpWidth .~ FixedSelectionWidth topInvW
& ldpCursorType .~ BorderCursor (Set.fromList selcursortype)
& ldpWidth .~ FixedSelectionWidth (determineInvSelCursorWidth w)
where
selcursortype
| ButtonRight `M.member` _mouseButtons (_input w) = [North,South,East,West]
| otherwise = [North,South,West]
inventoryDisplay :: SubInventory -> Configuration -> World -> Picture
inventoryDisplay subinv cfig w = drawSelectionList (invDisplayParams w) cfig $
defaultSelectionList & slItems .~ inventorySelectionList w
& slSelPos .~ inventoryCursorPos subinv w
drawSubInventory :: SubInventory -> Configuration -> World -> Picture
drawSubInventory subinv cfig w = case subinv of
LockedInventory -> mempty -- topInvCursor col cursPos cfig w
@@ -160,7 +169,7 @@ drawSubInventory subinv cfig w = case subinv of
]
where
titledSub subtitle subitems extrapics = pictures $ [invHead cfig subtitle
,drawSelectionList cfig subitems] <>
,drawSelectionList subInvListDisplayParams cfig subitems] <>
extrapics
closeobjectcursor = case selectedCloseObject w of
Nothing -> mempty