Example #1
0
        private void load(FrameworkConfigManager config, OsuConfigManager osuConfig, OsuGameBase game)
        {
            this.game = game;

            scalingMode      = osuConfig.GetBindable <ScalingMode>(OsuSetting.Scaling);
            sizeFullscreen   = config.GetBindable <Size>(FrameworkSetting.SizeFullscreen);
            scalingSizeX     = osuConfig.GetBindable <float>(OsuSetting.ScalingSizeX);
            scalingSizeY     = osuConfig.GetBindable <float>(OsuSetting.ScalingSizeY);
            scalingPositionX = osuConfig.GetBindable <float>(OsuSetting.ScalingPositionX);
            scalingPositionY = osuConfig.GetBindable <float>(OsuSetting.ScalingPositionY);

            Container resolutionSettingsContainer;

            Children = new Drawable[]
            {
                windowModeDropdown = new SettingsEnumDropdown <WindowMode>
                {
                    LabelText = "Screen mode",
                    Bindable  = config.GetBindable <WindowMode>(FrameworkSetting.WindowMode),
                },
                resolutionSettingsContainer = new Container
                {
                    RelativeSizeAxes = Axes.X,
                    AutoSizeAxes     = Axes.Y
                },
                new SettingsSlider <float, UIScaleSlider>
                {
                    LabelText             = "UI Scaling",
                    TransferValueOnCommit = true,
                    Bindable     = osuConfig.GetBindable <float>(OsuSetting.UIScale),
                    KeyboardStep = 0.01f
                },
                new SettingsEnumDropdown <ScalingMode>
                {
                    LabelText = "Screen Scaling",
                    Bindable  = osuConfig.GetBindable <ScalingMode>(OsuSetting.Scaling),
                },
                scalingSettings = new FillFlowContainer <SettingsSlider <float> >
                {
                    Direction        = FillDirection.Vertical,
                    RelativeSizeAxes = Axes.X,
                    AutoSizeAxes     = Axes.Y,
                    AutoSizeDuration = transition_duration,
                    AutoSizeEasing   = Easing.OutQuint,
                    Masking          = true,
                    Children         = new []
                    {
                        new SettingsSlider <float>
                        {
                            LabelText    = "Horizontal position",
                            Bindable     = scalingPositionX,
                            KeyboardStep = 0.01f
                        },
                        new SettingsSlider <float>
                        {
                            LabelText    = "Vertical position",
                            Bindable     = scalingPositionY,
                            KeyboardStep = 0.01f
                        },
                        new SettingsSlider <float>
                        {
                            LabelText    = "Horizontal scale",
                            Bindable     = scalingSizeX,
                            KeyboardStep = 0.01f
                        },
                        new SettingsSlider <float>
                        {
                            LabelText    = "Vertical scale",
                            Bindable     = scalingSizeY,
                            KeyboardStep = 0.01f
                        },
                    }
                },
            };

            scalingSettings.ForEach(s => bindPreviewEvent(s.Bindable));

            var resolutions = getResolutions();

            if (resolutions.Count > 1)
            {
                resolutionSettingsContainer.Child = resolutionDropdown = new ResolutionSettingsDropdown
                {
                    LabelText             = "Resolution",
                    ShowsDefaultIndicator = false,
                    Items    = resolutions,
                    Bindable = sizeFullscreen
                };

                windowModeDropdown.Bindable.BindValueChanged(windowMode =>
                {
                    if (windowMode == WindowMode.Fullscreen)
                    {
                        resolutionDropdown.Show();
                        sizeFullscreen.TriggerChange();
                    }
                    else
                    {
                        resolutionDropdown.Hide();
                    }
                }, true);
            }

            scalingMode.BindValueChanged(mode =>
            {
                scalingSettings.ClearTransforms();
                scalingSettings.AutoSizeAxes = mode != ScalingMode.Off ? Axes.Y : Axes.None;

                if (mode == ScalingMode.Off)
                {
                    scalingSettings.ResizeHeightTo(0, transition_duration, Easing.OutQuint);
                }

                scalingSettings.ForEach(s => s.TransferValueOnCommit = mode == ScalingMode.Everything);
            }, true);
        }
