mirror of
https://github.com/ppy/osu.git
synced 2024-11-11 10:33:30 +08:00
Add UI scale
Limited to (relatively) sane values until we eventually get around to adjusting UI to allow higher extermities.
This commit is contained in:
parent
e4ff36a5bc
commit
4f5c208672
@ -105,6 +105,8 @@ namespace osu.Game.Configuration
|
||||
|
||||
Set(OsuSetting.ScalingPositionX, 0.5f, 0f, 1f);
|
||||
Set(OsuSetting.ScalingPositionY, 0.5f, 0f, 1f);
|
||||
|
||||
Set(OsuSetting.UIScale, 1f, 0.8f, 1.6f, 0.01f);
|
||||
}
|
||||
|
||||
public OsuConfigManager(Storage storage)
|
||||
@ -167,6 +169,7 @@ namespace osu.Game.Configuration
|
||||
ScalingPositionX,
|
||||
ScalingPositionY,
|
||||
ScalingSizeX,
|
||||
ScalingSizeY
|
||||
ScalingSizeY,
|
||||
UIScale
|
||||
}
|
||||
}
|
||||
|
@ -46,10 +46,37 @@ namespace osu.Game.Graphics.Containers
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
RelativePositionAxes = Axes.Both,
|
||||
CornerRadius = 10,
|
||||
Child = content = new DrawSizePreservingFillContainer()
|
||||
Child = content = new ScalingDrawSizePreservingFillContainer(targetMode != ScalingMode.Gameplay)
|
||||
};
|
||||
}
|
||||
|
||||
private class ScalingDrawSizePreservingFillContainer : DrawSizePreservingFillContainer
|
||||
{
|
||||
private readonly bool applyUIScale;
|
||||
private Bindable<float> uiScale;
|
||||
|
||||
public ScalingDrawSizePreservingFillContainer(bool applyUIScale)
|
||||
{
|
||||
this.applyUIScale = applyUIScale;
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuConfigManager osuConfig)
|
||||
{
|
||||
if (applyUIScale)
|
||||
{
|
||||
uiScale = osuConfig.GetBindable<float>(OsuSetting.UIScale);
|
||||
uiScale.BindValueChanged(scaleChanged, true);
|
||||
}
|
||||
}
|
||||
|
||||
private void scaleChanged(float value)
|
||||
{
|
||||
this.ScaleTo(new Vector2(value), 500, Easing.Out);
|
||||
this.ResizeTo(new Vector2(1 / value), 500, Easing.Out);
|
||||
}
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuConfigManager config)
|
||||
{
|
||||
|
@ -359,7 +359,10 @@ namespace osu.Game
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
},
|
||||
mainContent = new DrawSizePreservingFillContainer(),
|
||||
mainContent = new Container
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
},
|
||||
overlayContent = new Container { RelativeSizeAxes = Axes.Both, Depth = float.MinValue },
|
||||
idleTracker = new IdleTracker(6000)
|
||||
});
|
||||
|
@ -63,9 +63,16 @@ namespace osu.Game.Overlays.Settings.Sections.Graphics
|
||||
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 = "Scaling",
|
||||
LabelText = "Screen Scaling",
|
||||
Bindable = osuConfig.GetBindable<ScalingMode>(OsuSetting.Scaling),
|
||||
},
|
||||
scalingSettings = new FillFlowContainer<SettingsSlider<float>>
|
||||
@ -141,6 +148,7 @@ namespace osu.Game.Overlays.Settings.Sections.Graphics
|
||||
scalingSettings.ResizeHeightTo(0, transition_duration, Easing.OutQuint);
|
||||
|
||||
scalingSettings.ForEach(s => s.TransferValueOnCommit = mode == ScalingMode.Everything);
|
||||
|
||||
}, true);
|
||||
}
|
||||
|
||||
@ -202,6 +210,11 @@ namespace osu.Game.Overlays.Settings.Sections.Graphics
|
||||
}
|
||||
}
|
||||
|
||||
private class UIScaleSlider : OsuSliderBar<float>
|
||||
{
|
||||
public override string TooltipText => base.TooltipText + "x";
|
||||
}
|
||||
|
||||
private class ResolutionSettingsDropdown : SettingsDropdown<Size>
|
||||
{
|
||||
protected override OsuDropdown<Size> CreateDropdown() => new ResolutionDropdownControl { Items = Items };
|
||||
|
Loading…
Reference in New Issue
Block a user