Skip to content

Commit

Permalink
fix(save): shuffle dialog not working as expected
Browse files Browse the repository at this point in the history
  • Loading branch information
seleb committed May 30, 2024
1 parent a84c283 commit 90ecd4d
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/save.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,16 +145,18 @@ bitsy.saveHack = {
};

// use saved index to eval/calc next index if available
inject(/(optionsShuffled\.push\()optionsUnshuffled\.splice\(i,1\)\[0\](\);)/, '$1 i $2 optionsUnshuffled.splice(i,1);');
inject(/(optionsShuffled\.push\()optionsUnshuffled\.splice\(i,1\)\[0\](\);)/, '$1 options.indexOf(optionsUnshuffled[i]) $2 optionsUnshuffled.splice(i,1);');
inject(
/(optionsShuffled\[index\])/,
`
var i = window.saveHack.loadSeqIdx(this);
index = i === undefined ? index : i;
optionsShuffled = window.saveHack.loadShuffle(this) || optionsShuffled;
window.saveHack.saveShuffle(this, optionsShuffled);
options[index]`
options[optionsShuffled[index]]`
);
// save the second shuffle after exhausting options
inject(/(\t\t\tshuffle\(this\.children\);)/, `$1 window.saveHack.saveShuffle(this, optionsShuffled);`);
inject(/(\/\/ bitsy\.log\(".+" \+ index\);)/g, '$1\nvar i = window.saveHack.loadSeqIdx(this);index = i === undefined ? index : i;');
// save index on changes
inject(/(index = next;)/g, '$1window.saveHack.saveSeqIdx(this, index);');
Expand Down

0 comments on commit 90ecd4d

Please sign in to comment.