1
0
mirror of https://github.com/ppy/osu.git synced 2025-03-24 16:17:23 +08:00

Added setting to not hide the first object in Hidden mod

This commit is contained in:
Vidalee 2018-03-11 21:02:14 +01:00
parent 5727965431
commit eed0f3a1de
6 changed files with 102 additions and 32 deletions

View File

@ -7,32 +7,51 @@ using System.Linq;
using osu.Framework.Graphics;
using osu.Game.Rulesets.Mods;
using osu.Game.Rulesets.Objects.Drawables;
using osu.Game.Rulesets.Objects.Types;
using osu.Game.Rulesets.Osu.Objects;
using osu.Game.Rulesets.Osu.Objects.Drawables;
using osu.Game.Rulesets.Objects.Types;
using osu.Game.Configuration;
namespace osu.Game.Rulesets.Osu.Mods
{
public class OsuModHidden : ModHidden, IApplicableToDrawableHitObjects
public class OsuModHidden : ModHidden, IApplicableToDrawableHitObjects, IReadFromConfig
{
public override string Description => @"Play with no approach circles and fading notes for a slight score advantage.";
public override double ScoreMultiplier => 1.06;
private const double fade_in_duration_multiplier = 0.4;
private const double fade_out_duration_multiplier = 0.3;
private bool IncreaseFirstObjectVisibility = true;
private IEnumerable<DrawableHitObject> drawables;
public void ApplyToDrawableHitObjects(IEnumerable<DrawableHitObject> drawables)
private void applyMod()
{
foreach (var d in drawables.OfType<DrawableOsuHitObject>())
if (IncreaseFirstObjectVisibility)
{
d.ApplyCustomUpdateState += ApplyHiddenState;
foreach (var d in drawables.OfType<DrawableOsuHitObject>())
{
//Don't hide the first object
if (d.ChildID == 1) continue;
d.ApplyCustomUpdateState += ApplyHiddenState;
d.HitObject.TimeFadein = d.HitObject.TimePreempt * fade_in_duration_multiplier;
foreach (var h in d.HitObject.NestedHitObjects.OfType<OsuHitObject>())
h.TimeFadein = h.TimePreempt * fade_in_duration_multiplier;
d.HitObject.TimeFadein = d.HitObject.TimePreempt * fade_in_duration_multiplier;
foreach (var h in d.HitObject.NestedHitObjects.OfType<OsuHitObject>())
h.TimeFadein = h.TimePreempt * fade_in_duration_multiplier;
}
}
else
{
foreach (var d in drawables.OfType<DrawableOsuHitObject>())
{
d.ApplyCustomUpdateState += ApplyHiddenState;
d.HitObject.TimeFadein = d.HitObject.TimePreempt * fade_in_duration_multiplier;
foreach (var h in d.HitObject.NestedHitObjects.OfType<OsuHitObject>())
h.TimeFadein = h.TimePreempt * fade_in_duration_multiplier;
}
}
}
protected void ApplyHiddenState(DrawableHitObject drawable, ArmedState state)
{
if (!(drawable is DrawableOsuHitObject d))
@ -83,5 +102,18 @@ namespace osu.Game.Rulesets.Osu.Mods
break;
}
}
public void ApplyToConfig(OsuConfigManager config)
{
IncreaseFirstObjectVisibility = config.GetBindable<bool>(OsuSetting.IncreaseFirstObjectVisibility);
//This starts the process of applying the mod effects. We start it here since this is the last void called.
applyMod();
}
public void ApplyToDrawableHitObjects(IEnumerable<DrawableHitObject> drawables)
{
this.drawables = drawables;
}
}
}

View File

@ -78,6 +78,8 @@ namespace osu.Game.Configuration
Set(OsuSetting.SpeedChangeVisualisation, SpeedChangeVisualisationMethod.Sequential);
Set(OsuSetting.IncreaseFirstObjectVisibility, true);
// Update
Set(OsuSetting.ReleaseStream, ReleaseStream.Lazer);
@ -125,6 +127,7 @@ namespace osu.Game.Configuration
Version,
ShowConvertedBeatmaps,
SpeedChangeVisualisation,
Skin
Skin,
IncreaseFirstObjectVisibility
}
}

View File

@ -38,6 +38,11 @@ namespace osu.Game.Overlays.Settings.Sections.Gameplay
LabelText = "Always show key overlay",
Bindable = config.GetBindable<bool>(OsuSetting.KeyOverlay)
},
new SettingsCheckbox
{
LabelText = "Increase the first object's visibility in \"Hidden\" mod",
Bindable = config.GetBindable<bool>(OsuSetting.IncreaseFirstObjectVisibility)
},
};
}
}

