Ejemplo n.º 1
0
        public override void Draw(DrawContext dc)
        {
            Color color = new Color((byte)128, (byte)128, (byte)128) * base.GlobalColorTransform * MathUtils.Saturate(m_scrollBarAlpha);

            if (color.A > 0 && m_scrollAreaLength > 0f)
            {
                FlatBatch2D flatBatch2D = dc.PrimitivesRenderer2D.FlatBatch(0, DepthStencilState.None);
                int         count       = flatBatch2D.TriangleVertices.Count;
                if (Direction == LayoutDirection.Horizontal)
                {
                    float   scrollPosition = ScrollPosition;
                    float   x       = base.ActualSize.X;
                    Vector2 corner  = new Vector2(scrollPosition / m_scrollAreaLength * x, base.ActualSize.Y - 5f);
                    Vector2 corner2 = new Vector2((scrollPosition + x) / m_scrollAreaLength * x, base.ActualSize.Y - 1f);
                    flatBatch2D.QueueQuad(corner, corner2, 0f, color);
                }
                else
                {
                    float   scrollPosition2 = ScrollPosition;
                    float   y       = base.ActualSize.Y;
                    Vector2 corner3 = new Vector2(base.ActualSize.X - 5f, scrollPosition2 / m_scrollAreaLength * y);
                    Vector2 corner4 = new Vector2(base.ActualSize.X - 1f, (scrollPosition2 + y) / m_scrollAreaLength * y);
                    flatBatch2D.QueueQuad(corner3, corner4, 0f, color);
                }
                flatBatch2D.TransformTriangles(base.GlobalTransform, count);
            }
        }
Ejemplo n.º 2
0
        public static void Draw()
        {
            Vector2  scale    = new Vector2(MathUtils.Round(MathUtils.Clamp(ScreensManager.RootWidget.GlobalScale, 1f, 4f)));
            Viewport viewport = Display.Viewport;

            if (SettingsManager.DisplayFpsCounter)
            {
                if (Time.PeriodicEvent(1.0, 0.0))
                {
                    m_statsString = $"CPUMEM {(float)TotalMemoryUsed / 1024f / 1024f:0}MB, GPUMEM {(float)TotalGpuMemoryUsed / 1024f / 1024f:0}MB, CPU {AverageCpuFrameTime / AverageFrameTime * 100f:0}%, FPS {1f / AverageFrameTime:0.0}";
                }
                m_primitivesRenderer.FontBatch(BitmapFont.DebugFont, 0, null, null, null, SamplerState.PointClamp).QueueText(m_statsString, new Vector2(viewport.Width, 0f), 0f, Color.White, TextAnchor.Right, scale, Vector2.Zero);
            }
            if (SettingsManager.DisplayFpsRibbon)
            {
                float num  = ((float)viewport.Width / scale.X > 480f) ? (scale.X * 2f) : scale.X;
                float num2 = (float)viewport.Height / -0.1f;
                float num3 = viewport.Height - 1;
                float s    = 0.5f;
                int   num4 = MathUtils.Max((int)((float)viewport.Width / num), 1);
                if (m_frameData == null || m_frameData.Length != num4)
                {
                    m_frameData      = new FrameData[num4];
                    m_frameDataIndex = 0;
                }
                m_frameData[m_frameDataIndex] = new FrameData
                {
                    CpuTime   = Program.LastCpuFrameTime,
                    TotalTime = Program.LastFrameTime
                };
                m_frameDataIndex = (m_frameDataIndex + 1) % m_frameData.Length;
                FlatBatch2D flatBatch2D = m_primitivesRenderer.FlatBatch();
                Color       color       = Color.Orange * s;
                Color       color2      = Color.Red * s;
                for (int num5 = m_frameData.Length - 1; num5 >= 0; num5--)
                {
                    int       num6      = (num5 - m_frameData.Length + 1 + m_frameDataIndex + m_frameData.Length) % m_frameData.Length;
                    FrameData frameData = m_frameData[num6];
                    float     x         = (float)num5 * num;
                    float     x2        = (float)(num5 + 1) * num;
                    flatBatch2D.QueueQuad(new Vector2(x, num3), new Vector2(x2, num3 + frameData.CpuTime * num2), 0f, color);
                    flatBatch2D.QueueQuad(new Vector2(x, num3 + frameData.CpuTime * num2), new Vector2(x2, num3 + frameData.TotalTime * num2), 0f, color2);
                }
                flatBatch2D.QueueLine(new Vector2(0f, num3 + 0.0166666675f * num2), new Vector2(viewport.Width, num3 + 0.0166666675f * num2), 0f, Color.Green);
            }
            else
            {
                m_frameData = null;
            }
            m_primitivesRenderer.Flush();
        }
