Cleanup
This commit is contained in:
+16
-17
@@ -1,30 +1,28 @@
|
||||
module Dodge.Concurrent
|
||||
( hardQuit
|
||||
, addSideEffect
|
||||
, conEffects
|
||||
, blockingLoad
|
||||
) where
|
||||
module Dodge.Concurrent (
|
||||
hardQuit,
|
||||
addSideEffect,
|
||||
conEffects,
|
||||
blockingLoad,
|
||||
) where
|
||||
|
||||
--import qualified Data.Set as S
|
||||
import Data.Sequence (Seq (..))
|
||||
import Dodge.Data.Universe
|
||||
import Dodge.Menu.Loading
|
||||
import LensHelp
|
||||
import Dodge.Data.Universe
|
||||
import Data.Sequence (Seq (..))
|
||||
|
||||
--import Control.Concurrent
|
||||
--import SDL.Input.Keyboard.Codes
|
||||
|
||||
conEffects :: Universe -> ConcurrentEffect Universe
|
||||
conEffects u = case u ^? uvSideEffects . _head of
|
||||
Just NewSideEffect{_ceSideEffect = eff} -> ConcurrentEffect (u & uvSideEffects . _head %~ g)
|
||||
(dopop eff)
|
||||
Just NewSideEffect{_ceSideEffect = eff} ->
|
||||
ConcurrentEffect
|
||||
(u & uvSideEffects . _head %~ g)
|
||||
(dopop eff)
|
||||
Just HardQuit -> ImmediateEffect (return Nothing)
|
||||
_ -> NoConcurrentEffect
|
||||
where
|
||||
g seff = RunningSideEffect (_ceString seff)
|
||||
dopop :: IO (Universe -> Maybe Universe) -> IO (Universe -> Maybe Universe)
|
||||
dopop mf = do
|
||||
f <- mf
|
||||
f <- mf
|
||||
return $ f . (uvSideEffects %~ taker)
|
||||
taker (_ :<| xs) = xs
|
||||
taker _ = mempty
|
||||
@@ -36,8 +34,9 @@ hardQuit :: Universe -> Universe
|
||||
hardQuit = uvSideEffects %~ (HardQuit <|)
|
||||
|
||||
blockingLoad :: String -> IO (Universe -> Maybe Universe) -> Universe -> Universe
|
||||
blockingLoad str f u = u & uvScreenLayers .:~ loadingScreen str
|
||||
& addSideEffect f str
|
||||
blockingLoad str f u =
|
||||
u & uvScreenLayers .:~ loadingScreen str
|
||||
& addSideEffect f str
|
||||
|
||||
--hardQuit = addSideEffect (return $ const Nothing) "QUITTING"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user