change subscriber function and close window on request

This commit is contained in:
nek0 2021-01-11 17:06:29 +01:00
parent 43f5649ce5
commit 1e71b63f67

View file

@ -58,9 +58,9 @@ main = do
preLoad :: GameData -> Affection ()
preLoad gd = do
void $ generalSubscribe
((\(SubKeyboard t) -> t) $ subKeyboard $ gameSubsystems gd)
(\(MsgKeyboardEvent when win motion False keysym) -> do
void $ partSubscribe
(subKeyboard $ gameSubsystems gd)
(\(MsgKeyboardEvent time win motion False keysym) -> do
translator <- liftIO $ atomically $ readTVar (gameActionTranslation gd)
case
((SDL.keysymScancode keysym, SDL.keysymModifier keysym) `M.lookup`
@ -69,10 +69,15 @@ preLoad gd = do
Just action ->
partEmit
(subTranslator $ gameSubsystems gd)
(TranslatorMessage action when motion)
(TranslatorMessage action time motion)
Nothing ->
return ()
)
void $ partSubscribe
(subWindow $ gameSubsystems gd)
(\(MsgWindowClose time win) ->
atomically $ writeTVar (gameRunning gd) False
)
handle :: GameData -> [SDL.EventPayload] -> Affection ()
handle gd evs = do