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
+8 -2
View File
@@ -3,9 +3,10 @@ module Dodge.StartNewGame (
startSeedGame,
) where
import Dodge.Menu.Loading
import Dodge.Concurrent
--import Dodge.Menu.Option
import Control.Lens
import LensHelp
import Dodge.Data.Universe
import Dodge.LevelGen
import Dodge.Save
@@ -16,8 +17,13 @@ startNewGameInSlot slot u = startSeedGame slot i u
where
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 _ i = addSideEffect (startSeedGameConc i) "GENERATING"
startSeedGame _ i = blockingLoad "LOADING" (startSeedGameConc i)
startSeedGameConc :: Int -> IO (Universe -> Maybe Universe)
startSeedGameConc seed = do