private void ComboVideoAdapter_ItemSelected()
        {
            int adapterIndex = (int)m_comboVideoAdapter.GetSelectedKey();
            { // AddDisplayModesToComboBox
                LoadResolutions(MyVideoSettingsManager.Adapters[adapterIndex]);

                m_comboResolution.ClearItems();

                var displayAspectRatio = MyVideoSettingsManager.GetRecommendedAspectRatio(adapterIndex);
                int resolutionToSelect = 0;
                int counter            = 0;
                for (int i = 0; i < m_resolutions.Count; ++i)
                {
                    var   resolution      = m_resolutions[i];
                    float aspectRatio     = (float)resolution.X / (float)resolution.Y;
                    var   aspectId        = MyVideoSettingsManager.GetClosestAspectRatio(aspectRatio);
                    var   aspectDetails   = MyVideoSettingsManager.GetAspectRatio(aspectId);
                    var   aspectRatioText = aspectDetails.TextShort;
                    var   starsMark       = aspectDetails.IsSupported ? (aspectId == displayAspectRatio.AspectRatioEnum) ? " ***" // recommended
                                                                                                                 : ""             // normal
                                                              : " *";                                                             // unsupported by UI
                    if (resolution.X == m_settingsOld.BackBufferWidth &&
                        resolution.Y == m_settingsOld.BackBufferHeight)
                    {
                        resolutionToSelect = counter;
                    }

                    m_comboResolution.AddItem(counter++, new StringBuilder(
                                                  string.Format("{0} x {1} - {2}{3}", resolution.X, resolution.Y, aspectRatioText, starsMark)));
                }

                m_comboResolution.SelectItemByKey(resolutionToSelect);
            }

            { // UpdateRecommendecAspectRatioLabel
                MyAspectRatio recommendedAspectRatio = MyVideoSettingsManager.GetRecommendedAspectRatio(adapterIndex);
                StringBuilder sb = new StringBuilder();
                sb.AppendFormat(MyTexts.GetString(MyCommonTexts.RecommendedAspectRatio), recommendedAspectRatio.TextShort);
                m_labelRecommendAspectRatio.Text = string.Format("*** {0}", sb);
            }
        }
Exemplo n.º 2
0
        void OnVideoAdapterSelected()
        {
            int adapterIndex = (int)m_videoAdapterCombobox.GetSelectedKey();
            { // AddDisplayModesToComboBox
                m_resolutionCombobox.ClearItems();

                var duplicateFilter = new HashSet <Vector2I>(Vector2I.Comparer);
                foreach (var displayMode in MyVideoSettingsManager.Adapters[adapterIndex].SupportedDisplayModes)
                {
                    duplicateFilter.Add(new Vector2I(displayMode.Width, displayMode.Height));
                }

                m_resolutionsForAdapter.Clear();
                m_resolutionsForAdapter.AddHashset(duplicateFilter);
                m_resolutionsForAdapter.Sort((a, b) =>
                { // Sort by width, then height.
                    if (a.X != b.X)
                    {
                        return(a.X.CompareTo(b.X));
                    }
                    return(a.Y.CompareTo(b.Y));
                });

                // Also show any extra display modes we have (there shouldn't be any on official builds).
                foreach (var mode in MyVideoSettingsManager.DebugDisplayModes)
                {
                    m_resolutionsForAdapter.Add(new Vector2I(mode.Width, mode.Height));
                }

                var displayAspectRatio = MyVideoSettingsManager.GetRecommendedAspectRatio(adapterIndex);
                int resolutionToSelect = 0;
                int counter            = 0;
                for (int i = 0; i < m_resolutionsForAdapter.Count; ++i)
                {
                    var   resolution      = m_resolutionsForAdapter[i];
                    float aspectRatio     = (float)resolution.X / (float)resolution.Y;
                    var   aspectId        = MyVideoSettingsManager.GetClosestAspectRatio(aspectRatio);
                    var   aspectDetails   = MyVideoSettingsManager.GetAspectRatio(aspectId);
                    var   aspectRatioText = aspectDetails.TextShort;
                    var   starsMark       = aspectDetails.IsSupported ? (aspectId == displayAspectRatio.AspectRatioEnum) ? " ***" // recommended
                                                                                                                 : ""             // normal
                                                              : " *";                                                             // unsupported
                    if (resolution.X == m_deviceSettingsOld.BackBufferWidth &&
                        resolution.Y == m_deviceSettingsOld.BackBufferHeight)
                    {
                        resolutionToSelect = counter;
                    }

                    m_resolutionCombobox.AddItem(counter++, new StringBuilder(
                                                     string.Format("{0} x {1} - {2}{3}", resolution.X, resolution.Y, aspectRatioText, starsMark)));
                }

                m_resolutionCombobox.SelectItemByKey(resolutionToSelect);
            }

            { // UpdateRecommendecAspectRatioLabel
                MyAspectRatio recommendedAspectRatio = MyVideoSettingsManager.GetRecommendedAspectRatio(adapterIndex);
                StringBuilder sb = new StringBuilder();
                sb.AppendFormat(MyTexts.GetString(MySpaceTexts.RecommendedAspectRatio), recommendedAspectRatio.TextShort);
                m_recommendAspectRatioLabel.Text = string.Format("*** {0}", sb);
            }
        }