Example #1
0
        private IEnumerable <int> PointsNearMouse(Rect screenRect)
        {
            GUI.BeginGroup(screenRect);
            try
            {
                int i = 0;
                while (true)
                {
                    if (i >= curve.PointsCount)
                    {
                        yield break;
                    }
                    Vector2 screenPoint = SimpleCurveDrawer.CurveToScreenCoordsInsideScreenRect(screenRect, curve.View.rect, curve[i].Loc);
                    if ((screenPoint - Event.current.mousePosition).sqrMagnitude < 49f)
                    {
                        break;
                    }
                    i++;
                }
                yield return(i);

                /*Error: Unable to find new state assignment for yield return*/;
            }
            finally
            {
                ((_003CPointsNearMouse_003Ec__Iterator0) /*Error near IL_0108: stateMachine*/)._003C_003E__Finally0();
            }
IL_0118:
            /*Error near IL_0119: Unexpected return in MoveNext()*/;
        }
        private IEnumerable <int> PointsNearMouse(Rect screenRect)
        {
            GUI.BeginGroup(screenRect);
            try
            {
                int i = 0;
                while (true)
                {
                    if (i < this.curve.PointsCount)
                    {
                        Vector2 screenPoint = SimpleCurveDrawer.CurveToScreenCoordsInsideScreenRect(screenRect, this.curve.View.rect, this.curve[i].Loc);
                        if (!((screenPoint - Event.current.mousePosition).sqrMagnitude < 49.0))
                        {
                            i++;
                            continue;
                        }
                        break;
                    }
                    yield break;
                }
                yield return(i);

                /*Error: Unable to find new state assignment for yield return*/;
            }
            finally
            {
                GUI.EndGroup();
            }
IL_0118:
            /*Error near IL_0119: Unexpected return in MoveNext()*/;
        }
 public static void DrawCurveMousePoint(List <SimpleCurveDrawInfo> curves, Rect screenRect, Rect viewRect, string labelX)
 {
     if (curves.Count != 0 && Mouse.IsOver(screenRect))
     {
         GUI.BeginGroup(screenRect);
         Vector2             mousePosition       = Event.current.mousePosition;
         Vector2             vector              = default(Vector2);
         Vector2             vector2             = default(Vector2);
         SimpleCurveDrawInfo simpleCurveDrawInfo = null;
         bool flag = false;
         foreach (SimpleCurveDrawInfo curf in curves)
         {
             if (curf.curve.AllPoints.Any())
             {
                 Vector2 vector3 = SimpleCurveDrawer.ScreenToCurveCoords(screenRect, viewRect, mousePosition);
                 vector3.y = curf.curve.Evaluate(vector3.x);
                 Vector2 vector4 = SimpleCurveDrawer.CurveToScreenCoordsInsideScreenRect(screenRect, viewRect, vector3);
                 if (!flag || Vector2.Distance(vector4, mousePosition) < Vector2.Distance(vector2, mousePosition))
                 {
                     flag                = true;
                     vector              = vector3;
                     vector2             = vector4;
                     simpleCurveDrawInfo = curf;
                 }
             }
         }
         if (flag)
         {
             SimpleCurveDrawer.DrawPoint(vector2);
             Rect rect = new Rect(vector2.x, vector2.y, 100f, 60f);
             Text.Anchor = TextAnchor.UpperLeft;
             if (rect.x + rect.width > screenRect.width)
             {
                 rect.x     -= rect.width;
                 Text.Anchor = TextAnchor.UpperRight;
             }
             if (rect.y + rect.height > screenRect.height)
             {
                 rect.y -= rect.height;
                 if (Text.Anchor == TextAnchor.UpperLeft)
                 {
                     Text.Anchor = TextAnchor.LowerLeft;
                 }
                 else
                 {
                     Text.Anchor = TextAnchor.LowerRight;
                 }
             }
             Widgets.Label(rect, labelX + ": " + vector.x.ToString("0.##") + "\n" + simpleCurveDrawInfo.labelY + ": " + vector.y.ToString("0.##"));
             Text.Anchor = TextAnchor.UpperLeft;
         }
         GUI.EndGroup();
     }
 }
