void SetRegionOption(RegionUtils.Provider provider)
        {
            EnvironmentInfo environmentInfo = LocaleUtils.GetEnvironmentInfo();

            environmentInfo.provider         = provider;
            environmentInfo.cloudEnvironment = CloudEnvironment.Production;
            Dispatcher.Dispatch(SetLoginSettingActions <EnvironmentInfo> .From(environmentInfo));

            SetActiveRegionPopup(false);
        }
        void OnCloudOKButtonClicked()
        {
            SetActiveCloudPopup(false);

            var optionItemButton = m_CloudButtons.FirstOrDefault(e => e.selected);

            if (optionItemButton == null)
            {
                return;
            }

            // if set to Default, remove player pref
            if (optionItemButton.cloudOption == CloudOption.Default)
            {
                Dispatcher.Dispatch(DeleteCloudEnvironmentSetting <EnvironmentInfo> .From(true));
                Dispatcher.Dispatch(DeleteCloudEnvironmentSetting <EnvironmentInfo> .From(false));
                return;
            }

            EnvironmentInfo environmentInfo = LocaleUtils.GetEnvironmentInfo();

            environmentInfo.cloudEnvironment = CloudEnvironment.Production;

            switch (optionItemButton.cloudOption)
            {
            case CloudOption.Production:
                environmentInfo.cloudEnvironment = CloudEnvironment.Production;
                break;

            case CloudOption.Local:
                environmentInfo.cloudEnvironment = CloudEnvironment.Local;
                break;

            case CloudOption.Staging:
                environmentInfo.cloudEnvironment = CloudEnvironment.Staging;
                break;

            case CloudOption.Test:
                environmentInfo.cloudEnvironment = CloudEnvironment.Test;
                break;

            case CloudOption.Other:
                environmentInfo.cloudEnvironment = CloudEnvironment.Other;
                break;
            }

            environmentInfo.customUrl = m_CloudURLInput.text;

            Dispatcher.Dispatch(SetLoginSettingActions <EnvironmentInfo> .From(environmentInfo));
        }
        void OnSessionStateDataChanged(UISessionStateData data)
        {
            if (m_LoginState != data.sessionState.loggedState)
            {
                switch (data.sessionState.loggedState)
                {
                case LoginState.LoggedIn:
                    m_NoProjectPanel.SetActive(false);
                    m_FetchingProjectsPanel.SetActive(true);
                    break;

                case LoginState.LoggedOut:
                    ClearProjectListItem();
                    m_NoProjectPanel.SetActive(false);
                    m_FetchingProjectsPanel.SetActive(false);
                    break;

                case LoginState.LoggingIn:
                case LoginState.LoggingOut:
                    // todo put spinner
                    break;
                }

                m_LoginState = data.sessionState.loggedState;
            }

            if (m_LoginState == LoginState.LoggedIn)
            {
                // Display Cloud environment debug info when it's not "Production"
                var environmentInfo = LocaleUtils.GetEnvironmentInfo();
                if (environmentInfo.cloudEnvironment != CloudEnvironment.Production)
                {
                    m_CloudSettingDebugInfo.gameObject.SetActive(true);

                    if (environmentInfo.cloudEnvironment == CloudEnvironment.Other)
                    {
                        if (PlayerPrefs.HasKey(LocaleUtils.SettingsKeys.CloudEnvironment))
                        {
                            m_CloudSettingDebugInfo.text = $"Environment: {environmentInfo.customUrl}";
                        }
                        else
                        {
                            m_CloudSettingDebugInfo.text =
                                $"Environment: {ProjectServerClient.ProjectServerAddress(environmentInfo.provider)}";
                        }
                    }
                    else
                    {
                        m_CloudSettingDebugInfo.text = $"Environment: {environmentInfo.cloudEnvironment}";
                    }
                }
                else
                {
                    m_CloudSettingDebugInfo.gameObject.SetActive(false);
                }

                UpdateProjectItems(data.sessionState.rooms);

                if (m_Rooms != data.sessionState.rooms || !EnumerableExtension.SafeSequenceEquals(m_Rooms, data.sessionState.rooms))
                {
                    m_Rooms = data.sessionState.rooms;
                }
                else if (HasNoProjectsAvailable())
                {
                    m_NoProjectPanel.SetActive(true);
                    m_FetchingProjectsPanel.SetActive(false);
                }
            }
        }
        void UpdateSettings()
        {
            var environmentInfo = LocaleUtils.GetEnvironmentInfo();

            RegionOption regionOption = RegionOption.None;

            switch (environmentInfo.provider)
            {
            case RegionUtils.Provider.GCP:
                regionOption = RegionOption.Default;
                break;

            case RegionUtils.Provider.Tencent:
                regionOption = RegionOption.China;
                break;
            }

            OptionItemButton selectedButton = null;

            foreach (var button in m_RegionButtons)
            {
                button.SelectButton(button.regionOption == regionOption);
                if (button.regionOption == regionOption)
                {
                    selectedButton = button;
                }
            }

            if (selectedButton != null)
            {
                m_RegionText.text = $"Region: {selectedButton.label.text}";
            }

            CloudOption cloudOption = CloudOption.Default;

            if (PlayerPrefs.HasKey(LocaleUtils.SettingsKeys.CloudEnvironment))
            {
                switch (environmentInfo.cloudEnvironment)
                {
                case CloudEnvironment.Other:
                    cloudOption = CloudOption.Other;
                    break;

                case CloudEnvironment.Local:
                    cloudOption = CloudOption.Local;
                    break;

                case CloudEnvironment.Test:
                    cloudOption = CloudOption.Test;
                    break;

                case CloudEnvironment.Staging:
                    cloudOption = CloudOption.Staging;
                    break;

                case CloudEnvironment.Production:
                    cloudOption = CloudOption.Production;
                    break;
                }
            }

            m_CloudOtherSelected = cloudOption == CloudOption.Other;
            EnableCustomInput(m_CloudOtherSelected);
            m_CloudURLInput.text = environmentInfo.customUrl;

            foreach (var button in m_CloudButtons)
            {
                button.SelectButton(button.cloudOption == cloudOption);
            }

            if (environmentInfo.cloudEnvironment != CloudEnvironment.Production)
            {
                m_CloudSettingDebugInfo.gameObject.SetActive(true);

                if (environmentInfo.cloudEnvironment == CloudEnvironment.Other)
                {
                    if (PlayerPrefs.HasKey(LocaleUtils.SettingsKeys.CloudEnvironment))
                    {
                        m_CloudSettingDebugInfo.text = $"Environment: {environmentInfo.customUrl}";
                    }
                    else
                    {
                        m_CloudSettingDebugInfo.text =
                            $"Environment: {ProjectServerClient.ProjectServerAddress(environmentInfo.provider, Protocol.Http)}";
                    }
                }
                else
                {
                    m_CloudSettingDebugInfo.text = $"Environment: {environmentInfo.cloudEnvironment}";
                }
            }
            else
            {
                m_CloudSettingDebugInfo.gameObject.SetActive(false);
            }
        }
