Merge branch 'master' into osu-hd-setting

This commit is contained in:
Dean Herbert
2018-05-21 15:21:09 +09:00
committed by GitHub
47 changed files with 761 additions and 436 deletions

View File

@ -84,10 +84,7 @@ namespace osu.Game.Rulesets.Mania.Beatmaps
yield break;
foreach (ManiaHitObject obj in objects)
{
obj.HitWindows = original.HitWindows;
yield return obj;
}
}
private readonly List<double> prevNoteTimes = new List<double>(max_notes_for_density);

View File

@ -59,7 +59,8 @@ namespace osu.Game.Rulesets.Mania.Difficulty
double starRating = calculateDifficulty() * star_scaling_factor;
categoryDifficulty?.Add("Strain", starRating);
if (categoryDifficulty != null)
categoryDifficulty["Strain"] = starRating;
return starRating;
}

View File

@ -0,0 +1,126 @@
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System;
using System.Collections.Generic;
using System.Linq;
using osu.Game.Beatmaps;
using osu.Game.Rulesets.Difficulty;
using osu.Game.Rulesets.Mods;
using osu.Game.Rulesets.Scoring;
namespace osu.Game.Rulesets.Mania.Difficulty
{
public class ManiaPerformanceCalculator : PerformanceCalculator
{
private Mod[] mods;
// Score after being scaled by non-difficulty-increasing mods
private double scaledScore;
private int countPerfect;
private int countGreat;
private int countGood;
private int countOk;
private int countMeh;
private int countMiss;
public ManiaPerformanceCalculator(Ruleset ruleset, IBeatmap beatmap, Score score)
: base(ruleset, beatmap, score)
{
}
public override double Calculate(Dictionary<string, double> categoryDifficulty = null)
{
mods = Score.Mods;
scaledScore = Score.TotalScore;
countPerfect = Convert.ToInt32(Score.Statistics[HitResult.Perfect]);
countGreat = Convert.ToInt32(Score.Statistics[HitResult.Great]);
countGood = Convert.ToInt32(Score.Statistics[HitResult.Good]);
countOk = Convert.ToInt32(Score.Statistics[HitResult.Ok]);
countMeh = Convert.ToInt32(Score.Statistics[HitResult.Meh]);
countMiss = Convert.ToInt32(Score.Statistics[HitResult.Miss]);
if (mods.Any(m => !m.Ranked))
return 0;
IEnumerable<Mod> scoreIncreaseMods = Ruleset.GetModsFor(ModType.DifficultyIncrease);
double scoreMultiplier = 1.0;
foreach (var m in mods.Where(m => !scoreIncreaseMods.Contains(m)))
scoreMultiplier *= m.ScoreMultiplier;
// Scale score up, so it's comparable to other keymods
scaledScore *= 1.0 / scoreMultiplier;
// Arbitrary initial value for scaling pp in order to standardize distributions across game modes.
// The specific number has no intrinsic meaning and can be adjusted as needed.
double multiplier = 0.8;
if (mods.Any(m => m is ModNoFail))
multiplier *= 0.9;
if (mods.Any(m => m is ModEasy))
multiplier *= 0.5;
double strainValue = computeStrainValue();
double accValue = computeAccuracyValue(strainValue);
double totalValue =
Math.Pow(
Math.Pow(strainValue, 1.1) +
Math.Pow(accValue, 1.1), 1.0 / 1.1
) * multiplier;
if (categoryDifficulty != null)
{
categoryDifficulty["Strain"] = strainValue;
categoryDifficulty["Accuracy"] = accValue;
}
return totalValue;
}
private double computeStrainValue()
{
// Obtain strain difficulty
double strainValue = Math.Pow(5 * Math.Max(1, Attributes["Strain"] / 0.2) - 4.0, 2.2) / 135.0;
// Longer maps are worth more
strainValue *= 1.0 + 0.1 * Math.Min(1.0, totalHits / 1500.0);
if (scaledScore <= 500000)
strainValue = 0;
else if (scaledScore <= 600000)
strainValue *= (scaledScore - 500000) / 100000 * 0.3;
else if (scaledScore <= 700000)
strainValue *= 0.3 + (scaledScore - 600000) / 100000 * 0.25;
else if (scaledScore <= 800000)
strainValue *= 0.55 + (scaledScore - 700000) / 100000 * 0.20;
else if (scaledScore <= 900000)
strainValue *= 0.75 + (scaledScore - 800000) / 100000 * 0.15;
else
strainValue *= 0.90 + (scaledScore - 900000) / 100000 * 0.1;
return strainValue;
}
private double computeAccuracyValue(double strainValue)
{
double hitWindowGreat = (Beatmap.HitObjects.First().HitWindows.Great / 2 - 0.5) / TimeRate;
if (hitWindowGreat <= 0)
return 0;
// Lots of arbitrary values from testing.
// Considering to use derivation from perfect accuracy in a probabilistic manner - assume normal distribution
double accuracyValue = Math.Max(0.0, 0.2 - (hitWindowGreat - 34) * 0.006667)
* strainValue
* Math.Pow(Math.Max(0.0, scaledScore - 960000) / 40000, 1.1);
// Bonus for many hitcircles - it's harder to keep good accuracy up for longer
// accuracyValue *= Math.Min(1.15, Math.Pow(totalHits / 1500.0, 0.3));
return accuracyValue;
}
private double totalHits => countPerfect + countOk + countGreat + countGood + countMeh + countMiss;
}
}

View File

@ -18,6 +18,7 @@ using osu.Game.Beatmaps.Legacy;
using osu.Game.Rulesets.Difficulty;
using osu.Game.Rulesets.Mania.Beatmaps;
using osu.Game.Rulesets.Mania.Difficulty;
using osu.Game.Rulesets.Scoring;
namespace osu.Game.Rulesets.Mania
{
@ -25,6 +26,7 @@ namespace osu.Game.Rulesets.Mania
{
public override RulesetContainer CreateRulesetContainerWith(WorkingBeatmap beatmap) => new ManiaRulesetContainer(this, beatmap);
public override IBeatmapConverter CreateBeatmapConverter(IBeatmap beatmap) => new ManiaBeatmapConverter(beatmap);
public override PerformanceCalculator CreatePerformanceCalculator(IBeatmap beatmap, Score score) => new ManiaPerformanceCalculator(this, beatmap, score);
public override IEnumerable<Mod> ConvertLegacyMods(LegacyMods mods)
{

View File

@ -204,6 +204,13 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables
/// </summary>
private class DrawableTailNote : DrawableNote
{
/// <summary>
/// Lenience of release hit windows. This is to make cases where the hold note release
/// is timed alongside presses of other hit objects less awkward.
/// Todo: This shouldn't exist for non-LegacyBeatmapDecoder beatmaps
/// </summary>
private const double release_window_lenience = 1.5;
private readonly DrawableHoldNote holdNote;
public DrawableTailNote(DrawableHoldNote holdNote, ManiaAction action)
@ -216,6 +223,9 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables
protected override void CheckForJudgements(bool userTriggered, double timeOffset)
{
// Factor in the release lenience
timeOffset /= release_window_lenience;
if (!userTriggered)
{
if (!HitObject.HitWindows.CanBeHit(timeOffset))

View File

@ -55,7 +55,7 @@ namespace osu.Game.Rulesets.Mania.Objects
/// <summary>
/// The tail note of the hold.
/// </summary>
public readonly Note Tail = new TailNote();
public readonly Note Tail = new Note();
/// <summary>
/// The time between ticks of this hold.
@ -94,25 +94,5 @@ namespace osu.Game.Rulesets.Mania.Objects
});
}
}
/// <summary>
/// The tail of the hold note.
/// </summary>
private class TailNote : Note
{
/// <summary>
/// Lenience of release hit windows. This is to make cases where the hold note release
/// is timed alongside presses of other hit objects less awkward.
/// Todo: This shouldn't exist for non-LegacyBeatmapDecoder beatmaps
/// </summary>
private const double release_window_lenience = 1.5;
protected override void ApplyDefaultsToSelf(ControlPointInfo controlPointInfo, BeatmapDifficulty difficulty)
{
base.ApplyDefaultsToSelf(controlPointInfo, difficulty);
HitWindows *= release_window_lenience;
}
}
}
}

