Add in "linear" lWorld to separate time reversable worlds
This commit is contained in:
+22
-22
@@ -27,7 +27,6 @@ import Dodge.Reloading
|
||||
import Dodge.Save
|
||||
import Dodge.Terminal.LeftButton
|
||||
import Dodge.WorldPos
|
||||
import qualified IntMapHelp as IM
|
||||
import LensHelp
|
||||
import SDL
|
||||
|
||||
@@ -41,18 +40,18 @@ handleTextInput text u =
|
||||
& uvScreenLayers . ix 0 . scInput %~ updateText
|
||||
& updateTerminalText
|
||||
where
|
||||
updateTerminalText = case u ^? uvWorld . cWorld . hud . hudElement . subInventory of
|
||||
updateTerminalText = case u ^? uvWorld . cWorld . lWorld . hud . hudElement . subInventory of
|
||||
Just (DisplayTerminal tmid)
|
||||
| hasfocus tmid ->
|
||||
uvWorld %~ \w -> guardDisconnectedID tmid w (w & cWorld . terminals . ix tmid . tmInput . tiText %~ updateText)
|
||||
uvWorld %~ \w -> guardDisconnectedID tmid w (w & cWorld . lWorld . terminals . ix tmid . tmInput . tiText %~ updateText)
|
||||
_ -> id
|
||||
hasfocus tmid = fromMaybe False $ u ^? uvWorld . cWorld . terminals . ix tmid . tmInput . tiFocus
|
||||
hasfocus tmid = fromMaybe False $ u ^? uvWorld . cWorld . lWorld . terminals . ix tmid . tmInput . tiFocus
|
||||
updateText s = case T.unpack text of
|
||||
";" -> s
|
||||
_ -> s `T.append` T.toUpper text
|
||||
|
||||
guardDisconnectedID :: Int -> World -> World -> World
|
||||
guardDisconnectedID tmid w w' = case w ^? cWorld . terminals . ix tmid . tmStatus of
|
||||
guardDisconnectedID tmid w w' = case w ^? cWorld . lWorld . terminals . ix tmid . tmStatus of
|
||||
Just TerminalReady -> w'
|
||||
_ -> w
|
||||
|
||||
@@ -85,7 +84,7 @@ handlePressedKey _ scode u = case scode of
|
||||
ScancodeF5 -> return . Just $ doQuicksave u
|
||||
ScancodeF9 -> return . Just $ loadSaveSlot QuicksaveSlot u
|
||||
ScancodeSemicolon -> return . Just $ gotoTerminal u
|
||||
_ | null (_uvScreenLayers u) -> case u ^? uvWorld . cWorld . hud . hudElement . subInventory of
|
||||
_ | null (_uvScreenLayers u) -> case u ^? uvWorld . cWorld . lWorld . hud . hudElement . subInventory of
|
||||
Just (DisplayTerminal tmid)
|
||||
| inTermFocus (_uvWorld u) ->
|
||||
return $ uvWorld (Just . handlePressedKeyTerminal tmid scode) u
|
||||
@@ -103,18 +102,18 @@ handlePressedKeyInGame scode uv = case scode of
|
||||
ScancodeT -> over uvWorld testEvent uv
|
||||
ScancodeX -> uv & uvWorld %~ toggleTweakInv
|
||||
ScancodeC -> over uvWorld toggleCombineInv uv
|
||||
ScancodeI -> uv & uvWorld . cWorld . hud . hudElement %~ toggleInspectInv
|
||||
ScancodeI -> uv & uvWorld . cWorld . lWorld . hud . hudElement %~ toggleInspectInv
|
||||
_ -> uv
|
||||
where
|
||||
w = _uvWorld uv
|
||||
|
||||
handlePressedKeyTerminal :: Int -> Scancode -> World -> World
|
||||
handlePressedKeyTerminal tmid scode w = case scode of
|
||||
ScancodeEscape -> w & cWorld . terminals . ix tmid . tmInput . tiFocus %~ const False
|
||||
ScancodeReturn -> w & terminalReturnEffect (w ^?! cWorld . terminals . ix tmid)
|
||||
ScancodeEscape -> w & cWorld . lWorld . terminals . ix tmid . tmInput . tiFocus %~ const False
|
||||
ScancodeReturn -> w & terminalReturnEffect (w ^?! cWorld . lWorld . terminals . ix tmid)
|
||||
ScancodeBackspace ->
|
||||
w
|
||||
& cWorld . terminals . ix tmid . tmInput . tiText %~ doBackspace
|
||||
& cWorld . lWorld . terminals . ix tmid . tmInput . tiText %~ doBackspace
|
||||
& backspaceTimer .~ 5
|
||||
_ -> w
|
||||
where
|
||||
@@ -123,11 +122,11 @@ handlePressedKeyTerminal tmid scode w = case scode of
|
||||
Just (t', _) -> t'
|
||||
|
||||
toggleTweakInv :: World -> World
|
||||
toggleTweakInv w = case w ^. cWorld . hud . hudElement of
|
||||
toggleTweakInv w = case w ^. cWorld . lWorld . hud . hudElement of
|
||||
DisplayInventory TweakInventory{} -> w & thepointer .~ DisplayInventory NoSubInventory
|
||||
_ -> w & thepointer .~ DisplayInventory (TweakInventory mi)
|
||||
where
|
||||
thepointer = cWorld . hud . hudElement
|
||||
thepointer = cWorld . lWorld . hud . hudElement
|
||||
mi = 0 <$ (yourItem w >>= (^? itTweaks . tweakParams . ix 0))
|
||||
|
||||
toggleInspectInv :: HUDElement -> HUDElement
|
||||
@@ -141,16 +140,17 @@ gotoTerminal w = case _uvScreenLayers w of
|
||||
_ -> w & uvScreenLayers .:~ InputScreen T.empty "Enter command"
|
||||
|
||||
spaceAction :: World -> World
|
||||
spaceAction w = case _hudElement $ _hud (_cWorld w) of
|
||||
DisplayCarte -> w & cWorld . hud . carteCenter .~ theLoc
|
||||
spaceAction w = case w ^?! cWorld . lWorld . hud . hudElement of
|
||||
DisplayCarte -> w & cWorld . lWorld . hud . carteCenter .~ theLoc
|
||||
DisplayInventory NoSubInventory -> case selectedCloseObject w of
|
||||
Just (_, Left flit) -> pickUpItem 0 flit w
|
||||
Just (_, Right but) -> doButtonEvent (_btEvent but) but w
|
||||
_ -> w
|
||||
DisplayInventory DisplayTerminal{} -> w & cWorld . hud . hudElement .~ DisplayInventory NoSubInventory
|
||||
_ -> w & cWorld . hud . hudElement .~ DisplayInventory NoSubInventory
|
||||
DisplayInventory DisplayTerminal{} -> w & cWorld . lWorld . hud . hudElement .~ DisplayInventory NoSubInventory
|
||||
_ -> w & cWorld . lWorld . hud . hudElement .~ DisplayInventory NoSubInventory
|
||||
where
|
||||
theLoc = doWorldPos (fst (_seenLocations (_cWorld w) IM.! _selLocation (_cWorld w))) w
|
||||
--theLoc = doWorldPos (fst (_seenLocations (_cWorld w) IM.! _selLocation (_cWorld w))) w
|
||||
theLoc = doWorldPos (w ^?! cWorld . lWorld . seenLocations . ix (w ^. cWorld . lWorld . selLocation) . _1) w
|
||||
|
||||
-- updateTopCloseObject i w' = w' & closeObjects %~ ( Right (_buttons w' IM.! i) : ) . tail
|
||||
|
||||
@@ -158,11 +158,11 @@ pauseGame :: Universe -> Universe
|
||||
pauseGame = uvScreenLayers .~ [pauseMenu]
|
||||
|
||||
toggleMap :: World -> World
|
||||
toggleMap w = case _hudElement $ _hud (_cWorld w) of
|
||||
DisplayCarte -> w & cWorld . hud . hudElement .~ DisplayInventory NoSubInventory
|
||||
_ -> w & cWorld . hud . hudElement .~ DisplayCarte
|
||||
toggleMap w = case w ^?! cWorld . lWorld . hud . hudElement of
|
||||
DisplayCarte -> w & cWorld . lWorld . hud . hudElement .~ DisplayInventory NoSubInventory
|
||||
_ -> w & cWorld . lWorld . hud . hudElement .~ DisplayCarte
|
||||
|
||||
escapeMap :: World -> World
|
||||
escapeMap w = case _hudElement $ _hud (_cWorld w) of
|
||||
DisplayCarte -> w & cWorld . hud . hudElement .~ DisplayInventory NoSubInventory
|
||||
escapeMap w = case w ^?! cWorld . lWorld . hud . hudElement of
|
||||
DisplayCarte -> w & cWorld . lWorld . hud . hudElement .~ DisplayInventory NoSubInventory
|
||||
_ -> w
|
||||
|
||||
Reference in New Issue
Block a user