Example #1
0
 // CopyA
 public void CopyA(ref SpriteColors c)
 {
     Color0.A = c.Color0.A;
     Color1.A = c.Color1.A;
     Color2.A = c.Color2.A;
     Color3.A = c.Color3.A;
 }
Example #2
0
 // Lerp
 public void Lerp(ref SpriteColors from, ref SpriteColors to, float f01)
 {
     Color0.Lerp(from.Color0, to.Color0, f01);
     Color1.Lerp(from.Color1, to.Color1, f01);
     Color2.Lerp(from.Color2, to.Color2, f01);
     Color3.Lerp(from.Color3, to.Color3, f01);
 }
Example #3
0
        public void MultA(ref SpriteColors c)
        {
            Color0.A = (byte)((Color0.A * c.Color0.A) / 255);
            Color1.A = (byte)((Color1.A * c.Color1.A) / 255);
            Color2.A = (byte)((Color2.A * c.Color2.A) / 255);
            Color3.A = (byte)((Color3.A * c.Color3.A) / 255);

            if (PreMultipliedAlpha)
            {
                MultRGB(c.Color0.A, c.Color1.A, c.Color2.A, c.Color3.A);
            }
        }
Example #4
0
        // Process
        private Vector2 Process(ref StringProxy text, FontStyle fontStyle, int renderPass, int layer, ref Vector3 pos, float height, E_Align align, ref SpriteColors colors, float wrapSizeX)
        {
            RenderPass = renderPass;
            Layer      = layer;
            Position   = pos;
            Align      = align;
            Colors     = colors;

            if ((fontStyle.RenderState.BlendState == E_BlendState.AlphaBlend) && !Colors.PreMultipliedAlpha)
            {
                Colors.ToPremultiplied();
            }

            return(Process(ref text, fontStyle, height, wrapSizeX, E_FontProcessType.Draw));
        }
Example #5
0
        // 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));
                }
            }
        }
Example #6
0
        public unsafe void AddSprite(int renderPass, int layer, ref Vector3 pos, float sX, float sY, E_Align align, ref SpriteColors colors, ref RenderState renderState)
        {
            if (SpriteCount == SpriteCountMax)
                return;

            fixed(Sprite *pSprite = &Sprites[SpriteCount])
            {
                pSprite->Type = E_SpriteType.Sprite;

                pSprite->Position.X = pos.X + AutoTransformOffset.X;
                pSprite->Position.Y = pos.Y + AutoTransformOffset.Y;
                pSprite->Position.Z = pos.Z + AutoTransformOffset.Z;

                pSprite->Size.X      = sX;
                pSprite->Size.Y      = sY;
                pSprite->Align       = align;
                pSprite->RenderState = renderState;

                pSprite->PreTransformIndex  = 0;
                pSprite->PostTransformIndex = AutoTransformIndex;

                pSprite->Colors = colors;

                if ((renderState.BlendState == E_BlendState.AlphaBlend) && !pSprite->Colors.PreMultipliedAlpha)
                {
                    pSprite->Colors.ToPremultiplied();
                }

                pSprite->Texture0.TextureIndex = -1;
                pSprite->Texture1.TextureIndex = -1;
                pSprite->Texture2.TextureIndex = -1;

                pSprite->BatchCount = 1;
            }

            RenderPassLayerSprites[renderPass][layer].Add(SpriteCount);
            CurrentSprite = SpriteCount++;
        }
