Compare commits

..
4 Commits
Author SHA1 Message Date
justin 1d5f982fcc Add file 2023-05-03 11:19:59 +01:00
justin ed8d8f0e93 Work on terminals 2023-05-03 11:19:47 +01:00
justin 61f88aeb4a Cleanup 2023-05-01 22:35:33 +01:00
justin 7b8b8750a9 Fix zoom bug 2023-05-01 14:27:49 +01:00
16 changed files with 228 additions and 239 deletions
Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.7 KiB

After

Width:  |  Height:  |  Size: 4.7 KiB

+1 -1
View File
@@ -56,5 +56,5 @@ chaseCritVocalization =
, seagullCry1S , seagullCry1S
, seagullCry2S , seagullCry2S
] ]
(50,100) (50, 200)
0 0
+3 -1
View File
@@ -31,7 +31,7 @@ data TerminalBootProgram
data Terminal = Terminal data Terminal = Terminal
{ _tmID :: Int { _tmID :: Int
, _tmBootProgram :: TerminalBootProgram -- Terminal -> World -> [TerminalLine] , _tmBootProgram :: TerminalBootProgram
, _tmButtonID :: Int , _tmButtonID :: Int
, _tmMachineID :: Int , _tmMachineID :: Int
, _tmName :: String , _tmName :: String
@@ -46,6 +46,7 @@ data Terminal = Terminal
, _tmStatus :: TerminalStatus , _tmStatus :: TerminalStatus
, _tmCommandHistory :: [String] , _tmCommandHistory :: [String]
, _tmToggles :: M.Map String TerminalToggle , _tmToggles :: M.Map String TerminalToggle
, _tmPartialCommand :: Maybe String
} }
--deriving (Eq, Show, Read) --, Generic) --deriving (Eq, Show, Read) --, Generic)
--h--deriving (Eq, Show, Read) --Generic, Flat) --h--deriving (Eq, Show, Read) --Generic, Flat)
@@ -57,6 +58,7 @@ data TmTm
= TmId = TmId
| TmTmClearDisplayedLines | TmTmClearDisplayedLines
| TmTmSetStatus TerminalStatus | TmTmSetStatus TerminalStatus
| TmTmSetPartialCommand (Maybe String)
--deriving (Eq, Ord, Show, Read) --Generic, Flat) --deriving (Eq, Ord, Show, Read) --Generic, Flat)
data TerminalLine data TerminalLine
+5 -3
View File
@@ -1,6 +1,7 @@
module Dodge.Default.Terminal where module Dodge.Default.Terminal
( defaultTerminal
) where
import qualified Data.Map.Strict as M
import Dodge.Data.Terminal import Dodge.Data.Terminal
import Dodge.Data.WorldEffect import Dodge.Data.WorldEffect
@@ -22,7 +23,8 @@ defaultTerminal =
, _tmDeathEffect = TmWdId , _tmDeathEffect = TmWdId
, _tmStatus = TerminalOff , _tmStatus = TerminalOff
, _tmCommandHistory = [] , _tmCommandHistory = []
, _tmToggles = M.empty , _tmToggles = mempty
, _tmPartialCommand = mempty
} }
defaultTerminalInput :: TerminalInput defaultTerminalInput :: TerminalInput
+13 -8
View File
@@ -10,7 +10,7 @@ module Dodge.Inventory (
rmInvItem, rmInvItem,
updateCloseObjects, updateCloseObjects,
updateRBList, updateRBList,
updateTerminal, checkTermDist,
closeObjScrollDir, closeObjScrollDir,
changeSwapSel, changeSwapSel,
scrollAugInvSel, scrollAugInvSel,
@@ -21,6 +21,7 @@ module Dodge.Inventory (
setInvPosFromSS, setInvPosFromSS,
) where ) where
import Control.Monad
import Color import Color
import Control.Applicative import Control.Applicative
import qualified Data.Map.Strict as M import qualified Data.Map.Strict as M
@@ -155,16 +156,20 @@ selNumEndMidHeight cfig ldp sss i j = do
selSecSelCol :: Int -> Int -> SelectionSections a -> Maybe Color selSecSelCol :: Int -> Int -> SelectionSections a -> Maybe Color
selSecSelCol i j sss = sss ^? sssSections . ix i . ssItems . ix j . siColor selSecSelCol i j sss = sss ^? sssSections . ix i . ssItems . ix j . siColor
updateTerminal :: World -> World
updateTerminal = checkTermDist
checkTermDist :: World -> World checkTermDist :: World -> World
checkTermDist w = case w ^? hud . hudElement . subInventory . termID of --checkTermDist w = case w ^? hud . hudElement . subInventory . termID of
Just tmid -> fromMaybe (w & hud . hudElement . subInventory .~ NoSubInventory) $ do -- Just tmid -> fromMaybe (w & hud . hudElement . subInventory .~ NoSubInventory) $ do
-- btid <- w ^? cWorld . lWorld . terminals . ix tmid . tmButtonID
-- btpos <- w ^? cWorld . lWorld . buttons . ix btid . btPos
-- guard $ dist btpos (_crPos $ you w) < 40
-- return w
-- Nothing -> w
checkTermDist w = fromMaybe w $ do
tmid <- w ^? hud . hudElement . subInventory . termID
btid <- w ^? cWorld . lWorld . terminals . ix tmid . tmButtonID btid <- w ^? cWorld . lWorld . terminals . ix tmid . tmButtonID
btpos <- w ^? cWorld . lWorld . buttons . ix btid . btPos btpos <- w ^? cWorld . lWorld . buttons . ix btid . btPos
if dist btpos (_crPos $ you w) < 40 then Just w else Nothing guard $ dist btpos (_crPos $ you w) > 40
Nothing -> w return (w & hud . hudElement . subInventory .~ NoSubInventory)
-- this looks ugly... -- this looks ugly...
updateCloseObjects :: World -> World updateCloseObjects :: World -> World
+30 -33
View File
@@ -3,8 +3,8 @@ module Dodge.Render.HUD (
drawHUD, drawHUD,
) where ) where
import Dodge.SelectionSections.Draw
import Control.Lens import Control.Lens
import Data.Foldable
import qualified Data.Map.Strict as M import qualified Data.Map.Strict as M
import Data.Maybe import Data.Maybe
import qualified Data.Vector as V import qualified Data.Vector as V
@@ -22,8 +22,8 @@ import Dodge.Item.Info
import Dodge.ListDisplayParams import Dodge.ListDisplayParams
import Dodge.Render.Connectors import Dodge.Render.Connectors
import Dodge.Render.List import Dodge.Render.List
import Dodge.SelectionSections.Draw
import Dodge.Tweak.Show import Dodge.Tweak.Show
--import Dodge.WorldPos
import Geometry import Geometry
import qualified IntMapHelp as IM import qualified IntMapHelp as IM
import Justify import Justify
@@ -41,11 +41,10 @@ drawHUD cfig w = case w ^. hud . hudElement of
<> drawSubInventory subinv cfig w <> drawSubInventory subinv cfig w
drawHP :: Configuration -> World -> Picture drawHP :: Configuration -> World -> Picture
drawHP cfig w = dShadCol white $ displayHP 0 cfig w drawHP cfig = dShadCol white . displayHP 0 cfig
drawInventory :: SelectionSections () -> World -> Configuration -> Picture drawInventory :: SelectionSections () -> World -> Configuration -> Picture
drawInventory sss w = drawSelectionSections sss (invDisplayParams w) drawInventory sss = drawSelectionSections sss . invDisplayParams
drawSubInventory :: SubInventory -> Configuration -> World -> Picture drawSubInventory :: SubInventory -> Configuration -> World -> Picture
drawSubInventory subinv cfig w = case subinv of drawSubInventory subinv cfig w = case subinv of
@@ -55,7 +54,6 @@ drawSubInventory subinv cfig w = case subinv of
DisplayTerminal tid -> displayTerminal tid cfig (w ^. cWorld . lWorld) DisplayTerminal tid -> displayTerminal tid cfig (w ^. cWorld . lWorld)
CombineInventory{_ciSections = sss} -> drawCombineInventory cfig sss w CombineInventory{_ciSections = sss} -> drawCombineInventory cfig sss w
drawCombineInventory :: Configuration -> SelectionSections CombinableItem -> World -> Picture drawCombineInventory :: Configuration -> SelectionSections CombinableItem -> World -> Picture
drawCombineInventory cfig sss w = drawCombineInventory cfig sss w =
invHead cfig "COMBINE" invHead cfig "COMBINE"
@@ -66,10 +64,19 @@ drawExamineInventory :: Configuration -> Maybe Int -> World -> Picture
drawExamineInventory cfig mtweaki w = drawExamineInventory cfig mtweaki w =
invHead cfig "EXAMINE" invHead cfig "EXAMINE"
<> examineInventoryExtra mtweaki itm cfig <> examineInventoryExtra mtweaki itm cfig
<> drawSelectionList secondColumnParams <> drawSelectionList
secondColumnParams
cfig cfig
( defaultSelectionList & slItems .~ ammoTweakSelectionItems itm ( defaultSelectionList & slItems .~ ammoTweakSelectionItems itm
++ map f (makeParagraph 60 $ yourAugmentedItem itemInfo (yourInfo (you w)) (closeObjectInfo (crNumFreeSlots (you w))) w) ++ map
f
( makeParagraph 60 $
yourAugmentedItem
itemInfo
(yourInfo (you w))
(closeObjectInfo (crNumFreeSlots (you w)))
w
)
) )
where where
itm = yourItem w itm = yourItem w
@@ -78,8 +85,7 @@ drawExamineInventory cfig mtweaki w =
{ _siPictures = [str] { _siPictures = [str]
, _siHeight = 1 , _siHeight = 1
, _siIsSelectable = True , _siIsSelectable = True
, --, _siWidth = length str , _siColor = white
_siColor = white
, _siOffX = 0 , _siOffX = 0
, _siPayload = () , _siPayload = ()
} }
@@ -104,7 +110,7 @@ yourAugmentedItem f x g w = case you w ^? crManipulation . manObject of
drawNoSubInventory :: Configuration -> World -> Picture drawNoSubInventory :: Configuration -> World -> Picture
drawNoSubInventory cfig w = drawNoSubInventory cfig w =
pictures fold
[ equipcursors [ equipcursors
, equipcursor -- the order is important, this should go on top of the other equipcursors , equipcursor -- the order is important, this should go on top of the other equipcursors
, rboptions , rboptions
@@ -134,8 +140,6 @@ examineInventoryExtra mtweaki mitm cfig = fromMaybe mempty $ do
tparam <- mitm ^? _Just . itTweaks . tweakParams . ix tweaki tparam <- mitm ^? _Just . itTweaks . tweakParams . ix tweaki
return $ listCursorNSW subInvX 60 cfig tweaki 0 white (length $ showTweak tparam) 15 return $ listCursorNSW subInvX 60 cfig tweaki 0 white (length $ showTweak tparam) 15
-- , drawSelectionList thirdColumnParams cfig (thirdColumnPara (itmInfo mitm))
combineInventoryExtra :: SelectionSections CombinableItem -> Configuration -> World -> Picture combineInventoryExtra :: SelectionSections CombinableItem -> Configuration -> World -> Picture
combineInventoryExtra sss cfig w = fromMaybe mempty $ do combineInventoryExtra sss cfig w = fromMaybe mempty $ do
(i, j) <- sss ^? sssExtra . sssSelPos . _Just (i, j) <- sss ^? sssExtra . sssSelPos . _Just
@@ -199,18 +203,11 @@ displayTerminal :: Int -> Configuration -> LWorld -> Picture
displayTerminal tid cfig w = fromMaybe mempty $ do displayTerminal tid cfig w = fromMaybe mempty $ do
tm <- w ^? terminals . ix tid tm <- w ^? terminals . ix tid
return $ return $
pictures invHead cfig (_tmTitle tm ++ ":T" ++ show tid)
[ invHead cfig (_tmTitle tm ++ ":T" ++ show tid) <> drawSelectionList secondColumnParams cfig (thesellist tm)
, drawSelectionList secondColumnParams cfig (thesellist tm)
]
where where
--toselitm (str, col) = SelectionItem [str] 1 True (length str) col 0 ()
toselitm (str, col) = SelectionItem [str] 1 True col 0 () toselitm (str, col) = SelectionItem [str] 1 True col 0 ()
thesellist tm = thesellist tm = defaultSelectionList & slItems .~ thelist tm
defaultSelectionList
{ _slItems = thelist tm
-- , _slLength = length (thelist tm)
}
thelist tm = thelist tm =
map toselitm . displayTermInput tm map toselitm . displayTermInput tm
. reverse . reverse
@@ -218,11 +215,12 @@ displayTerminal tid cfig w = fromMaybe mempty $ do
$ _tmDisplayedLines tm $ _tmDisplayedLines tm
displayTermInput tm = case _tmInput tm of displayTermInput tm = case _tmInput tm of
TerminalInput s hasfoc _ -> (++ [(displayInputText tm s ++ displayBlinkCursor hasfoc, white)]) TerminalInput s hasfoc _ -> (++ [(displayInputText tm s ++ displayBlinkCursor hasfoc, white)])
partcommand tm = maybe "" (++ " ") $ tm ^? tmPartialCommand . _Just
displayInputText tm s displayInputText tm s
| _tmStatus tm == TerminalReady = '>' : s | _tmStatus tm == TerminalReady = partcommand tm ++ "> " ++ s
| otherwise = "" | otherwise = ""
displayBlinkCursor hasfoc displayBlinkCursor hasfoc
| hasfoc = clockCycle 10 (V.fromList ["_", ""]) w | hasfoc = clockCycle 10 (V.fromList ["_", "."]) w
| otherwise = [] | otherwise = []
drawRBOptions :: Configuration -> World -> RightButtonOptions -> Picture drawRBOptions :: Configuration -> World -> RightButtonOptions -> Picture
@@ -276,8 +274,7 @@ combineCounts cfig w = foldMap f . group
f _ = mempty f _ = mempty
lnkMidPosInvSelsCol :: Configuration -> World -> Int -> Color -> [Int] -> Picture lnkMidPosInvSelsCol :: Configuration -> World -> Int -> Color -> [Int] -> Picture
lnkMidPosInvSelsCol cfig w i col = lnkMidPosInvSelsCol cfig w i col = foldMap f
foldMap f
where where
f j = fromMaybe mempty $ do f j = fromMaybe mempty $ do
sss <- w ^? hud . hudElement . diSections sss <- w ^? hud . hudElement . diSections
@@ -317,8 +314,9 @@ drawCarte cfig w =
where where
iPos = w ^. cWorld . lWorld . selLocation iPos = w ^. cWorld . lWorld . selLocation
locs = map (\(_, s) -> (s, white)) . IM.elems . _seenLocations . _lWorld $ _cWorld w locs = map (\(_, s) -> (s, white)) . IM.elems . _seenLocations . _lWorld $ _cWorld w
--locPoss = map (cartePosToScreen cfig (w ^. hud) . ($ w) . doWorldPos . fst) . IM.elems . _seenLocations . _lWorld $ _cWorld w
--locTexts = map fst locs --locPoss = map (cartePosToScreen cfig (w ^. hud) . ($ w) . doWorldPos . fst) . IM.elems . _seenLocations . _lWorld $ _cWorld w
--locTexts = map fst locs
--displayListEndCoords :: Configuration -> [String] -> [Point2] --displayListEndCoords :: Configuration -> [String] -> [Point2]
--displayListEndCoords cfig ss = map (doWindowScale cfig) $ zipWith h ss $ map f [1 ..] --displayListEndCoords cfig ss = map (doWindowScale cfig) $ zipWith h ss $ map f [1 ..]
@@ -399,8 +397,7 @@ picsToSelectable pics =
{ _siPictures = pics { _siPictures = pics
, _siHeight = length pics , _siHeight = length pics
, _siIsSelectable = True , _siIsSelectable = True
, --, _siWidth = wdth , _siColor = white
_siColor = white
, _siOffX = 0 , _siOffX = 0
, _siPayload = () , _siPayload = ()
} }
@@ -418,8 +415,8 @@ openCursorAt ::
Configuration -> Configuration ->
Picture Picture
openCursorAt wth col xoff yoff yint w = openCursorAt wth col xoff yoff yint w =
translate (xoff - halfWidth w) (halfHeight w - (20 * fromIntegral yint + yoff) - 20) translate (xoff - halfWidth w) (halfHeight w - (20 * fromIntegral yint + yoff) - 20) $
$ lineCol lineCol
[ (V2 wth 12.5, withAlpha 0 col) [ (V2 wth 12.5, withAlpha 0 col)
, (V2 0 12.5, col) , (V2 0 12.5, col)
, (V2 0 (-7.5), col) , (V2 0 (-7.5), col)
+47 -59
View File
@@ -1,6 +1,5 @@
module Dodge.Terminal ( module Dodge.Terminal (
doTerminalCommandEffect, doTerminalCommandEffect,
guardDisconnected,
makeTermLine, makeTermLine,
commandFutureLines, commandFutureLines,
quitCommand, quitCommand,
@@ -22,7 +21,6 @@ import Data.Char
import Data.Foldable import Data.Foldable
import qualified Data.Map.Strict as M import qualified Data.Map.Strict as M
import Data.Maybe import Data.Maybe
--import qualified Data.Text as T
import Dodge.Data.World import Dodge.Data.World
import Dodge.Default import Dodge.Default
import Dodge.SoundLogic import Dodge.SoundLogic
@@ -38,7 +36,6 @@ basicTerminal =
, _tmFutureLines = [] , _tmFutureLines = []
, _tmMaxLines = 14 , _tmMaxLines = 14
, _tmTitle = "TERMINAL" , _tmTitle = "TERMINAL"
, _tmInput = defaultTerminalInput
, _tmScrollCommands = [quitCommand] , _tmScrollCommands = [quitCommand]
, _tmWriteCommands = [helpCommand, commandsCommand] , _tmWriteCommands = [helpCommand, commandsCommand]
, _tmBootProgram = TerminalBootLines connectionBlurb , _tmBootProgram = TerminalBootLines connectionBlurb
@@ -48,9 +45,9 @@ basicTerminal =
connectionBlurbLines :: [TerminalLine] -> [TerminalLine] connectionBlurbLines :: [TerminalLine] -> [TerminalLine]
connectionBlurbLines tls = connectionBlurbLines tls =
[ termSoundLine computerBeepingS [ termSoundLine computerBeepingS
, TerminalLineDisplay 0 (TerminalLineConst "CONNECTING" termTextColor) , TerminalLineDisplay 0 (TerminalLineConst "Connecting" termTextColor)
, TerminalLineDisplay 10 (TerminalLineConst "..." termTextColor) , TerminalLineDisplay 10 (TerminalLineConst "..." termTextColor)
, TerminalLineDisplay 10 (TerminalLineConst "CONNECTED" termTextColor) , TerminalLineDisplay 10 (TerminalLineConst "Connected" termTextColor)
] ]
++ tls ++ tls
++ [TerminalLineTerminalEffect 0 (TmTmSetStatus TerminalReady)] ++ [TerminalLineTerminalEffect 0 (TmTmSetStatus TerminalReady)]
@@ -58,18 +55,18 @@ connectionBlurbLines tls =
quitCommand :: TerminalCommand quitCommand :: TerminalCommand
quitCommand = quitCommand =
TerminalCommand TerminalCommand
{ _tcString = "QUIT" { _tcString = "quit"
, _tcAlias = ["Q", "EXIT", "X", "SHUTDOWN", ""] , _tcAlias = ["q", "exit", "x", "shutdown", ""]
, _tcHelp = "DISCONNECTS THE TERMINAL." , _tcHelp = "Disconnects the terminal."
, _tcEffect = TerminalCommandArguments $ NoArguments [TerminalLineEffect 0 TmWdWdDisconnectTerminal] , _tcEffect = TerminalCommandArguments $ NoArguments [TerminalLineEffect 0 TmWdWdDisconnectTerminal]
} }
helpCommand :: TerminalCommand helpCommand :: TerminalCommand
helpCommand = helpCommand =
TerminalCommand TerminalCommand
{ _tcString = "HELP" { _tcString = "help"
, _tcAlias = ["H", "MAN"] , _tcAlias = ["h", "man"]
, _tcHelp = "DISPLAYS HELP FOR A SPECIFIC COMMAND." , _tcHelp = "Displays help for a specific command."
, _tcEffect = TerminalCommandEffectHelp -- \tm -> OneArgument "AN AVAILABLE COMMAND" . getCommandsHelp tm , _tcEffect = TerminalCommandEffectHelp -- \tm -> OneArgument "AN AVAILABLE COMMAND" . getCommandsHelp tm
} }
@@ -79,9 +76,9 @@ getCommandsHelp tm w = foldr f mempty $ getCommands tm
f tc = f tc =
M.insert M.insert
(_tcString tc) (_tcString tc)
( [ makeTermLine "COMMAND:" ( [ makeTermLine "Command:"
, makeColorTermLine commandColor (_tcString tc) , makeColorTermLine commandColor (_tcString tc)
, makeTermLine "ALIASES:" , makeTermLine "Aliases:"
, makeColorTermLine commandColor (unwords (_tcAlias tc)) , makeColorTermLine commandColor (unwords (_tcAlias tc))
] ]
++ case argumentHelp tc tm w of ++ case argumentHelp tc tm w of
@@ -94,29 +91,24 @@ getCommandsHelp tm w = foldr f mempty $ getCommands tm
commandsCommand :: TerminalCommand commandsCommand :: TerminalCommand
commandsCommand = commandsCommand =
TerminalCommand TerminalCommand
{ _tcString = "COMMANDS" { _tcString = "commands"
, _tcAlias = ["COMMAND", "COM"] , _tcAlias = ["command", "com"]
, _tcHelp = "DISPLAYS AVAILABLE COMMANDS." , _tcHelp = "Displays available commands."
, _tcEffect = TerminalCommandEffectCommands , _tcEffect = TerminalCommandEffectCommands
} }
connectionBlurb :: [TerminalLine] connectionBlurb :: [TerminalLine]
connectionBlurb = connectionBlurb =
[ termSoundLine computerBeepingS [ termSoundLine computerBeepingS
, TerminalLineDisplay 0 (TerminalLineConst "CONNECTING" termTextColor) , TerminalLineDisplay 0 (TerminalLineConst "Connecting" termTextColor)
, TerminalLineDisplay 10 (TerminalLineConst "..." termTextColor) , TerminalLineDisplay 10 (TerminalLineConst "..." termTextColor)
, TerminalLineDisplay 10 (TerminalLineConst "CONNECTED" termTextColor) , TerminalLineDisplay 10 (TerminalLineConst "Connected" termTextColor)
, TerminalLineTerminalEffect 0 (TmTmSetStatus TerminalReady) , TerminalLineTerminalEffect 0 (TmTmSetStatus TerminalReady)
] ]
termSoundLine :: SoundID -> TerminalLine termSoundLine :: SoundID -> TerminalLine
termSoundLine sid = TerminalLineEffect 0 (TmWdWdTermSound sid) termSoundLine sid = TerminalLineEffect 0 (TmWdWdTermSound sid)
-- where
-- termsound tm w = soundStart TerminalSound tpos sid Nothing w
-- where
-- tpos = fromMaybe 0 $ w ^? buttons . ix (_tmButtonID tm) . btPos
termTextColor :: Color termTextColor :: Color
termTextColor = greyN 0.9 termTextColor = greyN 0.9
@@ -141,14 +133,14 @@ commandColor = yellow
doTerminalCommandEffect :: TerminalCommandEffect -> Terminal -> World -> EffectArguments doTerminalCommandEffect :: TerminalCommandEffect -> Terminal -> World -> EffectArguments
doTerminalCommandEffect tce = case tce of doTerminalCommandEffect tce = case tce of
TerminalCommandArguments eas -> \_ _ -> eas TerminalCommandArguments eas -> \_ _ -> eas
TerminalCommandEffectDamageCoding -> \_ -> OneArgument "A DAMAGE TYPE" . getDamageCoding TerminalCommandEffectDamageCoding -> \_ -> OneArgument "a damage type" . getDamageCoding
TerminalCommandEffectSensorParameter -> \tm -> OneArgument "A SENSOR PARAMETER" . sensorInfoMap tm TerminalCommandEffectSensorParameter -> \tm -> OneArgument "a sensor parameter" . sensorInfoMap tm
TerminalCommandEffectLinkedObject -> \tm _ -> OneArgument "A LINKED OBJECT" (togglesToEffects tm) TerminalCommandEffectLinkedObject -> \tm _ -> OneArgument "a linked object" (togglesToEffects tm)
TerminalCommandEffectHelp -> \tm -> OneArgument "AN AVAILABLE COMMAND" . getCommandsHelp tm TerminalCommandEffectHelp -> \tm -> OneArgument "an available command" . getCommandsHelp tm
TerminalCommandEffectNoArgumentsStr str -> \_ _ -> NoArguments (makeTermPara str) TerminalCommandEffectNoArgumentsStr str -> \_ _ -> NoArguments (makeTermPara str)
TerminalCommandEffectCommands -> \tm _ -> TerminalCommandEffectCommands -> \tm _ ->
NoArguments NoArguments
( makeTermLine "AVAILABLE COMMANDS:" : ( makeTermLine "Available commands:" :
makeColorTermPara commandColor (unwords (map _tcString $ getCommands tm)) makeColorTermPara commandColor (unwords (map _tcString $ getCommands tm))
) )
TerminalCommandEffectSingleCommand eff followingLines -> \_ _ -> NoArguments $ TerminalLineEffect 0 (TmWdWdfromWdWd eff) : map makeTermLine followingLines TerminalCommandEffectSingleCommand eff followingLines -> \_ _ -> NoArguments $ TerminalLineEffect 0 (TmWdWdfromWdWd eff) : map makeTermLine followingLines
@@ -156,9 +148,9 @@ doTerminalCommandEffect tce = case tce of
argumentHelp :: TerminalCommand -> Terminal -> World -> (String, Maybe [String]) argumentHelp :: TerminalCommand -> Terminal -> World -> (String, Maybe [String])
argumentHelp tc tm w = case doTerminalCommandEffect (_tcEffect tc) tm w of argumentHelp tc tm w = case doTerminalCommandEffect (_tcEffect tc) tm w of
NoArguments{} -> ("ANY ARGUMENTS PROVIDED TO THIS COMMAND ARE IGNORED.", Nothing) NoArguments{} -> ("Any arguments provided to this command are ignored.", Nothing)
OneArgument argtype argm -> OneArgument argtype argm ->
( "EXPECTS " ++ argtype ++ " AS ARGUMENT. AVAILABLE ARGUMENTS: " ( "Expects " ++ argtype ++ " as argument. Available arguments: "
, Just (M.keys argm) , Just (M.keys argm)
) )
@@ -180,37 +172,31 @@ argumentHelp tc tm w = case doTerminalCommandEffect (_tcEffect tc) tm w of
-- , _tcEffect = TerminalCommandEffectSingleCommand eff followingLines -- , _tcEffect = TerminalCommandEffectSingleCommand eff followingLines
-- } -- }
guardDisconnected :: Terminal -> World -> World -> World
guardDisconnected tm w w' = case _tmStatus tm of
TerminalOff -> w
TerminalBusy -> w
TerminalReady -> w'
getDamageCoding :: World -> M.Map String [TerminalLine] getDamageCoding :: World -> M.Map String [TerminalLine]
getDamageCoding = decodedtmap . _sensorCoding . _cwgParams . _cwGen . _cWorld getDamageCoding = decodedtmap . _sensorCoding . _cwgParams . _cwGen . _cWorld
sensorInfoMap :: Terminal -> World -> M.Map String [TerminalLine] sensorInfoMap :: Terminal -> World -> M.Map String [TerminalLine]
sensorInfoMap tm w = sensorInfoMap tm w =
M.fromList M.fromList
[ ("REQUIREMENT", getSensor _proxRequirement tm w) [ ("Requirement", getSensor _proxRequirement tm w)
, ("DISTANCE", getSensor _proxDist tm w) , ("Distance", getSensor _proxDist tm w)
, ("CURRENTSTATUS", getSensor _proxStatus tm w) , ("Currentstatus", getSensor _proxStatus tm w)
, ("PASTSTATUS", getSensor _sensToggle tm w) , ("Paststatus", getSensor _sensToggle tm w)
] ]
getSensor :: Show a => (Sensor -> a) -> Terminal -> World -> [TerminalLine] getSensor :: Show a => (Sensor -> a) -> Terminal -> World -> [TerminalLine]
getSensor f tm w = getSensor f tm w =
maybe maybe
[] []
(makeTermPara . map toUpper . show . f) (makeTermPara . map toLower . show . f)
(w ^? cWorld . lWorld . machines . ix (_tmMachineID tm) . mcType . _McSensor) (w ^? cWorld . lWorld . machines . ix (_tmMachineID tm) . mcType . _McSensor)
toggleCommand :: TerminalCommand toggleCommand :: TerminalCommand
toggleCommand = toggleCommand =
TerminalCommand TerminalCommand
{ _tcString = "TOGGLE" { _tcString = "toggle"
, _tcAlias = ["TOG"] , _tcAlias = ["tog"]
, _tcHelp = "PERFORMS A REVERSABLE EFFECT." , _tcHelp = "Performs a reversable effect."
, _tcEffect = TerminalCommandEffectLinkedObject -- \tm _ -> OneArgument "A LINKED OBJECT" (togglesToEffects tm) , _tcEffect = TerminalCommandEffectLinkedObject -- \tm _ -> OneArgument "A LINKED OBJECT" (togglesToEffects tm)
} }
@@ -220,19 +206,19 @@ decodedtmap = M.mapKeys show . M.map ((: []) . makeTermLine . show)
sensorCommand :: TerminalCommand sensorCommand :: TerminalCommand
sensorCommand = sensorCommand =
TerminalCommand TerminalCommand
{ _tcString = "SENSOR" { _tcString = "sensor"
, _tcAlias = ["SEN"] , _tcAlias = ["sen"]
, _tcHelp = "ACCESS INFORMATION CONCERNING THE CONNECTED SENSOR." , _tcHelp = "Access information concerning the connected sensor."
, _tcEffect = TerminalCommandEffectSensorParameter -- \tm -> OneArgument "A SENSOR PARAMETER" . sensorInfoMap tm , _tcEffect = TerminalCommandEffectSensorParameter -- \tm -> OneArgument "A SENSOR PARAMETER" . sensorInfoMap tm
} }
disconnectTerminal :: Terminal -> World -> World disconnectTerminal :: Terminal -> World -> World
disconnectTerminal tm w = disconnectTerminal tm =
w (cWorld . lWorld . terminals . ix (_tmID tm) . tmStatus .~ TerminalOff)
& cWorld . lWorld . terminals . ix (_tmID tm) . tmStatus .~ TerminalOff . exitTerminalSubInv
& exitTerminalSubInv . ( cWorld . lWorld . terminals . ix (_tmID tm) . tmFutureLines
& cWorld . lWorld . terminals . ix (_tmID tm) . tmFutureLines
.~ [TerminalLineTerminalEffect 0 TmTmClearDisplayedLines] .~ [TerminalLineTerminalEffect 0 TmTmClearDisplayedLines]
)
exitTerminalSubInv :: World -> World exitTerminalSubInv :: World -> World
exitTerminalSubInv w = case w ^? hud . hudElement . subInventory . termID of exitTerminalSubInv w = case w ^? hud . hudElement . subInventory . termID of
@@ -242,9 +228,9 @@ exitTerminalSubInv w = case w ^? hud . hudElement . subInventory . termID of
damageCodeCommand :: TerminalCommand damageCodeCommand :: TerminalCommand
damageCodeCommand = damageCodeCommand =
TerminalCommand TerminalCommand
{ _tcString = "DAMAGECODE" { _tcString = "damagecode"
, _tcAlias = ["DCODE", "DC"] , _tcAlias = ["dcode", "dc"]
, _tcHelp = "DISPLAYS THE SHAPE AND COLOR ASSOCIATED WITH A GIVEN DAMAGE TYPE." , _tcHelp = "Displays the shape and color associated with a given damage type."
, _tcEffect = TerminalCommandEffectDamageCoding -- \_ -> OneArgument "A DAMAGE TYPE" . getDamageCoding , _tcEffect = TerminalCommandEffectDamageCoding -- \_ -> OneArgument "A DAMAGE TYPE" . getDamageCoding
} }
@@ -260,19 +246,21 @@ togglesToEffects = fmap f . _tmToggles
where where
f tt = [TerminalLineEffect 0 $ TmWdWdfromWdWd $ WdWdNegateTrig (_ttTriggerID tt)] f tt = [TerminalLineEffect 0 $ TmWdWdfromWdWd $ WdWdNegateTrig (_ttTriggerID tt)]
-- \_ -> triggers . ix (_ttTriggerID tt) %~ not]
simpleTermMessage :: [String] -> Terminal simpleTermMessage :: [String] -> Terminal
simpleTermMessage strs = defaultTerminal & tmFutureLines .~ map makeTermLine strs simpleTermMessage strs = defaultTerminal & tmFutureLines .~ map makeTermLine strs
commandFutureLines :: String -> Terminal -> World -> [TerminalLine] commandFutureLines :: String -> Terminal -> World -> [TerminalLine]
commandFutureLines s tm w = fromMaybe [errline "^ INVALID COMMAND"] $ do commandFutureLines s tm w = fromMaybe [errline "^ Invalid command"] $ do
(str, args) <- safeUncons $ words s (str, args) <- safeUncons $ words s
command <- find (\tc -> _tcString tc == str || str `elem` _tcAlias tc) (getCommands tm) command <- find (\tc -> _tcString tc == str || str `elem` _tcAlias tc) (getCommands tm)
case doTerminalCommandEffect (_tcEffect command) tm w of case doTerminalCommandEffect (_tcEffect command) tm w of
NoArguments tls -> Just tls NoArguments tls -> Just tls
OneArgument argtype m -> OneArgument argtype m ->
Just $ let setpartial =
fromMaybe [errline $ "^ INVALID ARGUMENT: EXPECTS " ++ argtype] $ TerminalLineTerminalEffect 0 (TmTmSetPartialCommand (Just str)) :
makeTermPara ("expects " ++ argtype ++ " as an argument")
in Just $
fromMaybe setpartial $
safeHead args >>= (m M.!?) safeHead args >>= (m M.!?)
where where
errline = makeColorTermLine red errline = makeColorTermLine red
+8 -21
View File
@@ -1,36 +1,23 @@
module Dodge.Terminal.LeftButton where module Dodge.Terminal.LeftButton (
doTerminalEffectLB,
terminalReturnEffect,
) where
import Control.Monad
import Data.Maybe import Data.Maybe
import Dodge.Data.World import Dodge.Data.World
import Dodge.Terminal--oops import Dodge.Terminal.ReturnEffect
import LensHelp import LensHelp
doTerminalEffectLB :: Terminal -> World -> World doTerminalEffectLB :: Terminal -> World -> World
doTerminalEffectLB tm w = guardDisconnected tm w $ doTerminalEffectLB tm w = fromMaybe w $ do
fromMaybe w $ do 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) if null (words s)
then Just $ defocusTerminalInput w then Just $ defocusTerminalInput w
else return $ terminalReturnEffect tm w else return $ terminalReturnEffect tm w
terminalReturnEffect :: Terminal -> World -> World
terminalReturnEffect tm w = guardDisconnected tm w $
fromMaybe w $ do
s <- w ^? cWorld . lWorld . terminals . ix (_tmID tm) . tmInput . tiText
return $
runTerminalString s tm $
w
& cWorld . lWorld . terminals . ix (_tmID tm) . tmFutureLines .~ [makeTermLine ('>' : s)]
defocusTerminalInput :: World -> World defocusTerminalInput :: World -> World
defocusTerminalInput w = fromMaybe w $ do defocusTerminalInput w = fromMaybe w $ do
tmid <- w ^? hud . hudElement . subInventory . termID tmid <- w ^? hud . hudElement . subInventory . termID
return $ w & cWorld . lWorld . terminals . ix tmid . tmInput . tiFocus %~ const False return $ w & cWorld . lWorld . terminals . ix tmid . tmInput . tiFocus %~ const False
runTerminalString :: String -> Terminal -> World -> World
runTerminalString s tm w =
w & cWorld . lWorld . terminals . ix (_tmID tm)
%~ ( (tmInput .~ TerminalInput mempty True (0, 0))
. (tmFutureLines ++.~ commandFutureLines s tm w)
. (tmCommandHistory %~ take 10 . (s :))
)
+28
View File
@@ -0,0 +1,28 @@
module Dodge.Terminal.ReturnEffect
where
import Control.Monad
import Data.Maybe
import Dodge.Data.World
import LensHelp
import Dodge.Terminal -- this should be rethought
terminalReturnEffect :: Terminal -> World -> World
terminalReturnEffect tm w = fromMaybe w $ do
guard $ _tmStatus tm == TerminalReady
s <- w ^? cWorld . lWorld . terminals . ix (_tmID tm) . tmInput . tiText
let pc = maybe "" (++ " ") $ tm ^? tmPartialCommand . _Just
return $
runTerminalString (pc ++ s) tm $
w
& cWorld . lWorld . terminals . ix (_tmID tm) . tmPartialCommand .~ Nothing
& cWorld . lWorld . terminals . ix (_tmID tm) . tmFutureLines .~
[makeTermLine (pc ++ "> " ++ s)]
runTerminalString :: String -> Terminal -> World -> World
runTerminalString s tm w =
w & cWorld . lWorld . terminals . ix (_tmID tm)
%~ ( (tmInput .~ TerminalInput mempty True (0, 0))
. (tmFutureLines ++.~ commandFutureLines s tm w)
. (tmCommandHistory %~ take 10 . (s :))
)
+1
View File
@@ -8,3 +8,4 @@ doTmTm tmtm = case tmtm of
TmTmClearDisplayedLines -> tmDisplayedLines .~ [] TmTmClearDisplayedLines -> tmDisplayedLines .~ []
TmTmSetStatus s -> tmStatus .~ s TmTmSetStatus s -> tmStatus .~ s
TmId -> id TmId -> id
TmTmSetPartialCommand ms -> tmPartialCommand .~ ms
+1 -2
View File
@@ -227,7 +227,6 @@ scrollTimeForward w = case w ^? timeFlow . futureWorlds . _head of
i <- w ^? timeFlow . scrollItemLocation i <- w ^? timeFlow . scrollItemLocation
return $ pointerToItemLocation (w ^?! cWorld . lWorld . itemLocations . ix i) . itUse . leftConsumption . wpCharge .~ ramount return $ pointerToItemLocation (w ^?! cWorld . lWorld . itemLocations . ix i) . itUse . leftConsumption . wpCharge .~ ramount
-- | The update step. -- | The update step.
functionalUpdate :: Universe -> Universe functionalUpdate :: Universe -> Universe
functionalUpdate w = functionalUpdate w =
@@ -271,7 +270,7 @@ functionalUpdate w =
. over uvWorld updateCreatureGroups . over uvWorld updateCreatureGroups
. over uvWorld updateWallDamages . over uvWorld updateWallDamages
. over uvWorld updateSeenWalls . over uvWorld updateSeenWalls
. over uvWorld updateTerminal . over uvWorld checkTermDist
. over uvWorld updateRBList . over uvWorld updateRBList
. over uvWorld updateCloseObjects . over uvWorld updateCloseObjects
. over uvWorld updateWheelEvents . over uvWorld updateWheelEvents
+33 -41
View File
@@ -5,13 +5,7 @@ module Dodge.Update.Camera (
updateCamera, updateCamera,
) where ) where
import Dodge.WASD
import Dodge.SmoothScroll
import SDL (MouseButton (..))
import Dodge.Base.Coordinate
import Dodge.InputFocus
import Bound import Bound
import Dodge.Viewpoints
import Control.Monad import Control.Monad
import Data.Foldable import Data.Foldable
import qualified Data.Map.Strict as M import qualified Data.Map.Strict as M
@@ -21,10 +15,15 @@ import Dodge.Creature.Test
import Dodge.Data.Config import Dodge.Data.Config
import Dodge.Data.World import Dodge.Data.World
import Dodge.Equipment import Dodge.Equipment
import Dodge.InputFocus
import Dodge.SmoothScroll
import Dodge.Viewpoints
import Dodge.WASD
import Dodge.Zoning.Wall import Dodge.Zoning.Wall
import Geometry import Geometry
import qualified IntMapHelp as IM import qualified IntMapHelp as IM
import LensHelp import LensHelp
import SDL (MouseButton (..))
import qualified SDL import qualified SDL
{- Update the screen camera rotation and position, including any in rold scope/remote camera modifiers; {- Update the screen camera rotation and position, including any in rold scope/remote camera modifiers;
@@ -35,7 +34,8 @@ updateCamera cfig w = case w ^. wCam . camControl of
CamFloat -> updateFloatingCamera cfig w CamFloat -> updateFloatingCamera cfig w
updateFloatingCamera :: Configuration -> World -> World updateFloatingCamera :: Configuration -> World -> World
updateFloatingCamera cfig w = w updateFloatingCamera cfig w =
w
& updateBounds cfig & updateBounds cfig
& wCam %~ setViewDistance cfig & wCam %~ setViewDistance cfig
& wCam %~ translateFloatingCamera theinput & wCam %~ translateFloatingCamera theinput
@@ -51,22 +51,23 @@ translateFloatingCamera theinput cam = fromMaybe cam $ do
hpos <- theinput ^? heldPos . ix ButtonLeft hpos <- theinput ^? heldPos . ix ButtonLeft
let thetran = let thetran =
screenToWorldPos cam hpos screenToWorldPos cam hpos
-.- -.- screenToWorldPos cam (theinput ^. mousePos)
screenToWorldPos cam (theinput ^. mousePos) return $
return $ cam & camCenter +~ thetran cam & camCenter +~ thetran
& camViewFrom +~ thetran & camViewFrom +~ thetran
translateFloatingCameraKeys :: Input -> Camera -> Camera translateFloatingCameraKeys :: Input -> Camera -> Camera
translateFloatingCameraKeys theinput = (camCenter -~ thetran) translateFloatingCameraKeys theinput =
(camCenter -~ thetran)
. (camViewFrom -~ thetran) . (camViewFrom -~ thetran)
where where
thetran = 10 *.* wasdDir theinput thetran = 10 *.* wasdDir theinput
zoomFloatingCamera :: Input -> Camera -> Camera zoomFloatingCamera :: Input -> Camera -> Camera
zoomFloatingCamera theinput cam zoomFloatingCamera theinput
| ButtonRight `M.member` (theinput ^. mouseButtons) = cam | ButtonRight `M.member` (theinput ^. mouseButtons) =
& camZoom *~ (zoomSpeed ^^ negate (getSmoothScrollValue theinput)) camZoom *~ (zoomSpeed ^^ negate (getSmoothScrollValue theinput))
| otherwise = cam | otherwise = id
updateInGameCamera :: Configuration -> World -> World updateInGameCamera :: Configuration -> World -> World
updateInGameCamera cfig w = updateInGameCamera cfig w =
@@ -100,8 +101,9 @@ moveZoomCamera cfig theinput cr campos =
guard (SDL.ButtonRight `M.member` _mouseButtons theinput) guard (SDL.ButtonRight `M.member` _mouseButtons theinput)
mitm ^? _Just . itScope . scopePos mitm ^? _Just . itScope . scopePos
newcen = cpos +.+ fromMaybe (V2 0 0) mscopeoffset +.+ offset newcen = cpos +.+ fromMaybe (V2 0 0) mscopeoffset +.+ offset
offset = rotateV (campos ^. camRot) offset =
$ ((newzoom - newDefaultZoom) / (newDefaultZoom * newzoom)) *.* _mousePos theinput rotateV (campos ^. camRot) $
((newzoom - newDefaultZoom) / (newDefaultZoom * newzoom)) *.* _mousePos theinput
newzoom = case mitm ^? _Just . itScope of newzoom = case mitm ^? _Just . itScope of
Just zs@ZoomScope{} -> _scopeZoom zs Just zs@ZoomScope{} -> _scopeZoom zs
_ -> newDefaultZoom * newItemZoom _ -> newDefaultZoom * newItemZoom
@@ -123,7 +125,6 @@ moveZoomCamera cfig theinput cr campos =
distFromEqmnt = foldl' max 1 $ IM.mapMaybe (_eeViewDist . _equipEffect . _itUse) $ getCrEquipment cr distFromEqmnt = foldl' max 1 $ IM.mapMaybe (_eeViewDist . _equipEffect . _itUse) $ getCrEquipment cr
hw = halfWidth cfig hw = halfWidth cfig
hh = halfHeight cfig hh = halfHeight cfig
-- = maybe clipZoom zoomFromItem (yourItem w ^? itZoom) wallZoom
-- these speeds are inverted, larger means slower -- these speeds are inverted, larger means slower
zoomInSpeed = 25 zoomInSpeed = 25
zoomOutSpeed = 15 zoomOutSpeed = 15
@@ -135,8 +136,8 @@ updateScopeZoom w = fromMaybe w $ do
updateScopeZoom' :: Int -> World -> World updateScopeZoom' :: Int -> World -> World
updateScopeZoom' i w updateScopeZoom' i w
| SDL.ButtonRight `M.member` _mouseButtons (_input w) | SDL.ButtonRight `M.member` _mouseButtons (_input w) =
= w & wppointer %~ doScopeZoom (w ^. input . smoothScrollAmount) mp w & wppointer %~ doScopeZoom (w ^. input . smoothScrollAmount) mp
| otherwise = w & wppointer %~ resetscope | otherwise = w & wppointer %~ resetscope
where where
wppointer = cWorld . lWorld . creatures . ix 0 . crInv . ix i . itScope wppointer = cWorld . lWorld . creatures . ix 0 . crInv . ix i . itScope
@@ -159,28 +160,20 @@ zoomSpeed :: Float
zoomSpeed = 39 / 40 zoomSpeed = 39 / 40
zoomInLongGun :: Point2 -> Scope -> Scope zoomInLongGun :: Point2 -> Scope -> Scope
zoomInLongGun mousep sc zoomInLongGun mousep sc = fromMaybe sc $ do
| currentZoom < 8 = curzoom <- sc ^? scopeZoom
sc guard $ curzoom < 8
& scopePos .+.+~ (1 - zoomSpeed) / newzoom *.* mousep return $
sc & scopePos .+.+~ (1 - zoomSpeed) * zoomSpeed / curzoom *.* mousep
& scopeZoom %~ (/ zoomSpeed) & scopeZoom %~ (/ zoomSpeed)
| otherwise = sc
where
Just currentZoom = sc ^? scopeZoom
newzoom = (sc ^?! scopeZoom) / zoomSpeed
zoomOutLongGun :: Scope -> Scope zoomOutLongGun :: Scope -> Scope
zoomOutLongGun sc zoomOutLongGun sc = fromMaybe sc $ do
| currentzoom > 0.5 = curzoom <- sc ^? scopeZoom
sc guard $ curzoom > 0.5
& scopePos %~ (\p -> p +.+ (zoomSpeed-1) / currentzoom *.* p) return $
-- & scopePos .*.*~ 1 - ((newzoom * 2) ** zoomSpeed) sc & scopePos %~ (\p -> p +.+ (zoomSpeed - 1) / curzoom *.* p)
& scopeZoom *~ zoomSpeed & scopeZoom *~ zoomSpeed
| otherwise = sc
& scopePos .~ V2 0 0
where
Just currentzoom = sc ^? scopeZoom
--newzoom = (sc ^?! scopeZoom) / zoomSpeed
ifConfigWallRotate :: Configuration -> World -> World ifConfigWallRotate :: Configuration -> World -> World
ifConfigWallRotate cfig w ifConfigWallRotate cfig w
@@ -207,7 +200,6 @@ doWallRotate wl w = rotateUsing $ (argV . uncurry (-.-) $ _wlLine wl) - (w ^. wC
| b - b' < negate 0.01 = w & wCam . camRot -~ 0.01 | b - b' < negate 0.01 = w & wCam . camRot -~ 0.01
| otherwise = w | otherwise = w
where where
--b = a * (2 / pi)
b = a * (4 / pi) b = a * (4 / pi)
b' = fromIntegral (round b :: Int) b' = fromIntegral (round b :: Int)
@@ -219,7 +211,8 @@ rotateCameraBy x w =
where where
rotateanyscope = fromMaybe id $ do rotateanyscope = fromMaybe id $ do
i <- w ^? cWorld . lWorld . creatures . ix 0 . crManipulation . manObject . inInventory . ispItem i <- w ^? cWorld . lWorld . creatures . ix 0 . crManipulation . manObject . inInventory . ispItem
return $ lWorld . creatures . ix 0 . crInv . ix i return $
lWorld . creatures . ix 0 . crInv . ix i
. itScope . itScope
. scopePos . scopePos
%~ rotateV x %~ rotateV x
@@ -262,7 +255,6 @@ farWallDistDirection p w =
findBoundDists :: Configuration -> World -> (Float, Float, Float, Float) findBoundDists :: Configuration -> World -> (Float, Float, Float, Float)
findBoundDists cfig w findBoundDists cfig w
| debugOn Bound_box_screen cfig = (hh, - hh, hw, - hw) | debugOn Bound_box_screen cfig = (hh, - hh, hw, - hw)
-- | otherwise = fromMaybe (0, 0, 0, 0) $ farWallDistDirection (w ^. cWorld . camPos . camCenter) w
| otherwise = fromMaybe (0, 0, 0, 0) $ farWallDistDirection (w ^. wCam . camViewFrom) w | otherwise = fromMaybe (0, 0, 0, 0) $ farWallDistDirection (w ^. wCam . camViewFrom) w
where where
hw = halfWidth cfig hw = halfWidth cfig
+2 -4
View File
@@ -90,10 +90,9 @@ updatePressedButtonsCarte' pkeys w
updateKeysInTerminal :: Int -> Universe -> Universe updateKeysInTerminal :: Int -> Universe -> Universe
updateKeysInTerminal tmid u = updateKeysInTerminal tmid u =
u & doTextInputOver tmpoint u & doTextInputOver (uvWorld . cWorld . lWorld . terminals . ix tmid . tmInput . tiText)
& checkEndStatus & checkEndStatus
where where
tmpoint = uvWorld . cWorld . lWorld . terminals . ix tmid . tmInput . tiText
pkeys = u ^. uvWorld . input . pressedKeys pkeys = u ^. uvWorld . input . pressedKeys
checkEndStatus checkEndStatus
| pkeys ^. at ScancodeReturn == Just InitialPress = | pkeys ^. at ScancodeReturn == Just InitialPress =
@@ -110,7 +109,6 @@ updateInitialPressInGame :: Universe -> Scancode -> Universe
updateInitialPressInGame uv sc = case sc of updateInitialPressInGame uv sc = case sc of
ScancodeF1 -> useNormalCamera uv ScancodeF1 -> useNormalCamera uv
ScancodeF2 -> pauseAndFloatCam uv ScancodeF2 -> pauseAndFloatCam uv
-- ScancodeF3 -> pauseAndPanCam uv
ScancodeF5 -> doQuicksave uv ScancodeF5 -> doQuicksave uv
ScancodeF9 -> doQuickload uv ScancodeF9 -> doQuickload uv
ScancodeEscape -> pauseGame uv ScancodeEscape -> pauseGame uv
@@ -152,7 +150,7 @@ doRegexInput u i sss
any any
((== Just InitialPress) . (`M.lookup` pkeys)) ((== Just InitialPress) . (`M.lookup` pkeys))
[ScancodeReturn, ScancodeSlash] [ScancodeReturn, ScancodeSlash]
endmouse = (Just 0 == ) $ u ^? uvWorld . input . mouseButtons . ix ButtonLeft endmouse = (Just 0 ==) $ u ^? uvWorld . input . mouseButtons . ix ButtonLeft
backspacetonothing = backspacetonothing =
sss ^? sssExtra . sssFilters . ix i . _Just == Just "" sss ^? sssExtra . sssFilters . ix i . _Just == Just ""
&& ScancodeBackspace `M.lookup` pkeys == Just InitialPress && ScancodeBackspace `M.lookup` pkeys == Just InitialPress
+3 -2
View File
@@ -4,7 +4,7 @@ module Dodge.Update.Input.Text (
) where ) where
import Data.Either import Data.Either
import Data.Char --import Data.Char
import Dodge.Data.Universe import Dodge.Data.Universe
import LensHelp import LensHelp
import SDL import SDL
@@ -14,7 +14,8 @@ doTextInputOver p u = doTextInputOver' u p u
doTextInputOver' :: Universe -> ASetter' a String -> a -> a doTextInputOver' :: Universe -> ASetter' a String -> a -> a
doTextInputOver' u p x = doTextInputOver' u p x =
x & p %~ (++ map toUpper (rights str)) --x & p %~ (++ map toUpper (rights str))
x & p %~ (++ rights str)
& checkBackspace & checkBackspace
where where
str = u ^. uvWorld . input . textInput str = u ^. uvWorld . input . textInput
+10 -19
View File
@@ -1,4 +1,9 @@
module Dodge.WorldEffect where module Dodge.WorldEffect (
doWdWd,
accessTerminal,
doTmWdWd,
lineOutputTerminal,
) where
import Data.Foldable import Data.Foldable
import qualified Data.Map.Strict as M import qualified Data.Map.Strict as M
@@ -41,9 +46,9 @@ doItCrWdWd icww = case icww of
ItCrWdItemEffect -> flip itemEffect ItCrWdItemEffect -> flip itemEffect
accessTerminal :: Maybe Int -> World -> World accessTerminal :: Maybe Int -> World -> World
accessTerminal mtmid w = case mtmid of accessTerminal mtmid w = fromMaybe w $ do
Nothing -> w tmid <- mtmid
Just tmid -> 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 . tmInput . tiFocus .~ True
& cWorld . lWorld . terminals . ix tmid %~ tryToBoot & cWorld . lWorld . terminals . ix tmid %~ tryToBoot
@@ -63,17 +68,6 @@ torqueCr x cid w
where where
(rot, g) = randomR (- x, x) $ _randGen w (rot, g) = randomR (- x, x) $ _randGen w
doCommandInstant :: String -> Terminal -> World -> World
doCommandInstant arg tm w = doLineEffectsInstant tm w $ commandFutureLines arg tm w
-- doesn't do internal terminal effects
doLineEffectsInstant :: Terminal -> World -> [TerminalLine] -> World
doLineEffectsInstant tm = foldr f
where
f tl w = case tl of
TerminalLineEffect _ eff -> doTmWdWd eff tm w
_ -> w
lineOutputTerminal :: [TerminalLine] -> Terminal lineOutputTerminal :: [TerminalLine] -> Terminal
lineOutputTerminal tls = lineOutputTerminal tls =
defaultTerminal defaultTerminal
@@ -81,7 +75,6 @@ lineOutputTerminal tls =
, _tmFutureLines = [] , _tmFutureLines = []
, _tmMaxLines = 14 , _tmMaxLines = 14
, _tmTitle = "TERMINAL" , _tmTitle = "TERMINAL"
, _tmInput = defaultTerminalInput
, _tmScrollCommands = [quitCommand] , _tmScrollCommands = [quitCommand]
, _tmWriteCommands = [helpCommand, commandsCommand] , _tmWriteCommands = [helpCommand, commandsCommand]
, _tmBootProgram = TerminalBootLines $ connectionBlurbLines tls , _tmBootProgram = TerminalBootLines $ connectionBlurbLines tls
@@ -89,9 +82,7 @@ lineOutputTerminal tls =
} }
doDeathTriggers :: Terminal -> World -> World doDeathTriggers :: Terminal -> World -> World
doDeathTriggers tm w = doDeathTriggers tm = cWorld . lWorld . triggers %~ flip (foldl' $ flip doDeathToggle) xs
w
& cWorld . lWorld . triggers %~ flip (foldl' $ flip doDeathToggle) xs
where where
xs = M.elems $ _tmToggles tm xs = M.elems $ _tmToggles tm
-2
View File
@@ -201,7 +201,6 @@ stackText = mconcat . zipWith (\y s -> translate 0 y $ centerText s) [0, 100 ..]
text :: String -> Picture text :: String -> Picture
{-# INLINE text #-} {-# INLINE text #-}
--text = translate (-50) (-100) . drawText (10)
text = translate (-50) (-100) . drawText (-10) text = translate (-50) (-100) . drawText (-10)
drawText :: Float -> String -> [Verx] drawText :: Float -> String -> [Verx]
@@ -209,7 +208,6 @@ drawText gap = map f . stringToList gap
where where
f (pos, col, V3 a b c) = Verx pos col [a, b, c, 1] BottomLayer textNum f (pos, col, V3 a b c) = Verx pos col [a, b, c, 1] BottomLayer textNum
line :: [Point2] -> Picture line :: [Point2] -> Picture
{-# INLINE line #-} {-# INLINE line #-}
line = thickLine 1 line = thickLine 1