View File

@ -1,8 +1,6 @@
// 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.Game.Beatmaps;
using osu.Game.Beatmaps.ControlPoints;
using osu.Game.Rulesets.Mania.Objects.Types;
using osu.Game.Rulesets.Objects;
@ -12,12 +10,6 @@ namespace osu.Game.Rulesets.Mania.Objects
{
public virtual int Column { get; set; }
protected override void ApplyDefaultsToSelf(ControlPointInfo controlPointInfo, BeatmapDifficulty difficulty)
{
base.ApplyDefaultsToSelf(controlPointInfo, difficulty);
HitWindows.AllowsPerfect = true;
HitWindows.AllowsOk = true;
}
protected override HitWindows CreateHitWindows() => new ManiaHitWindows();
}
}

View File

@ -3,11 +3,12 @@
using System.Collections.Generic;
using osu.Game.Beatmaps;
using osu.Game.Rulesets.Objects;
using osu.Game.Rulesets.Scoring;
namespace osu.Game.Rulesets.Objects.Legacy.Mania
namespace osu.Game.Rulesets.Mania.Objects
{
public class ConvertHitWindows : HitWindows
public class ManiaHitWindows : HitWindows
{
private static readonly IReadOnlyDictionary<HitResult, (double od0, double od5, double od10)> base_ranges = new Dictionary<HitResult, (double, double, double)>
{
@ -21,6 +22,9 @@ namespace osu.Game.Rulesets.Objects.Legacy.Mania
public override void SetDifficulty(double difficulty)
{
AllowsPerfect = true;
AllowsOk = true;
Perfect = BeatmapDifficulty.DifficultyRange(difficulty, base_ranges[HitResult.Perfect]);
Great = BeatmapDifficulty.DifficultyRange(difficulty, base_ranges[HitResult.Great]);
Good = BeatmapDifficulty.DifficultyRange(difficulty, base_ranges[HitResult.Good]);

View File

@ -40,8 +40,7 @@ namespace osu.Game.Rulesets.Osu.Beatmaps
RepeatSamples = curveData.RepeatSamples,
RepeatCount = curveData.RepeatCount,
Position = positionData?.Position ?? Vector2.Zero,
NewCombo = comboData?.NewCombo ?? false,
HitWindows = original.HitWindows
NewCombo = comboData?.NewCombo ?? false
};
}
else if (endTimeData != null)
@ -51,8 +50,7 @@ namespace osu.Game.Rulesets.Osu.Beatmaps
StartTime = original.StartTime,
Samples = original.Samples,
EndTime = endTimeData.EndTime,
Position = positionData?.Position ?? OsuPlayfield.BASE_SIZE / 2,
HitWindows = original.HitWindows
Position = positionData?.Position ?? OsuPlayfield.BASE_SIZE / 2
};
}
else
@ -62,8 +60,7 @@ namespace osu.Game.Rulesets.Osu.Beatmaps
StartTime = original.StartTime,
Samples = original.Samples,
Position = positionData?.Position ?? Vector2.Zero,
NewCombo = comboData?.NewCombo ?? false,
HitWindows = original.HitWindows
NewCombo = comboData?.NewCombo ?? false
};
}
}

View File

@ -71,5 +71,7 @@ namespace osu.Game.Rulesets.Osu.Objects
}
public virtual void OffsetPosition(Vector2 offset) => Position += offset;
protected override HitWindows CreateHitWindows() => new OsuHitWindows();
}
}

View File

@ -3,11 +3,12 @@
using System.Collections.Generic;
using osu.Game.Beatmaps;
using osu.Game.Rulesets.Objects;
using osu.Game.Rulesets.Scoring;
namespace osu.Game.Rulesets.Objects.Legacy.Osu
namespace osu.Game.Rulesets.Osu.Objects
{
public class ConvertHitWindows : HitWindows
public class OsuHitWindows : HitWindows
{
private static readonly IReadOnlyDictionary<HitResult, (double od0, double od5, double od10)> base_ranges = new Dictionary<HitResult, (double, double, double)>
{

View File

@ -17,8 +17,8 @@ namespace osu.Game.Rulesets.Taiko.Tests
protected override string ResourceAssembly => "osu.Game.Rulesets.Taiko";
[NonParallelizable]
[TestCase("basic", false), Ignore("See: https://github.com/ppy/osu/issues/2152")]
[TestCase("slider-generating-drumroll", false)]
[TestCase("basic")]
[TestCase("slider-generating-drumroll")]
public new void Test(string name)
{
base.Test(name);

View File

@ -98,12 +98,12 @@ namespace osu.Game.Rulesets.Taiko.Beatmaps
double distance = distanceData.Distance * spans * legacy_velocity_multiplier;
// The velocity of the taiko hit object - calculated as the velocity of a drum roll
double taikoVelocity = taiko_base_distance * beatmap.BeatmapInfo.BaseDifficulty.SliderMultiplier * legacy_velocity_multiplier / speedAdjustedBeatLength;
double taikoVelocity = taiko_base_distance * beatmap.BeatmapInfo.BaseDifficulty.SliderMultiplier / speedAdjustedBeatLength;
// The duration of the taiko hit object
double taikoDuration = distance / taikoVelocity;
// The velocity of the osu! hit object - calculated as the velocity of a slider
double osuVelocity = osu_base_scoring_distance * beatmap.BeatmapInfo.BaseDifficulty.SliderMultiplier * legacy_velocity_multiplier / speedAdjustedBeatLength;
double osuVelocity = osu_base_scoring_distance * beatmap.BeatmapInfo.BaseDifficulty.SliderMultiplier / speedAdjustedBeatLength;
// The duration of the osu! hit object
double osuDuration = distance / osuVelocity;
@ -132,8 +132,7 @@ namespace osu.Game.Rulesets.Taiko.Beatmaps
{
StartTime = j,
Samples = currentSamples,
IsStrong = strong,
HitWindows = obj.HitWindows
IsStrong = strong
};
}
else
@ -142,8 +141,7 @@ namespace osu.Game.Rulesets.Taiko.Beatmaps
{
StartTime = j,
Samples = currentSamples,
IsStrong = strong,
HitWindows = obj.HitWindows
IsStrong = strong
};
}
@ -158,8 +156,7 @@ namespace osu.Game.Rulesets.Taiko.Beatmaps
Samples = obj.Samples,
IsStrong = strong,
Duration = taikoDuration,
TickRate = beatmap.BeatmapInfo.BaseDifficulty.SliderTickRate == 3 ? 3 : 4,
HitWindows = obj.HitWindows
TickRate = beatmap.BeatmapInfo.BaseDifficulty.SliderTickRate == 3 ? 3 : 4
};
}
}
@ -173,8 +170,7 @@ namespace osu.Game.Rulesets.Taiko.Beatmaps
Samples = obj.Samples,
IsStrong = strong,
Duration = endTimeData.Duration,
RequiredHits = (int)Math.Max(1, endTimeData.Duration / 1000 * hitMultiplier),
HitWindows = obj.HitWindows
RequiredHits = (int)Math.Max(1, endTimeData.Duration / 1000 * hitMultiplier)
};
}
else
@ -187,8 +183,7 @@ namespace osu.Game.Rulesets.Taiko.Beatmaps
{
StartTime = obj.StartTime,
Samples = obj.Samples,
IsStrong = strong,
HitWindows = obj.HitWindows
IsStrong = strong
};
}
else
@ -197,8 +192,7 @@ namespace osu.Game.Rulesets.Taiko.Beatmaps
{
StartTime = obj.StartTime,
Samples = obj.Samples,
IsStrong = strong,
HitWindows = obj.HitWindows
IsStrong = strong
};
}
}

