From 182c7dcdaae6b31b74d056824eec3d5253a282d2 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 fa034bdf..6e18d19e 100644 --- a/src/modules/sabaki.js +++ b/src/modules/sabaki.js @@ -2581,6 +2581,8 @@ class Sabaki extends EventEmitter { // Menus openNodeMenu(treePosition, {x, y} = {}) { + let commentMenu = this.getCommentMenuTemplate(treePosition) + let t = i18n.context('menu.edit') let template = [ { @@ -2620,6 +2622,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 } ] @@ -2627,6 +2644,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) @@ -2710,7 +2733,7 @@ class Sabaki extends EventEmitter { item.click = () => this.setComment(treePosition, item.data) } - helper.popupMenu(template, x, y) + return template } openVariationMenu(