Example #1
0
    public override IEnumerator PerformFirstPass()
    {
        CustomGraphicsService customGraphicsService = new CustomGraphicsService();

        customGraphicsService.Init();
        Service.Set(customGraphicsService);
        GameObject gameObject = Service.Get <GameObject>();

        gameObject.AddComponent <WindowResizeService>();
        string tier = Screen.width + "x" + Screen.height;

        Service.Get <ICPSwrveService>().Action("desktop_display_settings", "start_resolution", tier);
        yield break;
    }
        private void Start()
        {
            SetTogglesInteractable(true, antiAliasingToggle, cameraPostToggle);
            customGraphicsService   = Service.Get <CustomGraphicsService>();
            displayedResolutionsMap = new Dictionary <int, Resolution>();
            initialWidth            = Screen.width;
            initialHeight           = Screen.height;
            QualityLevel qualityLevel  = customGraphicsService.LodPenguinQualityLevel;
            QualityLevel qualityLevel2 = customGraphicsService.GraphicsLevel;
            int          num           = customGraphicsService.AntiAliasLevel;
            bool         isOn          = customGraphicsService.CameraPostEnabled;

            graphicsQualityToggleHigh.isOn     = qualityLevel2 == QualityLevel.High;
            graphicsQualityToggleMedium.isOn   = qualityLevel2 == QualityLevel.Medium;
            graphicsQualityToggleLow.isOn      = qualityLevel2 == QualityLevel.Low;
            lodPenguinQualityToggleHigh.isOn   = qualityLevel == QualityLevel.High;
            lodPenguinQualityToggleMedium.isOn = qualityLevel == QualityLevel.Medium;
            lodPenguinQualityToggleLow.isOn    = qualityLevel == QualityLevel.Low;
            antiAliasingToggle.isOn            = num > 0;
            cameraPostToggle.isOn = isOn;
            SetTogglesInteractable(!graphicsQualityToggleLow.isOn, antiAliasingToggle);
            SetTogglesInteractable(graphicsQualityToggleHigh.isOn, cameraPostToggle);
            localizer = Service.Get <Localizer>();
            Localizer obj = localizer;

            obj.TokensUpdated = (Localizer.TokensUpdatedDelegate)Delegate.Combine(obj.TokensUpdated, new Localizer.TokensUpdatedDelegate(LocalizeDisplayModeMenu));
            LocalizeDisplayModeMenu();
            SetDisplayModeValueFromSettings();
            aspectRatioMenu.ClearOptions();
            List <string> list = new List <string>();

            foreach (KeyValuePair <string, float> supportedAspectRatio in customGraphicsService.SupportedAspectRatios)
            {
                if (anyResolutionMatchesAspectRatio(Screen.resolutions, supportedAspectRatio.Value))
                {
                    list.Add(supportedAspectRatio.Key);
                }
            }
            if (list.Count <= 0)
            {
                foreach (KeyValuePair <string, float> supportedAspectRatio2 in customGraphicsService.SupportedAspectRatios)
                {
                    list.Add(supportedAspectRatio2.Key);
                }
            }
            aspectRatioMenu.AddOptions(list);
            for (int i = 0; i < aspectRatioMenu.options.Count; i++)
            {
                Dropdown.OptionData optionData = aspectRatioMenu.options[i];
                if (optionData.text == CustomGraphicsService.AspectAlias)
                {
                    aspectRatioMenu.value = i;
                }
            }
            aspectRatioMenu.onValueChanged.AddListener(onAspectRatioChanged);
            filterResolutionOptions(Screen.fullScreen);
            string text = nearestFormattedResolution(Screen.width, Screen.height);

            for (int i = 0; i < resolutionsMenu.options.Count; i++)
            {
                Dropdown.OptionData optionData = resolutionsMenu.options[i];
                if (optionData.text == text)
                {
                    resolutionsMenu.value = i;
                }
            }
            resolutionsMenu.onValueChanged.AddListener(onResolutionChanged);
            isInitialized = true;
        }