Skip to content

Commit 8550619

Browse files
committed
add first pass of doc for open/save prompt dialogs in scripting
1 parent ff59906 commit 8550619

File tree

1 file changed

+48
-1
lines changed

1 file changed

+48
-1
lines changed

docs/scripting-doc/index.d.ts

Lines changed: 48 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,18 @@ interface size {
183183
* polygon array and then assign it to {@link MapObject.polygon}.
184184
*/
185185
type Polygon = point[];
186-
186+
/**
187+
* A string used to show only certain types of files when prompting the user to select a file path.
188+
*
189+
* Used in {@link FileEdit} and in {@link tiled.promptOpenFile} and related methods.
190+
* The filter is given in a format like `"Images (*.png *.xpm *.jpg)"`.
191+
*
192+
* If you want multiple filters, separate them with ';;', for example:
193+
* ```
194+
* "Images (*.png *.xpm *.jpg);;Text files (*.txt);;XML files (*.xml)"
195+
* ```
196+
*/
197+
type FileFilter = string;
187198
/**
188199
* The value of a property of type 'object', which refers to a
189200
* {@link MapObject} by its ID.
@@ -3924,6 +3935,42 @@ declare namespace tiled {
39243935
*/
39253936
export function prompt(label: string, text?: string, title?: string): string;
39263937

3938+
/**
3939+
* Shows a dialog which asks the user to choose an existing directory.
3940+
* Optionally override the starting directory of the dialog or its title.
3941+
*
3942+
* Returns the absolute path of the chosen directory, or an empty string if the user cancels the dialog.
3943+
*/
3944+
export function promptForDirectory(defaultDir?: string, title?: string): string;
3945+
3946+
/**
3947+
* Shows a dialog which asks the user to choose one or more existing files.
3948+
* Optionally override the starting directory of the dialog or its title.
3949+
* You can also restrict to only certain file types by specifying {@link FileFilter|filters}.
3950+
*
3951+
* Returns an array of the absolute paths of the chosen files, or an empty array if the user cancels the dialog.
3952+
*/
3953+
export function promptOpenMultipleFiles(defaultDir?: string, filters?: string, title?: string): string[];
3954+
3955+
/**
3956+
* Shows a dialog which asks the user to choose an existing file.
3957+
* Optionally override the starting directory of the dialog or its title.
3958+
* You can also restrict to only certain file types by specifying {@link FileFilter|filters}.
3959+
*
3960+
* Returns the absolute path of the chosen file, or an empty string if the user cancels the dialog.
3961+
*/
3962+
export function promptOpenFile(defaultDir?: string, filters?: string, title?: string): string;
3963+
3964+
/**
3965+
* Shows a dialog which asks the user to choose a destination for saving a file.
3966+
* If the user chooses a file path which already exists, they will be asked to confirm that they want to overwrite the file.
3967+
* Optionally override the starting directory of the dialog or its title.
3968+
* You can also restrict to only certain file types by specifying {@link FileFilter|filters}.
3969+
*
3970+
* Returns the absolute path of the chosen file, or an empty string if the user cancels the dialog.
3971+
*/
3972+
export function promptSaveFile(defaultDir?: string, filters?: string, title?: string): string;
3973+
39273974
/**
39283975
* Outputs the given text in the Console window as regular text.
39293976
*/

0 commit comments

Comments
 (0)