Example #7
0
        // OnRender
        protected override void OnRender()
        {
            ++FrameCounter;

            if (!d_ShowFPS)
            {
                return;
            }

            UI.SpriteColors c = _G.Game.IsRunningSlowly ? Color.Red : Color.Green;
            c.A(224);

            _UI.Sprite.AddSprite(RenderPass, Layer, ref Position, Size.X, Size.Y, UI.E_Align.TopRight, ref c, ref RenderState);
            _UI.Sprite.AddTexture(0, Textures[0].TextureIndex);

            Vector3 p = new Vector3(Position.X - (Size.Y / 2.0f), Position.Y + (Size.Y / 2.0f), Position.Z);

            UI.SpriteColors c2 = Color.Yellow;

            StringUI.Clear();
            StringUI.Add(FrameRate);

            _UI.Font.Draw(StringUI, FontStyle, RenderPass, Layer, ref p, Size.Y * 0.65f, UI.E_Align.MiddleCentre, ref c2, 0.0f);
        }
 // Lerp
 public void Lerp( ref SpriteColors from, ref SpriteColors to, float f01 )
 {
     Color0.Lerp( from.Color0, to.Color0, f01 );
     Color1.Lerp( from.Color1, to.Color1, f01 );
     Color2.Lerp( from.Color2, to.Color2, f01 );
     Color3.Lerp( from.Color3, to.Color3, f01 );
 }
        public void MultA( ref SpriteColors c )
        {
            Color0.A = (byte)( ( Color0.A * c.Color0.A ) / 255 );
            Color1.A = (byte)( ( Color1.A * c.Color1.A ) / 255 );
            Color2.A = (byte)( ( Color2.A * c.Color2.A ) / 255 );
            Color3.A = (byte)( ( Color3.A * c.Color3.A ) / 255 );

            if ( PreMultipliedAlpha )
            MultRGB( c.Color0.A, c.Color1.A, c.Color2.A, c.Color3.A );
        }
Example #10
0
        // Init
        public void Init()
        {
            if ( ColorBaseName != null )
            ColorBase = _UI.Store_Color.Get( ColorBaseName );

            if ( RenderStateName != null )
            RenderState = _UI.Store_RenderState.Get( RenderStateName );

            for ( int i = 0; i < Timelines.Count; ++i )
            Timelines[ i ].Bind( this );

            UpY = _UI.Sprite.IsRenderPass3D( RenderPass ) ? -1.0f : 1.0f;

            #if WINDOWS
            if ( Mouse_DefaultBB )
            {
            Mouse_SizeBB.X = Size.X;
            Mouse_SizeBB.Y = Size.Y;
            }

            Vector2 offset = _UI.Sprite.GetVertexOffsetAligned( RenderPass, Align );

            Mouse_PosBB.X -= ( Mouse_SizeBB.X * offset.X );
            Mouse_PosBB.Y -= ( Mouse_SizeBB.Y * offset.Y );
            #endif

            OnInit();
        }
 // CopyA
 public void CopyA( ref SpriteColors c )
 {
     Color0.A = c.Color0.A;
     Color1.A = c.Color1.A;
     Color2.A = c.Color2.A;
     Color3.A = c.Color3.A;
 }
Example #12
0
 public void ChangeColor(ref SpriteColors colors)
 {
     ColorBase = colors;
     FlagSet(E_WidgetFlag.DirtyColor);
 }
Example #13
0
 public void ChangeColor( string colorName )
 {
     ColorBase = _UI.Store_Color.Get( colorName );
     FlagSet( E_WidgetFlag.DirtyColor );
 }
Example #14
0
 public Vector2 Draw( StringUI text, FontStyle fontStyle, int renderPass, int layer, ref Vector3 pos, float height, E_Align align, ref SpriteColors colors, float wrapSizeX )
 {
     StringProxy stringProxy = new StringProxy( text );
     return Process( ref stringProxy, fontStyle, renderPass, layer, ref pos, height, align, ref colors, wrapSizeX );
 }
