Skip to content

Commit

Permalink
upgrade to 5.2.24
Browse files Browse the repository at this point in the history
  • Loading branch information
runinspring committed Jul 24, 2019
1 parent 982314a commit 8cf1f46
Show file tree
Hide file tree
Showing 16 changed files with 962 additions and 12 deletions.
4 changes: 2 additions & 2 deletions CoreExample/egretProperties.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,6 @@
"path": "${EGRET_DEFAULT}"
}
],
"engineVersion": "5.2.13",
"compilerVersion": "5.2.13"
"engineVersion": "5.2.24",
"compilerVersion": "5.2.24"
}
23 changes: 19 additions & 4 deletions CoreExample/scripts/api.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -282,9 +282,11 @@ declare module 'built-in' {
/**
* 是否输出转换过程
*/
verbose?: boolean


verbose?: boolean,
/**
* 其他传递的消息参数
*/
info?:any
}

/**
Expand Down Expand Up @@ -363,20 +365,30 @@ declare module 'built-in' {

/**
* 是否输出日志
* Whether to output the log
*/
verbose?: boolean

/**
* 采用何种 hash 算法,目前暂时只支持 crc32
* What hash algorithm is used, currently only crc32 is supported
*/
hash?: "crc32"


/**
* 设置匹配规则,将指定文件进行改名
* 该参数是个数组,允许设置多个匹配规则
* Set up matching rules to copy specified files to other folders
* This parameter is an array that allows multiple matching rules to be set
*/
matchers: Matcher[]

/**
* 回调函数,返回值里包括文件的一些信息
* The callback function, return value includes some information about the file
*/
callback?: Function
}


Expand All @@ -391,12 +403,15 @@ declare module 'built-in' {

/**
* 是否输出日志
* Whether to output the log
*/
verbose?: boolean

/**
* 设置匹配规则,将指定文件拷贝至其他文件夹
* 该参数是个数组,允许设置多个匹配规则
* Set up matching rules to copy specified files to other folders
* This parameter is an array that allows multiple matching rules to be set
*/
matchers: Matcher[]
}
Expand Down Expand Up @@ -426,4 +441,4 @@ declare module 'built-in' {

constructor(option?: MergeEuiJsonPluginOptions);
}
}
}
56 changes: 56 additions & 0 deletions CoreExample/scripts/config.oppogame.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/// 阅读 api.d.ts 查看文档
///<reference path="api.d.ts"/>

import * as path from 'path';
import { UglifyPlugin, CompilePlugin, ManifestPlugin, ExmlPlugin, ResSplitPlugin, CleanPlugin } from 'built-in';
import { OppogamePlugin } from './oppogame/oppogame';
import * as defaultConfig from './config';

const config: ResourceManagerConfig = {

buildConfig: (params) => {

const { target, command, projectName, version } = params;
const outputDir = `../${projectName}_oppogame`;
if (command == 'build') {
return {
outputDir,
commands: [
new CleanPlugin({ matchers: ["js", "resource"] }),
new CompilePlugin({ libraryType: "debug", defines: { DEBUG: true, RELEASE: false } }),
new ExmlPlugin('commonjs'), // 非 EUI 项目关闭此设置
new OppogamePlugin(),
new ManifestPlugin({ output: 'manifest.js' })
]
}
}
else if (command == 'publish') {
return {
outputDir,
commands: [
new CleanPlugin({ matchers: ["js", "resource"] }),
new CompilePlugin({ libraryType: "release", defines: { DEBUG: false, RELEASE: true } }),
new ExmlPlugin('commonjs'), // 非 EUI 项目关闭此设置
new OppogamePlugin(),
new UglifyPlugin([{
sources: ["main.js"],
target: "main.min.js"
}
]),
new ManifestPlugin({ output: 'manifest.js' })
]
}
}
else {
throw `unknown command : ${params.command}`;
}
},

mergeSelector: defaultConfig.mergeSelector,

typeSelector: defaultConfig.typeSelector
}



