예제 #1
0
 public void Disable()
 {
     _current?.Dispose();
     _current       = null;
     _currentScreen = null;
 }
예제 #2
0
        private IEnumerator RefreshCurrentUIDeferred(string screen)
        {
            // Let every event trigger a UI refresh
            yield return(0);

            _uiRefreshScheduled = false;

            // Cannot proceed
            if (_plugin == null || _plugin.animation == null || _plugin.animation.Current == null)
            {
                yield break;
            }

            // Same UI, just refresh
            if (_current != null && _current.name == screen)
            {
                yield break;
            }

            // UI Change
            _uiRefreshInProgress = true;

            // Dispose previous
            if (_current != null)
            {
                try
                {
                    _current.Dispose();
                }
                catch (Exception exc)
                {
                    SuperController.LogError($"VamTimeline.{nameof(ScreensManager)}.{nameof(RefreshCurrentUIDeferred)} (while removing {_current.name}): {exc}");
                }

                _current = null;
            }

            yield return(0);

            // Create new screen
            switch (screen)
            {
            case SettingsScreen.ScreenName:
                _current = new SettingsScreen(_plugin);
                break;

            case TargetsScreen.ScreenName:
                _current = new TargetsScreen(_plugin);
                break;

            case EditScreen.ScreenName:
                _current = new EditScreen(_plugin);
                break;

            case BulkScreen.ScreenName:
                _current = new BulkScreen(_plugin);
                break;

            case AdvancedScreen.ScreenName:
                _current = new AdvancedScreen(_plugin);
                break;

            case MocapScreen.ScreenName:
                _current = new MocapScreen(_plugin);
                break;

            case MoreScreen.ScreenName:
                _current = new MoreScreen(_plugin);
                break;

            case EditAnimationScreen.ScreenName:
                _current = new EditAnimationScreen(_plugin);
                break;

            case EditSequenceScreen.ScreenName:
                _current = new EditSequenceScreen(_plugin);
                break;

            case AddAnimationScreen.ScreenName:
                _current = new AddAnimationScreen(_plugin);
                break;

            case ManageAnimationsScreen.ScreenName:
                _current = new ManageAnimationsScreen(_plugin);
                break;

            case PerformanceScreen.ScreenName:
                _current = new PerformanceScreen(_plugin);
                break;

            case HelpScreen.ScreenName:
                _current = new HelpScreen(_plugin);
                break;

            default:
                throw new InvalidOperationException($"Unknown screen {screen}");
            }

            try
            {
                _current.onScreenChangeRequested.AddListener(ChangeScreen);
                _current.Init();
            }
            catch (Exception exc)
            {
                SuperController.LogError($"VamTimeline.{nameof(ScreensManager)}.{nameof(RefreshCurrentUIDeferred)} (while initializing {_current.name}): {exc}");
            }

            yield return(0);

            _uiRefreshInProgress = false;

            if (_uiRefreshInvalidated)
            {
                _uiRefreshInvalidated = false;
                _uiRefreshScheduled   = true;
                _plugin.StartCoroutine(RefreshCurrentUIDeferred(_currentScreen));
            }

            if (_animationUI.popup.visible)
            {
                // Fix for when the popup is open, it becomes hidden by newer components
                _animationUI.popup.visible = false;
            }
        }