This commit is contained in:
2025-12-24 16:43:36 +00:00
parent 8cd2625548
commit a1c20c56ce
4 changed files with 70 additions and 69 deletions
+23 -26
View File
@@ -51,28 +51,26 @@ import Picture
import SDL (MouseButton (..))
drawHUD :: Config -> World -> Picture
drawHUD cfig w = case w ^. hud of
-- DisplayCarte -> drawCarte cfig w
HUD{_diSections = sections, _subInventory = subinv} ->
drawInventory sections w cfig subinv
<> drawSubInventory subinv cfig w
drawHUD cfig w =
drawInventory sections w cfig subinv
<> drawSubInventory subinv cfig w
where
sections = w ^. hud . diSections
subinv = w ^. hud . subInventory
drawInventory :: IMSS () -> World -> Config -> SubInventory -> Picture
drawInventory sss w cfig = \case
DisplayTerminal {} ->
DisplayTerminal{} ->
drawSelectionSections sss 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
_ ->
drawSelectionSections sss invDP cfig
<> drawSSCursor sss invDP curs cfig (f $ w ^? hud . diSelection . _Just)
<> drawRootCursor w sss (f $ w ^? hud . diSelection . _Just) invDP cfig
<> drawSSCursor sss invDP curs cfig (w ^. hud . diSelection)
<> drawRootCursor w sss (w ^. hud . diSelection) invDP cfig
<> itemconnections
<> drawMouseOver cfig w
where
f = fmap (\(Sel x y _) -> (x, y))
curs = invCursorParams w
itemconnections = fromMaybe mempty $ do
inv' <- w ^? cWorld . lWorld . creatures . ix 0 . crInv
@@ -82,11 +80,12 @@ drawInventory sss w cfig = \case
_ -> return . drawItemConnections sss cfig $ invAdj inv
drawRootCursor ::
World -> IMSS () -> Maybe (Int, Int) -> LDParams -> Config -> Picture
World -> IMSS () -> Maybe Selection -> LDParams -> Config -> Picture
drawRootCursor w sss msel ldp cfig = fromMaybe mempty $ do
cr <- w ^? cWorld . lWorld . creatures . ix 0
guard $ crIsAiming cr
(i, j) <- msel
i <- msel ^? _Just . slSec
j <- msel ^? _Just . slInt
guard $ i == 0
inv' <- w ^? cWorld . lWorld . creatures . ix 0 . crInv
let inv = fmap (\k -> w ^?! cWorld . lWorld . items . ix k) inv'
@@ -124,7 +123,7 @@ drawMouseOver cfig w =
. translateScreenPos cfig (invDP ^. ldpPos)
. color (0.3 *^ white)
-- . color white
$ selSecDrawCursorAt invDP curs sss (j, i)
$ selSecDrawCursorAt invDP curs sss (Sel j i mempty)
-- curs = BoundaryCursor [West]
curs = BackdropCursor
combinvsel = do
@@ -136,7 +135,7 @@ drawMouseOver cfig w =
return
. translateScreenPos cfig (idp ^. ldpPos)
. color (0.3 * white)
$ selSecDrawCursorAt idp curs sss (j, i)
$ selSecDrawCursorAt idp curs sss (Sel j i mempty)
drawDragSelected :: Config -> World -> Maybe Picture
drawDragSelected cfig w = do
@@ -149,7 +148,7 @@ drawDragSelected cfig w = do
)
Sel i _ _ <- w ^? hud . diSelection . _Just
sss <- w ^? hud . diSections
let f x = (selSecDrawCursorAt invDP BackdropCursor sss (i, x) <>)
let f x = (selSecDrawCursorAt invDP BackdropCursor sss (Sel i x mempty) <>)
return
. translateScreenPos cfig (invDP ^. ldpPos)
. color (0.2 *^ white)
@@ -160,7 +159,7 @@ drawDragSelecting :: Config -> World -> Maybe Picture
drawDragSelecting cfig w = do
OverInvDragSelect (Just (i, j)) (Just b) <- w ^? input . mouseContext
sss <- w ^? hud . diSections
let f x = selSecDrawCursorAt invDP BackdropCursor sss (i, x)
let f x = selSecDrawCursorAt invDP BackdropCursor sss (Sel i x mempty)
return
. translateScreenPos cfig (invDP ^. ldpPos)
. color (0.2 *^ white)
@@ -171,7 +170,7 @@ drawSubInventory :: SubInventory -> Config -> World -> Picture
drawSubInventory subinv cfig w = case subinv of
NoSubInventory{} -> drawRBOptions cfig w
ExamineInventory -> drawExamineInventory cfig w
DisplayTerminal tid -> (drawTerminalDisplay w cfig tid)
DisplayTerminal tid -> drawTerminalDisplay w cfig tid
CombineInventory{_ciSections = sss} -> drawCombineInventory cfig sss w
MapperInventory _ _ itid -> drawMapperInventory itid w
@@ -191,9 +190,7 @@ drawCombineInventory cfig sss w =
<> combineInventoryExtra sss msel cfig w
where
curs = BoundaryCursor [North, South, West]
msel =
(\(Sel x y _) -> (x, y))
<$> (w ^? hud . subInventory . ciSelection . _Just)
msel = w ^? hud . subInventory . ciSelection . _Just
drawExamineInventory :: Config -> World -> Picture
drawExamineInventory cfig w =
@@ -332,10 +329,10 @@ drawItemChildrenConnect sss cfig i is = fromMaybe mempty $ do
where
snum = selNumPos cfig invDP sss 0
combineInventoryExtra ::
IMSS CombItem -> Maybe (Int, Int) -> Config -> World -> Picture
combineInventoryExtra :: IMSS CombItem -> Maybe Selection -> Config -> World -> Picture
combineInventoryExtra sss msel cfig w = fold $ do
(i, j) <- msel
i <- msel ^? _Just . slSec
j <- msel ^? _Just . slInt
si <- sss ^? ix i . ssItems . ix j
let col = _siColor si
lnks <- si ^? siPayload . _Just . ciInvIDs
@@ -347,7 +344,7 @@ combineInventoryExtra sss msel cfig w = fold $ do
invDP
(BoundaryCursor [North, South, East, West])
(w ^. hud . diSections)
(Just (0, i))
(Just (Sel 0 i mempty))
drawTerminalDisplay :: World -> Config -> Int -> Picture
drawTerminalDisplay w cfig tid = fold $ do
@@ -397,7 +394,7 @@ drawTerminalCursorLink w cfig tm = fold $ do
invDP
(BoundaryCursor [North, South, East, West])
(w ^. hud . diSections)
(Just (5, j))
(Just (Sel 5 j mempty))
)
<> lConnectCol (lp + V2 155 0) rp lcol white white
+7 -4
View File
@@ -19,6 +19,7 @@ module Dodge.Render.List (
drawLabelledList,
) where
import Dodge.Data.HUD
import qualified Data.IntMap.Strict as IM
import Data.Maybe
import Dodge.Base.Window
@@ -105,8 +106,10 @@ stackPicturesAtOff :: Int -> [Picture] -> Picture
stackPicturesAtOff i = mconcat . zipWith (drawListElement 10 1 0) [i, i - 1 ..]
selSecDrawCursorAt ::
LDParams -> CursorDisplay -> IM.IntMap (SelSection a) -> (Int, Int) -> Picture
selSecDrawCursorAt ldp curs sss (i, j) = fold $ do
LDParams -> CursorDisplay -> IM.IntMap (SelSection a) -> Selection -> Picture
selSecDrawCursorAt ldp curs sss sel = fold $ do
let i = sel ^. slSec
j = sel ^. slInt
yint <- selSecYint i j sss
sindent <- sss ^? ix i . ssIndent
si <- sss ^? ix i . ssItems . ix j
@@ -122,8 +125,8 @@ selSecDrawCursorAt ldp curs sss (i, j) = fold $ do
(_siHeight si)
selSecDrawCursor ::
LDParams -> CursorDisplay -> IM.IntMap (SelSection a) -> Maybe (Int, Int) -> Picture
selSecDrawCursor ldp curs = maybe mempty . selSecDrawCursorAt ldp curs
LDParams -> CursorDisplay -> IM.IntMap (SelSection a) -> Maybe Selection -> Picture
selSecDrawCursor ldp cd = maybe mempty . selSecDrawCursorAt ldp cd
-- displays a cursor that should match up to list text pictures
listCursorChooseBorderScale ::
+2 -1
View File
@@ -4,6 +4,7 @@ module Dodge.SelectionSections.Draw (
drawSSMultiCursor,
) where
import Dodge.Data.HUD
import Control.Lens
import qualified Data.IntMap.Strict as IM
import Dodge.Data.Config
@@ -29,7 +30,7 @@ drawSelectionSections sss ldp cfig =
)
drawSSCursor ::
IM.IntMap (SelSection a) -> LDParams -> CursorDisplay -> Config -> Maybe (Int, Int) -> Picture
IM.IntMap (SelSection a) -> LDParams -> CursorDisplay -> Config -> Maybe Selection -> Picture
drawSSCursor sss ldp curs cfig =
translateScreenPos cfig (ldp ^. ldpPos) .
selSecDrawCursor ldp curs sss