export = config;
56 changes: 56 additions & 0 deletions CoreExample/scripts/config.qgame.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/// 阅读 api.d.ts 查看文档
///<reference path="api.d.ts"/>

import * as path from 'path';
import { UglifyPlugin, CompilePlugin, ManifestPlugin, ExmlPlugin, ResSplitPlugin, CleanPlugin } from 'built-in';
import { MiqgamePlugin } from './qgame/qgame';
import * as defaultConfig from './config';

const config: ResourceManagerConfig = {

buildConfig: (params) => {

const { target, command, projectName, version } = params;
const outputDir = `../${projectName}_qgame`;
if (command == 'build') {
return {
outputDir,
commands: [
new CleanPlugin({ matchers: ["js", "resource"] }),
new CompilePlugin({ libraryType: "debug", defines: { DEBUG: true, RELEASE: false } }),
new ExmlPlugin('commonjs'), // 非 EUI 项目关闭此设置
new MiqgamePlugin(),
new ManifestPlugin({ output: 'manifest.js' })
]
}
}
else if (command == 'publish') {
return {
outputDir,
commands: [
new CleanPlugin({ matchers: ["js", "resource"] }),
new CompilePlugin({ libraryType: "release", defines: { DEBUG: false, RELEASE: true } }),
new ExmlPlugin('commonjs'), // 非 EUI 项目关闭此设置
new MiqgamePlugin(),
new UglifyPlugin([{
sources: ["main.js"],
target: "main.min.js"
}
]),
new ManifestPlugin({ output: 'manifest.js' })
]
}
}
else {
throw `unknown command : ${params.command}`;
}
},

mergeSelector: defaultConfig.mergeSelector,

typeSelector: defaultConfig.typeSelector
}



export = config;
56 changes: 56 additions & 0 deletions CoreExample/scripts/config.vivogame.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/// 阅读 api.d.ts 查看文档
///<reference path="api.d.ts"/>

import * as path from 'path';
import { UglifyPlugin, CompilePlugin, ManifestPlugin, ExmlPlugin, ResSplitPlugin, CleanPlugin } from 'built-in';
import { VivogamePlugin } from './vivogame/vivogame';
import * as defaultConfig from './config';

const config: ResourceManagerConfig = {

buildConfig: (params) => {

const { target, command, projectName, version } = params;
const outputDir = `../${projectName}_vivogame/src`;
if (command == 'build') {
return {
outputDir,
commands: [
new CleanPlugin({ matchers: ["../engine", "resource"] }),
new CompilePlugin({ libraryType: "debug", defines: { DEBUG: true, RELEASE: false } }),
new ExmlPlugin('commonjs'), // 非 EUI 项目关闭此设置
new VivogamePlugin(),
new ManifestPlugin({ output: 'manifest.js', info: { target: 'vivogame' } })
]
}
}
else if (command == 'publish') {
return {
outputDir,
commands: [
new CleanPlugin({ matchers: ["../engine", "resource"] }),
new CompilePlugin({ libraryType: "release", defines: { DEBUG: false, RELEASE: true } }),
new ExmlPlugin('commonjs'), // 非 EUI 项目关闭此设置
new VivogamePlugin(),
new UglifyPlugin([{
sources: ["main.js"],
target: "main.min.js"
}
]),
new ManifestPlugin({ output: 'manifest.js', info: { target: 'vivogame' } })
]
}
}
else {
throw `unknown command : ${params.command}`;
}
},

mergeSelector: defaultConfig.mergeSelector,

typeSelector: defaultConfig.typeSelector
}



