From da54a66fa05a0860399f7680ca3736475c64ad62 Mon Sep 17 00:00:00 2001 From: Robert Christ Date: Tue, 4 Jul 2023 12:08:34 -0400 Subject: [PATCH] Adds Bookmark and Comment Options to GameTree Node Menu. Issue 940 - https://github.com/SabakiHQ/Sabaki/issues/940 When navigating the gametree, it is not obvious how to bookmark or change colors of nodes. To bookmark, you can use hotspots (ctrl+b), and to change color, you can leave comments on the nodes. But neither of these options are available by right clicking a node, so unless you happen to come across this functionality by leaving a comment and happen to notice the impact, there is nothing that tells the user that this functionality exists. This commit rectifies this by adding these options when right clicking a node in the gametree. --- src/modules/sabaki.js | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/src/modules/sabaki.js b/src/modules/sabaki.js index 0c357fec..bc8a2074 100644 --- a/src/modules/sabaki.js +++ b/src/modules/sabaki.js @@ -2596,6 +2596,8 @@ class Sabaki extends EventEmitter { // Menus openNodeMenu(treePosition, {x, y} = {}) { + let commentMenu = this.getCommentMenuTemplate(treePosition) + let t = i18n.context('menu.edit') let template = [ { @@ -2635,6 +2637,21 @@ class Sabaki extends EventEmitter { { label: t('Remove &Other Variations'), click: () => this.removeOtherVariations(treePosition) + }, + {type: 'separator'}, + { + label: t('Show Co&mments'), + click: () => { + setting.toggle('view.show_comments') + this.setState(({showCommentBox}) => ({ + showCommentBox: !showCommentBox + })) + } + }, + {type: 'separator'}, + { + label: 'Annotate', + submenu: commentMenu } ] @@ -2642,6 +2659,12 @@ class Sabaki extends EventEmitter { } openCommentMenu(treePosition, {x, y} = {}) { + let template = this.getCommentMenuTemplate(treePosition) + + helper.popupMenu(template, x, y) + } + + getCommentMenuTemplate(treePosition) { let t = i18n.context('menu.comment') let node = this.inferredState.gameTree.get(treePosition) @@ -2725,7 +2748,7 @@ class Sabaki extends EventEmitter { item.click = () => this.setComment(treePosition, item.data) } - helper.popupMenu(template, x, y) + return template } openVariationMenu(