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