Draw cursor over close button of displayed terminal
This commit is contained in:
+40
-31
@@ -2,6 +2,7 @@
|
||||
|
||||
module Dodge.Render.HUD (drawHUD) where
|
||||
|
||||
import Data.List (elemIndex)
|
||||
import Control.Applicative
|
||||
import Control.Lens
|
||||
import Control.Monad
|
||||
@@ -171,10 +172,7 @@ drawSubInventory subinv cfig w = case subinv of
|
||||
-- LockedInventory -> mempty -- topInvCursor col cursPos cfig w
|
||||
NoSubInventory{} -> drawRBOptions cfig w
|
||||
ExamineInventory -> drawExamineInventory cfig w
|
||||
DisplayTerminal tid ->
|
||||
foldMap
|
||||
(drawTerminalDisplay (w ^. cWorld . lWorld) cfig)
|
||||
(w ^? cWorld . lWorld . terminals . ix tid)
|
||||
DisplayTerminal tid -> (drawTerminalDisplay w cfig tid)
|
||||
CombineInventory{_ciSections = sss} -> drawCombineInventory cfig sss w
|
||||
MapperInventory _ _ itid -> drawMapperInventory itid w
|
||||
|
||||
@@ -195,8 +193,8 @@ drawCombineInventory cfig sss w =
|
||||
where
|
||||
curs = BoundaryCursor [North, South, West]
|
||||
msel =
|
||||
(\(Sel x y _) -> (x, y)) <$>
|
||||
(w ^? hud . subInventory . ciSelection . _Just)
|
||||
(\(Sel x y _) -> (x, y))
|
||||
<$> (w ^? hud . subInventory . ciSelection . _Just)
|
||||
|
||||
drawExamineInventory :: Config -> World -> Picture
|
||||
drawExamineInventory cfig w =
|
||||
@@ -338,53 +336,64 @@ drawItemChildrenConnect sss cfig i is = fromMaybe mempty $ do
|
||||
where
|
||||
snum = selNumPos cfig invDP sss 0
|
||||
|
||||
combineInventoryExtra
|
||||
:: IM.IntMap (SelSection CombItem) -> Maybe (Int, Int) -> Config -> World -> Picture
|
||||
combineInventoryExtra ::
|
||||
IM.IntMap (SelSection CombItem) -> Maybe (Int, Int) -> Config -> World -> Picture
|
||||
combineInventoryExtra sss msel cfig w = fold $ do
|
||||
(i, j) <- msel
|
||||
si <- sss ^? ix i . ssItems . ix j
|
||||
let col = _siColor si
|
||||
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
|
||||
invcursor i = do
|
||||
sss' <- w ^? hud . diSections
|
||||
return $
|
||||
invcursor i =
|
||||
translateScreenPos cfig (invDP ^. ldpPos) $
|
||||
selSecDrawCursor
|
||||
invDP
|
||||
(BoundaryCursor [North, South, East, West])
|
||||
sss'
|
||||
(w ^. hud . diSections)
|
||||
(Just (0, i))
|
||||
|
||||
drawTerminalDisplay :: LWorld -> Config -> Terminal -> Picture
|
||||
drawTerminalDisplay lw cfig tm
|
||||
= drawSelectionList (secondColumnLDP & ldpBorder ?~ (49, 16)) cfig f
|
||||
drawTerminalDisplay :: World -> Config -> Int -> Picture
|
||||
drawTerminalDisplay w cfig tid = fold $ do
|
||||
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
|
||||
-- <> tm ^. tmButtonID
|
||||
|
||||
-- <> invHead cfig ("TERMINAL-" ++ show tid)
|
||||
-- <> color
|
||||
-- (withAlpha 0.5 green) -- consider integrating termScreenColor somehow
|
||||
-- (drawSelectionListBackground secondColumnLDP cfig tsize)
|
||||
-- <> color (dark $ _tmExternalColor tm) (drawTitleBackground cfig)
|
||||
|
||||
tid = tm ^. tmID
|
||||
-- tsize = getMaxLinesTM + 1
|
||||
toselitm (str, col) = SelItem [str] 1 55 True col 0 Nothing NoSIDisplayMod
|
||||
-- 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
|
||||
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 cfig w i col = fromMaybe mempty . foldMap f
|
||||
|
||||
Reference in New Issue
Block a user