Esempio n. 1
0
        // Apply server token
        private void RelinkServerToken(bool closeIfInvalid)
        {
            // Open Setup if Invalid
            bool invalid = !WitConfigurationUtility.IsServerTokenValid(serverToken);

            if (invalid)
            {
                // Clear if desired
                if (string.IsNullOrEmpty(serverToken))
                {
                    WitAuthUtility.ServerToken = serverToken;
                }
                // Close if desired
                if (closeIfInvalid)
                {
                    // Open Setup
                    WitWindowUtility.OpenSetupWindow(WitWindowUtility.OpenConfigurationWindow);
                    // Close this Window
                    Close();
                }
                return;
            }

            // Set valid server token
            WitAuthUtility.ServerToken = serverToken;
            WitConfigurationUtility.SetServerToken(serverToken);
        }
Esempio n. 2
0
 protected override bool DrawWizardGUI()
 {
     // Layout base
     base.DrawWizardGUI();
     // True if valid server token
     return(WitConfigurationUtility.IsServerTokenValid(serverToken));
 }
Esempio n. 3
0
 // Safe refresh
 protected virtual void SafeRefresh()
 {
     if (WitConfigurationUtility.IsServerTokenValid(_serverToken))
     {
         configuration.SetServerToken(_serverToken);
     }
     else if (WitConfigurationUtility.IsClientTokenValid(configuration.clientAccessToken))
     {
         configuration.RefreshData();
     }
 }
Esempio n. 4
0
        // Opens Understanding Window to specific configuration
        public static void OpenUnderstandingWindow(WitConfiguration configuration = null)
        {
            // Setup if needed
            if (configuration == null && !WitConfigurationUtility.HasValidCustomConfig())
            {
                OpenSetupWindow(OpenUnderstandingWindow);
                return;
            }

            // Get window & show
            WitConfigurationWindow window = (WitConfigurationWindow)EditorWindow.GetWindow(UnderstandingWindowType);

            window.autoRepaintOnSceneChange = true;
            window.SetConfiguration(configuration);
            window.Show();
        }
        // Configuration select
        public static void LayoutConfigurationSelect(ref int configIndex)
        {
            // Refresh configurations if needed
            WitConfiguration[] witConfigs = WitConfigurationUtility.WitConfigs;

            if (witConfigs == null || witConfigs.Length == 0)
            {
                // If no configuration exists, provide a means for the user to create a new one.
                GUILayout.BeginHorizontal();
                GUILayout.FlexibleSpace();

                if (WitEditorUI.LayoutTextButton("New Config"))
                {
                    WitConfigurationUtility.CreateConfiguration("");

                    EditorUtility.FocusProjectWindow();
                }

                GUILayout.FlexibleSpace();
                GUILayout.EndHorizontal();

                return;
            }

            // Clamp Config Index
            bool configUpdated = false;

            if (configIndex < 0 || configIndex >= witConfigs.Length)
            {
                configUpdated = true;
                configIndex   = Mathf.Clamp(configIndex, 0, witConfigs.Length);
            }

            GUILayout.BeginHorizontal();

            // Layout popup
            WitEditorUI.LayoutPopup(WitTexts.Texts.ConfigurationSelectLabel, WitConfigurationUtility.WitConfigNames, ref configIndex, ref configUpdated);

            if (GUILayout.Button("", GUI.skin.GetStyle("IN ObjectField"), GUILayout.Width(15)))
            {
                EditorUtility.FocusProjectWindow();
                EditorGUIUtility.PingObject(witConfigs[configIndex]);
            }

            GUILayout.EndHorizontal();
        }
Esempio n. 6
0
        protected override void LayoutContent()
        {
            // Reload if config is removed
            if (witConfiguration == null && witConfigIndex != -1)
            {
                WitConfigurationUtility.ReloadConfigurationData();
                SetConfiguration(-1);
            }

            // Layout popup
            int index = witConfigIndex;

            WitConfigurationEditorUI.LayoutConfigurationSelect(ref index);
            GUILayout.Space(WitStyles.ButtonMargin);
            // Selection changed
            if (index != witConfigIndex)
            {
                SetConfiguration(index);
            }
        }
Esempio n. 7
0
        protected override void LayoutContent()
        {
            // Server access token
            GUILayout.BeginHorizontal();
            bool updated = false;

            WitEditorUI.LayoutPasswordField(WitTexts.SettingsServerTokenContent, ref serverToken, ref updated);
            if (updated)
            {
                RelinkServerToken(false);
            }
            if (WitEditorUI.LayoutTextButton(WitTexts.Texts.SettingsRelinkButtonLabel))
            {
                RelinkServerToken(true);
            }
            if (WitEditorUI.LayoutTextButton(WitTexts.Texts.SettingsAddButtonLabel))
            {
                int newIndex = WitConfigurationUtility.CreateConfiguration(serverToken);
                if (newIndex != -1)
                {
                    SetConfiguration(newIndex);
                }
            }
            GUILayout.EndHorizontal();
            GUILayout.Space(WitStyles.ButtonMargin);

            // Configuration select
            base.LayoutContent();
            // Update inspector if needed
            if (witInspector == null || witConfiguration == null || witInspector.configuration != witConfiguration)
            {
                SetWitEditor();
            }

            // Layout configuration inspector
            if (witConfiguration && witInspector)
            {
                witInspector.OnInspectorGUI();
            }
        }
