Highlight moused-over inventory items

This commit is contained in:
2024-10-16 22:14:11 +01:00
parent cf0873d73b
commit d256bc0443
9 changed files with 214 additions and 148 deletions
+13 -2
View File
@@ -6,6 +6,8 @@ Description : Simulation update
-}
module Dodge.Update (updateUniverse) where
import Dodge.ListDisplayParams
import Dodge.SelectionSections
import Data.Monoid
import NewInt
import Control.Monad
@@ -232,7 +234,7 @@ scrollTimeForward w = case w ^? timeFlow . futureWorlds . _head of
-- | The update step.
functionalUpdate :: Universe -> Universe
functionalUpdate w =
functionalUpdate u =
checkEndGame
. over uvWorld (cWorld . lWorld . lClock +~ 1)
. over uvWorld updateDistortions
@@ -276,11 +278,12 @@ functionalUpdate w =
. over uvWorld updateRBList
. over uvWorld updateCloseObjects
. over uvWorld updateWheelEvents
. over uvWorld (updateMouseOverInventory (u ^. uvConfig))
. over uvWorld zoneClouds
. over uvWorld zoneCreatures
-- . over uvWorld updateInventorySelectionList
. set (uvWorld . cWorld . lWorld . flares) []
$ over uvWorld updatePastWorlds w
$ over uvWorld updatePastWorlds u
checkTermDist :: World -> World
checkTermDist w = fromMaybe w $ do
@@ -290,6 +293,14 @@ checkTermDist w = fromMaybe w $ do
guard $ dist btpos (_crPos $ you w) > 40
return (w & hud . hudElement . subInventory .~ NoSubInventory Nothing Nothing)
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
where
ldp = invDisplayParams w
updateWheelEvents :: World -> World
updateWheelEvents w