Tweak mouse context/cursors

This commit is contained in:
2024-11-15 22:53:33 +00:00
parent 4434093d81
commit 0621709f7b
7 changed files with 288 additions and 205 deletions
+35 -18
View File
@@ -20,7 +20,6 @@ fixedCoordPictures :: Universe -> Picture
fixedCoordPictures u =
drawMenuOrHUD cfig u
<> drawConcurrentMessage u
<> drawMouseCursor u
<> ttl (translate hw 0 $ drawList (map text (_uvTestString u u)))
<> ttl
( translate (0.5 * hw) (- hh)
@@ -31,6 +30,7 @@ fixedCoordPictures u =
)
<> displayFrameTicks u
<> aimDelaySweep (u ^. uvWorld)
<> drawMouseCursor u
where
cfig = _uvConfig u
hw = halfWidth cfig
@@ -78,23 +78,17 @@ drawMouseCursor u =
$ mouseCursorType u
mouseCursorType :: Universe -> Picture
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 . input . mouseContext . mcoCombInv
|| null (u ^? uvWorld . input . mouseContext . mcoCombInv)
)
&& 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
else drawPlus 5
| otherwise = rotate a (drawPlus 5)
mouseCursorType u = case u ^. uvWorld . input . mouseContext of
NoMouseContext -> drawPlus 5
MouseAiming -> rotate a (drawPlus 5)
OverInvSelect {} -> drawSelect 5
OverInvFilt {} -> drawCombFilter 5
OverCombSelect {} -> drawSelect 5
OverCombFilter {} -> drawCombFilterJump 5
OverCombCombine {} -> drawGapPlus 5
OverTerminalReturn -> drawReturn
OverTerminalEscape -> rotate (pi/4) $ drawPlus 5
where
isselect =
not (null $ u ^. uvScreenLayers)
|| not (null $ u ^? uvWorld . input . mouseContext . mcoInv)
w = u ^. uvWorld
a = fromMaybe 0 $ do
cpos <- w ^? cWorld . lWorld . creatures . ix 0 . crPos
@@ -107,7 +101,13 @@ determineTermCursor tmid u = fromMaybe (drawPlus 5) $ do
return drawReturn
drawReturn :: Picture
drawReturn = scale 0.1 0.1 . translate (-50) (-100) $ text [toEnum 153]
drawReturn = fold
[line [V2 0 0, V2 3 3]
,line [V2 0 0, V2 3 (-3)]
,line [V2 0 0, V2 6 0]
,line [V2 6 0, V2 6 10]
]
--drawReturn = scale 0.1 0.1 . translate (-50) (-100) $ text [toEnum 153]
drawWireRectCursor :: Picture
drawWireRectCursor = scale 0.1 0.1 $ text [cWireRect]
@@ -116,6 +116,23 @@ drawWireRectCursor = scale 0.1 0.1 $ text [cWireRect]
drawPlus :: Float -> Picture
drawPlus x = fold [line [V2 (- x) 0, V2 x 0], line [V2 0 (- x), V2 0 x]]
drawCombFilterJump :: Float -> Picture
drawCombFilterJump x = rotate (0.25*pi)
$ fold [line [V2 0 0, V2 x 0], line [V2 0 0, V2 0 x]]
drawSelect :: Float -> Picture
drawSelect x = line
[ V2 x x
, V2 0 x
, V2 0 (-x)
, V2 x (-x)
] <>
line [V2 (-x) 0, V2 0 0]
drawCombFilter :: Float -> Picture
drawCombFilter x = rotate (0.25*pi)
$ fold [line [V2 (- x) 0, V2 x 0], line [V2 0 (- x), V2 0 0]]
--drawDoublePlus :: Float -> Picture
--drawDoublePlus x = fold [line [V2 (- (1.5*x)) 0, V2 (1.5*x) 0]
-- , line [V2 (0.5 * x) (- x), V2 (0.5 * x) x]