From 6fd81b3a743c68082f486fce80f8e81b77ba078c Mon Sep 17 00:00:00 2001 From: dualface Date: Thu, 29 Dec 2016 20:30:17 +0800 Subject: [PATCH] upgrade for creator 1.4 --- .../creator-lua-support/core/Project.js | 16 +++++++------- .../packages/creator-lua-support/main.js | 21 ++++++++++--------- .../panels/setup-project-panel.js | 4 ++-- 3 files changed, 22 insertions(+), 19 deletions(-) diff --git a/creator-project/packages/creator-lua-support/core/Project.js b/creator-project/packages/creator-lua-support/core/Project.js index fc39415..65b7e43 100644 --- a/creator-project/packages/creator-lua-support/core/Project.js +++ b/creator-project/packages/creator-lua-support/core/Project.js @@ -13,13 +13,13 @@ function tostring(v) { } module.exports = class Project { - constructor(state) { - this.path = state ? state.path : ''; - this.startSceneUuid = state ? state.startSceneUuid : ''; - this.selectAllScenes = state ? state.selectAllScenes : true; - this.autoBuild = state ? state.autoBuild : true; + constructor(profile) { + this.path = profile ? profile.path : ''; + this.startSceneUuid = profile ? profile.startSceneUuid : ''; + this.selectAllScenes = profile ? profile.selectAllScenes : true; + this.autoBuild = profile ? profile.autoBuild : true; this.scenes = []; - this._scenesUuid = (state && Array.isArray(state.scenesUuid)) ? state.scenesUuid : []; + this._scenesUuid = (profile && Array.isArray(profile.scenesUuid)) ? profile.scenesUuid : []; } validate() { @@ -63,7 +63,9 @@ module.exports = class Project { printlog(' autoBuild: ' + (this.autoBuild ? 'YES' : 'NO')); printlog(' scenes:'); this.scenes.forEach((scene, index) => { - printlog(' ' + (index + 1).toString() + ': ' + scene.url + (scene.checked ? ' [*]' : ' [ ]')); + if (scene.checked) { + printlog(' ' + (index + 1).toString() + ': ' + scene.url + (scene.checked ? ' [*]' : ' [ ]')); + } }); } diff --git a/creator-project/packages/creator-lua-support/main.js b/creator-project/packages/creator-lua-support/main.js index 8a1c405..7f65181 100644 --- a/creator-project/packages/creator-lua-support/main.js +++ b/creator-project/packages/creator-lua-support/main.js @@ -9,11 +9,12 @@ const Path = require('path'); const Electron = require('electron'); -const PACKAGE_NAME = 'creator-lua-support'; const TIMEOUT = -1; const DEBUG_WORKER = false; let PACKAGE_VERSION = ''; +const PROFILE_PATH = 'profile://project/creator-lua-support.json'; +const PACKAGE_NAME = 'creator-lua-support'; const PROFILE_DEFAULTS = { setup: false, path: '', @@ -54,19 +55,19 @@ function _runWorker(url, message, project) { function _checkProject(reason) { // workaround for creator 1.3 - let state = Editor.Profile.load(PACKAGE_NAME, 'project', PROFILE_DEFAULTS); - let project = new Project(state); + let profile = Editor.Profile.load(PROFILE_PATH, PROFILE_DEFAULTS); + let project = new Project(profile.data); if (project.validate()) { return project; } else { if (reason !== 'scene:saved') { Editor.Dialog.messageBox({ - type: 'warning', - buttons: [Editor.T('MESSAGE.ok')], - title: 'Warning - Lua Support', - message: 'Please setup Target Project first', - noLink: true, + type: 'warning', + buttons: [Editor.T('MESSAGE.ok')], + title: 'Warning - Lua Support', + message: 'Please setup Target Project first', + noLink: true, }); } else { Editor.warn('[Lua Support] Please setup Target Project first'); @@ -143,8 +144,8 @@ module.exports = { 'scene:saved'(event) { // workaround for creator 1.3 - let state = Editor.Profile.load(PACKAGE_NAME, 'project', PROFILE_DEFAULTS); - if (state.autoBuild) { + let profile = Editor.Profile.load(PROFILE_PATH, PROFILE_DEFAULTS); + if (profile.data.autoBuild) { _build('scene:saved'); } }, diff --git a/creator-project/packages/creator-lua-support/panels/setup-project-panel.js b/creator-project/packages/creator-lua-support/panels/setup-project-panel.js index 6f67400..d78ae43 100644 --- a/creator-project/packages/creator-lua-support/panels/setup-project-panel.js +++ b/creator-project/packages/creator-lua-support/panels/setup-project-panel.js @@ -23,7 +23,7 @@ Editor.Panel.extend({ ready() { let opts = Editor.argv.panelArgv; let profileProject = this.profiles.project; - let project = new Project(profileProject); + let project = new Project(profileProject.data); let vm = this._vm = new window.Vue({ el: this.shadowRoot, @@ -39,7 +39,7 @@ Editor.Panel.extend({ project: { handler(val) { if (!profileProject.save) return; - project.dumpState(profileProject); + project.dumpState(profileProject.data); profileProject.save(); }, deep: true