1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-27 00:23:01 +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
{
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 double ScoreMultiplier => 1.06;
private const double fade_in_duration_multiplier = 0.4;
private const double fade_out_duration_multiplier = 0.3;
private 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<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)
protected override void ApplyHiddenState(DrawableHitObject drawable, ArmedState state)
{
if (!(drawable is DrawableOsuHitObject d))
return;

View File

@ -1,16 +1,42 @@
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
// 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.Rulesets.Objects.Drawables;
using System.Collections.Generic;
using System.Linq;
namespace osu.Game.Rulesets.Mods
{
public abstract class ModHidden : Mod
public abstract class ModHidden : Mod, IReadFromConfig
{
public override string Name => "Hidden";
public override string ShortenedName => "HD";
public override FontAwesome Icon => FontAwesome.fa_osu_mod_hidden;
public override ModType Type => ModType.DifficultyIncrease;
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

@ -66,6 +66,7 @@ namespace osu.Game.Rulesets.UI
/// The cursor provided by this <see cref="RulesetContainer"/>. May be null if no cursor is provided.
/// </summary>
public readonly CursorContainer Cursor;
protected readonly Ruleset Ruleset;
@ -88,12 +89,11 @@ namespace osu.Game.Rulesets.UI
Cursor = CreateCursor();
}
[BackgroundDependencyLoader(true)]
private void load(OnScreenDisplay onScreenDisplay, SettingsStore settings)
{
this.onScreenDisplay = onScreenDisplay;
rulesetConfig = CreateConfig(Ruleset, settings);
if (rulesetConfig != null)
@ -101,6 +101,7 @@ namespace osu.Game.Rulesets.UI
dependencies.Cache(rulesetConfig);
onScreenDisplay?.BeginTracking(this, rulesetConfig);
}
}
public abstract ScoreProcessor CreateScoreProcessor();
@ -130,7 +131,6 @@ namespace osu.Game.Rulesets.UI
HasReplayLoaded.Value = ReplayInputManager.ReplayInputHandler != null;
}
/// <summary>
/// Creates the cursor. May be null if the <see cref="RulesetContainer"/> doesn't provide a custom cursor.
/// </summary>
@ -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;
@ -194,7 +195,7 @@ namespace osu.Game.Rulesets.UI
/// Whether the specified beatmap is assumed to be specific to the current ruleset.
/// </summary>
public readonly bool IsForCurrentRuleset;
public override ScoreProcessor CreateScoreProcessor() => new ScoreProcessor<TObject>(this);
protected override Container<Drawable> Content => content;
@ -202,11 +203,8 @@ namespace osu.Game.Rulesets.UI
private IEnumerable<Mod> mods;
[BackgroundDependencyLoader]
private void load(OsuConfigManager osuConfig)
private void load(OsuConfigManager config)
{
// Apply mods
applyMods(Mods, osuConfig);
KeyBindingInputManager.Add(content = new Container
{
RelativeSizeAxes = Axes.Both,
@ -218,7 +216,11 @@ namespace osu.Game.Rulesets.UI
if (Cursor != null)
KeyBindingInputManager.Add(Cursor);
// Apply mods
applyMods(Mods, config);
loadObjects();
}
/// <summary>
@ -235,7 +237,6 @@ namespace osu.Game.Rulesets.UI
WorkingBeatmap = workingBeatmap;
IsForCurrentRuleset = isForCurrentRuleset;
// ReSharper disable once PossibleNullReferenceException
Mods = workingBeatmap.Mods.Value;
RelativeSizeAxes = Axes.Both;
@ -269,31 +270,29 @@ namespace osu.Game.Rulesets.UI
KeyBindingInputManager.RelativeSizeAxes = Axes.Both;
// 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
// for the IReadFromConfig implementations. This method is still executed after the constructor,
// so the mods are still added in last
// Mods are now added in the load() method, this method is still executed after the constructor
// so they are still added in last
}
/// <summary>
/// Applies the active mods to this RulesetContainer.
/// </summary>
/// <param name="mods"></param>
private void applyMods(IEnumerable<Mod> mods, OsuConfigManager config)
{
if (mods == null)
if(mods == null)
{
return;
foreach (var mod in mods.OfType<IReadFromConfig>())
mod.ReadFromConfig(config);
}
foreach (var mod in mods.OfType<IApplicableToHitObject<TObject>>())
foreach (var obj in Beatmap.HitObjects)
mod.ApplyToHitObject(obj);
foreach (var mod in mods.OfType<IApplicableToRulesetContainer<TObject>>())
mod.ApplyToRulesetContainer(this);
foreach (var mod in mods.OfType<IReadFromConfig>())
mod.ReadFromConfig(config);
}
public override void SetReplay(Replay replay)
@ -301,7 +300,7 @@ namespace osu.Game.Rulesets.UI
base.SetReplay(replay);
if (ReplayInputManager?.ReplayInputHandler != null)
ReplayInputManager.ReplayInputHandler.GamefieldToScreenSpace = Playfield.GamefieldToScreenSpace;
ReplayInputManager.ReplayInputHandler.ToScreenSpace = input => Playfield.ScaledContent.ToScreenSpace(input);
}
/// <summary>