From 1e71b63f67daa05184dfaacb79d68122446d37b4 Mon Sep 17 00:00:00 2001 From: nek0 Date: Mon, 11 Jan 2021 17:06:29 +0100 Subject: [PATCH] change subscriber function and close window on request --- src/Main.hs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/Main.hs b/src/Main.hs index 4a1e3ed..bacf903 100644 --- a/src/Main.hs +++ b/src/Main.hs @@ -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