Example #2
0
        private void load(FrameworkConfigManager config, OsuGameBase game)
        {
            this.game = game;

            letterboxing   = config.GetBindable <bool>(FrameworkSetting.Letterboxing);
            sizeFullscreen = config.GetBindable <Size>(FrameworkSetting.SizeFullscreen);

            Container resolutionSettingsContainer;

            Children = new Drawable[]
            {
                windowModeDropdown = new SettingsEnumDropdown <WindowMode>
                {
                    LabelText = "Screen mode",
                    Bindable  = config.GetBindable <WindowMode>(FrameworkSetting.WindowMode),
                },
                resolutionSettingsContainer = new Container
                {
                    RelativeSizeAxes = Axes.X,
                    AutoSizeAxes     = Axes.Y
                },
                new SettingsCheckbox
                {
                    LabelText = "Letterboxing",
                    Bindable  = letterboxing,
                },
                letterboxSettings = new FillFlowContainer
                {
                    Direction        = FillDirection.Vertical,
                    RelativeSizeAxes = Axes.X,
                    AutoSizeAxes     = Axes.Y,
                    AutoSizeDuration = transition_duration,
                    AutoSizeEasing   = Easing.OutQuint,
                    Masking          = true,

                    Children = new Drawable[]
                    {
                        new SettingsSlider <double>
                        {
                            LabelText    = "Horizontal position",
                            Bindable     = config.GetBindable <double>(FrameworkSetting.LetterboxPositionX),
                            KeyboardStep = 0.01f
                        },
                        new SettingsSlider <double>
                        {
                            LabelText    = "Vertical position",
                            Bindable     = config.GetBindable <double>(FrameworkSetting.LetterboxPositionY),
                            KeyboardStep = 0.01f
                        },
                    }
                },
            };

            var resolutions = getResolutions();

            if (resolutions.Count > 1)
            {
                resolutionSettingsContainer.Child = resolutionDropdown = new SettingsDropdown <Size>
                {
                    LabelText             = "Resolution",
                    ShowsDefaultIndicator = false,
                    Entries  = resolutions,
                    Bindable = sizeFullscreen
                };

                windowModeDropdown.Bindable.BindValueChanged(windowMode =>
                {
                    if (windowMode == WindowMode.Fullscreen)
                    {
                        resolutionDropdown.Show();
                        sizeFullscreen.TriggerChange();
                    }
                    else
                    {
                        resolutionDropdown.Hide();
                    }
                }, true);
            }

            letterboxing.BindValueChanged(isVisible =>
            {
                letterboxSettings.ClearTransforms();
                letterboxSettings.AutoSizeAxes = isVisible ? Axes.Y : Axes.None;

                if (!isVisible)
                {
                    letterboxSettings.ResizeHeightTo(0, transition_duration, Easing.OutQuint);
                }
            }, true);
        }
