Skip to content

Commit 2ed8b81

Browse files
author
Mark Henderson
committed
Merge remote-tracking branch 'upstream/develop' into contantScaleFactorFixes
2 parents 26bf859 + 38bb006 commit 2ed8b81

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+7787
-1565
lines changed

CocosDenshion/SimpleAudioEngine.js

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,9 @@ cc.SimpleAudioEngine = cc.AudioEngine.extend(/** @lends cc.SimpleAudioEngine# */
385385
if (reclaim[i].ended) {
386386
au = reclaim[i];
387387
au.currentTime = 0;
388+
if (window.chrome){
389+
au.load();
390+
}
388391
break;
389392
}
390393
}
@@ -577,15 +580,15 @@ cc.SimpleAudioEngine = cc.AudioEngine.extend(/** @lends cc.SimpleAudioEngine# */
577580
if (!path) return;
578581
var keyname = this._getPathWithoutExt(path);
579582
if (this._effectList.hasOwnProperty(keyname)) {
580-
this.stopEffect(path);
581583
delete this._effectList[keyname];
582584
}
583585

584586
var au,pathName;
585587
for (var k in this._audioIDList) {
586588
au = this._audioIDList[k];
587589
pathName = this._getPathWithoutExt(au.src);
588-
if(pathName == keyname){
590+
if(pathName.indexOf(keyname) > -1){
591+
this.stopEffect(k);
589592
delete this._audioIDList[k];
590593
}
591594
}
@@ -602,7 +605,7 @@ cc.SimpleAudioEngine = cc.AudioEngine.extend(/** @lends cc.SimpleAudioEngine# */
602605
},
603606

604607
/**
605-
* search in this._supportedFormat if @param ext is there
608+
* search in this._supportedFormat if ext is there
606609
* @param {String} ext
607610
* @returns {Boolean}
608611
*/
@@ -633,8 +636,6 @@ cc.SimpleAudioEngine = cc.AudioEngine.extend(/** @lends cc.SimpleAudioEngine# */
633636
}
634637
});
635638

