Merge branch 'master' into mania-mask-container

This commit is contained in:
Dan Balasescu 2018-07-19 19:38:43 +09:00 committed by GitHub
commit 5dba048c46
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 155 additions and 135 deletions

View File

@ -28,18 +28,20 @@ namespace osu.Game.Rulesets.Catch.Tests
protected override IEnumerable<ConvertValue> CreateConvertValue(HitObject hitObject) protected override IEnumerable<ConvertValue> CreateConvertValue(HitObject hitObject)
{ {
if (hitObject is JuiceStream stream) switch (hitObject)
{ {
foreach (var nested in stream.NestedHitObjects) case JuiceStream stream:
yield return new ConvertValue((CatchHitObject)nested); foreach (var nested in stream.NestedHitObjects)
yield return new ConvertValue((CatchHitObject)nested);
break;
case BananaShower shower:
foreach (var nested in shower.NestedHitObjects)
yield return new ConvertValue((CatchHitObject)nested);
break;
default:
yield return new ConvertValue((CatchHitObject)hitObject);
break;
} }
else if (hitObject is BananaShower shower)
{
foreach (var nested in shower.NestedHitObjects)
yield return new ConvertValue((CatchHitObject)nested);
}
else
yield return new ConvertValue((CatchHitObject)hitObject);
} }
protected override Ruleset CreateRuleset() => new CatchRuleset(); protected override Ruleset CreateRuleset() => new CatchRuleset();

View File

@ -46,13 +46,16 @@ namespace osu.Game.Rulesets.Catch.Difficulty
foreach (var hitObject in beatmap.HitObjects) foreach (var hitObject in beatmap.HitObjects)
{ {
// We want to only consider fruits that contribute to the combo. Droplets are addressed as accuracy and spinners are not relevant for "skill" calculations. switch (hitObject)
if (hitObject is Fruit)
{ {
difficultyHitObjects.Add(new CatchDifficultyHitObject((CatchHitObject)hitObject, halfCatchWidth)); // We want to only consider fruits that contribute to the combo. Droplets are addressed as accuracy and spinners are not relevant for "skill" calculations.
case Fruit fruit:
difficultyHitObjects.Add(new CatchDifficultyHitObject(fruit, halfCatchWidth));
break;
case JuiceStream _:
difficultyHitObjects.AddRange(hitObject.NestedHitObjects.OfType<CatchHitObject>().Where(o => !(o is TinyDroplet)).Select(o => new CatchDifficultyHitObject(o, halfCatchWidth)));
break;
} }
if (hitObject is JuiceStream)
difficultyHitObjects.AddRange(hitObject.NestedHitObjects.OfType<CatchHitObject>().Where(o => !(o is TinyDroplet)).Select(o => new CatchDifficultyHitObject(o, halfCatchWidth)));
} }
difficultyHitObjects.Sort((a, b) => a.BaseHitObject.StartTime.CompareTo(b.BaseHitObject.StartTime)); difficultyHitObjects.Sort((a, b) => a.BaseHitObject.StartTime.CompareTo(b.BaseHitObject.StartTime));

View File

@ -33,15 +33,19 @@ namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns.Legacy
bool generateHold = endTime - HitObject.StartTime >= 100; bool generateHold = endTime - HitObject.StartTime >= 100;
if (TotalColumns == 8) switch (TotalColumns)
{ {
if (HitObject.Samples.Any(s => s.Name == SampleInfo.HIT_FINISH) && endTime - HitObject.StartTime < 1000) case 8 when HitObject.Samples.Any(s => s.Name == SampleInfo.HIT_FINISH) && endTime - HitObject.StartTime < 1000:
addToPattern(pattern, 0, generateHold); addToPattern(pattern, 0, generateHold);
else break;
case 8:
addToPattern(pattern, getNextRandomColumn(RandomStart), generateHold); addToPattern(pattern, getNextRandomColumn(RandomStart), generateHold);
break;
default:
if (TotalColumns > 0)
addToPattern(pattern, getNextRandomColumn(0), generateHold);
break;
} }
else if (TotalColumns > 0)
addToPattern(pattern, getNextRandomColumn(0), generateHold);
return pattern; return pattern;
} }

View File

