コード例 #1
0
        public BitmapFont(string textureFile, string fontFile, SystemManagers managers)
        {
            mTextures = new Texture2D[1];

            var atlasedTexture = CheckForLoadedAtlasTexture(FileManager.GetDirectory(fontFile) + textureFile);

            if (atlasedTexture != null)
            {
                mAtlasedTexture = atlasedTexture;
                mTextures[0]    = mAtlasedTexture.Texture;
            }
            else
            {
                mTextures[0] = LoaderManager.Self.LoadContent <Texture2D>(textureFile);
            }

            mTextureNames[0] = mTextures[0].Name;

            //if (FlatRedBall.IO.FileManager.IsRelative(fontFile))
            //    fontFile = FlatRedBall.IO.FileManager.MakeAbsolute(fontFile);

            //FlatRedBall.IO.FileManager.ThrowExceptionIfFileDoesntExist(fontFile);

            SetFontPatternFromFile(fontFile);
        }
コード例 #2
0
        public BitmapFont(string fontFile, SystemManagers managers)
        {
#if ANDROID || IOS
            fontFile = fontFile.ToLowerInvariant();
#endif

            string fontContents = FileManager.FromFileText(fontFile);
            mFontFile = FileManager.Standardize(fontFile);

            string[] texturesToLoad = GetSourceTextures(fontContents);

            mTextures = new Texture2D[texturesToLoad.Length];

            string directory = FileManager.GetDirectory(fontFile);

            for (int i = 0; i < mTextures.Length; i++)
            {
                AtlasedTexture atlasedTexture = CheckForLoadedAtlasTexture(directory + texturesToLoad[i]);
                if (atlasedTexture != null)
                {
                    mAtlasedTexture = atlasedTexture;
                    mTextures[i]    = mAtlasedTexture.Texture;
                }
                else
                {
                    string fileName;


                    // fnt files treat ./ as relative, but FRB Android treats ./ as
                    // absolute. Since the value comes directly from .fnt, we want to
                    // consider ./ as relative instead of whatever FRB thinks is relative:
                    //if (FileManager.IsRelative(texturesToLoad[i]))
                    bool isRelative = texturesToLoad[i].StartsWith("./") || FileManager.IsRelative(texturesToLoad[i]);

                    if (isRelative)
                    {
                        if (FileManager.IsRelative(directory))
                        {
                            fileName = FileManager.RelativeDirectory + directory + texturesToLoad[i];
                        }
                        else
                        {
                            fileName = directory + texturesToLoad[i];
                        }

                        //mTextures[i] = LoaderManager.Self.Load(directory + texturesToLoad[i], managers);
                    }
                    else
                    {
                        //mTextures[i] = LoaderManager.Self.Load(texturesToLoad[i], managers);
                        fileName = texturesToLoad[i];
                    }
                    // Don't rely on this - it may be aliased, the internal loader may redirect. Let it do its job:
                    //if (ToolsUtilities.FileManager.FileExists(fileName))
                    mTextures[i] = LoaderManager.Self.LoadContent <Texture2D>(fileName);
                }
            }

            SetFontPattern(fontContents);
        }
コード例 #3
0
        public BitmapFont(string fontFile, SystemManagers managers)
        {
#if ANDROID || IOS
            fontFile = fontFile.ToLowerInvariant();
#endif

            string fontContents = FileManager.FromFileText(fontFile);
            mFontFile = FileManager.Standardize(fontFile);

            string[] texturesToLoad = GetSourceTextures(fontContents);

            mTextures = new Texture2D[texturesToLoad.Length];

            string directory = FileManager.GetDirectory(fontFile);

            for (int i = 0; i < mTextures.Length; i++)
            {
                AtlasedTexture atlasedTexture = CheckForLoadedAtlasTexture(directory + texturesToLoad[i]);
                if (atlasedTexture != null)
                {
                    mAtlasedTexture = atlasedTexture;
                    mTextures[i]    = mAtlasedTexture.Texture;
                }
                else
                {
                    string fileName;

                    if (FileManager.IsRelative(texturesToLoad[i]))
                    {
                        if (FileManager.IsRelative(directory))
                        {
                            fileName = FileManager.RelativeDirectory + directory + texturesToLoad[i];
                        }
                        else
                        {
                            fileName = directory + texturesToLoad[i];
                        }

                        //mTextures[i] = LoaderManager.Self.Load(directory + texturesToLoad[i], managers);
                    }
                    else
                    {
                        //mTextures[i] = LoaderManager.Self.Load(texturesToLoad[i], managers);
                        fileName = texturesToLoad[i];
                    }
                    if (ToolsUtilities.FileManager.FileExists(fileName))
                    {
                        mTextures[i] = LoaderManager.Self.LoadContent <Texture2D>(fileName);
                    }
                }
            }

            SetFontPattern(fontContents);
        }
