Merge branch 'master' into offset-ui-improvements

This commit is contained in:
Bartłomiej Dach 2022-03-05 16:10:18 +01:00
commit e4b4c3c5c4
No known key found for this signature in database
GPG Key ID: BCECCD4FA41F6497
19 changed files with 104 additions and 54 deletions

View File

@ -51,8 +51,8 @@
<Reference Include="Java.Interop" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="ppy.osu.Game.Resources" Version="2022.211.0" />
<PackageReference Include="ppy.osu.Framework.Android" Version="2022.223.0" />
<PackageReference Include="ppy.osu.Game.Resources" Version="2022.304.0" />
<PackageReference Include="ppy.osu.Framework.Android" Version="2022.304.0" />
</ItemGroup>
<ItemGroup Label="Transitive Dependencies">
<!-- Realm needs to be directly referenced in all Xamarin projects, as it will not pull in its transitive dependencies otherwise. -->

View File

@ -45,10 +45,5 @@ private void load()
}
};
}
private class TimeSlider : OsuSliderBar<double>
{
public override LocalisableString TooltipText => Current.Value.ToString(@"N0") + "ms";
}
}
}

View File

@ -140,7 +140,7 @@ protected override void InitialiseDefaults()
SetDefault(OsuSetting.UIScale, 1f, 0.8f, 1.6f, 0.01f);
SetDefault(OsuSetting.UIHoldActivationDelay, 200f, 0f, 500f, 50f);
SetDefault(OsuSetting.UIHoldActivationDelay, 200.0, 0.0, 500.0, 50.0);
SetDefault(OsuSetting.IntroSequence, IntroSequence.Triangles);
@ -240,9 +240,9 @@ public override TrackedSettings CreateTrackedSettings()
};
}
public Func<Guid, string> LookupSkinName { private get; set; }
public Func<Guid, string> LookupSkinName { private get; set; } = _ => @"unknown";
public Func<GlobalAction, LocalisableString> LookupKeyBindings { get; set; }
public Func<GlobalAction, LocalisableString> LookupKeyBindings { get; set; } = _ => @"unknown";
}
// IMPORTANT: These are used in user configuration files.

View File

@ -30,12 +30,12 @@ public abstract class HoldToConfirmContainer : Container
public Bindable<double> Progress = new BindableDouble();
private Bindable<float> holdActivationDelay;
private Bindable<double> holdActivationDelay;
[BackgroundDependencyLoader]
private void load(OsuConfigManager config)
{
holdActivationDelay = config.GetBindable<float>(OsuSetting.UIHoldActivationDelay);
holdActivationDelay = config.GetBindable<double>(OsuSetting.UIHoldActivationDelay);
}
protected void BeginConfirm()

View File

@ -140,6 +140,7 @@ private void playTapSample(double baseFrequency = 1f)
// Scale to [-0.75, 0.75] so that the sample isn't fully panned left or right (sounds weird)
channel.Balance.Value = ((activeCursor.X / DrawWidth) * 2 - 1) * 0.75;
channel.Frequency.Value = baseFrequency - (random_range / 2f) + RNG.NextDouble(random_range);
channel.Volume.Value = baseFrequency;
channel.Play();
}

View File

