Esempio n. 1
0
        /// <summary>
        /// Sorts the Roster.
        /// </summary>
        /// <param name="force">Force re-sorting? (Default: true)</param>
        public void SortRoster(bool force = true)
        {
            if (roster != null && (!sorted || force))
            {
                int count = buttonSelectOrder.Count;
                int off   = 0;
                if (defaultOrder != null)
                {
                    count++;
                    off++;
                }
                KerbalComparer[] comparisons = new KerbalComparer[count];
                if (defaultOrder != null)
                {
                    comparisons[0] = defaultOrder;
                }
                for (int i = 0; i < buttonSelectOrder.Count; i++)
                {
                    int bIdx = buttonSelectOrder[i];
                    comparisons[i + off] = buttons[bIdx].comparers[buttonStates[bIdx]];
                }
                CrewSorter <IUIListObject> .SortRoster(roster, comparisons);

                sorted = true;
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Switch the list that the crew Sort Bar operates with on tab change. (Callback)
        /// </summary>
        /// <param name="panel">The new panel</param>
        protected void OnTabSwitch(CrewPanel panel)
        {
            try {
                if (this.curPanel == panel)
                {
                    return;
                }
                this.curPanel = panel;

                StockRoster    roster       = null;
                KerbalComparer defaultOrder = null;
                switch (panel)
                {
                case CrewPanel.Available:
                    roster       = this.available;
                    defaultOrder = StandardKerbalComparers.DefaultAvailable;
                    break;

                case CrewPanel.Assigned:
                    roster       = this.assigned;
                    defaultOrder = StandardKerbalComparers.DefaultAssigned;
                    break;

                case CrewPanel.Killed:
                    roster       = this.killed;
                    defaultOrder = StandardKerbalComparers.DefaultKilled;
                    break;
                }
                sortBarCrew.SetRoster(roster);
                sortBarCrew.SetDefaultOrdering(defaultOrder);
            }
            catch (Exception e) {
                Debug.LogError("KerbalSorter: Unexpected error in AstronautComplexHook: " + e);
            }
        }
Esempio n. 3
0
 /// <summary>
 /// Sets the base ordering of the Roster.
 /// </summary>
 /// <param name="comp">The function defining the base ordering</param>
 public void SetDefaultOrdering(KerbalComparer comp)
 {
     defaultOrder = comp;
 }