Move saved worlds outside of world into universe
This commit is contained in:
@@ -62,6 +62,7 @@ firstWorldLoad theConfig = do
|
|||||||
& config .~ theConfig
|
& config .~ theConfig
|
||||||
,_preloadData = pdata
|
,_preloadData = pdata
|
||||||
,_menuLayers = []
|
,_menuLayers = []
|
||||||
|
,_savedWorlds = M.empty
|
||||||
}
|
}
|
||||||
|
|
||||||
theUpdateStep :: Universe -> IO Universe
|
theUpdateStep :: Universe -> IO Universe
|
||||||
|
|||||||
+2
-2
@@ -56,6 +56,7 @@ data Universe = Universe
|
|||||||
{ _uvWorld :: World
|
{ _uvWorld :: World
|
||||||
, _preloadData :: PreloadData
|
, _preloadData :: PreloadData
|
||||||
, _menuLayers :: [ScreenLayer]
|
, _menuLayers :: [ScreenLayer]
|
||||||
|
, _savedWorlds :: M.Map SaveSlot World
|
||||||
}
|
}
|
||||||
data World = World
|
data World = World
|
||||||
{ _keys :: !(S.Set Scancode)
|
{ _keys :: !(S.Set Scancode)
|
||||||
@@ -116,7 +117,6 @@ data World = World
|
|||||||
, _gameRooms :: [GameRoom] -- consider using and IntMap
|
, _gameRooms :: [GameRoom] -- consider using and IntMap
|
||||||
, _keyConfig :: KeyConfigSDL
|
, _keyConfig :: KeyConfigSDL
|
||||||
, _config :: Configuration
|
, _config :: Configuration
|
||||||
, _savedWorlds :: M.Map SaveSlot World
|
|
||||||
, _rewindWorlds :: [World]
|
, _rewindWorlds :: [World]
|
||||||
, _rewinding :: Bool
|
, _rewinding :: Bool
|
||||||
, _frameClock :: Int
|
, _frameClock :: Int
|
||||||
@@ -131,7 +131,7 @@ data ScreenLayer
|
|||||||
= OptionScreen
|
= OptionScreen
|
||||||
{ _scTitle :: Universe -> String
|
{ _scTitle :: Universe -> String
|
||||||
, _scOptions :: [MenuOption]
|
, _scOptions :: [MenuOption]
|
||||||
, _scDefaultEff :: Universe -> Maybe Universe
|
, _scDefaultEff :: Universe -> Maybe Universe -- IO (Maybe Universe)?
|
||||||
, _scOptionFlag :: OptionScreenFlag
|
, _scOptionFlag :: OptionScreenFlag
|
||||||
}
|
}
|
||||||
| ColumnsScreen String [(String,String)]
|
| ColumnsScreen String [(String,String)]
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ defaultWorld = World
|
|||||||
, _playingSounds = M.empty
|
, _playingSounds = M.empty
|
||||||
, _corpses = Zone IM.empty
|
, _corpses = Zone IM.empty
|
||||||
, _decorations = IM.empty
|
, _decorations = IM.empty
|
||||||
, _savedWorlds = M.empty
|
--, _savedWorlds = M.empty
|
||||||
-- , _menuLayers = []
|
-- , _menuLayers = []
|
||||||
, _worldFlags = S.empty
|
, _worldFlags = S.empty
|
||||||
, _clickMousePos = V2 0 0
|
, _clickMousePos = V2 0 0
|
||||||
|
|||||||
@@ -33,8 +33,8 @@ handleKeyboardEvent kev u = case keyboardEventKeyMotion kev of
|
|||||||
|
|
||||||
handlePressedKey :: Bool -> Scancode -> Universe -> Maybe Universe
|
handlePressedKey :: Bool -> Scancode -> Universe -> Maybe Universe
|
||||||
handlePressedKey True _ w = Just w
|
handlePressedKey True _ w = Just w
|
||||||
handlePressedKey _ ScancodeF5 w = Just $ over uvWorld doQuicksave w
|
handlePressedKey _ ScancodeF5 w = Just $ doQuicksave w
|
||||||
handlePressedKey _ ScancodeF9 w = Just $ over uvWorld (loadSaveSlot QuicksaveSlot) w
|
handlePressedKey _ ScancodeF9 w = Just $ loadSaveSlot QuicksaveSlot w
|
||||||
handlePressedKey _ ScancodeSemicolon w = Just $ gotoTerminal w
|
handlePressedKey _ ScancodeSemicolon w = Just $ gotoTerminal w
|
||||||
handlePressedKey _ scode w
|
handlePressedKey _ scode w
|
||||||
| null (_menuLayers w) = uvWorld (handlePressedKeyInGame scode) w
|
| null (_menuLayers w) = uvWorld (handlePressedKeyInGame scode) w
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import Dodge.Default.World
|
|||||||
import Dodge.Save
|
import Dodge.Save
|
||||||
import Dodge.Data
|
import Dodge.Data
|
||||||
import Dodge.Creature
|
import Dodge.Creature
|
||||||
import Dodge.Story
|
--import Dodge.Story
|
||||||
import Dodge.WorldEvent.Cloud
|
import Dodge.WorldEvent.Cloud
|
||||||
import Dodge.SoundLogic
|
import Dodge.SoundLogic
|
||||||
import Geometry.Data
|
import Geometry.Data
|
||||||
@@ -27,8 +27,8 @@ initialWorld = defaultWorld
|
|||||||
, _mousePos = V2 0 0
|
, _mousePos = V2 0 0
|
||||||
, _testString = testStringInit
|
, _testString = testStringInit
|
||||||
, _yourID = 0
|
, _yourID = 0
|
||||||
, _worldEvents = saveWorldInEmptySlot LevelStartSlot
|
, _sideEffects = return .saveWorldInEmptySlot LevelStartSlot
|
||||||
. soundStart BackgroundSound (V2 0 0) foamSprayFadeOutS Nothing
|
, _worldEvents = soundStart BackgroundSound (V2 0 0) foamSprayFadeOutS Nothing
|
||||||
. foldr ((.) . makeStartCloudAt) id [V3 x y 5 | x <- [-5,-4..5] , y <- [-5,-4..5]]
|
. foldr ((.) . makeStartCloudAt) id [V3 x y 5 | x <- [-5,-4..5] , y <- [-5,-4..5]]
|
||||||
, _pressPlates = IM.empty
|
, _pressPlates = IM.empty
|
||||||
, _buttons = IM.empty
|
, _buttons = IM.empty
|
||||||
|
|||||||
+1
-1
@@ -152,7 +152,7 @@ pauseMenu = OptionScreen
|
|||||||
pauseMenuOptions :: [MenuOption]
|
pauseMenuOptions :: [MenuOption]
|
||||||
pauseMenuOptions =
|
pauseMenuOptions =
|
||||||
[ Toggle ScancodeN startNewGame (const "NEW LEVEL")
|
[ Toggle ScancodeN startNewGame (const "NEW LEVEL")
|
||||||
, Toggle ScancodeR (uvWorld (Just . loadSaveSlot LevelStartSlot)) (const "RESTART")
|
, Toggle ScancodeR (Just . loadSaveSlot LevelStartSlot) (const "RESTART")
|
||||||
, Toggle ScancodeO (pushScreen optionMenu ) (const "OPTIONS")
|
, Toggle ScancodeO (pushScreen optionMenu ) (const "OPTIONS")
|
||||||
, Toggle ScancodeC (pushScreen displayControls) (const "CONTROLS")
|
, Toggle ScancodeC (pushScreen displayControls) (const "CONTROLS")
|
||||||
, InvisibleToggle ScancodeEscape (const Nothing)
|
, InvisibleToggle ScancodeEscape (const Nothing)
|
||||||
|
|||||||
+8
-10
@@ -11,23 +11,21 @@ import Data.Maybe
|
|||||||
import Control.Lens
|
import Control.Lens
|
||||||
import qualified Data.Set as S
|
import qualified Data.Set as S
|
||||||
|
|
||||||
clearSaves :: World -> World
|
clearSaves :: Universe -> Universe
|
||||||
clearSaves = savedWorlds .~ M.empty
|
clearSaves = savedWorlds .~ M.empty
|
||||||
|
|
||||||
saveWorldInEmptySlot :: SaveSlot -> World -> World
|
saveWorldInEmptySlot :: SaveSlot -> Universe -> Universe
|
||||||
saveWorldInEmptySlot slot w = case M.lookup slot $ _savedWorlds w of
|
saveWorldInEmptySlot slot w = case M.lookup slot $ _savedWorlds w of
|
||||||
Nothing -> w & savedWorlds %~ M.insert slot (clearKeys w)
|
Nothing -> w & savedWorlds %~ M.insert slot (clearKeys (_uvWorld w))
|
||||||
_ -> w
|
_ -> w
|
||||||
|
|
||||||
saveWorldInSlot :: SaveSlot -> World -> World
|
saveWorldInSlot :: SaveSlot -> Universe -> Universe
|
||||||
saveWorldInSlot slot w = w & savedWorlds %~ M.insert slot (clearSaves $ clearKeys w)
|
saveWorldInSlot slot w = w & savedWorlds %~ M.insert slot (clearKeys (_uvWorld w))
|
||||||
|
|
||||||
loadSaveSlot :: SaveSlot -> World -> World
|
loadSaveSlot :: SaveSlot -> Universe -> Universe
|
||||||
loadSaveSlot slot w = fromMaybe w
|
loadSaveSlot slot u = maybe u (\w -> u & uvWorld .~ w) $ M.lookup slot (_savedWorlds u)
|
||||||
$ M.lookup slot (_savedWorlds w)
|
|
||||||
<&> savedWorlds .~ _savedWorlds w -- keep saves from current point, not from save point
|
|
||||||
|
|
||||||
doQuicksave :: World -> World
|
doQuicksave :: Universe -> Universe
|
||||||
doQuicksave = saveWorldInSlot QuicksaveSlot
|
doQuicksave = saveWorldInSlot QuicksaveSlot
|
||||||
|
|
||||||
clearKeys :: World -> World
|
clearKeys :: World -> World
|
||||||
|
|||||||
+1
-1
@@ -11,7 +11,7 @@ import Dodge.Hammer
|
|||||||
import Dodge.Block
|
import Dodge.Block
|
||||||
import Dodge.Distortion
|
import Dodge.Distortion
|
||||||
import Dodge.SoundLogic
|
import Dodge.SoundLogic
|
||||||
import Dodge.Menu
|
--import Dodge.Menu
|
||||||
import Dodge.Base
|
import Dodge.Base
|
||||||
import Dodge.Zone
|
import Dodge.Zone
|
||||||
import Dodge.WallCreatureCollisions
|
import Dodge.WallCreatureCollisions
|
||||||
|
|||||||
Reference in New Issue
Block a user