@ -148,7 +148,7 @@ protected override void Update()
protected override void LoadComplete()
{
base.LoadComplete();
CurrentNumber.BindValueChanged(current => TooltipText = GetTooltipText(current.NewValue), true);
CurrentNumber.BindValueChanged(current => TooltipText = getTooltipText(current.NewValue), true);
}
protected override bool OnHover(HoverEvent e)
@ -178,7 +178,7 @@ protected override void OnUserChange(T value)
{
base.OnUserChange(value);
playSample(value);
TooltipText = GetTooltipText(value);
TooltipText = getTooltipText(value);
}
private void playSample(T value)
@ -203,7 +203,7 @@ private void playSample(T value)
channel.Play();
}
protected virtual LocalisableString GetTooltipText(T value)
private LocalisableString getTooltipText(T value)
{
if (CurrentNumber.IsInteger)
return value.ToInt32(NumberFormatInfo.InvariantInfo).ToString("N0");

View File

@ -0,0 +1,15 @@
// 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.
using osu.Framework.Localisation;
namespace osu.Game.Graphics.UserInterface
{
/// <summary>
/// A slider bar which displays a millisecond time value.
/// </summary>
public class TimeSlider : OsuSliderBar<double>
{
public override LocalisableString TooltipText => $"{Current.Value:N0} ms";
}
}

View File

@ -54,6 +54,11 @@ public static class GraphicsSettingsStrings
/// </summary>
public static LocalisableString Resolution => new TranslatableString(getKey(@"resolution"), @"Resolution");
/// <summary>
/// "Display"
/// </summary>
public static LocalisableString Display => new TranslatableString(getKey(@"display"), @"Display");
/// <summary>
/// "UI scaling"
/// </summary>

View File

@ -1,6 +1,8 @@
// 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.
using osu.Game.Extensions;
using osu.Game.Localisation;
using osu.Game.Online.API.Requests.Responses;
namespace osu.Game.Online.API.Requests
@ -8,14 +10,14 @@ namespace osu.Game.Online.API.Requests
public class GetWikiRequest : APIRequest<APIWikiPage>
{
private readonly string path;
private readonly string locale;
private readonly Language language;
public GetWikiRequest(string path, string locale = "en")
public GetWikiRequest(string path, Language language = Language.en)
{
this.path = path;
this.locale = locale;
this.language = language;
}
protected override string Target => $"wiki/{locale}/{path}";
protected override string Target => $"wiki/{language.ToCultureCode()}/{path}";
}
}

View File

@ -1,6 +1,7 @@
// 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.
using System.Threading;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Extensions.Color4Extensions;
@ -63,11 +64,17 @@ private void load(OverlayColourProvider colourProvider)
};
}
private CancellationTokenSource cancellationTokenSource;
private void updateDisplay(APIUser user)
{
var badges = user.Badges;
cancellationTokenSource?.Cancel();
cancellationTokenSource = new CancellationTokenSource();
badgeFlowContainer.Clear();
var badges = user.Badges;
if (badges?.Length > 0)
{
Show();
@ -79,7 +86,7 @@ private void updateDisplay(APIUser user)
{
// load in stable order regardless of async load order.
badgeFlowContainer.Insert(displayIndex, asyncBadge);
});
}, cancellationTokenSource.Token);
}
}
else
@ -87,5 +94,11 @@ private void updateDisplay(APIUser user)
Hide();
}
}
protected override void Dispose(bool isDisposing)
{
cancellationTokenSource?.Cancel();
base.Dispose(isDisposing);
}
}
}

View File

@ -23,7 +23,7 @@ private void load(OsuConfigManager config)
{
Children = new Drawable[]
{
new SettingsSlider<double, OffsetSlider>
new SettingsSlider<double, TimeSlider>
{
LabelText = AudioSettingsStrings.AudioOffset,
Current = config.GetBindable<double>(OsuSetting.AudioOffset),
@ -35,10 +35,5 @@ private void load(OsuConfigManager config)
}
};
}
private class OffsetSlider : OsuSliderBar<double>
{
public override LocalisableString TooltipText => Current.Value.ToString(@"0ms");
}
}
}

View File

