2019-09-04 22:56:24 -04:00
|
|
|
{- |
|
|
|
|
|
|
|
|
mtlstats
|
2021-05-08 12:19:34 -04:00
|
|
|
Copyright (C) 1984, 1985, 2019, 2020, 2021 Rhéal Lamothe
|
2019-09-04 22:56:24 -04:00
|
|
|
<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.Control (dispatch) where
|
|
|
|
|
2019-11-07 23:37:46 -05:00
|
|
|
import Lens.Micro ((^.))
|
2019-09-04 22:56:24 -04:00
|
|
|
|
2020-01-31 00:36:16 -05:00
|
|
|
import Mtlstats.Control.CreateGoalie
|
2020-01-29 12:10:57 -05:00
|
|
|
import Mtlstats.Control.CreatePlayer
|
2019-11-09 01:50:29 -05:00
|
|
|
import Mtlstats.Control.EditGoalie
|
2019-10-31 04:14:52 -04:00
|
|
|
import Mtlstats.Control.EditPlayer
|
2020-01-15 00:34:45 -05:00
|
|
|
import Mtlstats.Control.EditStandings
|
2019-11-07 22:36:08 -05:00
|
|
|
import Mtlstats.Control.NewGame
|
2020-01-29 12:10:57 -05:00
|
|
|
import Mtlstats.Control.TitleScreen
|
2019-09-04 22:56:24 -04:00
|
|
|
import Mtlstats.Menu
|
|
|
|
import Mtlstats.Prompt
|
|
|
|
import Mtlstats.Types
|
|
|
|
|
|
|
|
-- | Reads the program state and returs the apropriate controller to
|
|
|
|
-- run
|
|
|
|
dispatch :: ProgState -> Controller
|
|
|
|
dispatch s = case s^.progMode of
|
2020-01-31 00:36:16 -05:00
|
|
|
TitleScreen -> titleScreenC
|
2020-03-11 03:20:38 -04:00
|
|
|
MainMenu -> mainMenuC s
|
2020-01-31 00:36:16 -05:00
|
|
|
NewSeason flag -> newSeasonC flag
|
|
|
|
NewGame gs -> newGameC gs
|
|
|
|
EditMenu -> editMenuC
|
|
|
|
CreatePlayer cps -> createPlayerC cps
|
|
|
|
CreateGoalie cgs -> createGoalieC cgs
|
2020-01-16 12:42:33 -05:00
|
|
|
EditPlayer eps -> editPlayerC eps
|
|
|
|
EditGoalie egs -> editGoalieC egs
|
|
|
|
(EditStandings esm) -> editStandingsC esm
|
2019-09-07 00:27:18 -04:00
|
|
|
|
2020-03-11 03:20:38 -04:00
|
|
|
mainMenuC :: ProgState -> Controller
|
|
|
|
mainMenuC s = if null $ s^.dbName
|
|
|
|
then promptController getDBPrompt
|
|
|
|
else Controller
|
|
|
|
{ drawController = const $ drawMenu mainMenu
|
|
|
|
, handleController = menuHandler mainMenu
|
|
|
|
}
|
2019-09-07 00:27:18 -04:00
|
|
|
|
2020-01-14 02:42:30 -05:00
|
|
|
newSeasonC :: Bool -> Controller
|
|
|
|
newSeasonC False = promptController newSeasonPrompt
|
|
|
|
newSeasonC True = menuController newSeasonMenu
|
2019-09-07 00:27:18 -04:00
|
|
|
|
2019-12-17 11:32:32 -05:00
|
|
|
editMenuC :: Controller
|
2019-12-17 11:38:35 -05:00
|
|
|
editMenuC = menuController editMenu
|