Skip to content

Commit b0858bc

Browse files
committed
added ability to specify a file with an extension in the texture loader and it will figure out a best alternative.
1 parent 943ea7a commit b0858bc

File tree

6 files changed

+35
-4
lines changed

6 files changed

+35
-4
lines changed

.gitmodules

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
[submodule "MonoGame"]
22
path = MonoGame
33
url = git://github.com/mono/MonoGame.git
4+
[submodule "tools/ouya"]
5+
path = tools/ouya
6+
url = https://github.com/slygamer/ouya-csharp.git

cocos2d/cocos2d.Phone.csproj

+1
Original file line numberDiff line numberDiff line change
@@ -355,6 +355,7 @@
355355
<Compile Include="sprite_nodes\CCSpriteBatchNode.cs" />
356356
<Compile Include="sprite_nodes\CCSpriteFrame.cs" />
357357
<Compile Include="sprite_nodes\CCSpriteFrameCache.cs" />
358+
<Compile Include="support\CCUserDefault.cs" />
358359
<Compile Include="support\CCUtils.cs" />
359360
<Compile Include="support\Converters\CCRectConverter.cs" />
360361
<Compile Include="support\Converters\CCPointConverter.cs" />

cocos2d/denshion/EffectPlayer.cs

+15-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using Microsoft.Xna.Framework.Audio;
1+
using System;
2+
using Microsoft.Xna.Framework.Audio;
23
using cocos2d;
34

45
namespace CocosDenshion
@@ -41,7 +42,19 @@ public void Open(string pFileName, int uId)
4142

4243
Close();
4344

44-
m_effect = CCApplication.SharedApplication.Content.Load<SoundEffect>(pFileName);
45+
try
46+
{
47+
m_effect = CCApplication.SharedApplication.Content.Load<SoundEffect>(pFileName);
48+
}
49+
catch (Exception)
50+
{
51+
string srcfile = pFileName;
52+
if (srcfile.IndexOf('.') > -1)
53+
{
54+
srcfile = srcfile.Substring(0, srcfile.LastIndexOf('.'));
55+
m_effect = CCApplication.SharedApplication.Content.Load<SoundEffect>(srcfile);
56+
}
57+
}
4558
// Do not get an instance here b/c it is very slow.
4659
//_sfxInstance = m_effect.CreateInstance();
4760
m_nSoundId = uId;

cocos2d/textures/CCTextureCache.cs

+15-1
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,21 @@ public CCTexture2D AddImage(string fileimage)
114114
{
115115
// Either we are creating a new one or else we need to refresh the current one.
116116
// CCLog.Log("Loading texture {0}", fileimage);
117-
Texture2D textureXna = CCApplication.SharedApplication.Content.Load<Texture2D>(fileimage);
117+
Texture2D textureXna = null;
118+
try
119+
{
120+
textureXna = CCApplication.SharedApplication.Content.Load<Texture2D>(fileimage);
121+
}
122+
catch (Exception)
123+
{
124+
string srcfile = fileimage;
125+
if (srcfile.IndexOf('.') > -1)
126+
{
127+
// Remove the extension
128+
srcfile = srcfile.Substring(0, srcfile.LastIndexOf('.'));
129+
}
130+
textureXna = CCApplication.SharedApplication.Content.Load<Texture2D>(srcfile);
131+
}
118132
bool isInited = texture.InitWithTexture(textureXna);
119133

120134
if (isInited)

tests/tests/tests.Phone.csproj

-1
Original file line numberDiff line numberDiff line change
@@ -1081,7 +1081,6 @@
10811081
</None>
10821082
<Compile Include="Program.cs" />
10831083
<Compile Include="Game1.cs" />
1084-
<None Include="tests.Phone_2013_04_07_19_23_35.sap" />
10851084
</ItemGroup>
10861085
<ItemGroup>
10871086
<Compile Include="classes\tests\ExtensionsTest\ControlExtensionTest\CCControlButtonTest\CCControlButtonTest.cs" />

tools/ouya

Submodule ouya added at 5f712a4

0 commit comments

Comments
 (0)