Cleanup
This commit is contained in:
@@ -4,6 +4,7 @@ module Dodge.Event.Keyboard
|
||||
, handleTextInput
|
||||
) where
|
||||
import Dodge.Terminal
|
||||
import Dodge.InputFocus
|
||||
import Dodge.Base
|
||||
import Dodge.Combine
|
||||
import Dodge.Creature.Action
|
||||
@@ -35,8 +36,10 @@ handleTextInput text u = return . Just $ u
|
||||
& updateTerminalText
|
||||
where
|
||||
updateTerminalText = case u ^? uvWorld . hud . hudElement . subInventory of
|
||||
Just (DisplayTerminal tmid True) -> uvWorld . terminals . ix tmid . tmInput . _Just %~ updateText
|
||||
_ -> id
|
||||
Just (DisplayTerminal tmid) | hasfocus tmid
|
||||
-> uvWorld . terminals . ix tmid . tmInput . _Just . tiText %~ updateText
|
||||
_ -> id
|
||||
hasfocus tmid = fromMaybe False $ u ^? uvWorld . terminals . ix tmid . tmInput . _Just . tiFocus
|
||||
updateText s = case T.unpack text of
|
||||
";" -> s
|
||||
_ -> s `T.append` T.toUpper text
|
||||
@@ -65,7 +68,8 @@ handlePressedKey _ scode u = case scode of
|
||||
ScancodeF9 -> return . Just $ loadSaveSlot QuicksaveSlot u
|
||||
ScancodeSemicolon -> return . Just $ gotoTerminal u
|
||||
_ | null (_menuLayers u) -> case u ^? uvWorld . hud . hudElement . subInventory of
|
||||
Just (DisplayTerminal tmid True) -> return $ uvWorld (handlePressedKeyTerminal tmid scode) u
|
||||
Just (DisplayTerminal tmid)
|
||||
| hasTerminalFocus (_uvWorld u) -> return $ uvWorld (handlePressedKeyTerminal tmid scode) u
|
||||
_ -> return $ uvWorld (Just . handlePressedKeyInGame scode) u
|
||||
_ -> handlePressedKeyInMenu (head $ _menuLayers u) scode u
|
||||
|
||||
@@ -86,10 +90,10 @@ handlePressedKeyInGame scode w = case scode of
|
||||
|
||||
handlePressedKeyTerminal :: Int -> Scancode -> World -> Maybe World
|
||||
handlePressedKeyTerminal tmid scode w = case scode of
|
||||
ScancodeEscape -> Just $ w & hud . hudElement . subInventory . onInputLine .~ False
|
||||
ScancodeEscape -> Just $ w & terminals . ix tmid . tmInput . _Just . tiFocus %~ const False
|
||||
ScancodeReturn -> Just $ w & doTerminalEffect (w ^?! terminals . ix tmid)
|
||||
ScancodeBackspace -> Just $ w
|
||||
& terminals . ix tmid . tmInput . _Just %~ doBackspace
|
||||
& terminals . ix tmid . tmInput . _Just . tiText %~ doBackspace
|
||||
& backspaceTimer .~ 5
|
||||
_ -> Just w
|
||||
where
|
||||
|
||||
Reference in New Issue
Block a user