@ -56,10 +56,15 @@ namespace osu.Game.Rulesets.Mania.Replays
{ {
foreach (var point in group) foreach (var point in group)
{ {
if (point is HitPoint) switch (point)
actions.Add(columnActions[point.Column]); {
if (point is ReleasePoint) case HitPoint _:
actions.Remove(columnActions[point.Column]); actions.Add(columnActions[point.Column]);
break;
case ReleasePoint _:
actions.Remove(columnActions[point.Column]);
break;
}
} }
Replay.Frames.Add(new ManiaReplayFrame(group.First().Time, actions.ToArray())); Replay.Frames.Add(new ManiaReplayFrame(group.First().Time, actions.ToArray()));

View File

@ -285,44 +285,45 @@ namespace osu.Game.Rulesets.Osu.Replays
AddFrameToReplay(startFrame); AddFrameToReplay(startFrame);
// We add intermediate frames for spinning / following a slider here. switch (h)
if (h is Spinner)
{ {
Spinner s = h as Spinner; // We add intermediate frames for spinning / following a slider here.
case Spinner spinner:
Vector2 difference = startPosition - SPINNER_CENTRE;
float radius = difference.Length;
float angle = radius == 0 ? 0 : (float)Math.Atan2(difference.Y, difference.X);
double t;
for (double j = h.StartTime + FrameDelay; j < s.EndTime; j += FrameDelay)
{ {
t = ApplyModsToTime(j - h.StartTime) * spinnerDirection; Vector2 difference = startPosition - SPINNER_CENTRE;
Vector2 pos = SPINNER_CENTRE + CirclePosition(t / 20 + angle, SPIN_RADIUS); float radius = difference.Length;
AddFrameToReplay(new OsuReplayFrame((int)j, new Vector2(pos.X, pos.Y), action)); float angle = radius == 0 ? 0 : (float)Math.Atan2(difference.Y, difference.X);
double t;
for (double j = h.StartTime + FrameDelay; j < spinner.EndTime; j += FrameDelay)
{
t = ApplyModsToTime(j - h.StartTime) * spinnerDirection;
Vector2 pos = SPINNER_CENTRE + CirclePosition(t / 20 + angle, SPIN_RADIUS);
AddFrameToReplay(new OsuReplayFrame((int)j, new Vector2(pos.X, pos.Y), action));
}
t = ApplyModsToTime(spinner.EndTime - h.StartTime) * spinnerDirection;
Vector2 endPosition = SPINNER_CENTRE + CirclePosition(t / 20 + angle, SPIN_RADIUS);
AddFrameToReplay(new OsuReplayFrame(spinner.EndTime, new Vector2(endPosition.X, endPosition.Y), action));
endFrame.Position = endPosition;
break;
} }
case Slider slider:
t = ApplyModsToTime(s.EndTime - h.StartTime) * spinnerDirection;
Vector2 endPosition = SPINNER_CENTRE + CirclePosition(t / 20 + angle, SPIN_RADIUS);
AddFrameToReplay(new OsuReplayFrame(s.EndTime, new Vector2(endPosition.X, endPosition.Y), action));
endFrame.Position = endPosition;
}
else if (h is Slider)
{
Slider s = h as Slider;
for (double j = FrameDelay; j < s.Duration; j += FrameDelay)
{ {
Vector2 pos = s.StackedPositionAt(j / s.Duration); for (double j = FrameDelay; j < slider.Duration; j += FrameDelay)
AddFrameToReplay(new OsuReplayFrame(h.StartTime + j, new Vector2(pos.X, pos.Y), action)); {
} Vector2 pos = slider.StackedPositionAt(j / slider.Duration);
AddFrameToReplay(new OsuReplayFrame(h.StartTime + j, new Vector2(pos.X, pos.Y), action));
}
AddFrameToReplay(new OsuReplayFrame(s.EndTime, new Vector2(s.StackedEndPosition.X, s.StackedEndPosition.Y), action)); AddFrameToReplay(new OsuReplayFrame(slider.EndTime, new Vector2(slider.StackedEndPosition.X, slider.StackedEndPosition.Y), action));
break;
}
} }
// We only want to let go of our button if we are at the end of the current replay. Otherwise something is still going on after us so we need to keep the button pressed! // We only want to let go of our button if we are at the end of the current replay. Otherwise something is still going on after us so we need to keep the button pressed!

View File

@ -34,14 +34,16 @@ namespace osu.Game.Rulesets.Osu.UI
protected override DrawableHitObject<OsuHitObject> GetVisualRepresentation(OsuHitObject h) protected override DrawableHitObject<OsuHitObject> GetVisualRepresentation(OsuHitObject h)
{ {
if (h is HitCircle circle) switch (h)
return new DrawableHitCircle(circle); {
case HitCircle circle:
return new DrawableHitCircle(circle);
case Slider slider:
return new DrawableSlider(slider);
case Spinner spinner:
return new DrawableSpinner(spinner);
}
if (h is Slider slider)
return new DrawableSlider(slider);
if (h is Spinner spinner)
return new DrawableSpinner(spinner);
return null; return null;
} }

View File

@ -80,30 +80,31 @@ namespace osu.Game.Rulesets.Taiko.Scoring
foreach (var obj in beatmap.HitObjects) foreach (var obj in beatmap.HitObjects)
{ {
if (obj is Hit) switch (obj)
{ {
AddJudgement(new TaikoJudgement { Result = HitResult.Great }); case Hit _:
if (obj.IsStrong) AddJudgement(new TaikoJudgement { Result = HitResult.Great });
AddJudgement(new TaikoStrongHitJudgement()); if (obj.IsStrong)
} AddJudgement(new TaikoStrongHitJudgement());
else if (obj is DrumRoll) break;
{ case DrumRoll drumRoll:
for (int i = 0; i < ((DrumRoll)obj).NestedHitObjects.OfType<DrumRollTick>().Count(); i++) var count = drumRoll.NestedHitObjects.OfType<DrumRollTick>().Count();
{ for (int i = 0; i < count; i++)
AddJudgement(new TaikoDrumRollTickJudgement { Result = HitResult.Great }); {
AddJudgement(new TaikoDrumRollTickJudgement { Result = HitResult.Great });
if (obj.IsStrong)
AddJudgement(new TaikoStrongHitJudgement());
}
AddJudgement(new TaikoJudgement { Result = HitResult.Great });
if (obj.IsStrong) if (obj.IsStrong)
AddJudgement(new TaikoStrongHitJudgement()); AddJudgement(new TaikoStrongHitJudgement());
} break;
case Swell _:
AddJudgement(new TaikoJudgement { Result = HitResult.Great }); AddJudgement(new TaikoJudgement { Result = HitResult.Great });
break;
if (obj.IsStrong)
AddJudgement(new TaikoStrongHitJudgement());
}
else if (obj is Swell)
{
AddJudgement(new TaikoJudgement { Result = HitResult.Great });
} }
} }
} }

