Allow movement when viewing terminals

This commit is contained in:
2025-09-01 23:51:16 +01:00
parent a478ee0a2a
commit 7fcaac2a01
3 changed files with 106 additions and 100 deletions
+5 -2
View File
@@ -17,8 +17,11 @@ textInputFocus w = case w ^. hud . subInventory of
CombineInventory{} -> case he ^? subInventory . ciSelection . _Just . slSec of
Just (-1) -> Just $ hud . subInventory . ciFilter . _Just
_ -> Nothing
DisplayTerminal{_termID = tmid} -> return
$ cWorld . lWorld . terminals . ix tmid . tmStatus . tiText
DisplayTerminal{_termID = tmid} -> case w ^? cWorld . lWorld . terminals . ix tmid . tmStatus . tiText of
Just _ -> return $ cWorld . lWorld . terminals . ix tmid . tmStatus . tiText
Nothing -> Nothing
-- DisplayTerminal{_termID = tmid} -> return
-- $ cWorld . lWorld . terminals . ix tmid . tmStatus . tiText
_ -> Nothing
where
he = w ^. hud
+14 -10
View File
@@ -62,10 +62,9 @@ updateUseInputInGame u = updateFunctionKeys $ case u ^. uvWorld . hud of
& tohud %~ dodisplayregexinput diCloseFilter diCloseFilter 2
& uvWorld . worldEventFlags . at InventoryChange ?~ ()
& uvWorld %~ setInvPosFromSS
_ -> M.foldlWithKey' updateKeyInGame u pkeys
_ -> updateKeysInGame u
where
tohud = uvWorld . hud
pkeys = u ^. uvWorld . input . pressedKeys
dodisplayregexinput filterprism filterlens x di = fromMaybe di $ do
sss <- di ^? diSections
msel <- di ^? diSelection
@@ -83,6 +82,9 @@ updateUseInputInGame u = updateFunctionKeys $ case u ^. uvWorld . hud of
& ciSelection .~ msel'
& ciFilter .~ filts'
updateKeysInGame :: Universe -> Universe
updateKeysInGame u = M.foldlWithKey' updateKeyInGame u (u ^. uvWorld . input . pressedKeys)
updateMouseInGame :: Config -> World -> World
updateMouseInGame cfig w
| Just 0 <- lbpress = updateMouseClickInGame cfig w
@@ -378,19 +380,21 @@ updateFunctionKey uv ScancodeF3 _ = doDebugTest uv
updateFunctionKey uv ScancodeF4 _ = doDebugTest2 uv
updateFunctionKey uv _ _ = uv
-- look also at yourControl
updateKeysInTerminal :: Int -> Universe -> Universe
updateKeysInTerminal tmid u = fromMaybe u $ do
updateKeysInTerminal tmid u = fromMaybe deactivate $ do
tm <- u ^? uvWorld . cWorld . lWorld . terminals . ix tmid
x <- u ^? uvWorld . cWorld . lWorld . buttons . ix (tm ^. tmButtonID) . btPos
y <- u ^? uvWorld . cWorld . lWorld . creatures . ix 0 . crPos
return $ case tm ^. tmStatus of
case tm ^. tmStatus of
_
| dist x y > 40 || not (hasButtonLOS x y (u ^. uvWorld)) ->
u & uvWorld . hud . subInventory .~ NoSubInventory
TerminalDeactivated -> u & uvWorld . hud . subInventory .~ NoSubInventory
TerminalTextInput{} -> updateKeysTextInputTerminal tmid u
TerminalPressTo{} -> updateKeyContinueTerminal tmid u
_ -> u
| dist x y > 40 || not (hasButtonLOS x y (u ^. uvWorld)) -> Nothing
TerminalDeactivated -> Nothing
TerminalTextInput{} -> Just $ updateKeysTextInputTerminal tmid u
TerminalPressTo{} -> Just $ updateKeyContinueTerminal tmid u
_ -> Just $ updateKeysInGame u
where
deactivate = u & uvWorld . hud . subInventory .~ NoSubInventory
updateKeyContinueTerminal :: Int -> Universe -> Universe
updateKeyContinueTerminal tmid u