Skip to content

Commit

Permalink
Merge pull request ppy#30894 from HenintsoaSky/star-fountains-toggle-…
Browse files Browse the repository at this point in the history
…setting

Add a toggle for star fountains during gameplay
  • Loading branch information
smoogipoo authored Nov 28, 2024
2 parents e0fdcaf + c3ac6d7 commit 5d7aafa
Show file tree
Hide file tree
Showing 5 changed files with 76 additions and 1 deletion.
54 changes: 54 additions & 0 deletions osu.Game.Tests/Visual/Menus/TestSceneStarFountain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@

using System.Linq;
using NUnit.Framework;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Utils;
using osu.Game.Configuration;
using osu.Game.Screens.Menu;
using osu.Game.Screens.Play;

Expand Down Expand Up @@ -73,5 +75,57 @@ public void TestGameplay()
((StarFountain)Children[1]).Shoot(-1);
});
}

[Test]
public void TestGameplayStarFountainsSetting()
{
Bindable<bool> starFountainsEnabled = null!;

AddStep("load configuration", () =>
{
var config = new OsuConfigManager(LocalStorage);
starFountainsEnabled = config.GetBindable<bool>(OsuSetting.StarFountains);
});

AddStep("make fountains", () =>
{
Children = new Drawable[]
{
new KiaiGameplayFountains.GameplayStarFountain
{
Anchor = Anchor.BottomLeft,
Origin = Anchor.BottomLeft,
X = 75,
},
new KiaiGameplayFountains.GameplayStarFountain
{
Anchor = Anchor.BottomRight,
Origin = Anchor.BottomRight,
X = -75,
},
};
});

AddStep("enable KiaiStarEffects", () => starFountainsEnabled.Value = true);
AddRepeatStep("activate fountains (enabled)", () =>
{
((KiaiGameplayFountains.GameplayStarFountain)Children[0]).Shoot(1);
((KiaiGameplayFountains.GameplayStarFountain)Children[1]).Shoot(-1);
}, 100);

AddStep("disable KiaiStarEffects", () => starFountainsEnabled.Value = false);
AddRepeatStep("attempt to activate fountains (disabled)", () =>
{
((KiaiGameplayFountains.GameplayStarFountain)Children[0]).Shoot(1);
((KiaiGameplayFountains.GameplayStarFountain)Children[1]).Shoot(-1);
}, 100);

AddStep("re-enable KiaiStarEffects", () => starFountainsEnabled.Value = true);
AddRepeatStep("activate fountains (re-enabled)", () =>
{
((KiaiGameplayFountains.GameplayStarFountain)Children[0]).Shoot(1);
((KiaiGameplayFountains.GameplayStarFountain)Children[1]).Shoot(-1);
}, 100);
}
}
}
2 changes: 2 additions & 0 deletions osu.Game/Configuration/OsuConfigManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ protected override void InitialiseDefaults()
SetDefault(OsuSetting.LightenDuringBreaks, true);

SetDefault(OsuSetting.HitLighting, true);
SetDefault(OsuSetting.StarFountains, true);

SetDefault(OsuSetting.HUDVisibilityMode, HUDVisibilityMode.Always);
SetDefault(OsuSetting.ShowHealthDisplayWhenCantFail, true);
Expand Down Expand Up @@ -414,6 +415,7 @@ public enum OsuSetting
NotifyOnPrivateMessage,
UIHoldActivationDelay,
HitLighting,
StarFountains,
MenuBackgroundSource,
GameplayDisableWinKey,
SeasonalBackgroundMode,
Expand Down
5 changes: 5 additions & 0 deletions osu.Game/Localisation/GameplaySettingsStrings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,11 @@ public static class GameplaySettingsStrings
/// </summary>
public static LocalisableString FadePlayfieldWhenHealthLow => new TranslatableString(getKey(@"fade_playfield_when_health_low"), @"Fade playfield to red when health is low");

/// <summary>
/// "Star fountains"
/// </summary>
public static LocalisableString StarFountains => new TranslatableString(getKey(@"star_fountains"), @"Star fountains");

/// <summary>
/// "Always show key overlay"
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ private void load(OsuConfigManager config)
LabelText = GraphicsSettingsStrings.HitLighting,
Current = config.GetBindable<bool>(OsuSetting.HitLighting)
},
new SettingsCheckbox
{
LabelText = GameplaySettingsStrings.StarFountains,
Current = config.GetBindable<bool>(OsuSetting.StarFountains)
},
};
}
}
Expand Down
11 changes: 10 additions & 1 deletion osu.Game/Screens/Play/KiaiGameplayFountains.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@
using System;
using osu.Framework.Allocation;
using osu.Framework.Audio.Track;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Utils;
using osu.Game.Configuration;
using osu.Game.Beatmaps.ControlPoints;
using osu.Game.Graphics.Containers;
using osu.Game.Screens.Menu;
Expand All @@ -18,9 +20,13 @@ public partial class KiaiGameplayFountains : BeatSyncedContainer
private StarFountain leftFountain = null!;
private StarFountain rightFountain = null!;

private Bindable<bool> kiaiStarFountains = null!;

[BackgroundDependencyLoader]
private void load()
private void load(OsuConfigManager config)
{
kiaiStarFountains = config.GetBindable<bool>(OsuSetting.StarFountains);

RelativeSizeAxes = Axes.Both;

Children = new[]
Expand Down Expand Up @@ -48,6 +54,9 @@ protected override void OnNewBeat(int beatIndex, TimingControlPoint timingPoint,
{
base.OnNewBeat(beatIndex, timingPoint, effectPoint, amplitudes);

if (!kiaiStarFountains.Value)
return;

if (effectPoint.KiaiMode && !isTriggered)
{
bool isNearEffectPoint = Math.Abs(BeatSyncSource.Clock.CurrentTime - effectPoint.Time) < 500;
Expand Down

0 comments on commit 5d7aafa

Please sign in to comment.