View File

@ -213,13 +213,15 @@ namespace osu.Game.Rulesets.Taiko.UI
base.Add(h); base.Add(h);
var barline = h as DrawableBarLine; switch (h)
if (barline != null) {
barlineContainer.Add(barline.CreateProxy()); case DrawableBarLine barline:
barlineContainer.Add(barline.CreateProxy());
var taikoObject = h as DrawableTaikoHitObject; break;
if (taikoObject != null) case DrawableTaikoHitObject taikoObject:
topLevelHitContainer.Add(taikoObject.CreateProxiedContent()); topLevelHitContainer.Add(taikoObject.CreateProxiedContent());
break;
}
} }
internal void OnJudgement(DrawableHitObject judgedObject, Judgement judgement) internal void OnJudgement(DrawableHitObject judgedObject, Judgement judgement)

View File

@ -98,32 +98,22 @@ namespace osu.Game.Rulesets.Taiko.UI
protected override DrawableHitObject<TaikoHitObject> GetVisualRepresentation(TaikoHitObject h) protected override DrawableHitObject<TaikoHitObject> GetVisualRepresentation(TaikoHitObject h)
{ {
var centreHit = h as CentreHit; switch (h)
if (centreHit != null)
{ {
if (h.IsStrong) case CentreHit centreHit when h.IsStrong:
return new DrawableCentreHitStrong(centreHit); return new DrawableCentreHitStrong(centreHit);
return new DrawableCentreHit(centreHit); case CentreHit centreHit:
} return new DrawableCentreHit(centreHit);
case RimHit rimHit when h.IsStrong:
var rimHit = h as RimHit;
if (rimHit != null)
{
if (h.IsStrong)
return new DrawableRimHitStrong(rimHit); return new DrawableRimHitStrong(rimHit);
return new DrawableRimHit(rimHit); case RimHit rimHit:
return new DrawableRimHit(rimHit);
case DrumRoll drumRoll:
return new DrawableDrumRoll(drumRoll);
case Swell swell:
return new DrawableSwell(swell);
} }
var drumRoll = h as DrumRoll;
if (drumRoll != null)
{
return new DrawableDrumRoll(drumRoll);
}
var swell = h as Swell;
if (swell != null)
return new DrawableSwell(swell);
return null; return null;
} }