View File

@ -5,6 +5,7 @@ using System;
using System.Collections.Generic;
using osu.Game.Beatmaps;
using osu.Game.Rulesets.Difficulty;
using osu.Game.Rulesets.Mods;
using osu.Game.Rulesets.Taiko.Objects;
namespace osu.Game.Rulesets.Taiko.Difficulty
@ -35,6 +36,11 @@ namespace osu.Game.Rulesets.Taiko.Difficulty
{
}
public TaikoDifficultyCalculator(IBeatmap beatmap, Mod[] mods)
: base(beatmap, mods)
{
}
public override double Calculate(Dictionary<string, double> categoryDifficulty = null)
{
// Fill our custom DifficultyHitObject class, that carries additional information
@ -51,10 +57,7 @@ namespace osu.Game.Rulesets.Taiko.Difficulty
double starRating = calculateDifficulty() * star_scaling_factor;
if (categoryDifficulty != null)
{
categoryDifficulty.Add("Strain", starRating);
categoryDifficulty.Add("Hit window 300", 35 /*HitObjectManager.HitWindow300*/ / TimeRate);
}
categoryDifficulty["Strain"] = starRating;
return starRating;
}

View File

@ -0,0 +1,111 @@
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System;
using System.Collections.Generic;
using System.Linq;
using osu.Game.Beatmaps;
using osu.Game.Rulesets.Difficulty;
using osu.Game.Rulesets.Mods;
using osu.Game.Rulesets.Scoring;
using osu.Game.Rulesets.Taiko.Objects;
namespace osu.Game.Rulesets.Taiko.Difficulty
{
public class TaikoPerformanceCalculator : PerformanceCalculator
{
private readonly int beatmapMaxCombo;
private Mod[] mods;
private int countGreat;
private int countGood;
private int countMeh;
private int countMiss;
public TaikoPerformanceCalculator(Ruleset ruleset, IBeatmap beatmap, Score score)
: base(ruleset, beatmap, score)
{
beatmapMaxCombo = beatmap.HitObjects.Count(h => h is Hit);
}
public override double Calculate(Dictionary<string, double> categoryDifficulty = null)
{
mods = Score.Mods;
countGreat = Convert.ToInt32(Score.Statistics[HitResult.Great]);
countGood = Convert.ToInt32(Score.Statistics[HitResult.Good]);
countMeh = Convert.ToInt32(Score.Statistics[HitResult.Meh]);
countMiss = Convert.ToInt32(Score.Statistics[HitResult.Miss]);
// Don't count scores made with supposedly unranked mods
if (mods.Any(m => !m.Ranked))
return 0;
// Custom multipliers for NoFail and SpunOut.
double multiplier = 1.1; // This is being adjusted to keep the final pp value scaled around what it used to be when changing things
if (mods.Any(m => m is ModNoFail))
multiplier *= 0.90;
if (mods.Any(m => m is ModHidden))
multiplier *= 1.10;
double strainValue = computeStrainValue();
double accuracyValue = computeAccuracyValue();
double totalValue =
Math.Pow(
Math.Pow(strainValue, 1.1) +
Math.Pow(accuracyValue, 1.1), 1.0 / 1.1
) * multiplier;
if (categoryDifficulty != null)
{
categoryDifficulty["Strain"] = strainValue;
categoryDifficulty["Accuracy"] = accuracyValue;
}
return totalValue;
}
private double computeStrainValue()
{
double strainValue = Math.Pow(5.0 * Math.Max(1.0, Attributes["Strain"] / 0.0075) - 4.0, 2.0) / 100000.0;
// Longer maps are worth more
double lengthBonus = 1 + 0.1f * Math.Min(1.0, totalHits / 1500.0);
strainValue *= lengthBonus;
// Penalize misses exponentially. This mainly fixes tag4 maps and the likes until a per-hitobject solution is available
strainValue *= Math.Pow(0.985, countMiss);
// Combo scaling
if (beatmapMaxCombo > 0)
strainValue *= Math.Min(Math.Pow(Score.MaxCombo, 0.5) / Math.Pow(beatmapMaxCombo, 0.5), 1.0);
if (mods.Any(m => m is ModHidden))
strainValue *= 1.025;
if (mods.Any(m => m is ModFlashlight))
// Apply length bonus again if flashlight is on simply because it becomes a lot harder on longer maps.
strainValue *= 1.05 * lengthBonus;
// Scale the speed value with accuracy _slightly_
return strainValue * Score.Accuracy;
}
private double computeAccuracyValue()
{
double hitWindowGreat = (Beatmap.HitObjects.First().HitWindows.Great / 2 - 0.5) / TimeRate;
if (hitWindowGreat <= 0)
return 0;
// Lots of arbitrary values from testing.
// Considering to use derivation from perfect accuracy in a probabilistic manner - assume normal distribution
double accValue = Math.Pow(150.0 / hitWindowGreat, 1.1) * Math.Pow(Score.Accuracy, 15) * 22.0;
// Bonus for many hitcircles - it's harder to keep good accuracy up for longer
return accValue * Math.Min(1.15, Math.Pow(totalHits / 1500.0, 0.3));
}
private int totalHits => countGreat + countGood + countMeh + countMiss;
}
}

View File

@ -27,5 +27,7 @@ namespace osu.Game.Rulesets.Taiko.Objects
/// Strong hit objects give more points for hitting the hit object with both keys.
/// </summary>
public bool IsStrong;
protected override HitWindows CreateHitWindows() => new TaikoHitWindows();
}
}

View File

@ -3,11 +3,12 @@
using System.Collections.Generic;
using osu.Game.Beatmaps;
using osu.Game.Rulesets.Objects;
using osu.Game.Rulesets.Scoring;
namespace osu.Game.Rulesets.Objects.Legacy.Taiko
namespace osu.Game.Rulesets.Taiko.Objects
{
public class ConvertHitWindows : HitWindows
public class TaikoHitWindows : HitWindows
{
private static readonly IReadOnlyDictionary<HitResult, (double od0, double od5, double od10)> base_ranges = new Dictionary<HitResult, (double, double, double)>
{

View File

@ -14,6 +14,7 @@ using osu.Game.Rulesets.Replays.Types;
using osu.Game.Rulesets.Taiko.Replays;
using osu.Game.Beatmaps.Legacy;
using osu.Game.Rulesets.Difficulty;
using osu.Game.Rulesets.Scoring;
using osu.Game.Rulesets.Taiko.Beatmaps;
using osu.Game.Rulesets.Taiko.Difficulty;
@ -144,7 +145,9 @@ namespace osu.Game.Rulesets.Taiko
public override Drawable CreateIcon() => new SpriteIcon { Icon = FontAwesome.fa_osu_taiko_o };
public override DifficultyCalculator CreateDifficultyCalculator(IBeatmap beatmap, Mod[] mods = null) => new TaikoDifficultyCalculator(beatmap);
public override DifficultyCalculator CreateDifficultyCalculator(IBeatmap beatmap, Mod[] mods = null) => new TaikoDifficultyCalculator(beatmap, mods);
public override PerformanceCalculator CreatePerformanceCalculator(IBeatmap beatmap, Score score) => new TaikoPerformanceCalculator(this, beatmap, score);
public override int? LegacyID => 1;

View File

@ -6,6 +6,7 @@ using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Game.Beatmaps;
using osu.Game.Graphics.UserInterface;
using osu.Game.Online.Multiplayer;
using osu.Game.Rulesets;
using osu.Game.Screens.Multi.Components;
@ -111,6 +112,7 @@ namespace osu.Game.Tests.Visual
}
});
AddStep(@"select", () => first.State = SelectionState.Selected);
AddStep(@"change title", () => first.Room.Name.Value = @"I Changed Name");
AddStep(@"change host", () => first.Room.Host.Value = new User { Username = @"DrabWeb", Id = 6946022, Country = new Country { FlagName = @"CA" } });
AddStep(@"change status", () => first.Room.Status.Value = new RoomStatusPlaying());
@ -121,6 +123,7 @@ namespace osu.Game.Tests.Visual
new User { Statistics = new UserStatistics { Ranks = new UserStatistics.UserRanks { Global = 1254 } } },
new User { Statistics = new UserStatistics { Ranks = new UserStatistics.UserRanks { Global = 123189 } } },
});
AddStep(@"deselect", () => first.State = SelectionState.NotSelected);
}
[BackgroundDependencyLoader]

