forked from AtomicGameEngine/AtomicGameEngine
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEditorWork.d.ts
More file actions
477 lines (414 loc) · 17.9 KB
/
EditorWork.d.ts
File metadata and controls
477 lines (414 loc) · 17.9 KB
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
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
//
// Copyright (c) 2014-2015, THUNDERBEAST GAMES LLC All rights reserved
// LICENSE: Atomic Game Engine Editor and Tools EULA
// Please see LICENSE_ATOMIC_EDITOR_AND_TOOLS.md in repository root for
// license information: https://github.com/AtomicGameEngine/AtomicGameEngine
//
/// <reference path="Atomic.d.ts" />
/// <reference path="Editor.d.ts" />
/// <reference path="ToolCore.d.ts" />
/// <reference path="WebView.d.ts" />
declare module Editor.Templates {
// Commented out until the TSDoc gets updated to the latest version of TypeScript
//export type TemplateType = "component" | "script";
/**
* New file defintion
*/
export interface FileTemplateDefinition {
/** name to display in the dropdown */
name: string;
/** description */
desc: string;
/** type of template */
templateType: string;
/** file extension */
ext: string;
/** file name/path of the source templage file to clone from. Note, needs to be in the atomic cache */
filename: string;
}
}
declare module Editor.Extensions {
/**
* Base interface for any editor services.
*/
export interface EditorServiceExtension {
/**
* Unique name of this service
* @type {string}
*/
name: string;
/**
* Description of this service
* @type {string}
*/
description: string;
}
/**
* Base Service Event Listener. Attach descendents of these to an EditorServiceExtension
* to hook service events
*/
export interface ServiceEventListener extends EditorServiceExtension { }
interface EventDispatcher {
/**
* Send a custom event. This can be used by services to publish custom events
* @param {string} eventType
* @param {any} data
*/
sendEvent(eventType: string, data: any);
sendEvent<T extends Atomic.EventMetaData>(eventType:string, data?:T);
sendEvent<T extends Atomic.EventCallbackMetaData>(eventCallbackMetaData:T);
/**
* Subscribe to an event and provide a callback. This can be used by services to subscribe to custom events
* @param {string} eventType
* @param {any} callback
*/
subscribeToEvent?(eventType: string, callback: (...params) => any);
/**
* Subscribe to an event with a pre-wrapped event object. This can be used by services to subscribe to custom events
* @param {Atomic.EventMetaData} wrappedEvent
*/
subscribeToEvent?(wrappedEvent: Atomic.EventMetaData);
}
/**
* Generic service locator of editor services that may be injected by either a plugin
* or by the editor itself.
*/
export interface ServiceLoader extends EventDispatcher {
/**
* Loads a service into a service registry
* @param {EditorService} service
*/
loadService(service: EditorServiceExtension): void;
}
/**
* Service registry interface for registering services
*/
export interface ServicesProvider<T extends ServiceEventListener> {
registeredServices: T[];
/**
* Adds a service to the registered services list for this type of service
* @param {T} service the service to register
*/
register(service: T);
/**
* Removes a service from the registered services list for this type of service
* @param {T} service the service to unregister
*/
unregister(service: T);
}
/**
* Interface that describes a Resource Editor Factory that will build out the editor for the relevant resource type
*/
export interface ResourceEditorBuilder {
/**
* Returns true if this builder can generate an editor for this resource type
*/
canHandleResource(resourcePath: string) : boolean;
/**
* Generates a resource editor for the provided resource type
* @param resourceFrame
* @param resourcePath
* @param tabContainer
* @param lineNumber
*/
getEditor(resourceFrame: Atomic.UIWidget, resourcePath: string, tabContainer: Atomic.UITabContainer, lineNumber: number) : Editor.ResourceEditor;
}
}
declare module Editor.Modal {
export interface ExtensionWindow extends Atomic.UIWindow {
hide();
}
}
declare module Editor.HostExtensions {
/**
* Generic service locator of editor services that may be injected by either a plugin
* or by the editor itself.
*/
export interface HostServiceLocator extends Editor.Extensions.ServiceLoader {
resourceServices: ResourceServicesProvider;
projectServices: ProjectServicesProvider;
sceneServices: SceneServicesProvider;
uiServices: UIServicesProvider;
}
export interface HostEditorService extends Editor.Extensions.EditorServiceExtension {
/**
* Called by the service locator at load time
*/
initialize(serviceLocator: HostServiceLocator);
}
export interface ResourceServicesEventListener extends Editor.Extensions.ServiceEventListener {
/**
* Called once a resource is saved
*/
save?(ev: Editor.EditorSaveResourceEvent);
/**
* Called when a resource is deleted
*/
delete?(ev: Editor.EditorDeleteResourceEvent);
/**
* Called when a resource is renamed
*/
rename?(ev: Editor.EditorRenameResourceNotificationEvent);
/**
* Called when a resource is about to be edited
*/
edit?(ev: Editor.EditorEditResourceEvent);
}
export interface ResourceServicesProvider extends Editor.Extensions.ServicesProvider<ResourceServicesEventListener> {
createMaterial(resourcePath: string, materialName: string, reportError: boolean): boolean;
}
export interface ProjectServicesEventListener extends Editor.Extensions.ServiceEventListener {
projectUnloaded?();
projectLoaded?(ev: Editor.EditorLoadProjectEvent);
playerStarted?();
}
export interface ProjectServicesProvider extends Editor.Extensions.ServicesProvider<ProjectServicesEventListener> {
/**
* Return a preference value or the provided default from the user settings file
* @param {string} extensionName name of the extension the preference lives under
* @param {string} preferenceName name of the preference to retrieve
* @param {number | boolean | string} defaultValue value to return if pref doesn't exist
* @return {number|boolean|string}
*/
getUserPreference(settingsGroup: string, preferenceName: string, defaultValue?: number): number;
getUserPreference(settingsGroup: string, preferenceName: string, defaultValue?: string): string;
getUserPreference(settingsGroup: string, preferenceName: string, defaultValue?: boolean): boolean;
/**
* Return a preference value or the provided default from the global user settings file
* @param {string} extensionName name of the section the preference lives under
* @param {string} preferenceName name of the preference to retrieve
* @param {number | boolean | string} defaultValue value to return if pref doesn't exist
* @return {number|boolean|string}
*/
getApplicationPreference(settingsGroup: string, preferenceName: string, defaultValue?: number): number;
getApplicationPreference(settingsGroup: string, preferenceName: string, defaultValue?: string): string;
getApplicationPreference(settingsGroup: string, preferenceName: string, defaultValue?: boolean): boolean;
/**
* Sets a user preference value in the project settings file
* @param {string} extensionName name of the extension the preference lives under
* @param {string} preferenceName name of the preference to set
* @param {number | boolean | string} value value to set
*/
setUserPreference(extensionName: string, preferenceName: string, value: number | boolean | string);
/**
* Sets an editor preference value in the global editor settings file
* @param {string} groupName name of the section the preference lives under
* @param {string} preferenceName name of the preference to set
* @param {number | boolean | string} value value to set
*/
setApplicationPreference(groupName: string, preferenceName: string, value: number | boolean | string);
}
export interface SceneServicesEventListener extends Editor.Extensions.ServiceEventListener {
activeSceneEditorChanged?(ev: Editor.EditorActiveSceneEditorChangeEvent);
editorSceneClosed?(ev: Editor.EditorSceneClosedEvent);
}
export interface SceneServicesProvider extends Editor.Extensions.ServicesProvider<SceneServicesEventListener> { }
export interface UIServicesEventListener extends Editor.Extensions.ServiceEventListener {
menuItemClicked?(refid: string): boolean;
projectContextItemClicked?(asset: ToolCore.Asset, refid: string): boolean;
projectAssetClicked?(asset: ToolCore.Asset): boolean;
hierarchyContextItemClicked?(node: Atomic.Node, refid: string): boolean;
/**
* Handle messages that are submitted via Atomic.Query from within a web view editor.
* @param message The message type that was submitted to be used to determine what the data contains if present
* @param data any additional data that needs to be submitted with the message
*/
handleWebMessage?(messageType: string, data?: any): void;
}
export interface UIServicesProvider extends Editor.Extensions.ServicesProvider<UIServicesEventListener> {
createPluginMenuItemSource(id: string, items: any): Atomic.UIMenuItemSource;
removePluginMenuItemSource(id: string);
createHierarchyContextMenuItemSource(id: string, items: any): Atomic.UIMenuItemSource;
removeHierarchyContextMenuItemSource(id: string);
createProjectContextMenuItemSource(id: string, items: any): Atomic.UIMenuItemSource;
removeProjectContextMenuItemSource(id: string);
refreshHierarchyFrame();
loadCustomInspector(customInspector: Atomic.UIWidget);
showModalWindow(windowText: string, uifilename: string, handleWidgetEventCB: (ev: Atomic.UIWidgetEvent) => void): Editor.Modal.ExtensionWindow;
showNonModalWindow(windowText: string, uifilename: string, handleWidgetEventCB: (ev: Atomic.UIWidgetEvent) => void): Editor.Modal.ExtensionWindow;
showModalError(windowText: string, message: string):Atomic.UIMessageWindow;
showResourceSelection(windowText: string, importerType: string, resourceType: string, callback: (retObject: any, args: any) => void, args?: any);
/**
* Returns the currently active resource editor or null
* @return {Editor.ResourceEditor}
*/
getCurrentResourceEditor(): Editor.ResourceEditor;
/**
* Will load a resource editor or navigate to an already loaded resource editor by path
* @param path The path to the resource to load
* @param lineNumber optional line number to navigate to
* @return {Editor.ResourceEditor}
*/
loadResourceEditor(path: string, lineNumber?: number): Editor.ResourceEditor;
/**
* Register a custom editor. These editors will override editors in the standard editor list if
* they both resolve the ```canHandleResource``` call.
*/
registerCustomEditor(editorBuilder: Editor.Extensions.ResourceEditorBuilder);
/**
* Will unregister a previously registered editor builder
* @param {Editor.Extensions.ResourceEditorBuilder} editorBuilder
*/
unregisterCustomEditor(editorBuilder: Editor.Extensions.ResourceEditorBuilder);
}
}
/**
* Interfaces for client extensions
*/
declare module Editor.ClientExtensions {
export interface EditorFileEvent {
filename: string;
fileExt: string;
editor: any;
}
export interface CodeLoadedEvent extends EditorFileEvent {
code: string;
}
export interface CodeSavedEvent extends EditorFileEvent {
code: string;
}
/**
* Called once the resource has been deleted
* @type {String}
*/
export interface DeleteResourceEvent {
// The full path to the resource to edit
path: string;
}
/**
* Called once the resource has been renamed
* @type {String}
*/
export interface RenameResourceEvent {
/**
* Original path of the resource
* @type {string}
*/
path: string;
/**
* New path of the resource
* @type {string}
*/
newPath: string;
/**
* New base name of the resource (no path or extension)
* @type {string}
*/
newName?: string;
}
/**
* Generic service locator of editor services that may be injected by either a plugin
* or by the editor itself.
*/
export interface ClientServiceLocator extends Editor.Extensions.ServiceLoader {
/**
* Exposed services
* @type {WebViewServicesProvider}
*/
clientServices: WebViewServicesProvider;
}
export interface ClientEditorService extends Editor.Extensions.EditorServiceExtension {
/**
* Called by the service locator at load time
*/
initialize(serviceLocator: ClientServiceLocator);
}
export interface PreferencesChangedEventData {
applicationPreferences? : any;
projectPreferences? : any;
}
export interface WebViewServiceEventListener extends Editor.Extensions.EditorServiceExtension {
configureEditor?(ev: EditorFileEvent);
codeLoaded?(ev: CodeLoadedEvent);
save?(ev: CodeSavedEvent);
delete?(ev: DeleteResourceEvent);
rename?(ev: RenameResourceEvent);
projectUnloaded?();
formatCode?();
preferencesChanged?(preferences: PreferencesChangedEventData);
}
/**
* Available methods exposed to client services
*/
export interface WebViewServicesProvider extends Editor.Extensions.ServicesProvider<WebViewServiceEventListener> {
/**
* Get a reference to the interop to talk to the host
* @return {HostInterop}
*/
getHostInterop(): HostInterop;
/**
* Return a preference value or the provided default from the user settings file
* @param {string} extensionName name of the extension the preference lives under
* @param {string} preferenceName name of the preference to retrieve
* @param {number | boolean | string} defaultValue value to return if pref doesn't exist
* @return {number|boolean|string}
*/
getUserPreference(settingsGroup: string, preferenceName: string, defaultValue?: number): number;
getUserPreference(settingsGroup: string, preferenceName: string, defaultValue?: string): string;
getUserPreference(settingsGroup: string, preferenceName: string, defaultValue?: boolean): boolean;
/**
* Return a preference value or the provided default from the application settings file
* @param {string} extensionName name of the extension the preference lives under
* @param {string} preferenceName name of the preference to retrieve
* @param {number | boolean | string} defaultValue value to return if pref doesn't exist
* @return {number|boolean|string}
*/
getApplicationPreference(settingsGroup: string, preferenceName: string, defaultValue?: number): number;
getApplicationPreference(settingsGroup: string, preferenceName: string, defaultValue?: string): string;
getApplicationPreference(settingsGroup: string, preferenceName: string, defaultValue?: boolean): boolean;
}
export interface AtomicErrorMessage {
error_code: number;
error_message: string;
}
/**
* Interface for functions that are available from the client web view to call on the host
*/
export interface HostInterop {
/**
* Called from the host to notify the client what file to load
* @param {string} codeUrl
*/
loadCode(codeUrl: string);
/**
* Save the contents of the editor
* @return {Promise}
*/
saveCode(): PromiseLike<{}>;
/**
* Save the contents of a file as filename
* @param {string} filename
* @param {string} fileContents
* @return {Promise}
*/
saveFile(filename: string, fileContents: string): PromiseLike<{}>;
/**
* Queries the host for a particular resource and returns it in a promise
* @param {string} codeUrl
* @return {Promise}
*/
getResource(codeUrl: string): PromiseLike<{}>;
/**
* Returns a file resource from the resources directory
* @param {string} filename name and path of file under the project directory or a fully qualified file name
* @return {Promise}
*/
getFileResource(filename: string): PromiseLike<{}>;
/**
* Notify the host that the contents of the editor has changed
*/
notifyEditorChange();
/**
* This adds a global routine to the window object so that it can be called from the host
* @param {string} routineName
* @param {(} callback
*/
addCustomHostRoutine(routineName: string, callback: (...any) => void);
}
}
declare module Editor {
/**
* Valid editor shortcuts that can be called from menus
*/
export type EditorShortcutType = "cut" | "copy" | "paste" | "undo" | "redo" | "close" | "frameselected" | "selectall";
}