From edd82fb3ac1a919427c868e45d74aecdd92b27cc Mon Sep 17 00:00:00 2001 From: justin Date: Sun, 10 Apr 2022 10:32:55 +0100 Subject: [PATCH] Remove old layer code --- src/Dodge/Creature.hs | 3 +- src/Dodge/Creature/ChaseCrit.hs | 3 +- src/Dodge/Creature/Inanimate.hs | 3 +- src/Dodge/Creature/SwarmCrit.hs | 3 +- src/Dodge/Debug.hs | 5 ++-- src/Dodge/Debug/LinkDecoration.hs | 5 ++-- src/Dodge/Default.hs | 4 +-- src/Dodge/Item/Equipment.hs | 6 ++-- src/Dodge/Item/Weapon/Booster.hs | 2 +- src/Dodge/Item/Weapon/Decoration.hs | 3 +- src/Dodge/Item/Weapon/ExtraEffect.hs | 5 ++-- src/Dodge/Item/Weapon/Grenade.hs | 3 +- src/Dodge/Picture/Layer.hs | 44 ++++++++++++++-------------- src/Dodge/Picture/Layer/Data.hs | 2 +- src/Dodge/Render/Picture.hs | 3 +- src/Dodge/WorldEvent/Shockwave.hs | 2 +- src/Picture/Data.hs | 11 +++++++ 17 files changed, 54 insertions(+), 53 deletions(-) diff --git a/src/Dodge/Creature.hs b/src/Dodge/Creature.hs index 00ae0d01b..ae1a8e142 100644 --- a/src/Dodge/Creature.hs +++ b/src/Dodge/Creature.hs @@ -42,7 +42,6 @@ import Dodge.Creature.State import Dodge.Creature.Picture --import Dodge.Creature.ChooseTarget --import Dodge.Item -import Dodge.Picture.Layer import Picture import Geometry.Data import qualified IntMapHelp as IM @@ -155,7 +154,7 @@ startCr = defaultCreature , _crHP = 1000 , _crMaxHP = 1500 , _crInv = startInventory - , _crCorpse = onLayer CorpseLayer + , _crCorpse = setDepth 5 $ color (greyN 0.5) $ pictures [color (greyN 0.8) $ circleSolid 10, circLine 10] , _crFaction = PlayerFaction , _crMvType = MvWalking yourDefaultSpeed diff --git a/src/Dodge/Creature/ChaseCrit.hs b/src/Dodge/Creature/ChaseCrit.hs index ee0c83dbe..7c368579d 100644 --- a/src/Dodge/Creature/ChaseCrit.hs +++ b/src/Dodge/Creature/ChaseCrit.hs @@ -10,7 +10,6 @@ import Dodge.Creature.ReaderUpdate import Dodge.Creature.Action import Dodge.Creature.Perception import Dodge.Item.Consumable -import Dodge.Picture.Layer import Dodge.SoundLogic --import Geometry import Picture @@ -27,7 +26,7 @@ smallChaseCrit = chaseCrit , _crRad = 4 , _crPict = basicCrPict green , _crInv = IM.fromList [(0,medkit 200)] - , _crCorpse = onLayer CorpseLayer $ color (greyN 0.5) $ circleSolid 4 + , _crCorpse = setDepth 5 $ color (greyN 0.5) $ circleSolid 4 } chaseCrit :: Creature chaseCrit = defaultCreature diff --git a/src/Dodge/Creature/Inanimate.hs b/src/Dodge/Creature/Inanimate.hs index 783c70b5e..a7f4ccc8f 100644 --- a/src/Dodge/Creature/Inanimate.hs +++ b/src/Dodge/Creature/Inanimate.hs @@ -12,7 +12,6 @@ import Dodge.Creature.Lamp import Dodge.WorldEvent.Explosion import Dodge.Creature.Picture --import Dodge.Creature.Stance.Data -import Dodge.Picture.Layer import Dodge.Particle.Spark import Dodge.Default import Dodge.Creature.State @@ -32,7 +31,7 @@ barrel :: Creature barrel = defaultInanimate { _crUpdate = updateBarrel , _crHP = 500 - , _crPict = picAtCrPos $ onLayer CrLayer $ pictures + , _crPict = picAtCrPos $ setDepth 20 $ pictures [ color orange $ circleSolid 10 , setDepth 0.049 . color (greyN 0.5) $ circleSolid 8 , color (greyN 0.5) $ circleSolid 8 diff --git a/src/Dodge/Creature/SwarmCrit.hs b/src/Dodge/Creature/SwarmCrit.hs index 4ffb5a356..91e00606f 100644 --- a/src/Dodge/Creature/SwarmCrit.hs +++ b/src/Dodge/Creature/SwarmCrit.hs @@ -11,7 +11,6 @@ import Dodge.Creature.ReaderUpdate import Dodge.Creature.Perception --import Dodge.Creature.Impulse --import Dodge.Creature.State -import Dodge.Picture.Layer import Picture import Control.Lens @@ -32,7 +31,7 @@ swarmCrit = defaultCreature , _crRad = 2 , _crMass = 2 , _crPict = basicCrPict yellow - , _crCorpse = onLayer CorpseLayer $ color (greyN 0.5) $ circleSolid 2 + , _crCorpse = setDepth 5 $ color (greyN 0.5) $ circleSolid 2 , _crFaction = ColorFaction yellow , _crMeleeCooldown = 0 } diff --git a/src/Dodge/Debug.hs b/src/Dodge/Debug.hs index 742aa0b45..aad9bbff4 100644 --- a/src/Dodge/Debug.hs +++ b/src/Dodge/Debug.hs @@ -1,6 +1,5 @@ module Dodge.Debug where import Dodge.Data -import Dodge.Picture.Layer import Dodge.Zone import Dodge.Base import Geometry.Zone @@ -21,7 +20,7 @@ drawCircleAtForCol p t col w = w & props %~ { _pjPos = p , _pjStartPos = p , _pjVel = V2 0 0 - , _prDraw = \_ -> (,) mempty $ onLayer PtLayer $ uncurryV translate p $ color col $ circleSolid 20 + , _prDraw = \_ -> (,) mempty $ setDepth 20 $ uncurryV translate p $ color col $ circleSolid 20 , _pjID = k , _pjUpdate = \_ -> pjTimerF t k } @@ -34,7 +33,7 @@ drawLineForCol ps t col w = w & props %~ { _pjPos = head ps , _pjStartPos = head ps , _pjVel = V2 0 0 - , _prDraw = \_ -> (,) mempty $ onLayer PtLayer $ color col $ thickLine 5 ps + , _prDraw = \_ -> (,) mempty $ setDepth 20 $ color col $ thickLine 5 ps , _pjID = k , _pjUpdate = \_ -> pjTimerF t k } diff --git a/src/Dodge/Debug/LinkDecoration.hs b/src/Dodge/Debug/LinkDecoration.hs index 91bcdba28..7eea92ab3 100644 --- a/src/Dodge/Debug/LinkDecoration.hs +++ b/src/Dodge/Debug/LinkDecoration.hs @@ -6,7 +6,6 @@ import Dodge.Data import Dodge.RoomLink --import Dodge.Base import Dodge.LevelGen.Data -import Dodge.Picture.Layer import Picture import qualified IntMapHelp as IM import Geometry.Data @@ -26,11 +25,11 @@ roomLinkDecorations :: Room -> Picture roomLinkDecorations rm = pictures . map (linkDecoration . lnkPosDir) $ _rmLinks rm linkDecoration :: (Point2,Float) -> Picture -linkDecoration (p,a) = setLayer 1 . onLayer DebugLayer . color red $ line [p, p +.+ 20 *.* unitVectorAtAngle (a - pi/2)] +linkDecoration (p,a) = setLayer 1 . setDepth 50 . color red $ line [p, p +.+ 20 *.* unitVectorAtAngle (a - pi/2)] roomPolyDecorations :: Room -> Picture roomPolyDecorations rm = pictures . map polyWireFrame $ _rmPolys rm polyWireFrame :: [Point2] -> Picture -polyWireFrame (x:xs) = setLayer 1 . onLayer DebugLayer . color green $ line $ (x:xs) ++ [x] +polyWireFrame (x:xs) = setLayer 1 . setDepth 50 . color green $ line $ (x:xs) ++ [x] polyWireFrame _ = undefined diff --git a/src/Dodge/Default.hs b/src/Dodge/Default.hs index 713f29767..f11b3eac8 100644 --- a/src/Dodge/Default.hs +++ b/src/Dodge/Default.hs @@ -44,7 +44,7 @@ defaultCreature = Creature , _crInvEquipped = mempty , _crLeftInvSel = Nothing , _crState = defaultState - , _crCorpse = setLayer 0 $ onLayer CorpseLayer $ color (greyN 0.5) $ circleSolid 10 + , _crCorpse = setLayer 0 $ setDepth 5 $ color (greyN 0.5) $ circleSolid 10 , _crApplyDamage = defaultApplyDamage , _crStance = Stance {_carriage=Walking 0 WasLeftForward @@ -245,7 +245,7 @@ defaultPT = Projectile } defaultPP :: PressPlate defaultPP = PressPlate - { _ppPict = onLayer PressPlateLayer . color (dim . dim $ bright blue) $ circleSolid 5 + { _ppPict = setDepth 1 . color (dim . dim $ bright blue) $ circleSolid 5 , _ppPos = V2 0 0 , _ppRot = 0 , _ppEvent = const id diff --git a/src/Dodge/Item/Equipment.hs b/src/Dodge/Item/Equipment.hs index 0a8f7d568..691fc2ec8 100644 --- a/src/Dodge/Item/Equipment.hs +++ b/src/Dodge/Item/Equipment.hs @@ -43,7 +43,7 @@ flameShield :: Item flameShield = defaultEquipment { _itType = FLAMESHIELD , _itName = "FLAMESHIELD" - , _itEquipPict = \cr _ -> (,) emptySH $ onLayer CrLayer $ pictures [color cyan $ circle (_crRad cr+2)] + , _itEquipPict = \cr _ -> (,) emptySH $ setDepth 20 $ pictures [color cyan $ circle (_crRad cr+2)] , _itID = Nothing } {- | Slows you down, blocks forward projectiles. -} @@ -55,7 +55,7 @@ frontArmour = defaultEquipment -- [color (greyN 0.1) $ thickArc 0 (pi/2) 10 5 -- ,color (greyN 0.1) $ thickArc (3*pi/2) (2*pi) 10 5 -- ] - , _itEquipPict = \_ _ -> (,) emptySH $ onLayer CrLayer $ pictures + , _itEquipPict = \_ _ -> (,) emptySH $ setDepth 20 $ pictures [color (greyN 0.1) $ thickArc 0 (pi/2) 10 5 ,color (greyN 0.1) $ thickArc (3*pi/2) (2*pi) 10 5 ] @@ -166,7 +166,7 @@ jetPack :: Item jetPack = defaultEquipment { _itType = JETPACK , _itName = "JETPACK" - , _itEquipPict = \_ _ -> (,) emptySH $ onLayer CrLayer + , _itEquipPict = \_ _ -> (,) emptySH $ setDepth 20 $ pictures [color yellow $ polygon $ rectNSEW 5 (-5) (-3) (-11) ] , _itEffect = NoItEffect , _itID = Nothing diff --git a/src/Dodge/Item/Weapon/Booster.hs b/src/Dodge/Item/Weapon/Booster.hs index 97ac53d6c..fff2fe4bc 100644 --- a/src/Dodge/Item/Weapon/Booster.hs +++ b/src/Dodge/Item/Weapon/Booster.hs @@ -81,7 +81,7 @@ updateLinearShockwave pj w t = _pjTimer pj drawBoostShockwave :: Prop -> SPic -drawBoostShockwave pj = (,) mempty $ setLayer 1 $ onLayer UPtLayer $ pictures $ +drawBoostShockwave pj = (,) mempty $ setLayer 1 $ setDepth 20 $ pictures $ theArc ++ [ lineCol $ zip (reverse lps) $ map (`withAlpha` white) [0,0.05..] , lineCol $ zip (reverse rps) $ map (`withAlpha` white) [0,0.05..] diff --git a/src/Dodge/Item/Weapon/Decoration.hs b/src/Dodge/Item/Weapon/Decoration.hs index ff5eebb8f..df08fed4f 100644 --- a/src/Dodge/Item/Weapon/Decoration.hs +++ b/src/Dodge/Item/Weapon/Decoration.hs @@ -5,7 +5,6 @@ module Dodge.Item.Weapon.Decoration ( makeLaserScope ) where import Dodge.Data -import Dodge.Picture.Layer import Geometry.Data import Picture @@ -16,7 +15,7 @@ makeLaserScope -> Float -- ^ Fraction of red/green -> Particle makeLaserScope p ep relFrac = Particle - {_ptDraw = const $ setLayer 1 $ onLayer PtLayer $ pictures + {_ptDraw = const $ setLayer 1 $ setDepth 20 $ pictures [lineAlphaThick 0.5 0.5 ,lineAlphaThick 0.2 1.5 ,lineAlphaThick 0.1 2 diff --git a/src/Dodge/Item/Weapon/ExtraEffect.hs b/src/Dodge/Item/Weapon/ExtraEffect.hs index a71cd75fa..f86d86341 100644 --- a/src/Dodge/Item/Weapon/ExtraEffect.hs +++ b/src/Dodge/Item/Weapon/ExtraEffect.hs @@ -18,7 +18,6 @@ import Dodge.Base import Dodge.Item.Weapon.UseEffect import Dodge.Item.Weapon.LaserPath --import Dodge.Item.Attachment.Data -import Dodge.Picture.Layer import Dodge.Creature.Test import Dodge.WorldEvent.HelperParticle import Picture @@ -76,7 +75,7 @@ targetCursor = defaultTargeting targetSimpleDraw :: Int -> Item -> Creature -> World -> Picture targetSimpleDraw _ it _ w = fromMaybe mempty $ do mwp <- it ^? itTargeting . tgPos . _Just - return $ setLayer 5 $ color red $ onLayer InvLayer $ uncurryV translate mwp + return $ setLayer 4 $ color red $ setDepth 50 $ uncurryV translate mwp $ rotate (_cameraRot w) $ pictures [line [V2 x x, V2 (-x) (-x)] @@ -88,7 +87,7 @@ targetSimpleDraw _ it _ w = fromMaybe mempty $ do targetRBCreatureDraw :: Int -> Item -> Creature -> World -> Picture targetRBCreatureDraw _ it _ w = fromMaybe mempty $ do mwp <- it ^? itTargeting . tgPos . _Just - return $ setLayer 5 $ color thecolor $ onLayer InvLayer $ uncurryV translate mwp + return $ setLayer 5 $ color thecolor $ setDepth 50 $ uncurryV translate mwp $ rotate (_cameraRot w) $ pictures [line [V2 x x, V2 (-x) (-x)] diff --git a/src/Dodge/Item/Weapon/Grenade.hs b/src/Dodge/Item/Weapon/Grenade.hs index 6016295c0..1d824f8dd 100644 --- a/src/Dodge/Item/Weapon/Grenade.hs +++ b/src/Dodge/Item/Weapon/Grenade.hs @@ -1,6 +1,5 @@ module Dodge.Item.Weapon.Grenade where import Dodge.Data -import Dodge.Picture.Layer import Dodge.WorldEvent.Explosion --import Dodge.Item.Weapon.TriggerType import Dodge.Item.Weapon.Remote @@ -193,7 +192,7 @@ moveRemoteBomb itid time pID w | otherwise = x - 1 updatePicture = set (props . ix pID . prDraw) - (\_ -> (,) mempty $ onLayer PtLayer $ uncurryV translate newPos $ remoteBombPic time) + (\_ -> (,) mempty $ setDepth 20 $ uncurryV translate newPos $ remoteBombPic time) diff --git a/src/Dodge/Picture/Layer.hs b/src/Dodge/Picture/Layer.hs index 8e7724aa5..8c69474f7 100644 --- a/src/Dodge/Picture/Layer.hs +++ b/src/Dodge/Picture/Layer.hs @@ -1,35 +1,35 @@ {- | Uniform management of layers and depths on which pictures are drawn. -} module Dodge.Picture.Layer - ( onLayer - , onLayerL - , levLayer - , Layer (..) + ( --onLayer + onLayerL +-- , levLayer +-- , Layer (..) ) where import Dodge.Picture.Layer.Data import Picture {- | Uses a layer to set the depth. -} -onLayer :: Layer -> Picture -> Picture -onLayer l = setDepth $ (1 - fromIntegral (levLayer l) / 100) / 1000 +--onLayer :: Layer -> Picture -> Picture +--onLayer l = setDepth $ (1 - fromIntegral (levLayer l) / 100) / 1000 {- | Set a depth according to a list of numbers. Lists are lexicographically ordered if input values are always less than 100. Higher numbers will get placed on top of lower numbers. -} onLayerL :: [Int] -> Picture -> Picture onLayerL is = setDepth $ (1 - sum (zipWith (/) (map fromIntegral is) $ map (100 **) [1..])) / 1000 {- | For depth testing, set layer values. -} -levLayer :: Layer -> Int -levLayer BgLayer = 20 -levLayer PressPlateLayer = 45 -levLayer CorpseLayer = 50 -levLayer FlItLayer = 55 -levLayer CrLayer = 60 -levLayer WlLayer = 74 -levLayer GloomLayer = 67 -levLayer UPtLayer = 70 -levLayer PtLayer = 72 -levLayer HPtLayer = 73 -levLayer ShadowLayer = 75 -levLayer LabelLayer = 80 -levLayer InvLayer = 85 -levLayer MenuDepth = 90 -levLayer DebugLayer = 99 +--levLayer :: Layer -> Int +--levLayer BgLayer = 20 +--levLayer PressPlateLayer = 45 +--levLayer CorpseLayer = 50 +--levLayer FlItLayer = 55 +--levLayer CrLayer = 60 +--levLayer WlLayer = 74 +--levLayer GloomLayer = 67 +--levLayer UPtLayer = 70 +--levLayer PtLayer = 72 +--levLayer HPtLayer = 73 +--levLayer ShadowLayer = 75 +--levLayer LabelLayer = 80 +--levLayer InvLayer = 85 +--levLayer MenuDepth = 90 +--levLayer DebugLayer = 99 diff --git a/src/Dodge/Picture/Layer/Data.hs b/src/Dodge/Picture/Layer/Data.hs index e97f1e083..63710c823 100644 --- a/src/Dodge/Picture/Layer/Data.hs +++ b/src/Dodge/Picture/Layer/Data.hs @@ -1,7 +1,7 @@ module Dodge.Picture.Layer.Data where -data Layer +data Layer'' = PtLayer | CrLayer | WlLayer diff --git a/src/Dodge/Render/Picture.hs b/src/Dodge/Render/Picture.hs index b9e01fa40..ecb14e28c 100644 --- a/src/Dodge/Render/Picture.hs +++ b/src/Dodge/Render/Picture.hs @@ -5,7 +5,6 @@ module Dodge.Render.Picture import Dodge.Data --import Dodge.Base.Window import Dodge.Base.WinScale -import Dodge.Picture.Layer import Dodge.Render.HUD import Dodge.Render.MenuScreen import Geometry @@ -17,7 +16,7 @@ fixedCoordPictures u = case _menuLayers u of [ hudDrawings cfig w , customMouseCursor cfig w ] - (lay:_) -> setDepth (-1) . winScale cfig . onLayer MenuDepth $ menuScreen u lay + (lay:_) -> setDepth (-1) . winScale cfig $ menuScreen u lay where w = _uvWorld u cfig = _config u diff --git a/src/Dodge/WorldEvent/Shockwave.hs b/src/Dodge/WorldEvent/Shockwave.hs index de519f366..1abc445e5 100644 --- a/src/Dodge/WorldEvent/Shockwave.hs +++ b/src/Dodge/WorldEvent/Shockwave.hs @@ -115,7 +115,7 @@ moveInverseShockwave w pt drawInverseShockwave :: Particle -> Picture drawInverseShockwave pt - = setLayer 1 $ onLayer PtLayer $ uncurryV translate p + = setLayer 1 $ setDepth 20 $ uncurryV translate p $ color cyan $ thickCircle rad thickness where p = _ptPos pt diff --git a/src/Picture/Data.hs b/src/Picture/Data.hs index 0daea6505..facff62e5 100644 --- a/src/Picture/Data.hs +++ b/src/Picture/Data.hs @@ -14,6 +14,17 @@ data Verx = Verx , _vxShadNum :: !ShadNum } newtype LayNum = LayNum { _unLayNum :: Int } + +data Layer + = BottomLayer + | MidLayer + | BloomLayer + | BloomNoZWrite + | TopLayer + | FixedCoordLayer + +numLayers :: Int +numLayers = 6 --TODO use synonyms for layer numbers newtype ShadNum = ShadNum { _unShadNum :: Int } polyNum, polyzNum, bezNum, textNum, arcNum, ellNum :: ShadNum