Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/components/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,7 @@ class App extends Component {
analysisType: state.analysisType,
showAnalysis: state.showAnalysis,
showCoordinates: state.showCoordinates,
coordinatesType: state.coordinatesType,
showMoveNumbers: state.showMoveNumbers,
showMoveColorization: state.showMoveColorization,
showNextMoves: state.showNextMoves,
Expand Down
29 changes: 27 additions & 2 deletions src/components/Goban.js
Original file line number Diff line number Diff line change
Expand Up @@ -262,9 +262,34 @@ export default class Goban extends Component {
board.height
)

// Calculate coordinates

let relativeCoord = (x, size) => {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For fewer top-level variables and cleaner code, I suggest you move this function into the else if (coordinatesType === 'relative') branch.

let halfSize = Math.ceil(size / 2)
let ix = size - x + 1
if (x <= halfSize && x < 10) return x.toString()
else if (ix < halfSize && ix < 10) return `${ix}*`
else return 'X'
}

let getCoordTransformer = coordinatesType => {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This variable might better be called getCoordFunctions since it might get confused with transformCoords().

if (coordinatesType === '1-1') {
return [x => x + 1, y => y + 1]
} else if (coordinatesType === 'relative') {
return [
x => relativeCoord(x + 1, board.width),
y => relativeCoord(board.height - y, board.height)
]
} else {
return [x => alpha[x], y => board.height - y] // A1
}
}

let coordinatesType = setting.get('view.coordinates_type')
let coordTransformer = getCoordTransformer(coordinatesType)
let {coordX, coordY} = gobantransformer.transformCoords(
x => alpha[x],
y => board.height - y,
coordTransformer[0],
coordTransformer[1],
transformation,
board.width,
board.height
Expand Down
41 changes: 37 additions & 4 deletions src/menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ exports.get = function(props = {}) {
analysisType,
showAnalysis,
showCoordinates,
coordinatesType,
showMoveNumbers,
showMoveColorization,
showNextMoves,
Expand Down Expand Up @@ -554,10 +555,42 @@ exports.get = function(props = {}) {
{type: 'separator'},
{
label: i18n.t('menu.view', 'Show &Coordinates'),
accelerator: 'CmdOrCtrl+Shift+C',
type: 'checkbox',
checked: !!showCoordinates,
click: () => toggleSetting('view.show_coordinates')
submenu: [
{
label: i18n.t('menu.view', '&Don’t Show'),
accelerator: 'CmdOrCtrl+Shift+C',
type: 'checkbox',
checked: !showCoordinates,
click: () => toggleSetting('view.show_coordinates')
},
{
label: i18n.t('menu.view', '&A1 (Default)'),
type: 'checkbox',
checked: !!showCoordinates && coordinatesType === 'A1',
click: () => {
setting.set('view.show_coordinates', true)
setting.set('view.coordinates_type', 'A1')
}
},
{
label: i18n.t('menu.view', '1-1'),
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it not possible to put a keyboard hint on a number, like &1-1?

type: 'checkbox',
checked: !!showCoordinates && coordinatesType === '1-1',
click: () => {
setting.set('view.show_coordinates', true)
setting.set('view.coordinates_type', '1-1')
}
},
{
label: i18n.t('menu.view', '&Relative'),
type: 'checkbox',
checked: !!showCoordinates && coordinatesType === 'relative',
click: () => {
setting.set('view.show_coordinates', true)
setting.set('view.coordinates_type', 'relative')
}
}
]
},
{
label: i18n.t('menu.view', 'Show Move N&umbers'),
Expand Down
2 changes: 2 additions & 0 deletions src/modules/sabaki.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ class Sabaki extends EventEmitter {
highlightVertices: [],
playVariation: null,
analysisType: null,
coordinatesType: null,
showAnalysis: null,
showCoordinates: null,
showMoveColorization: null,
Expand Down Expand Up @@ -219,6 +220,7 @@ class Sabaki extends EventEmitter {
'view.show_move_numbers': 'showMoveNumbers',
'view.show_next_moves': 'showNextMoves',
'view.show_siblings': 'showSiblings',
'view.coordinates_type': 'coordinatesType',
'view.fuzzy_stone_placement': 'fuzzyStonePlacement',
'view.animated_stone_placement': 'animateStonePlacement',
'graph.grid_size': 'graphGridSize',
Expand Down
1 change: 1 addition & 0 deletions src/setting.js
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ let defaults = {
'theme.custom_background': null,
'theme.current': null,
'view.animated_stone_placement': true,
'view.coordinates_type': 'A1',
'view.fuzzy_stone_placement': true,
'view.leftsidebar_width': 250,
'view.leftsidebar_minwidth': 100,
Expand Down