Incomplete work on mouse interaction with filtered inventory

This commit is contained in:
2024-11-20 08:45:51 +00:00
parent 2dc5d35744
commit 3ecf137801
7 changed files with 196 additions and 197 deletions
+9 -10
View File
@@ -39,12 +39,7 @@ updateUseInputInGame u = updateFunctionKeys $ case u ^. uvWorld . hud . hudEleme
DisplayCarte -> over uvWorld updatePressedButtonsCarte u
DisplayInventory{_subInventory = si} -> case si of
DisplayTerminal tmid -> updateKeysInTerminal tmid u
-- | lbinitialpress ->
-- u & uvWorld
-- %~ doTerminalEffectLB (w ^?! cWorld . lWorld . terminals . ix tmid)
-- | otherwise -> updateKeysInTerminal tmid u
CombineInventory{_ciSections = sss, _ciSelection = msel}
-- | lbinitialpress -> u & uvWorld %~ updateCombineInvClick sss
| inSubInvRegex (u ^. uvWorld) ->
u
& uvWorld . hud . hudElement . subInventory
@@ -123,6 +118,8 @@ dropSelected w = fromMaybe w $ do
updateMouseReleaseInGame :: World -> World
updateMouseReleaseInGame w = case w ^. input . mouseContext of
OverInvFiltDrag -> w & input . mouseContext .~ MouseInGame
OverInvFiltDragDrop -> w & input . mouseContext .~ MouseInGame
OverInvDrag mpos -> fromMaybe (dropSelected w & input . mouseContext .~ MouseInGame) $ do
j <- mpos
return $ w & input . mouseContext .~ OverInvSelect (0,j)
@@ -178,11 +175,13 @@ updateMouseClickInGame cfig w = case w ^. input . mouseContext of
mpos = w ^. input . mousePos
startDrag :: (Int, Int) -> World -> World
startDrag (a, b) w = fromMaybe (augInvDirectSelect (a, b) $ setmichosen 0 w) $ do
(i, j) <- w ^? hud . hudElement . diSelection . _Just
x <- w ^? hud . hudElement . diSelectionExtra
guard $ i == a && b >= j && b <= j + x
return $ setmichosen x w
startDrag (a, b) w = case w ^? hud . hudElement . diInvFilter . _Just of
Just {} -> w & input . mouseContext .~ OverInvFiltDrag
_ -> fromMaybe (augInvDirectSelect (a, b) $ setmichosen 0 w) $ do
(i, j) <- w ^? hud . hudElement . diSelection . _Just
x <- w ^? hud . hudElement . diSelectionExtra
guard $ i == a && b >= j && b <= j + x
return $ setmichosen x w
where
setmichosen x =
(input . mouseContext .~ OverInvDrag (Just b))