View File

@ -21,7 +21,7 @@ namespace osu.Game.Tests.Visual
{
base.LoadComplete();
var room = new Room
Room room = new Room
{
Name = { Value = @"My Awesome Room" },
Host = { Value = new User { Username = @"flyte", Id = 3103765, Country = new Country { FlagName = @"JP" } } },
@ -71,9 +71,13 @@ namespace osu.Game.Tests.Visual
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Room = room,
RelativeSizeAxes = Axes.Both,
Width = 0.5f,
});
AddStep(@"set room", () => inspector.Room = room);
AddStep(@"null room", () => inspector.Room = null);
AddStep(@"set room", () => inspector.Room = room);
AddStep(@"change title", () => room.Name.Value = @"A Better Room Than The Above");
AddStep(@"change host", () => room.Host.Value = new User { Username = @"DrabWeb", Id = 6946022, Country = new Country { FlagName = @"CA" } });
AddStep(@"change status", () => room.Status.Value = new RoomStatusPlaying());
@ -88,7 +92,7 @@ namespace osu.Game.Tests.Visual
AddStep(@"change room", () =>
{
var newRoom = new Room
Room newRoom = new Room
{
Name = { Value = @"My New, Better Than Ever Room" },
Host = { Value = new User { Username = @"Angelsim", Id = 1777162, Country = new Country { FlagName = @"KR" } } },

View File

@ -107,8 +107,14 @@ namespace osu.Game.Beatmaps
IBeatmap converted = converter.Convert();
// Apply difficulty mods
foreach (var mod in Mods.Value.OfType<IApplicableToDifficulty>())
mod.ApplyToDifficulty(converted.BeatmapInfo.BaseDifficulty);
if (Mods.Value.Any(m => m is IApplicableToDifficulty))
{
converted.BeatmapInfo = converted.BeatmapInfo.Clone();
converted.BeatmapInfo.BaseDifficulty = converted.BeatmapInfo.BaseDifficulty.Clone();
foreach (var mod in Mods.Value.OfType<IApplicableToDifficulty>())
mod.ApplyToDifficulty(converted.BeatmapInfo.BaseDifficulty);
}
// Post-process
rulesetInstance.CreateBeatmapProcessor(converted)?.PostProcess();

View File

@ -0,0 +1,11 @@
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
namespace osu.Game.Graphics.UserInterface
{
public enum SelectionState
{
NotSelected,
Selected
}
}

View File

@ -37,6 +37,9 @@ namespace osu.Game.Input.Bindings
new KeyBinding(InputKey.Down, GlobalAction.DecreaseVolume),
new KeyBinding(InputKey.MouseWheelDown, GlobalAction.DecreaseVolume),
new KeyBinding(InputKey.F4, GlobalAction.ToggleMute),
new KeyBinding(InputKey.Escape, GlobalAction.Back),
new KeyBinding(InputKey.MouseButton1, GlobalAction.Back)
};
public IEnumerable<KeyBinding> InGameKeyBindings => new[]
@ -80,5 +83,8 @@ namespace osu.Game.Input.Bindings
TakeScreenshot,
[Description("Toggle gameplay mouse buttons")]
ToggleGameplayMouseButtons,
[Description("Go back")]
Back
}
}

View File

@ -6,9 +6,11 @@ using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Input;
using osu.Framework.Input.Bindings;
using osu.Game.Graphics;
using osu.Game.Graphics.Containers;
using osu.Game.Graphics.Sprites;
using osu.Game.Input.Bindings;
using osu.Game.Overlays.Settings;
using osu.Game.Overlays.Settings.Sections;
using osu.Game.Screens.Ranking;
@ -96,7 +98,7 @@ namespace osu.Game.Overlays
});
}
private class BackButton : OsuClickableContainer
private class BackButton : OsuClickableContainer, IKeyBindingHandler<GlobalAction>
{
private AspectContainer aspect;
@ -146,6 +148,20 @@ namespace osu.Game.Overlays
aspect.ScaleTo(1, 1000, Easing.OutElastic);
return base.OnMouseUp(state, args);
}
public bool OnPressed(GlobalAction action)
{
switch (action)
{
case GlobalAction.Back:
TriggerOnClick();
return true;
}
return false;
}
public bool OnReleased(GlobalAction action) => false;
}
}
}

View File

@ -6,7 +6,9 @@ using osu.Framework.Allocation;
using osu.Framework.Caching;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Input;
using OpenTK;
using OpenTK.Input;
using OpenTK.Graphics;
using osu.Framework.Configuration;
using osu.Framework.Graphics.Shapes;
@ -22,6 +24,7 @@ namespace osu.Game.Overlays.Toolbar
private readonly Drawable modeButtonLine;
private ToolbarModeButton activeButton;
private RulesetStore rulesets;
private readonly Bindable<RulesetInfo> ruleset = new Bindable<RulesetInfo>();
public ToolbarModeSelector()
@ -67,26 +70,42 @@ namespace osu.Game.Overlays.Toolbar
[BackgroundDependencyLoader(true)]
private void load(RulesetStore rulesets, OsuGame game)
{
this.rulesets = rulesets;
foreach (var r in rulesets.AvailableRulesets)
{
modeButtons.Add(new ToolbarModeButton
{
Ruleset = r,
Action = delegate
{
ruleset.Value = r;
}
Action = delegate { ruleset.Value = r; }
});
}
ruleset.ValueChanged += rulesetChanged;
ruleset.DisabledChanged += disabledChanged;
if (game != null)
ruleset.BindTo(game.Ruleset);
else
ruleset.Value = rulesets.AvailableRulesets.FirstOrDefault();
}
protected override bool OnKeyDown(InputState state, KeyDownEventArgs args)
{
base.OnKeyDown(state, args);
if (state.Keyboard.ControlPressed && !args.Repeat && args.Key >= Key.Number1 && args.Key <= Key.Number9)
{
int requested = args.Key - Key.Number1;
RulesetInfo found = rulesets.AvailableRulesets.Skip(requested).FirstOrDefault();
if (found != null)
ruleset.Value = found;
return true;
}
return false;
}
public override bool HandleKeyboardInput => !ruleset.Disabled && base.HandleKeyboardInput;
public override bool HandleMouseInput => !ruleset.Disabled && base.HandleMouseInput;

View File

@ -16,6 +16,7 @@ namespace osu.Game.Rulesets.Difficulty
private readonly Dictionary<string, double> attributes = new Dictionary<string, double>();
protected IDictionary<string, double> Attributes => attributes;
protected readonly Ruleset Ruleset;
protected readonly IBeatmap Beatmap;
protected readonly Score Score;
@ -23,9 +24,9 @@ namespace osu.Game.Rulesets.Difficulty
protected PerformanceCalculator(Ruleset ruleset, IBeatmap beatmap, Score score)
{
Score = score;
Ruleset = ruleset;
Beatmap = beatmap;
Score = score;
var diffCalc = ruleset.CreateDifficultyCalculator(beatmap, score.Mods);
diffCalc.Calculate(attributes);

View File

@ -6,6 +6,7 @@ using osu.Framework;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Primitives;
using osu.Framework.Input;
using osu.Game.Graphics.UserInterface;
using osu.Game.Rulesets.Objects.Drawables;
using OpenTK;
@ -137,10 +138,4 @@ namespace osu.Game.Rulesets.Edit
/// </summary>
public virtual Quad SelectionQuad => ScreenSpaceDrawQuad;
}
public enum SelectionState
{
NotSelected,
Selected
}
}

