player selection branch

This commit is contained in:
Jonathan Lamothe 2019-11-01 02:55:43 -04:00
parent 43c2f6191d
commit b19f1386ec
2 changed files with 22 additions and 2 deletions

View File

@ -21,8 +21,15 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
module Mtlstats.Control.EditPlayer (editPlayer) where module Mtlstats.Control.EditPlayer (editPlayer) where
import Lens.Micro ((^.))
import Mtlstats.Types import Mtlstats.Types
-- | Dispatcher/controller for the player edit mode -- | Dispatcher/controller for the player edit mode
editPlayer :: EditPlayerState -> Controller editPlayer :: EditPlayerState -> Controller
editPlayer = undefined editPlayer eps
| null $ eps^.epsSelectedPlayer = selectPlayerC
| otherwise = undefined
selectPlayerC :: Controller
selectPlayerC = undefined

View File

@ -83,6 +83,8 @@ module Mtlstats.Types (
cgsName, cgsName,
cgsSuccessCallback, cgsSuccessCallback,
cgsFailureCallback, cgsFailureCallback,
-- ** EditPlayerState Lenses
epsSelectedPlayer,
-- ** Database Lenses -- ** Database Lenses
dbPlayers, dbPlayers,
dbGoalies, dbGoalies,
@ -122,6 +124,7 @@ module Mtlstats.Types (
newGameState, newGameState,
newCreatePlayerState, newCreatePlayerState,
newCreateGoalieState, newCreateGoalieState,
newEditPlayerState,
newDatabase, newDatabase,
newPlayer, newPlayer,
newPlayerStats, newPlayerStats,
@ -301,7 +304,10 @@ data CreateGoalieState = CreateGoalieState
} }
-- | Player edit status -- | Player edit status
data EditPlayerState = EditPlayerState newtype EditPlayerState = EditPlayerState
{ _epsSelectedPlayer :: Maybe Int
-- ^ The index number of the player being edited
}
-- | Represents the database -- | Represents the database
data Database = Database data Database = Database
@ -549,6 +555,7 @@ makeLenses ''ProgState
makeLenses ''GameState makeLenses ''GameState
makeLenses ''CreatePlayerState makeLenses ''CreatePlayerState
makeLenses ''CreateGoalieState makeLenses ''CreateGoalieState
makeLenses ''EditPlayerState
makeLenses ''Database makeLenses ''Database
makeLenses ''Player makeLenses ''Player
makeLenses ''PlayerStats makeLenses ''PlayerStats
@ -631,6 +638,12 @@ newCreateGoalieState = CreateGoalieState
, _cgsFailureCallback = return () , _cgsFailureCallback = return ()
} }
-- | Constructor for an 'EditPlayerState'
newEditPlayerState :: EditPlayerState
newEditPlayerState = EditPlayerState
{ _epsSelectedPlayer = Nothing
}
-- | Constructor for a 'Database' -- | Constructor for a 'Database'
newDatabase :: Database newDatabase :: Database
newDatabase = Database newDatabase = Database