Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
PhaserEditor2D committed Aug 19, 2020
2 parents 888899d + 613170c commit ceab349
Show file tree
Hide file tree
Showing 60 changed files with 922 additions and 180 deletions.
32 changes: 29 additions & 3 deletions CHANGELOG.MD
Original file line number Diff line number Diff line change
@@ -1,16 +1,42 @@
# Change Log

## Version 3.4.0-next

### Added

* Scene Editor: shows error dialog when multiple files share the same scene id.
* [#63](https://github.com/PhaserEditor2D/PhaserEditor2D-v3/issues/63) Scene Editor: the **Fix Duplicated Scenes ID** command assign new IDs to the newer scene files.
* Scene Editor: the **Duplicate Scene File** command, available in Scene Editor > context menu > Scene.
* [#65](https://github.com/PhaserEditor2D/PhaserEditor2D-v3/issues/65) Scene Editor: the **Insert Spaces** and **Tab Size** parameters. To convert tabs to spaces in the compiler output.
* Scene Editor: the new created scenes will get the following parameters value from the latest modified scene: **compilerOutputLanguage**,**compilerInsertSpaces**, **compilerTabSize**, **borderWidth**, **borderHeight**, **borderX**, **borderY**.
* SceneEditor: the Pan scene tool.
* Scene Editor: allows move up/down the user components.
* User Components Editor: the **Insert Spaces** and **Tab Size** parameters.
* Saves the zooming state of all viewers in views, editors, dialogs, etc...
* [#59](https://github.com/PhaserEditor2D/PhaserEditor2D-v3/issues/59) Option to exclude a directory from the project.

### Modified

* [#61](https://github.com/PhaserEditor2D/PhaserEditor2D-v3/issues/61) Alphabetic sorting of viewer content.
* [#47](https://github.com/PhaserEditor2D/PhaserEditor2D-v3/issues/47) Inspector view: clearing content of a number field resets it to the default value.

### Fixes

* Scene Editor: fixes serialization of user number properties with `null` as default value.
* Scene Editor: fixes ID generation when pasting container objects.
* [#62](https://github.com/PhaserEditor2D/PhaserEditor2D-v3/issues/63) Scene Editor: fixes prefab constructor code generation when the texture is empty.

## Version 3.4.0 - Aug 4, 2020

## Added
### Added

* User Component Editor.
* Scene Editor: in Prefab Instance section shows a menu next to each prefab, to select all prefab instances.
* Scene Editor: adds user property of boolean type.
* Scene Editor: added a Compile Project command. It compiles all compilable files of the project (scenes, components).
* Volcano project template.

## Removed
### Removed

* **User Init Method** parameter and **Compiler Prefab Settings** section. Now you can insert code directly in the constructor of the prefab.
* Show size info of images, atlas frames and spritesheet frames in the Inspector view.
Expand Down Expand Up @@ -78,7 +104,7 @@
* Fixes menu vertical positioning when there is few space at the top.
* Scene Editor: shows message when a prefab is not found.
* Scene Editor: fixes user property declaration when no initial value is provided.
* [#45](https://github.com/PhaserEditor2D/PhaserEditor2D-v3/issues/45) Scene Editor: compiler skips using field declarations in JavaScript output. It is not supported in Safari.
* [#59](https://github.com/PhaserEditor2D/PhaserEditor2D-v3/issues/59) Scene Editor: compiler skips using field declarations in JavaScript output. It is not supported in Safari.
* Scene Editor: fixes scene compiler code merging when the output file was modified by formatters that replace tab chars with spaces.
* Scene Editor: fixes mouse wheel click on Safari.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ namespace colibri.ui.controls.dialogs {
export class CommandDialog extends controls.dialogs.ViewerDialog {

constructor() {
super(new controls.viewers.TreeViewer(), false);
super(new controls.viewers.TreeViewer("colibri.ui.controls.dialogs.CommandDialog"), false);

const size = this.getSize();
this.setSize(size.width * 1.5, size.height * 1.5);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ namespace colibri.ui.controls.viewers {
const viewer = this.getViewer();

viewer.setCellSize(viewer.getCellSize() + ICON_SIZE * z);
viewer.saveCellSize();

viewer.repaint();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ namespace colibri.ui.controls.viewers {

viewer.setCellSize(128 * controls.DEVICE_PIXEL_RATIO);

viewer.restoreCellSize();

this._center = center;
this._flat = flat;
this._sections = [];
Expand Down Expand Up @@ -45,6 +47,8 @@ namespace colibri.ui.controls.viewers {
objects: any[], treeIconList: TreeIconInfo[], paintItems: PaintItem[],
parentPaintItem: PaintItem, x: number, y: number) {

objects = this.sortObjects(objects);

const viewer = this.getViewer();

const labelProvider = viewer.getLabelProvider();
Expand Down Expand Up @@ -147,6 +151,8 @@ namespace colibri.ui.controls.viewers {
objects: any[], treeIconList: TreeIconInfo[], paintItems: PaintItem[],
parentPaintItem: PaintItem, x: number, y: number, offset: number, depth: number) {

objects = this.sortObjects(objects);

const viewer = this.getViewer();
const cellSize = Math.max(ROW_HEIGHT, viewer.getCellSize());
const context = viewer.getContext();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace colibri.ui.controls.viewers {
constructor(viewer: controls.viewers.TreeViewer, flat: boolean = false, center: boolean = false) {
super(viewer, flat, center);

viewer.setCellSize(64 * controls.DEVICE_PIXEL_RATIO);
viewer.setCellSize(64 * controls.DEVICE_PIXEL_RATIO, true);
}

renderCellBack(args: controls.viewers.RenderCellArgs, selected: boolean, isLastChild: boolean) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ namespace colibri.ui.controls.viewers {
private _treeRenderer: TreeViewerRenderer;
private _treeIconList: TreeIconInfo[];

constructor(...classList: string[]) {
super("TreeViewer", ...classList);
constructor(id: string, ...classList: string[]) {
super(id, "TreeViewer", ...classList);

this.getCanvas().addEventListener("click", e => this.onClick(e));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ namespace colibri.ui.controls.viewers {
constructor(viewer: TreeViewer, cellSize: number = ROW_HEIGHT) {

this._viewer = viewer;

this._viewer.setCellSize(cellSize);

this._viewer.restoreCellSize();
}

getViewer() {
Expand Down Expand Up @@ -48,12 +51,44 @@ namespace colibri.ui.controls.viewers {

}

protected sortObjects(objects: any[]): any[] {

if (!this._viewer.isSorted()) {

return objects;
}

const labelMap = new Map<any, string>();

for (const obj of objects) {

const label = this._viewer.getLabelProvider().getLabel(obj);

labelMap.set(obj, label);
}

const sorted = [...objects];

sorted.sort((obj1, obj2) => {

const label1 = labelMap.get(obj1);

const label2 = labelMap.get(obj2);

return label1.localeCompare(label2);
});

return sorted;
}

protected paintItems(
objects: any[], treeIconList: TreeIconInfo[], paintItems: PaintItem[],
parentPaintItem: PaintItem, x: number, y: number) {

const viewer = this._viewer;

objects = this.sortObjects(objects);

const context = viewer.getContext();

const b = viewer.getBounds();
Expand Down
56 changes: 51 additions & 5 deletions source/editor/plugins/colibri/src/ui/controls/viewers/Viewer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,19 @@ namespace colibri.ui.controls.viewers {
private _filterText: string;
protected _filterIncludeSet: Set<any>;
private _menu: controls.Menu;
private _viewerId: string;
private _sorted: boolean;

constructor(...classList: string[]) {
constructor(id: string, ...classList: string[]) {
super("canvas", "Viewer");

this.getElement().tabIndex = 1;
this.getElement().draggable = true;

this._viewerId = id;
this._filterText = "";
this._cellSize = 48;
this._sorted = true;

this.getElement().tabIndex = 1;
this.getElement().draggable = true;

this.initContext();

Expand All @@ -40,6 +44,41 @@ namespace colibri.ui.controls.viewers {
this._selectedObjects = new Set();

this.initListeners();

this.restoreCellSize();
}

isSorted() {

return this._sorted;
}

setSorted(sorted: boolean) {

this._sorted = sorted;
}

restoreCellSize() {

const key = "Viewer.cellSize." + this._viewerId;
const value = localStorage.getItem(key);

if (value) {

const size = Number.parseInt(value, 10);

if (!isNaN(size)) {

this._cellSize = size;
}
}
}

saveCellSize() {

const key = "Viewer.cellSize." + this._viewerId;

localStorage.setItem(key, this._cellSize.toString());
}

private initListeners() {
Expand Down Expand Up @@ -275,6 +314,8 @@ namespace colibri.ui.controls.viewers {
this.setCellSize(this.getCellSize() - ROW_HEIGHT);
}

this.saveCellSize();

this.repaint();
}

Expand Down Expand Up @@ -576,9 +617,14 @@ namespace colibri.ui.controls.viewers {
return this._cellSize;
}

setCellSize(cellSize: number): void {
setCellSize(cellSize: number, restoreSavedSize = false): void {

this._cellSize = Math.max(ROW_HEIGHT, cellSize);

if (restoreSavedSize) {

this.restoreCellSize();
}
}

getContentProvider() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ namespace colibri.ui.ide {

protected createViewer(): viewers.TreeViewer {

const viewer = new viewers.TreeViewer();
const viewer = new viewers.TreeViewer(this.getId() + ".EditorViewerView");

viewer.eventSelectionChanged.addListener(() => {

Expand Down
14 changes: 14 additions & 0 deletions source/editor/plugins/colibri/src/ui/ide/FileUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,20 @@ namespace colibri.ui.ide {

export class FileUtils {

static getFileCopyName(file: io.FilePath) {

const parent = file.getParent();

let name = file.getNameWithoutExtension();

while (parent.getFile(name + ".scene")) {

name = name + "_copy";
}

return name + ".scene";
}

static preloadImageSize(file: io.FilePath): Promise<controls.PreloadResult> {
return Workbench.getWorkbench().getFileImageSizeCache().preload(file);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace colibri.ui.ide.properties {
createForm(parent: HTMLDivElement) {
parent.classList.add("ManyImagePreviewFormArea");

const viewer = new controls.viewers.TreeViewer();
const viewer = new controls.viewers.TreeViewer("colibri.ui.ide.properties.ManyImagePreviewFormArea");

viewer.setContentProvider(new controls.viewers.ArrayTreeContentProvider());
viewer.setTreeRenderer(new controls.viewers.GridTreeViewerRenderer(viewer, false, true));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ namespace phasereditor2d.files.ui.actions {

const rootFolder = colibri.ui.ide.FileUtils.getRoot();

const viewer = new controls.viewers.TreeViewer();
const viewer = new controls.viewers.TreeViewer("phasereditor2d.files.ui.actions.CopyFilesAction");

viewer.setLabelProvider(new viewers.FileLabelProvider());
viewer.setCellRendererProvider(new viewers.FileCellRendererProvider());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ namespace phasereditor2d.files.ui.actions {
handler: {
executeFunc: args => {

const viewer = new controls.viewers.TreeViewer();
const viewer = new controls.viewers.TreeViewer("phasereditor2d.files.ui.actions.GoToFile");
viewer.setContentProvider(new controls.viewers.ArrayTreeContentProvider());
viewer.setLabelProvider(new viewers.FileLabelProvider());
viewer.setCellRendererProvider(new viewers.FileCellRendererProvider());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ namespace phasereditor2d.files.ui.actions {

const rootFolder = colibri.ui.ide.FileUtils.getRoot();

const viewer = new controls.viewers.TreeViewer();
const viewer = new controls.viewers.TreeViewer("phasereditor2d.files.ui.actions.MoveFilesAction");

viewer.setLabelProvider(new viewers.FileLabelProvider());
viewer.setCellRendererProvider(new viewers.FileCellRendererProvider());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,9 @@ namespace phasereditor2d.files.ui.actions {
return;
}

const viewer = new controls.viewers.TreeViewer();
const viewer = new controls.viewers.TreeViewer("phasereditor2d.files.ui.actions.OpenNewFileDialogAction");

viewer.setSorted(false);
viewer.setLabelProvider(new WizardLabelProvider());
viewer.setContentProvider(new controls.viewers.ArrayTreeContentProvider());
viewer.setCellRendererProvider(new WizardCellRendererProvider());
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

namespace phasereditor2d.files.ui.dialogs {

import controls = colibri.ui.controls;
Expand Down Expand Up @@ -173,7 +172,7 @@ namespace phasereditor2d.files.ui.dialogs {

private createFilteredViewer() {

const viewer = new viewers.TreeViewer();
const viewer = new viewers.TreeViewer("phasereditor2d.files.ui.dialogs.BaseNewFileDialog");

viewer.setLabelProvider(new files.ui.viewers.FileLabelProvider());
viewer.setContentProvider(new files.ui.viewers.FileTreeContentProvider(true));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace phasereditor2d.files.ui.dialogs {
private _uploadBtnElement: HTMLButtonElement;

constructor(uploadFolder: io.FilePath) {
super(new controls.viewers.TreeViewer(), false);
super(new controls.viewers.TreeViewer("phasereditor2d.files.ui.dialogs.UploadDialog"), false);

this._uploadFolder = uploadFolder;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ namespace phasereditor2d.files.ui.views {
}

protected createViewer() {
return new controls.viewers.TreeViewer();

return new controls.viewers.TreeViewer(FilesView.ID);
}

fillContextMenu(menu: controls.Menu) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace phasereditor2d.files.ui.views {
export class GridImageFileViewer extends controls.viewers.TreeViewer {

constructor(...classList: string[]) {
super(...classList);
super("phasereditor2d.files.ui.views.GridImageFileViewer", ...classList);

this.setContentProvider(new controls.viewers.ArrayTreeContentProvider());
this.setLabelProvider(new viewers.FileLabelProvider());
Expand Down
2 changes: 1 addition & 1 deletion source/editor/plugins/phasereditor2d.ide/src/IDEPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ namespace phasereditor2d.ide {

/* program entry point */

export const VER = "3.4.0";
export const VER = "3.5.0";

async function main() {

Expand Down
Loading

0 comments on commit ceab349

Please sign in to comment.