Skip to content

Commit

Permalink
导出进度条颜色;Label spacingX 属性导出;导出ui合图资源;Label粗体支持;单独场景导出;增加检查重复图片功能;支持检查…
Browse files Browse the repository at this point in the history
…未使用图片
Rate limit · GitHub

Access has been restricted

You have triggered a rate limit.

Please wait a few minutes before you try again;
in some cases this may take up to an hour.

Xiaobin0860 committed Mar 25, 2021
1 parent 1deafc1 commit 3a06f45
Showing 21 changed files with 8,146 additions and 297 deletions.
Original file line number Diff line number Diff line change
@@ -134,6 +134,8 @@ table Label
overflowType:LabelOverflowType;
enableWrap:bool;
outline:LabelOutline;
spacingX:float;
bold:bool;
}

table RichText
467 changes: 401 additions & 66 deletions creator_project/packages/creator-luacpp-support/core/BuildWorker.js

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -10,13 +10,16 @@ class Constants{};
Constants.PACKAGE_NAME = 'creator-luacpp-support';
// root of the this plugin
Constants.PACKAGE_PATH = Editor.url('packages://' + Constants.PACKAGE_NAME + '/');
Constants.WORK_PATH = Constants.PACKAGE_PATH;
// root of creator project
if (process && process.type === 'renderer')
Constants.PROJECT_PATH = Editor.remote.projectInfo.path;
Constants.PROJECT_PATH = Editor.remote.Project.path;
else
Constants.PROJECT_PATH = Editor.projectInfo.path;
Constants.PROJECT_PATH = Editor.Project.path;
// path of `assets` folder
Constants.ASSETS_PATH = Path.join(Constants.PROJECT_PATH, 'assets');
// path of `atlases` folder
Constants.ATLASES_PATH = Path.join(Constants.PROJECT_PATH, 'atlases');
// path of `temp` folder
Constants.TEMP_PATH = Path.join(Constants.PROJECT_PATH, 'temp');
// path of `temp/internal`
@@ -43,7 +46,10 @@ Constants.PROFILE_DEFAULTS = {
path: '',
autoBuild: false,
exportResourceOnly: false,
exportResourceDynamicallyLoaded: false
exportResourceDynamicallyLoaded: false,
exportSpriteSheet: false,
imageRepeatCheck: false,
unuseImageCheck: false
};

module.exports = Constants;
297 changes: 177 additions & 120 deletions creator_project/packages/creator-luacpp-support/core/Utils.js
Original file line number Diff line number Diff line change
@@ -1,144 +1,201 @@

/* jslint node: true, sub: true, esversion: 6, browser: true */
/* globals Editor */

"use strict";

const Path = require('path');
const Fs = require('fire-fs');
const Constants = require('./Constants');
const Path = require("path");
const Fs = require("fire-fs");
const Constants = require("./Constants");

let analytics = undefined;

