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; } } }
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; } } }
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; } } }