View File

@ -135,39 +135,5 @@ namespace osu.Game.Rulesets.Objects
/// <param name="timeOffset">The time offset.</param>
/// <returns>Whether the <see cref="HitObject"/> can be hit at any point in the future from this time offset.</returns>
public bool CanBeHit(double timeOffset) => timeOffset <= HalfWindowFor(HitResult.Meh);
/// <summary>
/// Multiplies all hit windows by a value.
/// </summary>
/// <param name="windows">The hit windows to multiply.</param>
/// <param name="value">The value to multiply each hit window by.</param>
public static HitWindows operator *(HitWindows windows, double value)
{
windows.Perfect *= value;
windows.Great *= value;
windows.Good *= value;
windows.Ok *= value;
windows.Meh *= value;
windows.Miss *= value;
return windows;
}
/// <summary>
/// Divides all hit windows by a value.
/// </summary>
/// <param name="windows">The hit windows to divide.</param>
/// <param name="value">The value to divide each hit window by.</param>
public static HitWindows operator /(HitWindows windows, double value)
{
windows.Perfect /= value;
windows.Great /= value;
windows.Good /= value;
windows.Ok /= value;
windows.Meh /= value;
windows.Miss /= value;
return windows;
}
}
}

View File

@ -14,6 +14,6 @@ namespace osu.Game.Rulesets.Objects.Legacy.Mania
public bool NewCombo { get; set; }
protected override HitWindows CreateHitWindows() => new ConvertHitWindows();
protected override HitWindows CreateHitWindows() => null;
}
}

View File

@ -13,6 +13,6 @@ namespace osu.Game.Rulesets.Objects.Legacy.Mania
public double Duration => EndTime - StartTime;
protected override HitWindows CreateHitWindows() => new ConvertHitWindows();
protected override HitWindows CreateHitWindows() => null;
}
}

View File

@ -14,6 +14,6 @@ namespace osu.Game.Rulesets.Objects.Legacy.Mania
public bool NewCombo { get; set; }
protected override HitWindows CreateHitWindows() => new ConvertHitWindows();
protected override HitWindows CreateHitWindows() => null;
}
}

View File

@ -16,6 +16,6 @@ namespace osu.Game.Rulesets.Objects.Legacy.Mania
public float X { get; set; }
protected override HitWindows CreateHitWindows() => new ConvertHitWindows();
protected override HitWindows CreateHitWindows() => null;
}
}

View File

@ -19,6 +19,6 @@ namespace osu.Game.Rulesets.Objects.Legacy.Osu
public bool NewCombo { get; set; }
protected override HitWindows CreateHitWindows() => new ConvertHitWindows();
protected override HitWindows CreateHitWindows() => null;
}
}

View File

@ -19,6 +19,6 @@ namespace osu.Game.Rulesets.Objects.Legacy.Osu
public bool NewCombo { get; set; }
protected override HitWindows CreateHitWindows() => new ConvertHitWindows();
protected override HitWindows CreateHitWindows() => null;
}
}

View File

@ -21,6 +21,6 @@ namespace osu.Game.Rulesets.Objects.Legacy.Osu
public float Y => Position.Y;
protected override HitWindows CreateHitWindows() => new ConvertHitWindows();
protected override HitWindows CreateHitWindows() => null;
}
}

View File

@ -12,6 +12,6 @@ namespace osu.Game.Rulesets.Objects.Legacy.Taiko
{
public bool NewCombo { get; set; }
protected override HitWindows CreateHitWindows() => new ConvertHitWindows();
protected override HitWindows CreateHitWindows() => null;
}
}

View File

@ -12,6 +12,6 @@ namespace osu.Game.Rulesets.Objects.Legacy.Taiko
{
public bool NewCombo { get; set; }
protected override HitWindows CreateHitWindows() => new ConvertHitWindows();
protected override HitWindows CreateHitWindows() => null;
}
}

View File

@ -14,6 +14,6 @@ namespace osu.Game.Rulesets.Objects.Legacy.Taiko
public double Duration => EndTime - StartTime;
protected override HitWindows CreateHitWindows() => new ConvertHitWindows();
protected override HitWindows CreateHitWindows() => null;
}
}

View File

@ -19,6 +19,8 @@ namespace osu.Game.Screens
public override bool ShowOverlaysOnEnter => false;
protected override bool AllowBackButton => false;
public Loader()
{
ValidForResume = false;

View File

@ -6,22 +6,24 @@ using System.Collections.Generic;
using System.Linq;
using osu.Framework;
using osu.Framework.Allocation;
using osu.Framework.Audio;
using osu.Framework.Audio.Sample;
using osu.Framework.Configuration;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Input;
using osu.Framework.Input.Bindings;
using osu.Framework.Threading;
using osu.Game.Graphics;
using osu.Game.Input.Bindings;
using OpenTK;
using OpenTK.Graphics;
using OpenTK.Input;
using osu.Framework.Audio.Sample;
using osu.Framework.Audio;
using osu.Framework.Configuration;
using osu.Framework.Threading;
namespace osu.Game.Screens.Menu
{
public class ButtonSystem : Container, IStateful<MenuState>
public class ButtonSystem : Container, IStateful<MenuState>, IKeyBindingHandler<GlobalAction>
{
public event Action<MenuState> StateChanged;
@ -146,7 +148,16 @@ namespace osu.Game.Screens.Menu
case Key.Space:
logo?.TriggerOnClick(state);
return true;
case Key.Escape:
}
return false;
}
public bool OnPressed(GlobalAction action)
{
switch (action)
{
case GlobalAction.Back:
switch (State)
{
case MenuState.TopLevel:
@ -155,12 +166,23 @@ namespace osu.Game.Screens.Menu
case MenuState.Play:
backButton.TriggerOnClick();
return true;
default:
return false;
}
default:
return false;
}
}
return false;
public bool OnReleased(GlobalAction action)
{
switch (action)
{
case GlobalAction.Back:
return true;
default:
return false;
}
}
private void onPlay()
@ -337,6 +359,7 @@ namespace osu.Game.Screens.Menu
logo.ScaleTo(0.5f, 200, Easing.OutQuint);
break;
}
break;
case MenuState.EnteringMode:
logoTracking = true;

View File

@ -26,6 +26,8 @@ namespace osu.Game.Screens.Menu
public override bool ShowOverlaysOnEnter => buttons.State != MenuState.Initial;
protected override bool AllowBackButton => buttons.State != MenuState.Initial;
private readonly BackgroundScreenDefault background;
private Screen songSelect;

View File

