Continue hud/mouse refactor

This commit is contained in:
2024-11-16 15:06:05 +00:00
parent 0621709f7b
commit 5efc9220e0
6 changed files with 184 additions and 226 deletions
+12 -8
View File
@@ -43,7 +43,7 @@ updateUseInputInGame u = updateFunctionKeys $ case u ^. uvWorld . hud . hudEleme
u & uvWorld . cWorld . lWorld . terminals . ix tmid . tmInput . tiFocus
%~ const True
CombineInventory{_ciSections = sss, _ciSelection = msel}
| lbinitialpress -> u & uvWorld %~ updateCombineInvClick msel sss
| lbinitialpress -> u & uvWorld %~ updateCombineInvClick sss
| inSubInvRegex (u ^. uvWorld) ->
u
& uvWorld . hud . hudElement . subInventory
@@ -103,11 +103,10 @@ updateFunctionKey uv sc InitialPress = case sc of
updateFunctionKey uv _ _ = uv
updateCombineInvClick ::
Maybe (Int, Int) ->
IM.IntMap (SelectionSection CombinableItem) ->
World ->
World
updateCombineInvClick msel sss w = fromMaybe trydocombination $ do
updateCombineInvClick sss w = fromMaybe trydocombination $ do
(i,j) <- w ^? input . mouseContext . mcoInvFilt
guard $ i == 0
str <- fmap (take 5) $ w
@@ -123,9 +122,15 @@ updateCombineInvClick msel sss w = fromMaybe trydocombination $ do
& worldEventFlags . at CombineInventoryChange ?~ ()
OverCombFilter -> w & hud . hudElement . subInventory . ciFilter .~ Nothing
& worldEventFlags . at CombineInventoryChange ?~ ()
OverCombCombine (i,j) -> (worldEventFlags . at InventoryChange ?~ ()) . maybeExitCombine $
tryCombine sss msel w
OverCombCombine (i,j) ->
(worldEventFlags . at InventoryChange ?~ ()) . maybeExitCombine $
tryCombine sss (i,j) w
& worldEventFlags . at CombineInventoryChange ?~ ()
OverCombEscape -> w
& worldEventFlags . at InventoryChange ?~ ()
& hud . hudElement . subInventory .~ NoSubInventory MouseInvNothing
x -> error $ "while combining this mouse context should not be possible: "
++ show x
-- x@(Just (i,_))
-- | x /= msel -> w & hud . hudElement . subInventory . ciSelection .~ x
@@ -352,11 +357,10 @@ toggleTweakInv w = case w ^? hud . hudElement . subInventory of
tryCombine ::
IM.IntMap (SelectionSection CombinableItem) ->
Maybe (Int, Int) ->
(Int, Int) ->
World ->
World
tryCombine sss msel w = fromMaybe w $ do
(i, j) <- msel
tryCombine sss (i,j) w = fromMaybe w $ do
CombinableItem is it _ <- sss ^? ix i . ssItems . ix j . siPayload
p <- w ^? cWorld . lWorld . creatures . ix 0 . crPos
return $