Push preloaddata into the universe
This commit is contained in:
+1
-1
@@ -54,6 +54,7 @@ import Data.Monoid
|
||||
type CRUpdate = Creature -> World -> (Endo World, Maybe Creature)
|
||||
data Universe = Universe
|
||||
{ _uvWorld :: World
|
||||
, _preloadData :: PreloadData
|
||||
}
|
||||
data World = World
|
||||
{ _keys :: !(S.Set Scancode)
|
||||
@@ -115,7 +116,6 @@ data World = World
|
||||
, _gameRooms :: [GameRoom] -- consider using and IntMap
|
||||
, _keyConfig :: KeyConfigSDL
|
||||
, _config :: Configuration
|
||||
, _preloadData :: PreloadData
|
||||
, _savedWorlds :: M.Map SaveSlot World
|
||||
, _rewindWorlds :: [World]
|
||||
, _rewinding :: Bool
|
||||
|
||||
@@ -8,7 +8,7 @@ import Dodge.Bounds
|
||||
--import Picture
|
||||
import Geometry.Data
|
||||
--import Picture.Texture
|
||||
import Data.Preload
|
||||
--import Data.Preload
|
||||
|
||||
import System.Random
|
||||
import qualified Data.IntMap.Strict as IM
|
||||
@@ -80,7 +80,7 @@ defaultWorld = World
|
||||
, _foregroundShape = mempty
|
||||
, _distortions = []
|
||||
, _gameRooms = []
|
||||
, _preloadData = DummyPdata -- hack TODO remove this
|
||||
-- , _preloadData = DummyPdata -- hack TODO remove this
|
||||
, _frameClock = 0
|
||||
, _worldBounds = defaultBounds
|
||||
, _rewindWorlds = []
|
||||
|
||||
+9
-7
@@ -7,11 +7,12 @@ module Dodge.Menu
|
||||
)
|
||||
where
|
||||
import Dodge.Data
|
||||
import Dodge.PreloadData
|
||||
import Dodge.Save
|
||||
import Dodge.Config.Update
|
||||
import SDL
|
||||
import SDL.Internal.Numbered
|
||||
import Preload.Update
|
||||
--import Preload.Update
|
||||
import Dodge.Base.Window
|
||||
import Dodge.SoundLogic
|
||||
import Dodge.LevelGen
|
||||
@@ -165,7 +166,8 @@ startNewGame w = Just $ w
|
||||
|
||||
uvWorldSideEffects :: Int -> World -> b -> IO World
|
||||
uvWorldSideEffects i w = const (generateWorldFromSeed i <&> keyConfig .~ _keyConfig w <&> config .~ _config w
|
||||
<&> preloadData .~ _preloadData w)
|
||||
-- <&> preloadData .~ _preloadData w
|
||||
)
|
||||
-- this kills save games etc...
|
||||
|
||||
|
||||
@@ -177,14 +179,14 @@ scodeToChar = toEnum . (+ 61) . fromIntegral . toNumber
|
||||
--charToScode = Scancode . fromIntegral . (\x -> x - 61) . fromEnum
|
||||
|
||||
updateFramebufferSize :: World -> World
|
||||
updateFramebufferSize w = w & sideEffects %~ up
|
||||
updateFramebufferSize w = w & sideEffects %~ sideEffectUpdatePreload divRes x y
|
||||
where
|
||||
(x,y) = (round $ getWindowX w, round $ getWindowY w)
|
||||
divRes = w ^. config . resolution_factor
|
||||
up :: (Universe -> IO Universe) -> Universe -> IO Universe
|
||||
up f w' = do
|
||||
pdata <- pdataResizeUpdate (x `div` divRes) (y `div` divRes) x y (_preloadData (_uvWorld w'))
|
||||
f $ w' & uvWorld . preloadData .~ pdata
|
||||
-- up :: (Universe -> IO Universe) -> Universe -> IO Universe
|
||||
-- up f w' = do
|
||||
-- pdata <- pdataResizeUpdate (x `div` divRes) (y `div` divRes) x y (_preloadData w')
|
||||
-- f $ w' & uvWorld . preloadData .~ pdata
|
||||
|
||||
--levelMenu :: Int -> ScreenLayer
|
||||
--levelMenu x = OptionScreen
|
||||
|
||||
@@ -13,5 +13,5 @@ import Control.Lens
|
||||
|
||||
sideEffectUpdatePreload :: Int -> Int -> Int -> (Universe -> IO Universe) -> Universe -> IO Universe
|
||||
sideEffectUpdatePreload divRes x y f u = do
|
||||
pdata <- pdataResizeUpdate (x `div` divRes) (y `div` divRes) x y (_preloadData (_uvWorld u))
|
||||
f $ u & uvWorld . preloadData .~ pdata
|
||||
pdata <- pdataResizeUpdate (x `div` divRes) (y `div` divRes) x y (_preloadData u)
|
||||
f $ u & preloadData .~ pdata
|
||||
|
||||
Reference in New Issue
Block a user