Example #4
0
 private IEnumerable <int> PointsNearMouse(Rect screenRect)
 {
     GUI.BeginGroup(screenRect);
     try
     {
         for (int i = 0; i < curve.PointsCount; i++)
         {
             if ((SimpleCurveDrawer.CurveToScreenCoordsInsideScreenRect(screenRect, curve.View.rect, curve[i].Loc) - Event.current.mousePosition).sqrMagnitude < 49f)
             {
                 yield return(i);
             }
         }
     }
     finally
     {
         GUI.EndGroup();
     }
 }
Example #5
0
 private IEnumerable <int> PointsNearMouse(Rect screenRect)
 {
     GUI.BeginGroup(screenRect);
     try
     {
         for (int i = 0; i < this.curve.PointsCount; i++)
         {
             Vector2 screenPoint = SimpleCurveDrawer.CurveToScreenCoordsInsideScreenRect(screenRect, this.curve.View.rect, this.curve[i].Loc);
             if ((screenPoint - Event.current.mousePosition).sqrMagnitude < 49f)
             {
                 yield return(i);
             }
         }
     }
     finally
     {
         base.< > __Finally0();
     }
 }
 private static void DrawInfiniteHorizontalLine(Rect rect, Rect viewRect, float curveY)
 {
     Widgets.DrawLineHorizontal(-999f, SimpleCurveDrawer.CurveToScreenCoordsInsideScreenRect(rect, viewRect, new Vector2(0f, curveY)).y, 9999f);
 }
 private static void DrawInfiniteVerticalLine(Rect rect, Rect viewRect, float curveX)
 {
     Widgets.DrawLineVertical(SimpleCurveDrawer.CurveToScreenCoordsInsideScreenRect(rect, viewRect, new Vector2(curveX, 0f)).x, -999f, 9999f);
 }
        public static void DrawCurveMeasures(Rect rect, Rect viewRect, Rect graphRect, int xLabelsCount, int yLabelsCount, bool xIntegersOnly, bool yIntegersOnly)
        {
            Text.Font = GameFont.Small;
            Color color  = new Color(0.45f, 0.45f, 0.45f);
            Color color2 = new Color(0.7f, 0.7f, 0.7f);

            GUI.BeginGroup(rect);
            float num;
            float num2;
            int   num3;

            SimpleCurveDrawer.CalculateMeasureStartAndInc(out num, out num2, out num3, viewRect.xMin, viewRect.xMax, xLabelsCount, xIntegersOnly);
            Text.Anchor = TextAnchor.UpperCenter;
            string b = string.Empty;

            for (int i = 0; i < num3; i++)
            {
                float  x    = num + num2 * (float)i;
                string text = x.ToString("F0");
                if (!(text == b))
                {
                    b = text;
                    float x2   = SimpleCurveDrawer.CurveToScreenCoordsInsideScreenRect(graphRect, viewRect, new Vector2(x, 0f)).x;
                    float num4 = x2 + 60f;
                    float num5 = rect.height - 30f;
                    GUI.color = color;
                    Widgets.DrawLineVertical(num4, num5, 5f);
                    GUI.color = color2;
                    Rect rect2 = new Rect(num4 - 31f, num5 + 2f, 60f, 30f);
                    Text.Font = GameFont.Tiny;
                    Widgets.Label(rect2, text);
                    Text.Font = GameFont.Small;
                }
            }
            float num6;
            float num7;
            int   num8;

            SimpleCurveDrawer.CalculateMeasureStartAndInc(out num6, out num7, out num8, viewRect.yMin, viewRect.yMax, yLabelsCount, yIntegersOnly);
            string b2 = string.Empty;

            Text.Anchor = TextAnchor.UpperRight;
            for (int j = 0; j < num8; j++)
            {
                float  y     = num6 + num7 * (float)j;
                string text2 = y.ToString("F0");
                if (!(text2 == b2))
                {
                    b2 = text2;
                    float y2   = SimpleCurveDrawer.CurveToScreenCoordsInsideScreenRect(graphRect, viewRect, new Vector2(0f, y)).y;
                    float num9 = y2 + (graphRect.y - rect.y);
                    GUI.color = color;
                    Widgets.DrawLineHorizontal(55f, num9, 5f + graphRect.width);
                    GUI.color = color2;
                    Rect rect3 = new Rect(0f, num9 - 10f, 55f, 20f);
                    Text.Font = GameFont.Tiny;
                    Widgets.Label(rect3, text2);
                    Text.Font = GameFont.Small;
                }
            }
            GUI.EndGroup();
            GUI.color   = new Color(1f, 1f, 1f);
            Text.Anchor = TextAnchor.UpperLeft;
        }
        public static void DrawCurveLines(Rect rect, SimpleCurveDrawInfo curve, bool drawPoints, Rect viewRect, bool useAALines, bool pointsRemoveOptimization)
        {
            if (curve.curve == null)
            {
                return;
            }
            if (curve.curve.PointsCount == 0)
            {
                return;
            }
            Rect position = rect;

            position.yMin -= 1f;
            position.yMax += 1f;
            GUI.BeginGroup(position);
            if (Event.current.type == EventType.Repaint)
            {
                if (useAALines)
                {
                    bool    flag       = true;
                    Vector2 start      = default(Vector2);
                    Vector2 curvePoint = default(Vector2);
                    int     num        = curve.curve.Points.Count((CurvePoint x) => x.x >= viewRect.xMin && x.x <= viewRect.xMax);
                    int     num2       = SimpleCurveDrawer.RemovePointsOptimizationFreq(num);
                    for (int i = 0; i < curve.curve.PointsCount; i++)
                    {
                        CurvePoint curvePoint2 = curve.curve[i];
                        if (!pointsRemoveOptimization || i % num2 != 0 || i == 0 || i == num - 1)
                        {
                            curvePoint.x = curvePoint2.x;
                            curvePoint.y = curvePoint2.y;
                            Vector2 vector = SimpleCurveDrawer.CurveToScreenCoordsInsideScreenRect(rect, viewRect, curvePoint);
                            if (flag)
                            {
                                flag = false;
                            }
                            else if ((start.x >= 0f && start.x <= rect.width) || (vector.x >= 0f && vector.x <= rect.width))
                            {
                                Widgets.DrawLine(start, vector, curve.color, 1f);
                            }
                            start = vector;
                        }
                    }
                    Vector2 start2 = SimpleCurveDrawer.CurveToScreenCoordsInsideScreenRect(rect, viewRect, curve.curve[0]);
                    Vector2 start3 = SimpleCurveDrawer.CurveToScreenCoordsInsideScreenRect(rect, viewRect, curve.curve[curve.curve.PointsCount - 1]);
                    Widgets.DrawLine(start2, new Vector2(0f, start2.y), curve.color, 1f);
                    Widgets.DrawLine(start3, new Vector2(rect.width, start3.y), curve.color, 1f);
                }
                else
                {
                    GUI.color = curve.color;
                    float num3 = viewRect.x;
                    float num4 = rect.width / 1f;
                    float num5 = viewRect.width / num4;
                    while (num3 < viewRect.xMax)
                    {
                        num3 += num5;
                        Vector2 vector2 = SimpleCurveDrawer.CurveToScreenCoordsInsideScreenRect(rect, viewRect, new Vector2(num3, curve.curve.Evaluate(num3)));
                        GUI.DrawTexture(new Rect(vector2.x, vector2.y, 1f, 1f), BaseContent.WhiteTex);
                    }
                }
                GUI.color = Color.white;
            }
            if (drawPoints)
            {
                for (int j = 0; j < curve.curve.PointsCount; j++)
                {
                    CurvePoint curvePoint3 = curve.curve[j];
                    Vector2    screenPoint = SimpleCurveDrawer.CurveToScreenCoordsInsideScreenRect(rect, viewRect, curvePoint3.Loc);
                    SimpleCurveDrawer.DrawPoint(screenPoint);
                }
            }
            foreach (float num6 in curve.curve.View.DebugInputValues)
            {
                float num7 = num6;
                GUI.color = new Color(0f, 1f, 0f, 0.25f);
                SimpleCurveDrawer.DrawInfiniteVerticalLine(rect, viewRect, num7);
                float   y            = curve.curve.Evaluate(num7);
                Vector2 curvePoint4  = new Vector2(num7, y);
                Vector2 screenPoint2 = SimpleCurveDrawer.CurveToScreenCoordsInsideScreenRect(rect, viewRect, curvePoint4);
                GUI.color = Color.green;
                SimpleCurveDrawer.DrawPoint(screenPoint2);
                GUI.color = Color.white;
            }
            GUI.EndGroup();
        }