Move menu layers outside of world

This commit is contained in:
2021-11-28 14:26:15 +00:00
parent 574f195b21
commit 462100703c
13 changed files with 132 additions and 124 deletions
+6 -6
View File
@@ -35,15 +35,15 @@ 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 _ ScancodeSemicolon w = Just $ over uvWorld gotoTerminal w
handlePressedKey _ ScancodeSemicolon w = Just $ gotoTerminal w
handlePressedKey _ scode w
| null (_menuLayers (_uvWorld w)) = uvWorld (handlePressedKeyInGame scode) w
| otherwise = handlePressedKeyInMenu (head $ _menuLayers (_uvWorld w)) scode w
| null (_menuLayers w) = uvWorld (handlePressedKeyInGame scode) w
| otherwise = handlePressedKeyInMenu (head $ _menuLayers w) scode w
handlePressedKeyInGame :: Scancode -> World -> Maybe World
handlePressedKeyInGame scode w
| scode == escapeKey (_keyConfig w) = Nothing
| scode == pauseKey (_keyConfig w) = Just $ pauseGame $ escapeMap w
-- | scode == pauseKey (_keyConfig w) = Just $ pauseGame $ escapeMap w
| scode == dropItemKey (_keyConfig w) = Just $ youDropItem w
| scode == toggleMapKey (_keyConfig w) = Just $ toggleMap w
| scode == reloadKey (_keyConfig w) = Just $ fromMaybe w $ startReloadingWeapon (you w) w
@@ -61,7 +61,7 @@ toggleInv x y
| x == y = TopInventory
| otherwise = x
gotoTerminal :: World -> World
gotoTerminal :: Universe -> Universe
gotoTerminal w = case _menuLayers w of
(InputScreen _ : _ ) -> w
_ -> w & menuLayers %~ (InputScreen [] :)
@@ -77,7 +77,7 @@ spaceAction w = if _carteDisplay w
theLoc = fst (_seenLocations w IM.! _selLocation w) w
updateTopCloseObject i w' = w' & closeObjects %~ ( Right (_buttons w' IM.! i) : ) . tail
pauseGame :: World -> World
pauseGame :: Universe -> Universe
pauseGame w = w {_menuLayers = [pauseMenu]}
toggleMap :: World -> World