Skip to content
This repository has been archived by the owner on Mar 18, 2022. It is now read-only.

Commit

Permalink
upgrade for creator 1.4
Browse files Browse the repository at this point in the history
  • Loading branch information
dualface committed Dec 29, 2016
1 parent 676f2ad commit 6fd81b3
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 19 deletions.
16 changes: 9 additions & 7 deletions creator-project/packages/creator-lua-support/core/Project.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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 ? ' [*]' : ' [ ]'));
}
});
}

Expand Down
21 changes: 11 additions & 10 deletions creator-project/packages/creator-lua-support/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: '',
Expand Down Expand Up @@ -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');
Expand Down Expand Up @@ -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');
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
Expand Down

0 comments on commit 6fd81b3

Please sign in to comment.