Skip to content

Commit

Permalink
Move hit lighting into ruleset config.
Browse files Browse the repository at this point in the history
  • Loading branch information
naoei committed Apr 24, 2022
1 parent 6a5a0c3 commit 9b07a5d
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 9 deletions.
20 changes: 14 additions & 6 deletions osu.Game.Rulesets.Tau.Tests/TestSceneDrawableJudgement.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,28 @@
using System.Linq;
using NUnit.Framework;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Extensions;
using osu.Framework.Extensions.ObjectExtensions;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Pooling;
using osu.Framework.Testing;
using osu.Game.Configuration;
using osu.Game.Rulesets.Judgements;
using osu.Game.Rulesets.Objects;
using osu.Game.Rulesets.Scoring;
using osu.Game.Rulesets.Tau.Configuration;
using osu.Game.Rulesets.Tau.Objects.Drawables;
using osu.Game.Skinning;

namespace osu.Game.Rulesets.Tau.Tests
{
public class TestSceneDrawableJudgement : TauSkinnableTestScene
{
[Resolved]
private OsuConfigManager config { get; set; }

private readonly List<DrawablePool<TestDrawableTauJudgement>> pools;

private readonly BindableBool hitLighting = new BindableBool();

public TestSceneDrawableJudgement()
{
pools = new List<DrawablePool<TestDrawableTauJudgement>>();
Expand All @@ -34,10 +35,17 @@ public TestSceneDrawableJudgement()
}
}

[BackgroundDependencyLoader]
private void load()
{
var config = (TauRulesetConfigManager)RulesetConfigs.GetConfigFor(Ruleset.Value.CreateInstance()).AsNonNull();
config.BindWith(TauRulesetSettings.HitLighting, hitLighting);
}

[Test]
public void TestHitLightingDisabled()
{
AddStep("hit Lighting disabled", () => config.SetValue(OsuSetting.HitLighting, false));
AddStep("hit Lighting disabled", () => hitLighting.Value = false);

showResult(HitResult.Great);

Expand All @@ -49,7 +57,7 @@ public void TestHitLightingDisabled()
[Test]
public void TestHitLightingEnabled()
{
AddStep("hit Lighting enabled", () => config.SetValue(OsuSetting.HitLighting, true));
AddStep("hit Lighting enabled", () => hitLighting.Value = true);

showResult(HitResult.Great);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ protected override void InitialiseDefaults()
base.InitialiseDefaults();

SetDefault(TauRulesetSettings.ShowVisualizer, true);
SetDefault(TauRulesetSettings.HitLighting, true);
SetDefault(TauRulesetSettings.PlayfieldDim, 0.3f, 0, 1, 0.01f);
SetDefault(TauRulesetSettings.BeatSize, 16f, 10, 25, 1f);
SetDefault(TauRulesetSettings.KiaiEffect, KiaiType.Turbulent);
Expand All @@ -24,6 +25,7 @@ protected override void InitialiseDefaults()
public enum TauRulesetSettings
{
ShowVisualizer,
HitLighting,
PlayfieldDim,
BeatSize,
KiaiEffect
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
using System.Linq;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Game.Configuration;
using osu.Game.Rulesets.Judgements;
using osu.Game.Rulesets.Scoring;
using osu.Game.Rulesets.Tau.Configuration;
using osu.Game.Rulesets.Tau.UI;
using osuTK;

Expand All @@ -14,7 +14,7 @@ public class DrawableTauJudgement : DrawableJudgement
protected SkinnableLighting Lighting { get; private set; }

[Resolved]
private OsuConfigManager config { get; set; }
private TauRulesetConfigManager config { get; set; }

[Resolved(canBeNull: true)]
private TauPlayfield playfield { get; set; }
Expand Down Expand Up @@ -58,7 +58,7 @@ protected override void PrepareForUse()

protected override void ApplyHitAnimations()
{
var hitLightingEnabled = config.Get<bool>(OsuSetting.HitLighting);
var hitLightingEnabled = config.Get<bool>(TauRulesetSettings.HitLighting);

Lighting.Alpha = 0;

Expand Down
6 changes: 6 additions & 0 deletions osu.Game.Rulesets.Tau/UI/TauSettingsSubsection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@ private void load()
LabelText = "Show Visualizer",
Current = config.GetBindable<bool>(TauRulesetSettings.ShowVisualizer)
},
new SettingsCheckbox
{
LabelText = "Hit lighting",
Current = config.GetBindable<bool>(TauRulesetSettings.HitLighting),
WarningText = "This has been moved into the ruleset settings to reduce the chance of Tau breaking."
},
new SettingsSlider<float>
{
LabelText = "Playfield dim",
Expand Down

0 comments on commit 9b07a5d

Please sign in to comment.