예제 #1
0
        /// <summary>Clear and populate the resolution dropdown</summary>
        private void PopulateDropdownResolution()
        {
            dropdownResolution.ClearOptions();
            screenResolutionsCurrent.Clear();
            List <string> options = new List <string>();

            // Add allowed resolutions to screenResolutionsCurrent
            foreach (ScreenResolution screenResolution in screenResolutionsTotal)
            {
                // Continue if windowed and resolution is too large
                if (!fullscreen && (screenResolution.Width > nativeResolution.Width * maxWindowedResolutionRatio || screenResolution.Height > nativeResolution.Height * maxWindowedResolutionRatio))
                {
                    continue;
                }

                screenResolutionsCurrent.Add(screenResolution);
            }

            // Clamp resolution to the largest of screenResolutionsCurrent
            if (!fullscreen && (currentScreenResolution.Width > nativeResolution.Width * maxWindowedResolutionRatio || currentScreenResolution.Height > nativeResolution.Height * maxWindowedResolutionRatio) && screenResolutionsCurrent.Count > 0)
            {
                currentScreenResolution = screenResolutionsCurrent[screenResolutionsCurrent.Count - 1];
            }

            // Add current resolution to screenResolutionsCurrent
            screenResolutionsCurrent.Insert(0, currentScreenResolution);

            // Add screenResolutions to options
            foreach (ScreenResolution screenResolution in screenResolutionsCurrent)
            {
                options.Add(screenResolution.ToString());
            }

            dropdownResolution.AddOptions(options);
            dropdownResolution.SetValueWithoutNotify(0);
        }