public static void DrawCurve(Rect rect, SimpleCurve curve, SimpleCurveDrawerStyle style = null, List <CurveMark> marks = null, Rect legendScreenRect = default(Rect))
 {
     SimpleCurveDrawer.DrawCurve(rect, new SimpleCurveDrawInfo
     {
         curve = curve
     }, style, marks, legendScreenRect);
 }
        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()*/;
        }
예제 #3
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()*/;
        }
 public static void DrawCurve(Rect rect, SimpleCurveDrawInfo curve, SimpleCurveDrawerStyle style = null, List <CurveMark> marks = null, Rect legendScreenRect = default(Rect))
 {
     if (curve.curve != null)
     {
         List <SimpleCurveDrawInfo> list = new List <SimpleCurveDrawInfo>();
         list.Add(curve);
         SimpleCurveDrawer.DrawCurves(rect, list, style, marks, legendScreenRect);
     }
 }
 public static void DrawCurve(Rect rect, SimpleCurveDrawInfo curve, SimpleCurveDrawerStyle style = null, List <CurveMark> marks = null, Rect legendScreenRect = default(Rect))
 {
     if (curve.curve == null)
     {
         return;
     }
     SimpleCurveDrawer.DrawCurves(rect, new List <SimpleCurveDrawInfo>
     {
         curve
     }, style, marks, legendScreenRect);
 }
 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();
     }
 }
        public static void DrawGraphBackgroundLines(Rect rect, Rect viewRect)
        {
            GUI.BeginGroup(rect);
            float num = 0.01f;

            while (viewRect.width / (num * 10f) > 4f)
            {
                num *= 10f;
            }
            for (float num2 = (float)Mathf.FloorToInt(viewRect.x / num) * num; num2 < viewRect.xMax; num2 += num)
            {
                if (Mathf.Abs(num2 % (10f * num)) < 0.001f)
                {
                    GUI.color = SimpleCurveDrawer.MajorLineColor;
                }
                else
                {
                    GUI.color = SimpleCurveDrawer.MinorLineColor;
                }
                SimpleCurveDrawer.DrawInfiniteVerticalLine(rect, viewRect, num2);
            }
            float num3 = 0.01f;

            while (viewRect.height / (num3 * 10f) > 4f)
            {
                num3 *= 10f;
            }
            for (float num4 = (float)Mathf.FloorToInt(viewRect.y / num3) * num3; num4 < viewRect.yMax; num4 += num3)
            {
                if (Mathf.Abs(num4 % (10f * num3)) < 0.001f)
                {
                    GUI.color = SimpleCurveDrawer.MajorLineColor;
                }
                else
                {
                    GUI.color = SimpleCurveDrawer.MinorLineColor;
                }
                SimpleCurveDrawer.DrawInfiniteHorizontalLine(rect, viewRect, num4);
            }
            GUI.color = SimpleCurveDrawer.AxisLineColor;
            SimpleCurveDrawer.DrawInfiniteHorizontalLine(rect, viewRect, 0f);
            SimpleCurveDrawer.DrawInfiniteVerticalLine(rect, viewRect, 0f);
            GUI.color = Color.white;
            GUI.EndGroup();
        }
예제 #8
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();
     }
 }
예제 #9
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();
     }
 }
        public static void DrawCurveMarks(Rect rect, Rect viewRect, List <CurveMark> marks)
        {
            float x    = viewRect.x;
            float num  = viewRect.x + viewRect.width;
            float num2 = rect.y + 5f;
            float num3 = rect.yMax - 5f;

            for (int i = 0; i < marks.Count; i++)
            {
                CurveMark curveMark = marks[i];
                if (curveMark.X >= x && curveMark.X <= num)
                {
                    GUI.color = curveMark.Color;
                    Vector2 screenPoint = new Vector2(rect.x + (curveMark.X - x) / (num - x) * rect.width, (i % 2 != 0) ? num3 : num2);
                    SimpleCurveDrawer.DrawPoint(screenPoint);
                    TooltipHandler.TipRegion(new Rect(screenPoint.x - 5f, screenPoint.y - 5f, 10f, 10f), new TipSignal(curveMark.Message));
                }
                i++;
            }
            GUI.color = Color.white;
        }
 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;
        }
