Cleanup
This commit is contained in:
+11
-23
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user