Remove possiblity of displayed but non-focussed terminal

This commit is contained in:
2024-11-16 20:25:49 +00:00
parent 86f185c71e
commit a0431ff9a3
11 changed files with 16 additions and 39 deletions
+1 -1
View File
@@ -1 +1 @@
All good (594 modules, at 16:39:41)
All good (594 modules, at 16:59:49)
+1 -1
View File
File diff suppressed because one or more lines are too long
-1
View File
@@ -18,7 +18,6 @@ data TerminalStatus = TerminalOff | TerminalBusy | TerminalReady
data TerminalInput = TerminalInput
{ _tiText :: String
, _tiFocus :: Bool
, _tiSel :: (Int, Int)
}
--deriving (Eq, Ord, Show, Read) --Generic, Flat)
-1
View File
@@ -34,6 +34,5 @@ defaultTerminalInput :: TerminalInput
defaultTerminalInput =
TerminalInput
{ _tiText = ""
, _tiFocus = True
, _tiSel = (0, 0)
}
+1 -10
View File
@@ -1,5 +1,4 @@
module Dodge.InputFocus (
inTermFocus,
inInvRegex,
inCloseRegex,
inSubInvRegex,
@@ -14,13 +13,6 @@ import Data.Maybe
import Dodge.Data.World
import LensHelp
inTermFocus :: World -> Bool
inTermFocus w = fromMaybe False $ do
tmid <- w ^? hud . hudElement . subInventory . termID
hasfocus <- w ^? cWorld . lWorld . terminals . ix tmid . tmInput . tiFocus
connectionstatus <- w ^? cWorld . lWorld . terminals . ix tmid . tmStatus
return $ hasfocus && connectionstatus == TerminalReady
--regexScope ::
-- (Applicative f) =>
-- World ->
@@ -75,9 +67,8 @@ inputFocus w = case w ^? hud . hudElement . subInventory of
Just (-1, _) -> Just $ hud . hudElement . subInventory . ciFilter . _Just
_ -> Nothing
Just DisplayTerminal{_termID = tmid} -> do
hasfocus <- w ^? cWorld . lWorld . terminals . ix tmid . tmInput . tiFocus
connectionstatus <- w ^? cWorld . lWorld . terminals . ix tmid . tmStatus
guard $ hasfocus && connectionstatus == TerminalReady
guard $ connectionstatus == TerminalReady
return $ cWorld . lWorld . terminals . ix tmid . tmInput . tiText
_ -> Nothing
where
+2 -5
View File
@@ -366,16 +366,13 @@ drawTerminalDisplay tid cfig w = fromMaybe mempty $ do
. take (getMaxLinesTM (tm ^. tmType))
$ _tmDisplayedLines tm
displayTermInput tm = case _tmInput tm of
TerminalInput{_tiText = s, _tiFocus = hasfoc} ->
(++ [(displayInputText tm s ++ displayBlinkCursor hasfoc, white)])
TerminalInput{_tiText = s} ->
(++ [(displayInputText tm s ++ [cFilledRect], white)])
partcommand tm = maybe "" (++ " ") $ tm ^? tmPartialCommand . _Just . tcString
displayInputText tm s
| _tmStatus tm == TerminalReady = partcommand tm ++ getPromptTM (tm ^. tmType) ++ s
| otherwise = ""
displayBlinkCursor hasfoc
-- | hasfoc = clockCycle 10 (V.fromList [[cFilledRect] , "."]) w
| hasfoc = [cFilledRect]
| otherwise = [cWireRect]
lnkMidPosInvSelsCol :: Configuration -> World -> Int -> Color -> [Int] -> Picture
lnkMidPosInvSelsCol cfig w i col = fromMaybe mempty . foldMap f
+4 -9
View File
@@ -288,7 +288,7 @@ terminalReturnEffect tm w = fromMaybe w $ do
runTerminalString :: String -> Terminal -> World -> World
runTerminalString s tm w =
w & cWorld . lWorld . terminals . ix (_tmID tm)
%~ ( (tmInput .~ TerminalInput{_tiText = mempty, _tiFocus = True, _tiSel = (0, 0)})
%~ ( (tmInput .~ TerminalInput{_tiText = mempty, _tiSel = (0, 0)})
. (tmFutureLines ++.~ commandFutureLines s tm w)
. (tmCommandHistory %~ take 10 . (s :))
)
@@ -297,11 +297,6 @@ doTerminalEffectLB :: Terminal -> World -> World
doTerminalEffectLB tm w = fromMaybe w $ do
guard (_tmStatus tm == TerminalReady)
s <- w ^? cWorld . lWorld . terminals . ix (_tmID tm) . tmInput . tiText
if null (words s) && null (_tmPartialCommand tm)
then Just $ defocusTerminalInput w
else return $ terminalReturnEffect tm w
defocusTerminalInput :: World -> World
defocusTerminalInput w = fromMaybe w $ do
tmid <- w ^? hud . hudElement . subInventory . termID
return $ w & cWorld . lWorld . terminals . ix tmid . tmInput . tiFocus %~ const False
return $ if null (words s) && null (_tmPartialCommand tm)
then w
else terminalReturnEffect tm w
+3 -1
View File
@@ -421,7 +421,9 @@ updateMouseContext cfig w =
tm <- w ^? cWorld . lWorld . terminals . ix tmid
return $
if isOverTerminalScreen cfig tm mpos
then OverTerminalReturn
then if null $ tm ^. tmInput . tiText
then NoMouseContext
else OverTerminalReturn
else OverTerminalEscape
isOverTerminalScreen :: Configuration -> Terminal -> Point2 -> Bool
+2 -5
View File
@@ -36,12 +36,9 @@ updateUseInputInGame u = updateFunctionKeys $ case u ^. uvWorld . hud . hudEleme
DisplayCarte -> over uvWorld updatePressedButtonsCarte u
DisplayInventory{_subInventory = si} -> case si of
DisplayTerminal tmid
| lbinitialpress && inTermFocus w -> u & uvWorld
| lbinitialpress -> u & uvWorld
%~ doTerminalEffectLB (w ^?! cWorld . lWorld . terminals . ix tmid)
| inTermFocus (_uvWorld u) -> updateKeysInTerminal tmid u
| lbinitialpress ->
u & uvWorld . cWorld . lWorld . terminals . ix tmid . tmInput . tiFocus
%~ const True
| otherwise -> updateKeysInTerminal tmid u
CombineInventory{_ciSections = sss, _ciSelection = msel}
| lbinitialpress -> u & uvWorld %~ updateCombineInvClick sss
| inSubInvRegex (u ^. uvWorld) ->
+2 -4
View File
@@ -7,7 +7,6 @@ import Data.Maybe
import Dodge.Base
import Dodge.Data.Universe
--import Dodge.HeldScroll
import Dodge.InputFocus
import Dodge.Inventory
import Dodge.SelectionSections
--import Dodge.SoundLogic
@@ -78,15 +77,14 @@ guardDisconnectedID tmid w w' = case w ^? cWorld . lWorld . terminals . ix tmid
terminalWheelEvent :: Int -> Int -> World -> World
terminalWheelEvent yi tmid w
| rbDown && inTermFocus w =
| rbDown =
guardDisconnectedID tmid w $
w
& cWorld . lWorld . terminals . ix tmid %~ updatetermsubsel
| inTermFocus w =
| otherwise =
guardDisconnectedID tmid w $
w
& cWorld . lWorld . terminals . ix tmid %~ updatetermsel
| otherwise = w
where
rbDown = ButtonRight `M.member` _mouseButtons (_input w)
updatetermsel tm = case tm ^? tmInput . tiSel of
-1
View File
@@ -56,7 +56,6 @@ accessTerminal mtmid w = fromMaybe w $ do
tmid <- mtmid
return $
w & hud . hudElement . subInventory .~ DisplayTerminal tmid
& cWorld . lWorld . terminals . ix tmid . tmInput . tiFocus .~ True
& cWorld . lWorld . terminals . ix tmid %~ tryToBoot
where
tryToBoot tm = case _tmStatus tm of