Block screen during long loading

This commit is contained in:
2022-12-29 00:44:51 +00:00
parent d1f80f1f7f
commit be41d51819
13 changed files with 90 additions and 54 deletions
+1 -1
View File
@@ -54,7 +54,7 @@ teslaBeamCombine (p, (a, b, bm), (x, y, _)) w =
where where
itid = fromJust $ _bmOrigin bm itid = fromJust $ _bmOrigin bm
dir = argV (normalizeV (b -.- a) +.+ normalizeV (y -.- x)) dir = argV (normalizeV (b -.- a) +.+ normalizeV (y -.- x))
(w', ip) = shootTeslaArc' (fromJust . _subParams $ _itParams it) p dir w (w', ip) = makeTeslaArc (fromJust . _subParams $ _itParams it) p dir w
it = case getItem itid w of it = case getItem itid w of
Nothing -> error "tried to get item use teslaBeamCombine that doesn't exist" Nothing -> error "tried to get item use teslaBeamCombine that doesn't exist"
Just itm -> itm Just itm -> itm
+5 -1
View File
@@ -1,4 +1,8 @@
module Dodge.Concurrent where module Dodge.Concurrent
( hardQuit
, addSideEffect
, conEffects
) where
--import qualified Data.Set as S --import qualified Data.Set as S
import Control.Lens import Control.Lens
+1 -1
View File
@@ -46,6 +46,7 @@ data SideEffect
| HardQuit | HardQuit
data OptionScreenFlag = NormalOptions | GameOverOptions | SplashOptions data OptionScreenFlag = NormalOptions | GameOverOptions | SplashOptions
| LoadingScreen
deriving (Eq, Ord, Show, Read) --Generic, Flat) deriving (Eq, Ord, Show, Read) --Generic, Flat)
data PositionedMenuOption data PositionedMenuOption
@@ -68,7 +69,6 @@ data ScreenLayer
{ _scInput :: T.Text { _scInput :: T.Text
, _scFooter :: String , _scFooter :: String
} }
-- | WaitScreen -- | WaitScreen
-- { _scWaitMessage :: Universe -> String -- { _scWaitMessage :: Universe -> String
-- , _scWaitTime :: Int -- , _scWaitTime :: Int
+7 -3
View File
@@ -1,4 +1,8 @@
module Dodge.EnergyBall where module Dodge.EnergyBall
( updateEnergyBall
, incBallAt
, makeFlamelet
) where
import Dodge.DamageCircle import Dodge.DamageCircle
import Dodge.Data.World import Dodge.Data.World
@@ -38,8 +42,8 @@ makeFlamelet (V2 x y) z vel size time w =
where where
(rot, g) = randomR (0, 3) $ _randGen w (rot, g) = randomR (0, 3) $ _randGen w
moveEnergyBall :: World -> EnergyBall -> (World, Maybe EnergyBall) updateEnergyBall :: World -> EnergyBall -> (World, Maybe EnergyBall)
moveEnergyBall w eb updateEnergyBall w eb
| _ebTimer eb <= 0 = (w, Nothing) | _ebTimer eb <= 0 = (w, Nothing)
| otherwise = | otherwise =
( ebFlicker eb $ uncurry (damageCircle 5 (_ebPos eb)) (_ebEff eb) w ( ebFlicker eb $ uncurry (damageCircle 5 (_ebPos eb)) (_ebEff eb) w
+3 -3
View File
@@ -1,7 +1,7 @@
module Dodge.Flame ( module Dodge.Flame (
aFlameParticle, aFlameParticle,
makeFlame, makeFlame,
moveFlame, updateFlame,
) where ) where
import Dodge.Data.World import Dodge.Data.World
@@ -68,8 +68,8 @@ doDamagesFL fdm (p, thhit) bt = case thhit of
dams = fdm bt p dams = fdm bt p
{- TODO: add generalised area damage particles/hiteffects. -} {- TODO: add generalised area damage particles/hiteffects. -}
moveFlame :: World -> Flame -> (World, Maybe Flame) updateFlame :: World -> Flame -> (World, Maybe Flame)
moveFlame w pt updateFlame w pt
| time <= 0 = (makeFlamerSmokeAt (addZ 20 ep) w, Nothing) | time <= 0 = (makeFlamerSmokeAt (addZ 20 ep) w, Nothing)
| otherwise = case List.safeHead $ thingsHit sp ep w of | otherwise = case List.safeHead $ thingsHit sp ep w of
Just (_, Left _) -> (doSound $ dodamage w, mvPt' 0.7) Just (_, Left _) -> (doSound $ dodamage w, mvPt' 0.7)
+1 -1
View File
@@ -501,6 +501,6 @@ shootTeslaArc it cr w =
w' w'
& cWorld . lWorld . creatures . ix (_crID cr) . crInv . ix (crSel cr) . itParams .~ ip & cWorld . lWorld . creatures . ix (_crID cr) . crInv . ix (crSel cr) . itParams .~ ip
where where
(w', ip) = shootTeslaArc' (_itParams it) pos dir w (w', ip) = makeTeslaArc (_itParams it) pos dir w
pos = _crPos cr +.+ aimingMuzzlePos cr it *.* unitVectorAtAngle dir pos = _crPos cr +.+ aimingMuzzlePos cr it *.* unitVectorAtAngle dir
dir = _crDir cr dir = _crDir cr
+12
View File
@@ -0,0 +1,12 @@
module Dodge.Item.Info where
import Dodge.Data.Item
itmBaseInfo :: ItemBaseType -> String
itmBaseInfo t = case t of
HELD _ -> "THIS ITEM CAN BE HELD."
LEFT _ -> "THIS ITEM CAN BE EQUIPPED. WHEN EQUIPPED, IT CAN BE ACTIVATED."
EQUIP _ -> "THIS ITEM CAN BE EQUIPPED."
Consumable _ -> "THIS ITEM CAN BE CONSUMED."
CRAFT _ -> "THIS ITEM SEEMS USELESS ON ITS OWN."
_ -> "THIS SHOULD NOT BE DISPLAYED"
+2 -1
View File
@@ -29,7 +29,8 @@ useTimeScrollGun itm _ w = w & cWorld . timeFlow .~ ScrollTimeFlow
} }
useRewindGun :: Item -> Creature -> World -> World useRewindGun :: Item -> Creature -> World -> World
useRewindGun itm _ w = w & cWorld . timeFlow .~ RewindLeftClick (itm ^?! itUse . leftConsumption . wpCharge) useRewindGun itm _ w = w
& cWorld . timeFlow .~ RewindLeftClick (itm ^?! itUse . leftConsumption . wpCharge)
--useRewindGun _ _ w = case w ^. cwTime . rewindWorlds of --useRewindGun _ _ w = case w ^. cwTime . rewindWorlds of
-- [w'] -> w & cwTime . maybeWorld .~ Just' w' -- [w'] -> w & cwTime . maybeWorld .~ Just' w'
+16
View File
@@ -0,0 +1,16 @@
module Dodge.Menu.Loading where
import Dodge.Menu.Option
import Dodge.Data.Universe
loadingScreen :: String -> ScreenLayer
loadingScreen str = OptionScreen
{ _scTitle = str
, _scOptions = []
, _scOffset = 0
, _scPositionedMenuOption = NoPositionedMenuOption
, _scOptionFlag = LoadingScreen
, _scSelectionList = SelectionList [] Nothing 0
, _scAvailableLines = 0
, _scListDisplayParams = optionListDisplayParams
}
+3 -3
View File
@@ -1,5 +1,5 @@
module Dodge.Spark ( module Dodge.Spark (
moveSpark, updateSpark,
colSpark, colSpark,
colSparkRandDir, colSparkRandDir,
createBarrelSpark, createBarrelSpark,
@@ -16,8 +16,8 @@ import Geometry
import LensHelp import LensHelp
import System.Random import System.Random
moveSpark :: World -> Spark -> (World, Maybe Spark) updateSpark :: World -> Spark -> (World, Maybe Spark)
moveSpark w sk updateSpark w sk
| magV (_skVel sk) < 1 = (w, Nothing) | magV (_skVel sk) < 1 = (w, Nothing)
| otherwise = case thingHit sp ep w of | otherwise = case thingHit sp ep w of
Nothing -> (w, Just $ sk & skPos .~ ep & skVel .*.*~ 0.9 & skOldPos .~ sp) Nothing -> (w, Just $ sk & skPos .~ ep & skVel .*.*~ 0.9 & skOldPos .~ sp)
+8 -2
View File
@@ -3,9 +3,10 @@ module Dodge.StartNewGame (
startSeedGame, startSeedGame,
) where ) where
import Dodge.Menu.Loading
import Dodge.Concurrent import Dodge.Concurrent
--import Dodge.Menu.Option --import Dodge.Menu.Option
import Control.Lens import LensHelp
import Dodge.Data.Universe import Dodge.Data.Universe
import Dodge.LevelGen import Dodge.LevelGen
import Dodge.Save import Dodge.Save
@@ -16,8 +17,13 @@ startNewGameInSlot slot u = startSeedGame slot i u
where where
i = fst $ randomR (0, maxBound) (_randGen (_uvWorld u)) i = fst $ randomR (0, maxBound) (_randGen (_uvWorld u))
blockingLoad :: String -> IO (Universe -> Maybe Universe) -> Universe -> Universe
blockingLoad str f u = u & uvScreenLayers .:~ loadingScreen str
& addSideEffect f str
startSeedGame :: Int -> Int -> Universe -> Universe startSeedGame :: Int -> Int -> Universe -> Universe
startSeedGame _ i = addSideEffect (startSeedGameConc i) "GENERATING" startSeedGame _ i = blockingLoad "LOADING" (startSeedGameConc i)
startSeedGameConc :: Int -> IO (Universe -> Maybe Universe) startSeedGameConc :: Int -> IO (Universe -> Maybe Universe)
startSeedGameConc seed = do startSeedGameConc seed = do
+10 -10
View File
@@ -1,14 +1,14 @@
module Dodge.Tesla.Arc module Dodge.Tesla.Arc (
( shootTeslaArc' makeTeslaArc,
, moveTeslaArc updateTeslaArc,
) where ) where
import Data.Foldable import Data.Foldable
import Dodge.Data.CrWlID
import Dodge.Data.ArcStep
import Data.Maybe import Data.Maybe
import Dodge.ArcStep import Dodge.ArcStep
import Dodge.Damage import Dodge.Damage
import Dodge.Data.ArcStep
import Dodge.Data.CrWlID
import Dodge.Data.World import Dodge.Data.World
import Dodge.Spark import Dodge.Spark
import Geometry import Geometry
@@ -26,11 +26,11 @@ aTeslaArcAt col thearc =
, _taColor = brightX 100 1.5 col , _taColor = brightX 100 1.5 col
} }
moveTeslaArc :: updateTeslaArc ::
World -> World ->
TeslaArc -> TeslaArc ->
(World, Maybe TeslaArc) (World, Maybe TeslaArc)
moveTeslaArc w pt updateTeslaArc w pt
| _taTimer pt == 2 = (makesparks $ foldl' (flip damthings) w thearc, Just $ pt & taTimer -~ 1) | _taTimer pt == 2 = (makesparks $ foldl' (flip damthings) w thearc, Just $ pt & taTimer -~ 1)
| _taTimer pt < 1 = (w, Nothing) | _taTimer pt < 1 = (w, Nothing)
| otherwise = (w, Just $ pt & taTimer -~ 1) | otherwise = (w, Just $ pt & taTimer -~ 1)
@@ -54,8 +54,8 @@ moveTeslaArc w pt
where where
q = 5 *.* unitVectorAtAngle dir q = 5 *.* unitVectorAtAngle dir
shootTeslaArc' :: ItemParams -> Point2 -> Float -> World -> (World, ItemParams) makeTeslaArc :: ItemParams -> Point2 -> Float -> World -> (World, ItemParams)
shootTeslaArc' ip pos dir w = makeTeslaArc ip pos dir w =
( w & randGen .~ g ( w & randGen .~ g
& cWorld . lWorld . teslaArcs .:~ aTeslaArcAt col newarc & cWorld . lWorld . teslaArcs .:~ aTeslaArcAt col newarc
, ip & currentArc ?~ newarc , ip & currentArc ?~ newarc
+21 -28
View File
@@ -65,7 +65,8 @@ import qualified IntMapHelp as IM
import LensHelp import LensHelp
import SDL import SDL
import Sound.Data import Sound.Data
import StrictHelp
--import StrictHelp
updateUniverse :: Universe -> Universe updateUniverse :: Universe -> Universe
updateUniverse u = updateUniverse u =
@@ -103,8 +104,8 @@ mouseClickOptionsList screen u = fromMaybe u $ do
mouseOverSelectionList :: ListDisplayParams -> SelectionList (Universe -> Universe) -> Universe -> Universe mouseOverSelectionList :: ListDisplayParams -> SelectionList (Universe -> Universe) -> Universe -> Universe
mouseOverSelectionList ldps sl u mouseOverSelectionList ldps sl u
| x > xl && x < xr | x > xl && x < xr
&& ylower == yupper && ylower == yupper
&& mmoving && mmoving
&& ylower >= 0 && ylower >= 0
&& ylower < ymax && ylower < ymax
@@ -179,6 +180,7 @@ updateUniverseLast =
{- For most menus the only way to change the world is using event handling. -} {- For most menus the only way to change the world is using event handling. -}
updateUniverseMid :: Universe -> Universe updateUniverseMid :: Universe -> Universe
updateUniverseMid u = case _uvScreenLayers u of updateUniverseMid u = case _uvScreenLayers u of
(OptionScreen{_scOptionFlag = LoadingScreen} : _) -> u
(OptionScreen{_scOptionFlag = GameOverOptions} : _) -> (OptionScreen{_scOptionFlag = GameOverOptions} : _) ->
u & uvWorld u & uvWorld
%~ ( %~ (
@@ -268,7 +270,6 @@ functionalUpdate w =
. over uvWorld updateFlames . over uvWorld updateFlames
. over uvWorld updateShockwaves . over uvWorld updateShockwaves
. over uvWorld updateEnergyBalls . over uvWorld updateEnergyBalls
-- . over uvWorld updateParticles
. over uvWorld updateBullets . over uvWorld updateBullets
. over uvWorld updateRadarBlips . over uvWorld updateRadarBlips
. over uvWorld updateFlares . over uvWorld updateFlares
@@ -298,7 +299,7 @@ functionalUpdate w =
. over uvWorld updateCloseObjects . over uvWorld updateCloseObjects
. over uvWorld updateWheelEvents . over uvWorld updateWheelEvents
-- . over uvWorld updateInventorySelectionList -- . over uvWorld updateInventorySelectionList
$ over uvWorld updatePastWorlds w $ over (uvWorld . cWorld) updatePastWorlds w
--updateInventorySelectionList :: World -> World --updateInventorySelectionList :: World -> World
--updateInventorySelectionList w = w --updateInventorySelectionList w = w
@@ -334,10 +335,9 @@ advanceScrollAmount u =
& uvWorld . input . previousScrollAmount .~ _scrollAmount (_input $ _uvWorld u) & uvWorld . input . previousScrollAmount .~ _scrollAmount (_input $ _uvWorld u)
& uvWorld . input . scrollAmount .~ 0 & uvWorld . input . scrollAmount .~ 0
updatePastWorlds :: World -> World updatePastWorlds :: CWorld -> CWorld
updatePastWorlds w = w & cWorld . pastWorlds %~ (forceFoldable . take 100 . ((w ^. cWorld . lWorld) :)) --updatePastWorlds w = w & pastWorlds %~ (forceFoldable . take 100 . ((w ^. lWorld) :))
updatePastWorlds w = w & pastWorlds .~ []
--updatePastWorlds w = w & cWorld . pastWorlds .~ []
moveHammersUp :: Universe -> Universe moveHammersUp :: Universe -> Universe
--moveHammersUp = uvWorld . hammers .~ M.empty --moveHammersUp = uvWorld . hammers .~ M.empty
@@ -494,52 +494,48 @@ updateObjCatMaybes p f w = w' & cWorld . lWorld . p #~ catMaybes newxs
updateDistortions :: World -> World updateDistortions :: World -> World
updateDistortions = updateObjMapMaybe distortions updateDistortion updateDistortions = updateObjMapMaybe distortions updateDistortion
--updateDistortions = cWorld . lWorld . distortions %~ mapMaybe updateDistortion
updateLightSources :: World -> World updateLightSources :: World -> World
updateLightSources = updateObjMapMaybe tempLightSources (\b -> updateTempLightSource (_tlsUpdate b) b) updateLightSources = updateObjMapMaybe tempLightSources (\b -> updateTempLightSource (_tlsUpdate b) b)
updateTeslaArcs :: World -> World
updateTeslaArcs = updateObjCatMaybes teslaArcs moveTeslaArc
updateRadarBlips :: World -> World updateRadarBlips :: World -> World
updateRadarBlips = updateObjMapMaybe radarBlips updateRadarBlip updateRadarBlips = updateObjMapMaybe radarBlips updateRadarBlip
updateFlares :: World -> World updateFlares :: World -> World
updateFlares = updateObjMapMaybe flares updateFlare updateFlares = updateObjMapMaybe flares updateFlare
updateTractorBeams :: World -> World
updateTractorBeams = updateObjCatMaybes tractorBeams updateTractorBeam
{- Apply internal particle updates, delete 'Nothing's. -} {- Apply internal particle updates, delete 'Nothing's. -}
updateBullets :: World -> World updateBullets :: World -> World
updateBullets w = updateInstantBullets $ set (cWorld . lWorld . bullets) (catMaybes ps) w' updateBullets w = updateInstantBullets $ set (cWorld . lWorld . bullets) (catMaybes ps) w'
where where
(w', ps) = mapAccumR updateBullet w $ w ^. cWorld . lWorld . bullets (w', ps) = mapAccumR updateBullet w $ w ^. cWorld . lWorld . bullets
updateTeslaArcs :: World -> World
updateTeslaArcs = updateObjCatMaybes teslaArcs updateTeslaArc
updateTractorBeams :: World -> World
updateTractorBeams = updateObjCatMaybes tractorBeams updateTractorBeam
updateShockwaves :: World -> World updateShockwaves :: World -> World
updateShockwaves = updateObjCatMaybes shockwaves updateShockwave updateShockwaves = updateObjCatMaybes shockwaves updateShockwave
updateFlames :: World -> World updateFlames :: World -> World
updateFlames = updateObjCatMaybes flames moveFlame updateFlames = updateObjCatMaybes flames updateFlame
updateEnergyBalls :: World -> World updateEnergyBalls :: World -> World
updateEnergyBalls = updateObjCatMaybes energyBalls moveEnergyBall updateEnergyBalls = updateObjCatMaybes energyBalls updateEnergyBall
updateRadarSweeps :: World -> World updateRadarSweeps :: World -> World
updateRadarSweeps = updateObjCatMaybes radarSweeps updateRadarSweep updateRadarSweeps = updateObjCatMaybes radarSweeps updateRadarSweep
updateSparks :: World -> World updateSparks :: World -> World
updateSparks = updateObjCatMaybes sparks moveSpark updateSparks = updateObjCatMaybes sparks updateSpark
updatePosEvents :: World -> World updatePosEvents :: World -> World
updatePosEvents = updateObjCatMaybes posEvents updatePosEvent updatePosEvents = updateObjCatMaybes posEvents updatePosEvent
{- Apply internal particle updates, delete 'Nothing's. -} updateClouds :: World -> World
--updateParticles :: World -> World updateClouds = updateObjCatMaybes clouds updateCloud
--updateParticles w = updateInstantParticles $ set particles (catMaybes ps) w'
-- where
-- (w',ps) = mapAccumR (\a b -> _ptUpdate b a b) w $ _particles w
updateBeams :: World -> World updateBeams :: World -> World
updateBeams w = updateBeams w =
w w
@@ -683,9 +679,6 @@ mvGust _ gu
& guPos .+.+~ _guVel gu & guPos .+.+~ _guVel gu
& guTime -~ 1 & guTime -~ 1
updateClouds :: World -> World
updateClouds = updateObjCatMaybes clouds updateCloud
cloudEffect :: Cloud -> World -> World cloudEffect :: Cloud -> World -> World
cloudEffect cl = case _clType cl of cloudEffect cl = case _clType cl of
GasCloud -> cloudPoisonDamage cl GasCloud -> cloudPoisonDamage cl