mtlstats/src/Mtlstats/UI.hs

57 lines
1.7 KiB
Haskell
Raw Normal View History

{- |
mtlstats
Copyright (C) 2019 Rhéal Lamothe
<rheal.lamothe@gmail.com>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or (at
your option) any later version.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
-}
module Mtlstats.UI (draw) where
import Control.Monad (void)
2019-08-20 01:40:59 -04:00
import Lens.Micro ((^.))
import qualified UI.NCurses as C
2019-08-21 01:08:12 -04:00
import Mtlstats.Menu
2019-08-24 19:02:29 -04:00
import Mtlstats.Prompt
import Mtlstats.Types
-- | Drawing function
draw :: ProgState -> C.Curses ()
2019-08-20 01:40:59 -04:00
draw s = do
void $ C.setCursorMode C.CursorInvisible
2019-08-20 01:40:59 -04:00
w <- C.defaultWindow
cm <- C.updateWindow w $ do
2019-08-20 01:40:59 -04:00
C.clear
case s ^. progMode of
2019-08-21 01:08:12 -04:00
MainMenu -> drawMenu mainMenu
2019-08-21 01:15:26 -04:00
NewSeason -> drawMenu newSeasonMenu
2019-08-23 10:04:33 -04:00
NewGame gs
2019-08-31 11:28:09 -04:00
| null $ gs^.gameYear -> drawPrompt gameYearPrompt s
| null $ gs^.gameType -> drawMenu gameTypeMenu
| null $ gs^.otherTeam -> drawPrompt otherTeamPrompt s
| null $ gs^.homeScore -> drawPrompt homeScorePrompt s
| null $ gs^.awayScore -> drawPrompt awayScorePrompt s
| null $ gs^.overtimeFlag -> overtimePrompt
| otherwise -> undefined
2019-08-20 01:40:59 -04:00
C.render
void $ C.setCursorMode cm
overtimePrompt :: C.Update C.CursorMode
overtimePrompt = do
C.drawString "Did the game go into overtime? (Y/N)"
return C.CursorInvisible