This commit is contained in:
2022-06-02 09:45:28 +01:00
parent 98cb8f2264
commit e112006b46
2 changed files with 24 additions and 14 deletions
+7 -3
View File
@@ -196,12 +196,16 @@ updateRBList :: World -> World
updateRBList w updateRBList w
| w ^? rbOptions . opCurInvPos == Just curinvid | w ^? rbOptions . opCurInvPos == Just curinvid
= w & setEquipAllocation & setEquipActivation = w & setEquipAllocation & setEquipActivation
| otherwise = case cr ^? crInv . ix (_crInvSel cr) . itUse . eqSite of | otherwise = case cr ^? crInv . ix curinvid . itUse . eqSite of
Just esite -> w Just esite -> w
& rbOptions .~ EquipOptions (equipSiteToPositions esite) (chooseEquipmentPosition cr (equipSiteToPositions esite)) curinvid DoNotMoveEquipment NoChangeActivateEquipment & rbOptions .~ EquipOptions (equipSiteToPositions esite)
(chooseEquipmentPosition cr (equipSiteToPositions esite))
curinvid
DoNotMoveEquipment
NoChangeActivateEquipment
& setEquipAllocation & setEquipActivation & setEquipAllocation & setEquipActivation
Nothing -> w & rbOptions .~ NoRightButtonOptions Nothing -> w & rbOptions .~ NoRightButtonOptions
| otherwise = w & rbOptions .~ NoRightButtonOptions -- | otherwise = w & rbOptions .~ NoRightButtonOptions
where where
curinvid = _crInvSel cr curinvid = _crInvSel cr
cr = you w cr = you w
+17 -11
View File
@@ -20,7 +20,7 @@ quitCommand = TerminalCommand
disconnectTerminal :: World -> World disconnectTerminal :: World -> World
disconnectTerminal = hud . hudElement . subInventory . termParams %~ disconnectTerminal = hud . hudElement . subInventory . termParams %~
( (termInput .~ Nothing) ( (termInput .~ Nothing)
. (termFutureLines ++.~ [TerminalLineDisplay 0 $ const ("DISCONNECTION COMPLETE",white)] ) . (termFutureLines ++.~ [makeTermLine "DISCONNECTION COMPLETE"] )
) )
helpCommand :: TerminalCommand helpCommand :: TerminalCommand
helpCommand = TerminalCommand helpCommand = TerminalCommand
@@ -39,8 +39,8 @@ helpf (str:_) w = maybe (Left "") Right $ do
commands <- getCommands w commands <- getCommands w
command <- find (\tc -> _tcString tc == str || str `elem` _tcAlias tc) commands command <- find (\tc -> _tcString tc == str || str `elem` _tcAlias tc) commands
return $ w & infoClearInput return $ w & infoClearInput
([TerminalLineDisplay 0 $ const ("COMMAND:" ++ _tcString command,white) ([makeTermLine ("COMMAND:" ++ _tcString command)
,TerminalLineDisplay 0 $ const ("ALIASES:" ++ unwords (_tcAlias command),white) ] ,makeTermLine ("ALIASES:" ++ unwords (_tcAlias command)) ]
++ stringToTermPara (_tcHelp command ++ " " ++ argumentHelp (_tcArgumentType command)) ++ stringToTermPara (_tcHelp command ++ " " ++ argumentHelp (_tcArgumentType command))
) )
getCommands :: World -> Maybe [TerminalCommand] getCommands :: World -> Maybe [TerminalCommand]
@@ -56,15 +56,20 @@ infoClearInput tls = hud . hudElement . subInventory . termParams %~
) )
) )
argumentHelp :: Maybe String -> String argumentHelp :: Maybe String -> String
argumentHelp mstr = case mstr of argumentHelp mstr = case mstr of
Nothing -> "ANY ARGUMENTS PROVIDED TO THIS COMMAND ARE IGNORED." Nothing -> "ANY ARGUMENTS PROVIDED TO THIS COMMAND ARE IGNORED."
Just str -> "EXPECTS " ++ str ++ " AS ARGUMENT." Just str -> "EXPECTS " ++ str ++ " AS ARGUMENT."
stringToTermPara :: String -> [TerminalLine] stringToTermPara :: String -> [TerminalLine]
stringToTermPara str = map (\s -> TerminalLineDisplay 0 $ const (s,white)) stringToTermPara = map makeTermLine . makeParagraph 60
(makeParagraph 60 str)
makeColorTermLine :: Color -> String -> TerminalLine
makeColorTermLine col str = TerminalLineDisplay 0 $ const (str,col)
makeTermLine :: String -> TerminalLine
makeTermLine = makeColorTermLine white
infoCommand :: String -> TerminalCommand infoCommand :: String -> TerminalCommand
infoCommand str = TerminalCommand infoCommand str = TerminalCommand
@@ -85,7 +90,7 @@ commandsCommand = TerminalCommand
, _tcArgumentType = Nothing , _tcArgumentType = Nothing
, _tcArguments = const [] , _tcArguments = const []
, _tcEffect = const $ \w -> Right $ w & infoClearInput , _tcEffect = const $ \w -> Right $ w & infoClearInput
(TerminalLineDisplay 0 (const ("AVAILABLE COMMANDS:",white)) ( makeTermLine "AVAILABLE COMMANDS:"
: stringToTermPara (unwords (maybe [""] (map _tcString) $ getCommands w)) : stringToTermPara (unwords (maybe [""] (map _tcString) $ getCommands w))
) )
} }
@@ -104,7 +109,8 @@ doTerminalEffect :: World -> World
doTerminalEffect w = fromMaybe w $ do doTerminalEffect w = fromMaybe w $ do
s <- fmap T.unpack $ w ^? hud . hudElement . subInventory . termParams . termInput . _Just s <- fmap T.unpack $ w ^? hud . hudElement . subInventory . termParams . termInput . _Just
return $ doTerminalEffect' s $ w return $ doTerminalEffect' s $ w
& hud . hudElement . subInventory . termParams . termFutureLines .~ [TerminalLineDisplay 0 (const ('>':s,greyN 0.9))] & hud . hudElement . subInventory . termParams . termFutureLines
.~ [makeColorTermLine (greyN 0.9) ('>':s)]
doTerminalEffect' :: String -> World -> World doTerminalEffect' :: String -> World -> World
doTerminalEffect' s w = fromMaybe (w & badinput) $ do doTerminalEffect' s w = fromMaybe (w & badinput) $ do
@@ -117,15 +123,15 @@ doTerminalEffect' s w = fromMaybe (w & badinput) $ do
Left err -> return $ w & hud . hudElement . subInventory . termParams %~ Left err -> return $ w & hud . hudElement . subInventory . termParams %~
( (termInput ?~ T.empty) ( (termInput ?~ T.empty)
. (termFutureLines ++.~ . (termFutureLines ++.~
[TerminalLineDisplay 0 [makeColorTermLine red
$ const ("^ INVALID ARGUMENT: EXPECTS "++fromJust (_tcArgumentType command)++ err ,red) ("^ INVALID ARGUMENT: EXPECTS "++fromJust (_tcArgumentType command)++ err)
] ]
) )
) )
where where
badinput = hud . hudElement . subInventory . termParams %~ badinput = hud . hudElement . subInventory . termParams %~
( (termInput ?~ T.empty) ( (termInput ?~ T.empty)
. (termFutureLines ++.~ [TerminalLineDisplay 0 $ const ("^ INVALID INPUT",red) . (termFutureLines ++.~ [makeColorTermLine red ("^ INVALID INPUT")
] ]
) )
) )