2019-01-24 16:43:03 +08:00
|
|
|
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
|
|
|
|
// See the LICENCE file in the repository root for full licence text.
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2020-12-22 16:36:56 +08:00
|
|
|
|
using System;
|
2022-10-04 05:52:04 +08:00
|
|
|
|
using System.Collections.Generic;
|
2018-06-10 21:17:57 +08:00
|
|
|
|
using System.Drawing;
|
2018-06-03 02:02:45 +08:00
|
|
|
|
using System.Linq;
|
2022-06-03 15:23:38 +08:00
|
|
|
|
using osu.Framework;
|
2016-11-11 06:40:42 +08:00
|
|
|
|
using osu.Framework.Allocation;
|
2019-02-21 18:04:31 +08:00
|
|
|
|
using osu.Framework.Bindables;
|
2016-11-30 23:32:07 +08:00
|
|
|
|
using osu.Framework.Configuration;
|
2019-01-08 12:48:38 +08:00
|
|
|
|
using osu.Framework.Extensions.IEnumerableExtensions;
|
2016-11-09 11:38:40 +08:00
|
|
|
|
using osu.Framework.Graphics;
|
2017-05-23 17:09:32 +08:00
|
|
|
|
using osu.Framework.Graphics.Containers;
|
2019-01-04 14:28:35 +08:00
|
|
|
|
using osu.Framework.Graphics.Shapes;
|
2021-02-22 16:14:00 +08:00
|
|
|
|
using osu.Framework.Localisation;
|
2019-02-28 19:19:51 +08:00
|
|
|
|
using osu.Framework.Platform;
|
2022-05-26 17:37:04 +08:00
|
|
|
|
using osu.Framework.Platform.Windows;
|
2019-01-04 12:29:37 +08:00
|
|
|
|
using osu.Game.Configuration;
|
2019-01-04 14:28:35 +08:00
|
|
|
|
using osu.Game.Graphics.Containers;
|
2018-11-14 17:02:38 +08:00
|
|
|
|
using osu.Game.Graphics.UserInterface;
|
2021-08-11 16:48:37 +08:00
|
|
|
|
using osu.Game.Localisation;
|
2022-10-28 12:52:45 +08:00
|
|
|
|
using osuTK;
|
2019-01-04 14:28:35 +08:00
|
|
|
|
using osuTK.Graphics;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2017-05-15 09:55:29 +08:00
|
|
|
|
namespace osu.Game.Overlays.Settings.Sections.Graphics
|
2016-11-12 18:44:16 +08:00
|
|
|
|
{
|
2017-05-15 09:55:29 +08:00
|
|
|
|
public class LayoutSettings : SettingsSubsection
|
2016-11-12 18:44:16 +08:00
|
|
|
|
{
|
2021-08-11 16:48:37 +08:00
|
|
|
|
protected override LocalisableString Header => GraphicsSettingsStrings.LayoutHeader;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2022-10-04 05:23:02 +08:00
|
|
|
|
private FillFlowContainer<SettingsSlider<float>> scalingSettings = null!;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2022-03-02 17:29:07 +08:00
|
|
|
|
private readonly Bindable<Display> currentDisplay = new Bindable<Display>();
|
2020-12-22 13:02:15 +08:00
|
|
|
|
private readonly IBindableList<WindowMode> windowModes = new BindableList<WindowMode>();
|
|
|
|
|
|
2022-10-04 05:23:02 +08:00
|
|
|
|
private Bindable<ScalingMode> scalingMode = null!;
|
|
|
|
|
private Bindable<Size> sizeFullscreen = null!;
|
2020-12-22 13:02:15 +08:00
|
|
|
|
|
|
|
|
|
private readonly BindableList<Size> resolutions = new BindableList<Size>(new[] { new Size(9999, 9999) });
|
2022-05-26 17:37:04 +08:00
|
|
|
|
private readonly IBindable<FullscreenCapability> fullscreenCapability = new Bindable<FullscreenCapability>(FullscreenCapability.Capable);
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2020-02-14 21:14:00 +08:00
|
|
|
|
[Resolved]
|
2022-10-04 05:23:02 +08:00
|
|
|
|
private OsuGameBase game { get; set; } = null!;
|
2020-02-14 21:14:00 +08:00
|
|
|
|
|
2022-05-26 17:37:04 +08:00
|
|
|
|
[Resolved]
|
2022-10-04 05:23:02 +08:00
|
|
|
|
private GameHost host { get; set; } = null!;
|
2022-05-26 17:37:04 +08:00
|
|
|
|
|
2022-10-04 05:52:04 +08:00
|
|
|
|
private IWindow? window;
|
|
|
|
|
|
2022-10-04 05:23:02 +08:00
|
|
|
|
private SettingsDropdown<Size> resolutionDropdown = null!;
|
|
|
|
|
private SettingsDropdown<Display> displayDropdown = null!;
|
|
|
|
|
private SettingsDropdown<WindowMode> windowModeDropdown = null!;
|
2022-10-28 12:52:45 +08:00
|
|
|
|
private SettingsCheckbox safeAreaConsiderationsCheckbox = null!;
|
2018-06-03 02:02:45 +08:00
|
|
|
|
|
2022-10-04 05:23:02 +08:00
|
|
|
|
private Bindable<float> scalingPositionX = null!;
|
|
|
|
|
private Bindable<float> scalingPositionY = null!;
|
|
|
|
|
private Bindable<float> scalingSizeX = null!;
|
|
|
|
|
private Bindable<float> scalingSizeY = null!;
|
2019-01-04 13:55:59 +08:00
|
|
|
|
|
2017-05-23 19:32:45 +08:00
|
|
|
|
private const int transition_duration = 400;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2016-11-12 18:44:16 +08:00
|
|
|
|
[BackgroundDependencyLoader]
|
2020-02-14 21:14:00 +08:00
|
|
|
|
private void load(FrameworkConfigManager config, OsuConfigManager osuConfig, GameHost host)
|
2016-11-09 11:38:40 +08:00
|
|
|
|
{
|
2022-10-04 05:52:04 +08:00
|
|
|
|
window = host.Window;
|
|
|
|
|
|
2019-01-04 12:29:37 +08:00
|
|
|
|
scalingMode = osuConfig.GetBindable<ScalingMode>(OsuSetting.Scaling);
|
2018-06-10 21:17:57 +08:00
|
|
|
|
sizeFullscreen = config.GetBindable<Size>(FrameworkSetting.SizeFullscreen);
|
2019-01-04 13:55:59 +08:00
|
|
|
|
scalingSizeX = osuConfig.GetBindable<float>(OsuSetting.ScalingSizeX);
|
|
|
|
|
scalingSizeY = osuConfig.GetBindable<float>(OsuSetting.ScalingSizeY);
|
|
|
|
|
scalingPositionX = osuConfig.GetBindable<float>(OsuSetting.ScalingPositionX);
|
|
|
|
|
scalingPositionY = osuConfig.GetBindable<float>(OsuSetting.ScalingPositionY);
|
2018-06-10 21:17:57 +08:00
|
|
|
|
|
2022-10-04 05:52:04 +08:00
|
|
|
|
if (window != null)
|
2020-12-22 13:02:15 +08:00
|
|
|
|
{
|
2022-10-04 05:52:04 +08:00
|
|
|
|
currentDisplay.BindTo(window.CurrentDisplayBindable);
|
|
|
|
|
windowModes.BindTo(window.SupportedWindowModes);
|
|
|
|
|
window.DisplaysChanged += onDisplaysChanged;
|
2020-12-22 13:02:15 +08:00
|
|
|
|
}
|
2018-09-19 16:52:35 +08:00
|
|
|
|
|
2022-09-22 20:01:23 +08:00
|
|
|
|
if (host.Renderer is IWindowsRenderer windowsRenderer)
|
|
|
|
|
fullscreenCapability.BindTo(windowsRenderer.FullscreenCapability);
|
2022-05-26 17:37:04 +08:00
|
|
|
|
|
2016-11-11 06:40:42 +08:00
|
|
|
|
Children = new Drawable[]
|
2016-11-09 11:38:40 +08:00
|
|
|
|
{
|
2019-02-28 19:19:51 +08:00
|
|
|
|
windowModeDropdown = new SettingsDropdown<WindowMode>
|
2016-11-11 06:40:42 +08:00
|
|
|
|
{
|
2021-08-11 16:48:37 +08:00
|
|
|
|
LabelText = GraphicsSettingsStrings.ScreenMode,
|
2019-02-28 20:38:55 +08:00
|
|
|
|
ItemSource = windowModes,
|
2020-10-06 16:18:41 +08:00
|
|
|
|
Current = config.GetBindable<WindowMode>(FrameworkSetting.WindowMode),
|
2016-11-11 06:40:42 +08:00
|
|
|
|
},
|
2022-03-02 17:29:07 +08:00
|
|
|
|
displayDropdown = new DisplaySettingsDropdown
|
|
|
|
|
{
|
|
|
|
|
LabelText = GraphicsSettingsStrings.Display,
|
2022-10-04 05:52:04 +08:00
|
|
|
|
Items = window?.Displays,
|
2022-03-02 17:29:07 +08:00
|
|
|
|
Current = currentDisplay,
|
|
|
|
|
},
|
2020-12-22 13:02:15 +08:00
|
|
|
|
resolutionDropdown = new ResolutionSettingsDropdown
|
2018-06-03 02:02:45 +08:00
|
|
|
|
{
|
2021-08-11 16:48:37 +08:00
|
|
|
|
LabelText = GraphicsSettingsStrings.Resolution,
|
2020-12-22 13:02:15 +08:00
|
|
|
|
ShowsDefaultIndicator = false,
|
|
|
|
|
ItemSource = resolutions,
|
|
|
|
|
Current = sizeFullscreen
|
2018-06-03 02:02:45 +08:00
|
|
|
|
},
|
2022-10-28 12:52:45 +08:00
|
|
|
|
safeAreaConsiderationsCheckbox = new SettingsCheckbox
|
|
|
|
|
{
|
|
|
|
|
LabelText = "Shrink game to avoid cameras and notches",
|
|
|
|
|
Current = osuConfig.GetBindable<bool>(OsuSetting.SafeAreaConsiderations),
|
|
|
|
|
},
|
2019-01-09 18:01:33 +08:00
|
|
|
|
new SettingsSlider<float, UIScaleSlider>
|
|
|
|
|
{
|
2021-08-11 16:48:37 +08:00
|
|
|
|
LabelText = GraphicsSettingsStrings.UIScaling,
|
2019-01-09 18:01:33 +08:00
|
|
|
|
TransferValueOnCommit = true,
|
2020-10-06 16:18:41 +08:00
|
|
|
|
Current = osuConfig.GetBindable<float>(OsuSetting.UIScale),
|
2019-11-21 00:27:34 +08:00
|
|
|
|
KeyboardStep = 0.01f,
|
2019-11-21 21:35:15 +08:00
|
|
|
|
Keywords = new[] { "scale", "letterbox" },
|
2019-01-09 18:01:33 +08:00
|
|
|
|
},
|
2019-01-04 12:29:37 +08:00
|
|
|
|
new SettingsEnumDropdown<ScalingMode>
|
2016-11-11 06:40:42 +08:00
|
|
|
|
{
|
2021-08-11 16:48:37 +08:00
|
|
|
|
LabelText = GraphicsSettingsStrings.ScreenScaling,
|
2020-10-06 16:18:41 +08:00
|
|
|
|
Current = osuConfig.GetBindable<ScalingMode>(OsuSetting.Scaling),
|
2019-11-21 21:35:15 +08:00
|
|
|
|
Keywords = new[] { "scale", "letterbox" },
|
2016-11-11 06:40:42 +08:00
|
|
|
|
},
|
2019-01-08 12:48:38 +08:00
|
|
|
|
scalingSettings = new FillFlowContainer<SettingsSlider<float>>
|
2016-11-30 23:32:07 +08:00
|
|
|
|
{
|
2017-05-23 17:09:32 +08:00
|
|
|
|
Direction = FillDirection.Vertical,
|
|
|
|
|
RelativeSizeAxes = Axes.X,
|
2017-05-23 19:32:45 +08:00
|
|
|
|
AutoSizeAxes = Axes.Y,
|
2017-05-23 17:09:32 +08:00
|
|
|
|
Masking = true,
|
2019-02-28 12:31:40 +08:00
|
|
|
|
Children = new[]
|
2017-05-23 17:09:32 +08:00
|
|
|
|
{
|
2019-01-04 12:29:37 +08:00
|
|
|
|
new SettingsSlider<float>
|
2017-05-23 17:09:32 +08:00
|
|
|
|
{
|
2021-08-11 16:48:37 +08:00
|
|
|
|
LabelText = GraphicsSettingsStrings.HorizontalPosition,
|
2020-10-06 16:18:41 +08:00
|
|
|
|
Current = scalingPositionX,
|
2020-01-28 12:32:30 +08:00
|
|
|
|
KeyboardStep = 0.01f,
|
|
|
|
|
DisplayAsPercentage = true
|
2017-05-23 17:09:32 +08:00
|
|
|
|
},
|
2019-01-04 12:29:37 +08:00
|
|
|
|
new SettingsSlider<float>
|
2017-05-23 17:09:32 +08:00
|
|
|
|
{
|
2021-08-11 16:48:37 +08:00
|
|
|
|
LabelText = GraphicsSettingsStrings.VerticalPosition,
|
2020-10-06 16:18:41 +08:00
|
|
|
|
Current = scalingPositionY,
|
2020-01-28 12:32:30 +08:00
|
|
|
|
KeyboardStep = 0.01f,
|
|
|
|
|
DisplayAsPercentage = true
|
2019-01-04 12:29:37 +08:00
|
|
|
|
},
|
|
|
|
|
new SettingsSlider<float>
|
|
|
|
|
{
|
2021-08-11 16:48:37 +08:00
|
|
|
|
LabelText = GraphicsSettingsStrings.HorizontalScale,
|
2020-10-06 16:18:41 +08:00
|
|
|
|
Current = scalingSizeX,
|
2020-01-28 12:32:30 +08:00
|
|
|
|
KeyboardStep = 0.01f,
|
|
|
|
|
DisplayAsPercentage = true
|
2019-01-04 12:29:37 +08:00
|
|
|
|
},
|
|
|
|
|
new SettingsSlider<float>
|
|
|
|
|
{
|
2021-08-11 16:48:37 +08:00
|
|
|
|
LabelText = GraphicsSettingsStrings.VerticalScale,
|
2020-10-06 16:18:41 +08:00
|
|
|
|
Current = scalingSizeY,
|
2020-01-28 12:32:30 +08:00
|
|
|
|
KeyboardStep = 0.01f,
|
|
|
|
|
DisplayAsPercentage = true
|
2017-05-23 17:09:32 +08:00
|
|
|
|
},
|
|
|
|
|
}
|
2016-11-30 23:32:07 +08:00
|
|
|
|
},
|
2016-11-11 06:40:42 +08:00
|
|
|
|
};
|
2022-05-26 17:37:04 +08:00
|
|
|
|
|
|
|
|
|
fullscreenCapability.BindValueChanged(_ => Schedule(updateScreenModeWarning), true);
|
2021-01-05 17:19:28 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void LoadComplete()
|
|
|
|
|
{
|
|
|
|
|
base.LoadComplete();
|
|
|
|
|
|
2021-01-06 14:19:12 +08:00
|
|
|
|
scalingSettings.ForEach(s => bindPreviewEvent(s.Current));
|
|
|
|
|
|
2022-06-24 20:25:23 +08:00
|
|
|
|
windowModeDropdown.Current.BindValueChanged(_ =>
|
2021-05-04 15:59:48 +08:00
|
|
|
|
{
|
2022-10-28 12:52:45 +08:00
|
|
|
|
updateDisplaySettingsVisibility();
|
2022-05-26 17:37:04 +08:00
|
|
|
|
updateScreenModeWarning();
|
2021-05-04 15:59:48 +08:00
|
|
|
|
}, true);
|
2021-01-05 17:19:28 +08:00
|
|
|
|
|
2022-06-24 20:25:23 +08:00
|
|
|
|
windowModes.BindCollectionChanged((_, _) =>
|
2020-12-22 13:02:15 +08:00
|
|
|
|
{
|
|
|
|
|
if (windowModes.Count > 1)
|
|
|
|
|
windowModeDropdown.Show();
|
|
|
|
|
else
|
|
|
|
|
windowModeDropdown.Hide();
|
|
|
|
|
}, true);
|
2019-01-08 12:48:38 +08:00
|
|
|
|
|
2020-12-22 16:34:51 +08:00
|
|
|
|
currentDisplay.BindValueChanged(display => Schedule(() =>
|
2018-06-03 02:02:45 +08:00
|
|
|
|
{
|
2020-12-22 13:02:15 +08:00
|
|
|
|
resolutions.RemoveRange(1, resolutions.Count - 1);
|
2018-09-19 16:52:35 +08:00
|
|
|
|
|
2020-12-22 16:34:51 +08:00
|
|
|
|
if (display.NewValue != null)
|
2018-09-19 16:52:35 +08:00
|
|
|
|
{
|
2020-12-22 16:34:51 +08:00
|
|
|
|
resolutions.AddRange(display.NewValue.DisplayModes
|
|
|
|
|
.Where(m => m.Size.Width >= 800 && m.Size.Height >= 600)
|
2020-12-22 16:36:56 +08:00
|
|
|
|
.OrderByDescending(m => Math.Max(m.Size.Height, m.Size.Width))
|
2020-12-22 16:34:51 +08:00
|
|
|
|
.Select(m => m.Size)
|
|
|
|
|
.Distinct());
|
2020-12-22 13:02:15 +08:00
|
|
|
|
}
|
|
|
|
|
|
2022-10-28 12:52:45 +08:00
|
|
|
|
updateDisplaySettingsVisibility();
|
2020-12-22 13:02:15 +08:00
|
|
|
|
}), true);
|
|
|
|
|
|
2022-06-24 20:25:23 +08:00
|
|
|
|
scalingMode.BindValueChanged(_ =>
|
2017-05-23 19:32:45 +08:00
|
|
|
|
{
|
2019-01-04 12:29:37 +08:00
|
|
|
|
scalingSettings.ClearTransforms();
|
2021-08-16 17:44:12 +08:00
|
|
|
|
scalingSettings.AutoSizeDuration = transition_duration;
|
|
|
|
|
scalingSettings.AutoSizeEasing = Easing.OutQuint;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2021-08-17 11:38:44 +08:00
|
|
|
|
updateScalingModeVisibility();
|
|
|
|
|
});
|
2019-01-08 12:48:38 +08:00
|
|
|
|
|
2021-08-17 11:38:44 +08:00
|
|
|
|
// initial update bypasses transforms
|
|
|
|
|
updateScalingModeVisibility();
|
2019-02-28 20:38:55 +08:00
|
|
|
|
|
2021-08-17 11:38:44 +08:00
|
|
|
|
void updateScalingModeVisibility()
|
|
|
|
|
{
|
|
|
|
|
if (scalingMode.Value == ScalingMode.Off)
|
|
|
|
|
scalingSettings.ResizeHeightTo(0, transition_duration, Easing.OutQuint);
|
|
|
|
|
|
|
|
|
|
scalingSettings.AutoSizeAxes = scalingMode.Value != ScalingMode.Off ? Axes.Y : Axes.None;
|
|
|
|
|
scalingSettings.ForEach(s => s.TransferValueOnCommit = scalingMode.Value == ScalingMode.Everything);
|
|
|
|
|
}
|
2017-03-21 23:24:19 +08:00
|
|
|
|
}
|
2018-06-03 02:02:45 +08:00
|
|
|
|
|
2022-10-04 05:52:04 +08:00
|
|
|
|
private void onDisplaysChanged(IEnumerable<Display> displays)
|
|
|
|
|
{
|
|
|
|
|
Scheduler.AddOnce(d =>
|
|
|
|
|
{
|
|
|
|
|
displayDropdown.Items = d;
|
2022-10-28 12:52:45 +08:00
|
|
|
|
updateDisplaySettingsVisibility();
|
2022-10-04 05:52:04 +08:00
|
|
|
|
}, displays);
|
|
|
|
|
}
|
|
|
|
|
|
2022-10-28 12:52:45 +08:00
|
|
|
|
private void updateDisplaySettingsVisibility()
|
2022-10-04 05:14:21 +08:00
|
|
|
|
{
|
|
|
|
|
if (resolutions.Count > 1 && windowModeDropdown.Current.Value == WindowMode.Fullscreen)
|
|
|
|
|
resolutionDropdown.Show();
|
|
|
|
|
else
|
|
|
|
|
resolutionDropdown.Hide();
|
|
|
|
|
|
|
|
|
|
if (displayDropdown.Items.Count() > 1)
|
|
|
|
|
displayDropdown.Show();
|
|
|
|
|
else
|
|
|
|
|
displayDropdown.Hide();
|
2022-10-28 12:52:45 +08:00
|
|
|
|
|
2022-10-28 17:07:25 +08:00
|
|
|
|
if (host.Window?.SafeAreaPadding.Value.Total != Vector2.Zero)
|
2022-10-28 12:52:45 +08:00
|
|
|
|
safeAreaConsiderationsCheckbox.Show();
|
|
|
|
|
else
|
|
|
|
|
safeAreaConsiderationsCheckbox.Hide();
|
2022-10-04 05:14:21 +08:00
|
|
|
|
}
|
|
|
|
|
|
2022-05-26 17:37:04 +08:00
|
|
|
|
private void updateScreenModeWarning()
|
|
|
|
|
{
|
2022-06-03 15:51:20 +08:00
|
|
|
|
if (RuntimeInfo.OS == RuntimeInfo.Platform.macOS)
|
2022-05-26 17:37:04 +08:00
|
|
|
|
{
|
2022-06-03 15:51:20 +08:00
|
|
|
|
if (windowModeDropdown.Current.Value == WindowMode.Fullscreen)
|
|
|
|
|
windowModeDropdown.SetNoticeText(LayoutSettingsStrings.FullscreenMacOSNote, true);
|
|
|
|
|
else
|
|
|
|
|
windowModeDropdown.ClearNoticeText();
|
|
|
|
|
|
2022-05-26 17:37:04 +08:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2022-06-03 15:51:20 +08:00
|
|
|
|
if (windowModeDropdown.Current.Value != WindowMode.Fullscreen)
|
2022-06-03 15:23:38 +08:00
|
|
|
|
{
|
2022-06-03 15:51:20 +08:00
|
|
|
|
windowModeDropdown.SetNoticeText(GraphicsSettingsStrings.NotFullscreenNote, true);
|
2022-06-03 15:23:38 +08:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2022-05-31 13:04:56 +08:00
|
|
|
|
if (host.Window is WindowsWindow)
|
2022-05-26 17:37:04 +08:00
|
|
|
|
{
|
2022-05-31 13:04:56 +08:00
|
|
|
|
switch (fullscreenCapability.Value)
|
|
|
|
|
{
|
|
|
|
|
case FullscreenCapability.Unknown:
|
2022-06-01 15:51:34 +08:00
|
|
|
|
windowModeDropdown.SetNoticeText(LayoutSettingsStrings.CheckingForFullscreenCapabilities, true);
|
2022-05-31 13:04:56 +08:00
|
|
|
|
break;
|
2022-05-26 17:37:04 +08:00
|
|
|
|
|
2022-05-31 13:04:56 +08:00
|
|
|
|
case FullscreenCapability.Capable:
|
2022-06-01 15:51:34 +08:00
|
|
|
|
windowModeDropdown.SetNoticeText(LayoutSettingsStrings.OsuIsRunningExclusiveFullscreen);
|
2022-05-31 13:04:56 +08:00
|
|
|
|
break;
|
2022-05-26 17:37:04 +08:00
|
|
|
|
|
2022-05-31 13:04:56 +08:00
|
|
|
|
case FullscreenCapability.Incapable:
|
2022-06-01 15:51:34 +08:00
|
|
|
|
windowModeDropdown.SetNoticeText(LayoutSettingsStrings.UnableToRunExclusiveFullscreen, true);
|
2022-05-31 13:04:56 +08:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
// We can only detect exclusive fullscreen status on windows currently.
|
2022-06-01 15:51:34 +08:00
|
|
|
|
windowModeDropdown.ClearNoticeText();
|
2022-05-26 17:37:04 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-01-08 12:48:38 +08:00
|
|
|
|
private void bindPreviewEvent(Bindable<float> bindable)
|
2019-01-04 13:55:59 +08:00
|
|
|
|
{
|
2019-02-22 16:51:39 +08:00
|
|
|
|
bindable.ValueChanged += _ =>
|
2019-01-04 13:55:59 +08:00
|
|
|
|
{
|
2019-01-04 14:28:35 +08:00
|
|
|
|
switch (scalingMode.Value)
|
|
|
|
|
{
|
|
|
|
|
case ScalingMode.Gameplay:
|
|
|
|
|
showPreview();
|
|
|
|
|
break;
|
|
|
|
|
}
|
2019-01-04 13:55:59 +08:00
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
2022-10-04 05:23:02 +08:00
|
|
|
|
private Drawable? preview;
|
2019-02-28 12:31:40 +08:00
|
|
|
|
|
2019-01-04 14:28:35 +08:00
|
|
|
|
private void showPreview()
|
|
|
|
|
{
|
|
|
|
|
if (preview?.IsAlive != true)
|
|
|
|
|
game.Add(preview = new ScalingPreview());
|
|
|
|
|
|
|
|
|
|
preview.FadeOutFromOne(1500);
|
|
|
|
|
preview.Expire();
|
|
|
|
|
}
|
|
|
|
|
|
2022-10-04 05:52:04 +08:00
|
|
|
|
protected override void Dispose(bool isDisposing)
|
|
|
|
|
{
|
|
|
|
|
if (window != null)
|
|
|
|
|
window.DisplaysChanged -= onDisplaysChanged;
|
|
|
|
|
|
|
|
|
|
base.Dispose(isDisposing);
|
|
|
|
|
}
|
|
|
|
|
|
2019-01-04 14:28:35 +08:00
|
|
|
|
private class ScalingPreview : ScalingContainer
|
|
|
|
|
{
|
|
|
|
|
public ScalingPreview()
|
|
|
|
|
{
|
|
|
|
|
Child = new Box
|
|
|
|
|
{
|
|
|
|
|
Colour = Color4.White,
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
Alpha = 0.5f,
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-01-09 18:01:33 +08:00
|
|
|
|
private class UIScaleSlider : OsuSliderBar<float>
|
|
|
|
|
{
|
2021-06-26 01:10:04 +08:00
|
|
|
|
public override LocalisableString TooltipText => base.TooltipText + "x";
|
2019-01-09 18:01:33 +08:00
|
|
|
|
}
|
|
|
|
|
|
2022-03-02 17:29:07 +08:00
|
|
|
|
private class DisplaySettingsDropdown : SettingsDropdown<Display>
|
|
|
|
|
{
|
|
|
|
|
protected override OsuDropdown<Display> CreateDropdown() => new DisplaySettingsDropdownControl();
|
|
|
|
|
|
|
|
|
|
private class DisplaySettingsDropdownControl : DropdownControl
|
|
|
|
|
{
|
|
|
|
|
protected override LocalisableString GenerateItemText(Display item)
|
|
|
|
|
{
|
|
|
|
|
return $"{item.Index}: {item.Name} ({item.Bounds.Width}x{item.Bounds.Height})";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-11-14 17:02:38 +08:00
|
|
|
|
private class ResolutionSettingsDropdown : SettingsDropdown<Size>
|
|
|
|
|
{
|
2019-06-25 11:00:05 +08:00
|
|
|
|
protected override OsuDropdown<Size> CreateDropdown() => new ResolutionDropdownControl();
|
2018-11-14 17:02:38 +08:00
|
|
|
|
|
|
|
|
|
private class ResolutionDropdownControl : DropdownControl
|
|
|
|
|
{
|
2021-02-22 16:14:00 +08:00
|
|
|
|
protected override LocalisableString GenerateItemText(Size item)
|
2018-11-14 17:02:38 +08:00
|
|
|
|
{
|
|
|
|
|
if (item == new Size(9999, 9999))
|
2021-08-11 16:48:37 +08:00
|
|
|
|
return CommonStrings.Default;
|
2019-02-28 12:31:40 +08:00
|
|
|
|
|
2018-11-14 17:02:38 +08:00
|
|
|
|
return $"{item.Width}x{item.Height}";
|
|
|
|
|
}
|
|
|
|
|
}
|
2018-09-07 18:29:51 +08:00
|
|
|
|
}
|
2016-11-12 18:44:16 +08:00
|
|
|
|
}
|
2017-05-04 22:07:24 +08:00
|
|
|
|
}
|