Ejemplo n.º 3
0
        public void DrawSquares(DrawContext dc)
        {
            FlatBatch2D flatBatch2D = dc.PrimitivesRenderer2D.FlatBatch(1, DepthStencilState.None, null, BlendState.AlphaBlend);
            int         count       = flatBatch2D.LineVertices.Count;
            int         count2      = flatBatch2D.TriangleVertices.Count;
            float       num         = (float)MathUtils.Remainder(Time.FrameStartTime + (double)m_timeOffset, 10000.0);
            float       num2        = base.ActualSize.X / 12f;
            float       num3        = (float)(int)base.GlobalColorTransform.A / 255f;

            for (float num4 = 0f; num4 < base.ActualSize.X; num4 += num2)
            {
                for (float num5 = 0f; num5 < base.ActualSize.Y; num5 += num2)
                {
                    float   num6    = 0.35f * MathUtils.Pow(MathUtils.Saturate(SimplexNoise.OctavedNoise(num4 + 1000f, num5, 0.7f * num, 0.5f, 1, 2f, 1f) - 0.1f), 1f) * num3;
                    float   num7    = 0.7f * MathUtils.Pow(SimplexNoise.OctavedNoise(num4, num5, 0.5f * num, 0.5f, 1, 2f, 1f), 3f) * num3;
                    Vector2 corner  = new Vector2(num4, num5);
                    Vector2 corner2 = new Vector2(num4 + num2, num5 + num2);
                    if (num6 > 0.01f)
                    {
                        flatBatch2D.QueueRectangle(corner, corner2, 0f, new Color(0f, 0f, 0f, num6));
                    }
                    if (num7 > 0.01f)
                    {
                        flatBatch2D.QueueQuad(corner, corner2, 0f, new Color(0f, 0f, 0f, num7));
                    }
                }
            }
            flatBatch2D.TransformLines(base.GlobalTransform, count);
            flatBatch2D.TransformTriangles(base.GlobalTransform, count2);
        }
Ejemplo n.º 4
0
 public override void Draw(DrawContext dc)
 {
     if (m_highlighted)
     {
         FlatBatch2D flatBatch2D = dc.PrimitivesRenderer2D.FlatBatch(100, DepthStencilState.None);
         int         count       = flatBatch2D.TriangleVertices.Count;
         flatBatch2D.QueueQuad(Vector2.Zero, base.ActualSize, 0f, new Color(128, 128, 128, 128));
         flatBatch2D.TransformTriangles(base.GlobalTransform, count);
         m_highlighted = false;
     }
 }
Ejemplo n.º 5
0
 public override void Draw(DrawContext dc)
 {
     if (SelectedIndex.HasValue && SelectedIndex.Value >= m_firstVisibleIndex && SelectedIndex.Value <= m_lastVisibleIndex)
     {
         Vector2     vector      = (Direction == LayoutDirection.Horizontal) ? new Vector2((float)SelectedIndex.Value * ItemSize - ScrollPosition, 0f) : new Vector2(0f, (float)SelectedIndex.Value * ItemSize - ScrollPosition);
         FlatBatch2D flatBatch2D = dc.PrimitivesRenderer2D.FlatBatch(0, DepthStencilState.None);
         int         count       = flatBatch2D.TriangleVertices.Count;
         Vector2     v           = (Direction == LayoutDirection.Horizontal) ? new Vector2(ItemSize, base.ActualSize.Y) : new Vector2(base.ActualSize.X, ItemSize);
         flatBatch2D.QueueQuad(vector, vector + v, 0f, SelectionColor * base.GlobalColorTransform);
         flatBatch2D.TransformTriangles(base.GlobalTransform, count);
     }
     base.Draw(dc);
 }