636-
637-
638639
/**
639640
* The entity stored in cc.WebAudioEngine, representing a sound object
640641
*/
@@ -734,7 +735,7 @@ cc.WebAudioEngine = cc.AudioEngine.extend(/** @lends cc.WebAudioEngine# */{
734735
},
735736

736737
/**
737-
* search in this._supportedFormat if @param ext is there
738+
* search in this._supportedFormat if ext is there
738739
* @param {String} ext
739740
* @returns {Boolean}
740741
*/
@@ -805,7 +806,7 @@ cc.WebAudioEngine = cc.AudioEngine.extend(/** @lends cc.WebAudioEngine# */{
805806

806807
/**
807808
* Init a new WebAudioSFX and play it, return this WebAudioSFX object
808-
* assuming that @param key exists in this._audioData
809+
* assuming that key exists in this._audioData
809810
* @param {String} key
810811
* @param {Boolean} loop Default value is false
811812
* @param {Number} volume 0.0 - 1.0, default value is 1.0
@@ -866,14 +867,16 @@ cc.WebAudioEngine = cc.AudioEngine.extend(/** @lends cc.WebAudioEngine# */{
866867
},
867868

868869
/**
869-
* According to the spec: dvcs.w3.org/hg/audio/raw-file/tip/webaudio/specification.html
870-
* const unsigned short UNSCHEDULED_STATE = 0;
871-
* const unsigned short SCHEDULED_STATE = 1;
872-
* const unsigned short PLAYING_STATE = 2; // this means it is playing
873-
* const unsigned short FINISHED_STATE = 3;
870+
* <p>
871+
* According to the spec: dvcs.w3.org/hg/audio/raw-file/tip/webaudio/specification.html <br/>
872+
* const unsigned short UNSCHEDULED_STATE = 0; <br/>
873+
* const unsigned short SCHEDULED_STATE = 1; <br/>
874+
* const unsigned short PLAYING_STATE = 2; // this means it is playing <br/>
875+
* const unsigned short FINISHED_STATE = 3; <br/>
874876
* However, the older specification doesn't include this property, such as this one: http://www.w3.org/2011/audio/drafts/2WD/Overview.html
877+
* </p>
875878
* @param {Object} sfxCache Assuming not null
876-
* @returns {Boolean} Whether @param sfxCache is playing or not
879+
* @returns {Boolean} Whether sfxCache is playing or not
877880
* @private
878881
*/
879882
_isSoundPlaying: function(sfxCache) {
@@ -1260,6 +1263,7 @@ cc.WebAudioEngine = cc.AudioEngine.extend(/** @lends cc.WebAudioEngine# */{
12601263
/**
12611264
* Used in resumeEffect() and resumeAllEffects()
12621265
* @param {Object} effectList A list of sounds, each sound may be playing/paused/finished
1266+
* @param {Number} volume
12631267
* @private
12641268
*/
12651269
_resumeSoundList: function(effectList, volume) {
@@ -1347,13 +1351,13 @@ cc.WebAudioEngine = cc.AudioEngine.extend(/** @lends cc.WebAudioEngine# */{
13471351
* cc.AudioEngine.getInstance().unloadEffect(EFFECT_FILE);
13481352
*/
13491353
unloadEffect: function(path) {
1350-
if (!path) {
1354+
if (!path)
13511355
return;
1352-
}
13531356

13541357
var keyName = this._getPathWithoutExt(path);
1355-
if (keyName in this._effects) {
1358+
if (this._effects.hasOwnProperty(keyName)) {
13561359
this.stopEffect(path);
1360+
delete this._effects[keyname];
13571361
}
13581362

13591363
if (keyName in this._audioData) {
@@ -1362,8 +1366,6 @@ cc.WebAudioEngine = cc.AudioEngine.extend(/** @lends cc.WebAudioEngine# */{
13621366
}
13631367
});
13641368

1365-
1366-
13671369
cc.AudioEngine._instance = null;
13681370

13691371
cc.AudioEngine.isMusicPlaying = false;

cocos2d/CCConfiguration.js

Lines changed: 141 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
THE SOFTWARE.
2525
****************************************************************************/
2626

27+
cc.ConfigurationType = {ConfigurationError:0, ConfigurationString:1, ConfigurationInt:2, ConfigurationDouble:3, ConfigurationBoolean:4};
28+
2729
/**
2830
* cc.Configuration contains some openGL variables
2931
* @class
@@ -40,6 +42,21 @@ cc.Configuration = cc.Class.extend(/** @lends cc.Configuration# */{
4042
_maxSamplesAllowed:0,
4143
_maxTextureUnits:0,
4244
_GlExtensions:"",
45+
_valueDict:null,
46+
47+
ctor: function () {
48+
this._maxTextureSize = 0;
49+
this._maxModelviewStackDepth = 0;
50+
this._supportsPVRTC = false;
51+
this._supportsNPOT = false;
52+
this._supportsBGRA8888 = false;
53+
this._supportsDiscardFramebuffer = false;
54+
this._supportsShareableVAO = false;
55+
this._maxSamplesAllowed = 0;
56+
this._maxTextureUnits = 0;
57+
this._GlExtensions = "";
58+
this._valueDict = {};
59+
},
4360

4461
/**
4562
* OpenGL Max texture size.
@@ -115,43 +132,150 @@ cc.Configuration = cc.Class.extend(/** @lends cc.Configuration# */{
115132
},
116133

117134
init:function () {
135+
var locValueDict = this._valueDict;
136+
locValueDict["cocos2d.x.version"] = cc.ENGINE_VERSION;
137+
locValueDict["cocos2d.x.compiled_with_profiler"] = false;
138+
locValueDict["cocos2d.x.compiled_with_gl_state_cache"] = cc.ENABLE_GL_STATE_CACHE;
139+
return true;
140+
},
141+
142+
/**
143+
* returns the value of a given key as a string. If the key is not found, it will return the default value
144+
* @param {String} key
145+
* @param {String} [default_value=null]
146+
* @returns {String}
147+
*/
148+
getCString:function(key, default_value){
149+
var locValueDict = this._valueDict;
150+
if(locValueDict.hasOwnProperty(key))
151+
return locValueDict[key];
152+
return default_value;
153+
},
154+
155+
/**
156+
* returns the value of a given key as a boolean. If the key is not found, it will return the default value
157+
* @param {string} key
158+
* @param {boolean|null} [default_value=false]
159+
* @returns {boolean}
160+
*/
161+
getBool: function(key, default_value){
162+
if(default_value == null)
163+
default_value = false;
164+
var locValueDict = this._valueDict;
165+
if(locValueDict.hasOwnProperty(key))
166+
return locValueDict[key];
167+
return default_value;
168+
},
169+
170+
/**
171+
* returns the value of a given key as a double. If the key is not found, it will return the default value
172+
* @param {string} key
173+
* @param {number} [default_value=0]
174+
* @returns {number}
175+
*/
176+
getNumber: function(key, default_value){
177+
if(default_value == null)
178+
default_value = 0;
179+
var locValueDict = this._valueDict;
180+
if(locValueDict.hasOwnProperty(key))
181+
return locValueDict[key];
182+
return default_value;
183+
},
184+
185+
/**
186+
* returns the value of a given key as a double
187+
* @param {string} key
188+
* @returns {Object|null}
189+
*/
190+
getObject:function(key){
191+
var locValueDict = this._valueDict;
192+
if(locValueDict.hasOwnProperty(key))
193+
return locValueDict[key];
194+
return null;
195+
},
196+
197+
/**
198+
* sets a new key/value pair in the configuration dictionary
199+
* @param {string} key
200+
* @param {Object} value
201+
*/
202+
setObject: function(key, value){
203+
this._valueDict[key] = value;
204+
},
205+
206+
/**
207+
* dumps the current configuration on the console
208+
*/
209+
dumpInfo: function(){
210+
if(cc.ENABLE_GL_STATE_CACHE === 0){
211+
cc.log("");
212+
cc.log("cocos2d: **** WARNING **** CC_ENABLE_PROFILERS is defined. Disable it when you finish profiling (from ccConfig.js)");
213+
cc.log("")
214+
}
215+
},
216+
217+
/**
218+
* gathers OpenGL / GPU information
219+
*/
220+
gatherGPUInfo: function(){
118221
if(cc.renderContextType === cc.CANVAS)
119-
return true;
222+
return;
120223

121224
var gl = cc.renderContext;
122-
cc.log("cocos2d: GL_VENDOR: " + gl.getParameter(gl.VENDOR));
123-
cc.log("cocos2d: GL_RENDERER: " + gl.getParameter(gl.RENDERER));
124-
cc.log("cocos2d: GL_VERSION: " + gl.getParameter(gl.VERSION));
225+
var locValueDict = this._valueDict;
226+
locValueDict["gl.vendor"] = gl.getParameter(gl.VENDOR);
227+
locValueDict["gl.renderer"] = gl.getParameter(gl.RENDERER);
228+
locValueDict["gl.version"] = gl.getParameter(gl.VERSION);
125229

126230
this._GlExtensions = "";
127231
var extArr = gl.getSupportedExtensions();
128232
for (var i = 0; i < extArr.length; i++)
129233
this._GlExtensions += extArr[i] + " ";
130-
cc.log("cocos2d: GL_EXTENSIONS: " + this._GlExtensions);
131234

132235
this._maxTextureSize = gl.getParameter(gl.MAX_TEXTURE_SIZE);
236+
locValueDict["gl.max_texture_size"] = this._maxTextureSize;
133237
this._maxTextureUnits = gl.getParameter(gl.MAX_COMBINED_TEXTURE_IMAGE_UNITS);
238+
locValueDict["gl.max_texture_units"] = this._maxTextureUnits;
134239

135240
this._supportsPVRTC = this.checkForGLExtension("GL_IMG_texture_compression_pvrtc");
136-
this._supportsNPOT = true;
241+
locValueDict["gl.supports_PVRTC"] = this._supportsPVRTC;
242+
243+
this._supportsNPOT = false; //true;
244+
locValueDict["gl.supports_NPOT"] = this._supportsNPOT;
245+
137246
this._supportsBGRA8888 = this.checkForGLExtension("GL_IMG_texture_format_BGRA888");
247+
locValueDict["gl.supports_BGRA8888"] = this._supportsBGRA8888;
248+
138249
this._supportsDiscardFramebuffer = this.checkForGLExtension("GL_EXT_discard_framebuffer");
250+
locValueDict["gl.supports_discard_framebuffer"] = this._supportsDiscardFramebuffer;
139251

140252
this._supportsShareableVAO = this.checkForGLExtension("vertex_array_object");
253+
locValueDict["gl.supports_vertex_array_object"] = this._supportsShareableVAO;
141254

142-
cc.log("cocos2d: GL_MAX_TEXTURE_SIZE: " + this._maxTextureSize);
143-
cc.log("cocos2d: GL_MAX_TEXTURE_UNITS: " + this._maxTextureUnits);
144-
cc.log("cocos2d: GL supports PVRTC: " + (this._supportsPVRTC ? "YES" : "NO"));
145-
cc.log("cocos2d: GL supports BGRA8888 textures: " + (this._supportsBGRA8888 ? "YES" : "NO"));
146-
cc.log("cocos2d: GL supports NPOT textures: " + (this._supportsNPOT ? "YES" : "NO"));
147-
cc.log("cocos2d: GL supports discard_framebuffer: " + (this._supportsDiscardFramebuffer ? "YES" : "NO"));
148-
cc.log("cocos2d: GL supports shareable VAO: " + (this._supportsShareableVAO ? "YES" : "NO"));
255+
cc.CHECK_GL_ERROR_DEBUG();
256+
},
149257

150-
if (cc.ENABLE_GL_STATE_CACHE == 0)
151-
cc.log("cocos2d: **** WARNING **** CC_ENABLE_GL_STATE_CACHE is disabled. To improve performance, enable it by editing ccConfig.h");
258+
/**
259+
* Loads a config file. If the keys are already present, then they are going to be replaced. Otherwise the new keys are added.
260+
* @param {string} filename
261+
*/
262+
loadConfigFile: function( filename){
263+
var fileUtils = cc.FileUtils.getInstance();
264+
var fullPath = fileUtils.fullPathForFilename(filename);
265+
var dict = fileUtils.dictionaryWithContentsOfFileThreadSafe(fullPath);
152266

153-
cc.CHECK_GL_ERROR_DEBUG();
154-
return true;
267+
if(dict == null)
268+
return;
269+
270+
var getDatas = dict["data"];
271+
if(!getDatas){
272+
cc.log("Expected 'data' dict, but not found. Config file: " + filename);
273+
return;
274+
}
275+
276+
// Add all keys in the existing dictionary
277+
for(var selKey in getDatas)
278+
this._valueDict[selKey] = getDatas[selKey];
155279
}
156280
});
157281

0 commit comments

Comments
 (0)