Cleanup
This commit is contained in:
+1
-1
@@ -943,6 +943,7 @@ data TerminalStatus = Connected | Disconnected
|
|||||||
data TerminalInput = TerminalInput
|
data TerminalInput = TerminalInput
|
||||||
{ _tiText :: T.Text
|
{ _tiText :: T.Text
|
||||||
, _tiFocus :: Bool
|
, _tiFocus :: Bool
|
||||||
|
, _tiSel :: (Int,Int)
|
||||||
}
|
}
|
||||||
data Terminal = Terminal
|
data Terminal = Terminal
|
||||||
{ _tmID :: Int
|
{ _tmID :: Int
|
||||||
@@ -954,7 +955,6 @@ data Terminal = Terminal
|
|||||||
, _tmFutureLines :: [TerminalLine]
|
, _tmFutureLines :: [TerminalLine]
|
||||||
, _tmMaxLines :: Int
|
, _tmMaxLines :: Int
|
||||||
, _tmTitle :: String
|
, _tmTitle :: String
|
||||||
, _tmSel :: Maybe (Int,Int)
|
|
||||||
, _tmInput :: Maybe TerminalInput
|
, _tmInput :: Maybe TerminalInput
|
||||||
, _tmScrollCommands :: [TerminalCommand]
|
, _tmScrollCommands :: [TerminalCommand]
|
||||||
, _tmWriteCommands :: [TerminalCommand]
|
, _tmWriteCommands :: [TerminalCommand]
|
||||||
|
|||||||
@@ -208,7 +208,7 @@ defaultMachine = Machine
|
|||||||
{ _mcID = 0
|
{ _mcID = 0
|
||||||
, _mcWallIDs = mempty
|
, _mcWallIDs = mempty
|
||||||
, _mcUpdate = defaultMachineUpdate
|
, _mcUpdate = defaultMachineUpdate
|
||||||
, _mcDeath = \_ -> id
|
, _mcDeath = const id
|
||||||
, _mcApplyDamage = \_ _ -> id
|
, _mcApplyDamage = \_ _ -> id
|
||||||
, _mcDraw = const mempty
|
, _mcDraw = const mempty
|
||||||
, _mcColor = white
|
, _mcColor = white
|
||||||
@@ -244,7 +244,7 @@ defaultDrawButton col bt =
|
|||||||
defaultTerminal :: Terminal
|
defaultTerminal :: Terminal
|
||||||
defaultTerminal = Terminal
|
defaultTerminal = Terminal
|
||||||
{ _tmID = 0
|
{ _tmID = 0
|
||||||
, _tmProgram = (\_ _ -> [])
|
, _tmProgram = \_ _ -> []
|
||||||
, _tmButtonID = 0
|
, _tmButtonID = 0
|
||||||
, _tmMachineID = 0
|
, _tmMachineID = 0
|
||||||
, _tmName = "TESTTERMINAL"
|
, _tmName = "TESTTERMINAL"
|
||||||
@@ -252,7 +252,6 @@ defaultTerminal = Terminal
|
|||||||
, _tmFutureLines = []
|
, _tmFutureLines = []
|
||||||
, _tmMaxLines = 14
|
, _tmMaxLines = 14
|
||||||
, _tmTitle = "TERMINAL IN LOCATION"
|
, _tmTitle = "TERMINAL IN LOCATION"
|
||||||
, _tmSel = Nothing
|
|
||||||
, _tmInput = Nothing
|
, _tmInput = Nothing
|
||||||
, _tmScrollCommands = []
|
, _tmScrollCommands = []
|
||||||
, _tmWriteCommands = []
|
, _tmWriteCommands = []
|
||||||
|
|||||||
+12
-16
@@ -100,10 +100,6 @@ handlePressedMouseButton but w = case (_hudElement (_hud w), but) of
|
|||||||
| otherwise -> w & terminals . ix tmid . tmInput . _Just . tiFocus %~ const True
|
| otherwise -> w & terminals . ix tmid . tmInput . _Just . tiFocus %~ const True
|
||||||
( DisplayInventory (CombineInventory mi) , ButtonLeft)
|
( DisplayInventory (CombineInventory mi) , ButtonLeft)
|
||||||
-> maybe (hud . hudElement .~ DisplayInventory NoSubInventory) doCombine mi w
|
-> maybe (hud . hudElement .~ DisplayInventory NoSubInventory) doCombine mi w
|
||||||
-- -> fromMaybe (w & hud . hudElement .~ DisplayInventory NoSubInventory)
|
|
||||||
-- $ do -- ugly
|
|
||||||
-- i <- mi
|
|
||||||
-- return $ doCombine i w
|
|
||||||
_ -> w
|
_ -> w
|
||||||
|
|
||||||
-- note "sort" on the inventory indices; otherwise
|
-- note "sort" on the inventory indices; otherwise
|
||||||
@@ -154,17 +150,17 @@ wheelEvent y w = case _hudElement $ _hud w of
|
|||||||
& terminals . ix tmid %~ updatetermsel
|
& terminals . ix tmid %~ updatetermsel
|
||||||
_ -> w
|
_ -> w
|
||||||
where
|
where
|
||||||
updatetermsel tp = case _tmSel tp of
|
updatetermsel tm = case tm ^? tmInput . _Just . tiSel of
|
||||||
Nothing -> tp & tmSel ?~ (0,0)
|
Nothing -> tm & tmInput . _Just . tiSel .~ (0,0)
|
||||||
& tmInput . _Just . tiText %~ replacewith tp 0
|
& tmInput . _Just . tiText %~ replacewith tm 0
|
||||||
Just (i,_) -> let newi = ((`mod` length (scrollCommands tp)) . subtract yi) i
|
Just (i,_) -> let newi = ((`mod` length (scrollCommands tm)) . subtract yi) i
|
||||||
in tp & tmSel . _Just .~ (newi,0)
|
in tm & tmInput . _Just . tiSel .~ (newi,0)
|
||||||
& tmInput . _Just . tiText %~ replacewith tp newi
|
& tmInput . _Just . tiText %~ replacewith tm newi
|
||||||
updatetermsubsel tp = case _tmSel tp of
|
updatetermsubsel tm = case tm ^? tmInput . _Just . tiSel of
|
||||||
Nothing -> tp
|
Nothing -> tm
|
||||||
Just (i,j) -> let newj = (j - yi) `mod` (1 + length (_tcArguments (scrollCommands tp !! i) tp w))
|
Just (i,j) -> let newj = (j - yi) `mod` (1 + length (_tcArguments (scrollCommands tm !! i) tm w))
|
||||||
in tp & tmSel . _Just .~ (i,newj)
|
in tm & tmInput . _Just . tiSel .~ (i,newj)
|
||||||
& tmInput . _Just . tiText %~ replacewith' tp i newj w
|
& tmInput . _Just . tiText %~ replacewith' tm i newj w
|
||||||
replacewith tp newi _ = T.pack (_tcString (scrollCommands tp !! newi))
|
replacewith tp newi _ = T.pack (_tcString (scrollCommands tp !! newi))
|
||||||
replacewith' tp i j w' _ = T.pack $ _tcString tc ++ " " ++ arg-- ++ ((_tcArguments tp) w !! j)
|
replacewith' tp i j w' _ = T.pack $ _tcString tc ++ " " ++ arg-- ++ ((_tcArguments tp) w !! j)
|
||||||
where
|
where
|
||||||
@@ -187,7 +183,7 @@ nullCommand = TerminalCommand
|
|||||||
, _tcHelp = ""
|
, _tcHelp = ""
|
||||||
, _tcArgumentType = Nothing
|
, _tcArgumentType = Nothing
|
||||||
, _tcArguments = const (const [])
|
, _tcArguments = const (const [])
|
||||||
, _tcEffect = const $ \_ w -> Right $ w
|
, _tcEffect = const $ \_ w -> Right w
|
||||||
}
|
}
|
||||||
|
|
||||||
scrollRBOption :: Float -> World -> World
|
scrollRBOption :: Float -> World -> World
|
||||||
|
|||||||
@@ -54,9 +54,7 @@ analyser starts sucs _ afters upf pslight psmc = extTrigLitPos pslight $ \tp ->
|
|||||||
where
|
where
|
||||||
tparams = defaultTermParams & tmFutureLines ++.~
|
tparams = defaultTermParams & tmFutureLines ++.~
|
||||||
(map makeTermLine starts ++ [makeTermLine sucs] ++ map makeTermLine afters)
|
(map makeTermLine starts ++ [makeTermLine sucs] ++ map makeTermLine afters)
|
||||||
termupdate tp _ =
|
termupdate tp _ mc = upf mc . (triggers . ix (fromJust $ _plMID tp) .~ const (_sensToggle $ _mcSensor mc))
|
||||||
(\mc -> upf mc . (triggers . ix (fromJust $ _plMID tp) .~ const (_sensToggle $ _mcSensor mc))
|
|
||||||
)
|
|
||||||
|
|
||||||
analyserTest :: (World -> Bool) -> Machine -> World -> World
|
analyserTest :: (World -> Bool) -> Machine -> World -> World
|
||||||
analyserTest t mc w = case
|
analyserTest t mc w = case
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ putTerminal''
|
|||||||
-> (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) $ \tmpl -> Just $
|
||||||
ps0PushPS (PutButton $ termButton)
|
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' -> (buttons . at (fromJust (_plMID btpl)) .~ Nothing) . fd mc')
|
||||||
|
|||||||
@@ -126,7 +126,8 @@ subInventoryDisplay subinv cfig w = case subinv of
|
|||||||
where
|
where
|
||||||
displayTermInput tp = case _tmInput tp of
|
displayTermInput tp = case _tmInput tp of
|
||||||
Nothing -> id
|
Nothing -> id
|
||||||
Just (TerminalInput s inputstatus) -> (++ [('>':T.unpack s++displayBlinkCursor inputstatus,white)])
|
Just (TerminalInput s inputstatus _)
|
||||||
|
-> (++ [('>':T.unpack s++displayBlinkCursor inputstatus,white)])
|
||||||
displayBlinkCursor inputstatus | inputstatus = clockCycle 10 (V.fromList ["_",""]) w
|
displayBlinkCursor inputstatus | inputstatus = clockCycle 10 (V.fromList ["_",""]) w
|
||||||
| otherwise = []
|
| otherwise = []
|
||||||
closeobjectcursor = case selectedCloseObject w of
|
closeobjectcursor = case selectedCloseObject w of
|
||||||
|
|||||||
@@ -73,7 +73,7 @@ getCommands tm w = do
|
|||||||
|
|
||||||
infoClearInput :: Terminal -> [TerminalLine] -> World -> World
|
infoClearInput :: Terminal -> [TerminalLine] -> World -> World
|
||||||
infoClearInput tm tls = terminals . ix (_tmID tm) %~
|
infoClearInput tm tls = terminals . ix (_tmID tm) %~
|
||||||
( (tmInput ?~ TerminalInput T.empty True)
|
( (tmInput ?~ TerminalInput T.empty True (0,0))
|
||||||
. (tmFutureLines ++.~ tls
|
. (tmFutureLines ++.~ tls
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
@@ -156,7 +156,7 @@ doTerminalEffect' s tm w = fromMaybe (w & badinput) $ do
|
|||||||
case _tcEffect command args tm w of
|
case _tcEffect command args tm w of
|
||||||
Right w' -> return w'
|
Right w' -> return w'
|
||||||
Left err -> return $ w & terminals . ix (_tmID tm) %~
|
Left err -> return $ w & terminals . ix (_tmID tm) %~
|
||||||
( (tmInput ?~ TerminalInput T.empty True)
|
( (tmInput ?~ TerminalInput T.empty True (0,0))
|
||||||
. (tmFutureLines ++.~
|
. (tmFutureLines ++.~
|
||||||
[makeColorTermLine red
|
[makeColorTermLine red
|
||||||
("^ INVALID ARGUMENT: EXPECTS "++fromJust (_tcArgumentType command)++ err)
|
("^ INVALID ARGUMENT: EXPECTS "++fromJust (_tcArgumentType command)++ err)
|
||||||
@@ -165,7 +165,7 @@ doTerminalEffect' s tm w = fromMaybe (w & badinput) $ do
|
|||||||
)
|
)
|
||||||
where
|
where
|
||||||
badinput = terminals . ix (_tmID tm) %~
|
badinput = terminals . ix (_tmID tm) %~
|
||||||
( (tmInput ?~ TerminalInput T.empty True)
|
( (tmInput ?~ TerminalInput T.empty True (0,0))
|
||||||
. (tmFutureLines ++.~ [makeColorTermLine red "^ INVALID INPUT" ]
|
. (tmFutureLines ++.~ [makeColorTermLine red "^ INVALID INPUT" ]
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
@@ -187,7 +187,6 @@ defaultTermParams = defaultTerminal
|
|||||||
,_tmFutureLines = []
|
,_tmFutureLines = []
|
||||||
,_tmMaxLines = 14
|
,_tmMaxLines = 14
|
||||||
,_tmTitle = "TERMINAL"
|
,_tmTitle = "TERMINAL"
|
||||||
,_tmSel = Nothing
|
|
||||||
,_tmInput = Nothing
|
,_tmInput = Nothing
|
||||||
,_tmScrollCommands = []
|
,_tmScrollCommands = []
|
||||||
,_tmWriteCommands = []
|
,_tmWriteCommands = []
|
||||||
|
|||||||
+1
-1
@@ -116,7 +116,7 @@ tmUpdate tm w = case w ^? terminals . ix (_tmID tm) . tmFutureLines . ix 0 of
|
|||||||
Just (TerminalLineInput _) -> w
|
Just (TerminalLineInput _) -> w
|
||||||
& pointTermParams %~
|
& pointTermParams %~
|
||||||
( ( tmFutureLines %~ tail )
|
( ( tmFutureLines %~ tail )
|
||||||
. ( tmInput ?~ TerminalInput T.empty True) )
|
. ( tmInput ?~ TerminalInput T.empty True (0,0)) )
|
||||||
where
|
where
|
||||||
pointTermParams = terminals . ix (_tmID tm)
|
pointTermParams = terminals . ix (_tmID tm)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user