Commit before removing "un-input-able" terminals
This commit is contained in:
@@ -41,19 +41,14 @@ import Data.Maybe
|
|||||||
--import System.Random
|
--import System.Random
|
||||||
|
|
||||||
analyser
|
analyser
|
||||||
:: [String] -- | initial text
|
:: (Machine -> World -> World)
|
||||||
-> String -- | succeed text
|
|
||||||
-> String -- | fail text
|
|
||||||
-> [String] -- | after text
|
|
||||||
-> (Machine -> World -> World)
|
|
||||||
-> PlacementSpot
|
-> PlacementSpot
|
||||||
-> PlacementSpot
|
-> PlacementSpot
|
||||||
-> Placement
|
-> Placement
|
||||||
analyser starts sucs _ afters upf pslight psmc = extTrigLitPos pslight $ \tp ->
|
analyser upf pslight psmc = extTrigLitPos pslight $ \tp ->
|
||||||
Just $ plSpot .~ psmc $ putTerminal' aquamarine tparams (termupdate tp)
|
Just $ plSpot .~ psmc $ putTerminal' aquamarine tparams (termupdate tp)
|
||||||
where
|
where
|
||||||
tparams = defaultTermParams & tmFutureLines ++.~
|
tparams = defaultTermParams & tmScrollCommands .:~ sensorCommand
|
||||||
(map makeTermLine starts ++ [makeTermLine sucs] ++ map makeTermLine afters)
|
|
||||||
termupdate tp _ mc = upf mc . (triggers . ix (fromJust $ _plMID tp) .~ const (_sensToggle $ _mcSensor mc))
|
termupdate tp _ mc = upf mc . (triggers . ix (fromJust $ _plMID tp) .~ const (_sensToggle $ _mcSensor mc))
|
||||||
|
|
||||||
analyserTest :: (World -> Bool) -> Machine -> World -> World
|
analyserTest :: (World -> Bool) -> Machine -> World -> World
|
||||||
|
|||||||
@@ -27,13 +27,12 @@ putTerminal''
|
|||||||
-> Terminal
|
-> Terminal
|
||||||
-> (Int -> Machine -> World -> World) -- | machine update, takes button id as input
|
-> (Int -> Machine -> World -> World) -- | machine update, takes button id as input
|
||||||
-> Placement
|
-> Placement
|
||||||
putTerminal'' mc tm mcf = ps0PushPS (PutTerminal tm) $ \tmpl -> Just $
|
putTerminal'' mc tm mcf = ps0PushPS (PutTerminal tm)
|
||||||
ps0PushPS (PutButton termButton)
|
$ \tmpl -> Just $ ps0PushPS (PutButton termButton)
|
||||||
$ \btpl -> Just $ pt0 (PutMachine (reverse $ square 10)
|
$ \btpl -> Just $ pt0 (PutMachine (reverse $ square 10)
|
||||||
(mc & mcUpdate .~ machineAddSound fridgeHumS (mcf (fromJust $ _plMID btpl))
|
(mc & mcUpdate .~ machineAddSound fridgeHumS (mcf (fromJust $ _plMID btpl))
|
||||||
& mcDeath %~ (\fd mc' -> (buttons . at (fromJust (_plMID btpl)) .~ Nothing) . fd mc')
|
& mcDeath %~ (\fd mc' -> mcKillTerm mc . (buttons . at (fromJust (_plMID btpl)) .~ Nothing) . fd mc')
|
||||||
)
|
) )
|
||||||
)
|
|
||||||
$ \mcpl -> Just $ sps0 $ PutWorldUpdate (const $ setids tmpl btpl mcpl)
|
$ \mcpl -> Just $ sps0 $ PutWorldUpdate (const $ setids tmpl btpl mcpl)
|
||||||
where
|
where
|
||||||
setids tmpl btpl mcpl w = w
|
setids tmpl btpl mcpl w = w
|
||||||
@@ -46,6 +45,13 @@ putTerminal'' mc tm mcf = ps0PushPS (PutTerminal tm) $ \tmpl -> Just $
|
|||||||
btid = fromJust (_plMID btpl)
|
btid = fromJust (_plMID btpl)
|
||||||
mcid = fromJust (_plMID mcpl)
|
mcid = fromJust (_plMID mcpl)
|
||||||
|
|
||||||
|
mcKillTerm :: Machine -> World -> World
|
||||||
|
mcKillTerm mc w = fromMaybe w $ do
|
||||||
|
tmid <- _mcTermMID mc
|
||||||
|
tm <- w ^? terminals . ix tmid
|
||||||
|
return $ w
|
||||||
|
& _tmDeathEffect tm tm
|
||||||
|
|
||||||
putTerminal'
|
putTerminal'
|
||||||
:: Color
|
:: Color
|
||||||
-> Terminal
|
-> Terminal
|
||||||
|
|||||||
+20
-21
@@ -84,20 +84,7 @@ subInventoryDisplay subinv cfig w = case subinv of
|
|||||||
, invHead cfig "TWEAK"
|
, invHead cfig "TWEAK"
|
||||||
, listTextPicturesAt subInvX 60 cfig $ map text (ammoTweakStrings it)
|
, listTextPicturesAt subInvX 60 cfig $ map text (ammoTweakStrings it)
|
||||||
]
|
]
|
||||||
DisplayTerminal {_termID = tid} ->
|
DisplayTerminal tid -> displayTerminal tid cfig w
|
||||||
let tp = w ^?! terminals . ix tid
|
|
||||||
in pictures
|
|
||||||
[ invHead cfig (_tmTitle tp ++ ":T" ++ show tid)
|
|
||||||
, renderListAt subInvX 60 cfig
|
|
||||||
. displayTermInput tp
|
|
||||||
-- . (++ map (\(str,_) -> (str,white)) (_termOptions tp))
|
|
||||||
. reverse
|
|
||||||
. take (_tmMaxLines tp)
|
|
||||||
$ _tmDisplayedLines tp
|
|
||||||
-- , fromMaybe mempty $ do
|
|
||||||
-- cursori <- _termSel tp <&> (+ _termMaxLines tp)
|
|
||||||
-- return $ listCursorNSW subInvX 60 cfig cursori white 15 1
|
|
||||||
]
|
|
||||||
CombineInventory mi -> pictures
|
CombineInventory mi -> pictures
|
||||||
[ invHead cfig "COMBINE"
|
[ invHead cfig "COMBINE"
|
||||||
, listTextPicturesAt subInvX 60 cfig $ combineListStringPictures w
|
, listTextPicturesAt subInvX 60 cfig $ combineListStringPictures w
|
||||||
@@ -111,7 +98,6 @@ subInventoryDisplay subinv cfig w = case subinv of
|
|||||||
cpos <- combinePoss w !? i
|
cpos <- combinePoss w !? i
|
||||||
csize <- combineSizes w !? i
|
csize <- combineSizes w !? i
|
||||||
col <- (combineItemListYou w !? i) <&> _itInvColor . snd
|
col <- (combineItemListYou w !? i) <&> _itInvColor . snd
|
||||||
--return $ listCursorNSW subInvX 60 cfig cpos col 15 csize
|
|
||||||
return $ listCursorNSW subInvX 60 cfig cpos col 15 csize
|
return $ listCursorNSW subInvX 60 cfig cpos col 15 csize
|
||||||
, fromMaybe mempty $ do
|
, fromMaybe mempty $ do
|
||||||
i <- mi
|
i <- mi
|
||||||
@@ -124,12 +110,6 @@ subInventoryDisplay subinv cfig w = case subinv of
|
|||||||
]
|
]
|
||||||
InspectInventory -> invHead cfig "INSPECT"
|
InspectInventory -> invHead cfig "INSPECT"
|
||||||
where
|
where
|
||||||
displayTermInput tp = case _tmInput tp of
|
|
||||||
Nothing -> id
|
|
||||||
Just (TerminalInput s inputstatus _)
|
|
||||||
-> (++ [('>':T.unpack s++displayBlinkCursor inputstatus,white)])
|
|
||||||
displayBlinkCursor inputstatus | inputstatus = clockCycle 10 (V.fromList ["_",""]) w
|
|
||||||
| otherwise = []
|
|
||||||
closeobjectcursor = case selectedCloseObject w of
|
closeobjectcursor = case selectedCloseObject w of
|
||||||
Nothing -> mempty
|
Nothing -> mempty
|
||||||
Just (i,co) -> listCursorNS clObjFloatIn 0 cfig (selNumPos i w) (closeObjectCol co) topInvW (invSelSize i w)
|
Just (i,co) -> listCursorNS clObjFloatIn 0 cfig (selNumPos i w) (closeObjectCol co) topInvW (invSelSize i w)
|
||||||
@@ -152,6 +132,25 @@ subInventoryDisplay subinv cfig w = case subinv of
|
|||||||
then drawRBOptions cfig w (_rbOptions w)
|
then drawRBOptions cfig w (_rbOptions w)
|
||||||
else mempty
|
else mempty
|
||||||
|
|
||||||
|
displayTerminal :: Int -> Configuration -> World -> Picture
|
||||||
|
displayTerminal tid cfig w = fromMaybe mempty $ do
|
||||||
|
tm <- w ^? terminals . ix tid
|
||||||
|
return $ pictures
|
||||||
|
[ invHead cfig (_tmTitle tm ++ ":T" ++ show tid)
|
||||||
|
, renderListAt subInvX 60 cfig
|
||||||
|
. displayTermInput tm
|
||||||
|
. reverse
|
||||||
|
. take (_tmMaxLines tm)
|
||||||
|
$ _tmDisplayedLines tm
|
||||||
|
]
|
||||||
|
where
|
||||||
|
displayTermInput tp = case _tmInput tp of
|
||||||
|
Nothing -> id
|
||||||
|
Just (TerminalInput s inputstatus _)
|
||||||
|
-> (++ [('>':T.unpack s++displayBlinkCursor inputstatus,white)])
|
||||||
|
displayBlinkCursor inputstatus | inputstatus = clockCycle 10 (V.fromList ["_",""]) w
|
||||||
|
| otherwise = []
|
||||||
|
|
||||||
drawRBOptions :: Configuration -> World -> RightButtonOptions -> Picture
|
drawRBOptions :: Configuration -> World -> RightButtonOptions -> Picture
|
||||||
drawRBOptions cfig w EquipOptions{_opEquip = es,_opSel=i, _opAllocateEquipment=ae} =
|
drawRBOptions cfig w EquipOptions{_opEquip = es,_opSel=i, _opAllocateEquipment=ae} =
|
||||||
listTextPicturesAtOffset 342 0 cfig (curpos-i) (map (text . eqPosText) es)
|
listTextPicturesAtOffset 342 0 cfig (curpos-i) (map (text . eqPosText) es)
|
||||||
|
|||||||
@@ -85,12 +85,6 @@ keyCardRoomRunPast keyid rmid = do
|
|||||||
|
|
||||||
keyCardAnalyserByDoor :: Int -> Int -> Room -> Room
|
keyCardAnalyserByDoor :: Int -> Int -> Room -> Room
|
||||||
keyCardAnalyserByDoor keyid = analyserByDoor
|
keyCardAnalyserByDoor keyid = analyserByDoor
|
||||||
[ bar
|
|
||||||
, hic
|
|
||||||
, bar ]
|
|
||||||
"UNLOCKED"
|
|
||||||
("REQUIRES KEYCARD-"++ show keyid)
|
|
||||||
(bar : replicate 2 "")
|
|
||||||
(machineAddSound fridgeHumS $ testYouHave (KEYCARD 0))
|
(machineAddSound fridgeHumS $ testYouHave (KEYCARD 0))
|
||||||
where
|
where
|
||||||
hic = "SECURITY CHECK"
|
hic = "SECURITY CHECK"
|
||||||
@@ -98,27 +92,20 @@ keyCardAnalyserByDoor keyid = analyserByDoor
|
|||||||
|
|
||||||
healthAnalyserByDoor :: Int -> Room -> Room
|
healthAnalyserByDoor :: Int -> Room -> Room
|
||||||
healthAnalyserByDoor = analyserByDoor
|
healthAnalyserByDoor = analyserByDoor
|
||||||
[ bar
|
|
||||||
, hic
|
|
||||||
, bar ]
|
|
||||||
"PASSED"
|
|
||||||
"REQUIRES HEALTH 1100"
|
|
||||||
(bar : replicate 2 "")
|
|
||||||
(machineAddSound fridgeHumS $ testYourHealth 1100)
|
(machineAddSound fridgeHumS $ testYourHealth 1100)
|
||||||
where
|
where
|
||||||
hic = "HEALTH INTEGRITY CHECK"
|
hic = "HEALTH INTEGRITY CHECK"
|
||||||
bar = replicate (length hic) '-'
|
bar = replicate (length hic) '-'
|
||||||
|
|
||||||
analyserByDoor :: [String] -> String -> String -> [String]
|
analyserByDoor :: (Machine -> World -> World) -> Int -> Room -> Room
|
||||||
-> (Machine -> World -> World) -> Int -> Room -> Room
|
analyserByDoor mcf outplid rm = rm
|
||||||
analyserByDoor sa sb sc sd mcf outplid rm = rm
|
|
||||||
& rmPmnts .++~
|
& rmPmnts .++~
|
||||||
[ psPt atFstLnkOut $ PutShape $ colorSH yellow
|
[ psPt atFstLnkOut $ PutShape $ colorSH yellow
|
||||||
$ barPP 1.5 (V3 20 (-1) 0) (V3 20 (-1) 80)
|
$ barPP 1.5 (V3 20 (-1) 0) (V3 20 (-1) 80)
|
||||||
]
|
]
|
||||||
& rmOutPmnt .~
|
& rmOutPmnt .~
|
||||||
[OutPlacement
|
[OutPlacement
|
||||||
(analyser sa sb sc sd
|
(analyser
|
||||||
mcf
|
mcf
|
||||||
(atFstLnkOutShiftBy (\(p,a) -> (p +.+ rotateV a (V2 18.5 (-2.5)), a)))
|
(atFstLnkOutShiftBy (\(p,a) -> (p +.+ rotateV a (V2 18.5 (-2.5)), a)))
|
||||||
(atFstLnkOutShiftBy sensorshift)
|
(atFstLnkOutShiftBy sensorshift)
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ addWarningTerminal outplid = (rmName .++~ "warningTerm-")
|
|||||||
termMessages trid = defaultTermParams & addInputLine
|
termMessages trid = defaultTermParams & addInputLine
|
||||||
[unlockCommand trid,quitCommand]
|
[unlockCommand trid,quitCommand]
|
||||||
[helpCommand,infoCommand theinfo,commandsCommand]
|
[helpCommand,infoCommand theinfo,commandsCommand]
|
||||||
unlockCommand trid = singleCommand "OPEN" ["YES","Y"] "OPEN THE CONNECTED DOOR." (toggledoor trid)
|
unlockCommand trid = singleCommand ["DOOR OPENED"] "OPEN" ["YES","Y"] "OPEN THE CONNECTED DOOR." (toggledoor trid)
|
||||||
toggledoor trid w' = w' & triggers . ix (fromJust $ _plMID trid) .~ const True
|
toggledoor trid w' = w' & triggers . ix (fromJust $ _plMID trid) .~ const True
|
||||||
theinfo = "DOOR CONTROLABLE WITH THE \"OPEN\" COMMAND. THIS TERMINAL CANNOT CLOSE THE DOOR."
|
theinfo = "DOOR CONTROLABLE WITH THE \"OPEN\" COMMAND. THIS TERMINAL CANNOT CLOSE THE DOOR."
|
||||||
|
|
||||||
|
|||||||
+39
-5
@@ -27,7 +27,16 @@ quitCommand = TerminalCommand
|
|||||||
disconnectTerminal :: Terminal -> World -> World
|
disconnectTerminal :: Terminal -> World -> World
|
||||||
disconnectTerminal tm w = w
|
disconnectTerminal tm w = w
|
||||||
& terminals . ix (_tmID tm) . tmStatus .~ Disconnected
|
& terminals . ix (_tmID tm) . tmStatus .~ Disconnected
|
||||||
& terminals . ix (_tmID tm) . tmFutureLines ++.~ [makeTermLine "DISCONNECTION COMPLETE"]
|
& terminals . ix (_tmID tm) . tmInput .~ Nothing
|
||||||
|
& exitTerminalSubInv
|
||||||
|
& terminals . ix (_tmID tm) . tmFutureLines .~
|
||||||
|
[ TerminalLineTerminalEffect 0 (tmDisplayedLines .~ [])
|
||||||
|
]
|
||||||
|
|
||||||
|
exitTerminalSubInv :: World -> World
|
||||||
|
exitTerminalSubInv w = case w ^? hud . hudElement . subInventory . termID of
|
||||||
|
Just _ -> w & hud . hudElement . subInventory .~ NoSubInventory
|
||||||
|
_ -> w
|
||||||
|
|
||||||
damageCodeCommand :: TerminalCommand
|
damageCodeCommand :: TerminalCommand
|
||||||
damageCodeCommand = TerminalCommand
|
damageCodeCommand = TerminalCommand
|
||||||
@@ -44,6 +53,29 @@ damageCodeCommand = TerminalCommand
|
|||||||
dinfo <- _sensorCoding (_genParams w) M.!? dtype
|
dinfo <- _sensorCoding (_genParams w) M.!? dtype
|
||||||
return $ Right $ w & infoClearInput tm [makeTermLine $ show (fst dinfo) ++ " " ++ show (snd dinfo)]
|
return $ Right $ w & infoClearInput tm [makeTermLine $ show (fst dinfo) ++ " " ++ show (snd dinfo)]
|
||||||
|
|
||||||
|
sensorCommand :: TerminalCommand
|
||||||
|
sensorCommand = TerminalCommand
|
||||||
|
{ _tcString = "SENSOR"
|
||||||
|
, _tcAlias = ["SEN"]
|
||||||
|
, _tcHelp = "ACCESS THE CONNECTED SENSOR"
|
||||||
|
, _tcArgumentType = Just "A SENSOR PARAMETER"
|
||||||
|
, _tcArguments = \tm w -> ["BOOL","VALUE"]
|
||||||
|
, _tcEffect = effectArgMessage sensf
|
||||||
|
}
|
||||||
|
effectArgMessage :: (String -> Terminal -> World -> Maybe [String])
|
||||||
|
-> [String] -> Terminal -> World -> Either String World
|
||||||
|
effectArgMessage f args tm w = maybe (Left "") Right $ do
|
||||||
|
arg <- safeHead args
|
||||||
|
strs <- f arg tm w
|
||||||
|
return $ w & terminals . ix (_tmID tm) . tmFutureLines ++.~ map makeTermLine strs
|
||||||
|
|
||||||
|
sensf :: String -> Terminal -> World -> Maybe [String]
|
||||||
|
sensf arg tm w = case arg of
|
||||||
|
"BOOL" -> Just [show $ w ^? machines . ix (_tmMachineID tm) . mcSensor . sensToggle]
|
||||||
|
_ -> Nothing
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
helpCommand :: TerminalCommand
|
helpCommand :: TerminalCommand
|
||||||
helpCommand = TerminalCommand
|
helpCommand = TerminalCommand
|
||||||
{ _tcString = "HELP"
|
{ _tcString = "HELP"
|
||||||
@@ -123,14 +155,16 @@ commandsCommand = TerminalCommand
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
singleCommand :: String -> [String] -> String -> (World -> World) -> TerminalCommand
|
singleCommand :: [String] -> String -> [String] -> String -> (World -> World) -> TerminalCommand
|
||||||
singleCommand command aliases htext eff = TerminalCommand
|
singleCommand followingLines command aliases htext eff = TerminalCommand
|
||||||
{_tcString = command
|
{_tcString = command
|
||||||
,_tcAlias = aliases
|
,_tcAlias = aliases
|
||||||
,_tcHelp = htext
|
,_tcHelp = htext
|
||||||
,_tcArgumentType = Nothing
|
,_tcArgumentType = Nothing
|
||||||
, _tcArguments = const $ const []
|
, _tcArguments = const $ const []
|
||||||
,_tcEffect = \_ tm w -> Right $ eff $ w & terminals . ix (_tmID tm) . tmInput .~ Nothing
|
,_tcEffect = \_ tm w -> Right $ eff $ w
|
||||||
|
& terminals . ix (_tmID tm) . tmInput . _Just . tiText .~ T.pack ""
|
||||||
|
& terminals . ix (_tmID tm) . tmFutureLines ++.~ map makeTermLine followingLines
|
||||||
-- & hud . hudElement . subInventory . onInputLine %~ const False
|
-- & hud . hudElement . subInventory . onInputLine %~ const False
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -189,7 +223,7 @@ defaultTermParams = defaultTerminal
|
|||||||
,_tmTitle = "TERMINAL"
|
,_tmTitle = "TERMINAL"
|
||||||
,_tmInput = Nothing
|
,_tmInput = Nothing
|
||||||
,_tmScrollCommands = []
|
,_tmScrollCommands = []
|
||||||
,_tmWriteCommands = []
|
,_tmWriteCommands = [helpCommand,commandsCommand]
|
||||||
,_tmProgram = \_ _ -> termSoundLine computerBeepingS
|
,_tmProgram = \_ _ -> termSoundLine computerBeepingS
|
||||||
: TerminalLineTerminalEffect 0 (tmStatus .~ Connected)
|
: TerminalLineTerminalEffect 0 (tmStatus .~ Connected)
|
||||||
: map makeTermLine connectionBlurb
|
: map makeTermLine connectionBlurb
|
||||||
|
|||||||
Reference in New Issue
Block a user