Inheritance: MonoBehaviour
Ejemplo n.º 1
0
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            // TODO: Add your initialization logic here
            _fontTreb = new BitmapFont(@"Treb11.xml");

            base.Initialize();
        }
Ejemplo n.º 2
0
        public BillboardText3D()
        {
            Positions = new Vector3Collection();
            Colors = new Color4Collection();
            TextureCoordinates = new Vector2Collection();

            this.TextInfo = new List<TextInfo>();

            var assembly = Assembly.GetExecutingAssembly();

            //Read the texture description
            using(var texDescriptionStream = assembly.GetManifestResourceStream("HelixToolkit.Wpf.SharpDX.Textures.arial.fnt"))
            {
                bmpFont = new BitmapFont();
                bmpFont.Load(texDescriptionStream);
            }

            //Read the texture
            using(var texImageStream = assembly.GetManifestResourceStream("HelixToolkit.Wpf.SharpDX.Textures.arial.png"))
            {
                var image = new BitmapImage();
                image.BeginInit();
                image.StreamSource = texImageStream;
                image.EndInit();

                Texture = image;
            }
        }
Ejemplo n.º 3
0
		/// <summary>
		/// Submit a text string of sprites for drawing in the current batch.
		/// </summary>
		/// <param name="spriteFont">A font.</param>
		/// <param name="text">The text which will be drawn.</param>
		/// <param name="position">The drawing location on screen.</param>
		/// <param name="color">A color mask.</param>
		/// <param name="rotation">A rotation of this string.</param>
		/// <param name="origin">Center of the rotation. 0,0 by default.</param>
		/// <param name="scale">A scaling of this string.</param>
		/// <param name="effects">Modificators for drawing. Can be combined.</param>
		/// <param name="layerDepth">A depth of the layer of this string.</param>
		public static void drawString( this Batcher batcher, BitmapFont bitmapFont, string text, Vector2 position, Color color,
			float rotation, Vector2 origin, float scale, SpriteEffects effects, float layerDepth )
		{
			var scaleVec = new Vector2( scale, scale );
			var source = new FontCharacterSource( text );
			bitmapFont.drawInto( batcher, ref source, position, color, rotation, origin, scaleVec, effects, layerDepth );
		}
Ejemplo n.º 4
0
 public FramesPerSecondCounter( BitmapFont font, Color color, FPSDockPosition dockPosition = FPSDockPosition.TopRight, int maximumSamples = 100 )
     : base(font, string.Empty, Vector2.Zero, color)
 {
     this.maximumSamples = maximumSamples;
     this.dockPosition = dockPosition;
     initialize();
 }
Ejemplo n.º 5
0
        public static BitmapFont Load(string fileName)
        {
            BitmapFont font = new BitmapFont();
            try
            {
                // lataa fonttitexture
                font.texture = Texture.Load(fileName);

                Bitmap CurrentBitmap = new Bitmap(Settings.TextureDir + fileName);

                if (CurrentBitmap.PixelFormat == System.Drawing.Imaging.PixelFormat.Format24bppRgb || CurrentBitmap.PixelFormat == System.Drawing.Imaging.PixelFormat.Format32bppArgb)
                {
                    BitmapData Data = CurrentBitmap.LockBits(new Rectangle(0, 0, CurrentBitmap.Width, CurrentBitmap.Height), ImageLockMode.ReadOnly, CurrentBitmap.PixelFormat);
                    font.SearchUV(ref Data, (CurrentBitmap.PixelFormat == System.Drawing.Imaging.PixelFormat.Format24bppRgb) ? 3 : 4);
                    CurrentBitmap.UnlockBits(Data);
                }
                else Log.Error("Font: wrong pixel format.");
            }
            catch (Exception e)
            {
                Log.Error("Font: error loading file " + fileName + "\n" + e.ToString());
            }

            if (vbo == null)
            {
                ushort[] ind = new ushort[] { 0, 1, 3, 1, 2, 3 };
                vbo = new VBO(BufferUsageHint.StreamDraw);
                vbo.DataToVBO(letter, ind, VBO.VertexMode.UV1);

                vbo.Shader = GLSLShader.Load("default2d.shader");
            }
            return font;
        }
Ejemplo n.º 6
0
 public CFNTViewer(CFNT Font)
 {
     this.Font = Font;
     f = Font.GetBitmapFont();
     InitializeComponent();
     pictureBox1.Image = f.PrintToBitmap(textBox1.Text, new BitmapFont.FontRenderSettings());
 }
