コード例 #1
0
ファイル: Button.cs プロジェクト: weimingtom/Sakura
 private void UpdateTextSprite()
 {
     if (string.IsNullOrEmpty(this.Text))
     {
         this.textSprt.Visible = false;
         this.updateFlags     &= ~Button.UpdateFlags.Text;
     }
     if ((this.updateFlags & Button.UpdateFlags.Text) == Button.UpdateFlags.Text)
     {
         TextRenderHelper textRenderHelper = new TextRenderHelper();
         textRenderHelper.LineBreak           = LineBreak.AtCode;
         textRenderHelper.HorizontalAlignment = this.HorizontalAlignment;
         textRenderHelper.VerticalAlignment   = this.VerticalAlignment;
         textRenderHelper.Font         = this.TextFont;
         textRenderHelper.TextTrimming = this.TextTrimming;
         UISpriteUnit unit = this.textSprt.GetUnit(0);
         unit.Width  = this.Width;
         unit.Height = this.Height;
         unit.Color  = this.TextColor;
         if (this.textSprt.Image != null)
         {
             this.textSprt.Image.Dispose();
         }
         this.textSprt.Image      = textRenderHelper.DrawText(ref this.text, (int)unit.Width, (int)unit.Height);
         this.textSprt.Alpha      = ((this.State == Button.ButtonState.Disabled) ? 0.3f : 1f);
         this.textSprt.ShaderType = ShaderType.TextTexture;
         this.textSprt.Visible    = true;
         this.iconSprt.Visible    = false;
         if (this.TextShadow != null)
         {
             this.textSprt.InternalShaderType = InternalShaderType.TextureAlphaShadow;
             this.textSprt.ShaderUniforms["u_ShadowColor"] = new float[]
             {
                 this.TextShadow.Color.R,
                 this.TextShadow.Color.G,
                 this.TextShadow.Color.B,
                 this.TextShadow.Color.A
             };
             this.textSprt.ShaderUniforms["u_ShadowOffset"] = new float[]
             {
                 this.TextShadow.HorizontalOffset / (float)this.textSprt.Image.Width,
                 this.TextShadow.VerticalOffset / (float)this.textSprt.Image.Height
             };
         }
         this.updateFlags &= ~Button.UpdateFlags.Text;
     }
 }
コード例 #2
0
ファイル: Label.cs プロジェクト: weimingtom/Sakura
 private void UpdateTextSprite()
 {
     if ((this.updateFlags & Label.UpdateFlags.Text) == Label.UpdateFlags.Text)
     {
         //FIXME:refresh text texture
         UISpriteUnit unit = this.textSprt.GetUnit(0);
         unit.Width  = this.Width;
         unit.Height = this.Height;
         unit.Color  = this.TextColor;
         TextRenderHelper textRenderHelper = new TextRenderHelper();
         textRenderHelper.Font = this.Font;
         textRenderHelper.HorizontalAlignment = this.HorizontalAlignment;
         textRenderHelper.VerticalAlignment   = this.VerticalAlignment;
         textRenderHelper.LineBreak           = this.LineBreak;
         textRenderHelper.TextTrimming        = this.TextTrimming;
         textRenderHelper.LineGap             = this.LineGap;
         this.textSprt.Visible    = true;
         this.textSprt.ShaderType = ShaderType.TextTexture;
         this.textSprt.__name     = "see UpdateTextSprite";
         if (this.textSprt.Image != null)
         {
             this.textSprt.Image.Dispose();
         }
         //FIXME:write text to memory bitmap
         this.textSprt.Image = textRenderHelper.DrawText(ref this.text, (int)unit.Width, (int)unit.Height);
         if (this.TextShadow != null)
         {
             this.textSprt.InternalShaderType = InternalShaderType.TextureAlphaShadow;
             this.textSprt.ShaderUniforms["u_ShadowColor"] = new float[]
             {
                 this.TextShadow.Color.R,
                 this.TextShadow.Color.G,
                 this.TextShadow.Color.B,
                 this.TextShadow.Color.A
             };
             this.textSprt.ShaderUniforms["u_ShadowOffset"] = new float[]
             {
                 this.TextShadow.HorizontalOffset / (float)this.textSprt.Image.Width,
                 this.TextShadow.VerticalOffset / (float)this.textSprt.Image.Height
             };
         }
         this.updateFlags &= ~Label.UpdateFlags.Text;
     }
 }
コード例 #3
0
 private void UpdateTextSprite()
 {
     if ((this.updateFlags & EditableText.UpdateFlags.Text) == EditableText.UpdateFlags.Text)
     {
         UISpriteUnit unit = this.textSprt.GetUnit(0);
         unit.X      = 10f;
         unit.Y      = 4f;
         unit.Width  = this.Width - 20f;
         unit.Height = this.Height - 8f;
         TextRenderHelper textRenderHelper = new TextRenderHelper();
         textRenderHelper.HorizontalAlignment = this.HorizontalAlignment;
         textRenderHelper.VerticalAlignment   = this.VerticalAlignment;
         textRenderHelper.LineBreak           = this.LineBreak;
         textRenderHelper.TextTrimming        = this.TextTrimming;
         textRenderHelper.LineGap             = this.LineGap;
         if (string.IsNullOrEmpty(this.Text))
         {
             unit.Color               = this.DefaultTextColor;
             textRenderHelper.Font    = this.DefaultFont;
             this.textSprt.ShaderType = ShaderType.TextTexture;
             if (this.textSprt.Image != null)
             {
                 this.textSprt.Image.Dispose();
             }
             this.textSprt.Image = textRenderHelper.DrawText(ref this.defaultText, (int)unit.Width, (int)unit.Height);
         }
         else
         {
             string text;
             if (this.TextInputMode == (TextInputMode)2)
             {
                 text = new string('*', this.Text.Length);
             }
             else
             {
                 text = this.Text;
             }
             unit.Color               = this.TextColor;
             textRenderHelper.Font    = this.Font;
             this.textSprt.ShaderType = ShaderType.TextTexture;
             if (this.textSprt.Image != null)
             {
                 this.textSprt.Image.Dispose();
             }
             this.textSprt.Image = textRenderHelper.DrawText(ref text, (int)unit.Width, (int)unit.Height);
         }
         if (this.TextShadow != null)
         {
             this.textSprt.InternalShaderType = InternalShaderType.TextureAlphaShadow;
             this.textSprt.ShaderUniforms["u_ShadowColor"] = new float[]
             {
                 this.TextShadow.Color.R,
                 this.TextShadow.Color.G,
                 this.TextShadow.Color.B,
                 this.TextShadow.Color.A
             };
             this.textSprt.ShaderUniforms["u_ShadowOffset"] = new float[]
             {
                 this.TextShadow.HorizontalOffset / (float)this.textSprt.Image.Width,
                 this.TextShadow.VerticalOffset / (float)this.textSprt.Image.Height
             };
         }
         this.updateFlags &= ~EditableText.UpdateFlags.Text;
     }
 }