コード例 #4
0
ファイル: NineSlice.cs プロジェクト: patridge/Gum
 /// <summary>
 /// Loads given texture(s) from atlas.
 /// </summary>
 /// <param name="valueAsString"></param>
 /// <param name="atlasedTexture"></param>
 public void LoadAtlasedTexture(string valueAsString, AtlasedTexture atlasedTexture)
 {
     //if made up of seperate textures
     if (NineSliceExtensions.GetIfShouldUsePattern(valueAsString))
     {
         SetTexturesUsingPattern(valueAsString, SystemManagers.Default, true);
     }
     else //single texture
     {
         foreach (var sprite in mSprites)
         {
             sprite.AtlasedTexture = atlasedTexture;
         }
     }
 }
コード例 #5
0
ファイル: Atlas.cs プロジェクト: patridge/Gum
 public void Add(string name, AtlasedTexture sprite)
 {
     atlasDictionary.Add(name, sprite);
 }
コード例 #6
0
ファイル: BitmapFont.cs プロジェクト: vchelaru/FlatRedBall
        public BitmapFont(string fontFile, SystemManagers managers)
        {

#if ANDROID || IOS
			fontFile = fontFile.ToLowerInvariant();
#endif

            string fontContents = FileManager.FromFileText(fontFile);
            mFontFile = FileManager.Standardize(fontFile);

            string[] texturesToLoad = GetSourceTextures(fontContents);

            mTextures = new Texture2D[texturesToLoad.Length];

            string directory = FileManager.GetDirectory(fontFile);

            for (int i = 0; i < mTextures.Length; i++)
            {
                AtlasedTexture atlasedTexture = CheckForLoadedAtlasTexture(directory + texturesToLoad[i]);
                if (atlasedTexture != null)
                {
                    mAtlasedTexture = atlasedTexture;
                    mTextures[i] = mAtlasedTexture.Texture;
                }
                else
                {
                    if (FileManager.IsRelative(texturesToLoad[i]))
                    {
                        //mTextures[i] = LoaderManager.Self.Load(directory + texturesToLoad[i], managers);
                        mTextures[i] = LoaderManager.Self.LoadContent<Texture2D>(directory + texturesToLoad[i]);
                    }
                    else
                    {
                        //mTextures[i] = LoaderManager.Self.Load(texturesToLoad[i], managers);
                        mTextures[i] = LoaderManager.Self.LoadContent<Texture2D>(texturesToLoad[i]);
                    }
                }
            } 
            
            SetFontPattern(fontContents);
        }
コード例 #7
0
ファイル: BitmapFont.cs プロジェクト: vchelaru/FlatRedBall
        public BitmapFont(string textureFile, string fontFile, SystemManagers managers)
        {
            mTextures = new Texture2D[1];

            var atlasedTexture = CheckForLoadedAtlasTexture(FileManager.GetDirectory(fontFile) + textureFile);
            if (atlasedTexture != null)
            {
                mAtlasedTexture = atlasedTexture;
                mTextures[0] = mAtlasedTexture.Texture;
            }
            else
            {
                mTextures[0] = LoaderManager.Self.LoadContent<Texture2D>(textureFile);
            }

            mTextureNames[0] = mTextures[0].Name;

            //if (FlatRedBall.IO.FileManager.IsRelative(fontFile))
            //    fontFile = FlatRedBall.IO.FileManager.MakeAbsolute(fontFile);

            //FlatRedBall.IO.FileManager.ThrowExceptionIfFileDoesntExist(fontFile);

            SetFontPatternFromFile(fontFile);
        }
コード例 #8
0
ファイル: Atlas.cs プロジェクト: vchelaru/FlatRedBall
 public void Add(string name, AtlasedTexture sprite)
 {
     atlasDictionary.Add(name, sprite);
 }
コード例 #9
0
ファイル: NineSlice.cs プロジェクト: vchelaru/FlatRedBall
 /// <summary>
 /// Loads given texture(s) from atlas.
 /// </summary>
 /// <param name="valueAsString"></param>
 /// <param name="atlasedTexture"></param>
 public void LoadAtlasedTexture(string valueAsString, AtlasedTexture atlasedTexture)
 {
     //if made up of seperate textures
     if (GetIfShouldUsePattern(valueAsString))
     {
         SetTexturesUsingPattern(valueAsString, SystemManagers.Default, true);
     }
     else //single texture
     {
         foreach (var sprite in mSprites)
         {
             sprite.AtlasedTexture = atlasedTexture;
         }   
     }
 }