Convert all static getter-only properties to static readonly fields

This commit is contained in:
Salman Ahmed 2020-04-08 14:23:29 +03:00
parent 7f3ad6d5be
commit d27d8671ab
4 changed files with 13 additions and 13 deletions

View File

@ -44,7 +44,7 @@ namespace osu.Game.Rulesets.Catch.Tests
}, false, false, false); }, false, false, false);
}); });
AddAssert("hyper-dash fruit has default colour", () => checkLegacyFruitHyperDashColour(drawableFruit, Catcher.DefaultHyperDashColour)); AddAssert("hyper-dash fruit has default colour", () => checkLegacyFruitHyperDashColour(drawableFruit, Catcher.DEFAULT_HYPER_DASH_COLOUR));
} }
[TestCase(true)] [TestCase(true)]
@ -66,7 +66,7 @@ namespace osu.Game.Rulesets.Catch.Tests
}, customCatcherHyperDashColour, false, true); }, customCatcherHyperDashColour, false, true);
}); });
AddAssert("hyper-dash fruit use fruit colour from skin", () => checkLegacyFruitHyperDashColour(drawableFruit, TestSkin.CustomHyperDashFruitColour)); AddAssert("hyper-dash fruit use fruit colour from skin", () => checkLegacyFruitHyperDashColour(drawableFruit, TestSkin.CUSTOM_HYPER_DASH_FRUIT_COLOUR));
} }
[Test] [Test]
@ -88,7 +88,7 @@ namespace osu.Game.Rulesets.Catch.Tests
}, true, false, false); }, true, false, false);
}); });
AddAssert("hyper-dash fruit colour falls back to catcher colour from skin", () => checkLegacyFruitHyperDashColour(drawableFruit, TestSkin.CustomHyperDashColour)); AddAssert("hyper-dash fruit colour falls back to catcher colour from skin", () => checkLegacyFruitHyperDashColour(drawableFruit, TestSkin.CUSTOM_HYPER_DASH_COLOUR));
} }
private Drawable setupSkinHierarchy(Drawable child, bool customCatcherColour, bool customAfterColour, bool customFruitColour) private Drawable setupSkinHierarchy(Drawable child, bool customCatcherColour, bool customAfterColour, bool customFruitColour)
@ -108,21 +108,21 @@ namespace osu.Game.Rulesets.Catch.Tests
private class TestSkin : LegacySkin private class TestSkin : LegacySkin
{ {
public static Color4 CustomHyperDashColour { get; } = Color4.Goldenrod; public static readonly Color4 CUSTOM_HYPER_DASH_COLOUR = Color4.Goldenrod;
public static Color4 CustomHyperDashFruitColour { get; } = Color4.Cyan; public static readonly Color4 CUSTOM_HYPER_DASH_AFTER_COLOUR = Color4.Lime;
public static Color4 CustomHyperDashAfterColour { get; } = Color4.Lime; public static readonly Color4 CUSTOM_HYPER_DASH_FRUIT_COLOUR = Color4.Cyan;
public TestSkin(bool customCatcherColour, bool customAfterColour, bool customFruitColour) public TestSkin(bool customCatcherColour, bool customAfterColour, bool customFruitColour)
: base(new SkinInfo(), null, null, string.Empty) : base(new SkinInfo(), null, null, string.Empty)
{ {
if (customCatcherColour) if (customCatcherColour)
Configuration.CustomColours[CatchSkinColour.HyperDash.ToString()] = CustomHyperDashColour; Configuration.CustomColours[CatchSkinColour.HyperDash.ToString()] = CUSTOM_HYPER_DASH_COLOUR;
if (customAfterColour) if (customAfterColour)
Configuration.CustomColours[CatchSkinColour.HyperDashAfterImage.ToString()] = CustomHyperDashAfterColour; Configuration.CustomColours[CatchSkinColour.HyperDashAfterImage.ToString()] = CUSTOM_HYPER_DASH_AFTER_COLOUR;
if (customFruitColour) if (customFruitColour)
Configuration.CustomColours[CatchSkinColour.HyperDashFruit.ToString()] = CustomHyperDashFruitColour; Configuration.CustomColours[CatchSkinColour.HyperDashFruit.ToString()] = CUSTOM_HYPER_DASH_FRUIT_COLOUR;
} }
} }
} }

View File

@ -68,7 +68,7 @@ namespace osu.Game.Rulesets.Catch.Objects.Drawables
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
Anchor = Anchor.Centre, Anchor = Anchor.Centre,
Origin = Anchor.Centre, Origin = Anchor.Centre,
BorderColour = Catcher.DefaultHyperDashColour, BorderColour = Catcher.DEFAULT_HYPER_DASH_COLOUR,
BorderThickness = 12f * RADIUS_ADJUST, BorderThickness = 12f * RADIUS_ADJUST,
Children = new Drawable[] Children = new Drawable[]
{ {
@ -78,7 +78,7 @@ namespace osu.Game.Rulesets.Catch.Objects.Drawables
Alpha = 0.3f, Alpha = 0.3f,
Blending = BlendingParameters.Additive, Blending = BlendingParameters.Additive,
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
Colour = Catcher.DefaultHyperDashColour, Colour = Catcher.DEFAULT_HYPER_DASH_COLOUR,
} }
} }
}); });

View File

@ -15,6 +15,6 @@ namespace osu.Game.Rulesets.Catch.Skinning
public static IBindable<Color4> GetHyperDashFruitColour(this ISkin skin) public static IBindable<Color4> GetHyperDashFruitColour(this ISkin skin)
=> skin.GetConfig<CatchSkinColour, Color4>(CatchSkinColour.HyperDashFruit) ?? => skin.GetConfig<CatchSkinColour, Color4>(CatchSkinColour.HyperDashFruit) ??
skin.GetConfig<CatchSkinColour, Color4>(CatchSkinColour.HyperDash) ?? skin.GetConfig<CatchSkinColour, Color4>(CatchSkinColour.HyperDash) ??
new Bindable<Color4>(Catcher.DefaultHyperDashColour); new Bindable<Color4>(Catcher.DEFAULT_HYPER_DASH_COLOUR);
} }
} }

View File

@ -21,7 +21,7 @@ namespace osu.Game.Rulesets.Catch.UI
{ {
public class Catcher : Container, IKeyBindingHandler<CatchAction> public class Catcher : Container, IKeyBindingHandler<CatchAction>
{ {
public static Color4 DefaultHyperDashColour { get; } = Color4.Red; public static readonly Color4 DEFAULT_HYPER_DASH_COLOUR = Color4.Red;
/// <summary> /// <summary>
/// Whether we are hyper-dashing or not. /// Whether we are hyper-dashing or not.