Skip to content

Commit

Permalink
Merge branch 'master' into ruleset-result-types
Browse files Browse the repository at this point in the history
  • Loading branch information
peppy committed Oct 9, 2020
2 parents f70252d + 02d4552 commit 07558b5
Show file tree
Hide file tree
Showing 28 changed files with 303 additions and 84 deletions.
58 changes: 41 additions & 17 deletions osu.Desktop/Updater/SquirrelUpdateManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ public class SquirrelUpdateManager : osu.Game.Updater.UpdateManager

private static readonly Logger logger = Logger.GetLogger("updater");

/// <summary>
/// Whether an update has been downloaded but not yet applied.
/// </summary>
private bool updatePending;

[BackgroundDependencyLoader]
private void load(NotificationOverlay notification)
{
Expand All @@ -37,9 +42,9 @@ private void load(NotificationOverlay notification)
Splat.Locator.CurrentMutable.Register(() => new SquirrelLogger(), typeof(Splat.ILogger));
}

protected override async Task PerformUpdateCheck() => await checkForUpdateAsync();
protected override async Task<bool> PerformUpdateCheck() => await checkForUpdateAsync();

private async Task checkForUpdateAsync(bool useDeltaPatching = true, UpdateProgressNotification notification = null)
private async Task<bool> checkForUpdateAsync(bool useDeltaPatching = true, UpdateProgressNotification notification = null)
{
// should we schedule a retry on completion of this check?
bool scheduleRecheck = true;
Expand All @@ -49,9 +54,19 @@ private async Task checkForUpdateAsync(bool useDeltaPatching = true, UpdateProgr
updateManager ??= await UpdateManager.GitHubUpdateManager(@"https://github.com/ppy/osu", @"osulazer", null, null, true);

var info = await updateManager.CheckForUpdate(!useDeltaPatching);

if (info.ReleasesToApply.Count == 0)
{
if (updatePending)
{
// the user may have dismissed the completion notice, so show it again.
notificationOverlay.Post(new UpdateCompleteNotification(this));
return true;
}

// no updates available. bail and retry later.
return;
return false;
}

if (notification == null)
{
Expand All @@ -72,6 +87,7 @@ private async Task checkForUpdateAsync(bool useDeltaPatching = true, UpdateProgr
await updateManager.ApplyReleases(info, p => notification.Progress = p / 100f);

notification.State = ProgressNotificationState.Completed;
updatePending = true;
}
catch (Exception e)
{
Expand Down Expand Up @@ -103,6 +119,8 @@ private async Task checkForUpdateAsync(bool useDeltaPatching = true, UpdateProgr
Scheduler.AddDelayed(async () => await checkForUpdateAsync(), 60000 * 30);
}
}

return true;
}

protected override void Dispose(bool isDisposing)
Expand All @@ -111,10 +129,27 @@ protected override void Dispose(bool isDisposing)
updateManager?.Dispose();
}

private class UpdateCompleteNotification : ProgressCompletionNotification
{
[Resolved]
private OsuGame game { get; set; }

public UpdateCompleteNotification(SquirrelUpdateManager updateManager)
{
Text = @"Update ready to install. Click to restart!";

Activated = () =>
{
updateManager.PrepareUpdateAsync()
.ContinueWith(_ => updateManager.Schedule(() => game.GracefullyExit()));
return true;
};
}
}

private class UpdateProgressNotification : ProgressNotification
{
private readonly SquirrelUpdateManager updateManager;
private OsuGame game;

public UpdateProgressNotification(SquirrelUpdateManager updateManager)
{
Expand All @@ -123,23 +158,12 @@ public UpdateProgressNotification(SquirrelUpdateManager updateManager)

protected override Notification CreateCompletionNotification()
{
return new ProgressCompletionNotification
{
Text = @"Update ready to install. Click to restart!",
Activated = () =>
{
updateManager.PrepareUpdateAsync()
.ContinueWith(_ => updateManager.Schedule(() => game.GracefullyExit()));
return true;
}
};
return new UpdateCompleteNotification(updateManager);
}

[BackgroundDependencyLoader]
private void load(OsuColour colours, OsuGame game)
private void load(OsuColour colours)
{
this.game = game;

IconContent.AddRange(new Drawable[]
{
new Box
Expand Down
2 changes: 1 addition & 1 deletion osu.Game.Rulesets.Catch/CatchRuleset.cs
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ public override string GetDisplayNameForHitResult(HitResult result)

public override ISkin CreateLegacySkinProvider(ISkinSource source, IBeatmap beatmap) => new CatchLegacySkinTransformer(source);

public override PerformanceCalculator CreatePerformanceCalculator(WorkingBeatmap beatmap, ScoreInfo score) => new CatchPerformanceCalculator(this, beatmap, score);
public override PerformanceCalculator CreatePerformanceCalculator(DifficultyAttributes attributes, ScoreInfo score) => new CatchPerformanceCalculator(this, attributes, score);

public int LegacyID => 2;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
using System.Collections.Generic;
using System.Linq;
using osu.Framework.Extensions;
using osu.Game.Beatmaps;
using osu.Game.Rulesets.Difficulty;
using osu.Game.Rulesets.Mods;
using osu.Game.Rulesets.Scoring;
Expand All @@ -25,8 +24,8 @@ public class CatchPerformanceCalculator : PerformanceCalculator
private int tinyTicksMissed;
private int misses;

public CatchPerformanceCalculator(Ruleset ruleset, WorkingBeatmap beatmap, ScoreInfo score)
: base(ruleset, beatmap, score)
public CatchPerformanceCalculator(Ruleset ruleset, DifficultyAttributes attributes, ScoreInfo score)
: base(ruleset, attributes, score)
{
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
using System.Collections.Generic;
using System.Linq;
using osu.Framework.Extensions;
using osu.Game.Beatmaps;
using osu.Game.Rulesets.Difficulty;
using osu.Game.Rulesets.Mods;
using osu.Game.Rulesets.Scoring;
Expand All @@ -29,8 +28,8 @@ public class ManiaPerformanceCalculator : PerformanceCalculator
private int countMeh;
private int countMiss;

public ManiaPerformanceCalculator(Ruleset ruleset, WorkingBeatmap beatmap, ScoreInfo score)
: base(ruleset, beatmap, score)
public ManiaPerformanceCalculator(Ruleset ruleset, DifficultyAttributes attributes, ScoreInfo score)
: base(ruleset, attributes, score)
{
}

Expand Down
2 changes: 1 addition & 1 deletion osu.Game.Rulesets.Mania/ManiaRuleset.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public class ManiaRuleset : Ruleset, ILegacyRuleset

public override IBeatmapConverter CreateBeatmapConverter(IBeatmap beatmap) => new ManiaBeatmapConverter(beatmap, this);

public override PerformanceCalculator CreatePerformanceCalculator(WorkingBeatmap beatmap, ScoreInfo score) => new ManiaPerformanceCalculator(this, beatmap, score);
public override PerformanceCalculator CreatePerformanceCalculator(DifficultyAttributes attributes, ScoreInfo score) => new ManiaPerformanceCalculator(this, attributes, score);

public const string SHORT_NAME = "mania";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@ public class OsuDifficultyAttributes : DifficultyAttributes
public double SpeedStrain;
public double ApproachRate;
public double OverallDifficulty;
public int HitCircleCount;
}
}
3 changes: 3 additions & 0 deletions osu.Game.Rulesets.Osu/Difficulty/OsuDifficultyCalculator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ protected override DifficultyAttributes CreateDifficultyAttributes(IBeatmap beat
// Add the ticks + tail of the slider. 1 is subtracted because the head circle would be counted twice (once for the slider itself in the line above)
maxCombo += beatmap.HitObjects.OfType<Slider>().Sum(s => s.NestedHitObjects.Count - 1);

int hitCirclesCount = beatmap.HitObjects.Count(h => h is HitCircle);

return new OsuDifficultyAttributes
{
StarRating = starRating,
Expand All @@ -56,6 +58,7 @@ protected override DifficultyAttributes CreateDifficultyAttributes(IBeatmap beat
ApproachRate = preempt > 1200 ? (1800 - preempt) / 120 : (1200 - preempt) / 150 + 5,
OverallDifficulty = (80 - hitWindowGreat) / 6,
MaxCombo = maxCombo,
HitCircleCount = hitCirclesCount,
Skills = skills
};
}
Expand Down
26 changes: 8 additions & 18 deletions osu.Game.Rulesets.Osu/Difficulty/OsuPerformanceCalculator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,9 @@
using System.Collections.Generic;
using System.Linq;
using osu.Framework.Extensions;
using osu.Game.Beatmaps;
using osu.Game.Rulesets.Difficulty;
using osu.Game.Rulesets.Mods;
using osu.Game.Rulesets.Osu.Mods;
using osu.Game.Rulesets.Osu.Objects;
using osu.Game.Rulesets.Scoring;
using osu.Game.Scoring;

Expand All @@ -19,9 +17,6 @@ public class OsuPerformanceCalculator : PerformanceCalculator
{
public new OsuDifficultyAttributes Attributes => (OsuDifficultyAttributes)base.Attributes;

private readonly int countHitCircles;
private readonly int beatmapMaxCombo;

private Mod[] mods;

private double accuracy;
Expand All @@ -31,14 +26,9 @@ public class OsuPerformanceCalculator : PerformanceCalculator
private int countMeh;
private int countMiss;

public OsuPerformanceCalculator(Ruleset ruleset, WorkingBeatmap beatmap, ScoreInfo score)
: base(ruleset, beatmap, score)
public OsuPerformanceCalculator(Ruleset ruleset, DifficultyAttributes attributes, ScoreInfo score)
: base(ruleset, attributes, score)
{
countHitCircles = Beatmap.HitObjects.Count(h => h is HitCircle);

beatmapMaxCombo = Beatmap.HitObjects.Count;
// Add the ticks + tail of the slider. 1 is subtracted because the "headcircle" would be counted twice (once for the slider itself in the line above)
beatmapMaxCombo += Beatmap.HitObjects.OfType<Slider>().Sum(s => s.NestedHitObjects.Count - 1);
}

public override double Calculate(Dictionary<string, double> categoryRatings = null)
Expand Down Expand Up @@ -81,7 +71,7 @@ public override double Calculate(Dictionary<string, double> categoryRatings = nu
categoryRatings.Add("Accuracy", accuracyValue);
categoryRatings.Add("OD", Attributes.OverallDifficulty);
categoryRatings.Add("AR", Attributes.ApproachRate);
categoryRatings.Add("Max Combo", beatmapMaxCombo);
categoryRatings.Add("Max Combo", Attributes.MaxCombo);
}

return totalValue;
Expand All @@ -106,8 +96,8 @@ private double computeAimValue()
aimValue *= Math.Pow(0.97, countMiss);

// Combo scaling
if (beatmapMaxCombo > 0)
aimValue *= Math.Min(Math.Pow(scoreMaxCombo, 0.8) / Math.Pow(beatmapMaxCombo, 0.8), 1.0);
if (Attributes.MaxCombo > 0)
aimValue *= Math.Min(Math.Pow(scoreMaxCombo, 0.8) / Math.Pow(Attributes.MaxCombo, 0.8), 1.0);

double approachRateFactor = 1.0;

Expand Down Expand Up @@ -154,8 +144,8 @@ private double computeSpeedValue()
speedValue *= Math.Pow(0.97, countMiss);

// Combo scaling
if (beatmapMaxCombo > 0)
speedValue *= Math.Min(Math.Pow(scoreMaxCombo, 0.8) / Math.Pow(beatmapMaxCombo, 0.8), 1.0);
if (Attributes.MaxCombo > 0)
speedValue *= Math.Min(Math.Pow(scoreMaxCombo, 0.8) / Math.Pow(Attributes.MaxCombo, 0.8), 1.0);

double approachRateFactor = 1.0;
if (Attributes.ApproachRate > 10.33)
Expand All @@ -178,7 +168,7 @@ private double computeAccuracyValue()
{
// This percentage only considers HitCircles of any value - in this part of the calculation we focus on hitting the timing hit window
double betterAccuracyPercentage;
int amountHitObjectsWithAccuracy = countHitCircles;
int amountHitObjectsWithAccuracy = Attributes.HitCircleCount;

if (amountHitObjectsWithAccuracy > 0)
betterAccuracyPercentage = ((countGreat - (totalHits - amountHitObjectsWithAccuracy)) * 6 + countOk * 2 + countMeh) / (double)(amountHitObjectsWithAccuracy * 6);
Expand Down
2 changes: 1 addition & 1 deletion osu.Game.Rulesets.Osu/OsuRuleset.cs
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ public override IEnumerable<Mod> GetModsFor(ModType type)

public override DifficultyCalculator CreateDifficultyCalculator(WorkingBeatmap beatmap) => new OsuDifficultyCalculator(this, beatmap);

public override PerformanceCalculator CreatePerformanceCalculator(WorkingBeatmap beatmap, ScoreInfo score) => new OsuPerformanceCalculator(this, beatmap, score);
public override PerformanceCalculator CreatePerformanceCalculator(DifficultyAttributes attributes, ScoreInfo score) => new OsuPerformanceCalculator(this, attributes, score);

public override HitObjectComposer CreateHitObjectComposer() => new OsuHitObjectComposer(this);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
using System.Collections.Generic;
using System.Linq;
using osu.Framework.Extensions;
using osu.Game.Beatmaps;
using osu.Game.Rulesets.Difficulty;
using osu.Game.Rulesets.Mods;
using osu.Game.Rulesets.Scoring;
Expand All @@ -24,8 +23,8 @@ public class TaikoPerformanceCalculator : PerformanceCalculator
private int countMeh;
private int countMiss;

public TaikoPerformanceCalculator(Ruleset ruleset, WorkingBeatmap beatmap, ScoreInfo score)
: base(ruleset, beatmap, score)
public TaikoPerformanceCalculator(Ruleset ruleset, DifficultyAttributes attributes, ScoreInfo score)
: base(ruleset, attributes, score)
{
}

Expand Down
2 changes: 2 additions & 0 deletions osu.Game.Rulesets.Taiko/Edit/TaikoSelectionHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ protected override IEnumerable<MenuItem> GetContextMenuItemsForSelection(IEnumer
yield return new TernaryStateMenuItem("Strong") { State = { BindTarget = selectionStrongState } };
}

public override bool HandleMovement(MoveSelectionEvent moveEvent) => true;

protected override void UpdateTernaryStates()
{
base.UpdateTernaryStates();
Expand Down
22 changes: 21 additions & 1 deletion osu.Game.Rulesets.Taiko/Skinning/TaikoLegacySkinTransformer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,37 @@
using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Game.Audio;
using osu.Game.Rulesets.Scoring;
using osu.Game.Rulesets.Taiko.UI;
using osu.Game.Skinning;

namespace osu.Game.Rulesets.Taiko.Skinning
{
public class TaikoLegacySkinTransformer : LegacySkinTransformer
{
private Lazy<bool> hasExplosion;

public TaikoLegacySkinTransformer(ISkinSource source)
: base(source)
{
Source.SourceChanged += sourceChanged;
sourceChanged();
}

private void sourceChanged()
{
hasExplosion = new Lazy<bool>(() => Source.GetTexture(getHitName(TaikoSkinComponents.TaikoExplosionGreat)) != null);
}

public override Drawable GetDrawableComponent(ISkinComponent component)
{
if (component is GameplaySkinComponent<HitResult>)
{
// if a taiko skin is providing explosion sprites, hide the judgements completely
if (hasExplosion.Value)
return Drawable.Empty();
}

if (!(component is TaikoSkinComponent taikoComponent))
return null;

Expand Down Expand Up @@ -87,10 +104,13 @@ public override Drawable GetDrawableComponent(ISkinComponent component)

var hitName = getHitName(taikoComponent.Component);
var hitSprite = this.GetAnimation(hitName, true, false);
var strongHitSprite = this.GetAnimation($"{hitName}k", true, false);

if (hitSprite != null)
{
var strongHitSprite = this.GetAnimation($"{hitName}k", true, false);

return new LegacyHitExplosion(hitSprite, strongHitSprite);
}

return null;

Expand Down
2 changes: 1 addition & 1 deletion osu.Game.Rulesets.Taiko/TaikoRuleset.cs
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ public override IEnumerable<Mod> GetModsFor(ModType type)

public override DifficultyCalculator CreateDifficultyCalculator(WorkingBeatmap beatmap) => new TaikoDifficultyCalculator(this, beatmap);

public override PerformanceCalculator CreatePerformanceCalculator(WorkingBeatmap beatmap, ScoreInfo score) => new TaikoPerformanceCalculator(this, beatmap, score);
public override PerformanceCalculator CreatePerformanceCalculator(DifficultyAttributes attributes, ScoreInfo score) => new TaikoPerformanceCalculator(this, attributes, score);

public int LegacyID => 1;

Expand Down
Loading

0 comments on commit 07558b5

Please sign in to comment.