Ejemplo n.º 6
0
        public override void Draw(DrawContext dc)
        {
            if (Time.RealTime - m_lastBoxesStepTime > 0.25)
            {
                m_boxIndex++;
                m_lastBoxesStepTime = Time.RealTime;
            }
            FlatBatch2D flatBatch2D = dc.PrimitivesRenderer2D.FlatBatch();
            int         count       = flatBatch2D.TriangleVertices.Count;

            for (int i = 0; i < 5; i++)
            {
                Vector2 v  = new Vector2(((float)i + 0.5f) * 24f, 6f);
                Color   c  = (i == m_boxIndex % 5) ? LitBarColor : UnlitBarColor;
                float   v2 = (i == m_boxIndex % 5) ? 12f : 8f;
                flatBatch2D.QueueQuad(v - new Vector2(v2) / 2f, v + new Vector2(v2) / 2f, 0f, c * base.GlobalColorTransform);
            }
            flatBatch2D.TransformTriangles(base.GlobalTransform, count);
        }
Ejemplo n.º 7
0
        public override void Draw(DrawContext dc)
        {
            Color color = Color * base.GlobalColorTransform;

            if (!string.IsNullOrEmpty(m_text))
            {
                Vector2      position     = new Vector2(0f - m_scroll, base.ActualSize.Y / 2f);
                SamplerState samplerState = TextureLinearFilter ? SamplerState.LinearClamp : SamplerState.PointClamp;
                FontBatch2D  fontBatch2D  = dc.PrimitivesRenderer2D.FontBatch(Font, 1, DepthStencilState.None, null, null, samplerState);
                int          count        = fontBatch2D.TriangleVertices.Count;
                fontBatch2D.QueueText(Text, position, 0f, color, TextAnchor.VerticalCenter, new Vector2(FontScale), FontSpacing);
                fontBatch2D.TransformTriangles(base.GlobalTransform, count);
            }
            if (!m_hasFocus || !(MathUtils.Remainder(Time.RealTime - m_focusStartTime, 0.5) < 0.25))
            {
                return;
            }
            float   num = Font.CalculateCharacterPosition(Text, CaretPosition, new Vector2(FontScale), FontSpacing);
            Vector2 v   = new Vector2(0f, base.ActualSize.Y / 2f) + new Vector2(num - m_scroll, 0f);

            if (m_hasFocus)
            {
                if (v.X < 0f)
                {
                    m_scroll = MathUtils.Max(m_scroll + v.X, 0f);
                }
                if (v.X > base.ActualSize.X)
                {
                    m_scroll += v.X - base.ActualSize.X + 1f;
                }
            }
            FlatBatch2D flatBatch2D = dc.PrimitivesRenderer2D.FlatBatch(1, DepthStencilState.None);
            int         count2      = flatBatch2D.TriangleVertices.Count;

            flatBatch2D.QueueQuad(v - new Vector2(0f, Font.GlyphHeight / 2f * FontScale * Font.Scale), v + new Vector2(1f, Font.GlyphHeight / 2f * FontScale * Font.Scale), 0f, color);
            flatBatch2D.TransformTriangles(base.GlobalTransform, count2);
        }
        public static void QueueBevelledRectangle(TexturedBatch2D texturedBatch, FlatBatch2D flatBatch, Vector2 c1, Vector2 c2, float depth, float bevelSize, Color color, Color bevelColor, Color shadowColor, float ambientLight, float directionalLight, float textureScale)
        {
            float   num     = MathUtils.Abs(bevelSize);
            Vector2 vector  = c1;
            Vector2 vector2 = c1 + new Vector2(num);
            Vector2 vector3 = c2 - new Vector2(num);
            Vector2 vector4 = c2;
            Vector2 vector5 = c2 + new Vector2(1.5f * num);
            float   x       = vector.X;
            float   x2      = vector2.X;
            float   x3      = vector3.X;
            float   x4      = vector4.X;
            float   x5      = vector5.X;
            float   y       = vector.Y;
            float   y2      = vector2.Y;
            float   y3      = vector3.Y;
            float   y4      = vector4.Y;
            float   y5      = vector5.Y;
            float   num2    = MathUtils.Saturate(((bevelSize > 0f) ? 1f : (-0.75f)) * directionalLight + ambientLight);
            float   num3    = MathUtils.Saturate(((bevelSize > 0f) ? (-0.75f) : 1f) * directionalLight + ambientLight);
            float   num4    = MathUtils.Saturate(((bevelSize > 0f) ? (-0.375f) : 0.5f) * directionalLight + ambientLight);
            float   num5    = MathUtils.Saturate(((bevelSize > 0f) ? 0.5f : (-0.375f)) * directionalLight + ambientLight);
            float   num6    = MathUtils.Saturate(0f * directionalLight + ambientLight);
            Color   color2  = new Color((byte)(num4 * (float)(int)bevelColor.R), (byte)(num4 * (float)(int)bevelColor.G), (byte)(num4 * (float)(int)bevelColor.B), bevelColor.A);
            Color   color3  = new Color((byte)(num5 * (float)(int)bevelColor.R), (byte)(num5 * (float)(int)bevelColor.G), (byte)(num5 * (float)(int)bevelColor.B), bevelColor.A);
            Color   color4  = new Color((byte)(num2 * (float)(int)bevelColor.R), (byte)(num2 * (float)(int)bevelColor.G), (byte)(num2 * (float)(int)bevelColor.B), bevelColor.A);
            Color   color5  = new Color((byte)(num3 * (float)(int)bevelColor.R), (byte)(num3 * (float)(int)bevelColor.G), (byte)(num3 * (float)(int)bevelColor.B), bevelColor.A);
            Color   color6  = new Color((byte)(num6 * (float)(int)color.R), (byte)(num6 * (float)(int)color.G), (byte)(num6 * (float)(int)color.B), color.A);

            if (texturedBatch != null)
            {
                float num7  = textureScale / (float)texturedBatch.Texture.Width;
                float num8  = textureScale / (float)texturedBatch.Texture.Height;
                float num9  = x * num7;
                float num10 = y * num8;
                float x6    = num9;
                float x7    = (x2 - x) * num7 + num9;
                float x8    = (x3 - x) * num7 + num9;
                float x9    = (x4 - x) * num7 + num9;
                float y6    = num10;
                float y7    = (y2 - y) * num8 + num10;
                float y8    = (y3 - y) * num8 + num10;
                float y9    = (y4 - y) * num8 + num10;
                if (bevelColor.A > 0)
                {
                    texturedBatch.QueueQuad(new Vector2(x, y), new Vector2(x2, y2), new Vector2(x3, y2), new Vector2(x4, y), depth, new Vector2(x6, y6), new Vector2(x7, y7), new Vector2(x8, y7), new Vector2(x9, y6), color4);
                    texturedBatch.QueueQuad(new Vector2(x3, y2), new Vector2(x3, y3), new Vector2(x4, y4), new Vector2(x4, y), depth, new Vector2(x8, y7), new Vector2(x8, y8), new Vector2(x9, y9), new Vector2(x9, y6), color3);
                    texturedBatch.QueueQuad(new Vector2(x, y4), new Vector2(x4, y4), new Vector2(x3, y3), new Vector2(x2, y3), depth, new Vector2(x6, y9), new Vector2(x9, y9), new Vector2(x8, y8), new Vector2(x7, y8), color5);
                    texturedBatch.QueueQuad(new Vector2(x, y), new Vector2(x, y4), new Vector2(x2, y3), new Vector2(x2, y2), depth, new Vector2(x6, y6), new Vector2(x6, y9), new Vector2(x7, y8), new Vector2(x7, y7), color2);
                }
                if (color6.A > 0)
                {
                    texturedBatch.QueueQuad(new Vector2(x2, y2), new Vector2(x3, y3), depth, new Vector2(x7, y7), new Vector2(x8, y8), color6);
                }
            }
            else if (flatBatch != null)
            {
                if (bevelColor.A > 0)
                {
                    flatBatch.QueueQuad(new Vector2(x, y), new Vector2(x2, y2), new Vector2(x3, y2), new Vector2(x4, y), depth, color4);
                    flatBatch.QueueQuad(new Vector2(x3, y2), new Vector2(x3, y3), new Vector2(x4, y4), new Vector2(x4, y), depth, color3);
                    flatBatch.QueueQuad(new Vector2(x, y4), new Vector2(x4, y4), new Vector2(x3, y3), new Vector2(x2, y3), depth, color5);
                    flatBatch.QueueQuad(new Vector2(x, y), new Vector2(x, y4), new Vector2(x2, y3), new Vector2(x2, y2), depth, color2);
                }
                if (color6.A > 0)
                {
                    flatBatch.QueueQuad(new Vector2(x2, y2), new Vector2(x3, y3), depth, color6);
                }
            }
            if (bevelSize > 0f && flatBatch != null && shadowColor.A > 0)
            {
                Color color7 = shadowColor;
                Color color8 = new Color(0, 0, 0, 0);
                flatBatch.QueueTriangle(new Vector2(x, y4), new Vector2(x2, y5), new Vector2(x2, y4), depth, color8, color8, color7);
                flatBatch.QueueTriangle(new Vector2(x4, y), new Vector2(x4, y2), new Vector2(x5, y2), depth, color8, color7, color8);
                flatBatch.QueueTriangle(new Vector2(x4, y4), new Vector2(x4, y5), new Vector2(x5, y4), depth, color7, color8, color8);
                flatBatch.QueueQuad(new Vector2(x2, y4), new Vector2(x2, y5), new Vector2(x4, y5), new Vector2(x4, y4), depth, color7, color8, color8, color7);
                flatBatch.QueueQuad(new Vector2(x4, y2), new Vector2(x4, y4), new Vector2(x5, y4), new Vector2(x5, y2), depth, color7, color7, color8, color8);
            }
        }
