From 69fe28afe79e36aa952e7be4419dac3ff65ee0cf Mon Sep 17 00:00:00 2001 From: justin Date: Mon, 18 Nov 2024 11:02:12 +0000 Subject: [PATCH] Cleanup --- ghcidOutput | 11 +------ src/Dodge/Terminal.hs | 34 +++++++-------------- src/Dodge/Update/Input/InGame.hs | 51 -------------------------------- 3 files changed, 12 insertions(+), 84 deletions(-) diff --git a/ghcidOutput b/ghcidOutput index 7380d08c9..9dca0d81b 100644 --- a/ghcidOutput +++ b/ghcidOutput @@ -1,10 +1 @@ -/home/justin/Haskell/loop/src/Dodge/Update/Input/InGame.hs:159:1-21: warning: [-Wunused-top-binds] - Defined but not used: ‘updateCombineInvClick’ - | -159 | updateCombineInvClick sss w = case w ^. input . mouseContext of - | ^^^^^^^^^^^^^^^^^^^^^ -/home/justin/Haskell/loop/src/Dodge/Update/Input/InGame.hs:159:23-25: warning: [-Wunused-matches] - Defined but not used: ‘sss’ - | -159 | updateCombineInvClick sss w = case w ^. input . mouseContext of - | ^^^ +All good (594 modules, at 11:01:56) diff --git a/src/Dodge/Terminal.hs b/src/Dodge/Terminal.hs index ab7e27e5d..ef0eb6cb4 100644 --- a/src/Dodge/Terminal.hs +++ b/src/Dodge/Terminal.hs @@ -1,5 +1,4 @@ module Dodge.Terminal ( - doTerminalEffectLB, doTerminalCommandEffect, makeTermLine, commandFutureLines, @@ -18,9 +17,8 @@ module Dodge.Terminal ( terminalReturnEffect, ) where -import Dodge.Terminal.Type -import Control.Monad import Color +import Control.Monad import Data.Char import Data.Foldable import qualified Data.Map.Strict as M @@ -28,6 +26,7 @@ import Data.Maybe import Dodge.Data.World import Dodge.Default import Dodge.SoundLogic +import Dodge.Terminal.Type import Justify import LensHelp import ListHelp (safeHead, safeUncons) @@ -225,8 +224,9 @@ disconnectTerminal tm = exitTerminalSubInv :: World -> World exitTerminalSubInv w = case w ^? hud . hudElement . subInventory . termID of - Just _ -> w & hud . hudElement . subInventory - .~ NoSubInventory MouseInvNothing + Just _ -> + w & hud . hudElement . subInventory + .~ NoSubInventory MouseInvNothing _ -> w damageCodeCommand :: TerminalCommand @@ -260,13 +260,13 @@ commandFutureLines s tm w = fromMaybe [errline "^ Invalid command"] $ do case doTerminalCommandEffect (_tcEffect command) tm w of NoArguments tls -> Just tls OneArgument argtype m -> - let setpartial - | null (_tmPartialCommand tm) - = TerminalLineTerminalEffect 0 (TmTmSetPartialCommand (Just command)) : - makeTermPara ("Expects " ++ argtype ++ " as an argument") - | otherwise = + let setpartial + | null (_tmPartialCommand tm) = + TerminalLineTerminalEffect 0 (TmTmSetPartialCommand (Just command)) : + makeTermPara ("Expects " ++ argtype ++ " as an argument") + | otherwise = TerminalLineTerminalEffect 0 (TmTmSetPartialCommand Nothing) : - makeTermPara "No argument input, cancelling" + makeTermPara "No argument input, cancelling" in Just $ fromMaybe setpartial $ safeHead args >>= (m M.!?) @@ -292,15 +292,3 @@ runTerminalString s tm w = . (tmFutureLines ++.~ commandFutureLines s tm w) . (tmCommandHistory %~ take 10 . (s :)) ) - -doTerminalEffectLB :: Terminal -> World -> World -doTerminalEffectLB tm w = case w ^. input . mouseContext of - OverTerminalReturn -> fromMaybe w $ do - guard (_tmStatus tm == TerminalReady) - s <- w ^? cWorld . lWorld . terminals . ix (_tmID tm) . tmInput . tiText - return $ if null (words s) && null (_tmPartialCommand tm) - then w - else terminalReturnEffect tm w - OverTerminalEscape -> w - & hud . hudElement . subInventory .~ NoSubInventory MouseInvNothing - _ -> w diff --git a/src/Dodge/Update/Input/InGame.hs b/src/Dodge/Update/Input/InGame.hs index 893a83df1..4f2714bb5 100644 --- a/src/Dodge/Update/Input/InGame.hs +++ b/src/Dodge/Update/Input/InGame.hs @@ -60,9 +60,7 @@ updateUseInputInGame u = updateFunctionKeys $ case u ^. uvWorld . hud . hudEleme & uvWorld %~ setInvPosFromSS _ -> M.foldlWithKey' updateKeyInGame u pkeys where --- w = u ^. uvWorld pkeys = u ^. uvWorld . input . pressedKeys --- lbinitialpress = u ^? uvWorld . input . mouseButtons . ix ButtonLeft == Just 0 dodisplayregexinput x di = fromMaybe di $ do sss <- di ^? diSections msel <- di ^? diSelection @@ -152,55 +150,6 @@ updateFunctionKey uv sc InitialPress = case sc of _ -> uv updateFunctionKey uv _ _ = uv -updateCombineInvClick :: - IM.IntMap (SelectionSection CombinableItem) -> - World -> - World -updateCombineInvClick sss w = case w ^. input . mouseContext of - OverCombSelect x -> - w & hud . hudElement . subInventory . ciSelection ?~ x - & worldEventFlags . at CombineInventoryChange ?~ () - OverCombFilter -> - w & hud . hudElement . subInventory . ciFilter .~ Nothing - & worldEventFlags . at CombineInventoryChange ?~ () - OverCombCombine (i, j) -> - (worldEventFlags . at InventoryChange ?~ ()) . maybeExitCombine $ - tryCombine (i, j) w - & worldEventFlags . at CombineInventoryChange ?~ () - OverCombEscape -> - w - & worldEventFlags . at InventoryChange ?~ () - & hud . hudElement . subInventory .~ NoSubInventory MouseInvNothing - OverInvFilt (i, j) -> fromMaybe w $ do - guard $ i == 0 - str <- - fmap (take 5) $ - w - ^? hud . hudElement . diSections . ix i . ssItems . ix j . siPictures . ix 0 - return . (worldEventFlags . at CombineInventoryChange ?~ ()) $ - case w ^? hud . hudElement . subInventory . ciFilter . _Just of - Just (_ : xs) - | str == xs -> - w - & hud . hudElement . subInventory . ciFilter .~ Nothing - _ -> w & hud . hudElement . subInventory . ciFilter ?~ ("<" ++ str) - x -> - error $ - "while combining this mouse context should not be possible: " - ++ show x - --- x@(Just (i,_)) --- | x /= msel -> w & hud . hudElement . subInventory . ciSelection .~ x --- & worldEventFlags . at CombineInventoryChange ?~ () --- | i == -1 -> w & hud . hudElement . subInventory . ciFilter .~ Nothing --- & worldEventFlags . at CombineInventoryChange ?~ () --- _ | (w ^? hud . hudElement . subInventory . ciSelection . _Just . _1) == Just (-1) --- -> w & hud . hudElement . subInventory . ciFilter .~ Nothing --- & worldEventFlags . at CombineInventoryChange ?~ () --- _ -> (worldEventFlags . at InventoryChange ?~ ()) . maybeExitCombine $ --- tryCombine sss msel w --- & worldEventFlags . at CombineInventoryChange ?~ () - updatePressedButtonsCarte :: World -> World updatePressedButtonsCarte w = updatePressedButtonsCarte' (_mouseButtons (_input w)) w