Continue mouse context refactor

This commit is contained in:
2024-11-18 22:21:12 +00:00
parent 69fe28afe7
commit 5b709cd7ba
7 changed files with 186 additions and 165 deletions
+7 -12
View File
@@ -88,20 +88,15 @@ updateUseInputInGame u = updateFunctionKeys $ case u ^. uvWorld . hud . hudEleme
& ciFilter .~ filts'
updateMouseClickInGame :: World -> World
updateMouseClickInGame w = if w ^? input . mouseButtons . ix ButtonLeft == Just 0
then updateMouseClickInGame' w
else w
updateMouseClickInGame w = case w ^? input . mouseButtons . ix ButtonLeft of
Just 0 -> updateMouseClickInGame' w
Just _ -> w
Nothing -> w
updateMouseClickInGame' :: World -> World
updateMouseClickInGame' w = case w ^. input . mouseContext of
OverTerminalReturn -> fromMaybe w $ do
tmid <- w ^? hud . hudElement . subInventory . termID
tm <- w ^? cWorld . lWorld . terminals . ix tmid
guard (_tmStatus tm == TerminalReady)
s <- tm ^? tmInput . tiText
return $ if null (words s) && null (_tmPartialCommand tm)
then w
else terminalReturnEffect tm w
OverInvSelect (i,j) -> w
OverTerminalReturn tmid -> terminalReturnEffect tmid w
OverTerminalEscape -> w
& hud . hudElement . subInventory .~ NoSubInventory MouseInvNothing
OverCombSelect x ->
@@ -183,7 +178,7 @@ updateKeysInTerminal tmid u =
pkeys = u ^. uvWorld . input . pressedKeys
checkEndStatus
| pkeys ^. at ScancodeReturn == Just InitialPress =
over uvWorld (\w -> terminalReturnEffect (w ^?! cWorld . lWorld . terminals . ix tmid) w)
over uvWorld (\w -> terminalReturnEffect tmid w)
| otherwise = id
updateKeyInGame :: Universe -> Scancode -> PressType -> Universe