Example #15
0
        // WidgetBase
        public WidgetBase()
        {
            IsActive = true;
            IsSelected = true;

            Name = null;

            RenderPass = 0;
            Layer = 0;

            Position = new Vector3( 0.0f, 0.0f, 0.0f );
            Size = new Vector3( 0.0f, 0.0f, 0.0f );
            Scale = new Vector2( 1.0f, 1.0f );
            Rotation = new Vector3( 0.0f, 0.0f, 0.0f );

            Align = E_Align.TopLeft;

            ParentWidget = null;
            ParentAttach = E_Align.None;

            Children = new List< WidgetBase >();

            Alpha = 1.0f;
            Intensity = 1.0f;
            ColorBaseName = null;
            ColorBase = Color.Magenta;

            RenderStateName = null;
            RenderState = new RenderState( (int)E_Effect.MultiTexture1, E_BlendState.AlphaBlend );

            Textures = new List< SpriteTexture >();

            Timelines = new List< Timeline >();

            AlphaFinal = Alpha;
            IntensityFinal = Intensity;
            ColorFinal = ColorBase;

            Flags = (int)E_WidgetFlag.InheritAlpha | (int)E_WidgetFlag.InheritIntensity;
            TransformMatrix = Matrix.Identity;

            UpY = 1.0f;
        }
Example #16
0
        // Process
        private Vector2 Process( ref StringProxy text, FontStyle fontStyle, int renderPass, int layer, ref Vector3 pos, float height, E_Align align, ref SpriteColors colors, float wrapSizeX )
        {
            RenderPass = renderPass;
            Layer = layer;
            Position = pos;
            Align = align;
            Colors = colors;

            if ( ( fontStyle.RenderState.BlendState == E_BlendState.AlphaBlend ) && !Colors.PreMultipliedAlpha )
            Colors.ToPremultiplied();

            return Process( ref text, fontStyle, height, wrapSizeX, E_FontProcessType.Draw );
        }
 public TimelineEffect_ColorLerp( SpriteColors colorTo, E_LerpType lerpType )
     : base(0.0f, 1.0f, lerpType)
 {
     ColorTo = colorTo;
 }
Example #18
0
        // Update
        public void Update(float frameTime)
        {
        #if !RELEASE
            frameTime *= d_TimeScale;
        #endif

            int indexInput = -1;

            // determine which screens gets input
            for (int i = (ScreenControls.Count - 1); i >= 0; --i)
            {
                if (ScreenControls[i].CurrentScreen.AllowInput)
                {
                    indexInput = i;
                    break;
                }
            }

            // process each screen
            // - input and update all first
            for (int i = 0; i < ScreenControls.Count; ++i)
            {
                CurrentScreenControl = i;

                ScreenControl screenControl = ScreenControls[i];

                if (i == indexInput)
                {
                    screenControl.ProcessInput();
                }

                screenControl.Update(frameTime);
            }

            // - messages and render second
            for (int i = 0; i < ScreenControls.Count; ++i)
            {
                CurrentScreenControl = i;

                ScreenControl screenControl = ScreenControls[i];

                for (int j = 0; j < MessageCount; ++j)
                {
                    screenControl.ProcessMessage(ref MessagePool[j]);
                }

                screenControl.Render();
            }

            // remove any dead screens
            for (int i = (ScreenControls.Count - 1); i >= 0; --i)
            {
                if (ScreenControls[i].State == E_ScreenState.None)
                {
                    ScreenControls.RemoveAt(i);
                }
            }

            CurrentScreenControl = -1;
            MessageCount         = 0;

        #if !RELEASE
            if (d_ShowSafeArea)
            {
                SpriteColors c           = 0x40c0c000;
                RenderState  renderState = new RenderState((int)E_Effect.MultiTexture1, E_BlendState.AlphaBlend);
                _UI.Sprite.AddSprite(0, _UI.Sprite.TopLayer, _UI.SXL, _UI.SYT, 0.0f, _UI.SSX, _UI.SSY, E_Align.TopLeft, ref c, ref renderState);
                _UI.Sprite.AddTexture(0, _UI.Texture.Get("null"));
            }

            if (d_ShowScreens)
            {
                SpriteColors c = Color.DarkOrange;

                for (int i = 0; i < ScreenControls.Count; ++i)
                {
                    Vector3 p = new Vector3(_UI.SXM, _UI.SYB - (20.0f * i), 0.0f);

                    StringUI.Clear();
                    StringUI.Add(i);
                    StringUI.Add("  -  ");
                    StringUI.Add(ScreenControls[i].CurrentScreen.Name);

                    _UI.Font.Draw(StringUI, _UI.Store_FontStyle.Get("Default"), 0, _UI.Sprite.TopLayer, ref p, 20.0f, E_Align.BottomCentre, ref c, 0.0f);
                }
            }
        #endif
        }