예제 #14
0
        private void DoCurveEditor(Rect screenRect)
        {
            Widgets.DrawMenuSection(screenRect);
            SimpleCurveDrawer.DrawCurve(screenRect, this.curve, null, null, default(Rect));
            Vector2 mousePosition = Event.current.mousePosition;

            if (Mouse.IsOver(screenRect))
            {
                Rect    rect = new Rect(mousePosition.x + 8f, mousePosition.y + 18f, 100f, 100f);
                Vector2 v    = SimpleCurveDrawer.ScreenToCurveCoords(screenRect, this.curve.View.rect, mousePosition);
                Widgets.Label(rect, v.ToStringTwoDigits());
            }
            Rect rect2 = new Rect(0f, 0f, 50f, 24f);

            rect2.x = screenRect.x;
            rect2.y = screenRect.y + screenRect.height / 2f - 12f;
            string s = Widgets.TextField(rect2, this.curve.View.rect.x.ToString());
            float  num;

            if (float.TryParse(s, out num))
            {
                this.curve.View.rect.x = num;
            }
            rect2.x = screenRect.xMax - rect2.width;
            rect2.y = screenRect.y + screenRect.height / 2f - 12f;
            s       = Widgets.TextField(rect2, this.curve.View.rect.xMax.ToString());
            if (float.TryParse(s, out num))
            {
                this.curve.View.rect.xMax = num;
            }
            rect2.x = screenRect.x + screenRect.width / 2f - rect2.width / 2f;
            rect2.y = screenRect.yMax - rect2.height;
            s       = Widgets.TextField(rect2, this.curve.View.rect.y.ToString());
            if (float.TryParse(s, out num))
            {
                this.curve.View.rect.y = num;
            }
            rect2.x = screenRect.x + screenRect.width / 2f - rect2.width / 2f;
            rect2.y = screenRect.y;
            s       = Widgets.TextField(rect2, this.curve.View.rect.yMax.ToString());
            if (float.TryParse(s, out num))
            {
                this.curve.View.rect.yMax = num;
            }
            if (Mouse.IsOver(screenRect))
            {
                if (Event.current.type == EventType.ScrollWheel)
                {
                    float           num2          = -1f * Event.current.delta.y * 0.025f;
                    float           num3          = this.curve.View.rect.center.x - this.curve.View.rect.x;
                    float           num4          = this.curve.View.rect.center.y - this.curve.View.rect.y;
                    SimpleCurveView expr_37D_cp_0 = this.curve.View;
                    expr_37D_cp_0.rect.xMin = expr_37D_cp_0.rect.xMin + num3 * num2;
                    SimpleCurveView expr_39E_cp_0 = this.curve.View;
                    expr_39E_cp_0.rect.xMax = expr_39E_cp_0.rect.xMax - num3 * num2;
                    SimpleCurveView expr_3BF_cp_0 = this.curve.View;
                    expr_3BF_cp_0.rect.yMin = expr_3BF_cp_0.rect.yMin + num4 * num2;
                    SimpleCurveView expr_3E0_cp_0 = this.curve.View;
                    expr_3E0_cp_0.rect.yMax = expr_3E0_cp_0.rect.yMax - num4 * num2;
                    Event.current.Use();
                }
                if (Event.current.type == EventType.MouseDown && (Event.current.button == 0 || Event.current.button == 2))
                {
                    List <int> list = this.PointsNearMouse(screenRect).ToList <int>();
                    if (list.Any <int>())
                    {
                        this.draggingPointIndex = list[0];
                    }
                    else
                    {
                        this.draggingPointIndex = -1;
                    }
                    if (this.draggingPointIndex < 0)
                    {
                        this.draggingButton = Event.current.button;
                    }
                    Event.current.Use();
                }
                if (Event.current.type == EventType.MouseDown && Event.current.button == 1)
                {
                    Vector2 mouseCurveCoords     = SimpleCurveDrawer.ScreenToCurveCoords(screenRect, this.curve.View.rect, Event.current.mousePosition);
                    List <FloatMenuOption> list2 = new List <FloatMenuOption>();
                    list2.Add(new FloatMenuOption("Add point at " + mouseCurveCoords.ToString(), delegate
                    {
                        this.curve.Add(new CurvePoint(mouseCurveCoords), true);
                    }, MenuOptionPriority.Default, null, null, 0f, null, null));
                    foreach (int current in this.PointsNearMouse(screenRect))
                    {
                        CurvePoint point = this.curve[current];
                        list2.Add(new FloatMenuOption("Remove point at " + point.ToString(), delegate
                        {
                            this.curve.RemovePointNear(point);
                        }, MenuOptionPriority.Default, null, null, 0f, null, null));
                    }
                    Find.WindowStack.Add(new FloatMenu(list2));
                    Event.current.Use();
                }
            }
            if (this.draggingPointIndex >= 0)
            {
                this.curve[this.draggingPointIndex] = new CurvePoint(SimpleCurveDrawer.ScreenToCurveCoords(screenRect, this.curve.View.rect, Event.current.mousePosition));
                this.curve.SortPoints();
                if (Event.current.type == EventType.MouseUp && Event.current.button == 0)
                {
                    this.draggingPointIndex = -1;
                    Event.current.Use();
                }
            }
            if (this.DraggingView)
            {
                if (Event.current.type == EventType.MouseDrag)
                {
                    Vector2         delta         = Event.current.delta;
                    SimpleCurveView expr_691_cp_0 = this.curve.View;
                    expr_691_cp_0.rect.x = expr_691_cp_0.rect.x - delta.x * this.curve.View.rect.width * 0.002f;
                    SimpleCurveView expr_6D0_cp_0 = this.curve.View;
                    expr_6D0_cp_0.rect.y = expr_6D0_cp_0.rect.y + delta.y * this.curve.View.rect.height * 0.002f;
                    Event.current.Use();
                }
                if (Event.current.type == EventType.MouseUp && Event.current.button == this.draggingButton)
                {
                    this.draggingButton = -1;
                }
            }
        }
