// OnRender protected override void OnRender() { if (Textures.Count == 0) { return; } if (!ColorFinal.HasAlpha() && ((RenderState.BlendState == E_BlendState.AlphaBlend) || (RenderState.BlendState == E_BlendState.NonPremultiplied))) { return; } using (new AutoTransform(this)) { _UI.Sprite.AddSprite(RenderPass, Layer, ref Position, Size.X, Size.Y, Align, ref ColorFinal, ref RenderState); for (int i = 0; i < Textures.Count; ++i) { if (i == SpriteTexture.TextureCount) { break; } _UI.Sprite.AddTexture(i, Textures[i]); } } // auto transform }
// OnRender protected override void OnRender() { if (Textures.Count < 2) { return; } if (!ColorFinal.HasAlpha() && ((RenderState.BlendState == E_BlendState.AlphaBlend) || (RenderState.BlendState == E_BlendState.NonPremultiplied))) { return; } using (new AutoTransform(this)) { // align Vector2 offset = _UI.Sprite.GetVertexOffsetAligned(0, Align); Vector3 pos = Position; pos.X -= offset.X * Size.X; pos.Y -= offset.Y * Size.Y * UpY; _UI.Sprite.AddSprite(RenderPass, Layer, ref pos, Size.X, Size.Y, E_Align.TopLeft, ref ColorFinal, ref RenderState); _UI.Sprite.AddTexture(0, Textures[0]); float pos01 = (float)(Value - MinValue) / (MaxValue - MinValue); _UI.Sprite.AddSprite(RenderPass, Layer, pos.X + (Size.X * pos01), pos.Y + (Size.Y / 2.0f) * UpY, pos.Z, IndicatorSize.X, IndicatorSize.Y, E_Align.MiddleCentre, ref ColorFinal, ref RenderState); _UI.Sprite.AddTexture(0, Textures[1]); } // auto transform }
// OnRender protected override void OnRender() { if ((Size.Y <= 0.0f) || (!ColorFinal.HasAlpha() && ((RenderState.BlendState == E_BlendState.AlphaBlend) || (RenderState.BlendState == E_BlendState.NonPremultiplied)))) { return; } if (FontStyle == null) { return; } if ((_String == null) && (StringUI == null)) { return; } using (new AutoTransform(this)) { if (FontEffects.Count > 0) { _UI.Font.DoFontEffectsNext(FontEffects); } if (Cache && CacheValid) { FontStyle.Render(SpriteListCache, RenderSizeY); } else { Vector2 stringSize = new Vector2(); if (StringUI != null) { stringSize = _UI.Font.Draw(StringUI, FontStyle, RenderPass, Layer, ref Position, RenderSizeY, Align, ref ColorFinal, RenderSizeX); } else { stringSize = _UI.Font.Draw(_String, FontStyle, RenderPass, Layer, ref Position, RenderSizeY, Align, ref ColorFinal, RenderSizeX); } // slag lag - are we bothered? We'll see ... Size.X = stringSize.X; Size.Y = stringSize.Y; if (Cache) { CacheValid = true; _UI.Font.SpriteList.CopyTo(SpriteListCache); } } for (int i = 0; i < FontEffects.Count; ++i) { FontEffects[i].Update(FrameTime); // meh - but need to update here to make sure the letter count is correct } } // auto transform }
// CalculateColor private void CalculateColor() { float oldAlphaFinal = AlphaFinal; float oldIntensityFinal = IntensityFinal; AlphaFinal = Alpha; IntensityFinal = Intensity; bool doAlpha = IsFlagSet(E_WidgetFlag.InheritAlpha); bool doIntensity = IsFlagSet(E_WidgetFlag.InheritIntensity); for (WidgetBase p = ParentWidget; p != null; p = p.ParentWidget) { if (doAlpha) { AlphaFinal *= p.Alpha; } if (doIntensity) { if (p.Intensity > 1.0f) { IntensityFinal += (p.Intensity - 1.0f); } else { IntensityFinal *= p.Intensity; } } doAlpha &= p.IsFlagSet(E_WidgetFlag.InheritAlpha); doIntensity &= p.IsFlagSet(E_WidgetFlag.InheritIntensity); if (!doAlpha && !doIntensity) { break; } } if ((AlphaFinal != oldAlphaFinal) || (IntensityFinal != oldIntensityFinal) || IsFlagSet(E_WidgetFlag.DirtyColor)) { ColorFinal.Set(ref ColorBase, AlphaFinal, IntensityFinal); if (RenderState.BlendState == E_BlendState.AlphaBlend) { ColorFinal.ToPremultiplied(); } FlagClear(E_WidgetFlag.DirtyColor); } }
// OnRender protected override void OnRender() { if (Textures.Count == 0) { return; } if (!ColorFinal.HasAlpha() && ((RenderState.BlendState == E_BlendState.AlphaBlend) || (RenderState.BlendState == E_BlendState.NonPremultiplied))) { return; } using (new AutoTransform(this)) { // align Vector2 offset = _UI.Sprite.GetVertexOffsetAligned(0, Align); Vector3 pos = Position; pos.X -= offset.X * Size.X; pos.Y -= offset.Y * Size.Y * UpY; // vertex positions float x0 = pos.X; float x1 = x0 + CornerSize.X; float x2 = x1 + Size.X - (CornerSize.X * 2.0f); float x3 = x2 + CornerSize.X; float y0 = pos.Y; float y1 = pos.Y + (CornerSize.Y * UpY); float y2 = y1 + (Size.Y - (CornerSize.Y * 2.0f)) * UpY; float y3 = y2 + (CornerSize.Y * UpY); // sizes float sx1x0 = x1 - x0; float sx2x1 = x2 - x1; float sx3x2 = x3 - x2; float sy1y0 = (y1 - y0) * UpY; float sy2y1 = (y2 - y1) * UpY; float sy3y2 = (y3 - y2) * UpY; // uvs SpriteTexture tex = Textures[0]; float u0 = tex.PUV.X + (CornerPuv01.X / tex.SUV.X); float u1 = u0 + (CornerSuv01.X / tex.SUV.X); float u3 = tex.PUV.X + tex.SUV.X - (CornerPuv01.X / tex.SUV.X); float u2 = u3 - (CornerSuv01.X / tex.SUV.X); float v0 = tex.PUV.Y + (CornerPuv01.Y / tex.SUV.Y); float v1 = u0 + (CornerSuv01.Y / tex.SUV.Y); float v3 = tex.PUV.Y + tex.SUV.Y - (CornerPuv01.Y / tex.SUV.Y); float v2 = u3 - (CornerSuv01.Y / tex.SUV.Y); // uv sizes float su1u0 = u1 - u0; float su2u1 = u2 - u1; float su3u2 = u3 - u2; float sv1v0 = v1 - v0; float sv2v1 = v2 - v1; float sv3v2 = v3 - v2; // TL _UI.Sprite.AddSprite(RenderPass, Layer, x0, y0, pos.Z, sx1x0, sy1y0, E_Align.TopLeft, ref ColorFinal, ref RenderState); _UI.Sprite.AddTexture(0, tex.TextureIndex, u0, v0, su1u0, sv1v0); // TC _UI.Sprite.AddSprite(RenderPass, Layer, x1, y0, pos.Z, sx2x1, sy1y0, E_Align.TopLeft, ref ColorFinal, ref RenderState); _UI.Sprite.AddTexture(0, tex.TextureIndex, u1, v0, su2u1, sv1v0); // TR _UI.Sprite.AddSprite(RenderPass, Layer, x2, y0, pos.Z, sx3x2, sy1y0, E_Align.TopLeft, ref ColorFinal, ref RenderState); _UI.Sprite.AddTexture(0, tex.TextureIndex, u2, v0, su3u2, sv1v0); // ML _UI.Sprite.AddSprite(RenderPass, Layer, x0, y1, pos.Z, sx1x0, sy2y1, E_Align.TopLeft, ref ColorFinal, ref RenderState); _UI.Sprite.AddTexture(0, tex.TextureIndex, u0, v1, su1u0, sv2v1); // MC _UI.Sprite.AddSprite(RenderPass, Layer, x1, y1, pos.Z, sx2x1, sy2y1, E_Align.TopLeft, ref ColorFinal, ref RenderState); _UI.Sprite.AddTexture(0, tex.TextureIndex, u1, v1, su2u1, sv2v1); // MR _UI.Sprite.AddSprite(RenderPass, Layer, x2, y1, pos.Z, sx3x2, sy2y1, E_Align.TopLeft, ref ColorFinal, ref RenderState); _UI.Sprite.AddTexture(0, tex.TextureIndex, u2, v1, su3u2, sv2v1); // BL _UI.Sprite.AddSprite(RenderPass, Layer, x0, y2, pos.Z, sx1x0, sy3y2, E_Align.TopLeft, ref ColorFinal, ref RenderState); _UI.Sprite.AddTexture(0, tex.TextureIndex, u0, v2, su1u0, sv3v2); // BC _UI.Sprite.AddSprite(RenderPass, Layer, x1, y2, pos.Z, sx2x1, sy3y2, E_Align.TopLeft, ref ColorFinal, ref RenderState); _UI.Sprite.AddTexture(0, tex.TextureIndex, u1, v2, su2u1, sv3v2); // BR _UI.Sprite.AddSprite(RenderPass, Layer, x2, y2, pos.Z, sx3x2, sy3y2, E_Align.TopLeft, ref ColorFinal, ref RenderState); _UI.Sprite.AddTexture(0, tex.TextureIndex, u2, v2, su3u2, sv3v2); } // auto transform }