Ejemplo n.º 9
0
        public override void Overdraw(DrawContext dc)
        {
            Color       color            = new Color(181, 172, 154) * base.GlobalColorTransform;
            float       num              = 0.6f;
            float       directionalLight = 0.4f;
            FlatBatch2D flatBatch2D      = dc.PrimitivesRenderer2D.FlatBatch();
            int         count            = flatBatch2D.TriangleVertices.Count;

            if (Children.Count == 2)
            {
                if (SettingsManager.ScreenLayout2 == ScreenLayout.DoubleVertical || SettingsManager.ScreenLayout2 == ScreenLayout.DoubleOpposite)
                {
                    Vector2 c  = new Vector2(base.ActualSize.X / 2f - m_spacing / 2f, -100f);
                    Vector2 c2 = new Vector2(base.ActualSize.X / 2f + m_spacing / 2f, base.ActualSize.Y + 100f);
                    BevelledRectangleWidget.QueueBevelledRectangle(null, flatBatch2D, c, c2, 0f, m_bevel, color, color, Color.Transparent, num, directionalLight, 0f);
                }
                if (SettingsManager.ScreenLayout2 == ScreenLayout.DoubleHorizontal)
                {
                    Vector2 c3 = new Vector2(-100f, base.ActualSize.Y / 2f - m_spacing / 2f);
                    Vector2 c4 = new Vector2(base.ActualSize.X + 100f, base.ActualSize.Y / 2f + m_spacing / 2f);
                    BevelledRectangleWidget.QueueBevelledRectangle(null, flatBatch2D, c3, c4, 0f, m_bevel, color, color, Color.Transparent, num, directionalLight, 0f);
                }
            }
            else if (Children.Count == 3)
            {
                if (SettingsManager.ScreenLayout3 == ScreenLayout.TripleVertical || SettingsManager.ScreenLayout3 == ScreenLayout.TripleOpposite)
                {
                    float x  = -100f;
                    float x2 = base.ActualSize.X / 2f - m_spacing / 2f + m_bevel;
                    float x3 = base.ActualSize.X / 2f + m_spacing / 2f - m_bevel;
                    float x4 = base.ActualSize.X + 100f;
                    float y  = -100f;
                    float y2 = base.ActualSize.Y / 2f - m_spacing / 2f + m_bevel;
                    float y3 = base.ActualSize.Y / 2f + m_spacing / 2f - m_bevel;
                    float y4 = base.ActualSize.Y + 100f;
                    BevelledRectangleWidget.QueueBevelledRectangle(null, flatBatch2D, new Vector2(x, y), new Vector2(x2, y4), 0f, 0f - m_bevel, Color.Transparent, color, Color.Transparent, num, directionalLight, 0f);
                    BevelledRectangleWidget.QueueBevelledRectangle(null, flatBatch2D, new Vector2(x3, y), new Vector2(x4, y2), 0f, 0f - m_bevel, Color.Transparent, color, Color.Transparent, num, directionalLight, 0f);
                    BevelledRectangleWidget.QueueBevelledRectangle(null, flatBatch2D, new Vector2(x3, y3), new Vector2(x4, y4), 0f, 0f - m_bevel, Color.Transparent, color, Color.Transparent, num, directionalLight, 0f);
                    Color color2 = color * new Color(num, num, num, 1f);
                    flatBatch2D.QueueQuad(new Vector2(x2, y), new Vector2(x3, y4), 0f, color2);
                    flatBatch2D.QueueQuad(new Vector2(x3, y2), new Vector2(x4, y3), 0f, color2);
                }
                if (SettingsManager.ScreenLayout3 == ScreenLayout.TripleHorizontal)
                {
                    float x5 = -100f;
                    float x6 = base.ActualSize.X / 2f - m_spacing / 2f + m_bevel;
                    float x7 = base.ActualSize.X / 2f + m_spacing / 2f - m_bevel;
                    float x8 = base.ActualSize.X + 100f;
                    float y5 = -100f;
                    float y6 = base.ActualSize.Y / 2f - m_spacing / 2f + m_bevel;
                    float y7 = base.ActualSize.Y / 2f + m_spacing / 2f - m_bevel;
                    float y8 = base.ActualSize.Y + 100f;
                    BevelledRectangleWidget.QueueBevelledRectangle(null, flatBatch2D, new Vector2(x5, y5), new Vector2(x8, y6), 0f, 0f - m_bevel, Color.Transparent, color, Color.Transparent, num, directionalLight, 0f);
                    BevelledRectangleWidget.QueueBevelledRectangle(null, flatBatch2D, new Vector2(x5, y7), new Vector2(x6, y8), 0f, 0f - m_bevel, Color.Transparent, color, Color.Transparent, num, directionalLight, 0f);
                    BevelledRectangleWidget.QueueBevelledRectangle(null, flatBatch2D, new Vector2(x7, y7), new Vector2(x8, y8), 0f, 0f - m_bevel, Color.Transparent, color, Color.Transparent, num, directionalLight, 0f);
                    Color color3 = color * new Color(num, num, num, 1f);
                    flatBatch2D.QueueQuad(new Vector2(x5, y6), new Vector2(x8, y7), 0f, color3);
                    flatBatch2D.QueueQuad(new Vector2(x6, y7), new Vector2(x7, y8), 0f, color3);
                }
                if (SettingsManager.ScreenLayout3 == ScreenLayout.TripleEven)
                {
                    float x9  = -100f;
                    float x10 = base.ActualSize.X / 2f - m_spacing / 2f + m_bevel;
                    float x11 = base.ActualSize.X / 2f + m_spacing / 2f - m_bevel;
                    float x12 = base.ActualSize.X + 100f;
                    float x13 = base.ActualSize.X / 4f;
                    float x14 = base.ActualSize.X * 3f / 4f;
                    float y9  = -100f;
                    float y10 = base.ActualSize.Y / 2f - m_spacing / 2f + m_bevel;
                    float y11 = base.ActualSize.Y / 2f + m_spacing / 2f - m_bevel;
                    float y12 = base.ActualSize.Y + 100f;
                    BevelledRectangleWidget.QueueBevelledRectangle(null, flatBatch2D, new Vector2(x9, y9), new Vector2(x10, y10), 0f, 0f - m_bevel, Color.Transparent, color, Color.Transparent, num, directionalLight, 0f);
                    BevelledRectangleWidget.QueueBevelledRectangle(null, flatBatch2D, new Vector2(x11, y9), new Vector2(x12, y10), 0f, 0f - m_bevel, Color.Transparent, color, Color.Transparent, num, directionalLight, 0f);
                    BevelledRectangleWidget.QueueBevelledRectangle(null, flatBatch2D, new Vector2(x13, y11), new Vector2(x14, y12), 0f, 0f - m_bevel, Color.Transparent, color, Color.Transparent, num, directionalLight, 0f);
                    Color color4 = color * new Color(num, num, num, 1f);
                    flatBatch2D.QueueQuad(new Vector2(x10, y9), new Vector2(x11, y10), 0f, color4);
                    flatBatch2D.QueueQuad(new Vector2(x9, y10), new Vector2(x12, y11), 0f, color4);
                    flatBatch2D.QueueQuad(new Vector2(x9, y11), new Vector2(x13, y12), 0f, color4);
                    flatBatch2D.QueueQuad(new Vector2(x14, y11), new Vector2(x12, y12), 0f, color4);
                }
            }
            else if (Children.Count == 4)
            {
                float x15 = -100f;
                float x16 = base.ActualSize.X / 2f - m_spacing / 2f + m_bevel;
                float x17 = base.ActualSize.X / 2f + m_spacing / 2f - m_bevel;
                float x18 = base.ActualSize.X + 100f;
                float y13 = -100f;
                float y14 = base.ActualSize.Y / 2f - m_spacing / 2f + m_bevel;
                float y15 = base.ActualSize.Y / 2f + m_spacing / 2f - m_bevel;
                float y16 = base.ActualSize.Y + 100f;
                BevelledRectangleWidget.QueueBevelledRectangle(null, flatBatch2D, new Vector2(x15, y13), new Vector2(x16, y14), 0f, 0f - m_bevel, Color.Transparent, color, Color.Transparent, num, directionalLight, 0f);
                BevelledRectangleWidget.QueueBevelledRectangle(null, flatBatch2D, new Vector2(x17, y13), new Vector2(x18, y14), 0f, 0f - m_bevel, Color.Transparent, color, Color.Transparent, num, directionalLight, 0f);
                BevelledRectangleWidget.QueueBevelledRectangle(null, flatBatch2D, new Vector2(x15, y15), new Vector2(x16, y16), 0f, 0f - m_bevel, Color.Transparent, color, Color.Transparent, num, directionalLight, 0f);
                BevelledRectangleWidget.QueueBevelledRectangle(null, flatBatch2D, new Vector2(x17, y15), new Vector2(x18, y16), 0f, 0f - m_bevel, (Children.Count == 3) ? color : Color.Transparent, color, Color.Transparent, num, directionalLight, 0f);
                Color color5 = color * new Color(num, num, num, 1f);
                flatBatch2D.QueueQuad(new Vector2(x16, y13), new Vector2(x17, y16), 0f, color5);
                flatBatch2D.QueueQuad(new Vector2(x15, y14), new Vector2(x18, y15), 0f, color5);
            }
            else if (Children.Count > 4)
            {
                throw new InvalidOperationException("Too many GameWidgets.");
            }
            flatBatch2D.TransformTriangles(base.GlobalTransform, count);
        }
