Flatten HUDElement

This commit is contained in:
2025-08-26 16:46:02 +01:00
parent 596880f76a
commit 9034c409e1
24 changed files with 255 additions and 270 deletions
+18 -18
View File
@@ -46,17 +46,17 @@ import Picture
import SDL (MouseButton (..))
drawHUD :: Configuration -> World -> Picture
drawHUD cfig w = case w ^. hud . hudElement of
drawHUD cfig w = case w ^. hud of
-- DisplayCarte -> drawCarte cfig w
DisplayInventory{_diSections = sections, _subInventory = subinv} ->
HUD {_diSections = sections, _subInventory = subinv} ->
drawInventory sections w cfig
<> drawSubInventory subinv cfig w
drawInventory :: IM.IntMap (SelectionSection ()) -> World -> Configuration -> Picture
drawInventory sss w cfig =
drawSelectionSections sss invDP cfig
<> drawSSCursor sss invDP curs cfig (f $ w ^? hud . hudElement . diSelection . _Just)
<> drawRootCursor w sss (f $ w ^? hud . hudElement . diSelection . _Just) invDP cfig
<> drawSSCursor sss invDP curs cfig (f $ w ^? hud . diSelection . _Just)
<> drawRootCursor w sss (f $ w ^? hud . diSelection . _Just) invDP cfig
<> itemconnections
<> drawMouseOver cfig w
where
@@ -65,7 +65,7 @@ drawInventory sss w cfig =
itemconnections = fromMaybe mempty $ do
inv' <- w ^? cWorld . lWorld . creatures . ix 0 . crInv
let inv = fmap (\k -> w ^?! cWorld . lWorld . items . ix k) inv'
case w ^? hud . hudElement . diInvFilter . _Just of
case w ^? hud . diInvFilter . _Just of
Just (_ : _) -> Nothing
_ -> return . drawItemConnections sss cfig $ invAdj inv
@@ -112,7 +112,7 @@ drawMouseOver cfig w =
(j, i) <-
w ^? input . mouseContext . mcoInvSelect
<|> w ^? input . mouseContext . mcoInvFilt
sss <- w ^? hud . hudElement . diSections
sss <- w ^? hud . diSections
return . translateScreenPos cfig (invDP ^. ldpPos)
. color (withAlpha 0.1 white)
-- . color white
@@ -123,7 +123,7 @@ drawMouseOver cfig w =
(j, i) <-
(w ^? input . mouseContext . mcoCombSelect)
<|> (w ^? input . mouseContext . mcoCombCombine)
sss <- w ^? hud . hudElement . subInventory . ciSections
sss <- w ^? hud . subInventory . ciSections
let idp = secondColumnParams
return . translateScreenPos cfig (idp ^. ldpPos)
. color (withAlpha 0.2 white)
@@ -131,15 +131,15 @@ drawMouseOver cfig w =
drawDragSelected :: Configuration -> World -> Maybe Picture
drawDragSelected cfig w = do
ys <- w ^? hud . hudElement . diSelection . _Just . _3
ys <- w ^? hud . diSelection . _Just . _3
guard $
not (IS.null ys)
&& ( case w ^? hud . hudElement . subInventory of
&& ( case w ^? hud . subInventory of
Just NoSubInventory -> True
_ -> False
)
(i, _, _) <- w ^? hud . hudElement . diSelection . _Just
sss <- w ^? hud . hudElement . diSections
(i, _, _) <- w ^? hud . diSelection . _Just
sss <- w ^? hud . diSections
let f x = (selSecDrawCursorAt invDP BackdropCursor sss (i, x) <>)
return . translateScreenPos cfig (invDP ^. ldpPos)
. color (withAlpha 0.2 white)
@@ -149,7 +149,7 @@ drawDragSelected cfig w = do
drawDragSelecting :: Configuration -> World -> Maybe Picture
drawDragSelecting cfig w = do
OverInvDragSelect (Just (i, j)) (Just b) <- w ^? input . mouseContext
sss <- w ^? hud . hudElement . diSections
sss <- w ^? hud . diSections
let f x = selSecDrawCursorAt invDP BackdropCursor sss (i, x)
return . translateScreenPos cfig (invDP ^. ldpPos)
. color (withAlpha 0.2 white)
@@ -189,7 +189,7 @@ drawCombineInventory cfig sss w =
curs = BoundaryCursor [North, South, West]
msel =
fmap (\(x, y, _) -> (x, y)) $
w ^? hud . hudElement . subInventory . ciSelection . _Just
w ^? hud . subInventory . ciSelection . _Just
drawExamineInventory :: Configuration -> World -> Picture
drawExamineInventory cfig w =
@@ -253,8 +253,8 @@ drawRBOptions cfig w = fold $ do
you w ^? crInv . ix invid >>= \k -> w ^? cWorld . lWorld . items . ix k >>= equipType -- . itUse . uequipEffect . eeType
i <- w ^? rbOptions . opSel
let ae = getEquipmentAllocation invid w
sss <- w ^? hud . hudElement . diSections
(i', j, _) <- w ^? hud . hudElement . diSelection . _Just
sss <- w ^? hud . diSections
(i', j, _) <- w ^? hud . diSelection . _Just
curpos <- selSecYint i' j sss
let ytext = drawListElement 0 1 0 curpos . text
midstr = equipAllocString ae
@@ -349,7 +349,7 @@ combineInventoryExtra sss msel cfig w = fold $ do
return (lnkMidPosInvSelsCol cfig w j col lnks) <> foldMap invcursor lnks
where
invcursor i = do
sss' <- w ^? hud . hudElement . diSections
sss' <- w ^? hud . diSections
return $
translateScreenPos cfig (invDP ^. ldpPos) $
selSecDrawCursor
@@ -391,8 +391,8 @@ lnkMidPosInvSelsCol :: Configuration -> World -> Int -> Color -> [Int] -> Pictur
lnkMidPosInvSelsCol cfig w i col = fromMaybe mempty . foldMap f
where
f j = do
sss <- w ^? hud . hudElement . diSections
combinesss <- w ^? hud . hudElement . subInventory . ciSections
sss <- w ^? hud . diSections
combinesss <- w ^? hud . subInventory . ciSections
lp <- selNumPos cfig invDP sss 0 j
rp <- selNumPos cfig secondColumnParams combinesss 0 i
invcol <- selSecSelCol 0 j sss