Пример #1
0
 public static int NewGroup(Action <int, int> reorderedAction)
 {
     if (Event.current.type != EventType.Repaint)
     {
         return(-1);
     }
     ReorderableWidget.ReorderableGroup item = default(ReorderableWidget.ReorderableGroup);
     item.reorderedAction = reorderedAction;
     ReorderableWidget.groups.Add(item);
     return(ReorderableWidget.groups.Count - 1);
 }
 public static int NewGroup(Action <int, int> reorderedAction, ReorderableDirection direction, float drawLineExactlyBetween_space = -1f, Action <int, Vector2> extraDraggedItemOnGUI = null)
 {
     if (Event.current.type != EventType.Repaint)
     {
         return(-1);
     }
     ReorderableWidget.ReorderableGroup item = default(ReorderableWidget.ReorderableGroup);
     item.reorderedAction = reorderedAction;
     item.direction       = direction;
     item.drawLineExactlyBetween_space = drawLineExactlyBetween_space;
     item.extraDraggedItemOnGUI        = extraDraggedItemOnGUI;
     ReorderableWidget.groups.Add(item);
     return(ReorderableWidget.groups.Count - 1);
 }
        public static bool Reorderable(int groupID, Rect rect, bool useRightButton = false)
        {
            bool result;

            if (Event.current.type == EventType.Repaint)
            {
                ReorderableWidget.ReorderableInstance item = default(ReorderableWidget.ReorderableInstance);
                item.groupID = groupID;
                item.rect    = rect;
                item.absRect = new Rect(UI.GUIToScreenPoint(rect.position), rect.size);
                ReorderableWidget.reorderables.Add(item);
                int num = ReorderableWidget.reorderables.Count - 1;
                if (ReorderableWidget.draggingReorderable != -1 && (ReorderableWidget.dragBegun || Vector2.Distance(ReorderableWidget.clickedAt, Event.current.mousePosition) > 5f))
                {
                    if (!ReorderableWidget.dragBegun)
                    {
                        SoundDefOf.Tick_Tiny.PlayOneShotOnCamera(null);
                        ReorderableWidget.dragBegun = true;
                    }
                    if (ReorderableWidget.draggingReorderable == num)
                    {
                        GUI.color = ReorderableWidget.HighlightColor;
                        Widgets.DrawHighlight(rect);
                        GUI.color = Color.white;
                    }
                    if (ReorderableWidget.lastInsertNear == num && groupID >= 0 && groupID < ReorderableWidget.groups.Count)
                    {
                        Rect rect2 = ReorderableWidget.reorderables[ReorderableWidget.lastInsertNear].rect;
                        ReorderableWidget.ReorderableGroup reorderableGroup = ReorderableWidget.groups[groupID];
                        if (reorderableGroup.DrawLineExactlyBetween)
                        {
                            if (reorderableGroup.direction == ReorderableDirection.Horizontal)
                            {
                                rect2.xMin -= reorderableGroup.drawLineExactlyBetween_space / 2f;
                                rect2.xMax += reorderableGroup.drawLineExactlyBetween_space / 2f;
                            }
                            else
                            {
                                rect2.yMin -= reorderableGroup.drawLineExactlyBetween_space / 2f;
                                rect2.yMax += reorderableGroup.drawLineExactlyBetween_space / 2f;
                            }
                        }
                        GUI.color = ReorderableWidget.LineColor;
                        if (reorderableGroup.direction == ReorderableDirection.Horizontal)
                        {
                            if (ReorderableWidget.lastInsertNearLeft)
                            {
                                Widgets.DrawLine(rect2.position, new Vector2(rect2.x, rect2.yMax), ReorderableWidget.LineColor, 2f);
                            }
                            else
                            {
                                Widgets.DrawLine(new Vector2(rect2.xMax, rect2.y), new Vector2(rect2.xMax, rect2.yMax), ReorderableWidget.LineColor, 2f);
                            }
                        }
                        else if (ReorderableWidget.lastInsertNearLeft)
                        {
                            Widgets.DrawLine(rect2.position, new Vector2(rect2.xMax, rect2.y), ReorderableWidget.LineColor, 2f);
                        }
                        else
                        {
                            Widgets.DrawLine(new Vector2(rect2.x, rect2.yMax), new Vector2(rect2.xMax, rect2.yMax), ReorderableWidget.LineColor, 2f);
                        }
                        GUI.color = Color.white;
                    }
                }
                result = (ReorderableWidget.draggingReorderable == num && ReorderableWidget.dragBegun);
            }
            else
            {
                if (Event.current.rawType == EventType.MouseUp)
                {
                    ReorderableWidget.released = true;
                }
                if (Event.current.type == EventType.MouseDown && ((useRightButton && Event.current.button == 1) || (!useRightButton && Event.current.button == 0)) && Mouse.IsOver(rect))
                {
                    ReorderableWidget.clicked       = true;
                    ReorderableWidget.clickedAt     = Event.current.mousePosition;
                    ReorderableWidget.clickedInRect = rect;
                }
                result = false;
            }
            return(result);
        }