Beispiel #1
0
 /// <summary>
 /// Checks whether this UIFontSpriteDefinition contains the same components as the specified UIFontSpriteDefinition.
 /// </summary>
 /// <param name="other">The UIFontSpriteDefinition to test.</param>
 /// <returns>
 /// True if other UIFontSpriteDefinition has the same components as this UIFontSpriteDefinition.
 /// </returns>
 public bool Equals(UIFontSpriteDefinition other)
 {
     return((!this.isDefined && !other.isDefined) ||
            (this.isDefined && other.isDefined &&
             this.pixelSize == other.pixelSize &&
             this.fontColor == other.fontColor));
 }
Beispiel #2
0
        /// <summary>
        /// Gets the font sprite with the given pixel size and font color.
        /// </summary>
        /// <param name="pixelSize">The pixel size of the font sprite.</param>
        /// <param name="fontColor">The color of the font sprite.</param>
        /// <returns>The font sprite with the given pixel size and font color.</returns>
        public UISprite GetFontSprite(RCIntVector pixelSize, RCColor fontColor)
        {
            if (pixelSize == RCIntVector.Undefined)
            {
                throw new ArgumentNullException("pixelSize");
            }
            if (fontColor == RCColor.Undefined)
            {
                throw new ArgumentNullException("fontColor");
            }

            UIFontSpriteDefinition spriteDef = new UIFontSpriteDefinition(pixelSize, fontColor);

            if (!this.fontSprites.ContainsKey(spriteDef))
            {
                /// Load the font sprite with the given pixel size and color if necessary.
                UISprite newFontSprite =
                    UIRoot.Instance.GraphicsPlatform.SpriteManager.CreateSprite(fontColor,
                                                                                this.originalFontSprite.Size,
                                                                                pixelSize);
                IUIRenderContext newFontSpriteCtx =
                    UIRoot.Instance.GraphicsPlatform.SpriteManager.CreateRenderContext(newFontSprite);
                newFontSpriteCtx.RenderSprite(this.originalFontSprite, new RCIntVector(0, 0));
                UIRoot.Instance.GraphicsPlatform.SpriteManager.CloseRenderContext(newFontSprite);
                newFontSprite.TransparentColor = this.transparentColor;
                newFontSprite.Upload();
                this.fontSprites.Add(spriteDef, newFontSprite);
            }

            return(this.fontSprites[spriteDef]);
        }
Beispiel #3
0
        /// <summary>
        /// Initializes a new UIFontSpriteDefinition with the specified UIFontSpriteDefinition.
        /// </summary>
        /// <param name="other">The UIFontSpriteDefinition to initialize with.</param>
        public UIFontSpriteDefinition(UIFontSpriteDefinition other)
        {
            if (!other.isDefined)
            {
                throw new ArgumentNullException("other");
            }

            this.isDefined = true;
            this.pixelSize = other.pixelSize;
            this.fontColor = other.fontColor;
        }