class Utils {
static log(data) {
const logFunc = Editor ? Editor.log : console.log;
logFunc(data);
}

static runpython(params, cb) {
let pyPath = 'python';
if (process.platform !== 'darwin')
pyPath = Editor.url('unpack://utils/Python27/python');

Utils.runcommand(pyPath, params, cb);
}

static runcommand(cmd, params, cb) {
const spawn = require('child_process').spawn;
const sp = spawn(cmd, params);

sp.stdout.on('data', (data) => {
Utils.log(data);
});

sp.stderr.on('data', (data) => {
Utils.log(data);
});

sp.on('close', (code) => {
cb(code);
});
}

// lua project includes config.json
static isLuaProject(dir) {
// project created by console
let cocos2dx_path = Path.join(dir, 'frameworks/cocos2d-x');
if (Fs.existsSync(cocos2dx_path))
return true;

// cocos2d-x internal lua tests
let app_delegate_path = Path.join(dir, 'project/Classes/AppDelegate.cpp');
if (Fs.existsSync(app_delegate_path))
return true;

return false;
static log(data) {
const logFunc = Editor ? Editor.log : console.log;
logFunc(data);
}

static runpython(params, cb) {
let pyPath = "python";
if (process.platform !== "darwin")
pyPath = Editor.url("unpack://utils/Python27/python");

Utils.runcommand(pyPath, params, cb);
}

static runcommand(cmd, params, cb) {
// console.log(cmd, params,process.env.PATH);

const spawn = require("child_process").spawn;
const sp = spawn(cmd, params, {
cwd: Constants.WORK_PATH,
env: {
PATH:
process.env.PATH +
(process.platform == "darwin" ? ":/usr/local/bin" : ";/usr/local/bin"),
},
});

sp.stdout.on("data", (data) => {
Utils.log(data);
});

sp.stderr.on("data", (data) => {
Utils.log(data);
});

sp.on("close", (code) => {
cb(code);
});

sp.on("error", (err) => {
Utils.log("Constants.WORK_PATH=" + Constants.WORK_PATH);
Utils.log(err);
cb(-1);
});
}

static runcommandSync(cmd, params) {
// console.log(cmd, params,process.env.PATH);

const spawnSync = require("child_process").spawnSync;
const rt = spawnSync(cmd, params, {
cwd: Constants.WORK_PATH,
env: {
PATH:
process.env.PATH +
(process.platform == "darwin" ? ":/usr/local/bin" : ";/usr/local/bin"),
},
});
if (rt.status == null || rt.status != 0) {
Utils.log(
"spawnSync=" + (rt.status == null ? rt.signal : rt.status.toString())
);
}

static getRelativePath(fullpath, uuid) {
// let path = Editor.assetdb.mountInfoByUuid(uuid).path;
// return fullpath.substring(path.length);

return Editor.assetdb.mountInfoByUuid(uuid);
if (rt.error) {
Utils.log(rt.error);
}
return rt.status;
}

// lua project includes config.json
static isLuaProject(dir) {
// project created by console
let cocos2dx_path = Path.join(dir, "frameworks/cocos2d-x");
if (Fs.existsSync(cocos2dx_path)) return true;

// cocos2d-x internal lua tests
let app_delegate_path = Path.join(dir, "project/Classes/AppDelegate.cpp");
if (Fs.existsSync(app_delegate_path)) return true;

return false;
}

static getRelativePath(fullpath, uuid) {
// let path = Editor.assetdb.mountInfoByUuid(uuid).path;
// return fullpath.substring(path.length);

return Editor.assetdb.mountInfoByUuid(uuid);
}

// should be invoked in renderer process
static getAssetsInfo(cb) {
Editor.remote.assetdb.queryMetas("db://**/*", "", function (
err,
metaInfos
) {
let uuidmaps = {};

for (let i = 0, len = metaInfos.length; i < len; ++i) {
let meta = metaInfos[i];
let type = meta.assetType();
if (type === "folder" || type === "javascript") continue;

let uuid = meta.uuid;
let path = null;
if (meta && !meta.useRawfile()) {
path = Editor.remote.assetdb._uuidToImportPathNoExt(uuid);
path += ".json";
}

// should be invoked in renderer process
static getAssetsInfo(cb) {
Editor.remote.assetdb.queryMetas('db://**/*', '', function(err, metaInfos) {
let uuidmaps = {};

for (let i = 0, len = metaInfos.length; i < len; ++i) {
let meta = metaInfos[i];
let type = meta.assetType();
if (type === 'folder' || type === 'javascript')
continue;
if (!path) path = Editor.remote.assetdb.uuidToFspath(uuid);

let uuid = meta.uuid;
let path = null;
if (meta && !meta.useRawfile()) {
path = Editor.remote.assetdb._uuidToImportPathNoExt(uuid);
path += '.json';
}
let url = path.replace(/\\/g, "/");

if (!path)
path = Editor.remote.assetdb.uuidToFspath(uuid);
uuidmaps[uuid] = url;
}

let url = path.replace(/\\/g, '/');
cb(uuidmaps);
});
}

uuidmaps[uuid] = url;
}
static replaceExt(path, ext) {
return path.substr(0, path.lastIndexOf(".")) + ext;
}

cb(uuidmaps);
})
}
static recordBuild() {
Utils.initAnalytics(function (analytics) {
analytics.CAEvent.onEvent({ eventName: "build" });
});
}

static replaceExt(path, ext) {
return (path.substr(0, path.lastIndexOf(".")) + ext);
static initAnalytics(callback) {
if (Utils._isAnalyticsInitialized()) {
callback(analytics);
return;
}

static recordBuild() {
Utils.initAnalytics(function(analytics){
analytics.CAEvent.onEvent({ eventName: 'build' });
var src = "https://analytics.cocos.com/assets/js/cocosAnalytics.min.js";
var script = document.createElement("script");
script.onload = function () {
document.head.removeChild(script);

analytics = cocosAnalytics;
if (typeof analytics !== "undefined") {
analytics.init({
appID: "630639001",
appSecret: "a2d8adf595006f7a6af5f9b7e66a31d7",
channel: "creator",
version: Constants.VERDION,
});
}

static initAnalytics(callback) {
if (Utils._isAnalyticsInitialized()) {
callback(analytics);
return;
}

var src = "https://analytics.cocos.com/assets/js/cocosAnalytics.min.js";
var script = document.createElement('script');
script.onload = function () {
document.head.removeChild(script);

analytics = cocosAnalytics;
if (typeof(analytics) !== 'undefined') {
analytics.init({
appID: '630639001',
appSecret: 'a2d8adf595006f7a6af5f9b7e66a31d7',
channel: 'creator',
version: Constants.VERDION
});
// analytics.enableDebug(true);
analytics.CAAccount.loginStart();
analytics.CAAccount.loginSuccess({'userID': 'creator_for_cpp'});

callback(analytics);
}
};
script.onerror = function () {
document.head.removeChild(script);
};
script.src = src;
document.head.appendChild(script);
}

static _isAnalyticsInitialized() {
return typeof(analytics) !== 'undefined';
}
// analytics.enableDebug(true);
analytics.CAAccount.loginStart();
analytics.CAAccount.loginSuccess({ userID: "creator_for_cpp" });

callback(analytics);
}
};
script.onerror = function () {
document.head.removeChild(script);
};
script.src = src;
document.head.appendChild(script);
}

static _isAnalyticsInitialized() {
return typeof analytics !== "undefined";
}

// return file list ends with `exts` in dir
static _getFilesWithExt(dir, exts, recursive) {
let foundFiles = [];

const files = Fs.readdirSync(dir);
files.forEach((f) => {
let fullpath = Path.join(dir, f);
let ext = Path.extname(f);
if (exts.includes(ext)) foundFiles.push(fullpath);

if (recursive) {
let stats = Fs.lstatSync(fullpath);
if (stats.isDirectory())
foundFiles = foundFiles.concat(
this._getFilesWithExt(fullpath, exts, recursive)
);
}
});
return foundFiles;
}
}

module.exports = Utils;
Original file line number Diff line number Diff line change
@@ -35,8 +35,8 @@ class WorkerBase {
function registerWorker(workerClass, runEvent) {
Electron.ipcRenderer.on('creator-luacpp-support:' + runEvent, (event, state, opts) => {
let worker = new workerClass(opts);
worker.run(state, () => {
event.reply();
worker.run(state, (err) => {
event.reply(err);
});
});
}
Original file line number Diff line number Diff line change
@@ -18,8 +18,12 @@ class Button extends Node {
this._properties.ignoreContentAdaptWithSize = false;

// normal sprite: get from sprite component
if (spr_component && spr_component._spriteFrame)
this._properties.spriteFrameName = get_sprite_frame_name_by_uuid(spr_component._spriteFrame.__uuid__);
if (spr_component && spr_component._spriteFrame) {
let name = get_sprite_frame_name_by_uuid(spr_component._spriteFrame.__uuid__);
if (name) {
this._properties.spriteFrameName = name;
}
}

// transition
let transition = but_component.transition;
Rate limit · GitHub

Access has been restricted

You have triggered a rate limit.

Please wait a few minutes before you try again;
in some cases this may take up to an hour.

0 comments on commit 3a06f45

Please sign in to comment.