Draw cursor over close button of displayed terminal

This commit is contained in:
2025-12-23 22:33:19 +00:00
parent 9e8b847940
commit 34c86c6a1b
+40 -31
View File
@@ -2,6 +2,7 @@
module Dodge.Render.HUD (drawHUD) where module Dodge.Render.HUD (drawHUD) where
import Data.List (elemIndex)
import Control.Applicative import Control.Applicative
import Control.Lens import Control.Lens
import Control.Monad import Control.Monad
@@ -171,10 +172,7 @@ drawSubInventory subinv cfig w = case subinv of
-- LockedInventory -> mempty -- topInvCursor col cursPos cfig w -- LockedInventory -> mempty -- topInvCursor col cursPos cfig w
NoSubInventory{} -> drawRBOptions cfig w NoSubInventory{} -> drawRBOptions cfig w
ExamineInventory -> drawExamineInventory cfig w ExamineInventory -> drawExamineInventory cfig w
DisplayTerminal tid -> DisplayTerminal tid -> (drawTerminalDisplay w cfig tid)
foldMap
(drawTerminalDisplay (w ^. cWorld . lWorld) cfig)
(w ^? cWorld . lWorld . terminals . ix tid)
CombineInventory{_ciSections = sss} -> drawCombineInventory cfig sss w CombineInventory{_ciSections = sss} -> drawCombineInventory cfig sss w
MapperInventory _ _ itid -> drawMapperInventory itid w MapperInventory _ _ itid -> drawMapperInventory itid w
@@ -195,8 +193,8 @@ drawCombineInventory cfig sss w =
where where
curs = BoundaryCursor [North, South, West] curs = BoundaryCursor [North, South, West]
msel = msel =
(\(Sel x y _) -> (x, y)) <$> (\(Sel x y _) -> (x, y))
(w ^? hud . subInventory . ciSelection . _Just) <$> (w ^? hud . subInventory . ciSelection . _Just)
drawExamineInventory :: Config -> World -> Picture drawExamineInventory :: Config -> World -> Picture
drawExamineInventory cfig w = drawExamineInventory cfig w =
@@ -338,53 +336,64 @@ drawItemChildrenConnect sss cfig i is = fromMaybe mempty $ do
where where
snum = selNumPos cfig invDP sss 0 snum = selNumPos cfig invDP sss 0
combineInventoryExtra combineInventoryExtra ::
:: IM.IntMap (SelSection CombItem) -> Maybe (Int, Int) -> Config -> World -> Picture IM.IntMap (SelSection CombItem) -> Maybe (Int, Int) -> Config -> World -> Picture
combineInventoryExtra sss msel cfig w = fold $ do combineInventoryExtra sss msel cfig w = fold $ do
(i, j) <- msel (i, j) <- msel
si <- sss ^? ix i . ssItems . ix j si <- sss ^? ix i . ssItems . ix j
let col = _siColor si let col = _siColor si
lnks <- si ^? siPayload . _Just . ciInvIDs lnks <- si ^? siPayload . _Just . ciInvIDs
return (lnkMidPosInvSelsCol cfig w j col lnks) <> foldMap invcursor lnks return (lnkMidPosInvSelsCol cfig w j col lnks) <> Just (foldMap invcursor lnks)
where where
invcursor i = do invcursor i =
sss' <- w ^? hud . diSections
return $
translateScreenPos cfig (invDP ^. ldpPos) $ translateScreenPos cfig (invDP ^. ldpPos) $
selSecDrawCursor selSecDrawCursor
invDP invDP
(BoundaryCursor [North, South, East, West]) (BoundaryCursor [North, South, East, West])
sss' (w ^. hud . diSections)
(Just (0, i)) (Just (0, i))
drawTerminalDisplay :: LWorld -> Config -> Terminal -> Picture drawTerminalDisplay :: World -> Config -> Int -> Picture
drawTerminalDisplay lw cfig tm drawTerminalDisplay w cfig tid = fold $ do
= drawSelectionList (secondColumnLDP & ldpBorder ?~ (49, 16)) cfig f tm <- w ^? cWorld . lWorld . terminals . ix tid
let toselitm (str, col) = SelItem [str] 1 55 True col 0 Nothing NoSIDisplayMod
f =
toselitm ("TERMINAL " ++ show tid, white)
: ( map (toselitm . (_1 %~ (" " <>)))
. displayTermInput
. reverse
$ _tmDisplayedLines tm
)
displayTermInput = case _tmStatus tm of
TerminalOff -> id
TerminalDeactivated -> id
TerminalLineRead -> (++ [(spincurs, termTextColor)])
TerminalTextInput s -> (++ [(getPromptTM ++ s ++ [cFilledRect], white)])
TerminalPressTo s -> (++ [(s, white)])
return $ drawSelectionList (secondColumnLDP & ldpBorder ?~ (49, 16)) cfig f
<> drawTerminalCursorLink w cfig tm
where where
-- <> tm ^. tmButtonID
-- <> invHead cfig ("TERMINAL-" ++ show tid) -- <> invHead cfig ("TERMINAL-" ++ show tid)
-- <> color -- <> color
-- (withAlpha 0.5 green) -- consider integrating termScreenColor somehow -- (withAlpha 0.5 green) -- consider integrating termScreenColor somehow
-- (drawSelectionListBackground secondColumnLDP cfig tsize) -- (drawSelectionListBackground secondColumnLDP cfig tsize)
-- <> color (dark $ _tmExternalColor tm) (drawTitleBackground cfig) -- <> color (dark $ _tmExternalColor tm) (drawTitleBackground cfig)
tid = tm ^. tmID
-- tsize = getMaxLinesTM + 1 -- tsize = getMaxLinesTM + 1
toselitm (str, col) = SelItem [str] 1 55 True col 0 Nothing NoSIDisplayMod
-- not sure if the width (55) is correct here -- not sure if the width (55) is correct here
f =
toselitm ("TERMINAL " ++ show tid, white)
: ( map (toselitm . (_1 %~ (" " <>)))
. displayTermInput
. reverse
$ _tmDisplayedLines tm
)
displayTermInput = case _tmStatus tm of
TerminalOff -> id
TerminalDeactivated -> id
TerminalLineRead -> (++ [(spincurs, termTextColor)])
TerminalTextInput s -> (++ [(getPromptTM ++ s ++ [cFilledRect], white)])
TerminalPressTo s -> (++ [(s, white)])
spincurs = clockCycle 4 (V.fromList ["/", "-", "\\", "|"]) lw spincurs = clockCycle 4 (V.fromList ["/", "-", "\\", "|"]) lw
lw = w ^. cWorld . lWorld
drawTerminalCursorLink :: World -> Config -> Terminal -> Picture
drawTerminalCursorLink w cfig tm = fold $ do
j <- elemIndex (tm ^. tmButtonID) $ w ^. hud . closeButtons
return . translateScreenPos cfig (invDP ^. ldpPos)
$ selSecDrawCursor invDP
(BoundaryCursor [North,South,East,West])
(w ^. hud . diSections)
(Just (5,j))
lnkMidPosInvSelsCol :: Config -> World -> Int -> Color -> [Int] -> Picture lnkMidPosInvSelsCol :: Config -> World -> Int -> Color -> [Int] -> Picture
lnkMidPosInvSelsCol cfig w i col = fromMaybe mempty . foldMap f lnkMidPosInvSelsCol cfig w i col = fromMaybe mempty . foldMap f