From 74706f72e6450befc842511bdc0077b100180ac9 Mon Sep 17 00:00:00 2001 From: Perry MacMurray Date: Tue, 5 Apr 2022 15:10:55 -0400 Subject: [PATCH 01/14] Add 12-hour display setting (TODO add toggle) --- osu.Game/Overlays/Toolbar/DigitalClockDisplay.cs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/osu.Game/Overlays/Toolbar/DigitalClockDisplay.cs b/osu.Game/Overlays/Toolbar/DigitalClockDisplay.cs index 81a362450c..b535c5c6a2 100644 --- a/osu.Game/Overlays/Toolbar/DigitalClockDisplay.cs +++ b/osu.Game/Overlays/Toolbar/DigitalClockDisplay.cs @@ -29,6 +29,8 @@ namespace osu.Game.Overlays.Toolbar } } + private bool format12H = true; + [BackgroundDependencyLoader] private void load(OsuColour colours) { @@ -50,13 +52,17 @@ namespace osu.Game.Overlays.Toolbar protected override void UpdateDisplay(DateTimeOffset now) { - realTime.Text = $"{now:HH:mm:ss}"; + realTime.Text = format12H ? $"{now:hh:mm:ss tt}" : $"{now:HH:mm:ss}"; gameTime.Text = $"running {new TimeSpan(TimeSpan.TicksPerSecond * (int)(Clock.CurrentTime / 1000)):c}"; } private void updateMetrics() { - Width = showRuntime ? 66 : 45; // Allows for space for game time up to 99 days (in the padding area since this is quite rare). + if (format12H) + Width = 74; + else + Width = showRuntime ? 66 : 45; // Allows for space for game time up to 99 days (in the padding area since this is quite rare). + gameTime.FadeTo(showRuntime ? 1 : 0); } } From 9d475f7b336b196a06f99801a64c7cd280641d9a Mon Sep 17 00:00:00 2001 From: Perry MacMurray Date: Tue, 5 Apr 2022 16:21:28 -0400 Subject: [PATCH 02/14] Add config in settings for forcing 24H time, determines default off CurrentCulture --- osu.Game/Configuration/OsuConfigManager.cs | 3 +++ osu.Game/Localisation/UserInterfaceStrings.cs | 5 +++++ .../Sections/UserInterface/GeneralSettings.cs | 5 +++++ .../Overlays/Toolbar/DigitalClockDisplay.cs | 20 ++++++++++++++++--- osu.Game/Overlays/Toolbar/ToolbarClock.cs | 6 ++++++ 5 files changed, 36 insertions(+), 3 deletions(-) diff --git a/osu.Game/Configuration/OsuConfigManager.cs b/osu.Game/Configuration/OsuConfigManager.cs index 2f966ac0a9..99372c92d9 100644 --- a/osu.Game/Configuration/OsuConfigManager.cs +++ b/osu.Game/Configuration/OsuConfigManager.cs @@ -102,6 +102,8 @@ namespace osu.Game.Configuration SetDefault(OsuSetting.MenuParallax, true); + SetDefault(OsuSetting.Prefer24HourTime, false); + // Gameplay SetDefault(OsuSetting.PositionalHitsounds, true); // replaced by level setting below, can be removed 20220703. SetDefault(OsuSetting.PositionalHitsoundsLevel, 0.2f, 0, 1); @@ -287,6 +289,7 @@ namespace osu.Game.Configuration MenuVoice, CursorRotation, MenuParallax, + Prefer24HourTime, BeatmapDetailTab, BeatmapDetailModsFilter, Username, diff --git a/osu.Game/Localisation/UserInterfaceStrings.cs b/osu.Game/Localisation/UserInterfaceStrings.cs index 4be403edb4..ac79f9f45d 100644 --- a/osu.Game/Localisation/UserInterfaceStrings.cs +++ b/osu.Game/Localisation/UserInterfaceStrings.cs @@ -24,6 +24,11 @@ namespace osu.Game.Localisation /// public static LocalisableString CursorRotation => new TranslatableString(getKey(@"cursor_rotation"), @"Rotate cursor when dragging"); + /// + /// "Prefer 24-hour time" + /// + public static LocalisableString Prefer24HourTime => new TranslatableString(getKey(@"prefer_24_hour_time"), @"Prefer 24-hour time"); + /// /// "Menu cursor size" /// diff --git a/osu.Game/Overlays/Settings/Sections/UserInterface/GeneralSettings.cs b/osu.Game/Overlays/Settings/Sections/UserInterface/GeneralSettings.cs index 59894cbcae..d6d38c8e12 100644 --- a/osu.Game/Overlays/Settings/Sections/UserInterface/GeneralSettings.cs +++ b/osu.Game/Overlays/Settings/Sections/UserInterface/GeneralSettings.cs @@ -41,6 +41,11 @@ namespace osu.Game.Overlays.Settings.Sections.UserInterface Current = config.GetBindable(OsuSetting.UIHoldActivationDelay), KeyboardStep = 50 }, + new SettingsCheckbox + { + LabelText = UserInterfaceStrings.Prefer24HourTime, + Current = config.GetBindable(OsuSetting.Prefer24HourTime) + }, }; } } diff --git a/osu.Game/Overlays/Toolbar/DigitalClockDisplay.cs b/osu.Game/Overlays/Toolbar/DigitalClockDisplay.cs index b535c5c6a2..66f40532d0 100644 --- a/osu.Game/Overlays/Toolbar/DigitalClockDisplay.cs +++ b/osu.Game/Overlays/Toolbar/DigitalClockDisplay.cs @@ -29,7 +29,21 @@ namespace osu.Game.Overlays.Toolbar } } - private bool format12H = true; + private bool format12H = false; + + public bool Format12H + { + get => format12H; + set + { + if (format12H == value) + return; + + format12H = value; + updateMetrics(); + UpdateDisplay(DateTimeOffset.Now); //Update realTime.Text immediately instead of waiting until next second + } + } [BackgroundDependencyLoader] private void load(OsuColour colours) @@ -52,14 +66,14 @@ namespace osu.Game.Overlays.Toolbar protected override void UpdateDisplay(DateTimeOffset now) { - realTime.Text = format12H ? $"{now:hh:mm:ss tt}" : $"{now:HH:mm:ss}"; + realTime.Text = format12H ? $"{now:h:mm:ss tt}" : $"{now:HH:mm:ss}"; gameTime.Text = $"running {new TimeSpan(TimeSpan.TicksPerSecond * (int)(Clock.CurrentTime / 1000)):c}"; } private void updateMetrics() { if (format12H) - Width = 74; + Width = 70; else Width = showRuntime ? 66 : 45; // Allows for space for game time up to 99 days (in the padding area since this is quite rare). diff --git a/osu.Game/Overlays/Toolbar/ToolbarClock.cs b/osu.Game/Overlays/Toolbar/ToolbarClock.cs index 22a96603dc..b256d6fbc4 100644 --- a/osu.Game/Overlays/Toolbar/ToolbarClock.cs +++ b/osu.Game/Overlays/Toolbar/ToolbarClock.cs @@ -1,6 +1,7 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. +using System.Globalization; using osu.Framework.Allocation; using osu.Framework.Bindables; using osu.Framework.Extensions.Color4Extensions; @@ -20,6 +21,7 @@ namespace osu.Game.Overlays.Toolbar public class ToolbarClock : OsuClickableContainer { private Bindable clockDisplayMode; + private Bindable digitalPrefer24Hour; private Box hoverBackground; private Box flashBackground; @@ -38,6 +40,7 @@ namespace osu.Game.Overlays.Toolbar private void load(OsuConfigManager config) { clockDisplayMode = config.GetBindable(OsuSetting.ToolbarClockDisplayMode); + digitalPrefer24Hour = config.GetBindable(OsuSetting.Prefer24HourTime); Children = new Drawable[] { @@ -94,6 +97,9 @@ namespace osu.Game.Overlays.Toolbar analog.FadeTo(showAnalog ? 1 : 0); }, true); + + digitalPrefer24Hour.BindValueChanged(prefer24H => + digital.Format12H = prefer24H.NewValue ? false : CultureInfo.CurrentCulture.DateTimeFormat.ShortTimePattern.Contains("tt"), true); } protected override bool OnClick(ClickEvent e) From 2525ec0d18db76a64e50be272dbf457204e1579a Mon Sep 17 00:00:00 2001 From: Perry MacMurray Date: Tue, 5 Apr 2022 17:07:58 -0400 Subject: [PATCH 03/14] Switch 24H toggle from UI settings to language settings --- osu.Game/Localisation/GeneralSettingsStrings.cs | 5 +++++ osu.Game/Localisation/UserInterfaceStrings.cs | 5 ----- .../Settings/Sections/General/LanguageSettings.cs | 8 +++++++- .../Settings/Sections/UserInterface/GeneralSettings.cs | 5 ----- 4 files changed, 12 insertions(+), 11 deletions(-) diff --git a/osu.Game/Localisation/GeneralSettingsStrings.cs b/osu.Game/Localisation/GeneralSettingsStrings.cs index a60e4891f4..cca8c8efd1 100644 --- a/osu.Game/Localisation/GeneralSettingsStrings.cs +++ b/osu.Game/Localisation/GeneralSettingsStrings.cs @@ -29,6 +29,11 @@ namespace osu.Game.Localisation /// public static LocalisableString PreferOriginalMetadataLanguage => new TranslatableString(getKey(@"prefer_original"), @"Prefer metadata in original language"); + /// + /// "Prefer 24-hour time" + /// + public static LocalisableString Prefer24HourTime => new TranslatableString(getKey(@"prefer_24_hour_time"), @"Prefer 24-hour time"); + /// /// "Updates" /// diff --git a/osu.Game/Localisation/UserInterfaceStrings.cs b/osu.Game/Localisation/UserInterfaceStrings.cs index ac79f9f45d..4be403edb4 100644 --- a/osu.Game/Localisation/UserInterfaceStrings.cs +++ b/osu.Game/Localisation/UserInterfaceStrings.cs @@ -24,11 +24,6 @@ namespace osu.Game.Localisation /// public static LocalisableString CursorRotation => new TranslatableString(getKey(@"cursor_rotation"), @"Rotate cursor when dragging"); - /// - /// "Prefer 24-hour time" - /// - public static LocalisableString Prefer24HourTime => new TranslatableString(getKey(@"prefer_24_hour_time"), @"Prefer 24-hour time"); - /// /// "Menu cursor size" /// diff --git a/osu.Game/Overlays/Settings/Sections/General/LanguageSettings.cs b/osu.Game/Overlays/Settings/Sections/General/LanguageSettings.cs index 200618c469..e7cc1bce10 100644 --- a/osu.Game/Overlays/Settings/Sections/General/LanguageSettings.cs +++ b/osu.Game/Overlays/Settings/Sections/General/LanguageSettings.cs @@ -6,6 +6,7 @@ using osu.Framework.Bindables; using osu.Framework.Configuration; using osu.Framework.Graphics; using osu.Framework.Localisation; +using osu.Game.Configuration; using osu.Game.Extensions; using osu.Game.Localisation; @@ -19,7 +20,7 @@ namespace osu.Game.Overlays.Settings.Sections.General protected override LocalisableString Header => GeneralSettingsStrings.LanguageHeader; [BackgroundDependencyLoader] - private void load(FrameworkConfigManager frameworkConfig) + private void load(FrameworkConfigManager frameworkConfig, OsuConfigManager config) { frameworkLocale = frameworkConfig.GetBindable(FrameworkSetting.Locale); @@ -34,6 +35,11 @@ namespace osu.Game.Overlays.Settings.Sections.General LabelText = GeneralSettingsStrings.PreferOriginalMetadataLanguage, Current = frameworkConfig.GetBindable(FrameworkSetting.ShowUnicode) }, + new SettingsCheckbox + { + LabelText = GeneralSettingsStrings.Prefer24HourTime, + Current = config.GetBindable(OsuSetting.Prefer24HourTime) + }, }; if (!LanguageExtensions.TryParseCultureCode(frameworkLocale.Value, out var locale)) diff --git a/osu.Game/Overlays/Settings/Sections/UserInterface/GeneralSettings.cs b/osu.Game/Overlays/Settings/Sections/UserInterface/GeneralSettings.cs index d6d38c8e12..59894cbcae 100644 --- a/osu.Game/Overlays/Settings/Sections/UserInterface/GeneralSettings.cs +++ b/osu.Game/Overlays/Settings/Sections/UserInterface/GeneralSettings.cs @@ -41,11 +41,6 @@ namespace osu.Game.Overlays.Settings.Sections.UserInterface Current = config.GetBindable(OsuSetting.UIHoldActivationDelay), KeyboardStep = 50 }, - new SettingsCheckbox - { - LabelText = UserInterfaceStrings.Prefer24HourTime, - Current = config.GetBindable(OsuSetting.Prefer24HourTime) - }, }; } } From 37509e04a934ec1e51c080866316589d69a70003 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 7 Apr 2022 18:11:30 +0900 Subject: [PATCH 04/14] Rename variable and fix inspections --- osu.Game/Overlays/Toolbar/DigitalClockDisplay.cs | 14 +++++++------- osu.Game/Overlays/Toolbar/ToolbarClock.cs | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/osu.Game/Overlays/Toolbar/DigitalClockDisplay.cs b/osu.Game/Overlays/Toolbar/DigitalClockDisplay.cs index 66f40532d0..4392c5811a 100644 --- a/osu.Game/Overlays/Toolbar/DigitalClockDisplay.cs +++ b/osu.Game/Overlays/Toolbar/DigitalClockDisplay.cs @@ -29,17 +29,17 @@ namespace osu.Game.Overlays.Toolbar } } - private bool format12H = false; + private bool use24HourDisplay; - public bool Format12H + public bool Use24HourDisplay { - get => format12H; + get => use24HourDisplay; set { - if (format12H == value) + if (use24HourDisplay == value) return; - format12H = value; + use24HourDisplay = value; updateMetrics(); UpdateDisplay(DateTimeOffset.Now); //Update realTime.Text immediately instead of waiting until next second } @@ -66,13 +66,13 @@ namespace osu.Game.Overlays.Toolbar protected override void UpdateDisplay(DateTimeOffset now) { - realTime.Text = format12H ? $"{now:h:mm:ss tt}" : $"{now:HH:mm:ss}"; + realTime.Text = use24HourDisplay ? $"{now:h:mm:ss tt}" : $"{now:HH:mm:ss}"; gameTime.Text = $"running {new TimeSpan(TimeSpan.TicksPerSecond * (int)(Clock.CurrentTime / 1000)):c}"; } private void updateMetrics() { - if (format12H) + if (use24HourDisplay) Width = 70; else Width = showRuntime ? 66 : 45; // Allows for space for game time up to 99 days (in the padding area since this is quite rare). diff --git a/osu.Game/Overlays/Toolbar/ToolbarClock.cs b/osu.Game/Overlays/Toolbar/ToolbarClock.cs index b256d6fbc4..264e4bffde 100644 --- a/osu.Game/Overlays/Toolbar/ToolbarClock.cs +++ b/osu.Game/Overlays/Toolbar/ToolbarClock.cs @@ -99,7 +99,7 @@ namespace osu.Game.Overlays.Toolbar }, true); digitalPrefer24Hour.BindValueChanged(prefer24H => - digital.Format12H = prefer24H.NewValue ? false : CultureInfo.CurrentCulture.DateTimeFormat.ShortTimePattern.Contains("tt"), true); + digital.Use24HourDisplay = !prefer24H.NewValue && CultureInfo.CurrentCulture.DateTimeFormat.ShortTimePattern.Contains("tt"), true); } protected override bool OnClick(ClickEvent e) From 7530fe5adf4ea66d7f5cc02034aefef8eed0c969 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 7 Apr 2022 18:13:23 +0900 Subject: [PATCH 05/14] Move default specification to configuration initial value --- osu.Game/Configuration/OsuConfigManager.cs | 4 +++- osu.Game/Overlays/Toolbar/ToolbarClock.cs | 8 +++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/osu.Game/Configuration/OsuConfigManager.cs b/osu.Game/Configuration/OsuConfigManager.cs index 99372c92d9..9aacb50684 100644 --- a/osu.Game/Configuration/OsuConfigManager.cs +++ b/osu.Game/Configuration/OsuConfigManager.cs @@ -3,6 +3,7 @@ using System; using System.Diagnostics; +using System.Globalization; using osu.Framework.Configuration; using osu.Framework.Configuration.Tracking; using osu.Framework.Extensions; @@ -102,7 +103,8 @@ namespace osu.Game.Configuration SetDefault(OsuSetting.MenuParallax, true); - SetDefault(OsuSetting.Prefer24HourTime, false); + // See https://stackoverflow.com/a/63307411 for default sourcing. + SetDefault(OsuSetting.Prefer24HourTime, CultureInfo.CurrentCulture.DateTimeFormat.ShortTimePattern.Contains(@"tt")); // Gameplay SetDefault(OsuSetting.PositionalHitsounds, true); // replaced by level setting below, can be removed 20220703. diff --git a/osu.Game/Overlays/Toolbar/ToolbarClock.cs b/osu.Game/Overlays/Toolbar/ToolbarClock.cs index 264e4bffde..d726a95f46 100644 --- a/osu.Game/Overlays/Toolbar/ToolbarClock.cs +++ b/osu.Game/Overlays/Toolbar/ToolbarClock.cs @@ -1,7 +1,6 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. -using System.Globalization; using osu.Framework.Allocation; using osu.Framework.Bindables; using osu.Framework.Extensions.Color4Extensions; @@ -21,7 +20,7 @@ namespace osu.Game.Overlays.Toolbar public class ToolbarClock : OsuClickableContainer { private Bindable clockDisplayMode; - private Bindable digitalPrefer24Hour; + private Bindable prefer24HourTime; private Box hoverBackground; private Box flashBackground; @@ -40,7 +39,7 @@ namespace osu.Game.Overlays.Toolbar private void load(OsuConfigManager config) { clockDisplayMode = config.GetBindable(OsuSetting.ToolbarClockDisplayMode); - digitalPrefer24Hour = config.GetBindable(OsuSetting.Prefer24HourTime); + prefer24HourTime = config.GetBindable(OsuSetting.Prefer24HourTime); Children = new Drawable[] { @@ -98,8 +97,7 @@ namespace osu.Game.Overlays.Toolbar analog.FadeTo(showAnalog ? 1 : 0); }, true); - digitalPrefer24Hour.BindValueChanged(prefer24H => - digital.Use24HourDisplay = !prefer24H.NewValue && CultureInfo.CurrentCulture.DateTimeFormat.ShortTimePattern.Contains("tt"), true); + prefer24HourTime.BindValueChanged(prefer24H => digital.Use24HourDisplay = !prefer24H.NewValue, true); } protected override bool OnClick(ClickEvent e) From 555aee7b6a98056587d1077a71faff2c44f0b0a5 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 7 Apr 2022 18:16:14 +0900 Subject: [PATCH 06/14] Remove incorrect and pointless complexity to width changes --- osu.Game/Overlays/Toolbar/DigitalClockDisplay.cs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/osu.Game/Overlays/Toolbar/DigitalClockDisplay.cs b/osu.Game/Overlays/Toolbar/DigitalClockDisplay.cs index 4392c5811a..68b36c2a04 100644 --- a/osu.Game/Overlays/Toolbar/DigitalClockDisplay.cs +++ b/osu.Game/Overlays/Toolbar/DigitalClockDisplay.cs @@ -72,10 +72,7 @@ namespace osu.Game.Overlays.Toolbar private void updateMetrics() { - if (use24HourDisplay) - Width = 70; - else - Width = showRuntime ? 66 : 45; // Allows for space for game time up to 99 days (in the padding area since this is quite rare). + Width = showRuntime || use24HourDisplay ? 66 : 45; // Allows for space for game time up to 99 days (in the padding area since this is quite rare). gameTime.FadeTo(showRuntime ? 1 : 0); } From b2c0eaeab4abf7f05cdec587acda9b1c19a29bbc Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 7 Apr 2022 18:20:15 +0900 Subject: [PATCH 07/14] Make string read better --- osu.Game/Localisation/GeneralSettingsStrings.cs | 4 ++-- .../Overlays/Settings/Sections/General/LanguageSettings.cs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/osu.Game/Localisation/GeneralSettingsStrings.cs b/osu.Game/Localisation/GeneralSettingsStrings.cs index cca8c8efd1..c65e6c77f4 100644 --- a/osu.Game/Localisation/GeneralSettingsStrings.cs +++ b/osu.Game/Localisation/GeneralSettingsStrings.cs @@ -30,9 +30,9 @@ namespace osu.Game.Localisation public static LocalisableString PreferOriginalMetadataLanguage => new TranslatableString(getKey(@"prefer_original"), @"Prefer metadata in original language"); /// - /// "Prefer 24-hour time" + /// "Prefer 24-hour time display" /// - public static LocalisableString Prefer24HourTime => new TranslatableString(getKey(@"prefer_24_hour_time"), @"Prefer 24-hour time"); + public static LocalisableString Prefer24HourTimeDisplay => new TranslatableString(getKey(@"prefer_24_hour_time_display"), @"Prefer 24-hour time display"); /// /// "Updates" diff --git a/osu.Game/Overlays/Settings/Sections/General/LanguageSettings.cs b/osu.Game/Overlays/Settings/Sections/General/LanguageSettings.cs index e7cc1bce10..cdce187a35 100644 --- a/osu.Game/Overlays/Settings/Sections/General/LanguageSettings.cs +++ b/osu.Game/Overlays/Settings/Sections/General/LanguageSettings.cs @@ -37,7 +37,7 @@ namespace osu.Game.Overlays.Settings.Sections.General }, new SettingsCheckbox { - LabelText = GeneralSettingsStrings.Prefer24HourTime, + LabelText = GeneralSettingsStrings.Prefer24HourTimeDisplay, Current = config.GetBindable(OsuSetting.Prefer24HourTime) }, }; From a4d3afd06d63059ca2b2cff0b4fb2577dd74818e Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 7 Apr 2022 19:12:10 +0900 Subject: [PATCH 08/14] Fix multiple issues with bindable safety in `SkinEditor` components --- .../Skinning/Editor/SkinBlueprintContainer.cs | 23 ++++++++++++------- osu.Game/Skinning/Editor/SkinEditor.cs | 3 +++ 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/osu.Game/Skinning/Editor/SkinBlueprintContainer.cs b/osu.Game/Skinning/Editor/SkinBlueprintContainer.cs index d67bfb89ab..ebf3c9c319 100644 --- a/osu.Game/Skinning/Editor/SkinBlueprintContainer.cs +++ b/osu.Game/Skinning/Editor/SkinBlueprintContainer.cs @@ -21,21 +21,20 @@ namespace osu.Game.Skinning.Editor private readonly List> targetComponents = new List>(); + [Resolved] + private SkinEditor editor { get; set; } + public SkinBlueprintContainer(Drawable target) { this.target = target; } - [BackgroundDependencyLoader(true)] - private void load(SkinEditor editor) - { - SelectedItems.BindTo(editor.SelectedComponents); - } - protected override void LoadComplete() { base.LoadComplete(); + SelectedItems.BindTo(editor.SelectedComponents); + // track each target container on the current screen. var targetContainers = target.ChildrenOfType().ToArray(); @@ -56,7 +55,7 @@ namespace osu.Game.Skinning.Editor } } - private void componentsChanged(object sender, NotifyCollectionChangedEventArgs e) + private void componentsChanged(object sender, NotifyCollectionChangedEventArgs e) => Schedule(() => { switch (e.Action) { @@ -79,7 +78,7 @@ namespace osu.Game.Skinning.Editor AddBlueprintFor(item); break; } - } + }); protected override void AddBlueprintFor(ISkinnableDrawable item) { @@ -93,5 +92,13 @@ namespace osu.Game.Skinning.Editor protected override SelectionBlueprint CreateBlueprintFor(ISkinnableDrawable component) => new SkinBlueprint(component); + + protected override void Dispose(bool isDisposing) + { + base.Dispose(isDisposing); + + foreach (var list in targetComponents) + list.UnbindAll(); + } } } diff --git a/osu.Game/Skinning/Editor/SkinEditor.cs b/osu.Game/Skinning/Editor/SkinEditor.cs index bcff70c008..4602366413 100644 --- a/osu.Game/Skinning/Editor/SkinEditor.cs +++ b/osu.Game/Skinning/Editor/SkinEditor.cs @@ -203,6 +203,9 @@ namespace osu.Game.Skinning.Editor SelectedComponents.Clear(); + // Immediately clear the previous blueprint container to ensure it doesn't try to interact with the old target. + content.Clear(); + Scheduler.AddOnce(loadBlueprintContainer); Scheduler.AddOnce(populateSettings); From 5b29ddd2ed91fae0d1fbe840d4575bce6d18be7d Mon Sep 17 00:00:00 2001 From: Salman Ahmed Date: Thu, 7 Apr 2022 15:05:08 +0300 Subject: [PATCH 09/14] Add further test coverage against paths with extensions --- .../Skinning/LegacySkinTextureFallbackTest.cs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/osu.Game.Tests/NonVisual/Skinning/LegacySkinTextureFallbackTest.cs b/osu.Game.Tests/NonVisual/Skinning/LegacySkinTextureFallbackTest.cs index db7fc0b4a0..76c49edf78 100644 --- a/osu.Game.Tests/NonVisual/Skinning/LegacySkinTextureFallbackTest.cs +++ b/osu.Game.Tests/NonVisual/Skinning/LegacySkinTextureFallbackTest.cs @@ -83,6 +83,20 @@ namespace osu.Game.Tests.NonVisual.Skinning "followpoint.png", "followpoint@2x.png", 2 }, + new object[] + { + // Looking up a path with extension specified should work. + new[] { "Gameplay/osu/followpoint.png" }, + "Gameplay/osu/followpoint.png", + "Gameplay/osu/followpoint.png", 1 + }, + new object[] + { + // Looking up a path with extension specified should also work with @2x sprites. + new[] { "Gameplay/osu/followpoint@2x.png" }, + "Gameplay/osu/followpoint.png", + "Gameplay/osu/followpoint@2x.png", 2 + }, }; [TestCaseSource(nameof(fallbackTestCases))] From fb9fe4213df4b89ddfec65c71765322aeb38742e Mon Sep 17 00:00:00 2001 From: Salman Ahmed Date: Thu, 7 Apr 2022 15:07:14 +0300 Subject: [PATCH 10/14] Fix skin texture lookups not handling paths with extensions --- osu.Game/Skinning/LegacySkin.cs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/osu.Game/Skinning/LegacySkin.cs b/osu.Game/Skinning/LegacySkin.cs index a97b5d44ce..f7d5581621 100644 --- a/osu.Game/Skinning/LegacySkin.cs +++ b/osu.Game/Skinning/LegacySkin.cs @@ -443,9 +443,7 @@ namespace osu.Game.Skinning string lookupName = name.Replace(@"@2x", string.Empty); float ratio = 2; - string twoTimesFilename = Path.HasExtension(lookupName) - ? @$"{Path.GetFileNameWithoutExtension(lookupName)}@2x{Path.GetExtension(lookupName)}" - : @$"{lookupName}@2x"; + string twoTimesFilename = $"{Path.ChangeExtension(lookupName, null)}@2x{Path.GetExtension(lookupName)}"; var texture = Textures?.Get(twoTimesFilename, wrapModeS, wrapModeT); From c323020fcf362ee4f570fc0f495127a555cd3d5e Mon Sep 17 00:00:00 2001 From: Salman Ahmed Date: Thu, 7 Apr 2022 15:56:12 +0300 Subject: [PATCH 11/14] Fix `Use24HourDisplay` conditional flipped --- osu.Game/Overlays/Toolbar/DigitalClockDisplay.cs | 3 ++- osu.Game/Overlays/Toolbar/ToolbarClock.cs | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/osu.Game/Overlays/Toolbar/DigitalClockDisplay.cs b/osu.Game/Overlays/Toolbar/DigitalClockDisplay.cs index 68b36c2a04..10de35ee50 100644 --- a/osu.Game/Overlays/Toolbar/DigitalClockDisplay.cs +++ b/osu.Game/Overlays/Toolbar/DigitalClockDisplay.cs @@ -40,6 +40,7 @@ namespace osu.Game.Overlays.Toolbar return; use24HourDisplay = value; + updateMetrics(); UpdateDisplay(DateTimeOffset.Now); //Update realTime.Text immediately instead of waiting until next second } @@ -66,7 +67,7 @@ namespace osu.Game.Overlays.Toolbar protected override void UpdateDisplay(DateTimeOffset now) { - realTime.Text = use24HourDisplay ? $"{now:h:mm:ss tt}" : $"{now:HH:mm:ss}"; + realTime.Text = use24HourDisplay ? $"{now:HH:mm:ss}" : $"{now:h:mm:ss tt}"; gameTime.Text = $"running {new TimeSpan(TimeSpan.TicksPerSecond * (int)(Clock.CurrentTime / 1000)):c}"; } diff --git a/osu.Game/Overlays/Toolbar/ToolbarClock.cs b/osu.Game/Overlays/Toolbar/ToolbarClock.cs index d726a95f46..308359570f 100644 --- a/osu.Game/Overlays/Toolbar/ToolbarClock.cs +++ b/osu.Game/Overlays/Toolbar/ToolbarClock.cs @@ -97,7 +97,7 @@ namespace osu.Game.Overlays.Toolbar analog.FadeTo(showAnalog ? 1 : 0); }, true); - prefer24HourTime.BindValueChanged(prefer24H => digital.Use24HourDisplay = !prefer24H.NewValue, true); + prefer24HourTime.BindValueChanged(prefer24H => digital.Use24HourDisplay = prefer24H.NewValue, true); } protected override bool OnClick(ClickEvent e) From 0e9248624076d27261c872a3a763ad6051251dfc Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 7 Apr 2022 22:05:04 +0900 Subject: [PATCH 12/14] Update various licence years to 2022 --- Directory.Build.props | 2 +- LICENCE | 2 +- Templates/osu.Game.Templates.csproj | 2 +- osu.Desktop/osu.nuspec | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Directory.Build.props b/Directory.Build.props index 3ab3dc3d13..709545bf1d 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -34,7 +34,7 @@ https://github.com/ppy/osu Automated release. ppy Pty Ltd - Copyright (c) 2021 ppy Pty Ltd + Copyright (c) 2022 ppy Pty Ltd osu game diff --git a/LICENCE b/LICENCE index b5962ad3b2..d3e7537cef 100644 --- a/LICENCE +++ b/LICENCE @@ -1,4 +1,4 @@ -Copyright (c) 2021 ppy Pty Ltd . +Copyright (c) 2022 ppy Pty Ltd . Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/Templates/osu.Game.Templates.csproj b/Templates/osu.Game.Templates.csproj index 4624d3d771..b8c3ad373a 100644 --- a/Templates/osu.Game.Templates.csproj +++ b/Templates/osu.Game.Templates.csproj @@ -8,7 +8,7 @@ https://github.com/ppy/osu/blob/master/Templates https://github.com/ppy/osu Automated release. - Copyright (c) 2021 ppy Pty Ltd + Copyright (c) 2022 ppy Pty Ltd Templates to use when creating a ruleset for consumption in osu!. dotnet-new;templates;osu netstandard2.1 diff --git a/osu.Desktop/osu.nuspec b/osu.Desktop/osu.nuspec index 1757fd7c73..dc1ec17e2c 100644 --- a/osu.Desktop/osu.nuspec +++ b/osu.Desktop/osu.nuspec @@ -11,7 +11,7 @@ false A free-to-win rhythm game. Rhythm is just a *click* away! testing - Copyright (c) 2021 ppy Pty Ltd + Copyright (c) 2022 ppy Pty Ltd en-AU From 11b4c5ca875b8a4f2a61ba8184f5f1b2865809be Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 7 Apr 2022 23:42:42 +0900 Subject: [PATCH 13/14] Fix potential null ref if `UpdateTargetScreen` is called too early --- osu.Game/Skinning/Editor/SkinEditor.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Skinning/Editor/SkinEditor.cs b/osu.Game/Skinning/Editor/SkinEditor.cs index 4602366413..e36d5ca3c6 100644 --- a/osu.Game/Skinning/Editor/SkinEditor.cs +++ b/osu.Game/Skinning/Editor/SkinEditor.cs @@ -204,7 +204,7 @@ namespace osu.Game.Skinning.Editor SelectedComponents.Clear(); // Immediately clear the previous blueprint container to ensure it doesn't try to interact with the old target. - content.Clear(); + content?.Clear(); Scheduler.AddOnce(loadBlueprintContainer); Scheduler.AddOnce(populateSettings); From a616f5bc2a4eb90824ed0d7ae62fcd4a972c7720 Mon Sep 17 00:00:00 2001 From: Salman Ahmed Date: Thu, 7 Apr 2022 19:24:15 +0300 Subject: [PATCH 14/14] Fix regressed digital clock width conditional --- osu.Game/Overlays/Toolbar/DigitalClockDisplay.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Overlays/Toolbar/DigitalClockDisplay.cs b/osu.Game/Overlays/Toolbar/DigitalClockDisplay.cs index 10de35ee50..ac6f563336 100644 --- a/osu.Game/Overlays/Toolbar/DigitalClockDisplay.cs +++ b/osu.Game/Overlays/Toolbar/DigitalClockDisplay.cs @@ -73,7 +73,7 @@ namespace osu.Game.Overlays.Toolbar private void updateMetrics() { - Width = showRuntime || use24HourDisplay ? 66 : 45; // Allows for space for game time up to 99 days (in the padding area since this is quite rare). + Width = showRuntime || !use24HourDisplay ? 66 : 45; // Allows for space for game time up to 99 days (in the padding area since this is quite rare). gameTime.FadeTo(showRuntime ? 1 : 0); }