Allow for ingame terminal input

This commit is contained in:
2022-06-01 15:42:30 +01:00
parent 2cedc1b968
commit 61722e55e8
6 changed files with 45 additions and 36 deletions
+6 -17
View File
@@ -1,6 +1,5 @@
module Dodge.Event.Menu
( handlePressedKeyInMenu
-- , handleTextInMenu
) where
import Dodge.Data
import Dodge.Debug.Terminal
@@ -9,21 +8,11 @@ import Dodge.Menu.PushPop
import Data.Maybe
--import Control.Monad
--import Control.Lens
import Control.Lens
import SDL
--import qualified Debug.Trace
import qualified Data.Text as T
--handleTextInMenu :: ScreenLayer -> T.Text -> Universe -> IO (Maybe Universe)
--handleTextInMenu mState text = return . Just . -- case mState of
---- InputScreen {} ->
-- (menuLayers . ix 0 . scInput %~ updateText)
---- _ -> id
-- where
-- updateText s = case T.unpack text of
-- "\b" -> undefined
-- _ -> s `T.append` text
handlePressedKeyInMenu :: ScreenLayer -> Scancode -> Universe -> IO (Maybe Universe)
handlePressedKeyInMenu mState scode = case mState of
OptionScreen { _scOptions = mos, _scDefaultEff = defeff}
@@ -35,13 +24,13 @@ handlePressedKeyInMenu mState scode = case mState of
ScancodeEscape -> popScreen
ScancodeReturn -> popScreen . applyTerminalString (T.unpack s)
ScancodeTab -> autoCompleteTerminal (T.unpack s) help
-- ScancodeBackspace -> return . Just . (menuLayers . ix 0 . scInput %~ doBackspace)
-- text input handled by handleText
ScancodeBackspace -> return . Just . (menuLayers . ix 0 . scInput %~ doBackspace)
-- text input handled by handleTextInput
_ -> return . Just
where
-- doBackspace [_] = ['>']
-- doBackspace (x:xs) = init (x:xs)
-- doBackspace _ = ['>']
doBackspace t = case T.unsnoc t of
Nothing -> t
Just (t',_) -> t'
optionListToEffects
:: (Universe -> IO (Maybe Universe))