From d333eca8c0761e39781af0711a54044cd5ea3c10 Mon Sep 17 00:00:00 2001 From: "Juan J. Martinez" Date: Sun, 16 Apr 2023 15:02:50 +0100 Subject: Documented the notification module --- src/Game/Toaster.hs | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src') diff --git a/src/Game/Toaster.hs b/src/Game/Toaster.hs index b0920c5..190365e 100644 --- a/src/Game/Toaster.hs +++ b/src/Game/Toaster.hs @@ -27,6 +27,9 @@ data Toaster = Toaster current :: Maybe Toast } +-- | Make a "toast" notification manager. +-- +-- The toast notifications appear on the bottom left of the screen and disappear after some seconds. mkToaster :: BM.BitmapFont -> Int -> IO Toaster mkToaster font height = do pure $ Toaster font height [] Nothing @@ -35,6 +38,7 @@ add :: Toaster -> String -> Toaster add t message = t {queue = t.queue ++ [message]} +-- | Update the current notification or activate the next one if there is no notification active. update :: Toaster -> Toaster update t = case t.current of Nothing -> case t.queue of @@ -50,6 +54,7 @@ update t = case t.current of | toast.y < t.gameHeight = Just toast {y = toast.y + 1} | otherwise = Nothing +-- | Render current notification (if there's one active). render :: SDL.Renderer -> Toaster -> IO () render renderer t = traverse_ (\toast -> BM.renderTextSolid renderer t.font 4 toast.y toast.message) t.current -- cgit v1.2.3