Start work simplifying terminals, aim towards respawn terminals

This commit is contained in:
2025-08-14 19:26:52 +01:00
parent 04c60151e1
commit 198b7acc78
6 changed files with 13 additions and 16 deletions
+1 -1
View File
@@ -47,7 +47,7 @@ data Terminal = Terminal
, _tmCommandHistory :: [String] , _tmCommandHistory :: [String]
, _tmToggles :: M.Map String TerminalToggle , _tmToggles :: M.Map String TerminalToggle
, _tmPartialCommand :: Maybe TerminalCommand , _tmPartialCommand :: Maybe TerminalCommand
, _tmType :: TerminalType -- , _tmType :: TerminalType
} }
--deriving (Eq, Show, Read) --, Generic) --deriving (Eq, Show, Read) --, Generic)
--h--deriving (Eq, Show, Read) --Generic, Flat) --h--deriving (Eq, Show, Read) --Generic, Flat)
-1
View File
@@ -25,7 +25,6 @@ defaultTerminal =
, _tmCommandHistory = [] , _tmCommandHistory = []
, _tmToggles = mempty , _tmToggles = mempty
, _tmPartialCommand = Nothing , _tmPartialCommand = Nothing
, _tmType = DefaultTerminal
, _tmExternalColor = dark magenta , _tmExternalColor = dark magenta
} }
+3 -3
View File
@@ -363,7 +363,7 @@ combineInventoryExtra sss msel cfig w = fromMaybe mempty $ do
drawTerminalDisplay :: Int -> Configuration -> LWorld -> Picture drawTerminalDisplay :: Int -> Configuration -> LWorld -> Picture
drawTerminalDisplay tid cfig w = fromMaybe mempty $ do drawTerminalDisplay tid cfig w = fromMaybe mempty $ do
tm <- w ^? terminals . ix tid tm <- w ^? terminals . ix tid
let tsize = getMaxLinesTM (tm ^. tmType) + 1 let tsize = getMaxLinesTM + 1
return $ return $
invHead cfig (_tmTitle tm ++ ":T" ++ show tid) invHead cfig (_tmTitle tm ++ ":T" ++ show tid)
<> drawSelectionList secondColumnParams cfig (thesellist tm) <> drawSelectionList secondColumnParams cfig (thesellist tm)
@@ -378,14 +378,14 @@ drawTerminalDisplay tid cfig w = fromMaybe mempty $ do
thelist tm = thelist tm =
map toselitm . displayTermInput tm map toselitm . displayTermInput tm
. reverse . reverse
. take (getMaxLinesTM (tm ^. tmType)) . take getMaxLinesTM
$ _tmDisplayedLines tm $ _tmDisplayedLines tm
displayTermInput tm = case _tmInput tm of displayTermInput tm = case _tmInput tm of
TerminalInput{_tiText = s} -> TerminalInput{_tiText = s} ->
(++ [(displayInputText tm s ++ [cFilledRect], white)]) (++ [(displayInputText tm s ++ [cFilledRect], white)])
partcommand tm = maybe "" (++ " ") $ tm ^? tmPartialCommand . _Just . tcString partcommand tm = maybe "" (++ " ") $ tm ^? tmPartialCommand . _Just . tcString
displayInputText tm s displayInputText tm s
| _tmStatus tm == TerminalReady = partcommand tm ++ getPromptTM (tm ^. tmType) ++ s | _tmStatus tm == TerminalReady = partcommand tm ++ getPromptTM ++ s
| otherwise = "" | otherwise = ""
-- | hasfoc = clockCycle 10 (V.fromList [[cFilledRect] , "."]) w -- | hasfoc = clockCycle 10 (V.fromList [[cFilledRect] , "."]) w
+1 -1
View File
@@ -284,7 +284,7 @@ terminalReturnEffect tmid w = fromMaybe w $ do
w w
& cWorld . lWorld . terminals . ix tmid . tmPartialCommand .~ Nothing & cWorld . lWorld . terminals . ix tmid . tmPartialCommand .~ Nothing
& cWorld . lWorld . terminals . ix tmid . tmFutureLines & cWorld . lWorld . terminals . ix tmid . tmFutureLines
.~ [makeTermLine (pc ++ getPromptTM (tm ^. tmType) ++ s)] .~ [makeTermLine (pc ++ getPromptTM ++ s)]
runTerminalString :: String -> Terminal -> World -> World runTerminalString :: String -> Terminal -> World -> World
runTerminalString s tm w = runTerminalString s tm w =
+4 -6
View File
@@ -3,10 +3,8 @@ module Dodge.Terminal.Type (
getMaxLinesTM, getMaxLinesTM,
) where ) where
import Dodge.Data.Terminal getPromptTM :: String
getPromptTM = "> "
getPromptTM :: TerminalType -> String getMaxLinesTM :: Int
getPromptTM _ = "> " getMaxLinesTM = 14
getMaxLinesTM :: TerminalType -> Int
getMaxLinesTM _ = 14
+4 -4
View File
@@ -397,7 +397,7 @@ updateMouseContextGame cfig u = case u ^. uvWorld . input . mouseContext of
tmid <- w ^? hud . hudElement . subInventory . termID tmid <- w ^? hud . hudElement . subInventory . termID
tm <- w ^? cWorld . lWorld . terminals . ix tmid tm <- w ^? cWorld . lWorld . terminals . ix tmid
return $ return $
if isOverTerminalScreen cfig tm mpos if isOverTerminalScreen cfig mpos
then fromMaybe NoMouseContext $ do then fromMaybe NoMouseContext $ do
let s = tm ^. tmInput . tiText let s = tm ^. tmInput . tiText
guard $ not (null s) && _tmStatus tm == TerminalReady guard $ not (null s) && _tmStatus tm == TerminalReady
@@ -415,8 +415,8 @@ getMenuMouseContext screen u = case screen ^. scOptions of
Just True -> MouseMenuClick yi Just True -> MouseMenuClick yi
_ -> NoMouseContext _ -> NoMouseContext
isOverTerminalScreen :: Configuration -> Terminal -> Point2 -> Bool isOverTerminalScreen :: Configuration -> Point2 -> Bool
isOverTerminalScreen cfig tm (V2 x y) = isOverTerminalScreen cfig (V2 x y) =
x <= xmax x <= xmax
&& x >= xmin - 5 && x >= xmin - 5
&& y <= ymax + 5 && y <= ymax + 5
@@ -424,7 +424,7 @@ isOverTerminalScreen cfig tm (V2 x y) =
where where
ldp = secondColumnParams ldp = secondColumnParams
V2 xmin ymax = screenPosAbs cfig (ldp ^. ldpPos) V2 xmin ymax = screenPosAbs cfig (ldp ^. ldpPos)
tsize = fromIntegral $ getMaxLinesTM (tm ^. tmType) + 1 tsize = fromIntegral $ getMaxLinesTM + 1
s = 5 + tsize * (20 * ldp ^. ldpScale + ldp ^. ldpVerticalGap) s = 5 + tsize * (20 * ldp ^. ldpScale + ldp ^. ldpVerticalGap)
ymin = ymax - s ymin = ymax - s
xmax = xmin + 555 -- HACK drawSelectionListBackground xmax = xmin + 555 -- HACK drawSelectionListBackground