Skip to content

Commit

Permalink
Allow spotlight for book explorers inc Lichess
Browse files Browse the repository at this point in the history
  • Loading branch information
rooklift committed Jan 2, 2025
1 parent a99862b commit 92ee795
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
10 changes: 7 additions & 3 deletions files/src/renderer/81_arrows.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

let arrow_props = {

draw_arrows: function(node, specific_source, show_move) { // specific_source is a Point(), show_move is a string
draw_arrows: function(node, specific_source, show_move) { // If not nullish, specific_source is a Point() and show_move is a string

// Function is responsible for updating the one_click_moves array.

Expand Down Expand Up @@ -356,9 +356,9 @@ let arrow_props = {
// of the app. The info_list here is just a list of objects each containing only "move" and "weight" - where
// the weights have been normalised to the 0-1 scale and the list has been sorted.
//
// Note that info_list here should not be modified.
// Note that info_list here MUST NOT BE MODIFIED.

draw_explorer_arrows: function(node, info_list) {
draw_explorer_arrows: function(node, info_list, specific_source) { // If not nullish, specific_source is a Point()

for (let x = 0; x < 8; x++) {
for (let y = 0; y < 8; y++) {
Expand All @@ -375,6 +375,10 @@ let arrow_props = {

for (let i = 0; i < info_list.length; i++) {

if (specific_source && specific_source.s !== info_list[i].move.slice(0, 2)) {
continue;
}

let [x1, y1] = XY(info_list[i].move.slice(0, 2));
let [x2, y2] = XY(info_list[i].move.slice(2, 4));

Expand Down
10 changes: 6 additions & 4 deletions files/src/renderer/95_hub.js
Original file line number Diff line number Diff line change
Expand Up @@ -814,7 +814,7 @@ let hub_props = {
if (!this.book) {
this.explorer_objects_cache = null;
this.explorer_cache_node_id = null;
this.info_handler.draw_explorer_arrows(this.tree.node, []); // Needs to happen, to update the one_click_moves.
this.info_handler.draw_explorer_arrows(this.tree.node, [], null); // Needs to happen, to update the one_click_moves.
return;
}

Expand Down Expand Up @@ -842,7 +842,8 @@ let hub_props = {
this.explorer_objects_cache.sort((a, b) => b.weight - a.weight);
}

this.info_handler.draw_explorer_arrows(this.tree.node, this.explorer_objects_cache);
let arrow_spotlight_square = config.click_spotlight ? this.active_square : null;
this.info_handler.draw_explorer_arrows(this.tree.node, this.explorer_objects_cache, arrow_spotlight_square);
},

draw_lichess_arrows: function() {
Expand All @@ -864,7 +865,7 @@ let hub_props = {
if (!ok) {
this.explorer_objects_cache = null;
this.explorer_cache_node_id = null;
this.info_handler.draw_explorer_arrows(this.tree.node, []); // Needs to happen, to update the one_click_moves.
this.info_handler.draw_explorer_arrows(this.tree.node, [], null); // Needs to happen, to update the one_click_moves.
return;
}

Expand All @@ -889,7 +890,8 @@ let hub_props = {
this.explorer_objects_cache.sort((a, b) => b.weight - a.weight);
}

this.info_handler.draw_explorer_arrows(this.tree.node, this.explorer_objects_cache);
let arrow_spotlight_square = config.click_spotlight ? this.active_square : null;
this.info_handler.draw_explorer_arrows(this.tree.node, this.explorer_objects_cache, arrow_spotlight_square);
},

draw_statusbox: function() {
Expand Down

0 comments on commit 92ee795

Please sign in to comment.