Cleanup
This commit is contained in:
@@ -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
|
||||||
|
|||||||
@@ -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
@@ -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
|
||||||
|
|||||||
+26
-26
@@ -3,7 +3,7 @@ module Dodge.Render.HUD (
|
|||||||
drawHUD,
|
drawHUD,
|
||||||
) where
|
) where
|
||||||
|
|
||||||
import Dodge.SelectionSections.Draw
|
import Data.Foldable
|
||||||
import Control.Lens
|
import Control.Lens
|
||||||
import qualified Data.Map.Strict as M
|
import qualified Data.Map.Strict as M
|
||||||
import Data.Maybe
|
import Data.Maybe
|
||||||
@@ -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
|
||||||
@@ -204,13 +208,9 @@ displayTerminal tid cfig w = fromMaybe mempty $ do
|
|||||||
, 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
|
defaultSelectionList & slItems .~ thelist tm
|
||||||
{ _slItems = thelist tm
|
|
||||||
-- , _slLength = length (thelist tm)
|
|
||||||
}
|
|
||||||
thelist tm =
|
thelist tm =
|
||||||
map toselitm . displayTermInput tm
|
map toselitm . displayTermInput tm
|
||||||
. reverse
|
. reverse
|
||||||
@@ -218,11 +218,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 = fromMaybe "" $ 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 +277,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,6 +317,7 @@ 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
|
--locPoss = map (cartePosToScreen cfig (w ^. hud) . ($ w) . doWorldPos . fst) . IM.elems . _seenLocations . _lWorld $ _cWorld w
|
||||||
--locTexts = map fst locs
|
--locTexts = map fst locs
|
||||||
|
|
||||||
@@ -399,8 +400,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 +418,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)
|
||||||
|
|||||||
+15
-20
@@ -22,7 +22,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 +37,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
|
||||||
@@ -112,11 +110,6 @@ connectionBlurb =
|
|||||||
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 +134,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 +149,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)
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -192,10 +185,10 @@ 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]
|
||||||
@@ -271,8 +264,10 @@ commandFutureLines s tm w = fromMaybe [errline "^ INVALID COMMAND"] $ do
|
|||||||
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 = TerminalLineTerminalEffect 0 (TmTmSetPartialCommand (Just str))
|
||||||
fromMaybe [errline $ "^ INVALID ARGUMENT: EXPECTS " ++ argtype] $
|
: 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,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
@@ -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
|
||||||
|
|||||||
+27
-25
@@ -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
|
||||||
@@ -162,14 +163,16 @@ zoomInLongGun :: Point2 -> Scope -> Scope
|
|||||||
zoomInLongGun mousep sc = fromMaybe sc $ do
|
zoomInLongGun mousep sc = fromMaybe sc $ do
|
||||||
curzoom <- sc ^? scopeZoom
|
curzoom <- sc ^? scopeZoom
|
||||||
guard $ curzoom < 8
|
guard $ curzoom < 8
|
||||||
return $ sc & scopePos .+.+~ (1 - zoomSpeed)*zoomSpeed/curzoom *.* mousep
|
return $
|
||||||
|
sc & scopePos .+.+~ (1 - zoomSpeed) * zoomSpeed / curzoom *.* mousep
|
||||||
& scopeZoom %~ (/ zoomSpeed)
|
& scopeZoom %~ (/ zoomSpeed)
|
||||||
|
|
||||||
zoomOutLongGun :: Scope -> Scope
|
zoomOutLongGun :: Scope -> Scope
|
||||||
zoomOutLongGun sc = fromMaybe sc $ do
|
zoomOutLongGun sc = fromMaybe sc $ do
|
||||||
curzoom <- sc ^? scopeZoom
|
curzoom <- sc ^? scopeZoom
|
||||||
guard $ curzoom > 0.5
|
guard $ curzoom > 0.5
|
||||||
return $ sc & scopePos %~ (\p -> p +.+ (zoomSpeed - 1) / curzoom *.* p)
|
return $
|
||||||
|
sc & scopePos %~ (\p -> p +.+ (zoomSpeed - 1) / curzoom *.* p)
|
||||||
& scopeZoom *~ zoomSpeed
|
& scopeZoom *~ zoomSpeed
|
||||||
|
|
||||||
ifConfigWallRotate :: Configuration -> World -> World
|
ifConfigWallRotate :: Configuration -> World -> World
|
||||||
@@ -197,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)
|
||||||
|
|
||||||
@@ -209,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
|
||||||
@@ -252,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
|
||||||
|
|||||||
@@ -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
|
||||||
@@ -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
|
||||||
|
|||||||
Reference in New Issue
Block a user