Ejemplo n.º 10
0
 public void Draw(Camera camera, int drawOrder)
 {
     if (drawOrder == m_drawOrders[0])
     {
         ViewUnderWaterDepth = 0f;
         ViewUnderMagmaDepth = 0f;
         Vector3    viewPosition = camera.ViewPosition;
         int        x            = Terrain.ToCell(viewPosition.X);
         int        y            = Terrain.ToCell(viewPosition.Y);
         int        z            = Terrain.ToCell(viewPosition.Z);
         FluidBlock surfaceFluidBlock;
         float?     surfaceHeight = m_subsystemFluidBlockBehavior.GetSurfaceHeight(x, y, z, out surfaceFluidBlock);
         if (surfaceHeight.HasValue)
         {
             if (surfaceFluidBlock is WaterBlock)
             {
                 ViewUnderWaterDepth = surfaceHeight.Value + 0.1f - viewPosition.Y;
             }
             else if (surfaceFluidBlock is MagmaBlock)
             {
                 ViewUnderMagmaDepth = surfaceHeight.Value + 1f - viewPosition.Y;
             }
         }
         if (ViewUnderWaterDepth > 0f)
         {
             int   seasonalHumidity = m_subsystemTerrain.Terrain.GetSeasonalHumidity(x, z);
             int   temperature      = m_subsystemTerrain.Terrain.GetSeasonalTemperature(x, z) + SubsystemWeather.GetTemperatureAdjustmentAtHeight(y);
             Color c    = BlockColorsMap.WaterColorsMap.Lookup(temperature, seasonalHumidity);
             float num  = MathUtils.Lerp(1f, 0.5f, (float)seasonalHumidity / 15f);
             float num2 = MathUtils.Lerp(1f, 0.2f, MathUtils.Saturate(0.075f * (ViewUnderWaterDepth - 2f)));
             float num3 = MathUtils.Lerp(0.33f, 1f, SkyLightIntensity);
             m_viewFogRange.X           = 0f;
             m_viewFogRange.Y           = MathUtils.Lerp(4f, 10f, num * num2 * num3);
             m_viewFogColor             = Color.MultiplyColorOnly(c, 0.66f * num2 * num3);
             VisibilityRangeYMultiplier = 1f;
             m_viewIsSkyVisible         = false;
         }
         else if (ViewUnderMagmaDepth > 0f)
         {
             m_viewFogRange.X           = 0f;
             m_viewFogRange.Y           = 0.1f;
             m_viewFogColor             = new Color(255, 80, 0);
             VisibilityRangeYMultiplier = 1f;
             m_viewIsSkyVisible         = false;
         }
         else
         {
             float num4 = 1024f;
             float num5 = 128f;
             int   seasonalTemperature = m_subsystemTerrain.Terrain.GetSeasonalTemperature(Terrain.ToCell(viewPosition.X), Terrain.ToCell(viewPosition.Z));
             float num6 = MathUtils.Lerp(0.5f, 0f, m_subsystemWeather.GlobalPrecipitationIntensity);
             float num7 = MathUtils.Lerp(1f, 0.8f, m_subsystemWeather.GlobalPrecipitationIntensity);
             m_viewFogRange.X           = VisibilityRange * num6;
             m_viewFogRange.Y           = VisibilityRange * num7;
             m_viewFogColor             = CalculateSkyColor(new Vector3(camera.ViewDirection.X, 0f, camera.ViewDirection.Z), m_subsystemTimeOfDay.TimeOfDay, m_subsystemWeather.GlobalPrecipitationIntensity, seasonalTemperature);
             VisibilityRangeYMultiplier = MathUtils.Lerp(VisibilityRange / num4, VisibilityRange / num5, MathUtils.Pow(m_subsystemWeather.GlobalPrecipitationIntensity, 4f));
             m_viewIsSkyVisible         = true;
         }
         if (!FogEnabled)
         {
             m_viewFogRange = new Vector2(100000f, 100000f);
         }
         if (!DrawSkyEnabled || !m_viewIsSkyVisible || SettingsManager.SkyRenderingMode == SkyRenderingMode.Disabled)
         {
             FlatBatch2D flatBatch2D = m_primitivesRenderer2d.FlatBatch(-1, DepthStencilState.None, RasterizerState.CullNoneScissor, BlendState.Opaque);
             int         count       = flatBatch2D.TriangleVertices.Count;
             flatBatch2D.QueueQuad(Vector2.Zero, camera.ViewportSize, 0f, m_viewFogColor);
             flatBatch2D.TransformTriangles(camera.ViewportMatrix, count);
             m_primitivesRenderer2d.Flush();
         }
     }
     else if (drawOrder == m_drawOrders[1])
     {
         if (DrawSkyEnabled && m_viewIsSkyVisible && SettingsManager.SkyRenderingMode != SkyRenderingMode.Disabled)
         {
             DrawSkydome(camera);
             DrawStars(camera);
             DrawSunAndMoon(camera);
             DrawClouds(camera);
             m_primitivesRenderer3d.Flush(camera.ViewProjectionMatrix);
         }
     }
     else
     {
         DrawLightning(camera);
         m_primitivesRenderer3d.Flush(camera.ViewProjectionMatrix);
     }
 }