Work on saving/loading concurrently

This commit is contained in:
2022-08-18 10:05:24 +01:00
parent 26e88f059a
commit c74d3b04bf
20 changed files with 232 additions and 154 deletions
+6 -6
View File
@@ -38,7 +38,7 @@ import SDL
handleTextInput :: T.Text -> Universe -> Universe
handleTextInput text u =
u
& menuLayers . ix 0 . scInput %~ updateText
& uvScreenLayers . ix 0 . scInput %~ updateText
& updateTerminalText
where
updateTerminalText = case u ^? uvWorld . cWorld . hud . hudElement . subInventory of
@@ -85,12 +85,12 @@ handlePressedKey _ scode u = case scode of
ScancodeF5 -> return . Just $ doQuicksave u
ScancodeF9 -> return . Just $ loadSaveSlot QuicksaveSlot u
ScancodeSemicolon -> return . Just $ gotoTerminal u
_ | null (_menuLayers u) -> case u ^? uvWorld . cWorld . hud . hudElement . subInventory of
_ | null (_uvScreenLayers u) -> case u ^? uvWorld . cWorld . hud . hudElement . subInventory of
Just (DisplayTerminal tmid)
| inTermFocus (_uvWorld u) ->
return $ uvWorld (Just . handlePressedKeyTerminal tmid scode) u
_ -> return $ (Just . handlePressedKeyInGame scode) u
_ -> handlePressedKeyInMenu (head $ _menuLayers u) scode u
_ -> handlePressedKeyInMenu (head $ _uvScreenLayers u) scode u
handlePressedKeyInGame :: Scancode -> Universe -> Universe
handlePressedKeyInGame scode uv = case scode of
@@ -136,9 +136,9 @@ toggleInspectInv he = case he of
_ -> DisplayInventory InspectInventory
gotoTerminal :: Universe -> Universe
gotoTerminal w = case _menuLayers w of
gotoTerminal w = case _uvScreenLayers w of
(InputScreen{} : _) -> w
_ -> w & menuLayers .:~ InputScreen T.empty "Enter command"
_ -> w & uvScreenLayers .:~ InputScreen T.empty "Enter command"
spaceAction :: World -> World
spaceAction w = case _hudElement $ _hud (_cWorld w) of
@@ -155,7 +155,7 @@ spaceAction w = case _hudElement $ _hud (_cWorld w) of
-- updateTopCloseObject i w' = w' & closeObjects %~ ( Right (_buttons w' IM.! i) : ) . tail
pauseGame :: Universe -> Universe
pauseGame = menuLayers .~ [pauseMenu]
pauseGame = uvScreenLayers .~ [pauseMenu]
toggleMap :: World -> World
toggleMap w = case _hudElement $ _hud (_cWorld w) of
+4 -4
View File
@@ -15,14 +15,14 @@ handlePressedKeyInMenu :: ScreenLayer -> Scancode -> Universe -> IO (Maybe Unive
handlePressedKeyInMenu mState scode = case mState of
OptionScreen{_scOptions = mos, _scDefaultEff = defeff} ->
optionListToEffects defeff scode mos
DisplayScreen{} -> popScreen
--DisplayScreen{} -> popScreen
ColumnsScreen{} -> popScreen
WaitScreen{} -> return . Just
-- WaitScreen{} -> return . Just
InputScreen s help -> case scode of
ScancodeEscape -> popScreen
ScancodeReturn -> popScreen . applyTerminalString (words $ T.unpack s)
ScancodeTab -> autoCompleteTerminal (T.unpack s) help
ScancodeBackspace -> return . Just . (menuLayers . ix 0 . scInput %~ doBackspace)
ScancodeBackspace -> return . Just . (uvScreenLayers . ix 0 . scInput %~ doBackspace)
-- text input handled by handleTextInput
_ -> return . Just
where
@@ -39,7 +39,7 @@ optionListToEffects ::
optionListToEffects defaulteff sc mops u = case sc of
ScancodeSpace ->
return . Just
. (menuLayers . ix 0 . scOptionsOffset %~ (f . (+ mlines)))
. (uvScreenLayers . ix 0 . scOptionsOffset %~ (f . (+ mlines)))
$ u
_ ->
( fromMaybe defaulteff