From e112006b46eec57ff937c2cf8a37a6651e4484c9 Mon Sep 17 00:00:00 2001 From: justin Date: Thu, 2 Jun 2022 09:45:28 +0100 Subject: [PATCH] Cleanup --- src/Dodge/Inventory.hs | 10 +++++++--- src/Dodge/Terminal.hs | 28 +++++++++++++++++----------- 2 files changed, 24 insertions(+), 14 deletions(-) diff --git a/src/Dodge/Inventory.hs b/src/Dodge/Inventory.hs index b6285c1fc..082436c70 100644 --- a/src/Dodge/Inventory.hs +++ b/src/Dodge/Inventory.hs @@ -196,12 +196,16 @@ updateRBList :: World -> World updateRBList w | w ^? rbOptions . opCurInvPos == Just curinvid = 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 - & rbOptions .~ EquipOptions (equipSiteToPositions esite) (chooseEquipmentPosition cr (equipSiteToPositions esite)) curinvid DoNotMoveEquipment NoChangeActivateEquipment + & rbOptions .~ EquipOptions (equipSiteToPositions esite) + (chooseEquipmentPosition cr (equipSiteToPositions esite)) + curinvid + DoNotMoveEquipment + NoChangeActivateEquipment & setEquipAllocation & setEquipActivation Nothing -> w & rbOptions .~ NoRightButtonOptions - | otherwise = w & rbOptions .~ NoRightButtonOptions +-- | otherwise = w & rbOptions .~ NoRightButtonOptions where curinvid = _crInvSel cr cr = you w diff --git a/src/Dodge/Terminal.hs b/src/Dodge/Terminal.hs index 50439b214..9a5510214 100644 --- a/src/Dodge/Terminal.hs +++ b/src/Dodge/Terminal.hs @@ -20,7 +20,7 @@ quitCommand = TerminalCommand disconnectTerminal :: World -> World disconnectTerminal = hud . hudElement . subInventory . termParams %~ ( (termInput .~ Nothing) - . (termFutureLines ++.~ [TerminalLineDisplay 0 $ const ("DISCONNECTION COMPLETE",white)] ) + . (termFutureLines ++.~ [makeTermLine "DISCONNECTION COMPLETE"] ) ) helpCommand :: TerminalCommand helpCommand = TerminalCommand @@ -39,8 +39,8 @@ helpf (str:_) w = maybe (Left "") Right $ do commands <- getCommands w command <- find (\tc -> _tcString tc == str || str `elem` _tcAlias tc) commands return $ w & infoClearInput - ([TerminalLineDisplay 0 $ const ("COMMAND:" ++ _tcString command,white) - ,TerminalLineDisplay 0 $ const ("ALIASES:" ++ unwords (_tcAlias command),white) ] + ([makeTermLine ("COMMAND:" ++ _tcString command) + ,makeTermLine ("ALIASES:" ++ unwords (_tcAlias command)) ] ++ stringToTermPara (_tcHelp command ++ " " ++ argumentHelp (_tcArgumentType command)) ) getCommands :: World -> Maybe [TerminalCommand] @@ -56,15 +56,20 @@ infoClearInput tls = hud . hudElement . subInventory . termParams %~ ) ) - argumentHelp :: Maybe String -> String argumentHelp mstr = case mstr of Nothing -> "ANY ARGUMENTS PROVIDED TO THIS COMMAND ARE IGNORED." Just str -> "EXPECTS " ++ str ++ " AS ARGUMENT." stringToTermPara :: String -> [TerminalLine] -stringToTermPara str = map (\s -> TerminalLineDisplay 0 $ const (s,white)) - (makeParagraph 60 str) +stringToTermPara = map makeTermLine . makeParagraph 60 + +makeColorTermLine :: Color -> String -> TerminalLine +makeColorTermLine col str = TerminalLineDisplay 0 $ const (str,col) + +makeTermLine :: String -> TerminalLine +makeTermLine = makeColorTermLine white + infoCommand :: String -> TerminalCommand infoCommand str = TerminalCommand @@ -85,7 +90,7 @@ commandsCommand = TerminalCommand , _tcArgumentType = Nothing , _tcArguments = const [] , _tcEffect = const $ \w -> Right $ w & infoClearInput - (TerminalLineDisplay 0 (const ("AVAILABLE COMMANDS:",white)) + ( makeTermLine "AVAILABLE COMMANDS:" : stringToTermPara (unwords (maybe [""] (map _tcString) $ getCommands w)) ) } @@ -104,7 +109,8 @@ doTerminalEffect :: World -> World doTerminalEffect w = fromMaybe w $ do s <- fmap T.unpack $ w ^? hud . hudElement . subInventory . termParams . termInput . _Just 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' 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 %~ ( (termInput ?~ T.empty) . (termFutureLines ++.~ - [TerminalLineDisplay 0 - $ const ("^ INVALID ARGUMENT: EXPECTS "++fromJust (_tcArgumentType command)++ err ,red) + [makeColorTermLine red + ("^ INVALID ARGUMENT: EXPECTS "++fromJust (_tcArgumentType command)++ err) ] ) ) where badinput = hud . hudElement . subInventory . termParams %~ ( (termInput ?~ T.empty) - . (termFutureLines ++.~ [TerminalLineDisplay 0 $ const ("^ INVALID INPUT",red) + . (termFutureLines ++.~ [makeColorTermLine red ("^ INVALID INPUT") ] ) )