Work on toggle terminals

This commit is contained in:
2025-08-20 17:06:30 +01:00
parent 8557724fb5
commit 9de2a22001
4 changed files with 15 additions and 21 deletions
+1 -1
View File
File diff suppressed because one or more lines are too long
+1 -1
View File
@@ -51,7 +51,7 @@ data TCom
| TCBase
| TCDamageCommand
| TCSensorInfo
| TCToggles
-- | TCToggles
data TmWdWd
= TmWdId
+2 -8
View File
@@ -42,18 +42,12 @@ addWarningTerminal str outplid = (rmName .++~ "warningTerm-")
)
termMessages trpl =
lineOutputTerminal (makeColorTermLine red "WARNING" : makeTermPara str)
& tmCommands .:~ TCToggles
-- & tmCommands .:~ TCToggles
& tmToggles .~ M.fromList
[("DOOR", TerminalToggle (fromJust $ _plMID trpl) (BlConst True))]
lineOutputTerminal :: [TerminalLine] -> Terminal
lineOutputTerminal tls =
defaultTerminal
{ _tmDisplayedLines = []
, _tmFutureLines = []
, _tmBootLines = connectionBlurbLines tls
, _tmDeathEffect = TmWdWdDoDeathTriggers
}
lineOutputTerminal tls = defaultTerminal & tmBootLines .~ connectionBlurbLines tls
moveToSideFirstOutLink :: RoomPos -> Room -> Maybe (Point2, Float)
moveToSideFirstOutLink rp rm = do
+11 -11
View File
@@ -9,7 +9,7 @@ module Dodge.Terminal (
sensorCommand,
makeColorTermLine,
makeTermPara,
toggleCommand,
-- toggleCommand,
terminalReturnEffect,
getCommands,
tabComplete,
@@ -59,9 +59,9 @@ getCommand :: World
-> Terminal -> TCom -> PTE.TrieMap Char (PTE.TrieMap Char [TerminalLine])
getCommand w tm = \case
TCInfo x z -> PTE.singleton x (PTE.singleton "" (makeTermPara z))
TCBase -> helpCommand <> quitCommand
TCBase -> helpCommand <> quitCommand <> toggleCommands tm
TCDamageCommand -> damageCodeCommand w
TCToggles -> toggleCommand tm
-- TCToggles -> toggleCommand tm
TCSensorInfo -> sensorCommand w tm
damageCodeCommand :: World -> PTE.TrieMap Char (PTE.TrieMap Char [TerminalLine])
@@ -92,18 +92,18 @@ sensorCommand w tm = PTE.singleton "SENSOR" $ fromMaybe mempty $ do
]
toggleCommand :: Terminal -> PTE.TrieMap Char (PTE.TrieMap Char [TerminalLine])
toggleCommand tm =
PTE.singleton "TOGGLE" $
PTE.fromList $
M.toList $ fmap f $ tm ^. tmToggles
toggleCommands :: Terminal -> PTE.TrieMap Char (PTE.TrieMap Char [TerminalLine])
toggleCommands tm
| null ts = mempty
| otherwise = PTE.singleton "TOGGLE" $ PTE.fromList $ fmap f $ M.toList ts
where
f x =
ts = tm ^. tmToggles
f (s,x) = (s,
[ TLine
1
[TerminalLineConst "TOGGLE DONE!" termTextColor]
[TerminalLineConst (s ++ " TOGGLE DONE!") termTextColor]
(TmWdWdfromWdWd (WdWdNegateTrig $ x ^. ttTriggerID))
]
])
helpCommand :: PTE.TrieMap Char (PTE.TrieMap Char [TerminalLine])
helpCommand = PTE.singleton "HELP" (fmap makeTermPara helpStrings)