Exemple #5
0
        void OnLoggedStateDataChanged(LoginState newData)
        {
            if (m_LoginState != newData)
            {
                switch (newData)
                {
                case LoginState.ProcessingToken:
                    ClearProjectListItem();
                    m_NoProjectPanel.SetActive(false);
                    m_FetchingProjectsPanel.SetActive(false);
                    break;

                case LoginState.LoggingIn:
                    m_NoProjectPanel.SetActive(false);
                    m_FetchingProjectsPanel.SetActive(false);
                    break;

                case LoginState.LoggedIn:
                    m_NoProjectPanel.SetActive(false);
                    m_FetchingProjectsPanel.SetActive(true);
                    break;

                case LoginState.LoggedOut:
                    ClearProjectListItem();
                    m_NoProjectPanel.SetActive(false);
                    m_FetchingProjectsPanel.SetActive(false);
                    break;

                case LoginState.LoggingOut:
                    // todo put spinner
                    break;
                }

                m_LoginState = newData;
            }

            if (m_LoginState == LoginState.LoggedIn)
            {
                // Display Cloud environment debug info when it's not "Production"
                var environmentInfo = LocaleUtils.GetEnvironmentInfo();
                if (environmentInfo.cloudEnvironment != CloudEnvironment.Production)
                {
                    m_CloudSettingDebugInfo.gameObject.SetActive(true);

                    if (environmentInfo.cloudEnvironment == CloudEnvironment.Other)
                    {
                        if (PlayerPrefs.HasKey(LocaleUtils.SettingsKeys.CloudEnvironment))
                        {
                            m_CloudSettingDebugInfo.text = $"Environment: {environmentInfo.customUrl}";
                        }
                        else
                        {
                            m_CloudSettingDebugInfo.text =
                                $"Environment: {ProjectServerClient.ProjectServerAddress(environmentInfo.provider, Protocol.Http)}";
                        }
                    }
                    else
                    {
                        m_CloudSettingDebugInfo.text = $"Environment: {environmentInfo.cloudEnvironment}";
                    }
                }
                else
                {
                    m_CloudSettingDebugInfo.gameObject.SetActive(false);
                }
            }
        }