Example #1
0
        private static void     UpdateSelection()
        {
            int hash = NGNavSelectionWindow.GetCurrentSelectionHash();

            if (NGNavSelectionWindow.lastHash == hash || hash == 0)
            {
                return;
            }

            if (Selection.objects.Length > 0)
            {
                // Prevent adding a new selection if the user just selected it through NG Nav Selection.
                if (0 <= NGNavSelectionWindow.lastFocusedHistoric && NGNavSelectionWindow.lastFocusedHistoric < NGNavSelectionWindow.historic.Count && NGNavSelectionWindow.historic[NGNavSelectionWindow.lastFocusedHistoric].GetSelectionHash() == hash)
                {
                    return;
                }

                NGNavSelectionWindow.hasChanged = true;

                // Add a new selection or update the last one.
                if (NGNavSelectionWindow.historicCursor != -1)
                {
                    NGNavSelectionWindow.historic.RemoveRange(NGNavSelectionWindow.historicCursor + 1, NGNavSelectionWindow.historic.Count - NGNavSelectionWindow.historicCursor - 1);
                    NGNavSelectionWindow.historicCursor = -1;
                }

                // Detect a change in the selection only if user selects ONE Object.
                if (Selection.objects.Length == 1)
                {
                    NGNavSelectionWindow.historic.Add(new AssetsSelection(Selection.objects, Selection.instanceIDs));
                }
                else if (NGNavSelectionWindow.historic.Count >= 1)
                {
                    NGNavSelectionWindow.historic[NGNavSelectionWindow.historic.Count - 1] = new AssetsSelection(Selection.objects, Selection.instanceIDs);
                }

                NavSettings settings = HQ.Settings.Get <NavSettings>();

                if (settings.maxHistoric > 0 && NGNavSelectionWindow.historic.Count > settings.maxHistoric)
                {
                    NGNavSelectionWindow.historic.RemoveRange(0, NGNavSelectionWindow.historic.Count - settings.maxHistoric);
                }
            }
            else
            {
                NGNavSelectionWindow.historicCursor = -1;
            }

            NGNavSelectionWindow.lastFocusedHistoric = -1;

            NGNavSelectionWindow.lastHash = hash;
            if (NGNavSelectionWindow.SelectionChanged != null)
            {
                NGNavSelectionWindow.SelectionChanged();
            }
        }
Example #2
0
        public static void      SetHistoricCursor(int i)
        {
            NGNavSelectionWindow.historicCursor = i;

            if (i >= 0)
            {
                NGNavSelectionWindow.historic[NGNavSelectionWindow.historicCursor].Select();
                NGNavSelectionWindow.lastHash = NGNavSelectionWindow.GetCurrentSelectionHash();
            }
        }