Example #19
0
	public unsafe void AddSprite( int renderPass, int layer, ref Vector3 pos, float sX, float sY, E_Align align, ref SpriteColors colors, ref RenderState renderState )
	{
		if ( SpriteCount == SpriteCountMax )
			return;

		fixed ( Sprite* pSprite = &Sprites[ SpriteCount ] )
		{
			pSprite->Type = E_SpriteType.Sprite;

			pSprite->Position.X = pos.X + AutoTransformOffset.X;
			pSprite->Position.Y = pos.Y + AutoTransformOffset.Y;
			pSprite->Position.Z = pos.Z + AutoTransformOffset.Z;

			pSprite->Size.X = sX;
			pSprite->Size.Y = sY;
			pSprite->Align = align;
			pSprite->RenderState = renderState;

			pSprite->PreTransformIndex = 0;
			pSprite->PostTransformIndex = AutoTransformIndex;

			pSprite->Colors = colors;

			if ( ( renderState.BlendState == E_BlendState.AlphaBlend ) && !pSprite->Colors.PreMultipliedAlpha )
				pSprite->Colors.ToPremultiplied();

			pSprite->Texture0.TextureIndex = -1;
			pSprite->Texture1.TextureIndex = -1;
			pSprite->Texture2.TextureIndex = -1;

			pSprite->BatchCount = 1;
		}

		RenderPassLayerSprites[ renderPass ][ layer ].Add( SpriteCount );
		CurrentSprite = SpriteCount++;
	}