@ -1,6 +1,8 @@
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System;
using osu.Framework;
using osu.Framework.Allocation;
using osu.Framework.Configuration;
using osu.Framework.Extensions.Color4Extensions;
@ -13,6 +15,7 @@ using osu.Game.Beatmaps.Drawables;
using osu.Game.Graphics;
using osu.Game.Graphics.Containers;
using osu.Game.Graphics.Sprites;
using osu.Game.Graphics.UserInterface;
using osu.Game.Online.Multiplayer;
using osu.Game.Users;
using OpenTK;
@ -20,20 +23,17 @@ using OpenTK.Graphics;
namespace osu.Game.Screens.Multi.Components
{
public class DrawableRoom : OsuClickableContainer
public class DrawableRoom : OsuClickableContainer, IStateful<SelectionState>
{
private const float corner_radius = 5;
private const float selection_border_width = 4;
private const float transition_duration = 100;
private const float content_padding = 10;
private const float height = 100;
private const float side_strip_width = 5;
private const float cover_width = 145;
private readonly Box sideStrip;
private readonly Container coverContainer;
private readonly OsuSpriteText name, status, beatmapTitle, beatmapDash, beatmapArtist;
private readonly FillFlowContainer<OsuSpriteText> beatmapInfoFlow;
private readonly ParticipantInfo participantInfo;
private readonly ModeTypeInfo modeTypeInfo;
private readonly Box selectionBox;
private readonly Bindable<string> nameBind = new Bindable<string>();
private readonly Bindable<User> hostBind = new Bindable<User>();
@ -42,136 +42,228 @@ namespace osu.Game.Screens.Multi.Components
private readonly Bindable<BeatmapInfo> beatmapBind = new Bindable<BeatmapInfo>();
private readonly Bindable<User[]> participantsBind = new Bindable<User[]>();
private OsuColour colours;
private LocalisationEngine localisation;
public readonly Room Room;
private SelectionState state;
public SelectionState State
{
get { return state; }
set
{
if (value == state) return;
state = value;
if (state == SelectionState.Selected)
selectionBox.FadeIn(transition_duration);
else
selectionBox.FadeOut(transition_duration);
StateChanged?.Invoke(State);
}
}
public event Action<SelectionState> StateChanged;
public DrawableRoom(Room room)
{
Room = room;
RelativeSizeAxes = Axes.X;
Height = height;
CornerRadius = 5;
Height = height + selection_border_width * 2;
CornerRadius = corner_radius + selection_border_width / 2;
Masking = true;
EdgeEffect = new EdgeEffectParameters
// create selectionBox here so State can be set before being loaded
selectionBox = new Box
{
Type = EdgeEffectType.Shadow,
Colour = Color4.Black.Opacity(40),
Radius = 5,
RelativeSizeAxes = Axes.Both,
Alpha = 0f,
};
Action += () => State = SelectionState.Selected;
}
[BackgroundDependencyLoader]
private void load(OsuColour colours, LocalisationEngine localisation)
{
Box sideStrip;
Container coverContainer;
OsuSpriteText name, status, beatmapTitle, beatmapDash, beatmapArtist;
ParticipantInfo participantInfo;
ModeTypeInfo modeTypeInfo;
Children = new Drawable[]
{
new Box
{
RelativeSizeAxes = Axes.Both,
Colour = OsuColour.FromHex(@"212121"),
},
sideStrip = new Box
{
RelativeSizeAxes = Axes.Y,
Width = side_strip_width,
},
new Container
{
Width = cover_width,
RelativeSizeAxes = Axes.Y,
Masking = true,
Margin = new MarginPadding { Left = side_strip_width },
Children = new Drawable[]
{
new Box
{
RelativeSizeAxes = Axes.Both,
Colour = Color4.Black,
},
coverContainer = new Container
{
RelativeSizeAxes = Axes.Both,
},
},
},
selectionBox,
new Container
{
RelativeSizeAxes = Axes.Both,
Padding = new MarginPadding
Padding = new MarginPadding(selection_border_width),
Child = new Container
{
Vertical = content_padding,
Left = side_strip_width + cover_width + content_padding,
Right = content_padding,
},
Children = new Drawable[]
{
new FillFlowContainer
RelativeSizeAxes = Axes.Both,
Masking = true,
CornerRadius = corner_radius,
EdgeEffect = new EdgeEffectParameters
{
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
Direction = FillDirection.Vertical,
Spacing = new Vector2(5f),
Children = new Drawable[]
Type = EdgeEffectType.Shadow,
Colour = Color4.Black.Opacity(40),
Radius = 5,
},
Children = new Drawable[]
{
new Box
{
name = new OsuSpriteText
{
TextSize = 18,
},
participantInfo = new ParticipantInfo(),
RelativeSizeAxes = Axes.Both,
Colour = OsuColour.FromHex(@"212121"),
},
},
new FillFlowContainer
{
Anchor = Anchor.BottomLeft,
Origin = Anchor.BottomLeft,
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
Direction = FillDirection.Vertical,
Children = new Drawable[]
sideStrip = new Box
{
status = new OsuSpriteText
RelativeSizeAxes = Axes.Y,
Width = side_strip_width,
},
new Container
{
Width = cover_width,
RelativeSizeAxes = Axes.Y,
Masking = true,
Margin = new MarginPadding { Left = side_strip_width },
Children = new Drawable[]
{
TextSize = 14,
Font = @"Exo2.0-Bold",
},
beatmapInfoFlow = new FillFlowContainer<OsuSpriteText>
{
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
Direction = FillDirection.Horizontal,
Children = new[]
new Box
{
beatmapTitle = new OsuSpriteText
RelativeSizeAxes = Axes.Both,
Colour = Color4.Black,
},
coverContainer = new Container
{
RelativeSizeAxes = Axes.Both,
},
},
},
new Container
{
RelativeSizeAxes = Axes.Both,
Padding = new MarginPadding
{
Vertical = content_padding,
Left = side_strip_width + cover_width + content_padding,
Right = content_padding,
},
Children = new Drawable[]
{
new FillFlowContainer
{
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
Direction = FillDirection.Vertical,
Spacing = new Vector2(5f),
Children = new Drawable[]
{
TextSize = 14,
Font = @"Exo2.0-BoldItalic",
name = new OsuSpriteText
{
TextSize = 18,
},
participantInfo = new ParticipantInfo(),
},
beatmapDash = new OsuSpriteText
},
new FillFlowContainer
{
Anchor = Anchor.BottomLeft,
Origin = Anchor.BottomLeft,
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
Direction = FillDirection.Vertical,
Children = new Drawable[]
{
TextSize = 14,
Font = @"Exo2.0-BoldItalic",
},
beatmapArtist = new OsuSpriteText
{
TextSize = 14,
Font = @"Exo2.0-RegularItalic",
status = new OsuSpriteText
{
TextSize = 14,
Font = @"Exo2.0-Bold",
},
new FillFlowContainer<OsuSpriteText>
{
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
Colour = colours.Gray9,
Direction = FillDirection.Horizontal,
Children = new[]
{
beatmapTitle = new OsuSpriteText
{
TextSize = 14,
Font = @"Exo2.0-BoldItalic",
},
beatmapDash = new OsuSpriteText
{
TextSize = 14,
Font = @"Exo2.0-BoldItalic",
},
beatmapArtist = new OsuSpriteText
{
TextSize = 14,
Font = @"Exo2.0-RegularItalic",
},
},
},
},
},
modeTypeInfo = new ModeTypeInfo
{
Anchor = Anchor.BottomRight,
Origin = Anchor.BottomRight,
},
},
},
},
modeTypeInfo = new ModeTypeInfo
{
Anchor = Anchor.BottomRight,
Origin = Anchor.BottomRight,
},
},
},
};
nameBind.ValueChanged += displayName;
hostBind.ValueChanged += displayUser;
typeBind.ValueChanged += displayGameType;
participantsBind.ValueChanged += displayParticipants;
nameBind.ValueChanged += n => name.Text = n;
hostBind.ValueChanged += h => participantInfo.Host = h;
typeBind.ValueChanged += m => modeTypeInfo.Type = m;
participantsBind.ValueChanged += p => participantInfo.Participants = p;
statusBind.ValueChanged += s =>
{
status.Text = s.Message;
foreach (Drawable d in new Drawable[] { selectionBox, sideStrip, status })
d.FadeColour(s.GetAppropriateColour(colours), 100);
};
beatmapBind.ValueChanged += b =>
{
modeTypeInfo.Beatmap = b;
if (b != null)
{
coverContainer.FadeIn(transition_duration);
LoadComponentAsync(new BeatmapSetCover(b.BeatmapSet)
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
FillMode = FillMode.Fill,
OnLoadComplete = d => d.FadeInFromZero(400, Easing.Out),
}, coverContainer.Add);
beatmapTitle.Current = localisation.GetUnicodePreference(b.Metadata.TitleUnicode, b.Metadata.Title);
beatmapDash.Text = @" - ";
beatmapArtist.Current = localisation.GetUnicodePreference(b.Metadata.ArtistUnicode, b.Metadata.Artist);
}
else
{
coverContainer.FadeOut(transition_duration);
beatmapTitle.Current = null;
beatmapArtist.Current = null;
beatmapTitle.Text = "Changing map";
beatmapDash.Text = beatmapArtist.Text = string.Empty;
}
};
nameBind.BindTo(Room.Name);
hostBind.BindTo(Room.Host);
@ -180,83 +272,5 @@ namespace osu.Game.Screens.Multi.Components
beatmapBind.BindTo(Room.Beatmap);
participantsBind.BindTo(Room.Participants);
}
[BackgroundDependencyLoader]
private void load(OsuColour colours, LocalisationEngine localisation)
{
this.localisation = localisation;
this.colours = colours;
beatmapInfoFlow.Colour = colours.Gray9;
//binded here instead of ctor because dependencies are needed
statusBind.ValueChanged += displayStatus;
beatmapBind.ValueChanged += displayBeatmap;
statusBind.TriggerChange();
beatmapBind.TriggerChange();
}
private void displayName(string value)
{
name.Text = value;
}
private void displayUser(User value)
{
participantInfo.Host = value;
}
private void displayStatus(RoomStatus value)
{
if (value == null) return;
status.Text = value.Message;
foreach (Drawable d in new Drawable[] { sideStrip, status })
d.FadeColour(value.GetAppropriateColour(colours), 100);
}
private void displayGameType(GameType value)
{
modeTypeInfo.Type = value;
}
private void displayBeatmap(BeatmapInfo value)
{
modeTypeInfo.Beatmap = value;
if (value != null)
{
coverContainer.FadeIn(transition_duration);
LoadComponentAsync(new BeatmapSetCover(value.BeatmapSet)
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
FillMode = FillMode.Fill,
OnLoadComplete = d => d.FadeInFromZero(400, Easing.Out),
},
coverContainer.Add);
beatmapTitle.Current = localisation.GetUnicodePreference(value.Metadata.TitleUnicode, value.Metadata.Title);
beatmapDash.Text = @" - ";
beatmapArtist.Current = localisation.GetUnicodePreference(value.Metadata.ArtistUnicode, value.Metadata.Artist);
}
else
{
coverContainer.FadeOut(transition_duration);
beatmapTitle.Current = null;
beatmapArtist.Current = null;
beatmapTitle.Text = "Changing map";
beatmapDash.Text = beatmapArtist.Text = string.Empty;
}
}
private void displayParticipants(User[] value)
{
participantInfo.Participants = value;
}
}
}

