implemented selectPositionPrompt
This commit is contained in:
parent
8a6cf10ad3
commit
a80eaa2a40
|
@ -0,0 +1,59 @@
|
|||
{- |
|
||||
|
||||
mtlstats
|
||||
Copyright (C) 1984, 1985, 2019, 2020 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.Helpers.Position
|
||||
( posSearch
|
||||
, posSearchExact
|
||||
, posCallback
|
||||
) where
|
||||
|
||||
import Mtlstats.Types
|
||||
|
||||
-- | Searches the 'Database' for all the positions used
|
||||
posSearch
|
||||
:: String
|
||||
-- ^ The search string
|
||||
-> Database
|
||||
-- ^ The database
|
||||
-> [(Int, String)]
|
||||
-- ^ A list of result indices and their values
|
||||
posSearch = undefined
|
||||
|
||||
-- | Searches the 'Database' for an exact position
|
||||
posSearchExact
|
||||
:: String
|
||||
-- ^ The search string
|
||||
-> Database
|
||||
-- ^ The database
|
||||
-> Maybe Int
|
||||
-- ^ The index of the result (or 'Nothing' if not found)
|
||||
posSearchExact = undefined
|
||||
|
||||
-- | Builds a callback function for when a 'Player' position is
|
||||
-- selected
|
||||
posCallback
|
||||
:: (String -> Action ())
|
||||
-- ^ The raw callback function
|
||||
-> Maybe Int
|
||||
-- ^ The index number of the position selected or 'Nothing' if blank
|
||||
-> Action ()
|
||||
-- ^ The action to perform
|
||||
posCallback = undefined
|
|
@ -42,6 +42,7 @@ module Mtlstats.Prompt (
|
|||
goalieNamePrompt,
|
||||
selectPlayerPrompt,
|
||||
selectGoaliePrompt,
|
||||
selectPositionPrompt,
|
||||
playerToEditPrompt
|
||||
) where
|
||||
|
||||
|
@ -56,6 +57,7 @@ import qualified UI.NCurses as C
|
|||
|
||||
import Mtlstats.Actions
|
||||
import Mtlstats.Config
|
||||
import Mtlstats.Helpers.Position
|
||||
import Mtlstats.Types
|
||||
import Mtlstats.Util
|
||||
|
||||
|
@ -307,6 +309,24 @@ selectGoaliePrompt pStr callback = selectPrompt SelectParams
|
|||
modify $ progMode .~ CreateGoalie cgs
|
||||
}
|
||||
|
||||
-- | Selects (or creates) a player position
|
||||
selectPositionPrompt
|
||||
:: String
|
||||
-- ^ The 'Prompt' string
|
||||
-> (String -> Action ())
|
||||
-- ^ The action to perform when a value is entered
|
||||
-> Prompt
|
||||
selectPositionPrompt pStr callback = selectPrompt SelectParams
|
||||
{ spPrompt = pStr
|
||||
, spSearchHeader = "Positions:"
|
||||
, spSearch = posSearch
|
||||
, spSearchExact = posSearchExact
|
||||
, spElemDesc = id
|
||||
, spProcessChar = \ch -> (++ [toUpper ch])
|
||||
, spCallback = posCallback callback
|
||||
, spNotFound = callback
|
||||
}
|
||||
|
||||
playerToEditPrompt :: Prompt
|
||||
playerToEditPrompt = selectPlayerPrompt "Player to edit: " $
|
||||
modify . (progMode.editPlayerStateL.epsSelectedPlayer .~)
|
||||
|
|
Loading…
Reference in New Issue
Block a user