forked from foundryvtt/pf2e
-
Notifications
You must be signed in to change notification settings - Fork 0
/
scene.d.ts
253 lines (222 loc) · 10.3 KB
/
scene.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
import type { ClientBaseScene } from "./client-base-mixes.d.ts";
declare global {
/**
* The client-side Scene document which extends the common BaseScene abstraction.
* Each Scene document contains SceneData which defines its data schema.
* @param [data={}] Initial data provided to construct the Scene document
*/
class Scene extends ClientBaseScene {
/**
* Track the viewed position of each scene (while in memory only, not persisted)
* When switching back to a previously viewed scene, we can automatically pan to the previous position.
*/
protected _viewPosition: {} | { x: number; y: number; scale: number };
/** Track whether the scene is the active view */
protected _view: boolean;
/** Provide a thumbnail image path used to represent this document. */
get thumbnail(): string;
/** A convenience accessor for whether the Scene is currently viewed */
get isView(): boolean;
/* -------------------------------------------- */
/* Scene Methods */
/* -------------------------------------------- */
/**
* Set this scene as currently active
* @return A Promise which resolves to the current scene once it has been successfully activated
*/
activate(): Promise<this>;
override clone(
data: DeepPartial<this["_source"]> | undefined,
options: { save: true; keepId?: boolean }
): Promise<this>;
override clone(data?: DeepPartial<this["_source"]>, options?: { save?: false; keepId?: boolean }): this;
override clone(
data?: DeepPartial<this["_source"]>,
options?: { save?: boolean; keepId?: boolean }
): this | Promise<this>;
/** Set this scene as the current view */
view(): Promise<this>;
override prepareBaseData(): void;
protected override _preCreate(
data: PreDocumentId<this["_source"]>,
options: DocumentModificationContext<null>,
user: User
): Promise<void>;
protected override _onCreate(
data: this["_source"],
options: DocumentModificationContext<null>,
userId: string
): void;
protected override _preUpdate(
data: DocumentUpdateData<this>,
options: SceneUpdateContext,
user: User
): Promise<void>;
override _onUpdate(changed: DeepPartial<this["_source"]>, options: SceneUpdateContext, userId: string): void;
protected override _preDelete(options: DocumentModificationContext<null>, user: User): Promise<void>;
protected override _onDelete(options: DocumentModificationContext<null>, userId: string): void;
/**
* Handle Scene activation workflow if the active state is changed to true
* @param active Is the scene now active?
*/
protected _onActivate(active: boolean): Promise<this>;
protected override _preCreateEmbeddedDocuments(
embeddedName: "Token",
result: foundry.documents.TokenSource[],
options: SceneEmbeddedModificationContext<this>,
userId: string
): void;
protected override _onCreateEmbeddedDocuments(
embeddedName: "Token",
documents: TokenDocument<this>[],
result: foundry.documents.TokenSource[],
options: SceneEmbeddedModificationContext<this>,
userId: string
): void;
protected override _onCreateEmbeddedDocuments(
embeddedName: string,
documents: foundry.abstract.Document<this>[],
result: object[],
options: SceneEmbeddedModificationContext<this>,
userId: string
): void;
protected override _preUpdateEmbeddedDocuments(
embeddedName: "Token",
result: TokenDocument<this>["_source"][],
options: SceneEmbeddedModificationContext<this>,
userId: string
): void;
protected override _onUpdateEmbeddedDocuments(
embeddedName: "Token",
documents: TokenDocument<this>[],
result: TokenDocument<this>["_source"][],
options: SceneEmbeddedModificationContext<this>,
userId: string
): void;
protected override _preDeleteEmbeddedDocuments(
embeddedName: "Token",
result: string[],
options: SceneEmbeddedModificationContext<this>,
userId: string
): void;
protected override _onDeleteEmbeddedDocuments(
embeddedName: "Token",
documents: TokenDocument<this>[],
result: string[],
options: SceneEmbeddedModificationContext<this>,
userId: string
): void;
protected override _onDeleteEmbeddedDocuments(
embeddedName: string,
documents: foundry.abstract.Document<this>[],
result: string[],
options: SceneEmbeddedModificationContext<this>,
userId: string
): void;
override toCompendium(pack: CompendiumCollection<this>): this["_source"];
/**
* Create a 300px by 100px thumbnail image for this scene background
* @param [string|null] A background image to use for thumbnail creation, otherwise the current scene background
is used.
* @param [width] The desired thumbnail width. Default is 300px
* @param [height] The desired thumbnail height. Default is 100px;
* @return The created thumbnail data.
*/
createThumbnail({
img,
width,
height,
}?: {
img?: ImageFilePath | null;
width?: number;
height?: number;
}): Promise<Record<string, unknown>>;
}
interface Scene {
readonly drawings: foundry.abstract.EmbeddedCollection<DrawingDocument<this>>;
readonly lights: foundry.abstract.EmbeddedCollection<AmbientLightDocument<this>>;
readonly notes: foundry.abstract.EmbeddedCollection<NoteDocument<this>>;
readonly sounds: foundry.abstract.EmbeddedCollection<AmbientSoundDocument<this>>;
readonly templates: foundry.abstract.EmbeddedCollection<MeasuredTemplateDocument<this>>;
readonly tokens: foundry.abstract.EmbeddedCollection<TokenDocument<this>>;
readonly tiles: foundry.abstract.EmbeddedCollection<TileDocument<this>>;
readonly walls: foundry.abstract.EmbeddedCollection<WallDocument<this>>;
_sheet: SceneConfig<this> | null;
get sheet(): SceneConfig<this>;
getEmbeddedCollection(embeddedName: "Token"): this["tokens"];
update(data: DocumentUpdateData<this>, options?: SceneUpdateContext): Promise<this>;
updateEmbeddedDocuments(
embeddedName: "Token",
updateData: EmbeddedDocumentUpdateData<TokenDocument<this>>[],
options?: SceneEmbeddedModificationContext<this>
): Promise<CollectionValue<this["tokens"]>[]>;
updateEmbeddedDocuments(
embeddedName: "AmbientLight",
updateData: EmbeddedDocumentUpdateData<AmbientLightDocument<this>>[],
options?: SceneEmbeddedModificationContext<this>
): Promise<CollectionValue<this["lights"]>[]>;
updateEmbeddedDocuments(
embeddedName: "AmbientSound",
updateData: EmbeddedDocumentUpdateData<AmbientSoundDocument<this>>[],
options?: SceneEmbeddedModificationContext<this>
): Promise<CollectionValue<this["sounds"]>[]>;
updateEmbeddedDocuments(
embeddedName: "Drawing",
updateData: EmbeddedDocumentUpdateData<DrawingDocument<this>>[],
options?: SceneEmbeddedModificationContext<this>
): Promise<CollectionValue<this["drawings"]>[]>;
updateEmbeddedDocuments(
embeddedName: "MeasuredTemplate",
updateData: EmbeddedDocumentUpdateData<MeasuredTemplateDocument<this>>[],
options?: SceneEmbeddedModificationContext<this>
): Promise<CollectionValue<this["tokens"]>[]>;
updateEmbeddedDocuments(
embeddedName: "Note",
updateData: EmbeddedDocumentUpdateData<NoteDocument<this>>[],
options?: SceneEmbeddedModificationContext<this>
): Promise<CollectionValue<this["notes"]>[]>;
updateEmbeddedDocuments(
embeddedName: "Tile",
updateData: EmbeddedDocumentUpdateData<TileDocument<this>>[],
options?: SceneEmbeddedModificationContext<this>
): Promise<CollectionValue<this["tiles"]>[]>;
updateEmbeddedDocuments(
embeddedName: "Wall",
updateData: EmbeddedDocumentUpdateData<WallDocument<this>>[],
options?: SceneEmbeddedModificationContext<this>
): Promise<CollectionValue<this["walls"]>[]>;
updateEmbeddedDocuments(
embeddedName:
| "Token"
| "AmbientLight"
| "AmbientSound"
| "Drawing"
| "MeasuredTemplate"
| "Note"
| "Tile"
| "Wall",
updateData:
| EmbeddedDocumentUpdateData<TokenDocument<this>>[]
| EmbeddedDocumentUpdateData<AmbientLightDocument<this>>[]
| EmbeddedDocumentUpdateData<AmbientSoundDocument<this>>[]
| EmbeddedDocumentUpdateData<DrawingDocument<this>>[]
| EmbeddedDocumentUpdateData<MeasuredTemplateDocument<this>>[]
| EmbeddedDocumentUpdateData<NoteDocument<this>>[]
| EmbeddedDocumentUpdateData<TileDocument<this>>[]
| EmbeddedDocumentUpdateData<WallDocument<this>>[],
options?: SceneEmbeddedModificationContext<this>
): Promise<
| CollectionValue<this["tokens"]>[]
| CollectionValue<this["lights"]>[]
| CollectionValue<this["sounds"]>[]
| CollectionValue<this["drawings"]>[]
| CollectionValue<this["tokens"]>[]
| CollectionValue<this["notes"]>[]
| CollectionValue<this["tiles"]>[]
| CollectionValue<this["walls"]>[]
>;
}
interface SceneUpdateContext extends DocumentModificationContext<null> {
animateDarkness?: number;
}
}