Skip to content

Commit

Permalink
Add the option to switch on / off the display of variations started b…
Browse files Browse the repository at this point in the history
…y mouse over. (#668)
  • Loading branch information
ebifrier committed Mar 22, 2020
1 parent 4d95db6 commit d81a3d8
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 11 deletions.
6 changes: 3 additions & 3 deletions src/components/ContentDisplay.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,7 @@ export default class ContentDisplay extends Component {

sabaki.setState({playVariation: {sign, moves, sibling}})

if (setting.get('board.variation_instant_replay')) {
currentTarget.style.backgroundSize = '100% 100%'
} else {
if (setting.get('board.variation_replay_mode') === 'move_by_move') {
clearInterval(this.variationIntervalId)
this.variationIntervalId = setInterval(() => {
if (counter >= moves.length) {
Expand All @@ -102,6 +100,8 @@ export default class ContentDisplay extends Component {
currentTarget.style.backgroundSize = `${percent}% 100%`
counter++
}, setting.get('board.variation_replay_interval'))
} else {
currentTarget.style.backgroundSize = '100% 100%'
}
}

Expand Down
7 changes: 5 additions & 2 deletions src/components/Goban.js
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,8 @@ export default class Goban extends Component {
}

playVariation(sign, moves, sibling = false) {
if (setting.get('board.variation_instant_replay')) {
let replayMode = setting.get('board.variation_replay_mode')
if (replayMode === 'instantly') {
this.variationIntervalId = true

this.setState({
Expand All @@ -181,7 +182,7 @@ export default class Goban extends Component {
variationSibling: sibling,
variationIndex: moves.length
})
} else {
} else if (replayMode === 'move_by_move') {
clearInterval(this.variationIntervalId)

this.variationIntervalId = setInterval(() => {
Expand All @@ -192,6 +193,8 @@ export default class Goban extends Component {
variationIndex: variationIndex + 1
}))
}, setting.get('board.variation_replay_interval'))
} else {
this.stopPlayingVariation()
}
}

Expand Down
56 changes: 51 additions & 5 deletions src/components/drawers/PreferencesDrawer.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ class GeneralTab extends Component {
super(props)

this.state = {
appLang: setting.get('app.lang')
appLang: setting.get('app.lang'),
variationReplayMode: setting.get('board.variation_replay_mode')
}

this.handleSoundEnabledChange = evt => {
Expand All @@ -91,9 +92,15 @@ class GeneralTab extends Component {
)
}

this.handleVariationReplayModeChange = evt => {
setting.set('board.variation_replay_mode', evt.currentTarget.value)
}

setting.events.on(sabaki.window.id, 'change', ({key, value}) => {
if (key === 'app.lang') {
this.setState({appLang: value})
} else if (key === 'board.variation_replay_mode') {
this.setState({variationReplayMode: value})
}
})
}
Expand Down Expand Up @@ -130,10 +137,49 @@ class GeneralTab extends Component {
id: 'view.animated_stone_placement',
text: t('Animate fuzzy placement')
}),
h(PreferencesItem, {
id: 'board.variation_instant_replay',
text: t('Instantly play out analysis variations on board')
}),

h(
'li',
{class: 'select'},
h(
'label',
{},
t('Replay mode of analysis variations:'),
' ',

h(
'select',
{onChange: this.handleVariationReplayModeChange},

h(
'option',
{
value: 'dont_play',
selected: this.state.variationReplayMode === 'dont_play'
},
t("Don't Play")
),

h(
'option',
{
value: 'instantly',
selected: this.state.variationReplayMode === 'instantly'
},
t('Instantly')
),

h(
'option',
{
value: 'move_by_move',
selected: this.state.variationReplayMode === 'move_by_move'
},
t('Move by Move')
)
)
)
),

h(
'li',
Expand Down
2 changes: 1 addition & 1 deletion src/setting.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ let defaults = {
'board.analysis_interval': 50,
'board.analysis_type': 'winrate',
'board.show_analysis': true,
'board.variation_instant_replay': false,
'board.variation_replay_mode': 'move_by_move',
'board.variation_replay_interval': 500,
'cleanmarkup.annotations': false,
'cleanmarkup.arrow': true,
Expand Down

0 comments on commit d81a3d8

Please sign in to comment.