Skip to content

Commit

Permalink
In game popup: toggle highlight style
Browse files Browse the repository at this point in the history
  • Loading branch information
tgass committed Oct 15, 2020
1 parent 5727889 commit 69e8b83
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion macbeth-wx/src/Macbeth/Wx/Game/Game.hs
Expand Up @@ -10,7 +10,7 @@ import Control.Exception
import Control.Monad
import Data.Maybe
import qualified Data.MultiSet as MultiSet
import Graphics.UI.WX hiding (when, position, play, point, white, black)
import Graphics.UI.WX hiding (when, position, play, point, white, black, style)
import Graphics.UI.WXCore hiding (when, Timer, black, white, point)
import Macbeth.Fics.Message
import Macbeth.Fics.Api.Api
Expand Down Expand Up @@ -105,6 +105,11 @@ wxGame env gameId gameParams isGameUser chan = do
, checked := showLabels boardConfig
, on command := atomically (modifyTVar vBoardState flipShowLabels) >> repaint p_back
]
void $ menuItem ctxMenu [ text := "Solid highlights"
, checkable:= True
, checked := Solid == style (highlightConfig boardConfig)
, on command := atomically (modifyTVar vBoardState flipHighlightStyle) >> repaint p_back
]
void $ wxPieceSetsMenu ctxMenu vBoardState p_board


Expand Down Expand Up @@ -189,6 +194,7 @@ wxGame env gameId gameParams isGameUser chan = do
, showCapturedPieces = showCapturedPieces $ Api.boardConfig state
, showLabels = Just $ showLabels $ Api.boardConfig state
, pieceSet = Just $ pieceSet $ Api.boardConfig state
, highlightConfig = Just $ highlightConfig $ Api.boardConfig state
}) <$> boardConfigFormat}
UserConfig.saveConfig updated
u <- convert (fromMaybe defaultBoardConfig $ UserConfig.boardConfig updated) (UserConfig.directory config)
Expand Down Expand Up @@ -244,3 +250,11 @@ flipShowLabels boardState =
let boardConfig' = Api.boardConfig boardState
flipped = boardConfig' { showLabels = not $ showLabels boardConfig' }
in boardState { Api.boardConfig = flipped }

flipHighlightStyle :: Api.BoardState -> Api.BoardState
flipHighlightStyle boardState =
let boardConfig' = Api.boardConfig boardState
highlightConfig' = highlightConfig boardConfig'
flipped = highlightConfig' { style = if style highlightConfig' == Solid then Hatched else Solid }
in boardState { Api.boardConfig = boardConfig'{ highlightConfig = flipped } }

0 comments on commit 69e8b83

Please sign in to comment.