Add 8-way cardinal/intercardinal datatype

This commit is contained in:
2024-10-18 12:39:46 +01:00
parent d256bc0443
commit 8b6f5529ff
12 changed files with 267 additions and 157 deletions
+27 -4
View File
@@ -278,6 +278,7 @@ functionalUpdate u =
. over uvWorld updateRBList
. over uvWorld updateCloseObjects
. over uvWorld updateWheelEvents
. over uvWorld (updateMouseInventorySelection (u ^. uvConfig))
. over uvWorld (updateMouseOverInventory (u ^. uvConfig))
. over uvWorld zoneClouds
. over uvWorld zoneCreatures
@@ -291,14 +292,36 @@ checkTermDist w = fromMaybe w $ do
btid <- w ^? cWorld . lWorld . terminals . ix tmid . tmButtonID
btpos <- w ^? cWorld . lWorld . buttons . ix btid . btPos
guard $ dist btpos (_crPos $ you w) > 40
return (w & hud . hudElement . subInventory .~ NoSubInventory Nothing Nothing)
return (w & hud . hudElement . subInventory .~ NoSubInventory NoMouseSel Nothing)
updateMouseInventorySelection :: Configuration -> World -> World
updateMouseInventorySelection cfig w
| leftclickstart = case msel of
Nothing -> fromMaybe w $ do
ysel <- mysel
return $ w & hud . hudElement . subInventory . nsSelected .~ MouseInvSelect ysel Nothing
Just (i,j) -> w & hud . hudElement . subInventory . nsSelected .~
MouseInvChosen (i,j) (i,j)
| leftclickheld = w
| otherwise = w
where
leftclickstart = w ^? input . mouseButtons . ix ButtonLeft == Just 0
leftclickheld = ButtonLeft `M.member` (w ^. input . mouseButtons)
mpos = w ^. input . mousePos
ldp = invDisplayParams w
msel = do
sss <- msss
inverseSelNumPos cfig ldp sss (w ^. input . mousePos)
mysel = do
sss <- msss
inverseSelSecYint (posSelSecYint cfig ldp (mpos ^. _y)) sss
msss = w ^? hud . hudElement . diSections
updateMouseOverInventory :: Configuration -> World -> World
updateMouseOverInventory cfig w = fromMaybe w $ do
sss <- w ^? hud . hudElement . diSections
guard $ w ^. input . mouseMoving
let x = inverseSelNumPos cfig ldp sss (w ^. input . mousePos)
return $ w & hud . hudElement . subInventory . nsMouseOver .~ x
return $ w & hud . hudElement . subInventory . nsMouseOver .~
inverseSelNumPos cfig ldp sss (w ^. input . mousePos)
where
ldp = invDisplayParams w