This commit is contained in:
2022-12-27 10:53:31 +00:00
parent eecc38d68f
commit 2def9800fa
6 changed files with 28 additions and 40 deletions
+17 -22
View File
@@ -14,7 +14,8 @@ import qualified Data.Vector as V
import Dodge.Base
import Dodge.Clock
import Dodge.Combine
import Dodge.Data.Universe
import Dodge.Data.World
import Dodge.Data.Config
import Dodge.Inventory
import Dodge.Inventory.ItemSpace
import Dodge.Item.Display
@@ -28,28 +29,22 @@ import ListHelp
import Padding
import Picture
import SDL (MouseButton (..))
import qualified Data.Set as Set
drawHUD :: Universe -> Picture
drawHUD uv = case w ^. cWorld . lWorld . hud . hudElement of
drawHUD :: Configuration -> World -> Picture
drawHUD cfig w = case w ^. cWorld . lWorld . hud . hudElement of
DisplayCarte -> drawCarte cfig w
DisplayInventory subinv ->
drawInGameHUD sl uv
drawInGameHUD sl cfig w
<> drawSubInventory subinv cfig w
where
sl = makeInventorySelectionList w
w = _uvWorld uv
cfig = _uvConfig uv
drawInGameHUD :: SelectionList () -> Universe -> Picture
drawInGameHUD sl uv =
drawInGameHUD :: SelectionList () -> Configuration -> World -> Picture
drawInGameHUD sl cfig w =
pictures
[ winScale cfig . dShadCol white $ displayHP 0 cfig w
, inventoryDisplay sl cfig w
, inventoryDisplay w cfig sl
]
where
w = _uvWorld uv
cfig = _uvConfig uv
defaultListDisplayParams :: ListDisplayParams
defaultListDisplayParams = ListDisplayParams
@@ -71,8 +66,8 @@ subInvListDisplayParams = ListDisplayParams
, _ldpWidth = FixedSelectionWidth 15
}
subInvSelectionList :: SelectionList a
subInvSelectionList = SelectionList
defaultSubInvSelectionList :: SelectionList a
defaultSubInvSelectionList = SelectionList
{ _slItems = []
, _slSelPos = Nothing
, _slLength = 0
@@ -81,15 +76,15 @@ subInvSelectionList = SelectionList
invDisplayParams :: World -> ListDisplayParams
invDisplayParams w = defaultListDisplayParams
& ldpWidth .~ FixedSelectionWidth topInvW
& ldpCursorType .~ BorderCursor (Set.fromList selcursortype)
& ldpCursorType .~ BorderCursor selcursortype
& ldpWidth .~ FixedSelectionWidth (determineInvSelCursorWidth w)
where
selcursortype
| ButtonRight `M.member` _mouseButtons (_input w) = [North,South,East,West]
| otherwise = [North,South,West]
inventoryDisplay :: SelectionList () -> Configuration -> World -> Picture
inventoryDisplay sl cfig w = drawSelectionList (invDisplayParams w) cfig sl
inventoryDisplay :: World -> Configuration -> SelectionList () -> Picture
inventoryDisplay w = drawSelectionList (invDisplayParams w)
drawSubInventory :: SubInventory -> Configuration -> World -> Picture
drawSubInventory subinv cfig w = case subinv of
@@ -102,7 +97,7 @@ drawSubInventory subinv cfig w = case subinv of
, rboptions
]
TweakInventory mtweaki ->
titledSub "TWEAK" (subInvSelectionList & slItems .~ ammoTweakSelectionItems it)
titledSub "TWEAK" (defaultSubInvSelectionList & slItems .~ ammoTweakSelectionItems it)
[ selcursor' listCursorNESW
, fromMaybe mempty $ do
tweaki <- mtweaki
@@ -136,7 +131,7 @@ drawSubInventory subinv cfig w = case subinv of
]
]
InspectInventory ->
titledSub "INSPECT" (subInvSelectionList & slItems .~ textSelItems (itmInfo it))
titledSub "INSPECT" (defaultSubInvSelectionList & slItems .~ textSelItems (itmInfo it))
[ selcursor' listCursorNESW
]
where
@@ -145,7 +140,7 @@ drawSubInventory subinv cfig w = case subinv of
extrapics
closeobjectcursor = case selectedCloseObject w of
Nothing -> mempty
Just (i,_) -> drawCursorAt (invDisplayParams w & ldpCursorType .~ BorderCursor (Set.fromList [North,South])) cfig (Just i) (inventorySelectionList w)
Just (i,_) -> drawCursorAt (invDisplayParams w & ldpCursorType .~ BorderCursor [North,South]) cfig (Just i) (inventorySelectionList w)
itcol = fromMaybe (greyN 0.5) (it ^? _Just . itInvColor)
cr = you w
it = yourItem w
@@ -289,7 +284,7 @@ determineInvSelCursorWidth w = case _rbOptions w of
else topInvW
combineListSelection :: World -> SelectionList ()
combineListSelection w = subInvSelectionList & slItems .~ combineListSelectionItems w
combineListSelection w = defaultSubInvSelectionList & slItems .~ combineListSelectionItems w
combineListSelectionItems :: World -> [SelectionItem ()]
combineListSelectionItems w = case combineListSelectionItems' w of