예제 #15
0
        private void DoCurveEditor(Rect screenRect)
        {
            Widgets.DrawMenuSection(screenRect);
            SimpleCurveDrawer.DrawCurve(screenRect, curve);
            Vector2 mousePosition = Event.current.mousePosition;

            if (Mouse.IsOver(screenRect))
            {
                Rect    rect = new Rect(mousePosition.x + 8f, mousePosition.y + 18f, 100f, 100f);
                Vector2 v    = SimpleCurveDrawer.ScreenToCurveCoords(screenRect, curve.View.rect, mousePosition);
                Widgets.Label(rect, v.ToStringTwoDigits());
            }
            Rect rect2 = new Rect(0f, 0f, 50f, 24f);

            rect2.x = screenRect.x;
            rect2.y = screenRect.y + screenRect.height / 2f - 12f;
            if (float.TryParse(Widgets.TextField(rect2, curve.View.rect.x.ToString()), out float result))
            {
                curve.View.rect.x = result;
            }
            rect2.x = screenRect.xMax - rect2.width;
            rect2.y = screenRect.y + screenRect.height / 2f - 12f;
            if (float.TryParse(Widgets.TextField(rect2, curve.View.rect.xMax.ToString()), out result))
            {
                curve.View.rect.xMax = result;
            }
            rect2.x = screenRect.x + screenRect.width / 2f - rect2.width / 2f;
            rect2.y = screenRect.yMax - rect2.height;
            if (float.TryParse(Widgets.TextField(rect2, curve.View.rect.y.ToString()), out result))
            {
                curve.View.rect.y = result;
            }
            rect2.x = screenRect.x + screenRect.width / 2f - rect2.width / 2f;
            rect2.y = screenRect.y;
            if (float.TryParse(Widgets.TextField(rect2, curve.View.rect.yMax.ToString()), out result))
            {
                curve.View.rect.yMax = result;
            }
            if (Mouse.IsOver(screenRect))
            {
                if (Event.current.type == EventType.ScrollWheel)
                {
                    float num  = -1f * Event.current.delta.y * 0.025f;
                    float num2 = curve.View.rect.center.x - curve.View.rect.x;
                    float num3 = curve.View.rect.center.y - curve.View.rect.y;
                    curve.View.rect.xMin += num2 * num;
                    curve.View.rect.xMax -= num2 * num;
                    curve.View.rect.yMin += num3 * num;
                    curve.View.rect.yMax -= num3 * num;
                    Event.current.Use();
                }
                if (Event.current.type == EventType.MouseDown && (Event.current.button == 0 || Event.current.button == 2))
                {
                    List <int> list = PointsNearMouse(screenRect).ToList();
                    if (list.Any())
                    {
                        draggingPointIndex = list[0];
                    }
                    else
                    {
                        draggingPointIndex = -1;
                    }
                    if (draggingPointIndex < 0)
                    {
                        draggingButton = Event.current.button;
                    }
                    Event.current.Use();
                }
                if (Event.current.type == EventType.MouseDown && Event.current.button == 1)
                {
                    Vector2 mouseCurveCoords     = SimpleCurveDrawer.ScreenToCurveCoords(screenRect, curve.View.rect, Event.current.mousePosition);
                    List <FloatMenuOption> list2 = new List <FloatMenuOption>();
                    list2.Add(new FloatMenuOption("Add point at " + mouseCurveCoords.ToString(), delegate
                    {
                        curve.Add(new CurvePoint(mouseCurveCoords));
                    }));
                    foreach (int item in PointsNearMouse(screenRect))
                    {
                        CurvePoint point = curve[item];
                        list2.Add(new FloatMenuOption("Remove point at " + point.ToString(), delegate
                        {
                            curve.RemovePointNear(point);
                        }));
                    }
                    Find.WindowStack.Add(new FloatMenu(list2));
                    Event.current.Use();
                }
            }
            if (draggingPointIndex >= 0)
            {
                curve[draggingPointIndex] = new CurvePoint(SimpleCurveDrawer.ScreenToCurveCoords(screenRect, curve.View.rect, Event.current.mousePosition));
                curve.SortPoints();
                if (Event.current.type == EventType.MouseUp && Event.current.button == 0)
                {
                    draggingPointIndex = -1;
                    Event.current.Use();
                }
            }
            if (DraggingView)
            {
                if (Event.current.type == EventType.MouseDrag)
                {
                    Vector2 delta = Event.current.delta;
                    curve.View.rect.x -= delta.x * curve.View.rect.width * 0.002f;
                    curve.View.rect.y += delta.y * curve.View.rect.height * 0.002f;
                    Event.current.Use();
                }
                if (Event.current.type == EventType.MouseUp && Event.current.button == draggingButton)
                {
                    draggingButton = -1;
                }
            }
        }
        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();
        }
        public static void DrawCurves(Rect rect, List <SimpleCurveDrawInfo> curves, SimpleCurveDrawerStyle style = null, List <CurveMark> marks = null, Rect legendRect = default(Rect))
        {
            if (Event.current.type != EventType.Repaint)
            {
                return;
            }
            if (style == null)
            {
                style = new SimpleCurveDrawerStyle();
            }
            if (curves.Count == 0)
            {
                return;
            }
            bool flag     = true;
            Rect viewRect = default(Rect);

            for (int i = 0; i < curves.Count; i++)
            {
                SimpleCurveDrawInfo simpleCurveDrawInfo = curves[i];
                if (simpleCurveDrawInfo.curve != null)
                {
                    if (flag)
                    {
                        flag     = false;
                        viewRect = simpleCurveDrawInfo.curve.View.rect;
                    }
                    else
                    {
                        viewRect.xMin = Mathf.Min(viewRect.xMin, simpleCurveDrawInfo.curve.View.rect.xMin);
                        viewRect.xMax = Mathf.Max(viewRect.xMax, simpleCurveDrawInfo.curve.View.rect.xMax);
                        viewRect.yMin = Mathf.Min(viewRect.yMin, simpleCurveDrawInfo.curve.View.rect.yMin);
                        viewRect.yMax = Mathf.Max(viewRect.yMax, simpleCurveDrawInfo.curve.View.rect.yMax);
                    }
                }
            }
            if (style.UseFixedScale)
            {
                viewRect.yMin = style.FixedScale.x;
                viewRect.yMax = style.FixedScale.y;
            }
            if (style.OnlyPositiveValues)
            {
                if (viewRect.xMin < 0f)
                {
                    viewRect.xMin = 0f;
                }
                if (viewRect.yMin < 0f)
                {
                    viewRect.yMin = 0f;
                }
            }
            if (style.UseFixedSection)
            {
                viewRect.xMin = style.FixedSection.min;
                viewRect.xMax = style.FixedSection.max;
            }
            if (Mathf.Approximately(viewRect.width, 0f) || Mathf.Approximately(viewRect.height, 0f))
            {
                return;
            }
            Rect rect2 = rect;

            if (style.DrawMeasures)
            {
                rect2.xMin += 60f;
                rect2.yMax -= 30f;
            }
            if (marks != null)
            {
                Rect rect3 = rect2;
                rect3.height = 15f;
                SimpleCurveDrawer.DrawCurveMarks(rect3, viewRect, marks);
                rect2.yMin = rect3.yMax;
            }
            if (style.DrawBackground)
            {
                GUI.color = new Color(0.302f, 0.318f, 0.365f);
                GUI.DrawTexture(rect2, BaseContent.WhiteTex);
            }
            if (style.DrawBackgroundLines)
            {
                SimpleCurveDrawer.DrawGraphBackgroundLines(rect2, viewRect);
            }
            if (style.DrawMeasures)
            {
                SimpleCurveDrawer.DrawCurveMeasures(rect, viewRect, rect2, style.MeasureLabelsXCount, style.MeasureLabelsYCount, style.XIntegersOnly, style.YIntegersOnly);
            }
            foreach (SimpleCurveDrawInfo curve in curves)
            {
                SimpleCurveDrawer.DrawCurveLines(rect2, curve, style.DrawPoints, viewRect, style.UseAntiAliasedLines, style.PointsRemoveOptimization);
            }
            if (style.DrawLegend)
            {
                SimpleCurveDrawer.DrawCurvesLegend(legendRect, curves);
            }
            if (style.DrawCurveMousePoint)
            {
                SimpleCurveDrawer.DrawCurveMousePoint(curves, rect2, viewRect, style.LabelX);
            }
        }
        private void DoCurveEditor(Rect screenRect)
        {
            Widgets.DrawMenuSection(screenRect);
            SimpleCurveDrawer.DrawCurve(screenRect, this.curve, null, null, default(Rect));
            Vector2 mousePosition = Event.current.mousePosition;

            if (Mouse.IsOver(screenRect))
            {
                Rect    rect = new Rect((float)(mousePosition.x + 8.0), (float)(mousePosition.y + 18.0), 100f, 100f);
                Vector2 v    = SimpleCurveDrawer.ScreenToCurveCoords(screenRect, this.curve.View.rect, mousePosition);
                Widgets.Label(rect, v.ToStringTwoDigits());
            }
            Rect rect2 = new Rect(0f, 0f, 50f, 24f);

            rect2.x = screenRect.x;
            rect2.y = (float)(screenRect.y + screenRect.height / 2.0 - 12.0);
            string s   = Widgets.TextField(rect2, this.curve.View.rect.x.ToString());
            float  num = default(float);

            if (float.TryParse(s, out num))
            {
                this.curve.View.rect.x = num;
            }
            rect2.x = screenRect.xMax - rect2.width;
            rect2.y = (float)(screenRect.y + screenRect.height / 2.0 - 12.0);
            s       = Widgets.TextField(rect2, this.curve.View.rect.xMax.ToString());
            if (float.TryParse(s, out num))
            {
                this.curve.View.rect.xMax = num;
            }
            rect2.x = (float)(screenRect.x + screenRect.width / 2.0 - rect2.width / 2.0);
            rect2.y = screenRect.yMax - rect2.height;
            s       = Widgets.TextField(rect2, this.curve.View.rect.y.ToString());
            if (float.TryParse(s, out num))
            {
                this.curve.View.rect.y = num;
            }
            rect2.x = (float)(screenRect.x + screenRect.width / 2.0 - rect2.width / 2.0);
            rect2.y = screenRect.y;
            s       = Widgets.TextField(rect2, this.curve.View.rect.yMax.ToString());
            if (float.TryParse(s, out num))
            {
                this.curve.View.rect.yMax = num;
            }
            if (Mouse.IsOver(screenRect))
            {
                if (Event.current.type == EventType.ScrollWheel)
                {
                    Vector2 delta   = Event.current.delta;
                    float   num2    = (float)(-1.0 * delta.y * 0.02500000037252903);
                    Vector2 center  = this.curve.View.rect.center;
                    float   num3    = center.x - this.curve.View.rect.x;
                    Vector2 center2 = this.curve.View.rect.center;
                    float   num4    = center2.y - this.curve.View.rect.y;
                    this.curve.View.rect.xMin += num3 * num2;
                    this.curve.View.rect.xMax -= num3 * num2;
                    this.curve.View.rect.yMin += num4 * num2;
                    this.curve.View.rect.yMax -= num4 * num2;
                    Event.current.Use();
                }
                if (Event.current.type == EventType.MouseDown && (Event.current.button == 0 || Event.current.button == 2))
                {
                    List <int> list = this.PointsNearMouse(screenRect).ToList();
                    if (list.Any())
                    {
                        this.draggingPointIndex = list[0];
                    }
                    else
                    {
                        this.draggingPointIndex = -1;
                    }
                    if (this.draggingPointIndex < 0)
                    {
                        this.draggingButton = Event.current.button;
                    }
                    Event.current.Use();
                }
                if (Event.current.type == EventType.MouseDown && Event.current.button == 1)
                {
                    Vector2 mouseCurveCoords     = SimpleCurveDrawer.ScreenToCurveCoords(screenRect, this.curve.View.rect, Event.current.mousePosition);
                    List <FloatMenuOption> list2 = new List <FloatMenuOption>();
                    list2.Add(new FloatMenuOption("Add point at " + mouseCurveCoords.ToString(), delegate
                    {
                        this.curve.Add(new CurvePoint(mouseCurveCoords), true);
                    }, MenuOptionPriority.Default, null, null, 0f, null, null));
                    foreach (int item in this.PointsNearMouse(screenRect))
                    {
                        CurvePoint point = this.curve[item];
                        list2.Add(new FloatMenuOption("Remove point at " + point.ToString(), delegate
                        {
                            this.curve.RemovePointNear(point);
                        }, MenuOptionPriority.Default, null, null, 0f, null, null));
                    }
                    Find.WindowStack.Add(new FloatMenu(list2));
                    Event.current.Use();
                }
            }
            if (this.draggingPointIndex >= 0)
            {
                this.curve[this.draggingPointIndex] = new CurvePoint(SimpleCurveDrawer.ScreenToCurveCoords(screenRect, this.curve.View.rect, Event.current.mousePosition));
                this.curve.SortPoints();
                if (Event.current.type == EventType.MouseUp && Event.current.button == 0)
                {
                    this.draggingPointIndex = -1;
                    Event.current.Use();
                }
            }
            if (this.DraggingView)
            {
                if (Event.current.type == EventType.MouseDrag)
                {
                    Vector2 delta2 = Event.current.delta;
                    this.curve.View.rect.x -= (float)(delta2.x * this.curve.View.rect.width * 0.0020000000949949026);
                    this.curve.View.rect.y += (float)(delta2.y * this.curve.View.rect.height * 0.0020000000949949026);
                    Event.current.Use();
                }
                if (Event.current.type == EventType.MouseUp && Event.current.button == this.draggingButton)
                {
                    this.draggingButton = -1;
                }
            }
        }