export = config;
90 changes: 90 additions & 0 deletions CoreExample/scripts/oppogame/oppogame.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
import * as fs from 'fs';
import * as path from 'path';
export class OppogamePlugin implements plugins.Command {

constructor() {
}
async onFile(file: plugins.File) {
if (file.extname == '.js') {
const filename = file.origin;
if (filename == "libs/modules/promise/promise.js" || filename == 'libs/modules/promise/promise.min.js') {
return null;
}
if (filename == 'libs/modules/egret/egret.js' || filename == 'libs/modules/egret/egret.min.js') {
let content = file.contents.toString();
content += `;window.egret = egret;`;
content = content.replace(/definition = __global/, "definition = window");
file.contents = new Buffer(content);
}
else {
let content = file.contents.toString();
if (
filename == "libs/modules/res/res.js" ||
filename == 'libs/modules/res/res.min.js' ||
filename == 'libs/modules/assetsmanager/assetsmanager.min.js' ||
filename == 'libs/modules/assetsmanager/assetsmanager.js'
) {
content += ";window.RES = RES;"
}
if (filename == "libs/modules/eui/eui.js" || filename == 'libs/modules/eui/eui.min.js') {
content += ";window.eui = eui;"
if(filename == "libs/modules/eui/eui.js"){
content = content.replace("function getRepeatedIds","window.getRepeatedIds=function getRepeatedIds");
content = content.replace("function getIds","window.getIds=function getIds");
content = content.replace("function toXMLString","window.toXMLString=function toXMLString");
content = content.replace("function checkDeclarations","window.checkDeclarations=function checkDeclarations");
content = content.replace("function getPropertyStr","window.getPropertyStr=function getPropertyStr");
}
}
if (filename == 'libs/modules/dragonBones/dragonBones.js' || filename == 'libs/modules/dragonBones/dragonBones.min.js') {
content += ';window.dragonBones = dragonBones';
}
content = "var egret = window.egret;" + content;

if (filename == 'main.js') {
content += "\n;window.Main = Main;"
}
file.contents = new Buffer(content);
}
}
return file;
}
async onFinish(pluginContext: plugins.CommandContext) {
//同步 index.html 配置到 game.js
const gameJSPath = path.join(pluginContext.outputDir, "main.js");
if(!fs.existsSync(gameJSPath)) {
console.log(`${gameJSPath}不存在,请先使用 Launcher 发布Oppo快游戏`);
return;
}
let gameJSContent = fs.readFileSync(gameJSPath, { encoding: "utf8" });
const projectConfig = pluginContext.buildConfig.projectConfig;
const optionStr =
`entryClassName: ${projectConfig.entryClassName},\n\t\t` +
`orientation: ${projectConfig.orientation},\n\t\t` +
`frameRate: ${projectConfig.frameRate},\n\t\t` +
`scaleMode: ${projectConfig.scaleMode},\n\t\t` +
`contentWidth: ${projectConfig.contentWidth},\n\t\t` +
`contentHeight: ${projectConfig.contentHeight},\n\t\t` +
`showFPS: ${projectConfig.showFPS},\n\t\t` +
`fpsStyles: ${projectConfig.fpsStyles},\n\t\t` +
`showLog: ${projectConfig.showLog},\n\t\t` +
`maxTouches: ${projectConfig.maxTouches},`;
const reg = /\/\/----auto option start----[\s\S]*\/\/----auto option end----/;
const replaceStr = '\/\/----auto option start----\n\t\t' + optionStr + '\n\t\t\/\/----auto option end----';
gameJSContent = gameJSContent.replace(reg, replaceStr);
fs.writeFileSync(gameJSPath, gameJSContent);

//修改横竖屏
let orientation;
if (projectConfig.orientation == '"landscape"') {
orientation = "landscape";
}
else {
orientation = "portrait";
}
const gameJSONPath = path.join(pluginContext.outputDir, "manifest.json");
let gameJSONContent = JSON.parse(fs.readFileSync(gameJSONPath, { encoding: "utf8" }));
gameJSONContent.orientation = orientation;
fs.writeFileSync(gameJSONPath, JSON.stringify(gameJSONContent, null, "\t"));
}
}
Loading

0 comments on commit 8cf1f46

Please sign in to comment.