switch from ncurses to brick #1
|
@ -24,6 +24,7 @@ module Mtlstats.Control.CreatePlayer (createPlayerC) where
|
|||
import Brick.Widgets.Core (str)
|
||||
import Control.Monad.State.Class (gets, modify)
|
||||
import Lens.Micro ((^.), (.~), (?~), (%~), to)
|
||||
import Lens.Micro.Mtl ((.=))
|
||||
|
||||
import Mtlstats.Actions
|
||||
import Mtlstats.Format
|
||||
|
@ -66,7 +67,7 @@ getActiveFlagC :: Controller
|
|||
getActiveFlagC = Controller
|
||||
{ drawController = const $ str "Is the player active? (Y/N)"
|
||||
, handleController = \e ->
|
||||
modify $ progMode.createPlayerStateL.cpsActiveFlag .~ ynHandler e
|
||||
progMode.createPlayerStateL.cpsActiveFlag .= ynHandler e
|
||||
}
|
||||
|
||||
confirmCreatePlayerC :: Controller
|
||||
|
|
|
@ -25,9 +25,10 @@ module Mtlstats.Control.EditGoalie (editGoalieC) where
|
|||
|
||||
import Brick.Types (Widget)
|
||||
import Brick.Widgets.Core (str, vBox)
|
||||
import Control.Monad.State.Class (gets, modify)
|
||||
import Control.Monad.State.Class (modify)
|
||||
import Data.Maybe (fromMaybe)
|
||||
import Lens.Micro ((^.), (.~), (%~))
|
||||
import Lens.Micro.Mtl (use)
|
||||
|
||||
import Mtlstats.Actions
|
||||
import Mtlstats.Handlers
|
||||
|
@ -99,7 +100,7 @@ deleteC _ = Controller
|
|||
in str $ hdr ++ "Are you sure you want to delete this goalie? (Y/N)"
|
||||
, handleController = \e -> case ynHandler e of
|
||||
Just True -> do
|
||||
gets (^.progMode.editGoalieStateL.egsSelectedGoalie) >>= mapM_
|
||||
use (progMode.editGoalieStateL.egsSelectedGoalie) >>= mapM_
|
||||
(\gid -> modify $ database.dbGoalies %~ dropNth gid)
|
||||
modify edit
|
||||
Just False -> modify $ progMode.editGoalieStateL.egsMode .~ EGMenu
|
||||
|
|
|
@ -23,9 +23,10 @@ module Mtlstats.Control.EditPlayer (editPlayerC) where
|
|||
|
||||
import Brick.Types (Widget)
|
||||
import Brick.Widgets.Core (emptyWidget, str, vBox)
|
||||
import Control.Monad.State.Class (gets, modify)
|
||||
import Control.Monad.State.Class (modify)
|
||||
import Data.Maybe (fromMaybe)
|
||||
import Lens.Micro ((^.), (.~), (%~))
|
||||
import Lens.Micro.Mtl (use)
|
||||
|
||||
import Mtlstats.Actions
|
||||
import Mtlstats.Handlers
|
||||
|
@ -90,7 +91,7 @@ deleteC _ = Controller
|
|||
in str $ hdr ++ "Are you sure you want to delete this player? (Y/N)"
|
||||
, handleController = \e -> case ynHandler e of
|
||||
Just True -> do
|
||||
gets (^.progMode.editPlayerStateL.epsSelectedPlayer) >>= mapM_
|
||||
use (progMode.editPlayerStateL.epsSelectedPlayer) >>= mapM_
|
||||
(\pid -> modify $ database.dbPlayers %~ dropNth pid)
|
||||
modify edit
|
||||
Just False -> modify $ progMode.editPlayerStateL.epsMode .~ EPMenu
|
||||
|
|
|
@ -37,7 +37,7 @@ import Graphics.Vty.Input.Events
|
|||
, Key (KDown, KHome, KEnter, KUp)
|
||||
)
|
||||
import Lens.Micro ((^.), (.~))
|
||||
import Lens.Micro.Mtl (use)
|
||||
import Lens.Micro.Mtl ((.=), use)
|
||||
|
||||
import Mtlstats.Actions
|
||||
import Mtlstats.Actions.NewGame
|
||||
|
@ -96,7 +96,7 @@ overtimeFlagC = Controller
|
|||
{ drawController = \s -> header s $
|
||||
str "Did the game go into overtime? (Y/N)"
|
||||
, handleController = \e ->
|
||||
modify $ progMode.gameStateL.overtimeFlag .~ ynHandler e
|
||||
progMode.gameStateL.overtimeFlag .= ynHandler e
|
||||
}
|
||||
|
||||
verifyDataC :: Controller
|
||||
|
|
|
@ -77,9 +77,9 @@ promptHandler p (VtyEvent (EvKey KEnter [])) = do
|
|||
editorW %= clearEditor
|
||||
promptAction p val
|
||||
promptHandler p (VtyEvent (EvKey (KChar c) [])) =
|
||||
modify $ editorW %~ promptProcessChar p c
|
||||
editorW %= promptProcessChar p c
|
||||
promptHandler _ (VtyEvent (EvKey KBS [])) =
|
||||
modify (editorW.editContentsL %~ deletePrevChar)
|
||||
editorW.editContentsL %= deletePrevChar
|
||||
promptHandler p (VtyEvent (EvKey k m)) =
|
||||
promptSpecialKey p k m
|
||||
promptHandler _ _ = return ()
|
||||
|
@ -243,7 +243,7 @@ selectPrompt params = Prompt
|
|||
results = spSearch params sStr db
|
||||
when (n < maxFunKeys) $
|
||||
whenJust (nth n results) $ \(sel, _) -> do
|
||||
modify $ editorW %~ clearEditor
|
||||
editorW %= clearEditor
|
||||
spCallback params $ Just sel
|
||||
_ -> return ()
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user