View File

@ -73,12 +73,17 @@ namespace osu.Game.Overlays.BeatmapSet.Buttons
downloader.Download(); downloader.Download();
}; };
downloader.DownloadState.ValueChanged += d => downloader.DownloadState.ValueChanged += state =>
{ {
if (d == BeatmapSetDownloader.DownloadStatus.Downloaded) switch (state)
this.FadeOut(200); {
else if (d == BeatmapSetDownloader.DownloadStatus.NotDownloaded) case BeatmapSetDownloader.DownloadStatus.Downloaded:
this.FadeIn(200); this.FadeOut(200);
break;
case BeatmapSetDownloader.DownloadStatus.NotDownloaded:
this.FadeIn(200);
break;
}
}; };
} }
} }

View File

@ -31,7 +31,7 @@ namespace osu.Game.Overlays.Direct
public DirectGridPanel(BeatmapSetInfo beatmap) : base(beatmap) public DirectGridPanel(BeatmapSetInfo beatmap) : base(beatmap)
{ {
Width = 400; Width = 380;
Height = 140 + vertical_padding; //full height of all the elements plus vertical padding (autosize uses the image) Height = 140 + vertical_padding; //full height of all the elements plus vertical padding (autosize uses the image)
} }

View File

@ -188,16 +188,17 @@ namespace osu.Game.Overlays
int optionCount = 0; int optionCount = 0;
int selectedOption = -1; int selectedOption = -1;
if (description.RawValue is bool) switch (description.RawValue)
{ {
optionCount = 1; case bool val:
if ((bool)description.RawValue) selectedOption = 0; optionCount = 1;
} if (val) selectedOption = 0;
else if (description.RawValue is Enum) break;
{ case Enum _:
var values = Enum.GetValues(description.RawValue.GetType()); var values = Enum.GetValues(description.RawValue.GetType());
optionCount = values.Length; optionCount = values.Length;
selectedOption = Convert.ToInt32(description.RawValue); selectedOption = Convert.ToInt32(description.RawValue);
break;
} }
textLine2.Origin = optionCount > 0 ? Anchor.BottomCentre : Anchor.Centre; textLine2.Origin = optionCount > 0 ? Anchor.BottomCentre : Anchor.Centre;

View File

@ -62,15 +62,19 @@ namespace osu.Game.Rulesets.Difficulty
IEnumerable<Mod> createDifficultyAdjustmentModCombinations(IEnumerable<Mod> currentSet, Mod[] adjustmentSet, int currentSetCount = 0, int adjustmentSetStart = 0) IEnumerable<Mod> createDifficultyAdjustmentModCombinations(IEnumerable<Mod> currentSet, Mod[] adjustmentSet, int currentSetCount = 0, int adjustmentSetStart = 0)
{ {
// Initial-case: Empty current set switch (currentSetCount)
if (currentSetCount == 0) {
yield return new NoModMod(); case 0:
// Initial-case: Empty current set
if (currentSetCount == 1) yield return new NoModMod();
yield return currentSet.Single(); break;
case 1:
if (currentSetCount > 1) yield return currentSet.Single();
yield return new MultiMod(currentSet.ToArray()); break;
default:
yield return new MultiMod(currentSet.ToArray());
break;
}
// Apply mods in the adjustment set recursively. Using the entire adjustment set would result in duplicate multi-mod mod // Apply mods in the adjustment set recursively. Using the entire adjustment set would result in duplicate multi-mod mod
// combinations in further recursions, so a moving subset is used to eliminate this effect // combinations in further recursions, so a moving subset is used to eliminate this effect