Centralise mouse context data
This commit is contained in:
+18
-21
@@ -6,6 +6,7 @@ module Dodge.Render.HUD (
|
||||
selNumPosCardinal, -- this shoud probably be pushed back here
|
||||
) where
|
||||
|
||||
import Control.Applicative
|
||||
import Dodge.Terminal.Type
|
||||
import Dodge.CharacterEnums
|
||||
import Dodge.Creature.Test
|
||||
@@ -67,10 +68,11 @@ drawInventory sss w cfig =
|
||||
<> drawSSCursor sss (w ^? hud . hudElement . diSelection . _Just) ldp curs cfig
|
||||
<> drawRootCursor w sss (w ^? hud . hudElement . diSelection . _Just) ldp cfig
|
||||
<> iextra
|
||||
<> drawMouseOver cfig w
|
||||
<> translateScreenPos
|
||||
cfig
|
||||
(ldp ^. ldpPos)
|
||||
(drawDIMouseOver w <> drawDISelections w)
|
||||
(drawDISelections w)
|
||||
where
|
||||
ldp = invDisplayParams w
|
||||
curs = invCursorParams w
|
||||
@@ -104,23 +106,22 @@ getRootItemBounds i inv = do
|
||||
y <- locLeftmost root ^? locLDT . ldtValue . cItem . itLocation . ilInvID
|
||||
return (x,y)
|
||||
|
||||
drawDIMouseOver :: World -> Picture
|
||||
drawDIMouseOver w = fromMaybe mempty $ do
|
||||
(j, i) <- w ^? hud . hudElement . diMouseOver . _Just
|
||||
sss <- w ^? hud . hudElement . diSections
|
||||
let idp = invDisplayParams w
|
||||
return . color (withAlpha 0.2 white) $ selSecDrawCursorAt 15 idp curs sss (j, i)
|
||||
where
|
||||
curs = BackdropCursor
|
||||
|
||||
drawCIMouseOver :: World -> Picture
|
||||
drawCIMouseOver w = fromMaybe mempty $ do
|
||||
(j, i) <- w ^? hud . hudElement . subInventory . ciMouseOver . _Just
|
||||
sss <- w ^? hud . hudElement . subInventory . ciSections
|
||||
let idp = invDisplayParams w
|
||||
return . color (withAlpha 0.2 white) $ selSecDrawCursorAt 15 idp curs sss (j, i)
|
||||
where
|
||||
drawMouseOver :: Configuration -> World -> Picture
|
||||
drawMouseOver cfig w = fromMaybe mempty $ invsel <|> combinvsel
|
||||
where
|
||||
invsel = do
|
||||
(j, i) <- w ^? input . mouseContext . mcoInv
|
||||
sss <- w ^? hud . hudElement . diSections
|
||||
let idp = invDisplayParams w
|
||||
return . translateScreenPos cfig (invDisplayParams w ^. ldpPos)
|
||||
. color (withAlpha 0.2 white) $ selSecDrawCursorAt 15 idp curs sss (j, i)
|
||||
curs = BackdropCursor
|
||||
combinvsel = do
|
||||
(j, i) <- w ^? input . mouseContext . mcoCombInv
|
||||
sss <- w ^? hud . hudElement . subInventory . ciSections
|
||||
let idp = invDisplayParams w
|
||||
return . translateScreenPos cfig (secondColumnParams ^. ldpPos)
|
||||
. color (withAlpha 0.2 white) $ selSecDrawCursorAt 15 idp curs sss (j, i)
|
||||
|
||||
getMouseInvSel :: World -> Maybe ((Int, Int), (Int, Int))
|
||||
getMouseInvSel w = case w ^? hud . hudElement . subInventory . nsSelected of
|
||||
@@ -158,10 +159,6 @@ drawCombineInventory cfig sss w =
|
||||
<> drawSelectionSections sss secondColumnParams cfig
|
||||
<> drawSSCursor sss msel secondColumnParams curs cfig
|
||||
<> combineInventoryExtra sss msel cfig w
|
||||
<> translateScreenPos
|
||||
cfig
|
||||
(secondColumnParams ^. ldpPos)
|
||||
(drawCIMouseOver w)
|
||||
where
|
||||
curs = BoundaryCursor [North, South, West]
|
||||
msel = w ^? hud . hudElement . subInventory . ciSelection . _Just
|
||||
|
||||
@@ -82,10 +82,10 @@ mouseCursorType u
|
||||
| isselect = drawPlus 5
|
||||
| Just tmid <- u ^? uvWorld . hud . hudElement . subInventory . termID = determineTermCursor tmid u
|
||||
| Just csel <- u ^? uvWorld . hud . hudElement . subInventory . ciSelection =
|
||||
if ( csel == u ^? uvWorld . hud . hudElement . subInventory . ciMouseOver . _Just
|
||||
|| null (u ^? uvWorld . hud . hudElement . subInventory . ciMouseOver . _Just)
|
||||
if ( csel == u ^? uvWorld . input . mouseContext . mcoCombInv
|
||||
|| null (u ^? uvWorld . input . mouseContext . mcoCombInv)
|
||||
)
|
||||
&& null (u ^? uvWorld . hud . hudElement . diMouseOver . _Just)
|
||||
&& null (u ^? uvWorld . input . mouseContext . mcoInv)
|
||||
&& fmap fst csel /= Just (-1)
|
||||
&& fromMaybe True (u ^? uvWorld . hud . hudElement . subInventory . ciSections . ix 0 . ssItems . ix 0 . siIsSelectable) --HACK to check there is something creatable
|
||||
then drawGapPlus 5
|
||||
@@ -94,7 +94,7 @@ mouseCursorType u
|
||||
where
|
||||
isselect =
|
||||
not (null $ u ^. uvScreenLayers)
|
||||
|| not (null $ u ^? uvWorld . hud . hudElement . diMouseOver . _Just)
|
||||
|| not (null $ u ^? uvWorld . input . mouseContext . mcoInv)
|
||||
w = u ^. uvWorld
|
||||
a = fromMaybe 0 $ do
|
||||
cpos <- w ^? cWorld . lWorld . creatures . ix 0 . crPos
|
||||
|
||||
Reference in New Issue
Block a user