diff --git a/CHANGELOG.MD b/CHANGELOG.MD index 40ff7176c..47f1a0bae 100644 --- a/CHANGELOG.MD +++ b/CHANGELOG.MD @@ -1,5 +1,14 @@ # Change Log +## Version 3.9.2 - Dec 7, 2020 + +* Viewer: massive improvement of rendering performance. +* Viewer: fixes layout request in filtered viewers. +* Viewer-based dialogs: allows open an item with the Enter key. +* Scene Editor: caches scene file thumbnails in local browser Indexed DB. +* Scene Editor: more accuracy on thumbnail generation of container-based prefabs. +* Restore custom "alert" message dialog. + ## Version 3.9.1 - Nov 30, 2020 * Check if a new version is available at startup. diff --git a/source/editor/plugins/colibri/src/core/io/FileContentCache.ts b/source/editor/plugins/colibri/src/core/io/FileContentCache.ts index ff442fda4..45a87e517 100644 --- a/source/editor/plugins/colibri/src/core/io/FileContentCache.ts +++ b/source/editor/plugins/colibri/src/core/io/FileContentCache.ts @@ -1,14 +1,25 @@ namespace colibri.core.io { - export declare type GetFileContent = (file: FilePath) => Promise; + export declare type GetFileContent = (file: FilePath, force?:boolean) => Promise; export declare type SetFileContent = (file: FilePath, content: T) => Promise; + export interface IContentCacheMap { + + has(key: string): boolean; + + delete(key: string): void; + + set(key: string, value: ContentEntry): void; + + get(key: string): ContentEntry; + } + export class FileContentCache { private _backendGetContent: GetFileContent; private _backendSetContent: SetFileContent; - private _map: Map>; + private _map: IContentCacheMap; private _preloadMap: Map>; constructor(getContent: GetFileContent, setContent?: SetFileContent) { @@ -30,6 +41,7 @@ namespace colibri.core.io { const filename = file.getFullName(); if (this._preloadMap.has(filename)) { + return this._preloadMap.get(filename); } @@ -38,10 +50,11 @@ namespace colibri.core.io { if (entry) { if (!force && entry.modTime === file.getModTime()) { + return ui.controls.Controls.resolveNothingLoaded(); } - const promise2 = this._backendGetContent(file) + const promise2 = this._backendGetContent(file, force) .then((content) => { @@ -58,7 +71,7 @@ namespace colibri.core.io { return promise2; } - const promise = this._backendGetContent(file) + const promise = this._backendGetContent(file, force) .then((content) => { @@ -116,5 +129,4 @@ namespace colibri.core.io { ) { } } - } \ No newline at end of file diff --git a/source/editor/plugins/colibri/src/ui/controls/Controls.ts b/source/editor/plugins/colibri/src/ui/controls/Controls.ts index 98f65bde3..0f7333987 100644 --- a/source/editor/plugins/colibri/src/ui/controls/Controls.ts +++ b/source/editor/plugins/colibri/src/ui/controls/Controls.ts @@ -54,11 +54,46 @@ namespace colibri.ui.controls { return ctx; } + private static _charWidthMap: Map = new Map(); + private static _textWidthMap: Map = new Map(); + static measureTextWidth(context: CanvasRenderingContext2D, label: string) { - const measure = context.measureText(label); + const font = FONT_FAMILY + FONT_HEIGHT; + + const textKey = font + "@" + label; + + let width = 0; + + if (this._textWidthMap.has(textKey)) { + + width = this._textWidthMap.get(textKey); + + } else { + + for (const c of label) { + + const key = font + "@" + c; + + let charWidth = 0; + + if (this._charWidthMap.has(key)) { + + charWidth = this._charWidthMap.get(key); + + } else { + + charWidth = context.measureText(c).width; + this._charWidthMap.set(key, charWidth); + } + + width += charWidth; + } + + this._textWidthMap.set(textKey, width); + } - return measure.width * DEVICE_PIXEL_RATIO; + return width * DEVICE_PIXEL_RATIO; } static setDragEventImage(e: DragEvent, render: (ctx: CanvasRenderingContext2D, w: number, h: number) => void) { diff --git a/source/editor/plugins/colibri/src/ui/controls/ImageFrame.ts b/source/editor/plugins/colibri/src/ui/controls/ImageFrame.ts index 95c709e63..27398445a 100644 --- a/source/editor/plugins/colibri/src/ui/controls/ImageFrame.ts +++ b/source/editor/plugins/colibri/src/ui/controls/ImageFrame.ts @@ -72,9 +72,9 @@ namespace colibri.ui.controls { paintFrame(context: CanvasRenderingContext2D, - srcX: number, srcY: number, scrW: number, srcH: number, + srcX: number, srcY: number, scrW: number, srcH: number, - dstX: number, dstY: number, dstW: number, dstH: number): void { + dstX: number, dstY: number, dstW: number, dstH: number): void { // not implemented fow now } @@ -82,6 +82,7 @@ namespace colibri.ui.controls { preload(): Promise { if (this._image === null) { + return controls.Controls.resolveNothingLoaded(); } diff --git a/source/editor/plugins/colibri/src/ui/controls/ImageWrapper.ts b/source/editor/plugins/colibri/src/ui/controls/ImageWrapper.ts index 2dff46115..403be4161 100644 --- a/source/editor/plugins/colibri/src/ui/controls/ImageWrapper.ts +++ b/source/editor/plugins/colibri/src/ui/controls/ImageWrapper.ts @@ -57,6 +57,11 @@ namespace colibri.ui.controls { return 0; } + + getImageElement() { + + return this._imageElement; + } } } \ No newline at end of file diff --git a/source/editor/plugins/colibri/src/ui/controls/ScrollPane.ts b/source/editor/plugins/colibri/src/ui/controls/ScrollPane.ts index 3b72699ab..f788702d4 100644 --- a/source/editor/plugins/colibri/src/ui/controls/ScrollPane.ts +++ b/source/editor/plugins/colibri/src/ui/controls/ScrollPane.ts @@ -43,32 +43,44 @@ namespace colibri.ui.controls { } getViewer() { + if (this._clientControl instanceof viewers.ViewerContainer) { + return this._clientControl.getViewer(); } + return this._clientControl; } updateScroll(clientContentHeight: number) { + const scrollY = this.getViewer().getScrollY(); + const b = this.getBounds(); + let newScrollY = scrollY; newScrollY = Math.max(-this._clientContentHeight + b.height, newScrollY); newScrollY = Math.min(0, newScrollY); if (newScrollY !== scrollY) { + this._clientContentHeight = clientContentHeight; this.setClientScrollY(scrollY); + } else if (clientContentHeight !== this._clientContentHeight) { + this._clientContentHeight = clientContentHeight; this.layout(); } } private onBarMouseDown(e: MouseEvent) { + if (e.target !== this._scrollBar) { + return; } + e.stopImmediatePropagation(); const b = this.getBounds(); this.setClientScrollY(- e.offsetY / b.height * (this._clientContentHeight - b.height)); @@ -77,6 +89,7 @@ namespace colibri.ui.controls { private onClientWheel(e: WheelEvent) { if (e.shiftKey || e.ctrlKey || e.metaKey || e.altKey) { + return; } @@ -103,15 +116,20 @@ namespace colibri.ui.controls { private _startScrollY = 0; private onMouseDown(e: MouseEvent) { + if (e.target === this._scrollHandler) { + e.stopImmediatePropagation(); + this._startDragY = e.y; this._startScrollY = this.getViewer().getScrollY(); } } private onMouseMove(e: MouseEvent) { + if (this._startDragY !== -1) { + let delta = e.y - this._startDragY; const b = this.getBounds(); delta = delta / b.height * this._clientContentHeight; @@ -120,21 +138,27 @@ namespace colibri.ui.controls { } private onMouseUp(e: MouseEvent) { + if (this._startDragY !== -1) { + e.stopImmediatePropagation(); this._startDragY = -1; } } getBounds() { + const b = this.getElement().getBoundingClientRect(); + return { x: 0, y: 0, width: b.width, height: b.height }; } layout(): void { + const b = this.getBounds(); if (b.height < this._clientContentHeight) { + this._scrollHandler.style.display = "block"; const h = Math.max(10, b.height / this._clientContentHeight * b.height); const y = -(b.height - h) * this.getViewer().getScrollY() / (this._clientContentHeight - b.height); @@ -143,8 +167,11 @@ namespace colibri.ui.controls { y: y, height: h }); + this.removeClass("hideScrollBar"); + } else { + this.addClass("hideScrollBar"); } diff --git a/source/editor/plugins/colibri/src/ui/controls/dialogs/AbstractViewerDialog.ts b/source/editor/plugins/colibri/src/ui/controls/dialogs/AbstractViewerDialog.ts index 1e47010b8..db2bc266c 100644 --- a/source/editor/plugins/colibri/src/ui/controls/dialogs/AbstractViewerDialog.ts +++ b/source/editor/plugins/colibri/src/ui/controls/dialogs/AbstractViewerDialog.ts @@ -26,6 +26,7 @@ namespace colibri.ui.controls.dialogs { } getViewer() { + return this._viewer; } @@ -39,6 +40,7 @@ namespace colibri.ui.controls.dialogs { this.resize(); if (this._viewer) { + this._viewer.repaint(); } } @@ -85,9 +87,9 @@ namespace colibri.ui.controls.dialogs { const inputElement = this.getFilteredViewer().getFilterControl().getElement(); - inputElement.addEventListener("keyup", e => { + const listener = e => { - if (e.keyCode === 13) { + if (e.key === "Enter") { e.preventDefault(); @@ -111,7 +113,10 @@ namespace colibri.ui.controls.dialogs { btn.click(); } } - }); + }; + + inputElement.addEventListener("keyup", listener); + this.getViewer().getElement().addEventListener("keyup", listener); return btn; } diff --git a/source/editor/plugins/colibri/src/ui/controls/dialogs/Dialog.ts b/source/editor/plugins/colibri/src/ui/controls/dialogs/Dialog.ts index 26c426190..a39785168 100644 --- a/source/editor/plugins/colibri/src/ui/controls/dialogs/Dialog.ts +++ b/source/editor/plugins/colibri/src/ui/controls/dialogs/Dialog.ts @@ -168,7 +168,7 @@ namespace colibri.ui.controls.dialogs { inputElement.addEventListener("keyup", e => { - if (e.keyCode === 13) { + if (e.key === "Enter") { e.preventDefault(); diff --git a/source/editor/plugins/colibri/src/ui/controls/globals.ts b/source/editor/plugins/colibri/src/ui/controls/globals.ts index c38760db0..311802eb0 100644 --- a/source/editor/plugins/colibri/src/ui/controls/globals.ts +++ b/source/editor/plugins/colibri/src/ui/controls/globals.ts @@ -3,6 +3,7 @@ namespace colibri.ui.controls { export const CONTROL_PADDING = 3; export const ROW_HEIGHT = 20; export const FONT_HEIGHT = 14; + export const FONT_WITH = 12; export const FONT_OFFSET = 2; export const FONT_FAMILY = "Arial, Helvetica, sans-serif"; export const ACTION_WIDTH = 20; diff --git a/source/editor/plugins/colibri/src/ui/controls/viewers/FilteredViewer.ts b/source/editor/plugins/colibri/src/ui/controls/viewers/FilteredViewer.ts index a1f083e92..0a8a8a7d8 100644 --- a/source/editor/plugins/colibri/src/ui/controls/viewers/FilteredViewer.ts +++ b/source/editor/plugins/colibri/src/ui/controls/viewers/FilteredViewer.ts @@ -36,7 +36,8 @@ namespace colibri.ui.controls.viewers { this.addZoomControl(); } - setTimeout(() => this.layout(), 1); + //setTimeout(() => this.layout(), 1); + requestAnimationFrame(() => this.layout()); } private addZoomControl() { @@ -204,6 +205,7 @@ namespace colibri.ui.controls.viewers { } layout() { + this._viewerContainer.layout(); this._scrollPane.layout(); } diff --git a/source/editor/plugins/colibri/src/ui/controls/viewers/GridTreeViewerRenderer.ts b/source/editor/plugins/colibri/src/ui/controls/viewers/GridTreeViewerRenderer.ts index 0a2fd0785..a93d5eba9 100644 --- a/source/editor/plugins/colibri/src/ui/controls/viewers/GridTreeViewerRenderer.ts +++ b/source/editor/plugins/colibri/src/ui/controls/viewers/GridTreeViewerRenderer.ts @@ -48,6 +48,7 @@ namespace colibri.ui.controls.viewers { parentPaintItem: PaintItem, x: number, y: number) { const viewer = this.getViewer(); + const paintAreaHeight = viewer.getBounds().height; const labelProvider = viewer.getLabelProvider(); @@ -58,13 +59,16 @@ namespace colibri.ui.controls.viewers { const limit = 64 * controls.DEVICE_PIXEL_RATIO; if (cellSize < limit) { + cellSize = limit; + viewer.setCellSize(cellSize); } } else { if (cellSize <= 48) { + return super.paintItems(objects, treeIconList, paintItems, null, x, y); } } @@ -94,26 +98,32 @@ namespace colibri.ui.controls.viewers { } if (first) { + first = false; + } else { + y2 += sectionMargin; } - const label = labelProvider.getLabel(section); + if (y2 >= -cellSize && y2 <= paintAreaHeight) { - ctx.save(); + const label = labelProvider.getLabel(section); - ctx.fillStyle = "rgba(0, 0, 0, 0.05)"; + ctx.save(); - ctx.fillRect(0, y2 - 18, b.width, 25); + ctx.fillStyle = "rgba(0, 0, 0, 0.05)"; - ctx.fillStyle = controls.Controls.getTheme().viewerForeground + "aa"; + ctx.fillRect(0, y2 - 18, b.width, 25); - const textWidth = controls.Controls.measureTextWidth(ctx, label); + ctx.fillStyle = controls.Controls.getTheme().viewerForeground + "aa"; - ctx.fillText(label, b.width / 2 - textWidth / 2, y2); + const textWidth = controls.Controls.measureTextWidth(ctx, label); - ctx.restore(); + ctx.fillText(label, b.width / 2 - textWidth / 2, y2); + + ctx.restore(); + } y2 += sectionMargin; @@ -123,9 +133,9 @@ namespace colibri.ui.controls.viewers { y2 = result.y + sectionMargin; if (result.x > TREE_RENDERER_GRID_PADDING) { + y2 += cellSize; } - } return { @@ -168,7 +178,7 @@ namespace colibri.ui.controls.viewers { const args = new RenderCellArgs(context, x, y, cellSize, cellSize, obj, viewer, true); - this.renderGridCell(args, renderer, depth, obj === lastObj); + let isItemVisible = false; if (y > -cellSize && y < b.height) { @@ -201,9 +211,12 @@ namespace colibri.ui.controls.viewers { obj: obj }); } + + isItemVisible = true; + this.renderGridCell(args, renderer, depth, obj === lastObj); } - const item = new PaintItem(paintItems.length, obj, parentPaintItem); + const item = new PaintItem(paintItems.length, obj, parentPaintItem, isItemVisible); item.set(args.x, args.y, args.w, args.h); @@ -244,31 +257,6 @@ namespace colibri.ui.controls.viewers { const ctx = args.canvasContext; - const label = args.viewer.getLabelProvider().getLabel(args.obj); - - let line = ""; - - for (const c of label) { - - const test = line + c; - - const textWidth = controls.Controls.measureTextWidth(ctx, test); - - if (textWidth > args.w) { - - if (line.length > 2) { - - line = line.substring(0, line.length - 2) + ".."; - } - - break; - - } else { - - line += c; - } - } - const selected = args.viewer.isSelected(args.obj); let labelHeight: number; @@ -314,16 +302,51 @@ namespace colibri.ui.controls.viewers { this.prepareContextForText(args); - const m = ctx.measureText(line); - const x2 = Math.max(x, x + args.w / 2 - m.width / 2); + const label = args.viewer.getLabelProvider().getLabel(args.obj); + + const trim = this.trimLabel(ctx, label, args.w); + + const x2 = Math.max(x, x + args.w / 2 - trim.textWidth / 2); - ctx.fillText(line, x2, args.y + args.h - 5); + ctx.fillText(trim.text, x2, args.y + args.h - 5); ctx.restore(); } } + private trimLabel(ctx: CanvasRenderingContext2D, label: string, maxWidth: number) { + + let text = ""; + let textWidth = 0; + + for (const c of label) { + + const test = text + c; + + textWidth = controls.Controls.measureTextWidth(ctx, test); + + if (textWidth > maxWidth) { + + if (text.length > 2) { + + text = text.substring(0, text.length - 2) + ".."; + } + + break; + + } else { + + text += c; + } + } + + return { + text, + textWidth + }; + } + protected renderCellBack(args: RenderCellArgs, selected: boolean, isLastChild: boolean) { if (selected) { diff --git a/source/editor/plugins/colibri/src/ui/controls/viewers/ImageCellRenderer.ts b/source/editor/plugins/colibri/src/ui/controls/viewers/ImageCellRenderer.ts index 3aebaca83..8c905258b 100644 --- a/source/editor/plugins/colibri/src/ui/controls/viewers/ImageCellRenderer.ts +++ b/source/editor/plugins/colibri/src/ui/controls/viewers/ImageCellRenderer.ts @@ -34,6 +34,7 @@ namespace colibri.ui.controls.viewers { } cellHeight(args: RenderCellArgs): number { + return args.viewer.getCellSize(); } diff --git a/source/editor/plugins/colibri/src/ui/controls/viewers/OneCharCellRenderer.ts b/source/editor/plugins/colibri/src/ui/controls/viewers/OneCharCellRenderer.ts new file mode 100644 index 000000000..0830743c0 --- /dev/null +++ b/source/editor/plugins/colibri/src/ui/controls/viewers/OneCharCellRenderer.ts @@ -0,0 +1,39 @@ +namespace colibri.ui.controls.viewers { + + export class OneCharCellRenderer implements ICellRenderer { + + private _iconSize: boolean; + + constructor(iconSize: boolean) { + + this._iconSize = iconSize; + } + + renderCell(args: RenderCellArgs): void { + + const label = args.viewer.getLabelProvider().getLabel(args.obj); + + const ctx = args.canvasContext; + + let char = label.trim(); + + if (label.length > 0) { + + char = label[0]; + + ctx.fillText(char, args.x + args.w / 2, args.y + args.h / 2, args.w); + } + } + + cellHeight(args: RenderCellArgs): number { + + return this._iconSize ? controls.ROW_HEIGHT : args.viewer.getCellSize(); + } + + preload(args: PreloadCellArgs): Promise { + + return controls.Controls.resolveNothingLoaded(); + } + } + +} \ No newline at end of file diff --git a/source/editor/plugins/colibri/src/ui/controls/viewers/PaintItem.ts b/source/editor/plugins/colibri/src/ui/controls/viewers/PaintItem.ts index 25100af0b..ed52cdb56 100644 --- a/source/editor/plugins/colibri/src/ui/controls/viewers/PaintItem.ts +++ b/source/editor/plugins/colibri/src/ui/controls/viewers/PaintItem.ts @@ -4,7 +4,8 @@ namespace colibri.ui.controls.viewers { constructor( public index: number, public data: any, - public parent: PaintItem = null + public parent: PaintItem = null, + public visible: boolean ) { super(); } diff --git a/source/editor/plugins/colibri/src/ui/controls/viewers/TreeViewer.ts b/source/editor/plugins/colibri/src/ui/controls/viewers/TreeViewer.ts index b98740d5f..5fa93274e 100644 --- a/source/editor/plugins/colibri/src/ui/controls/viewers/TreeViewer.ts +++ b/source/editor/plugins/colibri/src/ui/controls/viewers/TreeViewer.ts @@ -230,29 +230,6 @@ namespace colibri.ui.controls.viewers { } } - async preload(): Promise { - - const list: Array> = []; - - const viewer = this; - - this.visitObjects(obj => { - - const provider = this.getCellRendererProvider(); - - list.push(provider.preload(new PreloadCellArgs(obj, viewer)).then(r1 => { - - const renderer = provider.getCellRenderer(obj); - - return renderer.preload(new PreloadCellArgs(obj, viewer)).then(r2 => { - return Math.max(r1, r2); - }); - })); - }); - - return Controls.resolveAll(list); - } - protected paint(): void { const result = this._treeRenderer.paint(); diff --git a/source/editor/plugins/colibri/src/ui/controls/viewers/TreeViewerRenderer.ts b/source/editor/plugins/colibri/src/ui/controls/viewers/TreeViewerRenderer.ts index d6300ca39..51377eaa1 100644 --- a/source/editor/plugins/colibri/src/ui/controls/viewers/TreeViewerRenderer.ts +++ b/source/editor/plugins/colibri/src/ui/controls/viewers/TreeViewerRenderer.ts @@ -79,10 +79,13 @@ namespace colibri.ui.controls.viewers { viewer.paintItemBackground(obj, 0, y, b.width, cellHeight); + let isItemVisible = false; + if (y > -viewer.getCellSize() && y < b.height) { // render tree icon if (children.length > 0) { + const iconY = y + (cellHeight - TREE_ICON_SIZE) / 2; const themeIcon = ColibriPlugin.getInstance() @@ -103,10 +106,11 @@ namespace colibri.ui.controls.viewers { }); } + isItemVisible = true; this.renderTreeCell(args, renderer); } - const item = new PaintItem(paintItems.length, obj, parentPaintItem); + const item = new PaintItem(paintItems.length, obj, parentPaintItem, isItemVisible); item.set(args.x, args.y, args.w, args.h); paintItems.push(item); diff --git a/source/editor/plugins/colibri/src/ui/controls/viewers/Viewer.ts b/source/editor/plugins/colibri/src/ui/controls/viewers/Viewer.ts index c7c477b6f..78aa6083f 100644 --- a/source/editor/plugins/colibri/src/ui/controls/viewers/Viewer.ts +++ b/source/editor/plugins/colibri/src/ui/controls/viewers/Viewer.ts @@ -460,13 +460,17 @@ namespace colibri.ui.controls.viewers { } expandCollapseBranch(obj: any) { + const parents = []; const item = this._paintItems.find(i => i.data === obj); if (item && item.parent) { + const parentObj = item.parent.data; + this.setExpanded(parentObj, !this.isExpanded(parentObj)); + parents.push(parentObj); } @@ -498,17 +502,18 @@ namespace colibri.ui.controls.viewers { this.repaint2(); - const result = await this.preload(); + this.preload(this._paintItems).then(result => { - if (result === PreloadResult.RESOURCES_LOADED) { + if (result === PreloadResult.RESOURCES_LOADED) { - this.repaint2(); - } + this.repaint2(); + } + }); this.updateScrollPane(); } - updateScrollPane() { + private updateScrollPane() { const pane = this.getContainer().getContainer(); @@ -536,7 +541,27 @@ namespace colibri.ui.controls.viewers { } } - protected abstract preload(): Promise; + private async preload(paintItems: PaintItem[]): Promise { + + const viewer = this; + + const rendererProvider = this.getCellRendererProvider(); + + let result = PreloadResult.NOTHING_LOADED; + + for (const paintItem of paintItems) { + + const obj = paintItem.data; + + const renderer = rendererProvider.getCellRenderer(obj); + + const itemResult = await renderer.preload(new PreloadCellArgs(obj, viewer)); + + result = Math.max(itemResult, result); + } + + return result; + } paintItemBackground(obj: any, x: number, y: number, w: number, h: number, radius: number = 0): void { diff --git a/source/editor/plugins/phasereditor2d.blocks/src/ui/views/BlocksView.ts b/source/editor/plugins/phasereditor2d.blocks/src/ui/views/BlocksView.ts index 1cfa27cda..9b7485a8e 100644 --- a/source/editor/plugins/phasereditor2d.blocks/src/ui/views/BlocksView.ts +++ b/source/editor/plugins/phasereditor2d.blocks/src/ui/views/BlocksView.ts @@ -11,11 +11,12 @@ namespace phasereditor2d.blocks.ui.views { super("BlocksView"); this.setTitle("Blocks"); - this.setIcon(BlocksPlugin.getInstance().getIcon(ICON_BLOCKS)); + this.setIcon(BlocksPlugin.getInstance().getIcon(ICON_BLOCKS)); } getViewerProvider(editor: ide.EditorPart) { + return editor.getEditorViewerProvider(BlocksView.EDITOR_VIEWER_PROVIDER_KEY); } } diff --git a/source/editor/plugins/phasereditor2d.ide/src/IDEPlugin.ts b/source/editor/plugins/phasereditor2d.ide/src/IDEPlugin.ts index 4b96914f7..e00de8af0 100644 --- a/source/editor/plugins/phasereditor2d.ide/src/IDEPlugin.ts +++ b/source/editor/plugins/phasereditor2d.ide/src/IDEPlugin.ts @@ -335,7 +335,7 @@ namespace phasereditor2d.ide { /* program entry point */ - export const VER = "3.9.1"; + export const VER = "3.9.2"; async function main() { @@ -349,6 +349,7 @@ namespace phasereditor2d.ide { "background-color:silver", ); + colibri.ui.controls.dialogs.AlertDialog.replaceConsoleAlert(); await IDEPlugin.getInstance().requestServerMode(); diff --git a/source/editor/plugins/phasereditor2d.ide/src/core/IProjectSettings.ts b/source/editor/plugins/phasereditor2d.ide/src/core/IProjectSettings.ts new file mode 100644 index 000000000..2eff5eac3 --- /dev/null +++ b/source/editor/plugins/phasereditor2d.ide/src/core/IProjectSettings.ts @@ -0,0 +1,7 @@ +namespace phasereditor2d.ide.core { + + export interface IProjectSettings { + + disableViewerCellRendererPreview?: boolean; + } +} \ No newline at end of file diff --git a/source/editor/plugins/phasereditor2d.pack/src/core/ImageFrameContainerAssetPackItem.ts b/source/editor/plugins/phasereditor2d.pack/src/core/ImageFrameContainerAssetPackItem.ts index d907af48f..0b2da044c 100644 --- a/source/editor/plugins/phasereditor2d.pack/src/core/ImageFrameContainerAssetPackItem.ts +++ b/source/editor/plugins/phasereditor2d.pack/src/core/ImageFrameContainerAssetPackItem.ts @@ -41,12 +41,7 @@ namespace phasereditor2d.pack.core { for (const frame of frames) { - const img = frame.getImage(); - - if (img) { - - result = Math.max(await img.preload(), result); - } + result = Math.max(await frame.preload(), result); } const result2 = await this.makeThumbnail(); diff --git a/source/editor/plugins/phasereditor2d.pack/src/ui/viewers/AtlasItemCellRenderer.ts b/source/editor/plugins/phasereditor2d.pack/src/ui/viewers/AtlasItemCellRenderer.ts index 74b619912..53cedd3ca 100644 --- a/source/editor/plugins/phasereditor2d.pack/src/ui/viewers/AtlasItemCellRenderer.ts +++ b/source/editor/plugins/phasereditor2d.pack/src/ui/viewers/AtlasItemCellRenderer.ts @@ -13,11 +13,15 @@ namespace phasereditor2d.pack.ui.viewers { const container = args.obj as pack.core.ImageFrameContainerAssetPackItem; - const r1 = await container.preload(); + await container.preload(); + + const r1 = container.getThumbnail() ? controls.PreloadResult.NOTHING_LOADED : controls.PreloadResult.RESOURCES_LOADED; const r2 = await container.preloadImages(); - return Math.max(r1, r2); + const result = Math.max(r1, r2); + + return result; } } } \ No newline at end of file diff --git a/source/editor/plugins/phasereditor2d.scene/libs/localforage.js b/source/editor/plugins/phasereditor2d.scene/libs/localforage.js new file mode 100644 index 000000000..2c2a8336b --- /dev/null +++ b/source/editor/plugins/phasereditor2d.scene/libs/localforage.js @@ -0,0 +1,2959 @@ +/*! + localForage -- Offline Storage, Improved + Version 1.9.0 + https://localforage.github.io/localForage + (c) 2013-2017 Mozilla, Apache License 2.0 +*/ +(function (f) { + var g; + if (typeof window !== "undefined") { + g = window + } else if (typeof global !== "undefined") { + g = global + } else if (typeof self !== "undefined") { + g = self + } else { + g = this + } + g.localforage = f() +} +)(function () { + var define, module, exports; + return (function e(t, n, r) { + function s(o, u) { + if (!n[o]) { + if (!t[o]) { + var a = typeof require == "function" && require; + if (!u && a) + return a(o, !0); + if (i) + return i(o, !0); + var f = new Error("Cannot find module '" + o + "'"); + throw (f.code = "MODULE_NOT_FOUND", + f) + } + var l = n[o] = { + exports: {} + }; + t[o][0].call(l.exports, function (e) { + var n = t[o][1][e]; + return s(n ? n : e) + }, l, l.exports, e, t, n, r) + } + return n[o].exports + } + var i = typeof require == "function" && require; + for (var o = 0; o < r.length; o++) + s(r[o]); + return s + } + )({ + 1: [function (_dereq_, module, exports) { + (function (global) { + 'use strict'; + var Mutation = global.MutationObserver || global.WebKitMutationObserver; + + var scheduleDrain; + + { + if (Mutation) { + var called = 0; + var observer = new Mutation(nextTick); + var element = global.document.createTextNode(''); + observer.observe(element, { + characterData: true + }); + scheduleDrain = function () { + element.data = (called = ++called % 2); + } + ; + } else if (!global.setImmediate && typeof global.MessageChannel !== 'undefined') { + var channel = new global.MessageChannel(); + channel.port1.onmessage = nextTick; + scheduleDrain = function () { + channel.port2.postMessage(0); + } + ; + } else if ('document' in global && 'onreadystatechange' in global.document.createElement('script')) { + scheduleDrain = function () { + + // Create a