mirror of
https://github.com/cocos/cocos4.git
synced 2026-12-03 01:12:42 +08:00
Merge pull request #2326 from jareguo/master
register engine version for both web and jsb
This commit is contained in:
@@ -24,16 +24,6 @@
|
||||
THE SOFTWARE.
|
||||
****************************************************************************/
|
||||
|
||||
/**
|
||||
* The current version of Cocos2d being used.<br/>
|
||||
* Please DO NOT remove this String, it is an important flag for bug tracking.<br/>
|
||||
* If you post a bug to forum, please attach this flag.
|
||||
* @property {String} ENGINE_VERSION
|
||||
*/
|
||||
var engineVersion;
|
||||
engineVersion = '1.6.0';
|
||||
window['CocosEngine'] = cc.ENGINE_VERSION = engineVersion;
|
||||
|
||||
/**
|
||||
* @property {CanvasRenderingContext2D|WebGLRenderingContext} _renderContext - main Canvas 2D/3D Context of game engine
|
||||
* @private
|
||||
@@ -97,12 +87,7 @@ function _determineRenderType(config) {
|
||||
|
||||
function _afterEngineLoaded() {
|
||||
cc._engineLoaded = true;
|
||||
if (CC_EDITOR) {
|
||||
Editor.log(cc.ENGINE_VERSION);
|
||||
}
|
||||
else {
|
||||
console.log(cc.ENGINE_VERSION);
|
||||
}
|
||||
console.log('Cocos Creator v' + cc.ENGINE_VERSION);
|
||||
if (_engineLoadedCallback) _engineLoadedCallback();
|
||||
}
|
||||
|
||||
|
||||
@@ -1949,7 +1949,7 @@ cc.defineGetterSetter(cc.macro, 'ENABLE_CULLING',
|
||||
cc.renderer.childrenOrderDirty = true;
|
||||
}
|
||||
}
|
||||
)
|
||||
);
|
||||
|
||||
/**
|
||||
* !#en
|
||||
|
||||
@@ -24,117 +24,6 @@
|
||||
THE SOFTWARE.
|
||||
****************************************************************************/
|
||||
|
||||
// MACROS
|
||||
|
||||
/**
|
||||
* !#zh
|
||||
* 这里是一些用来判断执行环境的宏,这些宏都是全局变量,直接访问即可。<br>
|
||||
* 在项目构建时,这些宏将会被预处理并根据构建的平台剔除不需要的代码,例如
|
||||
*
|
||||
* if (CC_DEBUG) {
|
||||
* cc.log('debug');
|
||||
* }
|
||||
* else {
|
||||
* cc.log('release');
|
||||
* }
|
||||
*
|
||||
* 在构建后会只剩下
|
||||
*
|
||||
* cc.log('release');
|
||||
*
|
||||
* (好棒棒)<br>
|
||||
* <br>
|
||||
* 如需判断脚本是否运行于指定平台,可以用如下表达式:
|
||||
*
|
||||
* {
|
||||
* "编辑器": CC_EDITOR,
|
||||
* "编辑器 或 预览": CC_DEV,
|
||||
* "编辑器 或 预览 或 构建调试": CC_DEBUG,
|
||||
* "网页预览": CC_PREVIEW && !CC_JSB,
|
||||
* "模拟器预览": CC_PREVIEW && CC_JSB,
|
||||
* "构建调试": CC_BUILD && CC_DEBUG,
|
||||
* "构建发行": CC_BUILD && !CC_DEBUG,
|
||||
* }
|
||||
*
|
||||
* !#en
|
||||
* Here are some of the macro used to determine the execution environment, these macros are global variables, can be accessed directly.<br>
|
||||
* When the project is built, these macros will be preprocessed and discard unreachable code based on the built platform, for example:
|
||||
*
|
||||
* if (CC_DEBUG) {
|
||||
* cc.log('debug');
|
||||
* }
|
||||
* else {
|
||||
* cc.log('release');
|
||||
* }
|
||||
*
|
||||
* After build will become:
|
||||
*
|
||||
* cc.log('release');
|
||||
*
|
||||
* <br>
|
||||
* To determine whether the script is running on the specified platform, you can use the following expression:
|
||||
*
|
||||
* {
|
||||
* "editor": CC_EDITOR,
|
||||
* "editor or preview": CC_DEV,
|
||||
* "editor or preview or build in debug mode": CC_DEBUG,
|
||||
* "web preview": CC_PREVIEW && !CC_JSB,
|
||||
* "simulator preview": CC_PREVIEW && CC_JSB,
|
||||
* "build in debug mode": CC_BUILD && CC_DEBUG,
|
||||
* "build in release mode": CC_BUILD && !CC_DEBUG,
|
||||
* }
|
||||
*
|
||||
* @module GLOBAL-MACROS
|
||||
*/
|
||||
/**
|
||||
* @property {Boolean} CC_EDITOR - Running in the editor.
|
||||
*/
|
||||
/**
|
||||
* @property {Boolean} CC_PREVIEW - Preview in browser or simulator.
|
||||
*/
|
||||
/**
|
||||
* @property {Boolean} CC_DEV - Running in the editor or preview.
|
||||
*/
|
||||
/**
|
||||
* @property {Boolean} CC_DEBUG - Running in the editor or preview, or build in debug mode.
|
||||
*/
|
||||
/**
|
||||
* @property {Boolean} CC_BUILD - Running in published project.
|
||||
*/
|
||||
/**
|
||||
* @property {Boolean} CC_JSB - Running in native platform (mobile app, desktop app, or simulator).
|
||||
*/
|
||||
/**
|
||||
* @property {Boolean} CC_TEST - Running in the engine's unit test.
|
||||
*/
|
||||
/**
|
||||
* @property {Boolean} CC_WECHATGAME - Running in the Wechat's mini game.
|
||||
*/
|
||||
|
||||
// window may be undefined when first load engine from editor
|
||||
var _global = typeof window === 'undefined' ? global : window;
|
||||
function defineMacro (name, defaultValue) {
|
||||
// if "global_defs" not preprocessed by uglify, just declare them globally,
|
||||
// this may happened in release version's preview page.
|
||||
// (use evaled code to prevent mangle by uglify)
|
||||
if (typeof _global[name] === 'undefined') {
|
||||
_global[name] = defaultValue;
|
||||
}
|
||||
}
|
||||
function defined (name) {
|
||||
return typeof _global[name] === 'object';
|
||||
}
|
||||
|
||||
defineMacro('CC_TEST', defined('tap') || defined('QUnit'));
|
||||
defineMacro('CC_EDITOR', defined('Editor') && defined('process') && ('electron' in process.versions));
|
||||
defineMacro('CC_PREVIEW', !CC_EDITOR);
|
||||
defineMacro('CC_DEV', true); // (CC_EDITOR && !CC_BUILD) || CC_PREVIEW || CC_TEST
|
||||
defineMacro('CC_DEBUG', true); // CC_DEV || Debug Build
|
||||
defineMacro('CC_JSB', defined('jsb'));
|
||||
defineMacro('CC_BUILD', false);
|
||||
defineMacro('CC_WECHATGAME', false);
|
||||
defineMacro('CC_SUPPORT_JIT', !CC_WECHATGAME);
|
||||
|
||||
// PREDEFINE
|
||||
|
||||
/**
|
||||
@@ -146,22 +35,12 @@ defineMacro('CC_SUPPORT_JIT', !CC_WECHATGAME);
|
||||
* @main cc
|
||||
*/
|
||||
cc = {};
|
||||
|
||||
// The namespace for original nodes rendering in scene graph.
|
||||
_ccsg = {};
|
||||
|
||||
if (CC_DEV) {
|
||||
/**
|
||||
* contains internal apis for unit tests
|
||||
* @expose
|
||||
*/
|
||||
cc._Test = {};
|
||||
}
|
||||
|
||||
require('./predefine');
|
||||
require('./CCDebugger');
|
||||
|
||||
// polyfills
|
||||
/* require('./polyfill/bind'); */
|
||||
require('./polyfill/string');
|
||||
require('./polyfill/misc');
|
||||
require('./polyfill/array');
|
||||
@@ -172,10 +51,7 @@ if (!(CC_EDITOR && Editor.isMainProcess)) {
|
||||
require('./cocos2d/kazmath');
|
||||
require('./cocos2d/core/predefine');
|
||||
|
||||
ccs = {};
|
||||
cp = {};
|
||||
|
||||
// LOAD COCOS2D ENGINE CODE
|
||||
// LOAD ENGINE CODE
|
||||
|
||||
if (!(CC_EDITOR && Editor.isMainProcess)) {
|
||||
require('./cocos2d/shaders');
|
||||
@@ -183,7 +59,7 @@ if (!(CC_EDITOR && Editor.isMainProcess)) {
|
||||
require('./cocos2d');
|
||||
}
|
||||
|
||||
// LOAD EXTENDS FOR CREATOR
|
||||
// LOAD EXTENDS
|
||||
|
||||
require('./extends');
|
||||
|
||||
|
||||
+1
-30
@@ -26,41 +26,12 @@
|
||||
|
||||
'use strict';
|
||||
|
||||
function defineMacro (name, defaultValue) {
|
||||
// if "global_defs" not preprocessed by uglify, just declare them globally,
|
||||
// this may happened in release version's preview page.
|
||||
// (use evaled code to prevent mangle by uglify)
|
||||
if (typeof window[name] === 'undefined') {
|
||||
window[name] = defaultValue;
|
||||
}
|
||||
}
|
||||
function defined (name) {
|
||||
return typeof window[name] === 'object';
|
||||
}
|
||||
|
||||
defineMacro('CC_TEST', defined('tap') || defined('QUnit'));
|
||||
defineMacro('CC_EDITOR', defined('Editor') && defined('process') && ('electron' in process.versions));
|
||||
defineMacro('CC_PREVIEW', !CC_EDITOR);
|
||||
defineMacro('CC_DEV', true); // (CC_EDITOR && !CC_BUILD) || CC_PREVIEW || CC_TEST
|
||||
defineMacro('CC_DEBUG', true); // CC_DEV || Debug Build
|
||||
defineMacro('CC_JSB', defined('jsb'));
|
||||
defineMacro('CC_BUILD', false);
|
||||
defineMacro('CC_WECHATGAME', false);
|
||||
defineMacro('CC_SUPPORT_JIT', !CC_WECHATGAME);
|
||||
|
||||
require('../predefine');
|
||||
|
||||
if (!cc.ClassManager) {
|
||||
cc.ClassManager = window.ClassManager;
|
||||
}
|
||||
|
||||
if (CC_DEV) {
|
||||
/**
|
||||
* contains internal apis for unit tests
|
||||
* @expose
|
||||
*/
|
||||
cc._Test = {};
|
||||
}
|
||||
|
||||
// polyfills
|
||||
require('../polyfill/misc');
|
||||
// str.startswith isn't supported in JavaScriptCore which is shipped with iOS8.
|
||||
|
||||
+157
@@ -0,0 +1,157 @@
|
||||
/****************************************************************************
|
||||
Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
|
||||
|
||||
http://www.cocos.com
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated engine source code (the "Software"), a limited,
|
||||
worldwide, royalty-free, non-assignable, revocable and non-exclusive license
|
||||
to use Cocos Creator solely to develop games on your target platforms. You shall
|
||||
not use Cocos Creator software for developing other software or tools that's
|
||||
used for developing games. You are not granted to publish, distribute,
|
||||
sublicense, and/or sell copies of Cocos Creator.
|
||||
|
||||
The software or tools in this License Agreement are licensed, not sold.
|
||||
Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
****************************************************************************/
|
||||
|
||||
// MACROS
|
||||
|
||||
/**
|
||||
* !#zh
|
||||
* 这里是一些用来判断执行环境的宏,这些宏都是全局变量,直接访问即可。<br>
|
||||
* 在项目构建时,这些宏将会被预处理并根据构建的平台剔除不需要的代码,例如
|
||||
*
|
||||
* if (CC_DEBUG) {
|
||||
* cc.log('debug');
|
||||
* }
|
||||
* else {
|
||||
* cc.log('release');
|
||||
* }
|
||||
*
|
||||
* 在构建后会只剩下
|
||||
*
|
||||
* cc.log('release');
|
||||
*
|
||||
* (好棒棒)<br>
|
||||
* <br>
|
||||
* 如需判断脚本是否运行于指定平台,可以用如下表达式:
|
||||
*
|
||||
* {
|
||||
* "编辑器": CC_EDITOR,
|
||||
* "编辑器 或 预览": CC_DEV,
|
||||
* "编辑器 或 预览 或 构建调试": CC_DEBUG,
|
||||
* "网页预览": CC_PREVIEW && !CC_JSB,
|
||||
* "模拟器预览": CC_PREVIEW && CC_JSB,
|
||||
* "构建调试": CC_BUILD && CC_DEBUG,
|
||||
* "构建发行": CC_BUILD && !CC_DEBUG,
|
||||
* }
|
||||
*
|
||||
* !#en
|
||||
* Here are some of the macro used to determine the execution environment, these macros are global variables, can be accessed directly.<br>
|
||||
* When the project is built, these macros will be preprocessed and discard unreachable code based on the built platform, for example:
|
||||
*
|
||||
* if (CC_DEBUG) {
|
||||
* cc.log('debug');
|
||||
* }
|
||||
* else {
|
||||
* cc.log('release');
|
||||
* }
|
||||
*
|
||||
* After build will become:
|
||||
*
|
||||
* cc.log('release');
|
||||
*
|
||||
* <br>
|
||||
* To determine whether the script is running on the specified platform, you can use the following expression:
|
||||
*
|
||||
* {
|
||||
* "editor": CC_EDITOR,
|
||||
* "editor or preview": CC_DEV,
|
||||
* "editor or preview or build in debug mode": CC_DEBUG,
|
||||
* "web preview": CC_PREVIEW && !CC_JSB,
|
||||
* "simulator preview": CC_PREVIEW && CC_JSB,
|
||||
* "build in debug mode": CC_BUILD && CC_DEBUG,
|
||||
* "build in release mode": CC_BUILD && !CC_DEBUG,
|
||||
* }
|
||||
*
|
||||
* @module GLOBAL-MACROS
|
||||
*/
|
||||
/**
|
||||
* @property {Boolean} CC_EDITOR - Running in the editor.
|
||||
*/
|
||||
/**
|
||||
* @property {Boolean} CC_PREVIEW - Preview in browser or simulator.
|
||||
*/
|
||||
/**
|
||||
* @property {Boolean} CC_DEV - Running in the editor or preview.
|
||||
*/
|
||||
/**
|
||||
* @property {Boolean} CC_DEBUG - Running in the editor or preview, or build in debug mode.
|
||||
*/
|
||||
/**
|
||||
* @property {Boolean} CC_BUILD - Running in published project.
|
||||
*/
|
||||
/**
|
||||
* @property {Boolean} CC_JSB - Running in native platform (mobile app, desktop app, or simulator).
|
||||
*/
|
||||
/**
|
||||
* @property {Boolean} CC_TEST - Running in the engine's unit test.
|
||||
*/
|
||||
/**
|
||||
* @property {Boolean} CC_WECHATGAME - Running in the Wechat's mini game.
|
||||
*/
|
||||
|
||||
// window may be undefined when first load engine from editor
|
||||
var _global = typeof window === 'undefined' ? global : window;
|
||||
function defineMacro (name, defaultValue) {
|
||||
// if "global_defs" not preprocessed by uglify, just declare them globally,
|
||||
// this may happened in release version's preview page.
|
||||
if (typeof _global[name] === 'undefined') {
|
||||
_global[name] = defaultValue;
|
||||
}
|
||||
}
|
||||
function defined (name) {
|
||||
return typeof _global[name] === 'object';
|
||||
}
|
||||
|
||||
defineMacro('CC_TEST', defined('tap') || defined('QUnit'));
|
||||
defineMacro('CC_EDITOR', defined('Editor') && defined('process') && ('electron' in process.versions));
|
||||
defineMacro('CC_PREVIEW', !CC_EDITOR);
|
||||
defineMacro('CC_DEV', true); // (CC_EDITOR && !CC_BUILD) || CC_PREVIEW || CC_TEST
|
||||
defineMacro('CC_DEBUG', true); // CC_DEV || Debug Build
|
||||
defineMacro('CC_JSB', defined('jsb'));
|
||||
defineMacro('CC_BUILD', false);
|
||||
defineMacro('CC_WECHATGAME', false);
|
||||
defineMacro('CC_SUPPORT_JIT', !CC_WECHATGAME);
|
||||
|
||||
//
|
||||
|
||||
if (CC_DEV) {
|
||||
/**
|
||||
* contains internal apis for unit tests
|
||||
* @expose
|
||||
*/
|
||||
cc._Test = {};
|
||||
}
|
||||
|
||||
/**
|
||||
* @module cc
|
||||
*/
|
||||
|
||||
/**
|
||||
* The current version of Cocos2d being used.<br/>
|
||||
* Please DO NOT remove this String, it is an important flag for bug tracking.<br/>
|
||||
* If you post a bug to forum, please attach this flag.
|
||||
* @property {String} ENGINE_VERSION
|
||||
*/
|
||||
const engineVersion = '1.8.1';
|
||||
_global['CocosEngine'] = cc.ENGINE_VERSION = engineVersion;
|
||||
Reference in New Issue
Block a user