Skip to content

Commit

Permalink
Extract the 'select_folder' api to an external file
Browse files Browse the repository at this point in the history
  • Loading branch information
guyguy2001 committed Jun 10, 2024
1 parent 7e73c3d commit c7ce02a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
13 changes: 13 additions & 0 deletions src/eterna/eternaScript/SelectFolderAPI.ts
Original file line number Diff line number Diff line change
@@ -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)
);
}
8 changes: 5 additions & 3 deletions src/eterna/mode/PoseEdit/PoseEditMode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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');
Expand Down

0 comments on commit c7ce02a

Please sign in to comment.