Example #20
0
        // Set
        public void Set(ref SpriteColors colors, float alpha, float intensity)
        {
            alpha     = MathHelper.Clamp(alpha, 0.0f, 1.0f);
            intensity = MathHelper.Clamp(intensity, 0.0f, 2.0f);

            PreMultipliedAlpha = false;

            byte a = (byte)(alpha * 255.0f);

            Color0.A = (byte)((colors.Color0.A * a) / 255);
            Color1.A = (byte)((colors.Color1.A * a) / 255);
            Color2.A = (byte)((colors.Color2.A * a) / 255);
            Color3.A = (byte)((colors.Color3.A * a) / 255);

            if (intensity == 1.0f)
            {
                Color0.R = colors.Color0.R;
                Color0.G = colors.Color0.G;
                Color0.B = colors.Color0.B;

                Color1.R = colors.Color1.R;
                Color1.G = colors.Color1.G;
                Color1.B = colors.Color1.B;

                Color2.R = colors.Color2.R;
                Color2.G = colors.Color2.G;
                Color2.B = colors.Color2.B;

                Color3.R = colors.Color3.R;
                Color3.G = colors.Color3.G;
                Color3.B = colors.Color3.B;
            }
            else
            if (intensity < 1.0f)
            {
                byte i = (byte)(intensity * 255.0f);

                Color0.R = (byte)((colors.Color0.R * i) / 255);
                Color0.G = (byte)((colors.Color0.G * i) / 255);
                Color0.B = (byte)((colors.Color0.B * i) / 255);

                Color1.R = (byte)((colors.Color1.R * i) / 255);
                Color1.G = (byte)((colors.Color1.G * i) / 255);
                Color1.B = (byte)((colors.Color1.B * i) / 255);

                Color2.R = (byte)((colors.Color2.R * i) / 255);
                Color2.G = (byte)((colors.Color2.G * i) / 255);
                Color2.B = (byte)((colors.Color2.B * i) / 255);

                Color3.R = (byte)((colors.Color3.R * i) / 255);
                Color3.G = (byte)((colors.Color3.G * i) / 255);
                Color3.B = (byte)((colors.Color3.B * i) / 255);
            }
            else     // if ( intensity > 1.0f )
            {
                byte i = (byte)((intensity - 1.0f) * 255.0f);

                Color0.R = (byte)Math.Min(colors.Color0.R + i, 255);
                Color0.G = (byte)Math.Min(colors.Color0.G + i, 255);
                Color0.B = (byte)Math.Min(colors.Color0.B + i, 255);

                Color1.R = (byte)Math.Min(colors.Color1.R + i, 255);
                Color1.G = (byte)Math.Min(colors.Color1.G + i, 255);
                Color1.B = (byte)Math.Min(colors.Color1.B + i, 255);

                Color2.R = (byte)Math.Min(colors.Color2.R + i, 255);
                Color2.G = (byte)Math.Min(colors.Color2.G + i, 255);
                Color2.B = (byte)Math.Min(colors.Color2.B + i, 255);

                Color3.R = (byte)Math.Min(colors.Color3.R + i, 255);
                Color3.G = (byte)Math.Min(colors.Color3.G + i, 255);
                Color3.B = (byte)Math.Min(colors.Color3.B + i, 255);
            }
        }
        // Set
        public void Set( ref SpriteColors colors, float alpha, float intensity )
        {
            alpha = MathHelper.Clamp( alpha, 0.0f, 1.0f );
            intensity = MathHelper.Clamp( intensity, 0.0f, 2.0f );

            PreMultipliedAlpha = false;

            byte a = (byte)( alpha * 255.0f );

            Color0.A = (byte)( ( colors.Color0.A * a ) / 255 );
            Color1.A = (byte)( ( colors.Color1.A * a ) / 255 );
            Color2.A = (byte)( ( colors.Color2.A * a ) / 255 );
            Color3.A = (byte)( ( colors.Color3.A * a ) / 255 );

            if ( intensity == 1.0f )
            {
            Color0.R = colors.Color0.R;
            Color0.G = colors.Color0.G;
            Color0.B = colors.Color0.B;

            Color1.R = colors.Color1.R;
            Color1.G = colors.Color1.G;
            Color1.B = colors.Color1.B;

            Color2.R = colors.Color2.R;
            Color2.G = colors.Color2.G;
            Color2.B = colors.Color2.B;

            Color3.R = colors.Color3.R;
            Color3.G = colors.Color3.G;
            Color3.B = colors.Color3.B;
            }
            else
            if ( intensity < 1.0f )
            {
            byte i = (byte)( intensity * 255.0f );

            Color0.R = (byte)( ( colors.Color0.R * i ) / 255 );
            Color0.G = (byte)( ( colors.Color0.G * i ) / 255 );
            Color0.B = (byte)( ( colors.Color0.B * i ) / 255 );

            Color1.R = (byte)( ( colors.Color1.R * i ) / 255 );
            Color1.G = (byte)( ( colors.Color1.G * i ) / 255 );
            Color1.B = (byte)( ( colors.Color1.B * i ) / 255 );

            Color2.R = (byte)( ( colors.Color2.R * i ) / 255 );
            Color2.G = (byte)( ( colors.Color2.G * i ) / 255 );
            Color2.B = (byte)( ( colors.Color2.B * i ) / 255 );

            Color3.R = (byte)( ( colors.Color3.R * i ) / 255 );
            Color3.G = (byte)( ( colors.Color3.G * i ) / 255 );
            Color3.B = (byte)( ( colors.Color3.B * i ) / 255 );
            }
            else // if ( intensity > 1.0f )
            {
            byte i = (byte)( ( intensity - 1.0f ) * 255.0f );

            Color0.R = (byte)Math.Min( colors.Color0.R + i, 255 );
            Color0.G = (byte)Math.Min( colors.Color0.G + i, 255 );
            Color0.B = (byte)Math.Min( colors.Color0.B + i, 255 );

            Color1.R = (byte)Math.Min( colors.Color1.R + i, 255 );
            Color1.G = (byte)Math.Min( colors.Color1.G + i, 255 );
            Color1.B = (byte)Math.Min( colors.Color1.B + i, 255 );

            Color2.R = (byte)Math.Min( colors.Color2.R + i, 255 );
            Color2.G = (byte)Math.Min( colors.Color2.G + i, 255 );
            Color2.B = (byte)Math.Min( colors.Color2.B + i, 255 );

            Color3.R = (byte)Math.Min( colors.Color3.R + i, 255 );
            Color3.G = (byte)Math.Min( colors.Color3.G + i, 255 );
            Color3.B = (byte)Math.Min( colors.Color3.B + i, 255 );
            }
        }