Ejemplo n.º 7
0
    // Update is called once per frame
    void Update()
    {
        if( m_text != null )
        {
            bool reload = false;
            if( m_currentFont != m_font )
            {
                m_currentFont = m_font;
                m_text.m_font = m_currentFont;
                reload = true;
            }

            if( m_currentColor != m_color )
            {
                m_currentColor = m_color;
                reload = true;
            }

            if( m_currentStringID != m_stringID )
            {
                m_currentStringID = m_stringID;
                m_text.m_text = StringLookup.Get.GetString( m_currentStringID );
                reload = true;
            }

            if( reload )
            {
                m_text.Reload();
                m_text.SetColor( m_currentColor );
            }
        }
    }
        public World(string path, string file_name, int width, int height)
        {
            //setovanje visine i sirine za resize
            this.mf_width = width;
            this.mf_height = height;

            try
            {
                this.mf_scene = new AssimpScene(path, file_name);
                this.mf_font = new BitmapFont("Tahoma", 14f, false, true, true, false);
                this.mf_box = new Box();
            }
            catch (Exception)
            {
                MessageBox.Show("Neuspesno kreirana instanca klase BOX", "GRESKA", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            try
            {
                textures = new int[textureCount];
            }
            catch (Exception)
            {
                MessageBox.Show("Neuspesno kreirana niz identifikatora za teksture", "GRESKA", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            this.Initialize();
            this.Resize();
        }
Ejemplo n.º 9
0
        //////////////////////////////////////////////////////////////////////

        private void Init(BitmapFont font, char c)
        {
            character = c;
            this.font = font;
            BitmapFont.GlyphRenderer g = font.GetGlyphDetails(c);
            if(g != null)
            {
                float nearZ = Camera.main.nearClipPlane;
                var zero = Camera.main.ScreenToWorldPoint(new Vector3(0, 0, nearZ));
                var one = Camera.main.ScreenToWorldPoint(new Vector3(1, 1, nearZ));  // work out how big a pixel is...
                var pixel = one - zero;
                name = c.ToString();
                advance = g.advance;
                int imageCount = g.imageCount;
                if (imageCount > 0)
                {
                    letter = new GameObject[imageCount];
                    for (int i = 0; i < imageCount; ++i)
                    {
                        GameObject go = new GameObject("Layer:" + i.ToString());
                        SpriteRenderer sr = go.AddComponent<SpriteRenderer>();
                        Sprite sprite = g.images[i];
                        if (sprite) //huh?
                        {
                            sr.sprite = sprite;
                            sr.material = Glyph.Material;
                            go.transform.localPosition = new Vector3((-0.25f + g.offsets[i].x) * pixel.x, (0.25f + font.data.Height - g.offsets[i].y) * pixel.y, nearZ);
                            sr.sortingOrder = i;
                            go.transform.SetParent(transform);
                            letter[i] = go;
                        }
                    }
                }
            }
        }
Ejemplo n.º 10
0
		public static void init( BitmapFont font )
		{
			_spriteBatch = new SpriteBatch( Core.graphicsDevice );
			_font = font;

			var scale = FONT_LINE_HEIGHT / _font.lineHeight;
			FONT_SCALE = new Vector2( scale, scale );
		}
Ejemplo n.º 11
0
Archivo: IMGUI.cs Proyecto: prime31/Nez
		static IMGUI()
		{
			_spriteBatch = new SpriteBatch( Core.graphicsDevice );
			_font = Graphics.instance.bitmapFont;

			var scale = FONT_LINE_HEIGHT / _font.lineHeight;
			FONT_SCALE = new Vector2( scale, scale );
		}
Ejemplo n.º 12
0
        protected override void InitializeCore()
        {
            string fontFile = "verdana39.fnt";
            string imageFile = "verdana39.png";

            _batch = new GdxSpriteBatch(Context.GraphicsDevice);
            _font = new BitmapFont(Context.GraphicsDevice, fontFile, imageFile, false);
        }
Ejemplo n.º 13
0
        public ClockDisplay(FrameClock clock, BitmapFont font, Vector2 position)
        {
            this.Clock = clock;
            this.font = font;
            this.Position = position;

            GenerateText();
        }
Ejemplo n.º 14
0
 public DebugDrawItem( string text, Color color, float duration, float scale )
 {
     bitmapFont = Graphics.instance.bitmapFont;
     this.text = text;
     this.color = color;
     this.scale = scale;
     this.duration = duration;
     drawType = DebugDrawType.ConsoleText;
 }
Ejemplo n.º 15
0
 public static int text_width(BitmapFont font, string text)
 {
     float w = 0f;
     foreach (var c in text)
     {
         w += font.char_data[c].width;
     }
     return (int)w;
 }
Ejemplo n.º 16
0
		public Graphics( BitmapFont font )
		{
			batcher = new Batcher( Core.graphicsDevice );
			bitmapFont = font;

			// the bottom/right pixel is white on the default font so we'll use that for the pixelTexture
			var fontTex = bitmapFont.defaultCharacterRegion.subtexture.texture2D;
			pixelTexture = new Subtexture( fontTex, fontTex.Width - 1, fontTex.Height - 1, 1, 1 );
		}
Ejemplo n.º 17
0
        public MenuElement(InterfaceElement parent, Vector2 location, BitmapFont font)
            : base(parent, location)
        {
            Opacity = 1f;

            this.Font = font;
            Location = new Vector2(0f, Location.Y);
            Size = new Vector2(Parent.Size.X, 0f);
        }
Ejemplo n.º 18
0
        public TextElement(InterfaceElement parent, Vector2 location, BitmapFont font, string text, HAlign h, VAlign v)
            : base(parent, location)
        {
            Opacity = 1f;

            this.Text = text;
            this.Font = font;
            this.hAlign = h;
            this.vAlign = v;
        }
Ejemplo n.º 19
0
		public DebugDrawItem( BitmapFont bitmapFont, String text, Vector2 position, Color color, float duration, float scale )
		{
			this.bitmapFont = bitmapFont;
			this.text = text;
			this.position = position;
			this.color = color;
			this.scale = scale;
			this.duration = duration;
			drawType = DebugDrawType.BitmapFontText;
		}
Ejemplo n.º 20
0
 protected void OnLoad(object sender, EventArgs e)
 {
     spriteBatch = new SpriteBatch();
     texture = new Texture(new Bitmap(@"Content/test.png"));
     sprite = new Sprite(texture);
     arial = new BitmapFont("Content/arial_test");
     text = new Text(arial, "The quick brown fox \njumps over the lazy dog.", new Vector2(0, 256), Color.Black);
     fpsFont = new BitmapFont(@"Content/fps_font");
     fpsCounter = new ClockDisplay(Game.Clock, fpsFont, Vector2.Zero, Color.Black); // White is also default
     camera = Camera.CreateOrthographic(Game.ClientSize.Width, Game.ClientSize.Height, -1, 1);
 }
Ejemplo n.º 21
0
        public Text(BitmapFont font, string str, Vector2 pos)
        {
            VAO = GL.GenVertexArray();
            VBO = GL.GenBuffer();
            UBO = GL.GenBuffer();

            Font = font;
            String = str;
            Position = pos;

            GenerateInformation();
        }
Ejemplo n.º 22
0
		private static void Initialize(GraphicsDevice graphics)
		{
			if (_initialized == false)
			{
				_graphics = graphics;

				_initialized = true;
				byte[] pngBytes = Convert.FromBase64String(_biosFontData);
				_biosFont = new BitmapFont(Texture2D.FromStream(_graphics, new MemoryStream(pngBytes)), 8);
				_batch = new SpriteBatch(_graphics);
			}
		}
Ejemplo n.º 23
0
		public void SetValuesFrom(SpriteFrame baseFrame, Text text)
		{
			base.SetValuesFrom(baseFrame);
			TextSpacing = text.Spacing;
			TextScale = text.Scale;

			TextRed = text.Red;
			TextGreen = text.Green;
			TextBlue = text.Blue;

			Font = text.Font;

		}
Ejemplo n.º 24
0
        public BitmapFont LoadFont(string fontName)
        {
            string bitmapFileName = Path.Combine(_fontsFolder, String.Format(@"{0}.png", fontName));
            string bitmapAlphaFileName = Path.Combine(_fontsFolder, String.Format(@"_{0}.png", fontName));
            string definitionFileName = Path.Combine(_fontsFolder, String.Format(@"{0}.txt", fontName));

            _logger.Debug(
                "Loading font - fontname={0}, filename={1}, alphafilename={2}, definitionfilename={3}",
                fontName,
                bitmapFileName,
                bitmapAlphaFileName,
                definitionFileName);

            if (!File.Exists(bitmapFileName))
            {
                throw new FileNotFoundException(bitmapFileName);
            }

            if (!File.Exists(definitionFileName))
            {
                throw new FileNotFoundException(definitionFileName);
            }

            var bitmap = new Image<Bgra, byte>(bitmapFileName);
            var alphaBitmap = new Image<Bgra, byte>(bitmapAlphaFileName);
            var font = new BitmapFont { Bitmap = bitmap.CombineAlpha(alphaBitmap) };

            var definition = File.ReadAllText(definitionFileName, Encoding.GetEncoding(1252));

            var definesRegex = new Regex(@"Define.*?\);", RegexOptions.Singleline);
            var matches = definesRegex.Matches(definition).OfType<Match>().ToList();
            var charList = matches.First(x => x.Value.Contains("CharList")).Value;
            var widthList = matches.First(x => x.Value.Contains("WidthList")).Value;
            var rectList = matches.First(x => x.Value.Contains("RectList")).Value;
            var offsetList = matches.First(x => x.Value.Contains("OffsetList")).Value;

            AddCharList(font, charList);
            AddWidthList(font, widthList);
            AddRectList(font, rectList);
            AddOffsetList(font, offsetList);

            font.Ascent = Int32.Parse(new Regex(@"LayerSetAscent .*?(\d+?);").Match(definition).Groups[1].Value);

            int spaceWidth = Int32.Parse(new Regex(@"LayerSetCharWidths\s+Main\s\(' '\) \((\d+?)\);").Match(definition).Groups[1].Value);
            font.Characters.Add(new FontCharacter { Character = ' ', Width = spaceWidth, Rectangle = new Rectangle(0, 0, spaceWidth, 0) });

            return font;
        }
Ejemplo n.º 25
0
        public static BitmapFontSave FromBitmapFont(BitmapFont bitmapFont)
        {
            BitmapFontSave bitmapFontSave = new BitmapFontSave();

            if (bitmapFont == TextManager.DefaultFont)
            {
                bitmapFontSave.TextureFileName = ReservedDefaultName;
                bitmapFontSave.FontFileName = ReservedDefaultName;
            }
            else
            {
                bitmapFontSave.TextureFileName = bitmapFont.Texture.Name;
                bitmapFontSave.FontFileName = bitmapFont.mFontFile;
            }
            return bitmapFontSave;
        }
Ejemplo n.º 26
0
        static void Main(string[] args)
        {
            Background = Color.Black;
            Static = new Color(52, 73, 94);
            Foreground = new Color(253, 227, 167);

            Engine.Initialize<SfmlRenderer, IrrKlangModule.IrrKlangAudioModule>();

            Engine.EventHost.RegisterEvent<KeyDownEvent>((int)Keyboard.Key.Escape, 0, (ev) =>
                {
                    while (Engine.SceneHost.CurrentScene != null)
                        Engine.SceneHost.Pop();
                });

            Engine.EventHost.RegisterEvent<InitializeEvent>(0, (ev) =>
            {
                Engine.DesiredResolution = new Vector2(640f, 480f);

                Container = Engine.ResourceHost.LoadDictionary("main", "Resources");
                Font12 = LoadFont("Fonts/merriweather_12.fnt");
                Font16 = LoadFont("Fonts/merriweather_16.fnt");
                Logo = LoadTexture("logo.png");
                Player = LoadTexture("player.png");
                Portal = LoadTexture("portal.png");
                Hint1 = LoadTexture("hint1.png");
                Hint2 = LoadTexture("hint2.png");
                Hint3 = LoadTexture("hint3.png");
                EndScreen = LoadTexture("endscreen.png");

                Music = LoadSound("music.wav");
                EnemyHit = LoadSound("ehit.wav");
                Cut = LoadSound("cut.wav");
                Ground = LoadSound("ground.wav");

                Music.Loop();

                Image image = new Image(1, 1);
                image.SetColor(0, 0, Color.White);
                Pixel = Engine.Renderer.TextureFromImage(image);

                var scene = Engine.SceneHost.CreateGlobal<MainScene>();
                Engine.SceneHost.Push(scene);
            });

            Engine.StartGame("cut", WindowStyle.Default);
        }
Ejemplo n.º 27
0
        public DiagnosticsCenter()
        {
            objects = new List<IDiagnosable>();
            Add(this);
            buffer = new StringBuilder(1024);
            if(font == null)
                font = new BitmapFont(new Font("Consolas", 14));
            graphs = new List<DebugGraph>();

            fpsGraph = new DebugGraph(new Rectangle(120, 30, 200, 40)) { ValuesByX = 20, ApproximateGraduation = 1 };
            upsGraph = new DebugGraph(new Rectangle(120, 80, 200, 40)) { ValuesByX = 20, ApproximateGraduation = 1 };
            fdtGraph = new DebugGraph(new Rectangle(120, 130, 200, 60)) { ValuesByX = 120, ApproximateGraduation = 0.01f };
            udtGraph = new DebugGraph(new Rectangle(120, 200, 200, 60)) { ValuesByX = 120, ApproximateGraduation = 0.01f };
            memoryGraph = new DebugGraph(new Rectangle(220, 270, 200, 60)) { ValuesByX = 40, ApproximateGraduation = 8f };

            graphs.Add(fpsGraph); graphs.Add(upsGraph); graphs.Add(fdtGraph); graphs.Add(udtGraph); graphs.Add(memoryGraph);
            Init();
        }
Ejemplo n.º 28
0
        private static void AddCharList(BitmapFont font, string charList)
        {
            charList = charList.Replace("Define CharList", String.Empty)
                               .Replace(" ", String.Empty)
                               .Replace(Environment.NewLine, String.Empty)
                               .Replace("\n", String.Empty)
                               .Replace(",\"", ",'")
                               .Replace("\",", "',")
                               .TrimStart('(', '\'')
                               .TrimEnd(';', ')', '\'');

            foreach (var c in charList.Split(new[] { "','" }, StringSplitOptions.None))
            {
                var character = new FontCharacter
                                    {
                                        Character = c[0]
                                    };

                font.Characters.Add(character);
            }
        }
Ejemplo n.º 29
0
        public BillboardText3D()
        {
            Positions = new Vector3Collection();
            Colors = new Color4Collection();
            TextureCoordinates = new Vector2Collection();

            this.TextInfo = new List<TextInfo>();

            var assembly = Assembly.GetExecutingAssembly();

            var texDescriptionFilePath = Path.GetTempFileName();
            var texImageFilePath = Path.GetTempFileName();

            //Read the texture description
            var texDescriptionStream = assembly.GetManifestResourceStream("HelixToolkit.Wpf.SharpDX.Textures.arial.fnt");
            using (var fileStream = File.Create(texDescriptionFilePath))
            {
                texDescriptionStream.CopyTo(fileStream);
            }

            bmpFont = BitmapFontLoader.LoadFontFromFile(texDescriptionFilePath);

            //Read the texture
            var texImageStream = assembly.GetManifestResourceStream("HelixToolkit.Wpf.SharpDX.Textures.arial.png");
            using (var fileStream = File.Create(texImageFilePath))
            {
                texImageStream.CopyTo(fileStream);
            }

            Texture = new BitmapImage(new Uri(texImageFilePath));

            //Cleanup the temp files
            if (File.Exists(texDescriptionFilePath))
            {
                File.Delete(texDescriptionFilePath);
            }
        }
Ejemplo n.º 30
0
        private static void Initialize()
        {
            if (isInitialized)
                return;

            var assembly = Assembly.GetExecutingAssembly();

            var texDescriptionFilePath = Path.GetTempFileName();
            var texImageFilePath = Path.GetTempFileName();

            //Read the texture description           
            var texDescriptionStream = assembly.GetManifestResourceStream("HelixToolkit.Wpf.SharpDX.Textures.arial.fnt");
            using (var fileStream = File.Create(texDescriptionFilePath))
            {
                texDescriptionStream.CopyTo(fileStream);
            }

            bmpFont = BitmapFontLoader.LoadFontFromFile(texDescriptionFilePath);

            //Read the texture          
            var texImageStream = assembly.GetManifestResourceStream("HelixToolkit.Wpf.SharpDX.Textures.arial.png");
            using (var fileStream = File.Create(texImageFilePath))
            {
                texImageStream.CopyTo(fileStream);
            }

            Texture = new BitmapImage(new Uri(texImageFilePath));

            //Cleanup the temp files
            if (File.Exists(texDescriptionFilePath))
            {
                File.Delete(texDescriptionFilePath);
            }

            isInitialized = true;
        }
Ejemplo n.º 31
0
        /// <summary>
        ///     Draws unicode (UTF-16) characters as sprites using the specified <see cref="BitmapFont" />, text
        ///     <see cref="StringBuilder" />, transform <see cref="Matrix2D" /> and optional <see cref="Color" />, origin
        ///     <see cref="Vector2" />, <see cref="FlipFlags" />, and depth <see cref="float" />.
        /// </summary>
        /// <param name="bitmapFont">The <see cref="BitmapFont" />.</param>
        /// <param name="text">The text <see cref="StringBuilder" />.</param>
        /// <param name="transformMatrix">The transform <see cref="Matrix2D" />.</param>
        /// <param name="color">
        ///     The <see cref="Color" />. Use <code>null</code> to use the default
        ///     <see cref="Color.White" />.
        /// </param>
        /// <param name="flags">The <see cref="FlipFlags" />. The default value is <see cref="FlipFlags.None" />.</param>
        /// <param name="depth">The depth <see cref="float" />. The default value is <code>0f</code>.</param>
        /// <exception cref="InvalidOperationException">The <see cref="Batcher{TDrawCallInfo}.Begin(ref Matrix, ref Matrix, BlendState, SamplerState, DepthStencilState, RasterizerState, Effect)" /> method has not been called.</exception>
        /// <exception cref="ArgumentNullException"><paramref name="bitmapFont" /> is null or <paramref name="text" /> is null.</exception>
        public void DrawString(BitmapFont bitmapFont, StringBuilder text, ref Matrix2D transformMatrix,
                               Color?color = null, FlipFlags flags = FlipFlags.None, float depth = 0f)
        {
            EnsureHasBegun();

            if (bitmapFont == null)
            {
                throw new ArgumentNullException(nameof(bitmapFont));
            }

            if (text == null)
            {
                throw new ArgumentNullException(nameof(text));
            }

            var lineSpacing = bitmapFont.LineHeight;
            var offset      = new Vector2(0, 0);

            BitmapFontRegion lastGlyph = null;

            for (var i = 0; i < text.Length;)
            {
                int character;
                if (char.IsLowSurrogate(text[i]))
                {
                    character = char.ConvertToUtf32(text[i - 1], text[i]);
                    i        += 2;
                }
                else if (char.IsHighSurrogate(text[i]))
                {
                    character = char.ConvertToUtf32(text[i], text[i - 1]);
                    i        += 2;
                }
                else
                {
                    character = text[i];
                    i        += 1;
                }

                // ReSharper disable once SwitchStatementMissingSomeCases
                switch (character)
                {
                case '\r':
                    continue;

                case '\n':
                    offset.X  = 0;
                    offset.Y += lineSpacing;
                    lastGlyph = null;
                    continue;
                }

                var fontRegion = bitmapFont.GetCharacterRegion(character);
                if (fontRegion == null)
                {
                    continue;
                }

                var transform1Matrix = transformMatrix;
                transform1Matrix.M31 += offset.X + fontRegion.XOffset;
                transform1Matrix.M32 += offset.Y + fontRegion.YOffset;

                var textureRegion = fontRegion.TextureRegion;
                var bounds        = textureRegion.Bounds;
                DrawSprite(textureRegion.Texture, ref transform1Matrix, ref bounds, color, flags, depth);

                var advance = fontRegion.XAdvance + bitmapFont.LetterSpacing;
                if (BitmapFont.UseKernings && lastGlyph != null)
                {
                    int amount;
                    if (lastGlyph.Kernings.TryGetValue(character, out amount))
                    {
                        advance += amount;
                    }
                }

                offset.X += i != text.Length - 1
                    ? advance
                    : fontRegion.XOffset + fontRegion.Width;

                lastGlyph = fontRegion;
            }
        }
Ejemplo n.º 32
0
 public Label(BitmapFont font, string text = "") : this(font, Color.White, text)
 {
 }
Ejemplo n.º 33
0
 public void LoadContent(Microsoft.Xna.Framework.Content.ContentManager content)
 {
     _bitmapFont = content.Load <BitmapFont>("fonts/montserrat-32");
 }
Ejemplo n.º 34
0
        public static void LoadFonts(ContentManager Content)
        {
            BitmapFont EngineFont = Content.Load <BitmapFont>("engine_font");

            LoadFont("engine_font", EngineFont);
        }
Ejemplo n.º 35
0
 public WindowStyle()
 {
     TitleFont = Graphics.Instance.BitmapFont;
 }
Ejemplo n.º 36
0
 public LabelStyle(BitmapFont font, Color fontColor)
 {
     Font      = font ?? Graphics.Instance.BitmapFont;
     FontColor = fontColor;
 }
Ejemplo n.º 37
0
 public Label(string text, BitmapFont font) : this(text, font, Color.White)
 {
 }
Ejemplo n.º 38
0
 public NumberFieldStyle(BitmapFont font, Color fontColor, IDrawable cursor, IDrawable selection, IDrawable background, TextButtonStyle decreaseButtonStyle, TextButtonStyle increaseButtonStyle) : base(font, fontColor, cursor, selection, background)
 {
     this.DecreaseButtonStyle = decreaseButtonStyle;
     this.IncreaseButtonStyle = increaseButtonStyle;
 }
Ejemplo n.º 39
0
 public FramesPerSecondCounter(BitmapFont font, Color color, FPSDockPosition dockPosition = FPSDockPosition.TopRight, int maximumSamples = 100) : base(font, string.Empty, Vector2.Zero, color)
 {
     this.maximumSamples = maximumSamples;
     this.dockPosition   = dockPosition;
     initialize();
 }
Ejemplo n.º 40
0
 public WindowStyle(BitmapFont titleFont, Color titleFontColor, IDrawable background)
 {
     TitleFont      = titleFont ?? Graphics.Instance.BitmapFont;
     Background     = background;
     TitleFontColor = titleFontColor;
 }
Ejemplo n.º 41
0
        public static SpriteFont LoadXml(string xml, Func <string, Texture2D> textureGetter)
        {
            var data = new BitmapFont();

            data.LoadXml(xml);

            if (data.Pages.Length > 1)
            {
                throw new NotSupportedException("For now only BMFonts with single texture are supported");
            }
#if !XENKO
            var glyphBounds = new List <Rectangle>();
            var cropping    = new List <Rectangle>();
            var chars       = new List <char>();
            var kerning     = new List <Vector3>();

            var characters = data.Characters.Values.OrderBy(c => c.Char);
            foreach (var character in characters)
            {
                var bounds = character.Bounds;

                //                bounds.Offset(texture.Bounds.Location);

                glyphBounds.Add(bounds);
                cropping.Add(new Rectangle(character.Offset.X, character.Offset.Y, bounds.Width, bounds.Height));

                chars.Add(character.Char);

                kerning.Add(new Vector3(0, character.Bounds.Width, character.XAdvance - character.Bounds.Width));
            }

            var texture = textureGetter(data.Pages[0].FileName);

            var constructorInfo = typeof(SpriteFont).GetTypeInfo().DeclaredConstructors.First();
            var result          = (SpriteFont)constructorInfo.Invoke(new object[]
            {
                texture, glyphBounds, cropping,
                chars, data.LineHeight, 0, kerning, ' '
            });

            return(result);
#else
            var textureRegion = textureRegionLoader(data.Pages[0].FileName);

            var glyphs = new List <Glyph>();
            foreach (var pair in data.Characters)
            {
                var character = pair.Value;

                var bounds = character.Bounds;
                bounds.X += textureRegion.Bounds.X;
                bounds.Y += textureRegion.Bounds.Y;
                var glyph = new Glyph
                {
                    Character   = character.Char,
                    BitmapIndex = 0,
                    Offset      = new Vector2(character.Offset.X, character.Offset.Y),
                    Subrect     = bounds,
                    XAdvance    = character.XAdvance
                };

                glyphs.Add(glyph);
            }

            var textures = new List <Texture>
            {
                textureRegion.Texture
            };

            return(DefaultAssets.FontSystem.NewStatic(data.LineHeight, glyphs, textures, 0, data.LineHeight));
#endif
        }
Ejemplo n.º 42
0
        private void LoadLevel(string level, string episode)
        {
            string levelPath = PathOp.Combine(DualityApp.DataDirectory, "Episodes", episode, level);

            using (Stream s = FileOp.Open(PathOp.Combine(levelPath, ".res"), FileAccessMode.Read)) {
                // ToDo: Cache parser, move JSON parsing to ContentResolver
                JsonParser      json   = new JsonParser();
                LevelConfigJson config = json.Parse <LevelConfigJson>(s);

                if (config.Version.LayerFormat > LayerFormatVersion || config.Version.EventSet > EventSetVersion)
                {
                    throw new NotSupportedException("Version not supported");
                }

                Console.WriteLine("Loading level \"" + config.Description.Name + "\"...");

                root.Title     = BitmapFont.StripFormatting(config.Description.Name);
                root.Immersive = false;

                defaultNextLevel    = config.Description.NextLevel;
                defaultSecretLevel  = config.Description.SecretLevel;
                ambientLightDefault = config.Description.DefaultLight;
                ambientLightCurrent = ambientLightTarget = ambientLightDefault * 0.01f;

                if (config.Description.DefaultDarkness != null && config.Description.DefaultDarkness.Count >= 4)
                {
                    darknessColor = new Vector4(config.Description.DefaultDarkness[0] / 255f, config.Description.DefaultDarkness[1] / 255f, config.Description.DefaultDarkness[2] / 255f, config.Description.DefaultDarkness[3] / 255f);
                }
                else
                {
                    darknessColor = new Vector4(0, 0, 0, 1);
                }

                // Palette
                {
                    ColorRgba[] tileMapPalette;

                    string levelPalette = PathOp.Combine(levelPath, ".palette");
                    if (FileOp.Exists(levelPalette))
                    {
                        tileMapPalette = TileSet.LoadPalette(levelPalette);
                    }
                    else
                    {
                        string tilesetPath = PathOp.Combine(DualityApp.DataDirectory, "Tilesets", config.Description.DefaultTileset);
                        tileMapPalette = TileSet.LoadPalette(PathOp.Combine(tilesetPath, ".palette"));
                    }

                    ContentResolver.Current.ApplyBasePalette(tileMapPalette);
                }

                // Tileset
                tileMap = new TileMap(this, config.Description.DefaultTileset, (config.Description.Flags & LevelFlags.HasPit) != 0);

                // Additional tilesets
                if (config.Tilesets != null)
                {
                    for (int i = 0; i < config.Tilesets.Count; i++)
                    {
                        LevelConfigJson.TilesetSection part = config.Tilesets[i];
                        tileMap.ReadTilesetPart(part.Name, part.Offset, part.Count);
                    }
                }

                // Read all layers
                config.Layers.Add("Sprite", new LevelConfigJson.LayerSection {
                    XSpeed = 1,
                    YSpeed = 1
                });

                foreach (var layer in config.Layers.OrderBy(layer => layer.Value.Depth))
                {
                    LayerType type;
                    if (layer.Key == "Sprite")
                    {
                        type = LayerType.Sprite;
                    }
                    else if (layer.Key == "Sky")
                    {
                        type = LayerType.Sky;

                        if (layer.Value.BackgroundStyle != 0 /*Plain*/ && layer.Value.BackgroundColor != null && layer.Value.BackgroundColor.Count >= 3)
                        {
                            camera.GetComponent <Camera>().ClearColor = new ColorRgba((byte)layer.Value.BackgroundColor[0], (byte)layer.Value.BackgroundColor[1], (byte)layer.Value.BackgroundColor[2]);
                        }
                    }
                    else
                    {
                        type = LayerType.Other;
                    }

                    tileMap.ReadLayerConfiguration(type, levelPath, layer.Key, layer.Value);
                }

                // Read animated tiles
                string animTilesPath = PathOp.Combine(levelPath, "Animated.tiles");
                if (FileOp.Exists(animTilesPath))
                {
                    tileMap.ReadAnimatedTiles(animTilesPath);
                }

                CameraController controller = camera.GetComponent <CameraController>();
                controller.ViewRect = new Rect(tileMap.Size * tileMap.Tileset.TileSize);

                // Read events
                eventMap = new EventMap(this, tileMap.Size);

                string eventsPath = PathOp.Combine(levelPath, "Events.layer");
                if (FileOp.Exists(animTilesPath))
                {
                    eventMap.ReadEvents(eventsPath, config.Version.LayerFormat, difficulty);
                }

                levelTexts = config.TextEvents ?? new Dictionary <int, string>();

                GameObject tilemapHandler = new GameObject("TilemapHandler");
                tilemapHandler.Parent = rootObject;
                tilemapHandler.AddComponent(tileMap);

                // Load default music
                musicPath = PathOp.Combine(DualityApp.DataDirectory, "Music", config.Description.DefaultMusic);
                music     = DualityApp.Sound.PlaySound(new OpenMptStream(musicPath));
                music.BeginFadeIn(0.5f);

                if (config.Description.DefaultWeather != WeatherType.None)
                {
                    ApplyWeather(
                        config.Description.DefaultWeather,
                        config.Description.DefaultWeatherIntensity,
                        config.Description.DefaultWeatherOutdoors);
                }
            }
        }
Ejemplo n.º 43
0
 public TextButtonStyle(IDrawable up, IDrawable down, IDrawable over, BitmapFont font) : base(up, down, over)
 {
     this.font = font ?? Graphics.instance.bitmapFont;
 }
Ejemplo n.º 44
0
 public TextButtonStyle()
 {
     font = Graphics.instance.bitmapFont;
 }
Ejemplo n.º 45
0
 /// <inheritdoc />
 /// <summary>
 ///     Ctor
 /// </summary>
 public FpsCounter(BitmapFont font, int size) => TextFps = new SpriteTextBitmap(font, "0 FPS", false)
Ejemplo n.º 46
0
 public WindowStyle(BitmapFont titleFont, Color titleFontColor, ISceneDrawable background)
 {
     Background     = background;
     TitleFont      = titleFont;
     TitleFontColor = titleFontColor;
 }
Ejemplo n.º 47
0
 public LabelStyle()
 {
     Font = Graphics.Instance.BitmapFont;
 }
Ejemplo n.º 48
0
 /// <summary>
 /// LoadContent will be called once per game and is the place to load
 /// all of your content.
 /// </summary>
 protected override void LoadContent()
 {
     // Create a new SpriteBatch, which can be used to draw textures.
     spriteBatch = new SpriteBatch(GraphicsDevice);
     bitmapFont  = Content.Load <BitmapFont>("Fonts/fixedsys");
 }
Ejemplo n.º 49
0
 public Label(string text, BitmapFont font, Color fontColor) : this(text, new LabelStyle(font, fontColor))
 {
 }
Ejemplo n.º 50
0
 public FontStyle(BitmapFont font, Color color)
 {
     Font  = font;
     Color = color;
 }
Ejemplo n.º 51
0
 /// <summary>
 /// Loads the font into the dictionary and in turn the memory.
 /// </summary>
 /// <param name="key"></param>
 /// <param name="font"></param>
 public static void LoadFont(string key, BitmapFont font)
 {
     _fonts[key] = font;
 }
Ejemplo n.º 52
0
 public static void DrawText(this SpriteBatch spriteBatch, BitmapFont font, Vector2 position, string text, Color color)
 {
     font.Draw(spriteBatch, position, text, color);
 }
Ejemplo n.º 53
0
        private Vector2 GetTextPosition(int xPx, int yPx, int cellWidthPx, TextAlignment alignment, string text, BitmapFont font)
        {
            var y = yPx + 1 + _style.CellPaddingY;
            var x = 0;

            switch (alignment)
            {
            case TextAlignment.Left:
                x = xPx + 1 + _style.CellPaddingX;
                break;

            case TextAlignment.Right:
            {
                var size = font.MeasureString(text);
                x = (int)(xPx + cellWidthPx - size.Width - _style.CellPaddingX);
                break;
            }

            case TextAlignment.Center:
            {
                var size = font.MeasureString(text);
                x = (int)(xPx + ((cellWidthPx - size.Width) / 2));
                break;
            }
            }

            return(new Vector2(x, y));
        }
Ejemplo n.º 54
0
        public static void DrawStringOnCtrl(this SpriteBatch spriteBatch,
                                            Control ctrl,
                                            string text,
                                            BitmapFont font,
                                            Rectangle destinationRectangle,
                                            Color color,
                                            bool wrap,
                                            bool stroke,
                                            int strokeDistance = 1,
                                            HorizontalAlignment horizontalAlignment = HorizontalAlignment.Left,
                                            VerticalAlignment verticalAlignment     = VerticalAlignment.Middle)
        {
            if (string.IsNullOrEmpty(text))
            {
                return;
            }

            text = wrap ? DrawUtil.WrapText(font, text, destinationRectangle.Width) : text;

            // TODO: This does not account for vertical alignment
            if (horizontalAlignment != HorizontalAlignment.Left && (wrap || text.Contains("\n")))
            {
                using (StringReader reader = new StringReader(text)) {
                    string line;

                    int lineHeightDiff = 0;

                    while (destinationRectangle.Height - lineHeightDiff > 0 && (line = reader.ReadLine()) != null)
                    {
                        DrawStringOnCtrl(spriteBatch, ctrl, line, font, destinationRectangle.Add(0, lineHeightDiff, 0, -0), color, wrap, stroke, strokeDistance, horizontalAlignment, verticalAlignment);

                        lineHeightDiff += font.LineHeight;
                    }
                }

                return;
            }

            Vector2 textSize = font.MeasureString(text);

            destinationRectangle = destinationRectangle.ToBounds(ctrl.AbsoluteBounds);

            int xPos = destinationRectangle.X;
            int yPos = destinationRectangle.Y;

            switch (horizontalAlignment)
            {
            case HorizontalAlignment.Center:
                xPos += destinationRectangle.Width / 2 - (int)textSize.X / 2;
                break;

            case HorizontalAlignment.Right:
                xPos += destinationRectangle.Width - (int)textSize.X;
                break;
            }

            switch (verticalAlignment)
            {
            case VerticalAlignment.Middle:
                yPos += destinationRectangle.Height / 2 - (int)textSize.Y / 2;
                break;

            case VerticalAlignment.Bottom:
                yPos += destinationRectangle.Height - (int)textSize.Y;
                break;
            }

            var textPos = new Vector2(xPos, yPos);

            if (stroke)
            {
                spriteBatch.DrawString(font, text, textPos.OffsetBy(0, -strokeDistance), Color.Black * ctrl.AbsoluteOpacity());
                spriteBatch.DrawString(font, text, textPos.OffsetBy(strokeDistance, -strokeDistance), Color.Black * ctrl.AbsoluteOpacity());
                spriteBatch.DrawString(font, text, textPos.OffsetBy(strokeDistance, 0), Color.Black * ctrl.AbsoluteOpacity());
                spriteBatch.DrawString(font, text, textPos.OffsetBy(strokeDistance, strokeDistance), Color.Black * ctrl.AbsoluteOpacity());
                spriteBatch.DrawString(font, text, textPos.OffsetBy(0, strokeDistance), Color.Black * ctrl.AbsoluteOpacity());
                spriteBatch.DrawString(font, text, textPos.OffsetBy(-strokeDistance, strokeDistance), Color.Black * ctrl.AbsoluteOpacity());
                spriteBatch.DrawString(font, text, textPos.OffsetBy(-strokeDistance, 0), Color.Black * ctrl.AbsoluteOpacity());
                spriteBatch.DrawString(font, text, textPos.OffsetBy(-strokeDistance, -strokeDistance), Color.Black * ctrl.AbsoluteOpacity());
            }

            spriteBatch.DrawString(font, text, textPos, color * ctrl.AbsoluteOpacity());
        }
Ejemplo n.º 55
0
 public WindowStyle()
 {
     titleFont = Graphics.instance.bitmapFont;
 }
Ejemplo n.º 56
0
 public LabelStyle()
 {
     font = Graphics.instance.bitmapFont;
 }
Ejemplo n.º 57
0
 public WindowStyle(BitmapFont titleFont, Color titleFontColor, IDrawable background)
 {
     this.titleFont      = titleFont ?? Graphics.instance.bitmapFont;
     this.background     = background;
     this.titleFontColor = titleFontColor;
 }
Ejemplo n.º 58
0
        public T LoadFromFile <T>(string assetName)
        {
            string extension = FileManager.GetExtension(assetName);

            if (FileManager.IsRelative(assetName))
            {
                // get the absolute path using the current relative directory
                assetName = FileManager.RelativeDirectory + assetName;
            }



            string fullNameWithType = assetName + typeof(T).Name;


            // get the dictionary by the contentManagerName.  If it doesn't exist, GetDisposableDictionaryByName
            // will create it.

            if (mDisposableDictionary.ContainsKey(fullNameWithType))
            {
#if PROFILE
                mHistory.Add(new ContentLoadHistory(
                                 TimeManager.CurrentTime, typeof(T).Name, fullNameWithType, ContentLoadDetail.Cached));
#endif

                return((T)mDisposableDictionary[fullNameWithType]);
            }
            else if (mNonDisposableDictionary.ContainsKey(fullNameWithType))
            {
                return((T)mNonDisposableDictionary[fullNameWithType]);
            }
            else
            {
#if PROFILE
                mHistory.Add(new ContentLoadHistory(
                                 TimeManager.CurrentTime,
                                 typeof(T).Name,
                                 fullNameWithType,
                                 ContentLoadDetail.HddFromFile));
#endif
#if DEBUG
                // The ThrowExceptionIfFileDoesntExist
                // call used to be done before the checks
                // in the dictionaries.  But whatever is held
                // in there may not really be a file so let's check
                // if the file exists after we check the dictionaries.
                FileManager.ThrowExceptionIfFileDoesntExist(assetName);
#endif

                IDisposable loadedAsset = null;

                if (typeof(T) == typeof(Texture2D) || typeof(T) == typeof(Microsoft.Xna.Framework.Graphics.Texture2D))
                {
                    // for now we'll create it here, eventually have it in a dictionary:
                    loadedAsset = textureContentLoader.Load(assetName);
                }

                #region Scene

                else if (typeof(T) == typeof(FlatRedBall.Scene))
                {
                    FlatRedBall.Scene scene = FlatRedBall.Content.Scene.SceneSave.FromFile(assetName).ToScene(mName);

                    object sceneAsObject = scene;

                    lock (mNonDisposableDictionary)
                    {
                        if (!mNonDisposableDictionary.ContainsKey(fullNameWithType))
                        {
                            mNonDisposableDictionary.Add(fullNameWithType, scene);
                        }
                    }
                    return((T)sceneAsObject);
                }

                #endregion

                #region EmitterList

                else if (typeof(T) == typeof(EmitterList))
                {
                    EmitterList emitterList = EmitterSaveList.FromFile(assetName).ToEmitterList(mName);


                    mNonDisposableDictionary.Add(fullNameWithType, emitterList);


                    return((T)((object)emitterList));
                }

                #endregion

                #region Image
#if !MONOGAME
                else if (typeof(T) == typeof(Image))
                {
                    switch (extension.ToLowerInvariant())
                    {
                    case "gif":
                        Image image = Image.FromFile(assetName);
                        loadedAsset = image;
                        break;
                    }
                }
#endif
                #endregion

                #region BitmapList
#if !XBOX360 && !SILVERLIGHT && !WINDOWS_PHONE && !MONOGAME
                else if (typeof(T) == typeof(BitmapList))
                {
                    loadedAsset = BitmapList.FromFile(assetName);
                }
#endif

                #endregion

                #region NodeNetwork
                else if (typeof(T) == typeof(NodeNetwork))
                {
                    NodeNetwork nodeNetwork = NodeNetworkSave.FromFile(assetName).ToNodeNetwork();

                    mNonDisposableDictionary.Add(fullNameWithType, nodeNetwork);

                    return((T)((object)nodeNetwork));
                }
                #endregion

                #region ShapeCollection

                else if (typeof(T) == typeof(ShapeCollection))
                {
                    ShapeCollection shapeCollection =
                        ShapeCollectionSave.FromFile(assetName).ToShapeCollection();

                    mNonDisposableDictionary.Add(fullNameWithType, shapeCollection);

                    return((T)((object)shapeCollection));
                }
                #endregion

                #region PositionedObjectList<Polygon>

                else if (typeof(T) == typeof(PositionedObjectList <FlatRedBall.Math.Geometry.Polygon>))
                {
                    PositionedObjectList <FlatRedBall.Math.Geometry.Polygon> polygons =
                        PolygonSaveList.FromFile(assetName).ToPolygonList();
                    mNonDisposableDictionary.Add(fullNameWithType, polygons);
                    return((T)((object)polygons));
                }

                #endregion

                #region AnimationChainList

                else if (typeof(T) == typeof(AnimationChainList))
                {
                    if (assetName.EndsWith("gif"))
                    {
#if WINDOWS_8 || UWP || DESKTOP_GL
                        throw new NotImplementedException();
#else
                        AnimationChainList acl = new AnimationChainList();
                        acl.Add(FlatRedBall.Graphics.Animation.AnimationChain.FromGif(assetName, this.mName));
                        acl[0].ParentGifFileName = assetName;
                        loadedAsset = acl;
#endif
                    }
                    else
                    {
                        loadedAsset =
                            AnimationChainListSave.FromFile(assetName).ToAnimationChainList(mName);
                    }

                    mNonDisposableDictionary.Add(fullNameWithType, loadedAsset);
                }

                #endregion

                else if (typeof(T) == typeof(Song))
                {
                    var loader = new SongLoader();
                    return((T)(object)loader.Load(assetName));
                }
#if MONOGAME
                else if (typeof(T) == typeof(SoundEffect))
                {
                    T soundEffect;

                    if (assetName.StartsWith(@".\") || assetName.StartsWith(@"./"))
                    {
                        soundEffect = base.Load <T>(assetName.Substring(2));
                    }
                    else
                    {
                        soundEffect = base.Load <T>(assetName);
                    }

                    return(soundEffect);
                }
#endif

                #region RuntimeCsvRepresentation

#if !SILVERLIGHT
                else if (typeof(T) == typeof(RuntimeCsvRepresentation))
                {
#if XBOX360
                    throw new NotImplementedException("Can't load CSV from file.  Try instead to use the content pipeline.");
#else
                    return((T)((object)CsvFileManager.CsvDeserializeToRuntime(assetName)));
#endif
                }
#endif


                #endregion

                #region SplineList

                else if (typeof(T) == typeof(List <Spline>))
                {
                    List <Spline> splineList = SplineSaveList.FromFile(assetName).ToSplineList();
                    mNonDisposableDictionary.Add(fullNameWithType, splineList);
                    object asObject = splineList;

                    return((T)asObject);
                }

                else if (typeof(T) == typeof(SplineList))
                {
                    SplineList splineList = SplineSaveList.FromFile(assetName).ToSplineList();
                    mNonDisposableDictionary.Add(fullNameWithType, splineList);
                    object asObject = splineList;

                    return((T)asObject);
                }

                #endregion

                #region BitmapFont

                else if (typeof(T) == typeof(BitmapFont))
                {
                    // We used to assume the texture is named the same as the font file
                    // But now FRB understands the .fnt file and gets the PNG from the font file
                    //string pngFile = FileManager.RemoveExtension(assetName) + ".png";
                    string fntFile = FileManager.RemoveExtension(assetName) + ".fnt";

                    BitmapFont bitmapFont = new BitmapFont(fntFile, this.mName);

                    object bitmapFontAsObject = bitmapFont;

                    return((T)bitmapFontAsObject);
                }

                #endregion


                #region Text

                else if (typeof(T) == typeof(string))
                {
                    return((T)((object)FileManager.FromFileText(assetName)));
                }

                #endregion

                #region Catch mistakes

#if DEBUG
                else if (typeof(T) == typeof(Spline))
                {
                    throw new Exception("Cannot load Splines.  Try using the List<Spline> type instead.");
                }
                else if (typeof(T) == typeof(Emitter))
                {
                    throw new Exception("Cannot load Emitters.  Try using the EmitterList type instead.");
                }
#endif

                #endregion

                #region else, exception!

                else
                {
                    throw new NotImplementedException("Cannot load content of type " +
                                                      typeof(T).AssemblyQualifiedName + " from file.  If you are loading " +
                                                      "through the content pipeline be sure to remove the extension of the file " +
                                                      "name.");
                }

                #endregion

                if (loadedAsset != null)
                {
                    lock (mDisposableDictionary)
                    {
                        // Multiple threads could try to load this content simultaneously
                        if (!mDisposableDictionary.ContainsKey(fullNameWithType))
                        {
                            mDisposableDictionary.Add(fullNameWithType, loadedAsset);
                        }
                    }
                }

                return((T)loadedAsset);
            }
        }
Ejemplo n.º 59
0
 public FontStyle(BitmapFont font) : this(font, Color.White)
 {
 }
Ejemplo n.º 60
0
 public LabelStyle(BitmapFont font, Color fontColor)
 {
     this.font      = font ?? Graphics.instance.bitmapFont;
     this.fontColor = fontColor;
 }