// OnProcess protected unsafe override void OnProcess(FontSpriteList list) { fixed(FontSprite *pSpriteStart = &list.Sprites[0]) for (int i = list.RenderStart; i < list.RenderEnd; ++i) { (pSpriteStart + i)->Colors.MultA((byte)(Lerp.Adjust(SpriteTimes01[i], LerpType) * 255.0f)); } }
// CopyTo public void CopyTo( FontSpriteList o ) { o.RenderPass = RenderPass; o.Layer = Layer; for ( int i = 0; i < Sprites.Length; ++i ) o.Sprites[ i ] = Sprites[ i ]; o.RenderStart = RenderStart; o.RenderEnd = RenderEnd; }
// OnProcess protected unsafe override void OnProcess(FontSpriteList list) { list.RenderEnd = list.RenderStart + CurrentSprite; FontData fontData = Widget.FontStyle.Font.FontData; float scale = Widget.RenderSizeY / fontData.FontHeight; float multY = Widget.UpY; fixed(FontDataChar *pCharDataStart = &fontData.Characters[0]) fixed(FontSprite * pSpriteStart = &list.Sprites[0]) { for (int i = list.RenderStart; i < list.RenderEnd; ++i) { FontSprite *pSprite = (pSpriteStart + i); if (pSprite->IconIndex != -1) { continue; } float time01 = SpriteTimes01[i]; if (time01 == 1.0f) { continue; } char c = (char)Rand.Next(97, 123); int characterIndex = fontData.GetCharacterIndex(pSprite->Character); FontDataChar *pCharData = (pCharDataStart + characterIndex); int characterIndexRandom = fontData.GetCharacterIndex(c); FontDataChar *pCharDataRandom = (pCharDataStart + characterIndexRandom); pSprite->Position.X -= (pCharData->OffsetX * scale); pSprite->Position.Y -= (pCharData->OffsetY * scale) * multY; pSprite->Position.X += (pCharDataRandom->OffsetX * scale); pSprite->Position.Y += (pCharDataRandom->OffsetY * scale) * multY; pSprite->Size.X = pCharDataRandom->Width * scale; pSprite->Size.Y = pCharDataRandom->Height * scale; pSprite->Texture.PUV.X = (float)pCharDataRandom->X / fontData.TextureWidth; pSprite->Texture.PUV.Y = (float)pCharDataRandom->Y / fontData.TextureHeight; pSprite->Texture.SUV.X = (float)pCharDataRandom->Width / fontData.TextureWidth; pSprite->Texture.SUV.Y = (float)pCharDataRandom->Height / fontData.TextureHeight; } } }
// CopyTo public void CopyTo(FontSpriteList o) { o.RenderPass = RenderPass; o.Layer = Layer; for (int i = 0; i < Sprites.Length; ++i) { o.Sprites[i] = Sprites[i]; } o.RenderStart = RenderStart; o.RenderEnd = RenderEnd; }
// OnProcess protected unsafe override void OnProcess(FontSpriteList list) { fixed(FontSprite *pSpriteStart = &list.Sprites[0]) { for (int i = list.RenderStart; i < list.RenderEnd; ++i) { FontSprite *pSprite = (pSpriteStart + i); SpriteColors c = Colors; c.MultA(ref pSprite->Colors); if (pSprite->Colors.PreMultipliedAlpha) { c.ToPremultiplied(); } pSprite->Colors.Lerp(ref pSprite->Colors, ref c, Lerp.Adjust(SpriteTimes01[i], LerpType)); } } }
// OnInit protected override void OnInit() { RenderState.BlendState = E_BlendState.NonPremultiplied; // handled in the FontStyle RenderSizeX = Size.X; RenderSizeY = Size.Y; if (FontStyleName != null) { FontStyle = _UI.Store_FontStyle.Get(FontStyleName); } for (int i = 0; i < FontEffects.Count; ++i) { FontEffects[i].Bind(this); } if (Cache && (SpriteListCache == null)) { SpriteListCache = new FontSpriteList(); } }
// OnProcess protected unsafe override void OnProcess(FontSpriteList list) { float multY = Widget.UpY; fixed(FontSprite *pSpriteStart = &list.Sprites[0]) { for (int i = list.RenderStart; i < list.RenderEnd; ++i) { FontSprite *pSprite = (pSpriteStart + i); float time01 = Lerp.Adjust(SpriteTimes01[i], LerpType); float scaleX = ScaleFromX + (ScaleToX - ScaleFromX) * time01; float scaleY = ScaleFromY + (ScaleToY - ScaleFromY) * time01; pSprite->Position.X -= (pSprite->Size.X * (scaleX - 1.0f) * 0.5f); pSprite->Position.Y -= (pSprite->Size.Y * (scaleY - 1.0f) * 0.5f) * multY; pSprite->Size.X *= scaleX; pSprite->Size.Y *= scaleY; } } }
// Render public unsafe void Render( FontSpriteList list, float height ) { fixed ( FontSprite *pSpriteStart = &list.Sprites[ 0 ] ) { for ( int i = 0; i < RenderPasses.Count; ++i ) { FontStyleRenderPass renderPass = RenderPasses[ i ]; FontSprite *pSprite = ( pSpriteStart + list.RenderStart ); for ( int j = list.RenderStart; j < list.RenderEnd; ++j, ++pSprite ) { bool isIcon = ( pSprite->IconIndex != -1 ); SpriteColors colors; if ( !renderPass.ColorOverride.HasValue ) colors = pSprite->Colors; else { colors = renderPass.ColorOverride.Value; colors.MultA( ref pSprite->Colors ); if ( pSprite->Colors.PreMultipliedAlpha ) colors.ToPremultiplied(); } if ( renderPass.AlphaMult != 1.0f ) colors.MultA( (byte)( renderPass.AlphaMult * 255.0f ) ); // should this be auto-adjusted for 3d? I'm not convinced atm ... Vector3 position = pSprite->Position + ( renderPass.OffsetProportional ? ( renderPass.Offset * height ) : renderPass.Offset ); if ( isIcon ) { FontIcon fontIcon = _UI.Store_FontIcon.Get( pSprite->IconIndex ); _UI.Sprite.AddSprite( list.RenderPass, list.Layer + fontIcon.LayerOffset, ref position, pSprite->Size.X, pSprite->Size.Y, E_Align.TopLeft, ref colors, ref fontIcon.RenderState ); } else _UI.Sprite.AddSprite( list.RenderPass, list.Layer, ref position, pSprite->Size.X, pSprite->Size.Y, E_Align.TopLeft, ref colors, ref RenderState ); _UI.Sprite.AddTexture( 0, ref pSprite->Texture ); if ( !isIcon && ( renderPass.TextureIndex != -1 ) ) { Vector2 puv = new Vector2(); Vector2 suv = new Vector2( 1.0f ); switch ( renderPass.TextureMode ) { case E_FontStyleTextureMode.Character: { puv.X = pSprite->Texture.PUV.X; puv.Y = pSprite->Texture.PUV.Y; suv.X = pSprite->Texture.SUV.X; suv.Y = pSprite->Texture.SUV.Y; break; } case E_FontStyleTextureMode.Shift: { puv.X = pSprite->Texture.PUV.X; suv.X = pSprite->Size.X / pSprite->Size.Y; break; } case E_FontStyleTextureMode.PositionShift: { puv.X = pSprite->Texture.PUV.X + ( pSprite->Position.X * 0.5f ); suv.X = pSprite->Size.X / pSprite->Size.Y; break; } } _UI.Sprite.AddTexture( 1, renderPass.TextureIndex, ref puv, ref suv ); } } } } }
// OnProcess protected unsafe override void OnProcess( FontSpriteList list ) { fixed ( FontSprite* pSpriteStart = &list.Sprites[ 0 ] ) for ( int i = list.RenderStart; i < list.RenderEnd; ++i ) ( pSpriteStart + i )->Colors.MultA( (byte)( Lerp.Adjust( SpriteTimes01[ i ], LerpType ) * 255.0f ) ); }
// OnProcess protected unsafe override void OnProcess( FontSpriteList list ) { fixed ( FontSprite* pSpriteStart = &list.Sprites[ 0 ] ) { for ( int i = list.RenderStart; i < list.RenderEnd; ++i ) { FontSprite* pSprite = ( pSpriteStart + i ); SpriteColors c = Colors; c.MultA( ref pSprite->Colors ); if ( pSprite->Colors.PreMultipliedAlpha ) c.ToPremultiplied(); pSprite->Colors.Lerp( ref pSprite->Colors, ref c, Lerp.Adjust( SpriteTimes01[ i ], LerpType ) ); } } }
// OnProcess protected unsafe override void OnProcess( FontSpriteList list ) { float multY = Widget.UpY; fixed ( FontSprite* pSpriteStart = &list.Sprites[ 0 ] ) { for ( int i = list.RenderStart; i < list.RenderEnd; ++i ) { FontSprite* pSprite = ( pSpriteStart + i ); float time01 = Lerp.Adjust( SpriteTimes01[ i ], LerpType ); float scaleX = ScaleFromX + ( ScaleToX - ScaleFromX ) * time01; float scaleY = ScaleFromY + ( ScaleToY - ScaleFromY ) * time01; pSprite->Position.X -= ( pSprite->Size.X * ( scaleX - 1.0f ) * 0.5f ); pSprite->Position.Y -= ( pSprite->Size.Y * ( scaleY - 1.0f ) * 0.5f ) * multY; pSprite->Size.X *= scaleX; pSprite->Size.Y *= scaleY; } } }
// OnProcess protected override void OnProcess(FontSpriteList list) { list.RenderEnd = list.RenderStart + CurrentSprite; }
// OnProcess protected virtual void OnProcess(FontSpriteList list) { // }
// OnProcess protected virtual void OnProcess( FontSpriteList list ) { // }
// Process public void Process(FontSpriteList list) { SpriteCount = list.RenderEnd - list.RenderStart; OnProcess(list); }
// OnInit protected override void OnInit() { RenderState.BlendState = E_BlendState.NonPremultiplied; // handled in the FontStyle RenderSizeX = Size.X; RenderSizeY = Size.Y; if ( FontStyleName != null ) FontStyle = _UI.Store_FontStyle.Get( FontStyleName ); for ( int i = 0; i < FontEffects.Count; ++i ) FontEffects[ i ].Bind( this ); if ( Cache && ( SpriteListCache == null ) ) SpriteListCache = new FontSpriteList(); }
// OnProcess protected override void OnProcess( FontSpriteList list ) { list.RenderEnd = list.RenderStart + CurrentSprite; }
// FontManager public FontManager() { Fonts = new List< Font >(); SpriteList = new FontSpriteList(); StringUI = new StringUI( 16 ); }
// Process public void Process( FontSpriteList list ) { SpriteCount = list.RenderEnd - list.RenderStart; OnProcess( list ); }
// OnProcess protected unsafe override void OnProcess( FontSpriteList list ) { list.RenderEnd = list.RenderStart + CurrentSprite; FontData fontData = Widget.FontStyle.Font.FontData; float scale = Widget.RenderSizeY / fontData.FontHeight; float multY = Widget.UpY; fixed ( FontDataChar* pCharDataStart = &fontData.Characters[ 0 ] ) fixed ( FontSprite* pSpriteStart = &list.Sprites[ 0 ] ) { for ( int i = list.RenderStart; i < list.RenderEnd; ++i ) { FontSprite* pSprite = ( pSpriteStart + i ); if ( pSprite->IconIndex != -1 ) continue; float time01 = SpriteTimes01[ i ]; if ( time01 == 1.0f ) continue; char c = (char)Rand.Next( 97, 123 ); int characterIndex = fontData.GetCharacterIndex( pSprite->Character ); FontDataChar* pCharData = ( pCharDataStart + characterIndex ); int characterIndexRandom = fontData.GetCharacterIndex( c ); FontDataChar* pCharDataRandom = ( pCharDataStart + characterIndexRandom ); pSprite->Position.X -= ( pCharData->OffsetX * scale ); pSprite->Position.Y -= ( pCharData->OffsetY * scale ) * multY; pSprite->Position.X += ( pCharDataRandom->OffsetX * scale ); pSprite->Position.Y += ( pCharDataRandom->OffsetY * scale ) * multY; pSprite->Size.X = pCharDataRandom->Width * scale; pSprite->Size.Y = pCharDataRandom->Height * scale; pSprite->Texture.PUV.X = (float)pCharDataRandom->X / fontData.TextureWidth; pSprite->Texture.PUV.Y = (float)pCharDataRandom->Y / fontData.TextureHeight; pSprite->Texture.SUV.X = (float)pCharDataRandom->Width / fontData.TextureWidth; pSprite->Texture.SUV.Y = (float)pCharDataRandom->Height / fontData.TextureHeight; } } }
// FontManager public FontManager() { Fonts = new List <Font>(); SpriteList = new FontSpriteList(); StringUI = new StringUI(16); }