View File

@ -0,0 +1,15 @@
using osu.Framework.Allocation;
using osu.Game.Configuration;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace osu.Game.Rulesets.Mods
{
public interface IReadFromConfig
{
void ApplyToConfig(OsuConfigManager config);
}
}

View File

@ -67,6 +67,7 @@ namespace osu.Game.Rulesets.UI
/// </summary>
public readonly CursorContainer Cursor;
protected readonly Ruleset Ruleset;
private IRulesetConfigManager rulesetConfig;
@ -89,11 +90,9 @@ namespace osu.Game.Rulesets.UI
Cursor = CreateCursor();
}
[BackgroundDependencyLoader(true)]
[BackgroundDependencyLoader]
private void load(OnScreenDisplay onScreenDisplay, SettingsStore settings)
{
this.onScreenDisplay = onScreenDisplay;
rulesetConfig = CreateConfig(Ruleset, settings);
if (rulesetConfig != null)
@ -101,6 +100,7 @@ namespace osu.Game.Rulesets.UI
dependencies.Cache(rulesetConfig);
onScreenDisplay?.BeginTracking(this, rulesetConfig);
}
}
public abstract ScoreProcessor CreateScoreProcessor();
@ -167,6 +167,7 @@ namespace osu.Game.Rulesets.UI
public abstract class RulesetContainer<TObject> : RulesetContainer
where TObject : HitObject
{
public event Action<Judgement> OnJudgement;
public event Action<Judgement> OnJudgementRemoved;
@ -195,10 +196,34 @@ namespace osu.Game.Rulesets.UI
/// </summary>
public readonly bool IsForCurrentRuleset;
public override ScoreProcessor CreateScoreProcessor() => new ScoreProcessor<TObject>(this);
protected override Container<Drawable> Content => content;
private Container content;
private IEnumerable<Mod> mods;
[BackgroundDependencyLoader]
private void load(OsuConfigManager config)
{
KeyBindingInputManager.Add(content = new Container
{
RelativeSizeAxes = Axes.Both,
});
AddInternal(KeyBindingInputManager);
KeyBindingInputManager.Add(Playfield);
if (Cursor != null)
KeyBindingInputManager.Add(Cursor);
loadObjects();
// Apply mods
applyMods(Mods, config);
}
/// <summary>
/// Whether to assume the beatmap passed into this <see cref="RulesetContainer{TObject}"/> is for the current ruleset.
@ -247,34 +272,19 @@ namespace osu.Game.Rulesets.UI
KeyBindingInputManager.RelativeSizeAxes = Axes.Both;
// Add mods, should always be the last thing applied to give full control to mods
applyMods(Mods);
// Mods are now added in the load() method, this method is still executed after the constructor
// so they are still added in last
}
[BackgroundDependencyLoader]
private void load()
{
KeyBindingInputManager.Add(content = new Container
{
RelativeSizeAxes = Axes.Both,
});
AddInternal(KeyBindingInputManager);
KeyBindingInputManager.Add(Playfield);
if (Cursor != null)
KeyBindingInputManager.Add(Cursor);
loadObjects();
}
/// <summary>
/// Applies the active mods to this RulesetContainer.
/// </summary>
/// <param name="mods"></param>
private void applyMods(IEnumerable<Mod> mods)
private void applyMods(IEnumerable<Mod> mods, OsuConfigManager config)
{
if (mods == null)
return;
foreach (var mod in mods.OfType<IApplicableToHitObject<TObject>>())
foreach (var obj in Beatmap.HitObjects)
@ -282,6 +292,10 @@ namespace osu.Game.Rulesets.UI
foreach (var mod in mods.OfType<IApplicableToRulesetContainer<TObject>>())
mod.ApplyToRulesetContainer(this);
foreach (var mod in mods.OfType<IReadFromConfig>())
mod.ApplyToConfig(config);
}
public override void SetReplay(Replay replay)

View File

@ -372,6 +372,7 @@
<Compile Include="Overlays\Social\SocialListPanel.cs" />
<Compile Include="Overlays\Social\SocialPanel.cs" />
<Compile Include="Rulesets\Mods\IApplicableToDrawableHitObject.cs" />
<Compile Include="Rulesets\Mods\IReadFromConfig.cs" />
<Compile Include="Rulesets\Objects\HitWindows.cs" />
<Compile Include="Rulesets\Replays\Legacy\LegacyReplayFrame.cs" />
<Compile Include="Rulesets\Replays\Legacy\ReplayButtonState.cs" />