-
-
Notifications
You must be signed in to change notification settings - Fork 404
Add option to select the coordinate type #665
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 5 commits
bc05fb1
532f37d
00f60f3
4d402e6
b2d6275
607f750
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -262,9 +262,34 @@ export default class Goban extends Component { | |
| board.height | ||
| ) | ||
|
|
||
| // Calculate coordinates | ||
|
|
||
| let relativeCoord = (x, size) => { | ||
| 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 => { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This variable might better be called |
||
| 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 | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -23,6 +23,7 @@ exports.get = function(props = {}) { | |
| analysisType, | ||
| showAnalysis, | ||
| showCoordinates, | ||
| coordinatesType, | ||
| showMoveNumbers, | ||
| showMoveColorization, | ||
| showNextMoves, | ||
|
|
@@ -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'), | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||
| 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'), | ||
|
|
||
There was a problem hiding this comment.
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.