Merge branch 'master' of git://github.com/ppy/osu into ranks-section

This commit is contained in:
Jorolf
2017-08-08 23:13:25 +02:00
180 changed files with 1729 additions and 1185 deletions

View File

@ -0,0 +1,15 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using osu.Game.Beatmaps;
namespace osu.Game.Rulesets.Mods
{
/// <summary>
/// An interface for mods that make general adjustments to difficulty.
/// </summary>
public interface IApplicableToDifficulty
{
void ApplyToDifficulty(BeatmapDifficulty difficulty);
}
}

View File

@ -45,5 +45,10 @@ namespace osu.Game.Rulesets.Mods
/// The mods this mod cannot be enabled with.
/// </summary>
public virtual Type[] IncompatibleMods => new Type[] { };
/// <summary>
/// Whether we should allow failing at the current point in time.
/// </summary>
public virtual bool AllowFail => true;
}
}

View File

@ -2,11 +2,12 @@
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System;
using osu.Game.Beatmaps;
using osu.Game.Graphics;
namespace osu.Game.Rulesets.Mods
{
public abstract class ModEasy : Mod
public abstract class ModEasy : Mod, IApplicableToDifficulty
{
public override string Name => "Easy";
public override FontAwesome Icon => FontAwesome.fa_osu_mod_easy;
@ -15,5 +16,14 @@ namespace osu.Game.Rulesets.Mods
public override double ScoreMultiplier => 0.5;
public override bool Ranked => true;
public override Type[] IncompatibleMods => new[] { typeof(ModHardRock) };
public void ApplyToDifficulty(BeatmapDifficulty difficulty)
{
const float ratio = 0.5f;
difficulty.CircleSize *= ratio;
difficulty.ApproachRate *= ratio;
difficulty.DrainRate *= ratio;
difficulty.OverallDifficulty *= ratio;
}
}
}

View File

@ -2,16 +2,26 @@
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System;
using osu.Game.Beatmaps;
using osu.Game.Graphics;
namespace osu.Game.Rulesets.Mods
{
public abstract class ModHardRock : Mod
public abstract class ModHardRock : Mod, IApplicableToDifficulty
{
public override string Name => "Hard Rock";
public override FontAwesome Icon => FontAwesome.fa_osu_mod_hardrock;
public override ModType Type => ModType.DifficultyIncrease;
public override string Description => "Everything just got a bit harder...";
public override Type[] IncompatibleMods => new[] { typeof(ModEasy) };
public void ApplyToDifficulty(BeatmapDifficulty difficulty)
{
const float ratio = 1.4f;
difficulty.CircleSize *= 1.3f; // CS uses a custom 1.3 ratio.
difficulty.ApproachRate *= ratio;
difficulty.DrainRate *= ratio;
difficulty.OverallDifficulty *= ratio;
}
}
}
}

View File

@ -15,5 +15,10 @@ namespace osu.Game.Rulesets.Mods
public override double ScoreMultiplier => 0.5;
public override bool Ranked => true;
public override Type[] IncompatibleMods => new[] { typeof(ModRelax), typeof(ModSuddenDeath), typeof(ModAutoplay) };
/// <summary>
/// We never fail, 'yo.
/// </summary>
public override bool AllowFail => false;
}
}

View File

@ -7,6 +7,7 @@ using osu.Game.Rulesets.Mods;
using osu.Game.Rulesets.UI;
using osu.Game.Screens.Play;
using System.Collections.Generic;
using osu.Framework.Graphics;
using osu.Game.Rulesets.Scoring;
using osu.Game.Overlays.Settings;
@ -18,6 +19,8 @@ namespace osu.Game.Rulesets
public abstract IEnumerable<Mod> GetModsFor(ModType type);
public abstract Mod GetAutoplayMod();
/// <summary>
/// Attempt to create a hit renderer for a beatmap
/// </summary>
@ -31,7 +34,7 @@ namespace osu.Game.Rulesets
public abstract ScoreProcessor CreateScoreProcessor();
public virtual FontAwesome Icon => FontAwesome.fa_question_circle;
public virtual Drawable CreateIcon() => new SpriteIcon { Icon = FontAwesome.fa_question_circle };
public abstract string Description { get; }

View File

@ -62,7 +62,7 @@ namespace osu.Game.Rulesets
{
var us = createRulesetInfo(r);
var existing = Query<RulesetInfo>().FirstOrDefault(ri => ri.InstantiationInfo == us.InstantiationInfo);
var existing = Query<RulesetInfo>().Where(ri => ri.InstantiationInfo == us.InstantiationInfo).FirstOrDefault();
if (existing == null)
Connection.Insert(us);

View File

@ -16,8 +16,9 @@ namespace osu.Game.Rulesets.Scoring
{
/// <summary>
/// Invoked when the ScoreProcessor is in a failed state.
/// Return true if the fail was permitted.
/// </summary>
public event Action Failed;
public event Func<bool> Failed;
/// <summary>
/// Invoked when a new judgement has occurred. This occurs after the judgement has been processed by the <see cref="ScoreProcessor"/>.
@ -106,8 +107,8 @@ namespace osu.Game.Rulesets.Scoring
if (alreadyFailed || !HasFailed)
return;
alreadyFailed = true;
Failed?.Invoke();
if (Failed?.Invoke() != false)
alreadyFailed = true;
}
/// <summary>

View File

@ -153,6 +153,10 @@ namespace osu.Game.Rulesets.UI
// Convert the beatmap
Beatmap = converter.Convert(beatmap.Beatmap, isForCurrentRuleset);
// Apply difficulty adjustments from mods before using Difficulty.
foreach (var mod in Mods.OfType<IApplicableToDifficulty>())
mod.ApplyToDifficulty(Beatmap.BeatmapInfo.Difficulty);
// Apply defaults
foreach (var h in Beatmap.HitObjects)
h.ApplyDefaults(Beatmap.ControlPointInfo, Beatmap.BeatmapInfo.Difficulty);
@ -163,7 +167,7 @@ namespace osu.Game.Rulesets.UI
ApplyBeatmap();
// Add mods, should always be the last thing applied to give full control to mods
applyMods(beatmap.Mods.Value);
applyMods(Mods);
}
/// <summary>

View File

@ -8,13 +8,14 @@ using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Game.Graphics;
using osu.Game.Rulesets.Mods;
using OpenTK;
namespace osu.Game.Rulesets.UI
{
public class ModIcon : Container
{
private readonly TextAwesome modIcon;
private readonly TextAwesome background;
private readonly SpriteIcon modIcon;
private readonly SpriteIcon background;
private const float icon_size = 80;
@ -34,20 +35,21 @@ namespace osu.Game.Rulesets.UI
Children = new Drawable[]
{
background = new TextAwesome
background = new SpriteIcon
{
Origin = Anchor.Centre,
Anchor = Anchor.Centre,
TextSize = icon_size,
Size = new Vector2(icon_size),
Icon = FontAwesome.fa_osu_mod_bg,
Shadow = true,
},
modIcon = new TextAwesome
modIcon = new SpriteIcon
{
Origin = Anchor.Centre,
Anchor = Anchor.Centre,
Origin = Anchor.TopCentre,
Anchor = Anchor.TopCentre,
Colour = OsuColour.Gray(84),
TextSize = icon_size - 35,
Size = new Vector2(icon_size - 35),
Y = 25,
Icon = mod.Icon
},
};