Tweak mouse pointer display

This commit is contained in:
2024-11-04 09:32:36 +00:00
parent 1ed09fa8de
commit df08dc8ab5
7 changed files with 154 additions and 131 deletions
+14 -15
View File
@@ -160,21 +160,20 @@ inventoryX c = case c of
, makeTypeCraftNum 1 MOTOR
]
'F' -> fold
[ makeTypeCraftNum 5 PIPE
, makeTypeCraftNum 5 TUBE
, makeTypeCraftNum 5 HARDWARE
, makeTypeCraftNum 5 TIN
, makeTypeCraftNum 5 CAN
, makeTypeCraftNum 5 SPRING
, makeTypeCraftNum 5 PUMP
, makeTypeCraftNum 5 MAGNET
, makeTypeCraftNum 5 PLANK
, makeTypeCraftNum 5 PLATE
, makeTypeCraftNum 5 STEELDRUM
, makeTypeCraftNum 5 MOTOR
, makeTypeCraftNum 5 TRANSFORMER
, makeTypeCraftNum 5 PRISM
, makeTypeCraftNum 5 LIGHTER
[ makeTypeCraftNum 3 PIPE
, makeTypeCraftNum 3 TUBE
, makeTypeCraftNum 3 HARDWARE
, makeTypeCraftNum 3 TIN
, makeTypeCraftNum 3 CAN
, makeTypeCraftNum 3 SPRING
, makeTypeCraftNum 3 PUMP
, makeTypeCraftNum 3 MAGNET
, makeTypeCraftNum 3 PLATE
, makeTypeCraftNum 3 STEELDRUM
, makeTypeCraftNum 3 MOTOR
, makeTypeCraftNum 3 TRANSFORMER
, makeTypeCraftNum 3 PRISM
, makeTypeCraftNum 3 LIGHTER
-- , makeTypeCraftNum 5 (ENERGYBALLCRAFT IncBall)
]
'G' ->
+1 -1
View File
@@ -37,9 +37,9 @@ invDisplayParams w =
invCursorParams :: World -> CursorDisplay
invCursorParams w = BoundaryCursor $ case w ^? hud . hudElement . subInventory of
_ | ButtonRight `M.member` _mouseButtons (_input w) -> [North, South, East, West]
Just ExamineInventory{} -> [North, South, East, West]
Just CombineInventory{} -> []
_ | ButtonRight `M.member` _mouseButtons (_input w) -> [North, South, East, West]
_ -> [North, South, West]
secondColumnParams :: ListDisplayParams
+18 -2
View File
@@ -78,9 +78,18 @@ drawMouseCursor u =
mouseCursorType :: Universe -> Picture
mouseCursorType u
| null (u ^. uvScreenLayers) = rotate a (drawPlus 5)
| otherwise = drawPlus 5
| isselect = drawPlus 5
| 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))
&& null (u ^? uvWorld . hud . hudElement . diMouseOver . _Just)
&& fmap fst csel /= Just (-1)
then drawDoublePlus 5
else drawPlus 5
| otherwise = rotate a (drawPlus 5)
where
isselect = not (null $ u ^. uvScreenLayers)
|| not (null $ u ^? uvWorld . hud . hudElement . diMouseOver . _Just)
w = u ^. uvWorld
a = fromMaybe 0 $ do
cpos <- w ^? cWorld . lWorld . creatures . ix 0 . crPos
@@ -91,6 +100,13 @@ mouseCursorType u
drawPlus :: Float -> Picture
drawPlus x = fold [line [V2 (- x) 0, V2 x 0], line [V2 0 (- x), V2 0 x]]
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]
, line [V2 (negate 0.5 * x) (- x), V2 (negate 0.5 * x) x]
]
aimDelaySweep :: World -> Picture
aimDelaySweep w = fromMaybe mempty $ do
cr <- w ^? cWorld . lWorld . creatures . ix 0
+18 -10
View File
@@ -98,14 +98,18 @@ setClickWorldPos u =
(const (screenToWorldPos (u ^. uvWorld . wCam) (u ^. uvWorld . input . mousePos)))
(M.filter (== 0) $ u ^. uvWorld . input . mouseButtons)
-- the ordering of updating here may be important
updateWorldEventFlags :: Universe -> Universe
updateWorldEventFlags u =
(uvWorld . worldEventFlags .~ mempty)
-- for now update inventory positioning every tick
. updateInventoryPositioning
-- the question is how often to update the close objects section, and if
-- this can be done independently of the other sections
$ foldr updateWorldEventFlag u (u ^. uvWorld . worldEventFlags)
-- for now update inventory positioning every tick
-- the question is how often to update the close objects section, and if
-- this can be done independently of the other sections
$
foldr
updateWorldEventFlag
(updateInventoryPositioning u)
(u ^. uvWorld . worldEventFlags)
updateWorldEventFlag :: WorldEventFlag -> Universe -> Universe
updateWorldEventFlag wef = case wef of
@@ -380,11 +384,15 @@ shiftInvItemsDown (_, i) x w = fromMaybe w $ do
g i' m = fst <$> IM.lookupGT i' m
updateMouseOverInventory :: Configuration -> World -> World
updateMouseOverInventory cfig w = fromMaybe w $ do
sss <- w ^? hud . hudElement . diSections
return $
w & hud . hudElement . diMouseOver
.~ inverseSelNumPos cfig ldp sss (w ^. input . mousePos)
updateMouseOverInventory cfig w = fromMaybe
(w & hud . hudElement . diMouseOver .~ Nothing)
$ do
sss <- w ^? hud . hudElement . diSections
guard $ ButtonRight `M.notMember` (w ^. input . mouseButtons)
|| not (null $ w ^? hud . hudElement . subInventory . ciSelection)
return $
w & hud . hudElement . diMouseOver
.~ inverseSelNumPos cfig ldp sss (w ^. input . mousePos)
where
ldp = invDisplayParams w
+12 -13
View File
@@ -99,25 +99,24 @@ updateCombineInvClick ::
updateCombineInvClick msel sss w = fromMaybe trydocombination $ do
(i,j) <- w ^? hud . hudElement . diMouseOver . _Just
guard $ i == 0
str <- fmap (take 5) $ w ^? hud . hudElement . diSections . ix i . ssItems . ix j . siPictures . ix 0
return . (worldEventFlags . at CombineInventoryChange ?~ ()) $ case w ^? hud . hudElement . subInventory . ciFilter . _Just of
Just (_:xs) | str == xs -> w
& hud . hudElement . subInventory . ciFilter .~ Nothing
_ -> w & hud . hudElement . subInventory . ciFilter ?~ ("<" ++ str)
str <- fmap (take 5) $ w
^? hud . hudElement . diSections . ix i . ssItems . ix j . siPictures . ix 0
return . (worldEventFlags . at CombineInventoryChange ?~ ())
$ case w ^? hud . hudElement . subInventory . ciFilter . _Just of
Just (_:xs) | str == xs -> w
& hud . hudElement . subInventory . ciFilter .~ Nothing
_ -> w & hud . hudElement . subInventory . ciFilter ?~ ("<" ++ str)
where
trydocombination = case w ^? hud . hudElement . subInventory . ciMouseOver . _Just of
x@Just{} | x /= msel -> w & hud . hudElement . subInventory . ciSelection .~ x
x@(Just (i,_))
| x /= msel -> w & hud . hudElement . subInventory . ciSelection .~ x
& worldEventFlags . at CombineInventoryChange ?~ ()
_ ->
(worldEventFlags . at InventoryChange ?~ ()) . maybeExitCombine $
| i == -1 -> w & hud . hudElement . subInventory . ciFilter .~ Nothing
& worldEventFlags . at CombineInventoryChange ?~ ()
_ -> (worldEventFlags . at InventoryChange ?~ ()) . maybeExitCombine $
tryCombine sss msel w
& worldEventFlags . at CombineInventoryChange ?~ ()
--checkCombineSelectionExists :: SubInventory -> SubInventory
--checkCombineSelectionExists x@CombineInventory{_ciSections=sss,_ciSelection=msel}
-- = x & ciSelection %~ ssSetCursor (ssTryLookup msel) sss
--checkCombineSelectionExists x = x
updatePressedButtonsCarte :: World -> World
updatePressedButtonsCarte w = updatePressedButtonsCarte' (_mouseButtons (_input w)) w