View File

@ -25,17 +25,9 @@ namespace osu.Game.Screens.Multi.Components
{
public class RoomInspector : Container
{
private readonly MarginPadding contentPadding = new MarginPadding { Horizontal = 20, Vertical = 10 };
private const float transition_duration = 100;
private readonly Box statusStrip;
private readonly Container coverContainer;
private readonly FillFlowContainer topFlow, participantsFlow;
private readonly ModeTypeInfo modeTypeInfo;
private readonly OsuSpriteText participants, participantsSlash, maxParticipants, name, status, beatmapTitle, beatmapDash, beatmapArtist, beatmapAuthor;
private readonly ParticipantInfo participantInfo;
private readonly ScrollContainer participantsScroll;
private readonly MarginPadding contentPadding = new MarginPadding { Horizontal = 20, Vertical = 10 };
private readonly Bindable<string> nameBind = new Bindable<string>();
private readonly Bindable<User> hostBind = new Bindable<User>();
private readonly Bindable<RoomStatus> statusBind = new Bindable<RoomStatus>();
@ -45,10 +37,14 @@ namespace osu.Game.Screens.Multi.Components
private readonly Bindable<User[]> participantsBind = new Bindable<User[]>();
private OsuColour colours;
private LocalisationEngine localisation;
private Box statusStrip;
private Container coverContainer;
private FillFlowContainer topFlow, participantsFlow, participantNumbersFlow, infoPanelFlow;
private OsuSpriteText name, status;
private ScrollContainer participantsScroll;
private ParticipantInfo participantInfo;
private Room room;
public Room Room
{
get { return room; }
@ -57,20 +53,36 @@ namespace osu.Game.Screens.Multi.Components
if (value == room) return;
room = value;
nameBind.BindTo(Room.Name);
hostBind.BindTo(Room.Host);
statusBind.BindTo(Room.Status);
typeBind.BindTo(Room.Type);
beatmapBind.BindTo(Room.Beatmap);
maxParticipantsBind.BindTo(Room.MaxParticipants);
participantsBind.BindTo(Room.Participants);
nameBind.UnbindBindings();
hostBind.UnbindBindings();
statusBind.UnbindBindings();
typeBind.UnbindBindings();
beatmapBind.UnbindBindings();
maxParticipantsBind.UnbindBindings();
participantsBind.UnbindBindings();
if (room != null)
{
nameBind.BindTo(room.Name);
hostBind.BindTo(room.Host);
statusBind.BindTo(room.Status);
typeBind.BindTo(room.Type);
beatmapBind.BindTo(room.Beatmap);
maxParticipantsBind.BindTo(room.MaxParticipants);
participantsBind.BindTo(room.Participants);
}
updateState();
}
}
public RoomInspector()
[BackgroundDependencyLoader]
private void load(OsuColour colours, LocalisationEngine localisation)
{
Width = 520;
RelativeSizeAxes = Axes.Y;
this.colours = colours;
ModeTypeInfo modeTypeInfo;
OsuSpriteText participants, participantsSlash, maxParticipants, beatmapTitle, beatmapDash, beatmapArtist, beatmapAuthor;
Children = new Drawable[]
{
@ -120,7 +132,7 @@ namespace osu.Game.Screens.Multi.Components
Padding = new MarginPadding(20),
Children = new Drawable[]
{
new FillFlowContainer
participantNumbersFlow = new FillFlowContainer
{
Anchor = Anchor.TopRight,
Origin = Anchor.TopRight,
@ -178,6 +190,7 @@ namespace osu.Game.Screens.Multi.Components
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
Direction = FillDirection.Vertical,
LayoutDuration = transition_duration,
Padding = contentPadding,
Spacing = new Vector2(0f, 5f),
Children = new Drawable[]
@ -187,7 +200,7 @@ namespace osu.Game.Screens.Multi.Components
TextSize = 14,
Font = @"Exo2.0-Bold",
},
new FillFlowContainer
infoPanelFlow = new FillFlowContainer
{
AutoSizeAxes = Axes.X,
Height = 30,
@ -229,6 +242,7 @@ namespace osu.Game.Screens.Multi.Components
Anchor = Anchor.BottomLeft,
Origin = Anchor.BottomLeft,
TextSize = 14,
Colour = colours.Gray9,
},
},
},
@ -269,27 +283,68 @@ namespace osu.Game.Screens.Multi.Components
},
};
nameBind.ValueChanged += displayName;
hostBind.ValueChanged += displayUser;
typeBind.ValueChanged += displayGameType;
maxParticipantsBind.ValueChanged += displayMaxParticipants;
participantsBind.ValueChanged += displayParticipants;
}
[BackgroundDependencyLoader]
private void load(OsuColour colours, LocalisationEngine localisation)
{
this.localisation = localisation;
this.colours = colours;
beatmapAuthor.Colour = colours.Gray9;
//binded here instead of ctor because dependencies are needed
nameBind.ValueChanged += n => name.Text = n;
hostBind.ValueChanged += h => participantInfo.Host = h;
typeBind.ValueChanged += t => modeTypeInfo.Type = t;
statusBind.ValueChanged += displayStatus;
beatmapBind.ValueChanged += displayBeatmap;
statusBind.TriggerChange();
beatmapBind.TriggerChange();
beatmapBind.ValueChanged += b =>
{
modeTypeInfo.Beatmap = b;
if (b != null)
{
coverContainer.FadeIn(transition_duration);
LoadComponentAsync(new BeatmapSetCover(b.BeatmapSet)
{
RelativeSizeAxes = Axes.Both,
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
FillMode = FillMode.Fill,
OnLoadComplete = d => d.FadeInFromZero(400, Easing.Out),
}, coverContainer.Add);
beatmapTitle.Current = localisation.GetUnicodePreference(b.Metadata.TitleUnicode, b.Metadata.Title);
beatmapDash.Text = @" - ";
beatmapArtist.Current = localisation.GetUnicodePreference(b.Metadata.ArtistUnicode, b.Metadata.Artist);
beatmapAuthor.Text = $"mapped by {b.Metadata.Author}";
}
else
{
coverContainer.FadeOut(transition_duration);
beatmapTitle.Current = null;
beatmapArtist.Current = null;
beatmapTitle.Text = "Changing map";
beatmapDash.Text = beatmapArtist.Text = beatmapAuthor.Text = string.Empty;
}
};
maxParticipantsBind.ValueChanged += m =>
{
if (m == null)
{
participantsSlash.FadeOut(transition_duration);
maxParticipants.FadeOut(transition_duration);
}
else
{
participantsSlash.FadeIn(transition_duration);
maxParticipants.FadeIn(transition_duration);
maxParticipants.Text = m.ToString();
}
};
participantsBind.ValueChanged += p =>
{
participants.Text = p.Length.ToString();
participantInfo.Participants = p;
participantsFlow.ChildrenEnumerable = p.Select(u => new UserTile(u));
};
updateState();
}
protected override void UpdateAfterChildren()
@ -299,84 +354,39 @@ namespace osu.Game.Screens.Multi.Components
participantsScroll.Height = DrawHeight - topFlow.DrawHeight;
}
private void displayName(string value)
private void displayStatus(RoomStatus s)
{
name.Text = value;
status.Text = s.Message;
Color4 c = s.GetAppropriateColour(colours);
statusStrip.FadeColour(c, transition_duration);
status.FadeColour(c, transition_duration);
}
private void displayUser(User value)
private void updateState()
{
participantInfo.Host = value;
}
private void displayStatus(RoomStatus value)
{
status.Text = value.Message;
foreach (Drawable d in new Drawable[] { statusStrip, status })
d.FadeColour(value.GetAppropriateColour(colours), transition_duration);
}
private void displayGameType(GameType value)
{
modeTypeInfo.Type = value;
}
private void displayBeatmap(BeatmapInfo value)
{
modeTypeInfo.Beatmap = value;
if (value != null)
{
coverContainer.FadeIn(transition_duration);
LoadComponentAsync(new BeatmapSetCover(value.BeatmapSet)
{
RelativeSizeAxes = Axes.Both,
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
FillMode = FillMode.Fill,
OnLoadComplete = d => d.FadeInFromZero(400, Easing.Out),
},
coverContainer.Add);
beatmapTitle.Current = localisation.GetUnicodePreference(value.Metadata.TitleUnicode, value.Metadata.Title);
beatmapDash.Text = @" - ";
beatmapArtist.Current = localisation.GetUnicodePreference(value.Metadata.ArtistUnicode, value.Metadata.Artist);
beatmapAuthor.Text = $"mapped by {value.Metadata.Author}";
}
else
if (Room == null)
{
coverContainer.FadeOut(transition_duration);
participantsFlow.FadeOut(transition_duration);
participantNumbersFlow.FadeOut(transition_duration);
infoPanelFlow.FadeOut(transition_duration);
name.FadeOut(transition_duration);
participantInfo.FadeOut(transition_duration);
beatmapTitle.Current = null;
beatmapArtist.Current = null;
beatmapTitle.Text = "Changing map";
beatmapDash.Text = beatmapArtist.Text = beatmapAuthor.Text = string.Empty;
}
}
private void displayMaxParticipants(int? value)
{
if (value == null)
{
participantsSlash.FadeOut(transition_duration);
maxParticipants.FadeOut(transition_duration);
displayStatus(new RoomStatusNoneSelected());
}
else
{
participantsSlash.FadeIn(transition_duration);
maxParticipants.FadeIn(transition_duration);
maxParticipants.Text = value.ToString();
}
}
participantsFlow.FadeIn(transition_duration);
participantNumbersFlow.FadeIn(transition_duration);
infoPanelFlow.FadeIn(transition_duration);
name.FadeIn(transition_duration);
participantInfo.FadeIn(transition_duration);
private void displayParticipants(User[] value)
{
participants.Text = value.Length.ToString();
participantInfo.Participants = value;
participantsFlow.ChildrenEnumerable = value.Select(u => new UserTile(u));
statusBind.TriggerChange();
beatmapBind.TriggerChange();
}
}
private class UserTile : Container, IHasTooltip
@ -407,5 +417,11 @@ namespace osu.Game.Screens.Multi.Components
};
}
}
private class RoomStatusNoneSelected : RoomStatus
{
public override string Message => @"No Room Selected";
public override Color4 GetAppropriateColour(OsuColour colours) => colours.Gray8;
}
}
}

