Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
In order to prepare the ground for creating a new EternaJS app that just exposes the folding API without any additional state (which would allow fixing eternagame/eternagame.org#378), and in order to just simplify PoseEditMode, this PR extracts logic related the to the folding scripting (booster) API from PoseEditMode to a new class (/function), which would have very few dependencies.
Implementation Notes
Moved the code responsible for exposing the folding API (which only depends on the folding context, i.e read-only access to
this._folder
and understanding whether or not we are in psuedoknot mode) from PoseEditMode.ts to a separate ScriptsApi.ts flie (name WIP)Testing
I currently only ran
document.getElementById("maingame").fold("AUGGGGGGGGGGGGGGGGGGGGCCCCCCCCCCCCCCCCCCCC")
after running the script evaluator (in order to load the script interface)`.Related Issues
Preparations for fixing eternagame/eternagame.org#378
TODO
Blocking merge:
Rename the class and the file nameProbably change the class into a function- I decided against it.Move the fileMake eslint not angryDirect Follow-Up / maybe this PR
extract setting the folding engine as wellLater
Notes / Questions for CR
Notes
Questions
_getFolder
and_getIsPseudoknot
make sense? I couldn't find a better way without a) making aSwitchableFolder
proxy object or b) giving this class access to the entire PoseEditMode (now that I think about it, we could define an interface containingfolder
andisPseudoknot
... but I think it's better to just pass these 2, although I haven't done typescript in years)SwitchableFolder
- it'sFolderSwitcher
. Should I use it for this? Or the getter thing?FolderSwitcher
is coupled to pixi and the GUI, so I think I'm satisfied with the current way.isPseudoknot
ever going to change?Lib.fold
behave differently between different puzzles - but now it will also (or maybe has) behave differently between the editor and the scripts page and the gameeterna/eternaScript
, butExternalInterfaceCtx
should probably also sit there - however, I'm not sure if they should sit together - the code I moved is "user" code using the interface context, while the interface context itself is more of a "library" thing. Should I move it there as well in a follow up PR?