示例#1
0
        public void DoWorkTabEventChecks(Rect rect)
        {
            DraggableWork nomad = Controller.CurrentDraggable;

            if (nomad != null)
            {
                if (Event.current.type == EventType.MouseUp && nomad.parent == this)
                {
                    nomad.OnDrop();

                    if (rect.Contains(nomad.position))
                    {
                        this.OrderAndUpdatePriorities();

                        string    badDrag = !nomad.CompletelyDisabled ? "" : "DD_WorkTab_Message_DraggedIncapableWork".CachedTranslation(new string[] { nomad.Def.labelShort }).AdjustedFor(this.pawn);
                        WorkSound sound   = !nomad.CompletelyDisabled ? WorkSound.TaskCompleted : WorkSound.TaskFailed;

                        Utilities.UserFeedbackChain(sound, badDrag);
                    }
                }
            }

            else if (rect.Contains(Event.current.mousePosition))
            {
                if (Event.current.type == EventType.Repaint)
                {
                    this.OnHover();
                }

                else if (Event.current.type == EventType.MouseDown)
                {
                    this.OnClicked();
                }
            }
        }
示例#2
0
    private IEnumerator PlayWorkSound()
    {
        WorkSound.UnPause();
        yield return(new WaitForSeconds(0.15f));

        WorkSound.Pause();
    }
示例#3
0
 void InitialiseWorkSound()
 {
     WorkSound.mute = true;
     WorkSound.Play();
     WorkSound.Pause();
     WorkSound.mute = false;
 }
示例#4
0
        private void OnCtrlClick()
        {
            this.ctrlState = !this.ctrlState;

            foreach (Pawn pawn in Find.VisibleMap.mapPawns.FreeColonists)
            {
                Controller.GetManager.GetPawnSurface(pawn).OnPrimaryCtrlClick(this.ctrlState, this.def);
            }

            string    message = (this.ctrlState ? "DD_WorkTab_Message_PrimaryCtrlEnabledAll" : "DD_WorkTab_Message_PrimaryCtrlDisabledAll").CachedTranslation(new string[] { this.def.labelShort });
            WorkSound sound   = this.ctrlState ? WorkSound.WorkEnabled : WorkSound.WorkDisabled;

            Utilities.UserFeedbackChain(sound, message);
        }
示例#5
0
        /// <summary>
        /// Centralised method to send messages and sounds to the user.
        /// </summary>
        public static void UserFeedbackChain(WorkSound workSound, string message = "")
        {
            if (Controller.UseSounds)
            {
                SoundDef audio = null;

                switch (workSound)
                {
                case (WorkSound.TaskCompleted):
                    audio = TaskCompleted;
                    break;

                case (WorkSound.TaskFailed):
                    audio = TaskFailed;
                    break;

                case (WorkSound.WorkEnabled):
                    audio = WorkEnabled;
                    break;

                case (WorkSound.WorkDisabled):
                    audio = WorkDisabled;
                    break;

                case (WorkSound.SortedSkills):
                    audio = SortedSkills;
                    break;

                case (WorkSound.UnsortedSkills):
                    audio = UnsortedSkills;
                    break;

                case (WorkSound.CompareSkillsMapChanged):
                    audio = CompareSkillsMapChanged;
                    break;
                }

                audio.PlayOneShotOnCamera(null);
            }

            if (message != "" && Controller.VerboseMessages)
            {
                Messages.Message(message, MessageTypeDefOf.SilentInput);
            }
        }
示例#6
0
        private void DoSortingChecks(WorkTypeDef sortDef)
        {
            bool changedSorting = false;

            if (Event.current.button == 0)
            {
                if (this.sortingDef != sortDef)
                {
                    this.sortingDef   = sortDef;
                    this.sortingOrder = SortOrder.Descending;
                }

                else
                {
                    switch (this.sortingOrder)
                    {
                    case SortOrder.Descending:
                        this.sortingOrder = SortOrder.Ascending;
                        break;

                    case SortOrder.Ascending:
                        this.sortingOrder = SortOrder.Undefined;
                        break;

                    default:
                        this.sortingOrder = SortOrder.Descending;
                        break;
                    }
                }

                changedSorting = true;
            }

            if (Event.current.button == 1)
            {
                if (this.sortingDef != sortDef)
                {
                    this.sortingDef   = sortDef;
                    this.sortingOrder = SortOrder.Ascending;
                }

                else
                {
                    switch (this.sortingOrder)
                    {
                    case SortOrder.Descending:
                        this.sortingOrder = SortOrder.Undefined;
                        break;

                    case SortOrder.Ascending:
                        this.sortingOrder = SortOrder.Descending;
                        break;

                    default:
                        this.sortingOrder = SortOrder.Ascending;
                        break;
                    }
                }

                changedSorting = true;
            }

            if (changedSorting)
            {
                WorkSound sound = this.sortingOrder != SortOrder.Undefined ? WorkSound.SortedSkills : WorkSound.UnsortedSkills;

                Utilities.UserFeedbackChain(sound);

                this.mustRecacheColonists = true;
            }

            Event.current.Use();
        }