Example #22
0
 public FontEffect_ColorLerp( float spriteChangeTime, float spriteUpdateTime, float waitTime, SpriteColors colors, E_LerpType lerpType )
     : base(spriteChangeTime, spriteUpdateTime, waitTime)
 {
     Colors = colors;
     LerpType = lerpType;
 }
Example #23
0
        // Init
        public void Init()
        {
            if ( ColorBaseName != null )
            ColorBase = _UI.Store_Color.Get( ColorBaseName );

            if ( RenderStateName != null )
            RenderState = _UI.Store_RenderState.Get( RenderStateName );

            for ( int i = 0; i < Timelines.Count; ++i )
            Timelines[ i ].Bind( this );

            UpY = _UI.Sprite.IsRenderPass3D( RenderPass ) ? -1.0f : 1.0f;

            OnInit();
        }
Example #24
0
 public void ChangeColor( ref SpriteColors colors )
 {
     ColorBase = colors;
     FlagSet( E_WidgetFlag.DirtyColor );
 }
Example #25
0
 public FontEffect_ColorLerp(float spriteChangeTime, float spriteUpdateTime, float waitTime, SpriteColors colors, E_LerpType lerpType)
     : base(spriteChangeTime, spriteUpdateTime, waitTime)
 {
     Colors   = colors;
     LerpType = lerpType;
 }
Example #26
0
	public void AddSprite( int renderPass, int layer, float pX, float pY, float pZ, float sX, float sY, E_Align align, ref SpriteColors colors, ref RenderState renderState )
	{
		Vector3 p = new Vector3( pX, pY, pZ );
		AddSprite( renderPass, layer, ref p, sX, sY, align, ref colors, ref renderState );
	}
 protected override void OnBind()
 {
     ColorFrom = Widget.ColorBase;
 }
Example #28
0
 public TimelineEffect_ColorLerp(SpriteColors colorTo, E_LerpType lerpType)
     : base(0.0f, 1.0f, lerpType)
 {
     ColorTo = colorTo;
 }
Example #29
0
        public void AddSprite(int renderPass, int layer, float pX, float pY, float pZ, float sX, float sY, E_Align align, ref SpriteColors colors, ref RenderState renderState)
        {
            Vector3 p = new Vector3(pX, pY, pZ);

            AddSprite(renderPass, layer, ref p, sX, sY, align, ref colors, ref renderState);
        }
Example #30
0
        public Vector2 Draw(StringUI text, FontStyle fontStyle, int renderPass, int layer, ref Vector3 pos, float height, E_Align align, ref SpriteColors colors, float wrapSizeX)
        {
            StringProxy stringProxy = new StringProxy(text);

            return(Process(ref stringProxy, fontStyle, renderPass, layer, ref pos, height, align, ref colors, wrapSizeX));
        }