Esempio n. 8
0
        public void Initialize()
        {
            // Refresh configuration & auth tokens
            configuration = target as WitConfiguration;

            // Get app server token
            _serverToken = WitAuthUtility.GetAppServerToken(configuration);
            if (CanConfigurationRefresh(configuration) && WitConfigurationUtility.IsServerTokenValid(_serverToken))
            {
                // Get client token if needed
                _appID = WitConfigurationUtility.GetAppID(configuration);
                if (string.IsNullOrEmpty(_appID))
                {
                    configuration.SetServerToken(_serverToken);
                }
                // Refresh additional data
                else
                {
                    SafeRefresh();
                }
            }
        }
Esempio n. 9
0
 public static void WitCreateConfiguration()
 {
     WitConfigurationUtility.CreateConfiguration(WitAuthUtility.ServerToken);
 }
Esempio n. 10
0
 protected virtual int CreateConfiguration(string newToken)
 {
     return(WitConfigurationUtility.CreateConfiguration(newToken));
 }
Esempio n. 11
0
        protected virtual void LayoutContent()
        {
            // Begin vertical box
            GUILayout.BeginVertical(EditorStyles.helpBox);

            // Check for app name/id update
            ReloadAppData();

            // Title Foldout
            GUILayout.BeginHorizontal();
            string foldoutText = WitTexts.Texts.ConfigurationHeaderLabel;

            if (!string.IsNullOrEmpty(_appName))
            {
                foldoutText = foldoutText + " - " + _appName;
            }

            _foldout = WitEditorUI.LayoutFoldout(new GUIContent(foldoutText), _foldout);
            // Refresh button
            if (CanConfigurationRefresh(configuration))
            {
                if (string.IsNullOrEmpty(_appName))
                {
                    bool isValid = WitConfigurationUtility.IsServerTokenValid(_serverToken);
                    GUI.enabled = isValid;
                    if (WitEditorUI.LayoutTextButton(WitTexts.Texts.ConfigurationRefreshButtonLabel))
                    {
                        ApplyServerToken(_serverToken);
                    }
                }
                else
                {
                    bool isRefreshing = configuration.IsRefreshingData();
                    GUI.enabled = !isRefreshing;
                    if (WitEditorUI.LayoutTextButton(isRefreshing ? WitTexts.Texts.ConfigurationRefreshingButtonLabel : WitTexts.Texts.ConfigurationRefreshButtonLabel))
                    {
                        SafeRefresh();
                    }
                }
            }
            GUI.enabled = true;
            GUILayout.EndHorizontal();
            GUILayout.Space(WitStyles.ButtonMargin);

            // Show configuration app data
            if (_foldout)
            {
                // Indent
                EditorGUI.indentLevel++;

                // Server access token
                bool updated = false;
                WitEditorUI.LayoutPasswordField(WitTexts.ConfigurationServerTokenContent, ref _serverToken, ref updated);
                if (updated)
                {
                    ApplyServerToken(_serverToken);
                }

                // Additional data
                if (configuration)
                {
                    LayoutConfigurationData();
                }

                // Undent
                EditorGUI.indentLevel--;
            }

            // End vertical box layout
            GUILayout.EndVertical();

            GUILayout.BeginVertical(EditorStyles.helpBox);
            LayoutConduitContent();
            GUILayout.EndVertical();

            // Layout configuration request tabs
            LayoutConfigurationRequestTabs();

            // Additional open wit button
            GUILayout.FlexibleSpace();
            if (GUILayout.Button(OpenButtonLabel, WitStyles.TextButton))
            {
                Application.OpenURL(HeaderUrl);
            }
        }
Esempio n. 12
0
        /// <summary>
        /// Create a new preload settings asset by prompting a save location
        /// </summary>
        public static TTSPreloadSettings CreatePreloadSettings()
        {
            string savePath = WitConfigurationUtility.GetFileSaveDirectory("Save TTS Preload Settings", "TTSPreloadSettings", "asset");

            return(CreatePreloadSettings(savePath));
        }
Esempio n. 13
0
 // Window open
 protected virtual void OnEnable()
 {
     titleContent = Title;
     WitConfigurationUtility.ReloadConfigurationData();
 }