Example #3
0
        private void load(FrameworkConfigManager config, OsuConfigManager osuConfig, GameHost host)
        {
            scalingMode      = osuConfig.GetBindable <ScalingMode>(OsuSetting.Scaling);
            sizeFullscreen   = config.GetBindable <Size>(FrameworkSetting.SizeFullscreen);
            scalingSizeX     = osuConfig.GetBindable <float>(OsuSetting.ScalingSizeX);
            scalingSizeY     = osuConfig.GetBindable <float>(OsuSetting.ScalingSizeY);
            scalingPositionX = osuConfig.GetBindable <float>(OsuSetting.ScalingPositionX);
            scalingPositionY = osuConfig.GetBindable <float>(OsuSetting.ScalingPositionY);

            if (host.Window != null)
            {
                currentDisplay.BindTo(host.Window.CurrentDisplayBindable);
                windowModes.BindTo(host.Window.SupportedWindowModes);
            }

            Children = new Drawable[]
            {
                windowModeDropdown = new SettingsDropdown <WindowMode>
                {
                    LabelText  = "Screen mode",
                    ItemSource = windowModes,
                    Current    = config.GetBindable <WindowMode>(FrameworkSetting.WindowMode),
                },
                resolutionDropdown = new ResolutionSettingsDropdown
                {
                    LabelText             = "Resolution",
                    ShowsDefaultIndicator = false,
                    ItemSource            = resolutions,
                    Current = sizeFullscreen
                },
                new SettingsSlider <float, UIScaleSlider>
                {
                    LabelText             = "UI Scaling",
                    TransferValueOnCommit = true,
                    Current      = osuConfig.GetBindable <float>(OsuSetting.UIScale),
                    KeyboardStep = 0.01f,
                    Keywords     = new[] { "scale", "letterbox" },
                },
                new SettingsEnumDropdown <ScalingMode>
                {
                    LabelText = "Screen Scaling",
                    Current   = osuConfig.GetBindable <ScalingMode>(OsuSetting.Scaling),
                    Keywords  = new[] { "scale", "letterbox" },
                },
                scalingSettings = new FillFlowContainer <SettingsSlider <float> >
                {
                    Direction        = FillDirection.Vertical,
                    RelativeSizeAxes = Axes.X,
                    AutoSizeAxes     = Axes.Y,
                    AutoSizeDuration = transition_duration,
                    AutoSizeEasing   = Easing.OutQuint,
                    Masking          = true,
                    Children         = new[]
                    {
                        new SettingsSlider <float>
                        {
                            LabelText           = "Horizontal position",
                            Current             = scalingPositionX,
                            KeyboardStep        = 0.01f,
                            DisplayAsPercentage = true
                        },
                        new SettingsSlider <float>
                        {
                            LabelText           = "Vertical position",
                            Current             = scalingPositionY,
                            KeyboardStep        = 0.01f,
                            DisplayAsPercentage = true
                        },
                        new SettingsSlider <float>
                        {
                            LabelText           = "Horizontal scale",
                            Current             = scalingSizeX,
                            KeyboardStep        = 0.01f,
                            DisplayAsPercentage = true
                        },
                        new SettingsSlider <float>
                        {
                            LabelText           = "Vertical scale",
                            Current             = scalingSizeY,
                            KeyboardStep        = 0.01f,
                            DisplayAsPercentage = true
                        },
                    }
                },
            };

            windowModes.BindCollectionChanged((sender, args) =>
            {
                if (windowModes.Count > 1)
                {
                    windowModeDropdown.Show();
                }
                else
                {
                    windowModeDropdown.Hide();
                }
            }, true);

            windowModeDropdown.Current.ValueChanged += _ => updateResolutionDropdown();

            currentDisplay.BindValueChanged(display => Schedule(() =>
            {
                resolutions.RemoveRange(1, resolutions.Count - 1);

                if (display.NewValue != null)
                {
                    resolutions.AddRange(display.NewValue.DisplayModes
                                         .Where(m => m.Size.Width >= 800 && m.Size.Height >= 600)
                                         .OrderByDescending(m => Math.Max(m.Size.Height, m.Size.Width))
                                         .Select(m => m.Size)
                                         .Distinct());
                }

                updateResolutionDropdown();
            }), true);

            scalingSettings.ForEach(s => bindPreviewEvent(s.Current));

            scalingMode.BindValueChanged(mode =>
            {
                scalingSettings.ClearTransforms();
                scalingSettings.AutoSizeAxes = mode.NewValue != ScalingMode.Off ? Axes.Y : Axes.None;

                if (mode.NewValue == ScalingMode.Off)
                {
                    scalingSettings.ResizeHeightTo(0, transition_duration, Easing.OutQuint);
                }

                scalingSettings.ForEach(s => s.TransferValueOnCommit = mode.NewValue == ScalingMode.Everything);
            }, true);

            void updateResolutionDropdown()
            {
                if (resolutions.Count > 1 && windowModeDropdown.Current.Value == WindowMode.Fullscreen)
                {
                    resolutionDropdown.Show();
                }
                else
                {
                    resolutionDropdown.Hide();
                }
            }
        }
