Highlight moused-over inventory items
This commit is contained in:
+26
-1
@@ -5,6 +5,7 @@ module Dodge.Render.HUD (
|
||||
selNumPos, -- this shoud probably be pushed back here
|
||||
) where
|
||||
|
||||
import Dodge.SelectionSections
|
||||
import Control.Lens
|
||||
import Control.Monad
|
||||
import qualified Data.Map.Strict as M
|
||||
@@ -58,9 +59,13 @@ drawHP cfig =
|
||||
|
||||
drawInventory :: SelectionSections () -> World -> Configuration -> Picture
|
||||
drawInventory sss w cfig =
|
||||
drawSelectionSections sss (invDisplayParams w) cfig
|
||||
drawSelectionSections sss ldp cfig
|
||||
<> iextra
|
||||
<> translateScreenPos cfig (ldp ^. ldpPos)
|
||||
(drawDIMouseOver w)
|
||||
<> drawDISelections w cfig
|
||||
where
|
||||
ldp = invDisplayParams w
|
||||
iextra = fromMaybe mempty $ do
|
||||
inv <- w ^? cWorld . lWorld . creatures . ix 0 . crInv
|
||||
let x = case invAdj inv of
|
||||
@@ -68,6 +73,23 @@ drawInventory sss w cfig =
|
||||
Right y -> y
|
||||
return $ inventoryExtra sss cfig w x
|
||||
|
||||
drawDIMouseOver :: World -> Picture
|
||||
drawDIMouseOver w = fromMaybe mempty $ do
|
||||
(_,i) <- w ^? hud . hudElement . subInventory . nsMouseOver . _Just
|
||||
sss <- w ^? hud . hudElement . diSections
|
||||
let idp = invDisplayParams w
|
||||
return . color (withAlpha 0.5 white) $ selSecDrawCursorAt (0,i) 10 idp sss
|
||||
|
||||
drawDISelections :: World -> Configuration -> Picture
|
||||
drawDISelections w cfig = fromMaybe mempty $ do
|
||||
(i,j) <- w ^? hud . hudElement . subInventory . nsSelected . _Just
|
||||
sss <- w ^? hud . hudElement . diSections
|
||||
let idp = invDisplayParams w
|
||||
tp <- selNumPos cfig idp sss 0 i
|
||||
bp <- selNumPos cfig idp sss 0 j
|
||||
return . color red $ line [tp,bp]
|
||||
|
||||
|
||||
drawSubInventory :: SubInventory -> Configuration -> World -> Picture
|
||||
drawSubInventory subinv cfig w = case subinv of
|
||||
LockedInventory -> mempty -- topInvCursor col cursPos cfig w
|
||||
@@ -344,5 +366,8 @@ selNumPos cfig ldp sss i j = do
|
||||
s = _ldpScale ldp
|
||||
ygap = _ldpVerticalGap ldp
|
||||
|
||||
|
||||
|
||||
|
||||
selSecSelCol :: Int -> Int -> SelectionSections a -> Maybe Color
|
||||
selSecSelCol i j sss = sss ^? sssSections . ix i . ssItems . ix j . siColor
|
||||
|
||||
@@ -2,8 +2,6 @@ module Dodge.Render.ShapePicture (
|
||||
worldSPic,
|
||||
) where
|
||||
|
||||
import Dodge.Render.HUD
|
||||
import Dodge.ListDisplayParams
|
||||
import qualified Data.Map.Strict as M
|
||||
import Control.Lens
|
||||
import Control.Monad (guard)
|
||||
@@ -40,8 +38,6 @@ worldSPic cfig u =
|
||||
<> foldup mcSPic (filtOn _mcPos _machines)
|
||||
<> aimDelaySweep w
|
||||
<> drawMouseSelection w
|
||||
<> drawDISelections w cfig
|
||||
<> drawDIMouseOver w cfig
|
||||
where
|
||||
w = _uvWorld u
|
||||
foldup = foldMap'
|
||||
@@ -57,22 +53,6 @@ drawMouseSelection w = fromMaybe mempty $ do
|
||||
return $ noShape $ color (withAlpha 0.5 white)
|
||||
$ setLayer FixedCoordLayer $ polygon $ reverse $ rectVV p (w ^. input . mousePos)
|
||||
|
||||
drawDIMouseOver :: World -> Configuration -> SPic
|
||||
drawDIMouseOver w cfig = fromMaybe mempty $ do
|
||||
i <- w ^? hud . hudElement . subInventory . nsMouseOver . _Just
|
||||
sss <- w ^? hud . hudElement . diSections
|
||||
let idp = invDisplayParams w
|
||||
return . noShape . setLayer FixedCoordLayer . color white $ selSecDrawCursorAt (0,i) 10 idp sss
|
||||
|
||||
drawDISelections :: World -> Configuration -> SPic
|
||||
drawDISelections w cfig = fromMaybe mempty $ do
|
||||
(i,j) <- w ^? hud . hudElement . subInventory . nsSelected . _Just
|
||||
sss <- w ^? hud . hudElement . diSections
|
||||
let idp = invDisplayParams w
|
||||
tp <- selNumPos cfig idp sss 0 i
|
||||
bp <- selNumPos cfig idp sss 0 j
|
||||
return . noShape . setLayer FixedCoordLayer . color red $ line [tp,bp]
|
||||
|
||||
aimDelaySweep :: World -> SPic
|
||||
aimDelaySweep w = fromMaybe mempty $ do
|
||||
cr <- w ^? cWorld . lWorld . creatures . ix 0
|
||||
@@ -157,8 +137,6 @@ extraPics cfig u =
|
||||
<> foldMap drawBul (_bullets lw)
|
||||
<> foldMap drawBlip (_radarBlips lw)
|
||||
<> _flares lw
|
||||
-- <> foldMap (dbArg (drawBeam . _bmDraw)) (_positronBeams $ _beams lw)
|
||||
-- <> foldMap (dbArg (drawBeam . _bmDraw)) (_electronBeams $ _beams lw)
|
||||
<> foldMap (dbArg (drawLightSource . _lsPict)) (_lightSources lw)
|
||||
<> testPic cfig w
|
||||
<> foldMap ppDraw (_pressPlates lw)
|
||||
|
||||
Reference in New Issue
Block a user