1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-13 18:47:27 +08:00

Add support for tracking settings changes

This commit is contained in:
Dean Herbert 2023-09-27 19:16:31 +09:00
parent 192eb541c0
commit 6e602929a4

View File

@ -18,6 +18,7 @@ using osu.Framework.Bindables;
using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Graphics.Textures; using osu.Framework.Graphics.Textures;
using osu.Framework.Localisation; using osu.Framework.Localisation;
using osu.Game.Configuration;
namespace osu.Game.Rulesets.UI namespace osu.Game.Rulesets.UI
{ {
@ -44,6 +45,9 @@ namespace osu.Game.Rulesets.UI
get => mod; get => mod;
set set
{ {
if (mod == value)
return;
mod = value; mod = value;
if (IsLoaded) if (IsLoaded)
@ -62,6 +66,8 @@ namespace osu.Game.Rulesets.UI
private Container extendedContent; private Container extendedContent;
private ModSettingChangeTracker modSettingsChangeTracker;
/// <summary> /// <summary>
/// Construct a new instance. /// Construct a new instance.
/// </summary> /// </summary>
@ -123,7 +129,7 @@ namespace osu.Game.Rulesets.UI
Anchor = Anchor.CentreLeft, Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft, Origin = Anchor.CentreLeft,
Size = new Vector2(120, 55), Size = new Vector2(120, 55),
X = size - 23, X = size - 22,
Children = new Drawable[] Children = new Drawable[]
{ {
extendedBackground = new Sprite extendedBackground = new Sprite
@ -156,6 +162,14 @@ namespace osu.Game.Rulesets.UI
private void updateMod(IMod value) private void updateMod(IMod value)
{ {
modSettingsChangeTracker?.Dispose();
if (value is Mod actualMod)
{
modSettingsChangeTracker = new ModSettingChangeTracker(new[] { actualMod });
modSettingsChangeTracker.SettingChanged = _ => updateMod(actualMod);
}
modAcronym.Text = value.Acronym; modAcronym.Text = value.Acronym;
modIcon.Icon = value.Icon ?? FontAwesome.Solid.Question; modIcon.Icon = value.Icon ?? FontAwesome.Solid.Question;
@ -185,5 +199,11 @@ namespace osu.Game.Rulesets.UI
extendedText.Colour = background.Colour = Selected.Value ? backgroundColour.Lighten(0.2f) : backgroundColour; extendedText.Colour = background.Colour = Selected.Value ? backgroundColour.Lighten(0.2f) : backgroundColour;
extendedBackground.Colour = Selected.Value ? backgroundColour.Darken(2.4f) : backgroundColour.Darken(2.8f); extendedBackground.Colour = Selected.Value ? backgroundColour.Darken(2.4f) : backgroundColour.Darken(2.8f);
} }
protected override void Dispose(bool isDisposing)
{
base.Dispose(isDisposing);
modSettingsChangeTracker?.Dispose();
}
} }
} }