bump module Load to affection 0.0.0.10
This commit is contained in:
parent
eea0ec07fd
commit
a33fec68d4
1 changed files with 31 additions and 37 deletions
64
src/Load.hs
64
src/Load.hs
|
@ -7,7 +7,7 @@ import Graphics.Rendering.OpenGL.GL.FlushFinish (finish)
|
||||||
|
|
||||||
import Control.Concurrent (forkIO)
|
import Control.Concurrent (forkIO)
|
||||||
import Control.Concurrent.MVar
|
import Control.Concurrent.MVar
|
||||||
import Control.Monad (when)
|
import Control.Monad
|
||||||
|
|
||||||
import qualified Data.Map as M
|
import qualified Data.Map as M
|
||||||
import qualified Data.Text as T
|
import qualified Data.Text as T
|
||||||
|
@ -25,39 +25,39 @@ import Menu.Connect
|
||||||
import Types
|
import Types
|
||||||
import Util
|
import Util
|
||||||
|
|
||||||
loadLoad :: Affection UserData ()
|
loadLoad :: UserData -> Affection ()
|
||||||
loadLoad = do
|
loadLoad ud = do
|
||||||
ad <- A.get
|
ad <- A.get
|
||||||
ud <- getAffection
|
wState <- liftIO $ readMVar (worldState ud)
|
||||||
progress <- liftIO $ newMVar (0, "Starting up")
|
curWin <- liftIO $ readMVar (window ud)
|
||||||
future <- liftIO newEmptyMVar
|
tContext <- liftIO $ readMVar (threadContext ud)
|
||||||
|
let progress = (0, "Starting up")
|
||||||
|
void $ liftIO $ swapMVar (stateProgress ud) progress
|
||||||
|
void $ liftIO $ tryReadMVar (stateMVar ud)
|
||||||
_ <- liftIO $ createFont (nano ud) "bedstead"
|
_ <- liftIO $ createFont (nano ud) "bedstead"
|
||||||
(FileName "assets/font/Bedstead-Semicondensed.ttf")
|
(FileName "assets/font/Bedstead-Semicondensed.ttf")
|
||||||
_ <- liftIO $ forkIO $
|
_ <- liftIO $ forkIO $
|
||||||
loadFork
|
loadFork
|
||||||
(worldState ud)
|
wState
|
||||||
(fromJust $ window ud)
|
(fromJust curWin)
|
||||||
(fromJust $ threadContext ud)
|
(fromJust tContext)
|
||||||
(nano ud)
|
(nano ud)
|
||||||
future
|
(stateMVar ud)
|
||||||
progress
|
(stateProgress ud)
|
||||||
SDL.glMakeCurrent (fromJust $ window ud) (snd $ head $ glContext ad)
|
SDL.glMakeCurrent (fromJust curWin) (snd $ head $ glContext ad)
|
||||||
putAffection ud
|
void $ liftIO $ swapMVar (state ud) Load
|
||||||
{ stateMVar = future
|
void $ liftIO $ swapMVar (assetFonts ud) (M.fromList
|
||||||
, stateProgress = progress
|
|
||||||
, state = Load
|
|
||||||
, assetFonts = M.fromList
|
|
||||||
[ (FontBedstead, "bedstead")
|
[ (FontBedstead, "bedstead")
|
||||||
]
|
]
|
||||||
}
|
)
|
||||||
|
|
||||||
loadFork
|
loadFork
|
||||||
:: SystemState Entity (AffectionState (AffectionData UserData) IO)
|
:: SystemState Entity (AffectionState (AffectionData) IO)
|
||||||
-> SDL.Window
|
-> SDL.Window
|
||||||
-> SDL.GLContext
|
-> SDL.GLContext
|
||||||
-> Context
|
-> Context
|
||||||
-> MVar
|
-> MVar
|
||||||
( SystemState Entity (AffectionState (AffectionData UserData) IO)
|
( SystemState Entity (AffectionState (AffectionData) IO)
|
||||||
, StateData
|
, StateData
|
||||||
)
|
)
|
||||||
-> MVar (Float, T.Text)
|
-> MVar (Float, T.Text)
|
||||||
|
@ -525,30 +525,24 @@ loadFork ws win glc nvg future progress = do
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
drawLoad :: Affection UserData ()
|
drawLoad :: UserData -> Affection ()
|
||||||
drawLoad = do
|
drawLoad ud = do
|
||||||
ud <- getAffection
|
|
||||||
progress <- liftIO $ readMVar (stateProgress ud)
|
progress <- liftIO $ readMVar (stateProgress ud)
|
||||||
liftIO $ do
|
liftIO $ do
|
||||||
logIO A.Verbose ("LoadProgress: " <> fromString (show progress))
|
logIO A.Verbose ("LoadProgress: " <> fromString (show progress))
|
||||||
drawLoadScreen ud progress
|
drawLoadScreen ud progress
|
||||||
|
|
||||||
updateLoad :: Double -> Affection UserData ()
|
updateLoad :: UserData -> Double -> Affection ()
|
||||||
updateLoad _ = do
|
updateLoad ud _ = do
|
||||||
ud <- getAffection
|
|
||||||
mwsld <- liftIO $ tryTakeMVar (stateMVar ud)
|
mwsld <- liftIO $ tryTakeMVar (stateMVar ud)
|
||||||
case mwsld of
|
case mwsld of
|
||||||
Just (_, ld) -> do
|
Just (_, ld) -> do
|
||||||
liftIO $ logIO A.Debug "loaded assets, entering menu"
|
liftIO $ logIO A.Debug "loaded assets, entering menu"
|
||||||
putAffection ud
|
void $ liftIO $ swapMVar (assetImages ud) (loadAssetImages ld)
|
||||||
{ assetImages = loadAssetImages ld
|
void $ liftIO $ swapMVar (assetAnimations ud) (loadAssetAnims ld)
|
||||||
, assetAnimations = loadAssetAnims ld
|
void $ liftIO $ swapMVar (assetIcons ud) (loadAssetIcons ld)
|
||||||
, assetIcons = loadAssetIcons ld
|
void $ liftIO $ swapMVar (stateData ud) None
|
||||||
-- , state = Main WorldMap
|
|
||||||
-- , state = Menu Connect
|
|
||||||
, stateData = None
|
|
||||||
}
|
|
||||||
-- loadMap
|
-- loadMap
|
||||||
loadMenu
|
loadMenu ud
|
||||||
Nothing ->
|
Nothing ->
|
||||||
return ()
|
return ()
|
||||||
|
|
Loading…
Reference in a new issue