2019-08-20 00:18:23 -04:00
|
|
|
{- |
|
|
|
|
|
|
|
|
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
|
|
|
|
|
2019-08-22 16:53:31 -04:00
|
|
|
import Control.Monad (void)
|
2019-08-20 01:40:59 -04:00
|
|
|
import Lens.Micro ((^.))
|
2019-08-20 00:18:23 -04:00
|
|
|
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
|
2019-08-20 00:18:23 -04:00
|
|
|
import Mtlstats.Types
|
|
|
|
|
|
|
|
-- | Drawing function
|
|
|
|
draw :: ProgState -> C.Curses ()
|
2019-08-20 01:40:59 -04:00
|
|
|
draw s = do
|
2019-08-22 16:53:31 -04:00
|
|
|
void $ C.setCursorMode C.CursorInvisible
|
2019-08-20 01:40:59 -04:00
|
|
|
w <- C.defaultWindow
|
2019-08-22 16:53:31 -04:00
|
|
|
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-24 19:02:29 -04:00
|
|
|
| null $ gs ^. gameType -> drawMenu gameTypeMenu
|
|
|
|
| null $ gs ^. homeScore -> drawPrompt homeScorePrompt s
|
|
|
|
| otherwise -> undefined
|
2019-08-20 01:40:59 -04:00
|
|
|
C.render
|
2019-08-22 16:53:31 -04:00
|
|
|
void $ C.setCursorMode cm
|