This repository has been archived on 2023-06-24. You can view files and clone it, but you cannot make any changes to it's state, such as pushing and creating new issues, pull requests or comments.
2022FuncProg-project3-RPGEn.../lib/RPGEngine/Render/ActionSelection.hs

26 lines
No EOL
1.2 KiB
Haskell

module RPGEngine.Render.ActionSelection
( renderActionSelection
) where
import RPGEngine.Data (State (..), Action (..))
import Graphics.Gloss
( Picture, text, pictures, translate, scale, color )
import Graphics.Gloss.Data.Picture (blank)
import RPGEngine.Data.Level (getActionText)
import RPGEngine.Config (uizoom, selectionColor, textColor)
import RPGEngine.Input.Core (ListSelector(selection))
import RPGEngine.Render.Playing (renderPlaying)
import RPGEngine.Render.Core (overlay)
------------------------------ Exported ------------------------------
renderActionSelection :: State -> Picture
renderActionSelection (ActionSelection list selector continue) = everything
where numberedTexts = zip [0::Int ..] $ map getActionText list
sel = selection selector
everything = pictures $ [renderPlaying continue, overlay] ++ map render numberedTexts
render (i, t) | i == sel = color selectionColor $ make (i, t)
| otherwise = color textColor $ make (i, t)
make (i, t) = scale uizoom uizoom $ translate 0 (offset i) $ text t
offset i = negate (250 * uizoom * fromIntegral i)
renderActionSelection _ = blank