コード例 #1
0
        public void HeaderInteractions(Rect rect, PawnTable table)
        {
            if (!Mouse.IsOver(rect))
            {
                return;
            }

            // handle interactions
            if (Event.current.shift)
            {
                // deal with clicks and scrolls
                if (Find.PlaySettings.useWorkPriorities)
                {
                    if (ScrolledUp(rect, true) || RightClicked(rect))
                    {
                        WorkGiver.IncrementPriority(CapablePawns, VisibleHour, SelectedHours);
                    }
                    if (ScrolledDown(rect, true) || LeftClicked(rect))
                    {
                        WorkGiver.DecrementPriority(CapablePawns, VisibleHour, SelectedHours);
                    }
                }
                else
                {
                    // this gets slightly more complicated
                    var pawns = CapablePawns;
                    if (ScrolledUp(rect, true) || RightClicked(rect))
                    {
                        if (pawns.Any(p => p.GetPriority(WorkGiver, VisibleHour) != 0))
                        {
                            if (Settings.playSounds)
                            {
                                SoundDefOf.CheckboxTurnedOff.PlayOneShotOnCamera();
                            }
                            foreach (Pawn pawn in pawns)
                            {
                                pawn.SetPriority(WorkGiver, 0, SelectedHours);
                            }
                        }
                    }

                    if (ScrolledDown(rect, true) || LeftClicked(rect))
                    {
                        if (pawns.Any(p => p.GetPriority(WorkGiver, VisibleHour) == 0))
                        {
                            if (Settings.playSounds)
                            {
                                SoundDefOf.CheckboxTurnedOn.PlayOneShotOnCamera();
                            }
                            foreach (Pawn pawn in pawns)
                            {
                                pawn.SetPriority(WorkGiver, 3, SelectedHours);
                            }
                        }
                    }
                }
            }
            else if (def.sortable)
            {
                if (LeftClicked(rect))
                {
                    Sort(table);
                }
                if (RightClicked(rect))
                {
                    Sort(table, false);
                }
            }
        }