View File

@ -3,25 +3,29 @@
using System;
using osu.Framework.Allocation;
using osu.Framework.Audio;
using osu.Framework.Audio.Sample;
using osu.Framework.Configuration;
using osu.Framework.Graphics;
using osu.Framework.Input;
using osu.Framework.Input.Bindings;
using osu.Framework.Screens;
using osu.Game.Beatmaps;
using osu.Game.Graphics.Containers;
using OpenTK;
using osu.Framework.Audio.Sample;
using osu.Framework.Audio;
using osu.Framework.Graphics;
using osu.Game.Input.Bindings;
using osu.Game.Rulesets;
using osu.Game.Screens.Menu;
using osu.Framework.Input;
using OpenTK;
using OpenTK.Input;
namespace osu.Game.Screens
{
public abstract class OsuScreen : Screen
public abstract class OsuScreen : Screen, IKeyBindingHandler<GlobalAction>
{
public BackgroundScreen Background { get; private set; }
protected virtual bool AllowBackButton => true;
/// <summary>
/// Override to create a BackgroundMode for the current screen.
/// Note that the instance created may not be the used instance if it matches the BackgroundMode equality clause.
@ -90,6 +94,19 @@ namespace osu.Game.Screens
sampleExit = audio.Sample.Get(@"UI/screen-back");
}
public bool OnPressed(GlobalAction action)
{
if (action == GlobalAction.Back && AllowBackButton)
{
Exit();
return true;
}
return false;
}
public bool OnReleased(GlobalAction action) => action == GlobalAction.Back && AllowBackButton;
protected override bool OnKeyDown(InputState state, KeyDownEventArgs args)
{
if (args.Repeat || !IsCurrentScreen) return false;

View File

@ -45,6 +45,8 @@ namespace osu.Game.Screens.Play
public bool AllowLeadIn { get; set; } = true;
public bool AllowResults { get; set; } = true;
protected override bool AllowBackButton => false;
private Bindable<bool> mouseWheelDisabled;
private Bindable<double> userAudioOffset;

View File

@ -190,7 +190,5 @@ namespace osu.Game.Screens.Select
protected override bool OnMouseMove(InputState state) => true;
protected override bool OnClick(InputState state) => true;
protected override bool OnDragStart(InputState state) => true;
}
}

View File

@ -141,7 +141,5 @@ namespace osu.Game.Screens.Select
protected override bool OnMouseDown(InputState state, MouseDownEventArgs args) => true;
protected override bool OnClick(InputState state) => true;
protected override bool OnDragStart(InputState state) => true;
}
}