mirror of
https://github.com/cocos/cocos4.git
synced 2026-12-01 15:52:40 +08:00
Merge pull request #1734 from jareguo/temp2
remove unused code for moduleConfig.json
This commit is contained in:
@@ -64,11 +64,9 @@ cc._gameDiv = null;
|
||||
require('./cocos2d/core/utils');
|
||||
require('./cocos2d/core/platform/CCSys');
|
||||
|
||||
// INIT ENGINE
|
||||
|
||||
(function () {
|
||||
|
||||
var _jsAddedCache = {}, //cache for js and module that has added into jsList to be loaded.
|
||||
_engineInitCalled = false,
|
||||
var _engineInitCalled = false,
|
||||
_engineLoadedCallback = null;
|
||||
|
||||
cc._engineLoaded = false;
|
||||
@@ -105,26 +103,6 @@ function _determineRenderType(config) {
|
||||
}
|
||||
}
|
||||
|
||||
function _getJsListOfModule(moduleMap, moduleName, dir) {
|
||||
if (_jsAddedCache[moduleName]) return null;
|
||||
dir = dir || "";
|
||||
var jsList = [];
|
||||
var tempList = moduleMap[moduleName];
|
||||
if (!tempList) throw new Error("can not find module [" + moduleName + "]");
|
||||
var ccPath = cc.path;
|
||||
for (var i = 0, li = tempList.length; i < li; i++) {
|
||||
var item = tempList[i];
|
||||
if (_jsAddedCache[item]) continue;
|
||||
var extname = ccPath.extname(item);
|
||||
if (!extname) {
|
||||
var arr = _getJsListOfModule(moduleMap, item, dir);
|
||||
if (arr) jsList = jsList.concat(arr);
|
||||
} else if (extname.toLowerCase() === ".js") jsList.push(ccPath.join(dir, item));
|
||||
_jsAddedCache[item] = 1;
|
||||
}
|
||||
return jsList;
|
||||
}
|
||||
|
||||
function _afterEngineLoaded() {
|
||||
cc._engineLoaded = true;
|
||||
if (CC_EDITOR) {
|
||||
@@ -136,37 +114,9 @@ function _afterEngineLoaded() {
|
||||
if (_engineLoadedCallback) _engineLoadedCallback();
|
||||
}
|
||||
|
||||
function _load(config) {
|
||||
var CONFIG_KEY = cc.game.CONFIG_KEY, engineDir = config[CONFIG_KEY.engineDir], loader = cc.loader;
|
||||
|
||||
if (cc._Class) {
|
||||
// Single file loaded
|
||||
_afterEngineLoaded();
|
||||
} else {
|
||||
// Load cocos modules
|
||||
var ccModulesPath = cc.path.join(engineDir, "moduleConfig.json");
|
||||
loader.load(ccModulesPath, function (err, modulesJson) {
|
||||
if (err) throw new Error(err);
|
||||
var modules = config["modules"] || [];
|
||||
var moduleMap = modulesJson["module"];
|
||||
var jsList = [];
|
||||
if (cc.sys.capabilities["opengl"] && modules.indexOf("base4webgl") < 0) modules.splice(0, 0, "base4webgl");
|
||||
else if (modules.indexOf("core") < 0) modules.splice(0, 0, "core");
|
||||
for (var i = 0, li = modules.length; i < li; i++) {
|
||||
var arr = _getJsListOfModule(moduleMap, modules[i], engineDir);
|
||||
if (arr) jsList = jsList.concat(arr);
|
||||
}
|
||||
loader.load(jsList, function (err) {
|
||||
if (err) throw new Error(JSON.stringify(err));
|
||||
_afterEngineLoaded();
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function _windowLoaded() {
|
||||
function _windowLoaded () {
|
||||
window.removeEventListener('load', _windowLoaded, false);
|
||||
_load(cc.game.config);
|
||||
_afterEngineLoaded();
|
||||
}
|
||||
|
||||
cc.initEngine = function (config, cb) {
|
||||
@@ -193,8 +143,6 @@ cc.initEngine = function (config, cb) {
|
||||
|
||||
_determineRenderType(config);
|
||||
|
||||
document.body ? _load(config) : window.addEventListener('load', _windowLoaded, false);
|
||||
document.body ? _afterEngineLoaded() : window.addEventListener('load', _windowLoaded, false);
|
||||
_engineInitCalled = true;
|
||||
};
|
||||
|
||||
})();
|
||||
|
||||
@@ -89,7 +89,7 @@ var game = {
|
||||
CONFIG_KEY: {
|
||||
width: "width",
|
||||
height: "height",
|
||||
engineDir: "engineDir",
|
||||
// engineDir: "engineDir",
|
||||
debugMode: "debugMode",
|
||||
exposeClassName: "exposeClassName",
|
||||
showFPS: "showFPS",
|
||||
@@ -611,7 +611,7 @@ var game = {
|
||||
config[CONFIG_KEY.registerSystemEvent] = true;
|
||||
}
|
||||
config[CONFIG_KEY.showFPS] = (CONFIG_KEY.showFPS in config) ? (!!config[CONFIG_KEY.showFPS]) : true;
|
||||
config[CONFIG_KEY.engineDir] = config[CONFIG_KEY.engineDir] || 'frameworks/cocos2d-html5';
|
||||
// config[CONFIG_KEY.engineDir] = config[CONFIG_KEY.engineDir] || 'frameworks/cocos2d-html5';
|
||||
|
||||
// Scene parser
|
||||
this._sceneInfos = config[CONFIG_KEY.scenes] || [];
|
||||
|
||||
+2
-2
@@ -72,7 +72,7 @@ cc.game = {
|
||||
CONFIG_KEY: {
|
||||
width: 'width',
|
||||
height: 'height',
|
||||
engineDir: 'engineDir',
|
||||
// engineDir: 'engineDir',
|
||||
modules: 'modules',
|
||||
debugMode: 'debugMode',
|
||||
showFPS: 'showFPS',
|
||||
@@ -299,7 +299,7 @@ cc.game = {
|
||||
config[CONFIG_KEY.renderMode] = 0;
|
||||
}
|
||||
config[CONFIG_KEY.showFPS] = (CONFIG_KEY.showFPS in config) ? (!!config[CONFIG_KEY.showFPS]) : true;
|
||||
config[CONFIG_KEY.engineDir] = config[CONFIG_KEY.engineDir] || 'frameworks/cocos2d-html5';
|
||||
// config[CONFIG_KEY.engineDir] = config[CONFIG_KEY.engineDir] || 'frameworks/cocos2d-html5';
|
||||
|
||||
// Group List and Collide Map
|
||||
this.groupList = config.groupList || [];
|
||||
|
||||
@@ -43,6 +43,7 @@
|
||||
"gulp-util": "3.0.6",
|
||||
"jshint-stylish": "2.1.0",
|
||||
"multipipe": "0.3.0",
|
||||
"persistify": "^1.1.1",
|
||||
"require-dir": "0.3.0",
|
||||
"uglify-js-harmony": "2.7.7",
|
||||
"vinyl": "1.1.0",
|
||||
|
||||
@@ -56,7 +56,7 @@
|
||||
// 2 - Forced to use WebGL renderer, but this will be ignored on mobile browsers
|
||||
|
||||
"engineDir" : "../../frameworks/cocos2d-html5/",
|
||||
// In debug mode, if you use the whole engine to develop your game, you should specify its relative path with "engineDir",
|
||||
// (Deprecated) In debug mode, if you use the whole engine to develop your game, you should specify its relative path with "engineDir",
|
||||
// but if you are using a single engine file, you can ignore it.
|
||||
|
||||
"modules" : ["cocos2d", "extensions", "external"],
|
||||
|
||||
Reference in New Issue
Block a user