This commit is contained in:
2024-11-18 11:02:12 +00:00
parent 3c5e5b92b1
commit 69fe28afe7
3 changed files with 12 additions and 84 deletions
+11 -23
View File
@@ -1,5 +1,4 @@
module Dodge.Terminal (
doTerminalEffectLB,
doTerminalCommandEffect,
makeTermLine,
commandFutureLines,
@@ -18,9 +17,8 @@ module Dodge.Terminal (
terminalReturnEffect,
) where
import Dodge.Terminal.Type
import Control.Monad
import Color
import Control.Monad
import Data.Char
import Data.Foldable
import qualified Data.Map.Strict as M
@@ -28,6 +26,7 @@ import Data.Maybe
import Dodge.Data.World
import Dodge.Default
import Dodge.SoundLogic
import Dodge.Terminal.Type
import Justify
import LensHelp
import ListHelp (safeHead, safeUncons)
@@ -225,8 +224,9 @@ disconnectTerminal tm =
exitTerminalSubInv :: World -> World
exitTerminalSubInv w = case w ^? hud . hudElement . subInventory . termID of
Just _ -> w & hud . hudElement . subInventory
.~ NoSubInventory MouseInvNothing
Just _ ->
w & hud . hudElement . subInventory
.~ NoSubInventory MouseInvNothing
_ -> w
damageCodeCommand :: TerminalCommand
@@ -260,13 +260,13 @@ commandFutureLines s tm w = fromMaybe [errline "^ Invalid command"] $ do
case doTerminalCommandEffect (_tcEffect command) tm w of
NoArguments tls -> Just tls
OneArgument argtype m ->
let setpartial
| null (_tmPartialCommand tm)
= TerminalLineTerminalEffect 0 (TmTmSetPartialCommand (Just command)) :
makeTermPara ("Expects " ++ argtype ++ " as an argument")
| otherwise =
let setpartial
| null (_tmPartialCommand tm) =
TerminalLineTerminalEffect 0 (TmTmSetPartialCommand (Just command)) :
makeTermPara ("Expects " ++ argtype ++ " as an argument")
| otherwise =
TerminalLineTerminalEffect 0 (TmTmSetPartialCommand Nothing) :
makeTermPara "No argument input, cancelling"
makeTermPara "No argument input, cancelling"
in Just $
fromMaybe setpartial $
safeHead args >>= (m M.!?)
@@ -292,15 +292,3 @@ runTerminalString s tm w =
. (tmFutureLines ++.~ commandFutureLines s tm w)
. (tmCommandHistory %~ take 10 . (s :))
)
doTerminalEffectLB :: Terminal -> World -> World
doTerminalEffectLB tm w = case w ^. input . mouseContext of
OverTerminalReturn -> fromMaybe w $ do
guard (_tmStatus tm == TerminalReady)
s <- w ^? cWorld . lWorld . terminals . ix (_tmID tm) . tmInput . tiText
return $ if null (words s) && null (_tmPartialCommand tm)
then w
else terminalReturnEffect tm w
OverTerminalEscape -> w
& hud . hudElement . subInventory .~ NoSubInventory MouseInvNothing
_ -> w