@ -27,7 +27,7 @@ public class LayoutSettings : SettingsSubsection
private FillFlowContainer<SettingsSlider<float>> scalingSettings;
private readonly IBindable<Display> currentDisplay = new Bindable<Display>();
private readonly Bindable<Display> currentDisplay = new Bindable<Display>();
private readonly IBindableList<WindowMode> windowModes = new BindableList<WindowMode>();
private Bindable<ScalingMode> scalingMode;
@ -39,6 +39,7 @@ public class LayoutSettings : SettingsSubsection
private OsuGameBase game { get; set; }
private SettingsDropdown<Size> resolutionDropdown;
private SettingsDropdown<Display> displayDropdown;
private SettingsDropdown<WindowMode> windowModeDropdown;
private Bindable<float> scalingPositionX;
@ -72,6 +73,12 @@ private void load(FrameworkConfigManager config, OsuConfigManager osuConfig, Gam
ItemSource = windowModes,
Current = config.GetBindable<WindowMode>(FrameworkSetting.WindowMode),
},
displayDropdown = new DisplaySettingsDropdown
{
LabelText = GraphicsSettingsStrings.Display,
Items = host.Window?.Displays,
Current = currentDisplay,
},
resolutionDropdown = new ResolutionSettingsDropdown
{
LabelText = GraphicsSettingsStrings.Resolution,
@ -142,7 +149,7 @@ protected override void LoadComplete()
windowModeDropdown.Current.BindValueChanged(mode =>
{
updateResolutionDropdown();
updateDisplayModeDropdowns();
windowModeDropdown.WarningText = mode.NewValue != WindowMode.Fullscreen ? GraphicsSettingsStrings.NotFullscreenNote : default;
}, true);
@ -168,7 +175,7 @@ protected override void LoadComplete()
.Distinct());
}
updateResolutionDropdown();
updateDisplayModeDropdowns();
}), true);
scalingMode.BindValueChanged(mode =>
@ -183,12 +190,17 @@ protected override void LoadComplete()
// initial update bypasses transforms
updateScalingModeVisibility();
void updateResolutionDropdown()
void updateDisplayModeDropdowns()
{
if (resolutions.Count > 1 && windowModeDropdown.Current.Value == WindowMode.Fullscreen)
resolutionDropdown.Show();
else
resolutionDropdown.Hide();
if (displayDropdown.Items.Count() > 1)
displayDropdown.Show();
else
displayDropdown.Hide();
}
void updateScalingModeVisibility()
@ -243,6 +255,19 @@ private class UIScaleSlider : OsuSliderBar<float>
public override LocalisableString TooltipText => base.TooltipText + "x";
}
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})";
}
}
}
private class ResolutionSettingsDropdown : SettingsDropdown<Size>
{
protected override OsuDropdown<Size> CreateDropdown() => new ResolutionDropdownControl();

View File

@ -35,18 +35,13 @@ private void load(OsuConfigManager config)
LabelText = UserInterfaceStrings.Parallax,
Current = config.GetBindable<bool>(OsuSetting.MenuParallax)
},
new SettingsSlider<float, TimeSlider>
new SettingsSlider<double, TimeSlider>
{
LabelText = UserInterfaceStrings.HoldToConfirmActivationTime,
Current = config.GetBindable<float>(OsuSetting.UIHoldActivationDelay),
Current = config.GetBindable<double>(OsuSetting.UIHoldActivationDelay),
KeyboardStep = 50
},
};
}
private class TimeSlider : OsuSliderBar<float>
{
public override LocalisableString TooltipText => Current.Value.ToString(@"N0") + "ms";
}
}
}

View File

@ -7,6 +7,7 @@
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Game.Extensions;
using osu.Game.Online.API;
using osu.Game.Online.API.Requests;
using osu.Game.Online.API.Requests.Responses;
@ -100,7 +101,12 @@ private void onPathChanged(ValueChangedEvent<string> e)
cancellationToken?.Cancel();
request?.Cancel();
request = new GetWikiRequest(e.NewValue);
string[] values = e.NewValue.Split('/', 2);
if (values.Length > 1 && LanguageExtensions.TryParseCultureCode(values[0], out var language))
request = new GetWikiRequest(values[1], language);
else
request = new GetWikiRequest(e.NewValue);
Loading.Show();

View File

