Tweak mouse over display

This commit is contained in:
2024-11-19 12:51:50 +00:00
parent e31f6dfd4b
commit 13339c9a12
8 changed files with 289 additions and 245 deletions
+43 -72
View File
@@ -287,7 +287,7 @@ functionalUpdate u =
. over uvWorld updateRBList
. over uvWorld updateCloseObjects
. over uvWorld updateWheelEvents
. over uvWorld (updateMouseInventorySelection (u ^. uvConfig))
-- . over uvWorld (updateMouseInventorySelection (u ^. uvConfig))
. over uvWorld zoneClouds
. over uvWorld zoneCreatures
-- . over uvWorld updateInventorySelectionList
@@ -308,83 +308,54 @@ checkTermDist w = fromMaybe w $ do
--updateMouseInventoryEffects :: Configuration -> World -> World
--updateMouseInventoryEffects cfig w = w
updateMouseInventorySelection :: Configuration -> World -> World
updateMouseInventorySelection cfig w = fromMaybe w $ do
sss <- w ^? hud . hudElement . diSections
return $ updateMouseInventorySelection' sss cfig w
--updateMouseInventorySelection :: Configuration -> World -> World
--updateMouseInventorySelection cfig w = fromMaybe w $ do
-- sss <- w ^? hud . hudElement . diSections
-- return $ updateMouseInventorySelection' sss cfig w
updateMouseInventorySelection' ::
IM.IntMap (SelectionSection a) ->
Configuration ->
World ->
World
updateMouseInventorySelection' sss cfig w
| leftclickstart = w
-- case msel of
-- Nothing -> fromMaybe w $ do
-- ysel <- inverseSelSecYint (posSelSecYint cfig ldp (mpos ^. _y)) sss
-- return $
-- w & input . mouseContext
-- .~ OverInvDragSelect ysel Nothing
-- Just p -> w --startDrag p w
| leftclickheld = case w ^? input . mouseContext of
Just OverInvDragSelect{} ->
w & input . mouseContext . mcoSelEnd .~ msel
Just OverInvDrag -> fromMaybe w $ do
sel <- w ^? hud . hudElement . diSelection . _Just
x <- w ^? hud . hudElement . diSelectionExtra
return $ w & shiftInvItems sel x cfig mpos ldp sss
_ -> w
| otherwise = case w ^? input . mouseContext of
Just (OverInvDragSelect ssel (Just esel)) ->
w & input . mouseContext .~ MouseInGame
& hud . hudElement . diSelectionExtra
.~ (max (snd ssel) (snd esel) - min (snd ssel) (snd esel))
& augInvDirectSelect (min ssel esel)
_ -> w-- & hud . hudElement . subInventory . nsSelected .~ MouseInvNothing
where
leftclickstart = w ^? input . mouseButtons . ix ButtonLeft == Just 0 && nobuttonright
leftclickheld = ButtonLeft `M.member` (w ^. input . mouseButtons) && nobuttonright
nobuttonright = not $ ButtonRight `M.member` (w ^. input . mouseButtons)
mpos = w ^. input . mousePos
ldp = invDisplayParams w
msel = inverseSelNumPos cfig ldp sss (w ^. input . mousePos)
--updateMouseInventorySelection' ::
-- IM.IntMap (SelectionSection a) ->
-- Configuration ->
-- World ->
-- World
--updateMouseInventorySelection' sss cfig w
-- | leftclickstart = w
---- case msel of
---- Nothing -> fromMaybe w $ do
---- ysel <- inverseSelSecYint (posSelSecYint cfig ldp (mpos ^. _y)) sss
---- return $
---- w & input . mouseContext
---- .~ OverInvDragSelect ysel Nothing
---- Just p -> w --startDrag p w
-- | leftclickheld = case w ^? input . mouseContext of
---- Just OverInvDragSelect{} ->
---- w & input . mouseContext . mcoSelEnd .~ msel
---- Just OverInvDrag -> fromMaybe w $ do
---- sel <- w ^? hud . hudElement . diSelection . _Just
---- x <- w ^? hud . hudElement . diSelectionExtra
---- return $ w & shiftInvItems sel x cfig mpos ldp sss
-- _ -> w
-- | otherwise = w
---- | otherwise = case w ^? input . mouseContext of
---- Just (OverInvDragSelect ssel (Just esel)) ->
---- w & input . mouseContext .~ MouseInGame
---- & hud . hudElement . diSelectionExtra
---- .~ (max (snd ssel) (snd esel) - min (snd ssel) (snd esel))
---- & augInvDirectSelect (min ssel esel)
---- _ -> w-- & hud . hudElement . subInventory . nsSelected .~ MouseInvNothing
-- where
-- leftclickstart = w ^? input . mouseButtons . ix ButtonLeft == Just 0 && nobuttonright
-- leftclickheld = ButtonLeft `M.member` (w ^. input . mouseButtons) && nobuttonright
-- nobuttonright = not $ ButtonRight `M.member` (w ^. input . mouseButtons)
-- mpos = w ^. input . mousePos
-- ldp = invDisplayParams w
-- msel = inverseSelNumPos cfig ldp sss (w ^. input . mousePos)
shiftInvItems ::
(Int, Int) ->
Int ->
Configuration ->
Point2 ->
ListDisplayParams ->
IM.IntMap (SelectionSection a) ->
World ->
World
shiftInvItems topsel x cfig mpos ldp sss w = case inverseSelBoundaryUp cfig ldp sss mpos of
Just p | p < topsel -> shiftInvItemsUp topsel x w
_ -> case inverseSelBoundaryDown cfig ldp sss mpos of
Just p | p > (topsel & _2 +~ x) -> shiftInvItemsDown topsel x w
_ -> w
shiftInvItemsUp :: (Int, Int) -> Int -> World -> World
shiftInvItemsUp (_, i) x w = foldl' f w [i .. i + x]
where
f w' i' = swapInvItems g i' w'
g i' m = fst <$> IM.lookupLT i' m
shiftInvItemsDown :: (Int, Int) -> Int -> World -> World
shiftInvItemsDown (_, i) x w = fromMaybe w $ do
guard . isJust $
w ^? hud . hudElement . diSections . ix 0 . ssItems . ix (i + x + 1)
return $ foldl' f w $ reverse [i .. i + x]
where
f w' i' = swapInvItems g i' w'
g i' m = fst <$> IM.lookupGT i' m
updateMouseContext :: Configuration -> Universe -> Universe
updateMouseContext cfig u = case u ^. uvWorld . input . mouseContext of
OverInvDrag | lbheld -> u
OverInvDragSelect{} | lbheld -> u
OverInvDragSelect{} -> u
_ -> u & uvWorld . input . mouseContext
.~ fromMaybe
aimcontext