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