diff --git a/src/eterna/eternaScript/SelectFolderAPI.ts b/src/eterna/eternaScript/SelectFolderAPI.ts new file mode 100644 index 00000000..ee9f9d1f --- /dev/null +++ b/src/eterna/eternaScript/SelectFolderAPI.ts @@ -0,0 +1,13 @@ +import {ExternalInterfaceCtx} from 'eterna/util/ExternalInterface'; + +/** + * Adds the ability to modify the folder (via its name) to the EternaScript API. +*/ +export default function addSelectFolderAPIToInterface({selectFolder, scriptInterface}: { + selectFolder: (folderName: string) => boolean, + scriptInterface: ExternalInterfaceCtx, +}) { + scriptInterface.addCallback( + 'select_folder', (folderName: string): boolean => selectFolder(folderName) + ); +} diff --git a/src/eterna/mode/PoseEdit/PoseEditMode.ts b/src/eterna/mode/PoseEdit/PoseEditMode.ts index b7ced3dd..2c518d45 100644 --- a/src/eterna/mode/PoseEdit/PoseEditMode.ts +++ b/src/eterna/mode/PoseEdit/PoseEditMode.ts @@ -79,6 +79,7 @@ import NuPACK from 'eterna/folding/NuPACK'; import PasteStructureDialog from 'eterna/ui/PasteStructureDialog'; import ConfirmTargetDialog from 'eterna/ui/ConfirmTargetDialog'; import FoldingContextScriptAPI from 'eterna/eternaScript/FoldingAPI'; +import addSelectFolderAPIToInterface from 'eterna/eternaScript/SelectFolderAPI'; import GameMode from '../GameMode'; import SubmittingDialog from './SubmittingDialog'; import SubmitPoseDialog from './SubmitPoseDialog'; @@ -1276,9 +1277,10 @@ export default class PoseEditMode extends GameMode { }).registerToScriptInterface(this._scriptInterface); if (this._puzzle.puzzleType === PuzzleType.EXPERIMENTAL) { - this._scriptInterface.addCallback( - 'select_folder', (folderName: string): boolean => this.selectFolder(folderName) - ); + addSelectFolderAPIToInterface({ + selectFolder: this.selectFolder, + scriptInterface: this._scriptInterface + }); this._scriptInterface.addCallback('load_parameters_from_buffer', (_str: string): boolean => { log.info('TODO: load_parameters_from_buffer');