Example #4
0
        private void load(FrameworkConfigManager config, OsuConfigManager osuConfig, GameHost host)
        {
            scalingMode      = osuConfig.GetBindable <ScalingMode>(OsuSetting.Scaling);
            sizeFullscreen   = config.GetBindable <Size>(FrameworkSetting.SizeFullscreen);
            scalingSizeX     = osuConfig.GetBindable <float>(OsuSetting.ScalingSizeX);
            scalingSizeY     = osuConfig.GetBindable <float>(OsuSetting.ScalingSizeY);
            scalingPositionX = osuConfig.GetBindable <float>(OsuSetting.ScalingPositionX);
            scalingPositionY = osuConfig.GetBindable <float>(OsuSetting.ScalingPositionY);

            if (host.Window != null)
            {
                windowModes.BindTo(host.Window.SupportedWindowModes);
            }

            Container resolutionSettingsContainer;

            Children = new Drawable[]
            {
                windowModeDropdown = new SettingsDropdown <WindowMode>
                {
                    LabelText  = "Screen mode",
                    Current    = config.GetBindable <WindowMode>(FrameworkSetting.WindowMode),
                    ItemSource = windowModes,
                },
                resolutionSettingsContainer = new Container
                {
                    RelativeSizeAxes = Axes.X,
                    AutoSizeAxes     = Axes.Y
                },
                new SettingsSlider <float, UIScaleSlider>
                {
                    LabelText             = "UI Scaling",
                    TransferValueOnCommit = true,
                    Current      = osuConfig.GetBindable <float>(OsuSetting.UIScale),
                    KeyboardStep = 0.01f,
                    Keywords     = new[] { "scale", "letterbox" },
                },
                new SettingsEnumDropdown <ScalingMode>
                {
                    LabelText = "Screen Scaling",
                    Current   = osuConfig.GetBindable <ScalingMode>(OsuSetting.Scaling),
                    Keywords  = new[] { "scale", "letterbox" },
                },
                scalingSettings = new FillFlowContainer <SettingsSlider <float> >
                {
                    Direction        = FillDirection.Vertical,
                    RelativeSizeAxes = Axes.X,
                    AutoSizeAxes     = Axes.Y,
                    AutoSizeDuration = transition_duration,
                    AutoSizeEasing   = Easing.OutQuint,
                    Masking          = true,
                    Children         = new[]
                    {
                        new SettingsSlider <float>
                        {
                            LabelText           = "Horizontal position",
                            Current             = scalingPositionX,
                            KeyboardStep        = 0.01f,
                            DisplayAsPercentage = true
                        },
                        new SettingsSlider <float>
                        {
                            LabelText           = "Vertical position",
                            Current             = scalingPositionY,
                            KeyboardStep        = 0.01f,
                            DisplayAsPercentage = true
                        },
                        new SettingsSlider <float>
                        {
                            LabelText           = "Horizontal scale",
                            Current             = scalingSizeX,
                            KeyboardStep        = 0.01f,
                            DisplayAsPercentage = true
                        },
                        new SettingsSlider <float>
                        {
                            LabelText           = "Vertical scale",
                            Current             = scalingSizeY,
                            KeyboardStep        = 0.01f,
                            DisplayAsPercentage = true
                        },
                    }
                },
            };

            scalingSettings.ForEach(s => bindPreviewEvent(s.Current));

            var resolutions = getResolutions();

            if (resolutions.Count > 1)
            {
                resolutionSettingsContainer.Child = resolutionDropdown = new ResolutionSettingsDropdown
                {
                    LabelText             = "Resolution",
                    ShowsDefaultIndicator = false,
                    Items   = resolutions,
                    Current = sizeFullscreen
                };

                windowModeDropdown.Current.BindValueChanged(mode =>
                {
                    if (mode.NewValue == WindowMode.Fullscreen)
                    {
                        resolutionDropdown.Show();
                        sizeFullscreen.TriggerChange();
                    }
                    else
                    {
                        resolutionDropdown.Hide();
                    }
                }, true);
            }

            scalingMode.BindValueChanged(mode =>
            {
                scalingSettings.ClearTransforms();
                scalingSettings.AutoSizeAxes = mode.NewValue != ScalingMode.Off ? Axes.Y : Axes.None;

                if (mode.NewValue == ScalingMode.Off)
                {
                    scalingSettings.ResizeHeightTo(0, transition_duration, Easing.OutQuint);
                }

                scalingSettings.ForEach(s => s.TransferValueOnCommit = mode.NewValue == ScalingMode.Everything);
            }, true);

            windowModes.CollectionChanged += (sender, args) => windowModesChanged();

            windowModesChanged();
        }