1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-29 05:52:56 +08:00

Made the changes requested

This commit is contained in:
Vidalee 2018-05-06 12:38:25 +02:00
parent 1c1d58e2cb
commit 393c01ba90
3 changed files with 48 additions and 43 deletions

View File

@ -15,34 +15,14 @@ using osu.Framework.Configuration;
namespace osu.Game.Rulesets.Osu.Mods namespace osu.Game.Rulesets.Osu.Mods
{ {
public class OsuModHidden : ModHidden, IApplicableToDrawableHitObjects, IReadFromConfig public class OsuModHidden : ModHidden, IApplicableToDrawableHitObjects
{ {
public override string Description => @"Play with no approach circles and fading circles/sliders."; public override string Description => @"Play with no approach circles and fading circles/sliders.";
public override double ScoreMultiplier => 1.06; public override double ScoreMultiplier => 1.06;
private const double fade_in_duration_multiplier = 0.4; private const double fade_in_duration_multiplier = 0.4;
private const double fade_out_duration_multiplier = 0.3; private const double fade_out_duration_multiplier = 0.3;
private Bindable<bool> increaseFirstObjectVisibility = new Bindable<bool>();
public void ReadFromConfig(OsuConfigManager config) protected override void ApplyHiddenState(DrawableHitObject drawable, ArmedState state)
{
increaseFirstObjectVisibility = config.GetBindable<bool>(OsuSetting.IncreaseFirstObjectVisibility);
}
public void ApplyToDrawableHitObjects(IEnumerable<DrawableHitObject> drawables)
{
foreach (var d in drawables.OfType<DrawableOsuHitObject>())
{
//Don't hide the first object if the increaseFirstObjectVisibility is true ("drawables" are in a reverse order -> Last() )
if (d == drawables.Last() && increaseFirstObjectVisibility) 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;
}
}
protected void ApplyHiddenState(DrawableHitObject drawable, ArmedState state)
{ {
if (!(drawable is DrawableOsuHitObject d)) if (!(drawable is DrawableOsuHitObject d))
return; return;

View File

@ -1,16 +1,42 @@
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>. // Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using osu.Framework.Allocation;
using osu.Framework.Configuration;
using osu.Game.Configuration;
using osu.Game.Graphics; using osu.Game.Graphics;
using osu.Game.Rulesets.Objects.Drawables;
using System.Collections.Generic;
using System.Linq;
namespace osu.Game.Rulesets.Mods namespace osu.Game.Rulesets.Mods
{ {
public abstract class ModHidden : Mod public abstract class ModHidden : Mod, IReadFromConfig
{ {
public override string Name => "Hidden"; public override string Name => "Hidden";
public override string ShortenedName => "HD"; public override string ShortenedName => "HD";
public override FontAwesome Icon => FontAwesome.fa_osu_mod_hidden; public override FontAwesome Icon => FontAwesome.fa_osu_mod_hidden;
public override ModType Type => ModType.DifficultyIncrease; public override ModType Type => ModType.DifficultyIncrease;
public override bool Ranked => true; public override bool Ranked => true;
protected Bindable<bool> increaseFirstObjectVisibility = new Bindable<bool>();
public void ReadFromConfig(OsuConfigManager config)
{
increaseFirstObjectVisibility = config.GetBindable<bool>(OsuSetting.IncreaseFirstObjectVisibility);
}
public void ApplyToDrawableHitObjects(IEnumerable<DrawableHitObject> drawables)
{
foreach (var d in drawables.OfType<DrawableHitObject>())
{
if (d == drawables.Last() && increaseFirstObjectVisibility)
return;
d.ApplyCustomUpdateState += ApplyHiddenState;
}
}
protected virtual void ApplyHiddenState(DrawableHitObject hitObject, ArmedState state) { }
} }
} }

View File

@ -67,6 +67,7 @@ namespace osu.Game.Rulesets.UI
/// </summary> /// </summary>
public readonly CursorContainer Cursor; public readonly CursorContainer Cursor;
protected readonly Ruleset Ruleset; protected readonly Ruleset Ruleset;
private IRulesetConfigManager rulesetConfig; private IRulesetConfigManager rulesetConfig;
@ -93,7 +94,6 @@ namespace osu.Game.Rulesets.UI
private void load(OnScreenDisplay onScreenDisplay, SettingsStore settings) private void load(OnScreenDisplay onScreenDisplay, SettingsStore settings)
{ {
this.onScreenDisplay = onScreenDisplay; this.onScreenDisplay = onScreenDisplay;
rulesetConfig = CreateConfig(Ruleset, settings); rulesetConfig = CreateConfig(Ruleset, settings);
if (rulesetConfig != null) if (rulesetConfig != null)
@ -101,6 +101,7 @@ namespace osu.Game.Rulesets.UI
dependencies.Cache(rulesetConfig); dependencies.Cache(rulesetConfig);
onScreenDisplay?.BeginTracking(this, rulesetConfig); onScreenDisplay?.BeginTracking(this, rulesetConfig);
} }
} }
public abstract ScoreProcessor CreateScoreProcessor(); public abstract ScoreProcessor CreateScoreProcessor();
@ -130,7 +131,6 @@ namespace osu.Game.Rulesets.UI
HasReplayLoaded.Value = ReplayInputManager.ReplayInputHandler != null; HasReplayLoaded.Value = ReplayInputManager.ReplayInputHandler != null;
} }
/// <summary> /// <summary>
/// Creates the cursor. May be null if the <see cref="RulesetContainer"/> doesn't provide a custom cursor. /// Creates the cursor. May be null if the <see cref="RulesetContainer"/> doesn't provide a custom cursor.
/// </summary> /// </summary>
@ -167,6 +167,7 @@ namespace osu.Game.Rulesets.UI
public abstract class RulesetContainer<TObject> : RulesetContainer public abstract class RulesetContainer<TObject> : RulesetContainer
where TObject : HitObject where TObject : HitObject
{ {
public event Action<Judgement> OnJudgement; public event Action<Judgement> OnJudgement;
public event Action<Judgement> OnJudgementRemoved; public event Action<Judgement> OnJudgementRemoved;
@ -202,11 +203,8 @@ namespace osu.Game.Rulesets.UI
private IEnumerable<Mod> mods; private IEnumerable<Mod> mods;
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(OsuConfigManager osuConfig) private void load(OsuConfigManager config)
{ {
// Apply mods
applyMods(Mods, osuConfig);
KeyBindingInputManager.Add(content = new Container KeyBindingInputManager.Add(content = new Container
{ {
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
@ -218,7 +216,11 @@ namespace osu.Game.Rulesets.UI
if (Cursor != null) if (Cursor != null)
KeyBindingInputManager.Add(Cursor); KeyBindingInputManager.Add(Cursor);
// Apply mods
applyMods(Mods, config);
loadObjects(); loadObjects();
} }
/// <summary> /// <summary>
@ -235,7 +237,6 @@ namespace osu.Game.Rulesets.UI
WorkingBeatmap = workingBeatmap; WorkingBeatmap = workingBeatmap;
IsForCurrentRuleset = isForCurrentRuleset; IsForCurrentRuleset = isForCurrentRuleset;
// ReSharper disable once PossibleNullReferenceException
Mods = workingBeatmap.Mods.Value; Mods = workingBeatmap.Mods.Value;
RelativeSizeAxes = Axes.Both; RelativeSizeAxes = Axes.Both;
@ -269,13 +270,10 @@ namespace osu.Game.Rulesets.UI
KeyBindingInputManager.RelativeSizeAxes = Axes.Both; KeyBindingInputManager.RelativeSizeAxes = Axes.Both;
// Add mods, should always be the last thing applied to give full control to mods // Add mods, should always be the last thing applied to give full control to mods
// Mods are now added in the load() method because we need the OsuConfigManager // Mods are now added in the load() method, this method is still executed after the constructor
// for the IReadFromConfig implementations. This method is still executed after the constructor, // so they are still added in last
// so the mods are still added in last
} }
/// <summary> /// <summary>
/// Applies the active mods to this RulesetContainer. /// Applies the active mods to this RulesetContainer.
/// </summary> /// </summary>
@ -283,17 +281,18 @@ namespace osu.Game.Rulesets.UI
private void applyMods(IEnumerable<Mod> mods, OsuConfigManager config) private void applyMods(IEnumerable<Mod> mods, OsuConfigManager config)
{ {
if(mods == null) if(mods == null)
{
return; return;
}
foreach (var mod in mods.OfType<IReadFromConfig>())
mod.ReadFromConfig(config);
foreach (var mod in mods.OfType<IApplicableToHitObject<TObject>>()) foreach (var mod in mods.OfType<IApplicableToHitObject<TObject>>())
foreach (var obj in Beatmap.HitObjects) foreach (var obj in Beatmap.HitObjects)
mod.ApplyToHitObject(obj); mod.ApplyToHitObject(obj);
foreach (var mod in mods.OfType<IApplicableToRulesetContainer<TObject>>()) foreach (var mod in mods.OfType<IApplicableToRulesetContainer<TObject>>())
mod.ApplyToRulesetContainer(this); mod.ApplyToRulesetContainer(this);
foreach (var mod in mods.OfType<IReadFromConfig>())
mod.ReadFromConfig(config);
} }
public override void SetReplay(Replay replay) public override void SetReplay(Replay replay)
@ -301,7 +300,7 @@ namespace osu.Game.Rulesets.UI
base.SetReplay(replay); base.SetReplay(replay);
if (ReplayInputManager?.ReplayInputHandler != null) if (ReplayInputManager?.ReplayInputHandler != null)
ReplayInputManager.ReplayInputHandler.GamefieldToScreenSpace = Playfield.GamefieldToScreenSpace; ReplayInputManager.ReplayInputHandler.ToScreenSpace = input => Playfield.ScaledContent.ToScreenSpace(input);
} }
/// <summary> /// <summary>