@ -66,7 +66,7 @@ public class MainMenu : OsuScreen, IHandlePresentBeatmap, IKeyBindingHandler<Glo
protected override BackgroundScreen CreateBackground() => background;
private Bindable<float> holdDelay;
private Bindable<double> holdDelay;
private Bindable<bool> loginDisplayed;
private ExitConfirmOverlay exitConfirmOverlay;
@ -77,7 +77,7 @@ public class MainMenu : OsuScreen, IHandlePresentBeatmap, IKeyBindingHandler<Glo
[BackgroundDependencyLoader(true)]
private void load(BeatmapListingOverlay beatmapListing, SettingsOverlay settings, OsuConfigManager config, SessionStatics statics)
{
holdDelay = config.GetBindable<float>(OsuSetting.UIHoldActivationDelay);
holdDelay = config.GetBindable<double>(OsuSetting.UIHoldActivationDelay);
loginDisplayed = statics.GetBindable<bool>(Static.LoginOverlayDisplayed);
if (host.CanExit)

View File

@ -63,11 +63,11 @@ public HoldForMenuButton()
[Resolved]
private OsuConfigManager config { get; set; }
private Bindable<float> activationDelay;
private Bindable<double> activationDelay;
protected override void LoadComplete()
{
activationDelay = config.GetBindable<float>(OsuSetting.UIHoldActivationDelay);
activationDelay = config.GetBindable<double>(OsuSetting.UIHoldActivationDelay);
activationDelay.BindValueChanged(v =>
{
text.Text = v.NewValue > 0

View File

@ -98,12 +98,10 @@ public class OffsetSliderBar : PlayerSliderBar<double>
protected class CustomSliderBar : SliderBar
{
protected override LocalisableString GetTooltipText(double value)
{
return value == 0
? new TranslatableString("_", @"{0} ms", base.GetTooltipText(value))
: new TranslatableString("_", @"{0} ms {1}", base.GetTooltipText(value), getEarlyLateText(value));
}
public override LocalisableString TooltipText =>
Current.Value == 0
? new TranslatableString("_", @"{0} ms", base.TooltipText)
: new TranslatableString("_", @"{0} ms {1}", base.TooltipText, getEarlyLateText(Current.Value));
private LocalisableString getEarlyLateText(double value)
{

View File

@ -36,8 +36,8 @@
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Realm" Version="10.9.0" />
<PackageReference Include="ppy.osu.Framework" Version="2022.223.0" />
<PackageReference Include="ppy.osu.Game.Resources" Version="2022.211.0" />
<PackageReference Include="ppy.osu.Framework" Version="2022.304.0" />
<PackageReference Include="ppy.osu.Game.Resources" Version="2022.304.0" />
<PackageReference Include="Sentry" Version="3.14.0" />
<PackageReference Include="SharpCompress" Version="0.30.1" />
<PackageReference Include="NUnit" Version="3.13.2" />

View File

@ -61,8 +61,8 @@
<Reference Include="System.Net.Http" />
</ItemGroup>
<ItemGroup Label="Package References">
<PackageReference Include="ppy.osu.Framework.iOS" Version="2022.223.0" />
<PackageReference Include="ppy.osu.Game.Resources" Version="2022.211.0" />
<PackageReference Include="ppy.osu.Framework.iOS" Version="2022.304.0" />
<PackageReference Include="ppy.osu.Game.Resources" Version="2022.304.0" />
</ItemGroup>
<!-- See https://github.com/dotnet/runtime/issues/35988 (can be removed after Xamarin uses net6.0) -->
<PropertyGroup>
@ -84,7 +84,7 @@
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="5.0.14" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite.Core" Version="5.0.14" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
<PackageReference Include="ppy.osu.Framework" Version="2022.223.0" />
<PackageReference Include="ppy.osu.Framework" Version="2022.304.0" />
<PackageReference Include="SharpCompress" Version="0.30.1" />
<PackageReference Include="NUnit" Version="3.13.2" />
<PackageReference Include="System.ComponentModel.Annotations" Version="5.0.0" />