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 | TCBase
| TCDamageCommand | TCDamageCommand
| TCSensorInfo | TCSensorInfo
| TCToggles -- | TCToggles
data TmWdWd data TmWdWd
= TmWdId = TmWdId
+2 -8
View File
@@ -42,18 +42,12 @@ addWarningTerminal str outplid = (rmName .++~ "warningTerm-")
) )
termMessages trpl = termMessages trpl =
lineOutputTerminal (makeColorTermLine red "WARNING" : makeTermPara str) lineOutputTerminal (makeColorTermLine red "WARNING" : makeTermPara str)
& tmCommands .:~ TCToggles -- & tmCommands .:~ TCToggles
& tmToggles .~ M.fromList & tmToggles .~ M.fromList
[("DOOR", TerminalToggle (fromJust $ _plMID trpl) (BlConst True))] [("DOOR", TerminalToggle (fromJust $ _plMID trpl) (BlConst True))]
lineOutputTerminal :: [TerminalLine] -> Terminal lineOutputTerminal :: [TerminalLine] -> Terminal
lineOutputTerminal tls = lineOutputTerminal tls = defaultTerminal & tmBootLines .~ connectionBlurbLines tls
defaultTerminal
{ _tmDisplayedLines = []
, _tmFutureLines = []
, _tmBootLines = connectionBlurbLines tls
, _tmDeathEffect = TmWdWdDoDeathTriggers
}
moveToSideFirstOutLink :: RoomPos -> Room -> Maybe (Point2, Float) moveToSideFirstOutLink :: RoomPos -> Room -> Maybe (Point2, Float)
moveToSideFirstOutLink rp rm = do moveToSideFirstOutLink rp rm = do
+11 -11
View File
@@ -9,7 +9,7 @@ module Dodge.Terminal (
sensorCommand, sensorCommand,
makeColorTermLine, makeColorTermLine,
makeTermPara, makeTermPara,
toggleCommand, -- toggleCommand,
terminalReturnEffect, terminalReturnEffect,
getCommands, getCommands,
tabComplete, tabComplete,
@@ -59,9 +59,9 @@ getCommand :: World
-> Terminal -> TCom -> PTE.TrieMap Char (PTE.TrieMap Char [TerminalLine]) -> Terminal -> TCom -> PTE.TrieMap Char (PTE.TrieMap Char [TerminalLine])
getCommand w tm = \case getCommand w tm = \case
TCInfo x z -> PTE.singleton x (PTE.singleton "" (makeTermPara z)) TCInfo x z -> PTE.singleton x (PTE.singleton "" (makeTermPara z))
TCBase -> helpCommand <> quitCommand TCBase -> helpCommand <> quitCommand <> toggleCommands tm
TCDamageCommand -> damageCodeCommand w TCDamageCommand -> damageCodeCommand w
TCToggles -> toggleCommand tm -- TCToggles -> toggleCommand tm
TCSensorInfo -> sensorCommand w tm TCSensorInfo -> sensorCommand w tm
damageCodeCommand :: World -> PTE.TrieMap Char (PTE.TrieMap Char [TerminalLine]) 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]) toggleCommands :: Terminal -> PTE.TrieMap Char (PTE.TrieMap Char [TerminalLine])
toggleCommand tm = toggleCommands tm
PTE.singleton "TOGGLE" $ | null ts = mempty
PTE.fromList $ | otherwise = PTE.singleton "TOGGLE" $ PTE.fromList $ fmap f $ M.toList ts
M.toList $ fmap f $ tm ^. tmToggles
where where
f x = ts = tm ^. tmToggles
f (s,x) = (s,
[ TLine [ TLine
1 1
[TerminalLineConst "TOGGLE DONE!" termTextColor] [TerminalLineConst (s ++ " TOGGLE DONE!") termTextColor]
(TmWdWdfromWdWd (WdWdNegateTrig $ x ^. ttTriggerID)) (TmWdWdfromWdWd (WdWdNegateTrig $ x ^. ttTriggerID))
] ])
helpCommand :: PTE.TrieMap Char (PTE.TrieMap Char [TerminalLine]) helpCommand :: PTE.TrieMap Char (PTE.TrieMap Char [TerminalLine])
helpCommand = PTE.singleton "HELP" (fmap makeTermPara helpStrings) helpCommand = PTE.singleton "HELP" (fmap makeTermPara helpStrings)