Skip to content

Commit

Permalink
feat: update workspace with scene asset support
Browse files Browse the repository at this point in the history
  • Loading branch information
julien-moreau committed Aug 15, 2022
1 parent f6e72d8 commit c7e8414
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 0 deletions.
Binary file modified assets/project/add-project.zip
Binary file not shown.
Binary file modified assets/project/workspace.zip
Binary file not shown.
9 changes: 9 additions & 0 deletions src/renderer/editor/project/converter/scenes-converter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,5 +62,14 @@ export class WorkspaceSceneConverter {

editor.console.logInfo(`Converted scene "${p}" to scene file "${sceneFileName}"`);
}));

// Update workspace file
const workspaceJson = await readJSON(workspacePath, { encoding: "utf-8" }) as IWorkSpace;
workspaceJson.editorVersion = editor._packageJson.version;

await writeJSON(workspacePath, workspaceJson, {
spaces: "\t",
encoding: "utf-8",
});
}
}
18 changes: 18 additions & 0 deletions src/renderer/editor/project/welcome/welcome.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,7 @@ export class WelcomeDialog extends React.Component<IWelcomeDialogProps, IWelcome
const workspacePath = join(path, "workspace.editorworkspace");
await this._updateWorkspaceSettings(workspacePath);
await this._copyVsCodeLaunch(path);
await this._configureSceneFile(path);

// Open project!
await WorkSpace.SetOpeningWorkspace(workspacePath);
Expand Down Expand Up @@ -258,6 +259,7 @@ export class WelcomeDialog extends React.Component<IWelcomeDialogProps, IWelcome

await this._updateWorkspaceSettings(workspacePath);
await this._copyVsCodeLaunch(path);
await this._configureSceneFile(path);

await WorkSpace.SetOpeningWorkspace(join(path, workspaceFile));
window.location.reload();
Expand Down Expand Up @@ -288,6 +290,22 @@ export class WelcomeDialog extends React.Component<IWelcomeDialogProps, IWelcome
await copy(join(AppTools.GetAppPath(), "assets/project/launch.json"), join(path, ".vscode/launch.json"), { overwrite: false });
}

/**
* Configures the default scene file to keep real creation data.
*/
private async _configureSceneFile(path: string): Promise<void> {
try {
await writeJson(join(path, "assets/scene.scene"), {
createdAt: new Date(Date.now()).toDateString(),
}, {
spaces: "\t",
encoding: "utf-8",
});
} catch (e) {
// Catch silently.
}
}

/**
* Returns wether or not the folder is empty.
*/
Expand Down

0 comments on commit c7e8414

Please sign in to comment.