From 3936e1a386de74c9e868c189d9f2ecc38e8605ec Mon Sep 17 00:00:00 2001 From: justin Date: Wed, 20 Aug 2025 17:15:34 +0100 Subject: [PATCH] Improve tab completion, cleanup --- src/Dodge/Data/Terminal.hs | 1 - src/Dodge/Room/Warning.hs | 1 - src/Dodge/Terminal.hs | 3 +-- src/Dodge/WorldEffect.hs | 21 +++++++-------------- 4 files changed, 8 insertions(+), 18 deletions(-) diff --git a/src/Dodge/Data/Terminal.hs b/src/Dodge/Data/Terminal.hs index c89890872..528401c23 100644 --- a/src/Dodge/Data/Terminal.hs +++ b/src/Dodge/Data/Terminal.hs @@ -51,7 +51,6 @@ data TCom | TCBase | TCDamageCommand | TCSensorInfo --- | TCToggles data TmWdWd = TmWdId diff --git a/src/Dodge/Room/Warning.hs b/src/Dodge/Room/Warning.hs index 701c8e950..125b9afc6 100644 --- a/src/Dodge/Room/Warning.hs +++ b/src/Dodge/Room/Warning.hs @@ -42,7 +42,6 @@ addWarningTerminal str outplid = (rmName .++~ "warningTerm-") ) termMessages trpl = lineOutputTerminal (makeColorTermLine red "WARNING" : makeTermPara str) --- & tmCommands .:~ TCToggles & tmToggles .~ M.fromList [("DOOR", TerminalToggle (fromJust $ _plMID trpl) (BlConst True))] diff --git a/src/Dodge/Terminal.hs b/src/Dodge/Terminal.hs index 93a9057b5..cfd165f77 100644 --- a/src/Dodge/Terminal.hs +++ b/src/Dodge/Terminal.hs @@ -61,7 +61,6 @@ getCommand w tm = \case TCInfo x z -> PTE.singleton x (PTE.singleton "" (makeTermPara z)) TCBase -> helpCommand <> quitCommand <> toggleCommands tm TCDamageCommand -> damageCodeCommand w --- TCToggles -> toggleCommand tm TCSensorInfo -> sensorCommand w tm damageCodeCommand :: World -> PTE.TrieMap Char (PTE.TrieMap Char [TerminalLine]) @@ -156,7 +155,7 @@ tabComplete s' w tm = case PTE.lookup s $ getCommands w tm of .~ ( makeColorTermPara commandColor (unwords xs) - <> [TLine 1 [] . TmTmSetStatus $ TerminalTextInput s] + <> [TLine 1 [] . TmTmSetStatus $ TerminalTextInput s'] ) --damageCodeCommand :: TerminalCommand diff --git a/src/Dodge/WorldEffect.hs b/src/Dodge/WorldEffect.hs index 7fb1bed7c..10cfc689f 100644 --- a/src/Dodge/WorldEffect.hs +++ b/src/Dodge/WorldEffect.hs @@ -86,28 +86,21 @@ doDeathToggle (TerminalToggle trid f) = ix trid %~ doBlBl f doTmWdWd :: TmWdWd -> Terminal -> World -> World doTmWdWd tmwdwd = case tmwdwd of - TmTmClearDisplayedLines -> \tm -> fromMaybe id $ do - tid <- tm ^? tmID - return $ cWorld . lWorld . terminals . ix tid . tmDisplayedLines .~ [] + TmTmClearDisplayedLines -> \tm -> + cWorld . lWorld . terminals . ix (tm ^. tmID) . tmDisplayedLines .~ [] TmTmSetStatus x -> \tm -> cWorld . lWorld . terminals . ix (tm ^. tmID) . tmStatus .~ x TmWdId -> const id - TmWdWdPowerDownTerminal -> powerDownTerminal - TmWdWdDeactivateTerminal -> deactivateTerminal + TmWdWdPowerDownTerminal -> resetTerminal TerminalOff + TmWdWdDeactivateTerminal -> resetTerminal TerminalDeactivated TmWdWdTermSound sid -> \tm w -> let tpos = fromMaybe 0 $ w ^? cWorld . lWorld . buttons . ix (_tmButtonID tm) . btPos in soundStart TerminalSound tpos sid Nothing w TmWdWdDoDeathTriggers -> doDeathTriggers TmWdWdfromWdWd f -> \_ -> doWdWd f -powerDownTerminal :: Terminal -> World -> World -powerDownTerminal tm = - (cWorld . lWorld . terminals . ix (_tmID tm) . tmStatus .~ TerminalOff) - . (cWorld . lWorld . terminals . ix (_tmID tm) . tmDisplayedLines .~ []) - . exitTerminalSubInv - -deactivateTerminal :: Terminal -> World -> World -deactivateTerminal tm = - (cWorld . lWorld . terminals . ix (_tmID tm) . tmStatus .~ TerminalDeactivated) +resetTerminal :: TerminalStatus -> Terminal -> World -> World +resetTerminal x tm = + (cWorld . lWorld . terminals . ix (_tmID tm) . tmStatus .~ x) . (cWorld . lWorld . terminals . ix (_tmID tm) . tmDisplayedLines .~ []) . exitTerminalSubInv