mirror of
https://github.com/ppy/osu.git
synced 2024-11-06 07:47:25 +08:00
Merge branch 'master' into master
This commit is contained in:
commit
fbb7dc4507
@ -5,20 +5,17 @@ using osu.Game.Beatmaps;
|
||||
using osu.Game.Rulesets.Catch.Objects;
|
||||
using osu.Game.Rulesets.Catch.Replays;
|
||||
using osu.Game.Rulesets.Mods;
|
||||
using osu.Game.Rulesets.Scoring;
|
||||
using osu.Game.Scoring;
|
||||
using osu.Game.Users;
|
||||
|
||||
namespace osu.Game.Rulesets.Catch.Mods
|
||||
{
|
||||
public class CatchModAutoplay : ModAutoplay<CatchHitObject>
|
||||
{
|
||||
protected override Score CreateReplayScore(Beatmap<CatchHitObject> beatmap)
|
||||
protected override Score CreateReplayScore(Beatmap<CatchHitObject> beatmap) => new Score
|
||||
{
|
||||
return new Score
|
||||
{
|
||||
User = new User { Username = "osu!salad!" },
|
||||
Replay = new CatchAutoGenerator(beatmap).Generate(),
|
||||
};
|
||||
}
|
||||
ScoreInfo = new ScoreInfo { User = new User { Username = "osu!salad!" } },
|
||||
Replay = new CatchAutoGenerator(beatmap).Generate(),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -5,10 +5,10 @@ using System;
|
||||
using System.Linq;
|
||||
using osu.Framework.MathUtils;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Replays;
|
||||
using osu.Game.Rulesets.Catch.Objects;
|
||||
using osu.Game.Rulesets.Catch.UI;
|
||||
using osu.Game.Rulesets.Replays;
|
||||
using osu.Game.Users;
|
||||
|
||||
namespace osu.Game.Rulesets.Catch.Replays
|
||||
{
|
||||
@ -19,7 +19,7 @@ namespace osu.Game.Rulesets.Catch.Replays
|
||||
public CatchAutoGenerator(Beatmap<CatchHitObject> beatmap)
|
||||
: base(beatmap)
|
||||
{
|
||||
Replay = new Replay { User = new User { Username = @"Autoplay" } };
|
||||
Replay = new Replay();
|
||||
}
|
||||
|
||||
protected Replay Replay;
|
||||
|
@ -4,6 +4,7 @@
|
||||
using System.Collections.Generic;
|
||||
using osu.Framework.Input.StateChanges;
|
||||
using osu.Framework.MathUtils;
|
||||
using osu.Game.Replays;
|
||||
using osu.Game.Rulesets.Replays;
|
||||
|
||||
namespace osu.Game.Rulesets.Catch.Replays
|
||||
|
@ -2,9 +2,9 @@
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Replays.Legacy;
|
||||
using osu.Game.Rulesets.Catch.UI;
|
||||
using osu.Game.Rulesets.Replays;
|
||||
using osu.Game.Rulesets.Replays.Legacy;
|
||||
using osu.Game.Rulesets.Replays.Types;
|
||||
|
||||
namespace osu.Game.Rulesets.Catch.Replays
|
||||
|
@ -5,12 +5,12 @@ using osu.Framework.Input;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Configuration;
|
||||
using osu.Game.Input.Handlers;
|
||||
using osu.Game.Replays;
|
||||
using osu.Game.Rulesets.Catch.Objects;
|
||||
using osu.Game.Rulesets.Catch.Objects.Drawable;
|
||||
using osu.Game.Rulesets.Catch.Replays;
|
||||
using osu.Game.Rulesets.Catch.Scoring;
|
||||
using osu.Game.Rulesets.Objects.Drawables;
|
||||
using osu.Game.Rulesets.Replays;
|
||||
using osu.Game.Rulesets.Scoring;
|
||||
using osu.Game.Rulesets.UI;
|
||||
using osu.Game.Rulesets.UI.Scrolling;
|
||||
|
@ -46,5 +46,7 @@ namespace osu.Game.Rulesets.Mania.Tests
|
||||
protected override void AddHitObject(DrawableHitObject hitObject) => column.Add((DrawableManiaHitObject)hitObject);
|
||||
|
||||
public Column ColumnAt(Vector2 screenSpacePosition) => column;
|
||||
|
||||
public int TotalColumns => 1;
|
||||
}
|
||||
}
|
||||
|
@ -2,14 +2,37 @@
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Timing;
|
||||
using osu.Game.Rulesets.Mania.Edit;
|
||||
using osu.Game.Rulesets.Mania.UI;
|
||||
using osu.Game.Tests.Visual;
|
||||
using osuTK;
|
||||
using osuTK.Graphics;
|
||||
|
||||
namespace osu.Game.Rulesets.Mania.Tests
|
||||
{
|
||||
public abstract class ManiaSelectionBlueprintTestCase : SelectionBlueprintTestCase
|
||||
[Cached(Type = typeof(IManiaHitObjectComposer))]
|
||||
public abstract class ManiaSelectionBlueprintTestCase : SelectionBlueprintTestCase, IManiaHitObjectComposer
|
||||
{
|
||||
[Cached(Type = typeof(IAdjustableClock))]
|
||||
private readonly IAdjustableClock clock = new StopwatchClock();
|
||||
|
||||
private readonly Column column;
|
||||
|
||||
protected ManiaSelectionBlueprintTestCase()
|
||||
{
|
||||
Add(column = new Column(0)
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
AccentColour = Color4.OrangeRed,
|
||||
Clock = new FramedClock(new StopwatchClock()), // No scroll
|
||||
});
|
||||
}
|
||||
|
||||
public Column ColumnAt(Vector2 screenSpacePosition) => column;
|
||||
|
||||
public int TotalColumns => 1;
|
||||
}
|
||||
}
|
||||
|
@ -8,6 +8,7 @@ using osu.Game.Beatmaps;
|
||||
using osu.Game.Rulesets.Difficulty;
|
||||
using osu.Game.Rulesets.Mods;
|
||||
using osu.Game.Rulesets.Scoring;
|
||||
using osu.Game.Scoring;
|
||||
|
||||
namespace osu.Game.Rulesets.Mania.Difficulty
|
||||
{
|
||||
@ -27,7 +28,7 @@ namespace osu.Game.Rulesets.Mania.Difficulty
|
||||
private int countMeh;
|
||||
private int countMiss;
|
||||
|
||||
public ManiaPerformanceCalculator(Ruleset ruleset, WorkingBeatmap beatmap, Score score)
|
||||
public ManiaPerformanceCalculator(Ruleset ruleset, WorkingBeatmap beatmap, ScoreInfo score)
|
||||
: base(ruleset, beatmap, score)
|
||||
{
|
||||
}
|
||||
|
@ -15,6 +15,9 @@ namespace osu.Game.Rulesets.Mania.Edit.Blueprints
|
||||
{
|
||||
public class ManiaSelectionBlueprint : SelectionBlueprint
|
||||
{
|
||||
public Vector2 ScreenSpaceDragPosition { get; private set; }
|
||||
public Vector2 DragPosition { get; private set; }
|
||||
|
||||
protected new DrawableManiaHitObject HitObject => (DrawableManiaHitObject)base.HitObject;
|
||||
|
||||
protected IClock EditorClock { get; private set; }
|
||||
@ -22,6 +25,9 @@ namespace osu.Game.Rulesets.Mania.Edit.Blueprints
|
||||
[Resolved]
|
||||
private IScrollingInfo scrollingInfo { get; set; }
|
||||
|
||||
[Resolved]
|
||||
private IManiaHitObjectComposer composer { get; set; }
|
||||
|
||||
public ManiaSelectionBlueprint(DrawableHitObject hitObject)
|
||||
: base(hitObject)
|
||||
{
|
||||
@ -41,27 +47,22 @@ namespace osu.Game.Rulesets.Mania.Edit.Blueprints
|
||||
Position = Parent.ToLocalSpace(HitObject.ToScreenSpace(Vector2.Zero));
|
||||
}
|
||||
|
||||
public override void AdjustPosition(DragEvent dragEvent)
|
||||
protected override bool OnMouseDown(MouseDownEvent e)
|
||||
{
|
||||
var objectParent = HitObject.Parent;
|
||||
ScreenSpaceDragPosition = e.ScreenSpaceMousePosition;
|
||||
DragPosition = HitObject.ToLocalSpace(e.ScreenSpaceMousePosition);
|
||||
|
||||
// Using the hitobject position is required since AdjustPosition can be invoked multiple times per frame
|
||||
// without the position having been updated by the parenting ScrollingHitObjectContainer
|
||||
HitObject.Y += dragEvent.Delta.Y;
|
||||
return base.OnMouseDown(e);
|
||||
}
|
||||
|
||||
float targetPosition;
|
||||
protected override bool OnDrag(DragEvent e)
|
||||
{
|
||||
var result = base.OnDrag(e);
|
||||
|
||||
// If we're scrolling downwards, a position of 0 is actually further away from the hit target
|
||||
// so we need to flip the vertical coordinate in the hitobject container's space
|
||||
if (scrollingInfo.Direction.Value == ScrollingDirection.Down)
|
||||
targetPosition = -HitObject.Position.Y;
|
||||
else
|
||||
targetPosition = HitObject.Position.Y;
|
||||
ScreenSpaceDragPosition = e.ScreenSpaceMousePosition;
|
||||
DragPosition = HitObject.ToLocalSpace(e.ScreenSpaceMousePosition);
|
||||
|
||||
HitObject.HitObject.StartTime = scrollingInfo.Algorithm.TimeAt(targetPosition,
|
||||
EditorClock.CurrentTime,
|
||||
scrollingInfo.TimeRange.Value,
|
||||
objectParent.DrawHeight);
|
||||
return result;
|
||||
}
|
||||
|
||||
public override void Show()
|
||||
|
@ -9,5 +9,7 @@ namespace osu.Game.Rulesets.Mania.Edit
|
||||
public interface IManiaHitObjectComposer
|
||||
{
|
||||
Column ColumnAt(Vector2 screenSpacePosition);
|
||||
|
||||
int TotalColumns { get; }
|
||||
}
|
||||
}
|
||||
|
@ -12,6 +12,7 @@ using osu.Framework.Allocation;
|
||||
using osu.Game.Rulesets.Mania.Edit.Blueprints;
|
||||
using osu.Game.Rulesets.Mania.UI;
|
||||
using osu.Game.Rulesets.UI;
|
||||
using osu.Game.Screens.Edit.Compose.Components;
|
||||
using osuTK;
|
||||
|
||||
namespace osu.Game.Rulesets.Mania.Edit
|
||||
@ -38,6 +39,8 @@ namespace osu.Game.Rulesets.Mania.Edit
|
||||
protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent)
|
||||
=> dependencies = new DependencyContainer(base.CreateChildDependencies(parent));
|
||||
|
||||
public int TotalColumns => ((ManiaPlayfield)RulesetContainer.Playfield).TotalColumns;
|
||||
|
||||
protected override RulesetContainer<ManiaHitObject> CreateRulesetContainer(Ruleset ruleset, WorkingBeatmap beatmap)
|
||||
{
|
||||
RulesetContainer = new ManiaEditRulesetContainer(ruleset, beatmap);
|
||||
@ -54,6 +57,8 @@ namespace osu.Game.Rulesets.Mania.Edit
|
||||
new HoldNoteCompositionTool()
|
||||
};
|
||||
|
||||
public override SelectionHandler CreateSelectionHandler() => new ManiaSelectionHandler();
|
||||
|
||||
public override SelectionBlueprint CreateBlueprintFor(DrawableHitObject hitObject)
|
||||
{
|
||||
switch (hitObject)
|
||||
|
125
osu.Game.Rulesets.Mania/Edit/ManiaSelectionHandler.cs
Normal file
125
osu.Game.Rulesets.Mania/Edit/ManiaSelectionHandler.cs
Normal file
@ -0,0 +1,125 @@
|
||||
// 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.Linq;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Input.Events;
|
||||
using osu.Framework.Timing;
|
||||
using osu.Game.Rulesets.Edit;
|
||||
using osu.Game.Rulesets.Mania.Edit.Blueprints;
|
||||
using osu.Game.Rulesets.Mania.Objects;
|
||||
using osu.Game.Rulesets.UI;
|
||||
using osu.Game.Rulesets.UI.Scrolling;
|
||||
using osu.Game.Screens.Edit.Compose.Components;
|
||||
using osuTK;
|
||||
|
||||
namespace osu.Game.Rulesets.Mania.Edit
|
||||
{
|
||||
public class ManiaSelectionHandler : SelectionHandler
|
||||
{
|
||||
[Resolved]
|
||||
private IScrollingInfo scrollingInfo { get; set; }
|
||||
|
||||
[Resolved]
|
||||
private IManiaHitObjectComposer composer { get; set; }
|
||||
|
||||
private IClock editorClock;
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(IAdjustableClock clock)
|
||||
{
|
||||
editorClock = clock;
|
||||
}
|
||||
|
||||
public override void HandleDrag(SelectionBlueprint blueprint, DragEvent dragEvent)
|
||||
{
|
||||
adjustOrigins((ManiaSelectionBlueprint)blueprint);
|
||||
performDragMovement(dragEvent);
|
||||
performColumnMovement(dragEvent);
|
||||
|
||||
base.HandleDrag(blueprint, dragEvent);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Ensures that the position of hitobjects remains centred to the mouse position.
|
||||
/// E.g. The hitobject position will change if the editor scrolls while a hitobject is dragged.
|
||||
/// </summary>
|
||||
/// <param name="reference">The <see cref="ManiaSelectionBlueprint"/> that received the drag event.</param>
|
||||
private void adjustOrigins(ManiaSelectionBlueprint reference)
|
||||
{
|
||||
var referenceParent = (HitObjectContainer)reference.HitObject.Parent;
|
||||
|
||||
float offsetFromReferenceOrigin = reference.DragPosition.Y - reference.HitObject.OriginPosition.Y;
|
||||
float targetPosition = referenceParent.ToLocalSpace(reference.ScreenSpaceDragPosition).Y - offsetFromReferenceOrigin;
|
||||
|
||||
// Flip the vertical coordinate space when scrolling downwards
|
||||
if (scrollingInfo.Direction.Value == ScrollingDirection.Down)
|
||||
targetPosition = targetPosition - referenceParent.DrawHeight;
|
||||
|
||||
float movementDelta = targetPosition - reference.HitObject.Position.Y;
|
||||
|
||||
foreach (var b in SelectedBlueprints.OfType<ManiaSelectionBlueprint>())
|
||||
b.HitObject.Y += movementDelta;
|
||||
}
|
||||
|
||||
private void performDragMovement(DragEvent dragEvent)
|
||||
{
|
||||
foreach (var b in SelectedBlueprints)
|
||||
{
|
||||
var hitObject = b.HitObject;
|
||||
|
||||
var objectParent = (HitObjectContainer)hitObject.Parent;
|
||||
|
||||
// Using the hitobject position is required since AdjustPosition can be invoked multiple times per frame
|
||||
// without the position having been updated by the parenting ScrollingHitObjectContainer
|
||||
hitObject.Y += dragEvent.Delta.Y;
|
||||
|
||||
float targetPosition;
|
||||
|
||||
// If we're scrolling downwards, a position of 0 is actually further away from the hit target
|
||||
// so we need to flip the vertical coordinate in the hitobject container's space
|
||||
if (scrollingInfo.Direction.Value == ScrollingDirection.Down)
|
||||
targetPosition = -hitObject.Position.Y;
|
||||
else
|
||||
targetPosition = hitObject.Position.Y;
|
||||
|
||||
objectParent.Remove(hitObject);
|
||||
|
||||
hitObject.HitObject.StartTime = scrollingInfo.Algorithm.TimeAt(targetPosition,
|
||||
editorClock.CurrentTime,
|
||||
scrollingInfo.TimeRange.Value,
|
||||
objectParent.DrawHeight);
|
||||
|
||||
objectParent.Add(hitObject);
|
||||
}
|
||||
}
|
||||
|
||||
private void performColumnMovement(DragEvent dragEvent)
|
||||
{
|
||||
var lastColumn = composer.ColumnAt(dragEvent.ScreenSpaceLastMousePosition);
|
||||
var currentColumn = composer.ColumnAt(dragEvent.ScreenSpaceMousePosition);
|
||||
if (lastColumn == null || currentColumn == null)
|
||||
return;
|
||||
|
||||
int columnDelta = currentColumn.Index - lastColumn.Index;
|
||||
if (columnDelta == 0)
|
||||
return;
|
||||
|
||||
int minColumn = int.MaxValue;
|
||||
int maxColumn = int.MinValue;
|
||||
|
||||
foreach (var obj in SelectedHitObjects.OfType<ManiaHitObject>())
|
||||
{
|
||||
if (obj.Column < minColumn)
|
||||
minColumn = obj.Column;
|
||||
if (obj.Column > maxColumn)
|
||||
maxColumn = obj.Column;
|
||||
}
|
||||
|
||||
columnDelta = MathHelper.Clamp(columnDelta, -minColumn, composer.TotalColumns - 1 - maxColumn);
|
||||
|
||||
foreach (var obj in SelectedHitObjects.OfType<ManiaHitObject>())
|
||||
obj.Column += columnDelta;
|
||||
}
|
||||
}
|
||||
}
|
@ -24,7 +24,7 @@ using osu.Game.Rulesets.Mania.Beatmaps;
|
||||
using osu.Game.Rulesets.Mania.Configuration;
|
||||
using osu.Game.Rulesets.Mania.Difficulty;
|
||||
using osu.Game.Rulesets.Mania.Edit;
|
||||
using osu.Game.Rulesets.Scoring;
|
||||
using osu.Game.Scoring;
|
||||
|
||||
namespace osu.Game.Rulesets.Mania
|
||||
{
|
||||
@ -32,7 +32,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(WorkingBeatmap beatmap, Score score) => new ManiaPerformanceCalculator(this, beatmap, score);
|
||||
public override PerformanceCalculator CreatePerformanceCalculator(WorkingBeatmap beatmap, ScoreInfo score) => new ManiaPerformanceCalculator(this, beatmap, score);
|
||||
|
||||
public override HitObjectComposer CreateHitObjectComposer() => new ManiaHitObjectComposer(this);
|
||||
|
||||
|
@ -11,7 +11,7 @@ namespace osu.Game.Rulesets.Mania.Mods
|
||||
{
|
||||
public abstract class ManiaKeyMod : Mod, IApplicableToBeatmapConverter
|
||||
{
|
||||
public override string ShortenedName => Name;
|
||||
public override string Acronym => Name;
|
||||
public abstract int KeyCount { get; }
|
||||
public override ModType Type => ModType.Conversion;
|
||||
public override double ScoreMultiplier => 1; // TODO: Implement the mania key mod score multiplier
|
||||
|
@ -6,20 +6,17 @@ using osu.Game.Rulesets.Mania.Beatmaps;
|
||||
using osu.Game.Rulesets.Mania.Objects;
|
||||
using osu.Game.Rulesets.Mania.Replays;
|
||||
using osu.Game.Rulesets.Mods;
|
||||
using osu.Game.Rulesets.Scoring;
|
||||
using osu.Game.Scoring;
|
||||
using osu.Game.Users;
|
||||
|
||||
namespace osu.Game.Rulesets.Mania.Mods
|
||||
{
|
||||
public class ManiaModAutoplay : ModAutoplay<ManiaHitObject>
|
||||
{
|
||||
protected override Score CreateReplayScore(Beatmap<ManiaHitObject> beatmap)
|
||||
protected override Score CreateReplayScore(Beatmap<ManiaHitObject> beatmap) => new Score
|
||||
{
|
||||
return new Score
|
||||
{
|
||||
User = new User { Username = "osu!topus!" },
|
||||
Replay = new ManiaAutoGenerator((ManiaBeatmap)beatmap).Generate(),
|
||||
};
|
||||
}
|
||||
ScoreInfo = new ScoreInfo { User = new User { Username = "osu!topus!" } },
|
||||
Replay = new ManiaAutoGenerator((ManiaBeatmap)beatmap).Generate(),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -12,7 +12,7 @@ namespace osu.Game.Rulesets.Mania.Mods
|
||||
public class ManiaModDualStages : Mod, IPlayfieldTypeMod, IApplicableToBeatmapConverter, IApplicableToBeatmap<ManiaHitObject>
|
||||
{
|
||||
public override string Name => "Dual Stages";
|
||||
public override string ShortenedName => "DS";
|
||||
public override string Acronym => "DS";
|
||||
public override string Description => @"Double the stages, double the fun!";
|
||||
public override ModType Type => ModType.Conversion;
|
||||
public override double ScoreMultiplier => 1;
|
||||
|
@ -11,7 +11,7 @@ namespace osu.Game.Rulesets.Mania.Mods
|
||||
public class ManiaModFadeIn : Mod
|
||||
{
|
||||
public override string Name => "Fade In";
|
||||
public override string ShortenedName => "FI";
|
||||
public override string Acronym => "FI";
|
||||
public override FontAwesome Icon => FontAwesome.fa_osu_mod_hidden;
|
||||
public override ModType Type => ModType.DifficultyIncrease;
|
||||
public override string Description => @"Keys appear out of nowhere!";
|
||||
|
@ -7,7 +7,7 @@ namespace osu.Game.Rulesets.Mania.Mods
|
||||
{
|
||||
public override int KeyCount => 1;
|
||||
public override string Name => "One Key";
|
||||
public override string ShortenedName => "1K";
|
||||
public override string Acronym => "1K";
|
||||
public override string Description => @"Play with one key.";
|
||||
}
|
||||
}
|
||||
|
@ -7,7 +7,7 @@ namespace osu.Game.Rulesets.Mania.Mods
|
||||
{
|
||||
public override int KeyCount => 2;
|
||||
public override string Name => "Two Keys";
|
||||
public override string ShortenedName => "2K";
|
||||
public override string Acronym => "2K";
|
||||
public override string Description => @"Play with two keys.";
|
||||
}
|
||||
}
|
||||
|
@ -7,7 +7,7 @@ namespace osu.Game.Rulesets.Mania.Mods
|
||||
{
|
||||
public override int KeyCount => 3;
|
||||
public override string Name => "Three Keys";
|
||||
public override string ShortenedName => "3K";
|
||||
public override string Acronym => "3K";
|
||||
public override string Description => @"Play with three keys.";
|
||||
}
|
||||
}
|
||||
|
@ -7,7 +7,7 @@ namespace osu.Game.Rulesets.Mania.Mods
|
||||
{
|
||||
public override int KeyCount => 4;
|
||||
public override string Name => "Four Keys";
|
||||
public override string ShortenedName => "4K";
|
||||
public override string Acronym => "4K";
|
||||
public override string Description => @"Play with four keys.";
|
||||
}
|
||||
}
|
||||
|
@ -7,7 +7,7 @@ namespace osu.Game.Rulesets.Mania.Mods
|
||||
{
|
||||
public override int KeyCount => 5;
|
||||
public override string Name => "Five Keys";
|
||||
public override string ShortenedName => "5K";
|
||||
public override string Acronym => "5K";
|
||||
public override string Description => @"Play with five keys.";
|
||||
}
|
||||
}
|
||||
|
@ -7,7 +7,7 @@ namespace osu.Game.Rulesets.Mania.Mods
|
||||
{
|
||||
public override int KeyCount => 6;
|
||||
public override string Name => "Six Keys";
|
||||
public override string ShortenedName => "6K";
|
||||
public override string Acronym => "6K";
|
||||
public override string Description => @"Play with six keys.";
|
||||
}
|
||||
}
|
||||
|
@ -7,7 +7,7 @@ namespace osu.Game.Rulesets.Mania.Mods
|
||||
{
|
||||
public override int KeyCount => 7;
|
||||
public override string Name => "Seven Keys";
|
||||
public override string ShortenedName => "7K";
|
||||
public override string Acronym => "7K";
|
||||
public override string Description => @"Play with seven keys.";
|
||||
}
|
||||
}
|
||||
|
@ -7,7 +7,7 @@ namespace osu.Game.Rulesets.Mania.Mods
|
||||
{
|
||||
public override int KeyCount => 8;
|
||||
public override string Name => "Eight Keys";
|
||||
public override string ShortenedName => "8K";
|
||||
public override string Acronym => "8K";
|
||||
public override string Description => @"Play with eight keys.";
|
||||
}
|
||||
}
|
||||
|
@ -7,7 +7,7 @@ namespace osu.Game.Rulesets.Mania.Mods
|
||||
{
|
||||
public override int KeyCount => 9;
|
||||
public override string Name => "Nine Keys";
|
||||
public override string ShortenedName => "9K";
|
||||
public override string Acronym => "9K";
|
||||
public override string Description => @"Play with nine keys.";
|
||||
}
|
||||
}
|
||||
|
@ -13,7 +13,7 @@ namespace osu.Game.Rulesets.Mania.Mods
|
||||
public class ManiaModMirror : Mod, IApplicableToRulesetContainer<ManiaHitObject>
|
||||
{
|
||||
public override string Name => "Mirror";
|
||||
public override string ShortenedName => "MR";
|
||||
public override string Acronym => "MR";
|
||||
public override ModType Type => ModType.Conversion;
|
||||
public override double ScoreMultiplier => 1;
|
||||
public override bool Ranked => true;
|
||||
|
@ -15,7 +15,7 @@ namespace osu.Game.Rulesets.Mania.Mods
|
||||
public class ManiaModRandom : Mod, IApplicableToRulesetContainer<ManiaHitObject>
|
||||
{
|
||||
public override string Name => "Random";
|
||||
public override string ShortenedName => "RD";
|
||||
public override string Acronym => "RD";
|
||||
public override ModType Type => ModType.Conversion;
|
||||
public override FontAwesome Icon => FontAwesome.fa_osu_dice;
|
||||
public override string Description => @"Shuffle around the keys!";
|
||||
|
@ -1,6 +1,7 @@
|
||||
// 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.Configuration;
|
||||
using osu.Game.Rulesets.Mania.Objects.Types;
|
||||
using osu.Game.Rulesets.Objects;
|
||||
|
||||
@ -8,7 +9,13 @@ namespace osu.Game.Rulesets.Mania.Objects
|
||||
{
|
||||
public abstract class ManiaHitObject : HitObject, IHasColumn
|
||||
{
|
||||
public virtual int Column { get; set; }
|
||||
public readonly Bindable<int> ColumnBindable = new Bindable<int>();
|
||||
|
||||
public virtual int Column
|
||||
{
|
||||
get => ColumnBindable;
|
||||
set => ColumnBindable.Value = value;
|
||||
}
|
||||
|
||||
protected override HitWindows CreateHitWindows() => new ManiaHitWindows();
|
||||
}
|
||||
|
@ -3,11 +3,11 @@
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using osu.Game.Replays;
|
||||
using osu.Game.Rulesets.Mania.Beatmaps;
|
||||
using osu.Game.Rulesets.Mania.Objects;
|
||||
using osu.Game.Rulesets.Objects.Types;
|
||||
using osu.Game.Rulesets.Replays;
|
||||
using osu.Game.Users;
|
||||
|
||||
namespace osu.Game.Rulesets.Mania.Replays
|
||||
{
|
||||
@ -22,7 +22,7 @@ namespace osu.Game.Rulesets.Mania.Replays
|
||||
public ManiaAutoGenerator(ManiaBeatmap beatmap)
|
||||
: base(beatmap)
|
||||
{
|
||||
Replay = new Replay { User = new User { Username = @"Autoplay" } };
|
||||
Replay = new Replay();
|
||||
|
||||
columnActions = new ManiaAction[Beatmap.TotalColumns];
|
||||
|
||||
|
@ -4,6 +4,7 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using osu.Framework.Input.StateChanges;
|
||||
using osu.Game.Replays;
|
||||
using osu.Game.Rulesets.Replays;
|
||||
|
||||
namespace osu.Game.Rulesets.Mania.Replays
|
||||
|
@ -3,9 +3,9 @@
|
||||
|
||||
using System.Collections.Generic;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Replays.Legacy;
|
||||
using osu.Game.Rulesets.Mania.Beatmaps;
|
||||
using osu.Game.Rulesets.Replays;
|
||||
using osu.Game.Rulesets.Replays.Legacy;
|
||||
using osu.Game.Rulesets.Replays.Types;
|
||||
|
||||
namespace osu.Game.Rulesets.Mania.Replays
|
||||
|
@ -145,11 +145,13 @@ namespace osu.Game.Rulesets.Mania.UI
|
||||
HitObjectContainer.Add(hitObject);
|
||||
}
|
||||
|
||||
public override void Remove(DrawableHitObject h)
|
||||
public override bool Remove(DrawableHitObject h)
|
||||
{
|
||||
h.OnNewResult -= OnNewResult;
|
||||
if (!base.Remove(h))
|
||||
return false;
|
||||
|
||||
HitObjectContainer.Remove(h);
|
||||
h.OnNewResult -= OnNewResult;
|
||||
return true;
|
||||
}
|
||||
|
||||
internal void OnNewResult(DrawableHitObject judgedObject, JudgementResult result)
|
||||
|
@ -55,7 +55,7 @@ namespace osu.Game.Rulesets.Mania.UI
|
||||
|
||||
public override void Add(DrawableHitObject h) => getStageByColumn(((ManiaHitObject)h.HitObject).Column).Add(h);
|
||||
|
||||
public override void Remove(DrawableHitObject h) => getStageByColumn(((ManiaHitObject)h.HitObject).Column).Remove(h);
|
||||
public override bool Remove(DrawableHitObject h) => getStageByColumn(((ManiaHitObject)h.HitObject).Column).Remove(h);
|
||||
|
||||
public void Add(BarLine barline) => stages.ForEach(s => s.Add(barline));
|
||||
|
||||
@ -86,6 +86,11 @@ namespace osu.Game.Rulesets.Mania.UI
|
||||
return found;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves the total amount of columns across all stages in this playfield.
|
||||
/// </summary>
|
||||
public int TotalColumns => stages.Sum(s => s.Columns.Count);
|
||||
|
||||
private ManiaStage getStageByColumn(int column)
|
||||
{
|
||||
int sum = 0;
|
||||
|
@ -12,6 +12,7 @@ using osu.Framework.MathUtils;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Beatmaps.ControlPoints;
|
||||
using osu.Game.Input.Handlers;
|
||||
using osu.Game.Replays;
|
||||
using osu.Game.Rulesets.Mania.Beatmaps;
|
||||
using osu.Game.Rulesets.Mania.Configuration;
|
||||
using osu.Game.Rulesets.Mania.Mods;
|
||||
@ -21,7 +22,6 @@ using osu.Game.Rulesets.Mania.Replays;
|
||||
using osu.Game.Rulesets.Mania.Scoring;
|
||||
using osu.Game.Rulesets.Objects.Drawables;
|
||||
using osu.Game.Rulesets.Objects.Types;
|
||||
using osu.Game.Rulesets.Replays;
|
||||
using osu.Game.Rulesets.Scoring;
|
||||
using osu.Game.Rulesets.UI;
|
||||
using osu.Game.Rulesets.UI.Scrolling;
|
||||
|
@ -156,18 +156,29 @@ namespace osu.Game.Rulesets.Mania.UI
|
||||
public override void Add(DrawableHitObject h)
|
||||
{
|
||||
var maniaObject = (ManiaHitObject)h.HitObject;
|
||||
int columnIndex = maniaObject.Column - firstColumnIndex;
|
||||
Columns.ElementAt(columnIndex).Add(h);
|
||||
|
||||
int columnIndex = -1;
|
||||
|
||||
maniaObject.ColumnBindable.BindValueChanged(_ =>
|
||||
{
|
||||
if (columnIndex != -1)
|
||||
Columns.ElementAt(columnIndex).Remove(h);
|
||||
|
||||
columnIndex = maniaObject.Column - firstColumnIndex;
|
||||
Columns.ElementAt(columnIndex).Add(h);
|
||||
}, true);
|
||||
|
||||
h.OnNewResult += OnNewResult;
|
||||
}
|
||||
|
||||
public override void Remove(DrawableHitObject h)
|
||||
public override bool Remove(DrawableHitObject h)
|
||||
{
|
||||
var maniaObject = (ManiaHitObject)h.HitObject;
|
||||
int columnIndex = maniaObject.Column - firstColumnIndex;
|
||||
Columns.ElementAt(columnIndex).Remove(h);
|
||||
|
||||
h.OnNewResult -= OnNewResult;
|
||||
return true;
|
||||
}
|
||||
|
||||
public void Add(BarLine barline) => base.Add(new DrawableBarLine(barline));
|
||||
|
@ -10,6 +10,7 @@ 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;
|
||||
|
||||
namespace osu.Game.Rulesets.Osu.Difficulty
|
||||
{
|
||||
@ -29,7 +30,7 @@ namespace osu.Game.Rulesets.Osu.Difficulty
|
||||
private int countMeh;
|
||||
private int countMiss;
|
||||
|
||||
public OsuPerformanceCalculator(Ruleset ruleset, WorkingBeatmap beatmap, Score score)
|
||||
public OsuPerformanceCalculator(Ruleset ruleset, WorkingBeatmap beatmap, ScoreInfo score)
|
||||
: base(ruleset, beatmap, score)
|
||||
{
|
||||
countHitCircles = Beatmap.HitObjects.Count(h => h is HitCircle);
|
||||
|
@ -1,7 +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.Framework.Input.Events;
|
||||
using osu.Game.Rulesets.Edit;
|
||||
using osu.Game.Rulesets.Objects.Drawables;
|
||||
using osu.Game.Rulesets.Osu.Objects;
|
||||
@ -16,7 +15,5 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints
|
||||
: base(hitObject)
|
||||
{
|
||||
}
|
||||
|
||||
public override void AdjustPosition(DragEvent dragEvent) => OsuObject.Position += dragEvent.Delta;
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +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.Framework.Input.Events;
|
||||
using osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders.Components;
|
||||
using osu.Game.Rulesets.Osu.Objects;
|
||||
using osu.Game.Rulesets.Osu.Objects.Drawables;
|
||||
@ -10,13 +9,9 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders
|
||||
{
|
||||
public class SliderCircleSelectionBlueprint : OsuSelectionBlueprint
|
||||
{
|
||||
private readonly Slider slider;
|
||||
|
||||
public SliderCircleSelectionBlueprint(DrawableOsuHitObject hitObject, Slider slider, SliderPosition position)
|
||||
: base(hitObject)
|
||||
{
|
||||
this.slider = slider;
|
||||
|
||||
InternalChild = new SliderCirclePiece(slider, position);
|
||||
|
||||
Select();
|
||||
@ -24,7 +19,5 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders
|
||||
|
||||
// Todo: This is temporary, since the slider circle masks don't do anything special yet. In the future they will handle input.
|
||||
public override bool HandlePositionalInput => false;
|
||||
|
||||
public override void AdjustPosition(DragEvent dragEvent) => slider.Position += dragEvent.Delta;
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +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.Framework.Input.Events;
|
||||
using osu.Game.Rulesets.Osu.Edit.Blueprints.Spinners.Components;
|
||||
using osu.Game.Rulesets.Osu.Objects;
|
||||
using osu.Game.Rulesets.Osu.Objects.Drawables;
|
||||
@ -20,10 +19,5 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Spinners
|
||||
}
|
||||
|
||||
public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => piece.ReceivePositionalInputAt(screenSpacePos);
|
||||
|
||||
public override void AdjustPosition(DragEvent dragEvent)
|
||||
{
|
||||
// Spinners don't support position adjustments
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -15,6 +15,7 @@ using osu.Game.Rulesets.Osu.Objects;
|
||||
using osu.Game.Rulesets.Osu.Objects.Drawables;
|
||||
using osu.Game.Rulesets.Osu.UI;
|
||||
using osu.Game.Rulesets.UI;
|
||||
using osu.Game.Screens.Edit.Compose.Components;
|
||||
|
||||
namespace osu.Game.Rulesets.Osu.Edit
|
||||
{
|
||||
@ -35,6 +36,8 @@ namespace osu.Game.Rulesets.Osu.Edit
|
||||
new SpinnerCompositionTool()
|
||||
};
|
||||
|
||||
public override SelectionHandler CreateSelectionHandler() => new OsuSelectionHandler();
|
||||
|
||||
protected override Container CreateLayerContainer() => new PlayfieldAdjustmentContainer { RelativeSizeAxes = Axes.Both };
|
||||
|
||||
public override SelectionBlueprint CreateBlueprintFor(DrawableHitObject hitObject)
|
||||
|
30
osu.Game.Rulesets.Osu/Edit/OsuSelectionHandler.cs
Normal file
30
osu.Game.Rulesets.Osu/Edit/OsuSelectionHandler.cs
Normal file
@ -0,0 +1,30 @@
|
||||
// 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.Linq;
|
||||
using osu.Framework.Input.Events;
|
||||
using osu.Game.Rulesets.Edit;
|
||||
using osu.Game.Rulesets.Osu.Objects;
|
||||
using osu.Game.Screens.Edit.Compose.Components;
|
||||
|
||||
namespace osu.Game.Rulesets.Osu.Edit
|
||||
{
|
||||
public class OsuSelectionHandler : SelectionHandler
|
||||
{
|
||||
public override void HandleDrag(SelectionBlueprint blueprint, DragEvent dragEvent)
|
||||
{
|
||||
foreach (var h in SelectedHitObjects.OfType<OsuHitObject>())
|
||||
{
|
||||
if (h is Spinner)
|
||||
{
|
||||
// Spinners don't support position adjustments
|
||||
continue;
|
||||
}
|
||||
|
||||
h.Position += dragEvent.Delta;
|
||||
}
|
||||
|
||||
base.HandleDrag(blueprint, dragEvent);
|
||||
}
|
||||
}
|
||||
}
|
@ -10,7 +10,7 @@ namespace osu.Game.Rulesets.Osu.Mods
|
||||
public class OsuModAutopilot : Mod
|
||||
{
|
||||
public override string Name => "Autopilot";
|
||||
public override string ShortenedName => "AP";
|
||||
public override string Acronym => "AP";
|
||||
public override FontAwesome Icon => FontAwesome.fa_osu_mod_autopilot;
|
||||
public override ModType Type => ModType.Automation;
|
||||
public override string Description => @"Automatic cursor movement - just follow the rhythm.";
|
||||
|
@ -7,7 +7,8 @@ using osu.Game.Beatmaps;
|
||||
using osu.Game.Rulesets.Mods;
|
||||
using osu.Game.Rulesets.Osu.Objects;
|
||||
using osu.Game.Rulesets.Osu.Replays;
|
||||
using osu.Game.Rulesets.Scoring;
|
||||
using osu.Game.Scoring;
|
||||
using osu.Game.Users;
|
||||
|
||||
namespace osu.Game.Rulesets.Osu.Mods
|
||||
{
|
||||
@ -15,12 +16,10 @@ namespace osu.Game.Rulesets.Osu.Mods
|
||||
{
|
||||
public override Type[] IncompatibleMods => base.IncompatibleMods.Append(typeof(OsuModAutopilot)).Append(typeof(OsuModSpunOut)).ToArray();
|
||||
|
||||
protected override Score CreateReplayScore(Beatmap<OsuHitObject> beatmap)
|
||||
protected override Score CreateReplayScore(Beatmap<OsuHitObject> beatmap) => new Score
|
||||
{
|
||||
return new Score
|
||||
{
|
||||
Replay = new OsuAutoGenerator(beatmap).Generate()
|
||||
};
|
||||
}
|
||||
ScoreInfo = new ScoreInfo { User = new User { Username = "Autoplay" } },
|
||||
Replay = new OsuAutoGenerator(beatmap).Generate()
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -10,7 +10,7 @@ namespace osu.Game.Rulesets.Osu.Mods
|
||||
public class OsuModSpunOut : Mod
|
||||
{
|
||||
public override string Name => "Spun Out";
|
||||
public override string ShortenedName => "SO";
|
||||
public override string Acronym => "SO";
|
||||
public override FontAwesome Icon => FontAwesome.fa_osu_mod_spunout;
|
||||
public override ModType Type => ModType.DifficultyReduction;
|
||||
public override string Description => @"Spinners will be automatically completed.";
|
||||
|
@ -9,7 +9,7 @@ namespace osu.Game.Rulesets.Osu.Mods
|
||||
public class OsuModTarget : Mod
|
||||
{
|
||||
public override string Name => "Target";
|
||||
public override string ShortenedName => "TP";
|
||||
public override string Acronym => "TP";
|
||||
public override ModType Type => ModType.Conversion;
|
||||
public override FontAwesome Icon => FontAwesome.fa_osu_mod_target;
|
||||
public override string Description => @"Practice keeping up with the beat of the song.";
|
||||
|
@ -15,7 +15,7 @@ namespace osu.Game.Rulesets.Osu.Mods
|
||||
internal class OsuModTransform : Mod, IApplicableToDrawableHitObjects
|
||||
{
|
||||
public override string Name => "Transform";
|
||||
public override string ShortenedName => "TR";
|
||||
public override string Acronym => "TR";
|
||||
public override FontAwesome Icon => FontAwesome.fa_arrows;
|
||||
public override ModType Type => ModType.Fun;
|
||||
public override string Description => "Everything rotates. EVERYTHING.";
|
||||
|
@ -16,7 +16,7 @@ namespace osu.Game.Rulesets.Osu.Mods
|
||||
internal class OsuModWiggle : Mod, IApplicableToDrawableHitObjects
|
||||
{
|
||||
public override string Name => "Wiggle";
|
||||
public override string ShortenedName => "WG";
|
||||
public override string Acronym => "WG";
|
||||
public override FontAwesome Icon => FontAwesome.fa_certificate;
|
||||
public override ModType Type => ModType.Fun;
|
||||
public override string Description => "They just won't stay still...";
|
||||
|
@ -11,7 +11,6 @@ using System.Collections.Generic;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Game.Overlays.Settings;
|
||||
using osu.Framework.Input.Bindings;
|
||||
using osu.Game.Rulesets.Scoring;
|
||||
using osu.Game.Rulesets.Osu.Edit;
|
||||
using osu.Game.Rulesets.Edit;
|
||||
using osu.Game.Rulesets.Osu.Replays;
|
||||
@ -20,6 +19,7 @@ using osu.Game.Beatmaps.Legacy;
|
||||
using osu.Game.Rulesets.Difficulty;
|
||||
using osu.Game.Rulesets.Osu.Beatmaps;
|
||||
using osu.Game.Rulesets.Osu.Difficulty;
|
||||
using osu.Game.Scoring;
|
||||
|
||||
namespace osu.Game.Rulesets.Osu
|
||||
{
|
||||
@ -131,7 +131,7 @@ namespace osu.Game.Rulesets.Osu
|
||||
|
||||
public override DifficultyCalculator CreateDifficultyCalculator(WorkingBeatmap beatmap) => new OsuDifficultyCalculator(this, beatmap);
|
||||
|
||||
public override PerformanceCalculator CreatePerformanceCalculator(WorkingBeatmap beatmap, Score score) => new OsuPerformanceCalculator(this, beatmap, score);
|
||||
public override PerformanceCalculator CreatePerformanceCalculator(WorkingBeatmap beatmap, ScoreInfo score) => new OsuPerformanceCalculator(this, beatmap, score);
|
||||
|
||||
public override HitObjectComposer CreateHitObjectComposer() => new OsuHitObjectComposer(this);
|
||||
|
||||
|
@ -8,8 +8,8 @@ using osu.Game.Rulesets.Osu.Objects;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Game.Replays;
|
||||
using osu.Game.Rulesets.Objects.Types;
|
||||
using osu.Game.Rulesets.Replays;
|
||||
using osu.Game.Rulesets.Scoring;
|
||||
|
||||
namespace osu.Game.Rulesets.Osu.Replays
|
||||
|
@ -6,9 +6,9 @@ using osu.Game.Beatmaps;
|
||||
using osu.Game.Rulesets.Osu.Objects;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using osu.Game.Replays;
|
||||
using osu.Game.Rulesets.Osu.UI;
|
||||
using osu.Game.Rulesets.Replays;
|
||||
using osu.Game.Users;
|
||||
|
||||
namespace osu.Game.Rulesets.Osu.Replays
|
||||
{
|
||||
@ -37,13 +37,7 @@ namespace osu.Game.Rulesets.Osu.Replays
|
||||
protected OsuAutoGeneratorBase(Beatmap<OsuHitObject> beatmap)
|
||||
: base(beatmap)
|
||||
{
|
||||
Replay = new Replay
|
||||
{
|
||||
User = new User
|
||||
{
|
||||
Username = @"Autoplay",
|
||||
}
|
||||
};
|
||||
Replay = new Replay();
|
||||
|
||||
// We are using ApplyModsToRate and not ApplyModsToTime to counteract the speed up / slow down from HalfTime / DoubleTime so that we remain at a constant framerate of 60 fps.
|
||||
FrameDelay = ApplyModsToRate(1000.0 / 60.0);
|
||||
|
@ -3,8 +3,8 @@
|
||||
|
||||
using System.Collections.Generic;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Replays.Legacy;
|
||||
using osu.Game.Rulesets.Replays;
|
||||
using osu.Game.Rulesets.Replays.Legacy;
|
||||
using osu.Game.Rulesets.Replays.Types;
|
||||
using osuTK;
|
||||
|
||||
|
@ -5,6 +5,7 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using osu.Framework.Input.StateChanges;
|
||||
using osu.Framework.MathUtils;
|
||||
using osu.Game.Replays;
|
||||
using osu.Game.Rulesets.Replays;
|
||||
using osuTK;
|
||||
|
||||
|
@ -9,6 +9,7 @@ using osu.Game.Rulesets.Osu.Judgements;
|
||||
using osu.Game.Rulesets.Osu.Objects;
|
||||
using osu.Game.Rulesets.Scoring;
|
||||
using osu.Game.Rulesets.UI;
|
||||
using osu.Game.Scoring;
|
||||
|
||||
namespace osu.Game.Rulesets.Osu.Scoring
|
||||
{
|
||||
@ -39,7 +40,7 @@ namespace osu.Game.Rulesets.Osu.Scoring
|
||||
comboResultCounts.Clear();
|
||||
}
|
||||
|
||||
public override void PopulateScore(Score score)
|
||||
public override void PopulateScore(ScoreInfo score)
|
||||
{
|
||||
base.PopulateScore(score);
|
||||
|
||||
|
@ -6,6 +6,7 @@ using osu.Framework.Graphics.Cursor;
|
||||
using osu.Framework.Input;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Input.Handlers;
|
||||
using osu.Game.Replays;
|
||||
using osu.Game.Rulesets.Objects.Drawables;
|
||||
using osu.Game.Rulesets.Osu.Objects;
|
||||
using osu.Game.Rulesets.Osu.Objects.Drawables;
|
||||
@ -14,7 +15,6 @@ using osu.Game.Rulesets.Osu.Scoring;
|
||||
using osu.Game.Rulesets.Osu.UI.Cursor;
|
||||
using osu.Game.Rulesets.Scoring;
|
||||
using osu.Game.Rulesets.UI;
|
||||
using osu.Game.Rulesets.Replays;
|
||||
|
||||
namespace osu.Game.Rulesets.Osu.UI
|
||||
{
|
||||
|
@ -9,6 +9,7 @@ using osu.Game.Rulesets.Difficulty;
|
||||
using osu.Game.Rulesets.Mods;
|
||||
using osu.Game.Rulesets.Scoring;
|
||||
using osu.Game.Rulesets.Taiko.Objects;
|
||||
using osu.Game.Scoring;
|
||||
|
||||
namespace osu.Game.Rulesets.Taiko.Difficulty
|
||||
{
|
||||
@ -22,7 +23,7 @@ namespace osu.Game.Rulesets.Taiko.Difficulty
|
||||
private int countMeh;
|
||||
private int countMiss;
|
||||
|
||||
public TaikoPerformanceCalculator(Ruleset ruleset, WorkingBeatmap beatmap, Score score)
|
||||
public TaikoPerformanceCalculator(Ruleset ruleset, WorkingBeatmap beatmap, ScoreInfo score)
|
||||
: base(ruleset, beatmap, score)
|
||||
{
|
||||
}
|
||||
|
@ -3,22 +3,19 @@
|
||||
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Rulesets.Mods;
|
||||
using osu.Game.Rulesets.Scoring;
|
||||
using osu.Game.Rulesets.Taiko.Objects;
|
||||
using osu.Game.Rulesets.Taiko.Replays;
|
||||
using osu.Game.Scoring;
|
||||
using osu.Game.Users;
|
||||
|
||||
namespace osu.Game.Rulesets.Taiko.Mods
|
||||
{
|
||||
public class TaikoModAutoplay : ModAutoplay<TaikoHitObject>
|
||||
{
|
||||
protected override Score CreateReplayScore(Beatmap<TaikoHitObject> beatmap)
|
||||
protected override Score CreateReplayScore(Beatmap<TaikoHitObject> beatmap) => new Score
|
||||
{
|
||||
return new Score
|
||||
{
|
||||
User = new User { Username = "mekkadosu!" },
|
||||
Replay = new TaikoAutoGenerator(beatmap).Generate(),
|
||||
};
|
||||
}
|
||||
ScoreInfo = new ScoreInfo { User = new User { Username = "mekkadosu!" } },
|
||||
Replay = new TaikoAutoGenerator(beatmap).Generate(),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -5,10 +5,10 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Replays;
|
||||
using osu.Game.Rulesets.Objects.Types;
|
||||
using osu.Game.Rulesets.Taiko.Objects;
|
||||
using osu.Game.Rulesets.Replays;
|
||||
using osu.Game.Users;
|
||||
|
||||
namespace osu.Game.Rulesets.Taiko.Replays
|
||||
{
|
||||
@ -19,13 +19,7 @@ namespace osu.Game.Rulesets.Taiko.Replays
|
||||
public TaikoAutoGenerator(Beatmap<TaikoHitObject> beatmap)
|
||||
: base(beatmap)
|
||||
{
|
||||
Replay = new Replay
|
||||
{
|
||||
User = new User
|
||||
{
|
||||
Username = @"Autoplay",
|
||||
}
|
||||
};
|
||||
Replay = new Replay();
|
||||
}
|
||||
|
||||
protected Replay Replay;
|
||||
|
@ -5,6 +5,7 @@ using osu.Game.Rulesets.Replays;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using osu.Framework.Input.StateChanges;
|
||||
using osu.Game.Replays;
|
||||
|
||||
namespace osu.Game.Rulesets.Taiko.Replays
|
||||
{
|
||||
|
@ -3,8 +3,8 @@
|
||||
|
||||
using System.Collections.Generic;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Replays.Legacy;
|
||||
using osu.Game.Rulesets.Replays;
|
||||
using osu.Game.Rulesets.Replays.Legacy;
|
||||
using osu.Game.Rulesets.Replays.Types;
|
||||
|
||||
namespace osu.Game.Rulesets.Taiko.Replays
|
||||
|
@ -14,9 +14,9 @@ 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;
|
||||
using osu.Game.Scoring;
|
||||
|
||||
namespace osu.Game.Rulesets.Taiko
|
||||
{
|
||||
@ -112,7 +112,7 @@ namespace osu.Game.Rulesets.Taiko
|
||||
|
||||
public override DifficultyCalculator CreateDifficultyCalculator(WorkingBeatmap beatmap) => new TaikoDifficultyCalculator(this, beatmap);
|
||||
|
||||
public override PerformanceCalculator CreatePerformanceCalculator(WorkingBeatmap beatmap, Score score) => new TaikoPerformanceCalculator(this, beatmap, score);
|
||||
public override PerformanceCalculator CreatePerformanceCalculator(WorkingBeatmap beatmap, ScoreInfo score) => new TaikoPerformanceCalculator(this, beatmap, score);
|
||||
|
||||
public override int? LegacyID => 1;
|
||||
|
||||
|
@ -5,7 +5,6 @@ using osu.Framework.Allocation;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Rulesets.Objects.Drawables;
|
||||
using osu.Game.Rulesets.Objects.Types;
|
||||
using osu.Game.Rulesets.Replays;
|
||||
using osu.Game.Rulesets.Scoring;
|
||||
using osu.Game.Rulesets.Taiko.Objects;
|
||||
using osu.Game.Rulesets.Taiko.Objects.Drawables;
|
||||
@ -16,6 +15,7 @@ using System.Linq;
|
||||
using osu.Framework.Input;
|
||||
using osu.Game.Configuration;
|
||||
using osu.Game.Input.Handlers;
|
||||
using osu.Game.Replays;
|
||||
using osu.Game.Rulesets.UI.Scrolling;
|
||||
|
||||
namespace osu.Game.Rulesets.Taiko.UI
|
||||
|
@ -102,7 +102,7 @@ namespace osu.Game.Tests.Beatmaps.IO
|
||||
int fireCount = 0;
|
||||
|
||||
// ReSharper disable once AccessToModifiedClosure
|
||||
manager.ItemAdded += _ => fireCount++;
|
||||
manager.ItemAdded += (_, __, ___) => fireCount++;
|
||||
manager.ItemRemoved += _ => fireCount++;
|
||||
|
||||
var imported = loadOszIntoOsu(osu);
|
||||
|
@ -18,7 +18,7 @@ namespace osu.Game.Tests.NonVisual
|
||||
var combinations = new TestDifficultyCalculator().CreateDifficultyAdjustmentModCombinations();
|
||||
|
||||
Assert.AreEqual(1, combinations.Length);
|
||||
Assert.IsTrue(combinations[0] is NoModMod);
|
||||
Assert.IsTrue(combinations[0] is ModNoMod);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@ -27,7 +27,7 @@ namespace osu.Game.Tests.NonVisual
|
||||
var combinations = new TestDifficultyCalculator(new ModA()).CreateDifficultyAdjustmentModCombinations();
|
||||
|
||||
Assert.AreEqual(2, combinations.Length);
|
||||
Assert.IsTrue(combinations[0] is NoModMod);
|
||||
Assert.IsTrue(combinations[0] is ModNoMod);
|
||||
Assert.IsTrue(combinations[1] is ModA);
|
||||
}
|
||||
|
||||
@ -37,7 +37,7 @@ namespace osu.Game.Tests.NonVisual
|
||||
var combinations = new TestDifficultyCalculator(new ModA(), new ModB()).CreateDifficultyAdjustmentModCombinations();
|
||||
|
||||
Assert.AreEqual(4, combinations.Length);
|
||||
Assert.IsTrue(combinations[0] is NoModMod);
|
||||
Assert.IsTrue(combinations[0] is ModNoMod);
|
||||
Assert.IsTrue(combinations[1] is ModA);
|
||||
Assert.IsTrue(combinations[2] is MultiMod);
|
||||
Assert.IsTrue(combinations[3] is ModB);
|
||||
@ -52,7 +52,7 @@ namespace osu.Game.Tests.NonVisual
|
||||
var combinations = new TestDifficultyCalculator(new ModA(), new ModIncompatibleWithA()).CreateDifficultyAdjustmentModCombinations();
|
||||
|
||||
Assert.AreEqual(3, combinations.Length);
|
||||
Assert.IsTrue(combinations[0] is NoModMod);
|
||||
Assert.IsTrue(combinations[0] is ModNoMod);
|
||||
Assert.IsTrue(combinations[1] is ModA);
|
||||
Assert.IsTrue(combinations[2] is ModIncompatibleWithA);
|
||||
}
|
||||
@ -63,7 +63,7 @@ namespace osu.Game.Tests.NonVisual
|
||||
var combinations = new TestDifficultyCalculator(new ModA(), new ModB(), new ModIncompatibleWithA(), new ModIncompatibleWithAAndB()).CreateDifficultyAdjustmentModCombinations();
|
||||
|
||||
Assert.AreEqual(8, combinations.Length);
|
||||
Assert.IsTrue(combinations[0] is NoModMod);
|
||||
Assert.IsTrue(combinations[0] is ModNoMod);
|
||||
Assert.IsTrue(combinations[1] is ModA);
|
||||
Assert.IsTrue(combinations[2] is MultiMod);
|
||||
Assert.IsTrue(combinations[3] is ModB);
|
||||
@ -86,7 +86,7 @@ namespace osu.Game.Tests.NonVisual
|
||||
var combinations = new TestDifficultyCalculator(new ModAofA(), new ModIncompatibleWithAofA()).CreateDifficultyAdjustmentModCombinations();
|
||||
|
||||
Assert.AreEqual(3, combinations.Length);
|
||||
Assert.IsTrue(combinations[0] is NoModMod);
|
||||
Assert.IsTrue(combinations[0] is ModNoMod);
|
||||
Assert.IsTrue(combinations[1] is ModAofA);
|
||||
Assert.IsTrue(combinations[2] is ModIncompatibleWithAofA);
|
||||
}
|
||||
@ -94,7 +94,7 @@ namespace osu.Game.Tests.NonVisual
|
||||
private class ModA : Mod
|
||||
{
|
||||
public override string Name => nameof(ModA);
|
||||
public override string ShortenedName => nameof(ModA);
|
||||
public override string Acronym => nameof(ModA);
|
||||
public override double ScoreMultiplier => 1;
|
||||
|
||||
public override Type[] IncompatibleMods => new[] { typeof(ModIncompatibleWithA), typeof(ModIncompatibleWithAAndB) };
|
||||
@ -103,7 +103,7 @@ namespace osu.Game.Tests.NonVisual
|
||||
private class ModB : Mod
|
||||
{
|
||||
public override string Name => nameof(ModB);
|
||||
public override string ShortenedName => nameof(ModB);
|
||||
public override string Acronym => nameof(ModB);
|
||||
public override double ScoreMultiplier => 1;
|
||||
|
||||
public override Type[] IncompatibleMods => new[] { typeof(ModIncompatibleWithAAndB) };
|
||||
@ -112,7 +112,7 @@ namespace osu.Game.Tests.NonVisual
|
||||
private class ModIncompatibleWithA : Mod
|
||||
{
|
||||
public override string Name => $"Incompatible With {nameof(ModA)}";
|
||||
public override string ShortenedName => $"Incompatible With {nameof(ModA)}";
|
||||
public override string Acronym => $"Incompatible With {nameof(ModA)}";
|
||||
public override double ScoreMultiplier => 1;
|
||||
|
||||
public override Type[] IncompatibleMods => new[] { typeof(ModA) };
|
||||
@ -130,7 +130,7 @@ namespace osu.Game.Tests.NonVisual
|
||||
private class ModIncompatibleWithAAndB : Mod
|
||||
{
|
||||
public override string Name => $"Incompatible With {nameof(ModA)} and {nameof(ModB)}";
|
||||
public override string ShortenedName => $"Incompatible With {nameof(ModA)} and {nameof(ModB)}";
|
||||
public override string Acronym => $"Incompatible With {nameof(ModA)} and {nameof(ModB)}";
|
||||
public override double ScoreMultiplier => 1;
|
||||
|
||||
public override Type[] IncompatibleMods => new[] { typeof(ModA), typeof(ModB) };
|
||||
|
168
osu.Game.Tests/Scores/IO/ImportScoreTest.cs
Normal file
168
osu.Game.Tests/Scores/IO/ImportScoreTest.cs
Normal file
@ -0,0 +1,168 @@
|
||||
// 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.IO;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Platform;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Rulesets.Mods;
|
||||
using osu.Game.Rulesets.Osu;
|
||||
using osu.Game.Rulesets.Osu.Mods;
|
||||
using osu.Game.Rulesets.Scoring;
|
||||
using osu.Game.Scoring;
|
||||
using osu.Game.Users;
|
||||
|
||||
namespace osu.Game.Tests.Scores.IO
|
||||
{
|
||||
public class ImportScoreTest
|
||||
{
|
||||
public const string TEST_OSZ_PATH = @"../../../../osu-resources/osu.Game.Resources/Beatmaps/241526 Soleily - Renatus.osz";
|
||||
|
||||
[Test]
|
||||
public void TestBasicImport()
|
||||
{
|
||||
using (HeadlessGameHost host = new CleanRunHeadlessGameHost("TestBasicImport"))
|
||||
{
|
||||
try
|
||||
{
|
||||
var osu = loadOsu(host);
|
||||
|
||||
var toImport = new ScoreInfo
|
||||
{
|
||||
Rank = ScoreRank.B,
|
||||
TotalScore = 987654,
|
||||
Accuracy = 0.8,
|
||||
Health = 0.8,
|
||||
MaxCombo = 500,
|
||||
Combo = 250,
|
||||
User = new User { Username = "Test user" },
|
||||
Date = DateTimeOffset.Now,
|
||||
OnlineScoreID = 12345,
|
||||
};
|
||||
|
||||
var imported = loadIntoOsu(osu, toImport);
|
||||
|
||||
Assert.AreEqual(toImport.Rank, imported.Rank);
|
||||
Assert.AreEqual(toImport.TotalScore, imported.TotalScore);
|
||||
Assert.AreEqual(toImport.Accuracy, imported.Accuracy);
|
||||
Assert.AreEqual(toImport.Health, imported.Health);
|
||||
Assert.AreEqual(toImport.MaxCombo, imported.MaxCombo);
|
||||
Assert.AreEqual(toImport.Combo, imported.Combo);
|
||||
Assert.AreEqual(toImport.User.Username, imported.User.Username);
|
||||
Assert.AreEqual(toImport.Date, imported.Date);
|
||||
Assert.AreEqual(toImport.OnlineScoreID, imported.OnlineScoreID);
|
||||
}
|
||||
finally
|
||||
{
|
||||
host.Exit();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestImportMods()
|
||||
{
|
||||
using (HeadlessGameHost host = new CleanRunHeadlessGameHost("TestImportMods"))
|
||||
{
|
||||
try
|
||||
{
|
||||
var osu = loadOsu(host);
|
||||
|
||||
var toImport = new ScoreInfo
|
||||
{
|
||||
Mods = new Mod[] { new OsuModHardRock(), new OsuModDoubleTime() },
|
||||
};
|
||||
|
||||
var imported = loadIntoOsu(osu, toImport);
|
||||
|
||||
Assert.IsTrue(imported.Mods.Any(m => m is OsuModHardRock));
|
||||
Assert.IsTrue(imported.Mods.Any(m => m is OsuModDoubleTime));
|
||||
}
|
||||
finally
|
||||
{
|
||||
host.Exit();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestImportStatistics()
|
||||
{
|
||||
using (HeadlessGameHost host = new CleanRunHeadlessGameHost("TestImportStatistics"))
|
||||
{
|
||||
try
|
||||
{
|
||||
var osu = loadOsu(host);
|
||||
|
||||
var toImport = new ScoreInfo
|
||||
{
|
||||
Statistics = new Dictionary<HitResult, object>
|
||||
{
|
||||
{ HitResult.Perfect, 100 },
|
||||
{ HitResult.Miss, 50 }
|
||||
}
|
||||
};
|
||||
|
||||
var imported = loadIntoOsu(osu, toImport);
|
||||
|
||||
Assert.AreEqual(toImport.Statistics[HitResult.Perfect], imported.Statistics[HitResult.Perfect]);
|
||||
Assert.AreEqual(toImport.Statistics[HitResult.Miss], imported.Statistics[HitResult.Miss]);
|
||||
}
|
||||
finally
|
||||
{
|
||||
host.Exit();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private ScoreInfo loadIntoOsu(OsuGameBase osu, ScoreInfo score)
|
||||
{
|
||||
var beatmapManager = osu.Dependencies.Get<BeatmapManager>();
|
||||
|
||||
score.Beatmap = beatmapManager.GetAllUsableBeatmapSets().First().Beatmaps.First();
|
||||
score.Ruleset = new OsuRuleset().RulesetInfo;
|
||||
|
||||
var scoreManager = osu.Dependencies.Get<ScoreManager>();
|
||||
scoreManager.Import(score);
|
||||
|
||||
return scoreManager.GetAllUsableScores().First();
|
||||
}
|
||||
|
||||
private string createTemporaryBeatmap()
|
||||
{
|
||||
var temp = Path.GetTempFileName() + ".osz";
|
||||
File.Copy(TEST_OSZ_PATH, temp, true);
|
||||
Assert.IsTrue(File.Exists(temp));
|
||||
return temp;
|
||||
}
|
||||
|
||||
private OsuGameBase loadOsu(GameHost host)
|
||||
{
|
||||
var osu = new OsuGameBase();
|
||||
Task.Run(() => host.Run(osu));
|
||||
waitForOrAssert(() => osu.IsLoaded, @"osu! failed to start in a reasonable amount of time");
|
||||
|
||||
var beatmapFile = createTemporaryBeatmap();
|
||||
var beatmapManager = osu.Dependencies.Get<BeatmapManager>();
|
||||
beatmapManager.Import(beatmapFile);
|
||||
|
||||
return osu;
|
||||
}
|
||||
|
||||
private void waitForOrAssert(Func<bool> result, string failureMessage, int timeout = 60000)
|
||||
{
|
||||
Task task = Task.Run(() =>
|
||||
{
|
||||
while (!result()) Thread.Sleep(200);
|
||||
});
|
||||
|
||||
Assert.IsTrue(task.Wait(timeout), failureMessage);
|
||||
}
|
||||
}
|
||||
}
|
@ -16,15 +16,16 @@ using osu.Framework.Graphics.Containers;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Online.API.Requests.Responses;
|
||||
using osu.Game.Rulesets.Osu;
|
||||
using osu.Game.Scoring;
|
||||
|
||||
namespace osu.Game.Tests.Visual
|
||||
{
|
||||
[System.ComponentModel.Description("in BeatmapOverlay")]
|
||||
public class TestCaseBeatmapScoresContainer : OsuTestCase
|
||||
{
|
||||
private readonly IEnumerable<APIScore> scores;
|
||||
private readonly IEnumerable<APIScore> anotherScores;
|
||||
private readonly APIScore topScore;
|
||||
private readonly IEnumerable<APIScoreInfo> scores;
|
||||
private readonly IEnumerable<APIScoreInfo> anotherScores;
|
||||
private readonly APIScoreInfo topScoreInfo;
|
||||
private readonly Box background;
|
||||
|
||||
public TestCaseBeatmapScoresContainer()
|
||||
@ -48,7 +49,7 @@ namespace osu.Game.Tests.Visual
|
||||
|
||||
AddStep("scores pack 1", () => scoresContainer.Scores = scores);
|
||||
AddStep("scores pack 2", () => scoresContainer.Scores = anotherScores);
|
||||
AddStep("only top score", () => scoresContainer.Scores = new[] { topScore });
|
||||
AddStep("only top score", () => scoresContainer.Scores = new[] { topScoreInfo });
|
||||
AddStep("remove scores", () => scoresContainer.Scores = null);
|
||||
AddStep("resize to big", () => container.ResizeWidthTo(1, 300));
|
||||
AddStep("resize to normal", () => container.ResizeWidthTo(0.8f, 300));
|
||||
@ -57,7 +58,7 @@ namespace osu.Game.Tests.Visual
|
||||
|
||||
scores = new[]
|
||||
{
|
||||
new APIScore
|
||||
new APIScoreInfo
|
||||
{
|
||||
User = new User
|
||||
{
|
||||
@ -80,7 +81,7 @@ namespace osu.Game.Tests.Visual
|
||||
TotalScore = 1234567890,
|
||||
Accuracy = 1,
|
||||
},
|
||||
new APIScore
|
||||
new APIScoreInfo
|
||||
{
|
||||
User = new User
|
||||
{
|
||||
@ -102,7 +103,7 @@ namespace osu.Game.Tests.Visual
|
||||
TotalScore = 1234789,
|
||||
Accuracy = 0.9997,
|
||||
},
|
||||
new APIScore
|
||||
new APIScoreInfo
|
||||
{
|
||||
User = new User
|
||||
{
|
||||
@ -123,7 +124,7 @@ namespace osu.Game.Tests.Visual
|
||||
TotalScore = 12345678,
|
||||
Accuracy = 0.9854,
|
||||
},
|
||||
new APIScore
|
||||
new APIScoreInfo
|
||||
{
|
||||
User = new User
|
||||
{
|
||||
@ -143,7 +144,7 @@ namespace osu.Game.Tests.Visual
|
||||
TotalScore = 1234567,
|
||||
Accuracy = 0.8765,
|
||||
},
|
||||
new APIScore
|
||||
new APIScoreInfo
|
||||
{
|
||||
User = new User
|
||||
{
|
||||
@ -169,7 +170,7 @@ namespace osu.Game.Tests.Visual
|
||||
|
||||
anotherScores = new[]
|
||||
{
|
||||
new APIScore
|
||||
new APIScoreInfo
|
||||
{
|
||||
User = new User
|
||||
{
|
||||
@ -191,7 +192,7 @@ namespace osu.Game.Tests.Visual
|
||||
TotalScore = 1234789,
|
||||
Accuracy = 0.9997,
|
||||
},
|
||||
new APIScore
|
||||
new APIScoreInfo
|
||||
{
|
||||
User = new User
|
||||
{
|
||||
@ -214,7 +215,7 @@ namespace osu.Game.Tests.Visual
|
||||
TotalScore = 1234567890,
|
||||
Accuracy = 1,
|
||||
},
|
||||
new APIScore
|
||||
new APIScoreInfo
|
||||
{
|
||||
User = new User
|
||||
{
|
||||
@ -230,7 +231,7 @@ namespace osu.Game.Tests.Visual
|
||||
TotalScore = 123456,
|
||||
Accuracy = 0.6543,
|
||||
},
|
||||
new APIScore
|
||||
new APIScoreInfo
|
||||
{
|
||||
User = new User
|
||||
{
|
||||
@ -251,7 +252,7 @@ namespace osu.Game.Tests.Visual
|
||||
TotalScore = 12345678,
|
||||
Accuracy = 0.9854,
|
||||
},
|
||||
new APIScore
|
||||
new APIScoreInfo
|
||||
{
|
||||
User = new User
|
||||
{
|
||||
@ -279,7 +280,7 @@ namespace osu.Game.Tests.Visual
|
||||
s.Statistics.Add(HitResult.Meh, RNG.Next(2000));
|
||||
}
|
||||
|
||||
topScore = new APIScore
|
||||
topScoreInfo = new APIScoreInfo
|
||||
{
|
||||
User = new User
|
||||
{
|
||||
@ -301,9 +302,9 @@ namespace osu.Game.Tests.Visual
|
||||
TotalScore = 987654321,
|
||||
Accuracy = 0.8487,
|
||||
};
|
||||
topScore.Statistics.Add(HitResult.Great, RNG.Next(2000));
|
||||
topScore.Statistics.Add(HitResult.Good, RNG.Next(2000));
|
||||
topScore.Statistics.Add(HitResult.Meh, RNG.Next(2000));
|
||||
topScoreInfo.Statistics.Add(HitResult.Great, RNG.Next(2000));
|
||||
topScoreInfo.Statistics.Add(HitResult.Good, RNG.Next(2000));
|
||||
topScoreInfo.Statistics.Add(HitResult.Meh, RNG.Next(2000));
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
|
@ -29,7 +29,7 @@ namespace osu.Game.Tests.Visual
|
||||
{
|
||||
public override IReadOnlyList<Type> RequiredTypes => new[]
|
||||
{
|
||||
typeof(SelectionBox),
|
||||
typeof(SelectionHandler),
|
||||
typeof(DragBox),
|
||||
typeof(HitObjectComposer),
|
||||
typeof(OsuHitObjectComposer),
|
||||
|
@ -5,7 +5,6 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Game.Rulesets.Scoring;
|
||||
using osu.Game.Screens.Select.Leaderboards;
|
||||
using osu.Game.Users;
|
||||
using osu.Framework.Allocation;
|
||||
@ -13,6 +12,7 @@ using osuTK;
|
||||
using System.Linq;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Rulesets;
|
||||
using osu.Game.Scoring;
|
||||
|
||||
namespace osu.Game.Tests.Visual
|
||||
{
|
||||
@ -58,7 +58,7 @@ namespace osu.Game.Tests.Visual
|
||||
{
|
||||
var scores = new[]
|
||||
{
|
||||
new Score
|
||||
new ScoreInfo
|
||||
{
|
||||
Rank = ScoreRank.XH,
|
||||
Accuracy = 1,
|
||||
@ -76,7 +76,7 @@ namespace osu.Game.Tests.Visual
|
||||
},
|
||||
},
|
||||
},
|
||||
new Score
|
||||
new ScoreInfo
|
||||
{
|
||||
Rank = ScoreRank.X,
|
||||
Accuracy = 1,
|
||||
@ -94,7 +94,7 @@ namespace osu.Game.Tests.Visual
|
||||
},
|
||||
},
|
||||
},
|
||||
new Score
|
||||
new ScoreInfo
|
||||
{
|
||||
Rank = ScoreRank.SH,
|
||||
Accuracy = 1,
|
||||
@ -112,7 +112,7 @@ namespace osu.Game.Tests.Visual
|
||||
},
|
||||
},
|
||||
},
|
||||
new Score
|
||||
new ScoreInfo
|
||||
{
|
||||
Rank = ScoreRank.S,
|
||||
Accuracy = 1,
|
||||
@ -130,7 +130,7 @@ namespace osu.Game.Tests.Visual
|
||||
},
|
||||
},
|
||||
},
|
||||
new Score
|
||||
new ScoreInfo
|
||||
{
|
||||
Rank = ScoreRank.A,
|
||||
Accuracy = 1,
|
||||
@ -148,7 +148,7 @@ namespace osu.Game.Tests.Visual
|
||||
},
|
||||
},
|
||||
},
|
||||
new Score
|
||||
new ScoreInfo
|
||||
{
|
||||
Rank = ScoreRank.B,
|
||||
Accuracy = 0.9826,
|
||||
@ -166,7 +166,7 @@ namespace osu.Game.Tests.Visual
|
||||
},
|
||||
},
|
||||
},
|
||||
new Score
|
||||
new ScoreInfo
|
||||
{
|
||||
Rank = ScoreRank.C,
|
||||
Accuracy = 0.9654,
|
||||
@ -184,7 +184,7 @@ namespace osu.Game.Tests.Visual
|
||||
},
|
||||
},
|
||||
},
|
||||
new Score
|
||||
new ScoreInfo
|
||||
{
|
||||
Rank = ScoreRank.F,
|
||||
Accuracy = 0.6025,
|
||||
@ -202,7 +202,7 @@ namespace osu.Game.Tests.Visual
|
||||
},
|
||||
},
|
||||
},
|
||||
new Score
|
||||
new ScoreInfo
|
||||
{
|
||||
Rank = ScoreRank.F,
|
||||
Accuracy = 0.5140,
|
||||
@ -220,7 +220,7 @@ namespace osu.Game.Tests.Visual
|
||||
},
|
||||
},
|
||||
},
|
||||
new Score
|
||||
new ScoreInfo
|
||||
{
|
||||
Rank = ScoreRank.F,
|
||||
Accuracy = 0.4222,
|
||||
|
@ -187,7 +187,7 @@ namespace osu.Game.Tests.Visual
|
||||
private static int importId;
|
||||
private int getImportId() => ++importId;
|
||||
|
||||
private void changeMods(params Mod[] mods) => AddStep($"change mods to {string.Join(", ", mods.Select(m => m.ShortenedName))}", () => selectedMods.Value = mods);
|
||||
private void changeMods(params Mod[] mods) => AddStep($"change mods to {string.Join(", ", mods.Select(m => m.Acronym))}", () => selectedMods.Value = mods);
|
||||
|
||||
private void changeRuleset(int id) => AddStep($"change ruleset to {id}", () => Ruleset.Value = rulesets.AvailableRulesets.First(r => r.ID == id));
|
||||
|
||||
|
@ -5,6 +5,7 @@ using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using osu.Game.Rulesets;
|
||||
using osu.Game.Rulesets.Mods;
|
||||
using osu.Game.Scoring;
|
||||
using osu.Game.Screens.Play;
|
||||
|
||||
namespace osu.Game.Tests.Visual
|
||||
@ -19,13 +20,10 @@ namespace osu.Game.Tests.Visual
|
||||
Beatmap.Value.Mods.Value = Beatmap.Value.Mods.Value.Concat(new[] { ruleset.GetAutoplayMod() });
|
||||
var dummyRulesetContainer = ruleset.CreateRulesetContainerWith(Beatmap.Value);
|
||||
|
||||
// We have the replay
|
||||
var replay = dummyRulesetContainer.Replay;
|
||||
|
||||
// Reset the mods
|
||||
Beatmap.Value.Mods.Value = Beatmap.Value.Mods.Value.Where(m => !(m is ModAutoplay));
|
||||
|
||||
return new ReplayPlayer(replay);
|
||||
return new ReplayPlayer(new Score { Replay = dummyRulesetContainer.Replay });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -7,6 +7,7 @@ using NUnit.Framework;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Rulesets.Scoring;
|
||||
using osu.Game.Scoring;
|
||||
using osu.Game.Screens.Ranking;
|
||||
using osu.Game.Users;
|
||||
|
||||
@ -19,7 +20,7 @@ namespace osu.Game.Tests.Visual
|
||||
|
||||
public override IReadOnlyList<Type> RequiredTypes => new[]
|
||||
{
|
||||
typeof(Score),
|
||||
typeof(ScoreInfo),
|
||||
typeof(Results),
|
||||
typeof(ResultsPage),
|
||||
typeof(ResultsPageScore),
|
||||
@ -40,7 +41,7 @@ namespace osu.Game.Tests.Visual
|
||||
if (beatmapInfo != null)
|
||||
Beatmap.Value = beatmaps.GetWorkingBeatmap(beatmapInfo);
|
||||
|
||||
Add(new Results(new Score
|
||||
Add(new Results(new ScoreInfo
|
||||
{
|
||||
TotalScore = 2845370,
|
||||
Accuracy = 0.98,
|
||||
|
@ -1,20 +1,17 @@
|
||||
// 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.ComponentModel.DataAnnotations.Schema;
|
||||
using Newtonsoft.Json;
|
||||
using osu.Game.Database;
|
||||
|
||||
namespace osu.Game.Beatmaps
|
||||
{
|
||||
public class BeatmapDifficulty
|
||||
public class BeatmapDifficulty : IHasPrimaryKey
|
||||
{
|
||||
/// <summary>
|
||||
/// The default value used for all difficulty settings except <see cref="SliderMultiplier"/> and <see cref="SliderTickRate"/>.
|
||||
/// </summary>
|
||||
public const float DEFAULT_DIFFICULTY = 5;
|
||||
|
||||
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||
[JsonIgnore]
|
||||
public int ID { get; set; }
|
||||
|
||||
public float DrainRate { get; set; } = DEFAULT_DIFFICULTY;
|
||||
|
@ -15,8 +15,6 @@ namespace osu.Game.Beatmaps
|
||||
[Serializable]
|
||||
public class BeatmapInfo : IEquatable<BeatmapInfo>, IJsonSerializable, IHasPrimaryKey
|
||||
{
|
||||
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||
[JsonIgnore]
|
||||
public int ID { get; set; }
|
||||
|
||||
public int BeatmapVersion;
|
||||
|
@ -63,6 +63,8 @@ namespace osu.Game.Beatmaps
|
||||
|
||||
public override string[] HandledExtensions => new[] { ".osz" };
|
||||
|
||||
protected override string[] HashableFileTypes => new[] { ".osu" };
|
||||
|
||||
protected override string ImportFromStablePath => "Songs";
|
||||
|
||||
private readonly RulesetStore rulesets;
|
||||
@ -129,19 +131,6 @@ namespace osu.Game.Beatmaps
|
||||
beatmaps.ForEach(b => b.OnlineBeatmapID = null);
|
||||
}
|
||||
|
||||
protected override BeatmapSetInfo CheckForExisting(BeatmapSetInfo model)
|
||||
{
|
||||
// check if this beatmap has already been imported and exit early if so
|
||||
var existingHashMatch = beatmaps.ConsumableItems.FirstOrDefault(b => b.Hash == model.Hash);
|
||||
if (existingHashMatch != null)
|
||||
{
|
||||
Undelete(existingHashMatch);
|
||||
return existingHashMatch;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Downloads a beatmap.
|
||||
/// This will post notifications tracking progress.
|
||||
@ -317,20 +306,6 @@ namespace osu.Game.Beatmaps
|
||||
/// <returns>Results from the provided query.</returns>
|
||||
public IQueryable<BeatmapInfo> QueryBeatmaps(Expression<Func<BeatmapInfo, bool>> query) => beatmaps.Beatmaps.AsNoTracking().Where(query);
|
||||
|
||||
/// <summary>
|
||||
/// Create a SHA-2 hash from the provided archive based on contained beatmap (.osu) file content.
|
||||
/// </summary>
|
||||
private string computeBeatmapSetHash(ArchiveReader reader)
|
||||
{
|
||||
// for now, concatenate all .osu files in the set to create a unique hash.
|
||||
MemoryStream hashable = new MemoryStream();
|
||||
foreach (string file in reader.Filenames.Where(f => f.EndsWith(".osu")))
|
||||
using (Stream s = reader.GetStream(file))
|
||||
s.CopyTo(hashable);
|
||||
|
||||
return hashable.ComputeSHA2Hash();
|
||||
}
|
||||
|
||||
protected override BeatmapSetInfo CreateModel(ArchiveReader reader)
|
||||
{
|
||||
// let's make sure there are actually .osu files to import.
|
||||
@ -349,7 +324,6 @@ namespace osu.Game.Beatmaps
|
||||
{
|
||||
OnlineBeatmapSetID = beatmap.BeatmapInfo.BeatmapSet?.OnlineBeatmapSetID,
|
||||
Beatmaps = new List<BeatmapInfo>(),
|
||||
Hash = computeBeatmapSetHash(reader),
|
||||
Metadata = beatmap.Metadata,
|
||||
};
|
||||
}
|
||||
|
@ -6,14 +6,14 @@ using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Linq;
|
||||
using Newtonsoft.Json;
|
||||
using osu.Game.Database;
|
||||
using osu.Game.Users;
|
||||
|
||||
namespace osu.Game.Beatmaps
|
||||
{
|
||||
[Serializable]
|
||||
public class BeatmapMetadata : IEquatable<BeatmapMetadata>
|
||||
public class BeatmapMetadata : IEquatable<BeatmapMetadata>, IHasPrimaryKey
|
||||
{
|
||||
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||
public int ID { get; set; }
|
||||
|
||||
public string Title { get; set; }
|
||||
|
@ -2,15 +2,13 @@
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using osu.Game.Database;
|
||||
using osu.Game.IO;
|
||||
|
||||
namespace osu.Game.Beatmaps
|
||||
{
|
||||
public class BeatmapSetFileInfo : INamedFileInfo
|
||||
public class BeatmapSetFileInfo : INamedFileInfo, IHasPrimaryKey
|
||||
{
|
||||
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||
public int ID { get; set; }
|
||||
|
||||
public int BeatmapSetInfoID { get; set; }
|
||||
|
@ -10,7 +10,6 @@ namespace osu.Game.Beatmaps
|
||||
{
|
||||
public class BeatmapSetInfo : IHasPrimaryKey, IHasFiles<BeatmapSetFileInfo>, ISoftDelete
|
||||
{
|
||||
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||
public int ID { get; set; }
|
||||
|
||||
private int? onlineBeatmapSetID;
|
||||
|
@ -78,7 +78,7 @@ namespace osu.Game.Beatmaps.Drawables
|
||||
}
|
||||
}
|
||||
|
||||
private void setAdded(BeatmapSetInfo s) => Schedule(() =>
|
||||
private void setAdded(BeatmapSetInfo s, bool existing, bool silent) => Schedule(() =>
|
||||
{
|
||||
if (s.OnlineBeatmapSetID == set.OnlineBeatmapSetID)
|
||||
DownloadState.Value = DownloadStatus.Downloaded;
|
||||
|
@ -9,7 +9,6 @@ namespace osu.Game.Configuration
|
||||
[Table("Settings")]
|
||||
public class DatabasedSetting : IHasPrimaryKey
|
||||
{
|
||||
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||
public int ID { get; set; }
|
||||
|
||||
public int? RulesetID { get; set; }
|
||||
|
@ -8,6 +8,7 @@ using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using JetBrains.Annotations;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using osu.Framework.Extensions;
|
||||
using osu.Framework.IO.File;
|
||||
using osu.Framework.Logging;
|
||||
using osu.Framework.Platform;
|
||||
@ -31,6 +32,8 @@ namespace osu.Game.Database
|
||||
where TModel : class, IHasFiles<TFileModel>, IHasPrimaryKey, ISoftDelete
|
||||
where TFileModel : INamedFileInfo, new()
|
||||
{
|
||||
public delegate void ItemAddedDelegate(TModel model, bool existing, bool silent);
|
||||
|
||||
/// <summary>
|
||||
/// Set an endpoint for notifications to be posted to.
|
||||
/// </summary>
|
||||
@ -40,7 +43,7 @@ namespace osu.Game.Database
|
||||
/// Fired when a new <see cref="TModel"/> becomes available in the database.
|
||||
/// This is not guaranteed to run on the update thread.
|
||||
/// </summary>
|
||||
public event Action<TModel> ItemAdded;
|
||||
public event ItemAddedDelegate ItemAdded;
|
||||
|
||||
/// <summary>
|
||||
/// Fired when a <see cref="TModel"/> is removed from the database.
|
||||
@ -107,7 +110,7 @@ namespace osu.Game.Database
|
||||
ContextFactory = contextFactory;
|
||||
|
||||
ModelStore = modelStore;
|
||||
ModelStore.ItemAdded += s => handleEvent(() => ItemAdded?.Invoke(s));
|
||||
ModelStore.ItemAdded += (item, silent) => handleEvent(() => ItemAdded?.Invoke(item, false, silent));
|
||||
ModelStore.ItemRemoved += s => handleEvent(() => ItemRemoved?.Invoke(s));
|
||||
|
||||
Files = new FileStore(contextFactory, storage);
|
||||
@ -203,7 +206,12 @@ namespace osu.Game.Database
|
||||
try
|
||||
{
|
||||
var model = CreateModel(archive);
|
||||
return model == null ? null : Import(model, archive);
|
||||
|
||||
if (model == null) return null;
|
||||
|
||||
model.Hash = computeHash(archive);
|
||||
|
||||
return Import(model, false, archive);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
@ -212,12 +220,34 @@ namespace osu.Game.Database
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Any file extensions which should be included in hash creation.
|
||||
/// Generally should include all file types which determine the file's uniqueness.
|
||||
/// Large files should be avoided if possible.
|
||||
/// </summary>
|
||||
protected abstract string[] HashableFileTypes { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Create a SHA-2 hash from the provided archive based on file content of all files matching <see cref="HashableFileTypes"/>.
|
||||
/// </summary>
|
||||
private string computeHash(ArchiveReader reader)
|
||||
{
|
||||
// for now, concatenate all .osu files in the set to create a unique hash.
|
||||
MemoryStream hashable = new MemoryStream();
|
||||
foreach (string file in reader.Filenames.Where(f => HashableFileTypes.Any(f.EndsWith)))
|
||||
using (Stream s = reader.GetStream(file))
|
||||
s.CopyTo(hashable);
|
||||
|
||||
return hashable.ComputeSHA2Hash();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Import an item from a <see cref="TModel"/>.
|
||||
/// </summary>
|
||||
/// <param name="item">The model to be imported.</param>
|
||||
/// <param name="silent">Whether the user should be notified fo the import.</param>
|
||||
/// <param name="archive">An optional archive to use for model population.</param>
|
||||
public TModel Import(TModel item, ArchiveReader archive = null)
|
||||
public TModel Import(TModel item, bool silent = false, ArchiveReader archive = null)
|
||||
{
|
||||
delayEvents();
|
||||
|
||||
@ -235,7 +265,9 @@ namespace osu.Game.Database
|
||||
|
||||
if (existing != null)
|
||||
{
|
||||
Undelete(existing);
|
||||
Logger.Log($"Found existing {typeof(TModel)} for {item} (ID {existing.ID}). Skipping import.", LoggingTarget.Database);
|
||||
handleEvent(() => ItemAdded?.Invoke(existing, true, silent));
|
||||
return existing;
|
||||
}
|
||||
|
||||
@ -245,7 +277,7 @@ namespace osu.Game.Database
|
||||
Populate(item, archive);
|
||||
|
||||
// import to store
|
||||
ModelStore.Add(item);
|
||||
ModelStore.Add(item, silent);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
@ -471,7 +503,12 @@ namespace osu.Game.Database
|
||||
{
|
||||
}
|
||||
|
||||
protected virtual TModel CheckForExisting(TModel model) => null;
|
||||
/// <summary>
|
||||
/// Check whether an existing model already exists for a new import item.
|
||||
/// </summary>
|
||||
/// <param name="model">The new model proposed for import. Note that <see cref="Populate"/> has not yet been run on this model.</param>
|
||||
/// <returns>An existing model which matches the criteria to skip importing, else null.</returns>
|
||||
protected virtual TModel CheckForExisting(TModel model) => model.Hash == null ? null : ModelStore.ConsumableItems.FirstOrDefault(b => b.Hash == model.Hash);
|
||||
|
||||
private DbSet<TModel> queryModel() => ContextFactory.Get().Set<TModel>();
|
||||
|
||||
@ -485,7 +522,9 @@ namespace osu.Game.Database
|
||||
if (ZipUtils.IsZipArchive(path))
|
||||
return new ZipArchiveReader(File.Open(path, FileMode.Open, FileAccess.Read, FileShare.Read), Path.GetFileName(path));
|
||||
if (Directory.Exists(path))
|
||||
return new LegacyFilesystemReader(path);
|
||||
return new LegacyDirectoryArchiveReader(path);
|
||||
if (File.Exists(path))
|
||||
return new LegacyFileArchiveReader(path);
|
||||
throw new InvalidFormatException($"{path} is not a valid archive");
|
||||
}
|
||||
}
|
||||
|
@ -11,8 +11,9 @@ namespace osu.Game.Database
|
||||
/// <typeparam name="TFile">The model representing a file.</typeparam>
|
||||
public interface IHasFiles<TFile>
|
||||
where TFile : INamedFileInfo
|
||||
|
||||
{
|
||||
List<TFile> Files { get; set; }
|
||||
|
||||
string Hash { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -1,10 +1,15 @@
|
||||
// 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.ComponentModel.DataAnnotations.Schema;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace osu.Game.Database
|
||||
{
|
||||
public interface IHasPrimaryKey
|
||||
{
|
||||
[JsonIgnore]
|
||||
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||
int ID { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -10,7 +10,11 @@ namespace osu.Game.Database
|
||||
/// </summary>
|
||||
public interface INamedFileInfo
|
||||
{
|
||||
// An explicit foreign key property isn't required but is recommended and may be helpful to have
|
||||
int FileInfoID { get; set; }
|
||||
|
||||
FileInfo FileInfo { get; set; }
|
||||
|
||||
string Filename { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -16,7 +16,9 @@ namespace osu.Game.Database
|
||||
public abstract class MutableDatabaseBackedStore<T> : DatabaseBackedStore
|
||||
where T : class, IHasPrimaryKey, ISoftDelete
|
||||
{
|
||||
public event Action<T> ItemAdded;
|
||||
public delegate void ItemAddedDelegate(T model, bool silent);
|
||||
|
||||
public event ItemAddedDelegate ItemAdded;
|
||||
public event Action<T> ItemRemoved;
|
||||
|
||||
protected MutableDatabaseBackedStore(IDatabaseContextFactory contextFactory, Storage storage = null)
|
||||
@ -33,7 +35,8 @@ namespace osu.Game.Database
|
||||
/// Add a <see cref="T"/> to the database.
|
||||
/// </summary>
|
||||
/// <param name="item">The item to add.</param>
|
||||
public void Add(T item)
|
||||
/// <param name="silent">Whether the user should be notified of the addition.</param>
|
||||
public void Add(T item, bool silent)
|
||||
{
|
||||
using (var usage = ContextFactory.GetForWrite())
|
||||
{
|
||||
@ -41,7 +44,7 @@ namespace osu.Game.Database
|
||||
context.Attach(item);
|
||||
}
|
||||
|
||||
ItemAdded?.Invoke(item);
|
||||
ItemAdded?.Invoke(item, silent);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -54,7 +57,7 @@ namespace osu.Game.Database
|
||||
usage.Context.Update(item);
|
||||
|
||||
ItemRemoved?.Invoke(item);
|
||||
ItemAdded?.Invoke(item);
|
||||
ItemAdded?.Invoke(item, true);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -89,7 +92,7 @@ namespace osu.Game.Database
|
||||
item.DeletePending = false;
|
||||
}
|
||||
|
||||
ItemAdded?.Invoke(item);
|
||||
ItemAdded?.Invoke(item, true);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -10,6 +10,7 @@ using osu.Game.Beatmaps;
|
||||
using osu.Game.Configuration;
|
||||
using osu.Game.IO;
|
||||
using osu.Game.Rulesets;
|
||||
using osu.Game.Scoring;
|
||||
using DatabasedKeyBinding = osu.Game.Input.Bindings.DatabasedKeyBinding;
|
||||
using LogLevel = Microsoft.Extensions.Logging.LogLevel;
|
||||
using osu.Game.Skinning;
|
||||
@ -27,6 +28,7 @@ namespace osu.Game.Database
|
||||
public DbSet<FileInfo> FileInfo { get; set; }
|
||||
public DbSet<RulesetInfo> RulesetInfo { get; set; }
|
||||
public DbSet<SkinInfo> SkinInfo { get; set; }
|
||||
public DbSet<ScoreInfo> ScoreInfo { get; set; }
|
||||
|
||||
private readonly string connectionString;
|
||||
|
||||
@ -105,6 +107,9 @@ namespace osu.Game.Database
|
||||
modelBuilder.Entity<BeatmapSetInfo>().HasIndex(b => b.DeletePending);
|
||||
modelBuilder.Entity<BeatmapSetInfo>().HasIndex(b => b.Hash).IsUnique();
|
||||
|
||||
modelBuilder.Entity<SkinInfo>().HasIndex(b => b.Hash).IsUnique();
|
||||
modelBuilder.Entity<SkinInfo>().HasIndex(b => b.DeletePending);
|
||||
|
||||
modelBuilder.Entity<DatabasedKeyBinding>().HasIndex(b => new { b.RulesetID, b.Variant });
|
||||
modelBuilder.Entity<DatabasedKeyBinding>().HasIndex(b => b.IntAction);
|
||||
|
||||
@ -117,6 +122,8 @@ namespace osu.Game.Database
|
||||
modelBuilder.Entity<RulesetInfo>().HasIndex(b => b.ShortName).IsUnique();
|
||||
|
||||
modelBuilder.Entity<BeatmapInfo>().HasOne(b => b.BaseDifficulty);
|
||||
|
||||
modelBuilder.Entity<ScoreInfo>().HasIndex(b => b.OnlineScoreID).IsUnique();
|
||||
}
|
||||
|
||||
private class OsuDbLoggerFactory : ILoggerFactory
|
||||
|
@ -8,13 +8,13 @@ using System.Linq;
|
||||
namespace osu.Game.IO.Archives
|
||||
{
|
||||
/// <summary>
|
||||
/// Reads an extracted legacy beatmap from disk.
|
||||
/// Reads an archive from a directory on disk.
|
||||
/// </summary>
|
||||
public class LegacyFilesystemReader : ArchiveReader
|
||||
public class LegacyDirectoryArchiveReader : ArchiveReader
|
||||
{
|
||||
private readonly string path;
|
||||
|
||||
public LegacyFilesystemReader(string path)
|
||||
public LegacyDirectoryArchiveReader(string path)
|
||||
: base(Path.GetFileName(path))
|
||||
{
|
||||
// re-get full path to standardise with Directory.GetFiles return values below.
|
34
osu.Game/IO/Archives/LegacyFileArchiveReader.cs
Normal file
34
osu.Game/IO/Archives/LegacyFileArchiveReader.cs
Normal file
@ -0,0 +1,34 @@
|
||||
// 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.Collections.Generic;
|
||||
using System.IO;
|
||||
|
||||
namespace osu.Game.IO.Archives
|
||||
{
|
||||
/// <summary>
|
||||
/// Reads a file on disk as an archive.
|
||||
/// Note: In this case, the file is not an extractable archive, use <see cref="ZipArchiveReader"/> instead.
|
||||
/// </summary>
|
||||
public class LegacyFileArchiveReader : ArchiveReader
|
||||
{
|
||||
private readonly string path;
|
||||
|
||||
public LegacyFileArchiveReader(string path)
|
||||
: base(Path.GetFileName(path))
|
||||
{
|
||||
// re-get full path to standardise
|
||||
this.path = Path.GetFullPath(path);
|
||||
}
|
||||
|
||||
public override Stream GetStream(string name) => File.OpenRead(path);
|
||||
|
||||
public override void Dispose()
|
||||
{
|
||||
}
|
||||
|
||||
public override IEnumerable<string> Filenames => new[] { Name };
|
||||
|
||||
public override Stream GetUnderlyingStream() => null;
|
||||
}
|
||||
}
|
@ -1,14 +1,13 @@
|
||||
// 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.ComponentModel.DataAnnotations.Schema;
|
||||
using System.IO;
|
||||
using osu.Game.Database;
|
||||
|
||||
namespace osu.Game.IO
|
||||
{
|
||||
public class FileInfo
|
||||
public class FileInfo : IHasPrimaryKey
|
||||
{
|
||||
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||
public int ID { get; set; }
|
||||
|
||||
public string Hash { get; set; }
|
||||
|
@ -1,46 +0,0 @@
|
||||
// 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.Diagnostics;
|
||||
using System.Threading.Tasks;
|
||||
using osu.Framework.Platform;
|
||||
using osu.Game.Rulesets.Scoring;
|
||||
|
||||
namespace osu.Game.IPC
|
||||
{
|
||||
public class ScoreIPCChannel : IpcChannel<ScoreImportMessage>
|
||||
{
|
||||
private readonly ScoreStore scores;
|
||||
|
||||
public ScoreIPCChannel(IIpcHost host, ScoreStore scores = null)
|
||||
: base(host)
|
||||
{
|
||||
this.scores = scores;
|
||||
MessageReceived += msg =>
|
||||
{
|
||||
Debug.Assert(scores != null);
|
||||
ImportAsync(msg.Path).ContinueWith(t =>
|
||||
{
|
||||
if (t.Exception != null) throw t.Exception;
|
||||
}, TaskContinuationOptions.OnlyOnFaulted);
|
||||
};
|
||||
}
|
||||
|
||||
public async Task ImportAsync(string path)
|
||||
{
|
||||
if (scores == null)
|
||||
{
|
||||
//we want to contact a remote osu! to handle the import.
|
||||
await SendMessageAsync(new ScoreImportMessage { Path = path });
|
||||
return;
|
||||
}
|
||||
|
||||
scores.ReadReplayFile(path);
|
||||
}
|
||||
}
|
||||
|
||||
public class ScoreImportMessage
|
||||
{
|
||||
public string Path;
|
||||
}
|
||||
}
|
@ -10,7 +10,6 @@ namespace osu.Game.Input.Bindings
|
||||
[Table("KeyBinding")]
|
||||
public class DatabasedKeyBinding : KeyBinding, IHasPrimaryKey
|
||||
{
|
||||
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||
public int ID { get; set; }
|
||||
|
||||
public int? RulesetID { get; set; }
|
||||
|
@ -43,6 +43,7 @@ namespace osu.Game.Input.Bindings
|
||||
|
||||
new KeyBinding(InputKey.Space, GlobalAction.Select),
|
||||
new KeyBinding(InputKey.Enter, GlobalAction.Select),
|
||||
new KeyBinding(InputKey.KeypadEnter, GlobalAction.Select),
|
||||
};
|
||||
|
||||
public IEnumerable<KeyBinding> InGameKeyBindings => new[]
|
||||
|
387
osu.Game/Migrations/20181128100659_AddSkinInfoHash.Designer.cs
generated
Normal file
387
osu.Game/Migrations/20181128100659_AddSkinInfoHash.Designer.cs
generated
Normal file
@ -0,0 +1,387 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
using osu.Game.Database;
|
||||
|
||||
namespace osu.Game.Migrations
|
||||
{
|
||||
[DbContext(typeof(OsuDbContext))]
|
||||
[Migration("20181128100659_AddSkinInfoHash")]
|
||||
partial class AddSkinInfoHash
|
||||
{
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "2.1.4-rtm-31024");
|
||||
|
||||
modelBuilder.Entity("osu.Game.Beatmaps.BeatmapDifficulty", b =>
|
||||
{
|
||||
b.Property<int>("ID")
|
||||
.ValueGeneratedOnAdd();
|
||||
|
||||
b.Property<float>("ApproachRate");
|
||||
|
||||
b.Property<float>("CircleSize");
|
||||
|
||||
b.Property<float>("DrainRate");
|
||||
|
||||
b.Property<float>("OverallDifficulty");
|
||||
|
||||
b.Property<double>("SliderMultiplier");
|
||||
|
||||
b.Property<double>("SliderTickRate");
|
||||
|
||||
b.HasKey("ID");
|
||||
|
||||
b.ToTable("BeatmapDifficulty");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("osu.Game.Beatmaps.BeatmapInfo", b =>
|
||||
{
|
||||
b.Property<int>("ID")
|
||||
.ValueGeneratedOnAdd();
|
||||
|
||||
b.Property<int>("AudioLeadIn");
|
||||
|
||||
b.Property<int>("BaseDifficultyID");
|
||||
|
||||
b.Property<int>("BeatDivisor");
|
||||
|
||||
b.Property<int>("BeatmapSetInfoID");
|
||||
|
||||
b.Property<bool>("Countdown");
|
||||
|
||||
b.Property<double>("DistanceSpacing");
|
||||
|
||||
b.Property<int>("GridSize");
|
||||
|
||||
b.Property<string>("Hash");
|
||||
|
||||
b.Property<bool>("Hidden");
|
||||
|
||||
b.Property<bool>("LetterboxInBreaks");
|
||||
|
||||
b.Property<string>("MD5Hash");
|
||||
|
||||
b.Property<int?>("MetadataID");
|
||||
|
||||
b.Property<int?>("OnlineBeatmapID");
|
||||
|
||||
b.Property<string>("Path");
|
||||
|
||||
b.Property<int>("RulesetID");
|
||||
|
||||
b.Property<bool>("SpecialStyle");
|
||||
|
||||
b.Property<float>("StackLeniency");
|
||||
|
||||
b.Property<double>("StarDifficulty");
|
||||
|
||||
b.Property<int>("Status");
|
||||
|
||||
b.Property<string>("StoredBookmarks");
|
||||
|
||||
b.Property<double>("TimelineZoom");
|
||||
|
||||
b.Property<string>("Version");
|
||||
|
||||
b.Property<bool>("WidescreenStoryboard");
|
||||
|
||||
b.HasKey("ID");
|
||||
|
||||
b.HasIndex("BaseDifficultyID");
|
||||
|
||||
b.HasIndex("BeatmapSetInfoID");
|
||||
|
||||
b.HasIndex("Hash");
|
||||
|
||||
b.HasIndex("MD5Hash");
|
||||
|
||||
b.HasIndex("MetadataID");
|
||||
|
||||
b.HasIndex("OnlineBeatmapID")
|
||||
.IsUnique();
|
||||
|
||||
b.HasIndex("RulesetID");
|
||||
|
||||
b.ToTable("BeatmapInfo");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("osu.Game.Beatmaps.BeatmapMetadata", b =>
|
||||
{
|
||||
b.Property<int>("ID")
|
||||
.ValueGeneratedOnAdd();
|
||||
|
||||
b.Property<string>("Artist");
|
||||
|
||||
b.Property<string>("ArtistUnicode");
|
||||
|
||||
b.Property<string>("AudioFile");
|
||||
|
||||
b.Property<string>("AuthorString")
|
||||
.HasColumnName("Author");
|
||||
|
||||
b.Property<string>("BackgroundFile");
|
||||
|
||||
b.Property<int>("PreviewTime");
|
||||
|
||||
b.Property<string>("Source");
|
||||
|
||||
b.Property<string>("Tags");
|
||||
|
||||
b.Property<string>("Title");
|
||||
|
||||
b.Property<string>("TitleUnicode");
|
||||
|
||||
b.HasKey("ID");
|
||||
|
||||
b.ToTable("BeatmapMetadata");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("osu.Game.Beatmaps.BeatmapSetFileInfo", b =>
|
||||
{
|
||||
b.Property<int>("ID")
|
||||
.ValueGeneratedOnAdd();
|
||||
|
||||
b.Property<int>("BeatmapSetInfoID");
|
||||
|
||||
b.Property<int>("FileInfoID");
|
||||
|
||||
b.Property<string>("Filename")
|
||||
.IsRequired();
|
||||
|
||||
b.HasKey("ID");
|
||||
|
||||
b.HasIndex("BeatmapSetInfoID");
|
||||
|
||||
b.HasIndex("FileInfoID");
|
||||
|
||||
b.ToTable("BeatmapSetFileInfo");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("osu.Game.Beatmaps.BeatmapSetInfo", b =>
|
||||
{
|
||||
b.Property<int>("ID")
|
||||
.ValueGeneratedOnAdd();
|
||||
|
||||
b.Property<bool>("DeletePending");
|
||||
|
||||
b.Property<string>("Hash");
|
||||
|
||||
b.Property<int?>("MetadataID");
|
||||
|
||||
b.Property<int?>("OnlineBeatmapSetID");
|
||||
|
||||
b.Property<bool>("Protected");
|
||||
|
||||
b.Property<int>("Status");
|
||||
|
||||
b.HasKey("ID");
|
||||
|
||||
b.HasIndex("DeletePending");
|
||||
|
||||
b.HasIndex("Hash")
|
||||
.IsUnique();
|
||||
|
||||
b.HasIndex("MetadataID");
|
||||
|
||||
b.HasIndex("OnlineBeatmapSetID")
|
||||
.IsUnique();
|
||||
|
||||
b.ToTable("BeatmapSetInfo");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("osu.Game.Configuration.DatabasedSetting", b =>
|
||||
{
|
||||
b.Property<int>("ID")
|
||||
.ValueGeneratedOnAdd();
|
||||
|
||||
b.Property<int>("IntKey")
|
||||
.HasColumnName("Key");
|
||||
|
||||
b.Property<int?>("RulesetID");
|
||||
|
||||
b.Property<string>("StringValue")
|
||||
.HasColumnName("Value");
|
||||
|
||||
b.Property<int?>("Variant");
|
||||
|
||||
b.HasKey("ID");
|
||||
|
||||
b.HasIndex("RulesetID", "Variant");
|
||||
|
||||
b.ToTable("Settings");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("osu.Game.Input.Bindings.DatabasedKeyBinding", b =>
|
||||
{
|
||||
b.Property<int>("ID")
|
||||
.ValueGeneratedOnAdd();
|
||||
|
||||
b.Property<int>("IntAction")
|
||||
.HasColumnName("Action");
|
||||
|
||||
b.Property<string>("KeysString")
|
||||
.HasColumnName("Keys");
|
||||
|
||||
b.Property<int?>("RulesetID");
|
||||
|
||||
b.Property<int?>("Variant");
|
||||
|
||||
b.HasKey("ID");
|
||||
|
||||
b.HasIndex("IntAction");
|
||||
|
||||
b.HasIndex("RulesetID", "Variant");
|
||||
|
||||
b.ToTable("KeyBinding");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("osu.Game.IO.FileInfo", b =>
|
||||
{
|
||||
b.Property<int>("ID")
|
||||
.ValueGeneratedOnAdd();
|
||||
|
||||
b.Property<string>("Hash");
|
||||
|
||||
b.Property<int>("ReferenceCount");
|
||||
|
||||
b.HasKey("ID");
|
||||
|
||||
b.HasIndex("Hash")
|
||||
.IsUnique();
|
||||
|
||||
b.HasIndex("ReferenceCount");
|
||||
|
||||
b.ToTable("FileInfo");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("osu.Game.Rulesets.RulesetInfo", b =>
|
||||
{
|
||||
b.Property<int?>("ID")
|
||||
.ValueGeneratedOnAdd();
|
||||
|
||||
b.Property<bool>("Available");
|
||||
|
||||
b.Property<string>("InstantiationInfo");
|
||||
|
||||
b.Property<string>("Name");
|
||||
|
||||
b.Property<string>("ShortName");
|
||||
|
||||
b.HasKey("ID");
|
||||
|
||||
b.HasIndex("Available");
|
||||
|
||||
b.HasIndex("ShortName")
|
||||
.IsUnique();
|
||||
|
||||
b.ToTable("RulesetInfo");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("osu.Game.Skinning.SkinFileInfo", b =>
|
||||
{
|
||||
b.Property<int>("ID")
|
||||
.ValueGeneratedOnAdd();
|
||||
|
||||
b.Property<int>("FileInfoID");
|
||||
|
||||
b.Property<string>("Filename")
|
||||
.IsRequired();
|
||||
|
||||
b.Property<int>("SkinInfoID");
|
||||
|
||||
b.HasKey("ID");
|
||||
|
||||
b.HasIndex("FileInfoID");
|
||||
|
||||
b.HasIndex("SkinInfoID");
|
||||
|
||||
b.ToTable("SkinFileInfo");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("osu.Game.Skinning.SkinInfo", b =>
|
||||
{
|
||||
b.Property<int>("ID")
|
||||
.ValueGeneratedOnAdd();
|
||||
|
||||
b.Property<string>("Creator");
|
||||
|
||||
b.Property<bool>("DeletePending");
|
||||
|
||||
b.Property<string>("Hash");
|
||||
|
||||
b.Property<string>("Name");
|
||||
|
||||
b.HasKey("ID");
|
||||
|
||||
b.HasIndex("DeletePending");
|
||||
|
||||
b.HasIndex("Hash")
|
||||
.IsUnique();
|
||||
|
||||
b.ToTable("SkinInfo");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("osu.Game.Beatmaps.BeatmapInfo", b =>
|
||||
{
|
||||
b.HasOne("osu.Game.Beatmaps.BeatmapDifficulty", "BaseDifficulty")
|
||||
.WithMany()
|
||||
.HasForeignKey("BaseDifficultyID")
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
|
||||
b.HasOne("osu.Game.Beatmaps.BeatmapSetInfo", "BeatmapSet")
|
||||
.WithMany("Beatmaps")
|
||||
.HasForeignKey("BeatmapSetInfoID")
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
|
||||
b.HasOne("osu.Game.Beatmaps.BeatmapMetadata", "Metadata")
|
||||
.WithMany("Beatmaps")
|
||||
.HasForeignKey("MetadataID");
|
||||
|
||||
b.HasOne("osu.Game.Rulesets.RulesetInfo", "Ruleset")
|
||||
.WithMany()
|
||||
.HasForeignKey("RulesetID")
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("osu.Game.Beatmaps.BeatmapSetFileInfo", b =>
|
||||
{
|
||||
b.HasOne("osu.Game.Beatmaps.BeatmapSetInfo")
|
||||
.WithMany("Files")
|
||||
.HasForeignKey("BeatmapSetInfoID")
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
|
||||
b.HasOne("osu.Game.IO.FileInfo", "FileInfo")
|
||||
.WithMany()
|
||||
.HasForeignKey("FileInfoID")
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("osu.Game.Beatmaps.BeatmapSetInfo", b =>
|
||||
{
|
||||
b.HasOne("osu.Game.Beatmaps.BeatmapMetadata", "Metadata")
|
||||
.WithMany("BeatmapSets")
|
||||
.HasForeignKey("MetadataID");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("osu.Game.Skinning.SkinFileInfo", b =>
|
||||
{
|
||||
b.HasOne("osu.Game.IO.FileInfo", "FileInfo")
|
||||
.WithMany()
|
||||
.HasForeignKey("FileInfoID")
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
|
||||
b.HasOne("osu.Game.Skinning.SkinInfo")
|
||||
.WithMany("Files")
|
||||
.HasForeignKey("SkinInfoID")
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
41
osu.Game/Migrations/20181128100659_AddSkinInfoHash.cs
Normal file
41
osu.Game/Migrations/20181128100659_AddSkinInfoHash.cs
Normal file
@ -0,0 +1,41 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
namespace osu.Game.Migrations
|
||||
{
|
||||
public partial class AddSkinInfoHash : Migration
|
||||
{
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AddColumn<string>(
|
||||
name: "Hash",
|
||||
table: "SkinInfo",
|
||||
nullable: true);
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_SkinInfo_DeletePending",
|
||||
table: "SkinInfo",
|
||||
column: "DeletePending");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_SkinInfo_Hash",
|
||||
table: "SkinInfo",
|
||||
column: "Hash",
|
||||
unique: true);
|
||||
}
|
||||
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropIndex(
|
||||
name: "IX_SkinInfo_DeletePending",
|
||||
table: "SkinInfo");
|
||||
|
||||
migrationBuilder.DropIndex(
|
||||
name: "IX_SkinInfo_Hash",
|
||||
table: "SkinInfo");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "Hash",
|
||||
table: "SkinInfo");
|
||||
}
|
||||
}
|
||||
}
|
485
osu.Game/Migrations/20181130084152_AddScoreInfoTables.Designer.cs
generated
Normal file
485
osu.Game/Migrations/20181130084152_AddScoreInfoTables.Designer.cs
generated
Normal file
@ -0,0 +1,485 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
using osu.Game.Database;
|
||||
|
||||
namespace osu.Game.Migrations
|
||||
{
|
||||
[DbContext(typeof(OsuDbContext))]
|
||||
[Migration("20181130084152_AddScoreInfoTables")]
|
||||
partial class AddScoreInfoTables
|
||||
{
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "2.1.4-rtm-31024");
|
||||
|
||||
modelBuilder.Entity("osu.Game.Beatmaps.BeatmapDifficulty", b =>
|
||||
{
|
||||
b.Property<int>("ID")
|
||||
.ValueGeneratedOnAdd();
|
||||
|
||||
b.Property<float>("ApproachRate");
|
||||
|
||||
b.Property<float>("CircleSize");
|
||||
|
||||
b.Property<float>("DrainRate");
|
||||
|
||||
b.Property<float>("OverallDifficulty");
|
||||
|
||||
b.Property<double>("SliderMultiplier");
|
||||
|
||||
b.Property<double>("SliderTickRate");
|
||||
|
||||
b.HasKey("ID");
|
||||
|
||||
b.ToTable("BeatmapDifficulty");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("osu.Game.Beatmaps.BeatmapInfo", b =>
|
||||
{
|
||||
b.Property<int>("ID")
|
||||
.ValueGeneratedOnAdd();
|
||||
|
||||
b.Property<int>("AudioLeadIn");
|
||||
|
||||
b.Property<int>("BaseDifficultyID");
|
||||
|
||||
b.Property<int>("BeatDivisor");
|
||||
|
||||
b.Property<int>("BeatmapSetInfoID");
|
||||
|
||||
b.Property<bool>("Countdown");
|
||||
|
||||
b.Property<double>("DistanceSpacing");
|
||||
|
||||
b.Property<int>("GridSize");
|
||||
|
||||
b.Property<string>("Hash");
|
||||
|
||||
b.Property<bool>("Hidden");
|
||||
|
||||
b.Property<bool>("LetterboxInBreaks");
|
||||
|
||||
b.Property<string>("MD5Hash");
|
||||
|
||||
b.Property<int?>("MetadataID");
|
||||
|
||||
b.Property<int?>("OnlineBeatmapID");
|
||||
|
||||
b.Property<string>("Path");
|
||||
|
||||
b.Property<int>("RulesetID");
|
||||
|
||||
b.Property<bool>("SpecialStyle");
|
||||
|
||||
b.Property<float>("StackLeniency");
|
||||
|
||||
b.Property<double>("StarDifficulty");
|
||||
|
||||
b.Property<int>("Status");
|
||||
|
||||
b.Property<string>("StoredBookmarks");
|
||||
|
||||
b.Property<double>("TimelineZoom");
|
||||
|
||||
b.Property<string>("Version");
|
||||
|
||||
b.Property<bool>("WidescreenStoryboard");
|
||||
|
||||
b.HasKey("ID");
|
||||
|
||||
b.HasIndex("BaseDifficultyID");
|
||||
|
||||
b.HasIndex("BeatmapSetInfoID");
|
||||
|
||||
b.HasIndex("Hash");
|
||||
|
||||
b.HasIndex("MD5Hash");
|
||||
|
||||
b.HasIndex("MetadataID");
|
||||
|
||||
b.HasIndex("OnlineBeatmapID")
|
||||
.IsUnique();
|
||||
|
||||
b.HasIndex("RulesetID");
|
||||
|
||||
b.ToTable("BeatmapInfo");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("osu.Game.Beatmaps.BeatmapMetadata", b =>
|
||||
{
|
||||
b.Property<int>("ID")
|
||||
.ValueGeneratedOnAdd();
|
||||
|
||||
b.Property<string>("Artist");
|
||||
|
||||
b.Property<string>("ArtistUnicode");
|
||||
|
||||
b.Property<string>("AudioFile");
|
||||
|
||||
b.Property<string>("AuthorString")
|
||||
.HasColumnName("Author");
|
||||
|
||||
b.Property<string>("BackgroundFile");
|
||||
|
||||
b.Property<int>("PreviewTime");
|
||||
|
||||
b.Property<string>("Source");
|
||||
|
||||
b.Property<string>("Tags");
|
||||
|
||||
b.Property<string>("Title");
|
||||
|
||||
b.Property<string>("TitleUnicode");
|
||||
|
||||
b.HasKey("ID");
|
||||
|
||||
b.ToTable("BeatmapMetadata");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("osu.Game.Beatmaps.BeatmapSetFileInfo", b =>
|
||||
{
|
||||
b.Property<int>("ID")
|
||||
.ValueGeneratedOnAdd();
|
||||
|
||||
b.Property<int>("BeatmapSetInfoID");
|
||||
|
||||
b.Property<int>("FileInfoID");
|
||||
|
||||
b.Property<string>("Filename")
|
||||
.IsRequired();
|
||||
|
||||
b.HasKey("ID");
|
||||
|
||||
b.HasIndex("BeatmapSetInfoID");
|
||||
|
||||
b.HasIndex("FileInfoID");
|
||||
|
||||
b.ToTable("BeatmapSetFileInfo");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("osu.Game.Beatmaps.BeatmapSetInfo", b =>
|
||||
{
|
||||
b.Property<int>("ID")
|
||||
.ValueGeneratedOnAdd();
|
||||
|
||||
b.Property<bool>("DeletePending");
|
||||
|
||||
b.Property<string>("Hash");
|
||||
|
||||
b.Property<int?>("MetadataID");
|
||||
|
||||
b.Property<int?>("OnlineBeatmapSetID");
|
||||
|
||||
b.Property<bool>("Protected");
|
||||
|
||||
b.Property<int>("Status");
|
||||
|
||||
b.HasKey("ID");
|
||||
|
||||
b.HasIndex("DeletePending");
|
||||
|
||||
b.HasIndex("Hash")
|
||||
.IsUnique();
|
||||
|
||||
b.HasIndex("MetadataID");
|
||||
|
||||
b.HasIndex("OnlineBeatmapSetID")
|
||||
.IsUnique();
|
||||
|
||||
b.ToTable("BeatmapSetInfo");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("osu.Game.Configuration.DatabasedSetting", b =>
|
||||
{
|
||||
b.Property<int>("ID")
|
||||
.ValueGeneratedOnAdd();
|
||||
|
||||
b.Property<int>("IntKey")
|
||||
.HasColumnName("Key");
|
||||
|
||||
b.Property<int?>("RulesetID");
|
||||
|
||||
b.Property<string>("StringValue")
|
||||
.HasColumnName("Value");
|
||||
|
||||
b.Property<int?>("Variant");
|
||||
|
||||
b.HasKey("ID");
|
||||
|
||||
b.HasIndex("RulesetID", "Variant");
|
||||
|
||||
b.ToTable("Settings");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("osu.Game.Input.Bindings.DatabasedKeyBinding", b =>
|
||||
{
|
||||
b.Property<int>("ID")
|
||||
.ValueGeneratedOnAdd();
|
||||
|
||||
b.Property<int>("IntAction")
|
||||
.HasColumnName("Action");
|
||||
|
||||
b.Property<string>("KeysString")
|
||||
.HasColumnName("Keys");
|
||||
|
||||
b.Property<int?>("RulesetID");
|
||||
|
||||
b.Property<int?>("Variant");
|
||||
|
||||
b.HasKey("ID");
|
||||
|
||||
b.HasIndex("IntAction");
|
||||
|
||||
b.HasIndex("RulesetID", "Variant");
|
||||
|
||||
b.ToTable("KeyBinding");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("osu.Game.IO.FileInfo", b =>
|
||||
{
|
||||
b.Property<int>("ID")
|
||||
.ValueGeneratedOnAdd();
|
||||
|
||||
b.Property<string>("Hash");
|
||||
|
||||
b.Property<int>("ReferenceCount");
|
||||
|
||||
b.HasKey("ID");
|
||||
|
||||
b.HasIndex("Hash")
|
||||
.IsUnique();
|
||||
|
||||
b.HasIndex("ReferenceCount");
|
||||
|
||||
b.ToTable("FileInfo");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("osu.Game.Rulesets.RulesetInfo", b =>
|
||||
{
|
||||
b.Property<int?>("ID")
|
||||
.ValueGeneratedOnAdd();
|
||||
|
||||
b.Property<bool>("Available");
|
||||
|
||||
b.Property<string>("InstantiationInfo");
|
||||
|
||||
b.Property<string>("Name");
|
||||
|
||||
b.Property<string>("ShortName");
|
||||
|
||||
b.HasKey("ID");
|
||||
|
||||
b.HasIndex("Available");
|
||||
|
||||
b.HasIndex("ShortName")
|
||||
.IsUnique();
|
||||
|
||||
b.ToTable("RulesetInfo");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("osu.Game.Scoring.ScoreFileInfo", b =>
|
||||
{
|
||||
b.Property<int>("ID")
|
||||
.ValueGeneratedOnAdd();
|
||||
|
||||
b.Property<int>("FileInfoID");
|
||||
|
||||
b.Property<string>("Filename")
|
||||
.IsRequired();
|
||||
|
||||
b.Property<int?>("ScoreInfoID");
|
||||
|
||||
b.HasKey("ID");
|
||||
|
||||
b.HasIndex("FileInfoID");
|
||||
|
||||
b.HasIndex("ScoreInfoID");
|
||||
|
||||
b.ToTable("ScoreFileInfo");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("osu.Game.Scoring.ScoreInfo", b =>
|
||||
{
|
||||
b.Property<int>("ID")
|
||||
.ValueGeneratedOnAdd();
|
||||
|
||||
b.Property<double>("Accuracy");
|
||||
|
||||
b.Property<int>("BeatmapInfoID");
|
||||
|
||||
b.Property<int>("Combo");
|
||||
|
||||
b.Property<DateTimeOffset>("Date");
|
||||
|
||||
b.Property<bool>("DeletePending");
|
||||
|
||||
b.Property<string>("Hash");
|
||||
|
||||
b.Property<double>("Health");
|
||||
|
||||
b.Property<int>("MaxCombo");
|
||||
|
||||
b.Property<string>("ModsJson")
|
||||
.HasColumnName("Mods");
|
||||
|
||||
b.Property<long?>("OnlineScoreID");
|
||||
|
||||
b.Property<double?>("PP");
|
||||
|
||||
b.Property<int>("Rank");
|
||||
|
||||
b.Property<int>("RulesetID");
|
||||
|
||||
b.Property<string>("StatisticsJson")
|
||||
.HasColumnName("Statistics");
|
||||
|
||||
b.Property<double>("TotalScore");
|
||||
|
||||
b.Property<string>("UserString")
|
||||
.HasColumnName("User");
|
||||
|
||||
b.HasKey("ID");
|
||||
|
||||
b.HasIndex("BeatmapInfoID");
|
||||
|
||||
b.HasIndex("OnlineScoreID")
|
||||
.IsUnique();
|
||||
|
||||
b.HasIndex("RulesetID");
|
||||
|
||||
b.ToTable("ScoreInfo");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("osu.Game.Skinning.SkinFileInfo", b =>
|
||||
{
|
||||
b.Property<int>("ID")
|
||||
.ValueGeneratedOnAdd();
|
||||
|
||||
b.Property<int>("FileInfoID");
|
||||
|
||||
b.Property<string>("Filename")
|
||||
.IsRequired();
|
||||
|
||||
b.Property<int>("SkinInfoID");
|
||||
|
||||
b.HasKey("ID");
|
||||
|
||||
b.HasIndex("FileInfoID");
|
||||
|
||||
b.HasIndex("SkinInfoID");
|
||||
|
||||
b.ToTable("SkinFileInfo");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("osu.Game.Skinning.SkinInfo", b =>
|
||||
{
|
||||
b.Property<int>("ID")
|
||||
.ValueGeneratedOnAdd();
|
||||
|
||||
b.Property<string>("Creator");
|
||||
|
||||
b.Property<bool>("DeletePending");
|
||||
|
||||
b.Property<string>("Hash");
|
||||
|
||||
b.Property<string>("Name");
|
||||
|
||||
b.HasKey("ID");
|
||||
|
||||
b.HasIndex("DeletePending");
|
||||
|
||||
b.HasIndex("Hash")
|
||||
.IsUnique();
|
||||
|
||||
b.ToTable("SkinInfo");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("osu.Game.Beatmaps.BeatmapInfo", b =>
|
||||
{
|
||||
b.HasOne("osu.Game.Beatmaps.BeatmapDifficulty", "BaseDifficulty")
|
||||
.WithMany()
|
||||
.HasForeignKey("BaseDifficultyID")
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
|
||||
b.HasOne("osu.Game.Beatmaps.BeatmapSetInfo", "BeatmapSet")
|
||||
.WithMany("Beatmaps")
|
||||
.HasForeignKey("BeatmapSetInfoID")
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
|
||||
b.HasOne("osu.Game.Beatmaps.BeatmapMetadata", "Metadata")
|
||||
.WithMany("Beatmaps")
|
||||
.HasForeignKey("MetadataID");
|
||||
|
||||
b.HasOne("osu.Game.Rulesets.RulesetInfo", "Ruleset")
|
||||
.WithMany()
|
||||
.HasForeignKey("RulesetID")
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("osu.Game.Beatmaps.BeatmapSetFileInfo", b =>
|
||||
{
|
||||
b.HasOne("osu.Game.Beatmaps.BeatmapSetInfo")
|
||||
.WithMany("Files")
|
||||
.HasForeignKey("BeatmapSetInfoID")
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
|
||||
b.HasOne("osu.Game.IO.FileInfo", "FileInfo")
|
||||
.WithMany()
|
||||
.HasForeignKey("FileInfoID")
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("osu.Game.Beatmaps.BeatmapSetInfo", b =>
|
||||
{
|
||||
b.HasOne("osu.Game.Beatmaps.BeatmapMetadata", "Metadata")
|
||||
.WithMany("BeatmapSets")
|
||||
.HasForeignKey("MetadataID");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("osu.Game.Scoring.ScoreFileInfo", b =>
|
||||
{
|
||||
b.HasOne("osu.Game.IO.FileInfo", "FileInfo")
|
||||
.WithMany()
|
||||
.HasForeignKey("FileInfoID")
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
|
||||
b.HasOne("osu.Game.Scoring.ScoreInfo")
|
||||
.WithMany("Files")
|
||||
.HasForeignKey("ScoreInfoID");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("osu.Game.Scoring.ScoreInfo", b =>
|
||||
{
|
||||
b.HasOne("osu.Game.Beatmaps.BeatmapInfo", "Beatmap")
|
||||
.WithMany()
|
||||
.HasForeignKey("BeatmapInfoID")
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
|
||||
b.HasOne("osu.Game.Rulesets.RulesetInfo", "Ruleset")
|
||||
.WithMany()
|
||||
.HasForeignKey("RulesetID")
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("osu.Game.Skinning.SkinFileInfo", b =>
|
||||
{
|
||||
b.HasOne("osu.Game.IO.FileInfo", "FileInfo")
|
||||
.WithMany()
|
||||
.HasForeignKey("FileInfoID")
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
|
||||
b.HasOne("osu.Game.Skinning.SkinInfo")
|
||||
.WithMany("Files")
|
||||
.HasForeignKey("SkinInfoID")
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
113
osu.Game/Migrations/20181130084152_AddScoreInfoTables.cs
Normal file
113
osu.Game/Migrations/20181130084152_AddScoreInfoTables.cs
Normal file
@ -0,0 +1,113 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
namespace osu.Game.Migrations
|
||||
{
|
||||
public partial class AddScoreInfoTables : Migration
|
||||
{
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.CreateTable(
|
||||
name: "ScoreInfo",
|
||||
columns: table => new
|
||||
{
|
||||
ID = table.Column<int>(nullable: false)
|
||||
.Annotation("Sqlite:Autoincrement", true),
|
||||
Rank = table.Column<int>(nullable: false),
|
||||
TotalScore = table.Column<double>(nullable: false),
|
||||
Accuracy = table.Column<double>(nullable: false),
|
||||
Health = table.Column<double>(nullable: false),
|
||||
PP = table.Column<double>(nullable: true),
|
||||
MaxCombo = table.Column<int>(nullable: false),
|
||||
Combo = table.Column<int>(nullable: false),
|
||||
RulesetID = table.Column<int>(nullable: false),
|
||||
Mods = table.Column<string>(nullable: true),
|
||||
User = table.Column<string>(nullable: true),
|
||||
BeatmapInfoID = table.Column<int>(nullable: false),
|
||||
OnlineScoreID = table.Column<long>(nullable: true),
|
||||
Date = table.Column<DateTimeOffset>(nullable: false),
|
||||
Statistics = table.Column<string>(nullable: true),
|
||||
Hash = table.Column<string>(nullable: true),
|
||||
DeletePending = table.Column<bool>(nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_ScoreInfo", x => x.ID);
|
||||
table.ForeignKey(
|
||||
name: "FK_ScoreInfo_BeatmapInfo_BeatmapInfoID",
|
||||
column: x => x.BeatmapInfoID,
|
||||
principalTable: "BeatmapInfo",
|
||||
principalColumn: "ID",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "FK_ScoreInfo_RulesetInfo_RulesetID",
|
||||
column: x => x.RulesetID,
|
||||
principalTable: "RulesetInfo",
|
||||
principalColumn: "ID",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "ScoreFileInfo",
|
||||
columns: table => new
|
||||
{
|
||||
ID = table.Column<int>(nullable: false)
|
||||
.Annotation("Sqlite:Autoincrement", true),
|
||||
FileInfoID = table.Column<int>(nullable: false),
|
||||
Filename = table.Column<string>(nullable: false),
|
||||
ScoreInfoID = table.Column<int>(nullable: true)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_ScoreFileInfo", x => x.ID);
|
||||
table.ForeignKey(
|
||||
name: "FK_ScoreFileInfo_FileInfo_FileInfoID",
|
||||
column: x => x.FileInfoID,
|
||||
principalTable: "FileInfo",
|
||||
principalColumn: "ID",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "FK_ScoreFileInfo_ScoreInfo_ScoreInfoID",
|
||||
column: x => x.ScoreInfoID,
|
||||
principalTable: "ScoreInfo",
|
||||
principalColumn: "ID",
|
||||
onDelete: ReferentialAction.Restrict);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_ScoreFileInfo_FileInfoID",
|
||||
table: "ScoreFileInfo",
|
||||
column: "FileInfoID");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_ScoreFileInfo_ScoreInfoID",
|
||||
table: "ScoreFileInfo",
|
||||
column: "ScoreInfoID");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_ScoreInfo_BeatmapInfoID",
|
||||
table: "ScoreInfo",
|
||||
column: "BeatmapInfoID");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_ScoreInfo_OnlineScoreID",
|
||||
table: "ScoreInfo",
|
||||
column: "OnlineScoreID",
|
||||
unique: true);
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_ScoreInfo_RulesetID",
|
||||
table: "ScoreInfo",
|
||||
column: "RulesetID");
|
||||
}
|
||||
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropTable(
|
||||
name: "ScoreFileInfo");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "ScoreInfo");
|
||||
}
|
||||
}
|
||||
}
|
@ -14,7 +14,7 @@ namespace osu.Game.Migrations
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "2.1.3-rtm-32065");
|
||||
.HasAnnotation("ProductVersion", "2.1.4-rtm-31024");
|
||||
|
||||
modelBuilder.Entity("osu.Game.Beatmaps.BeatmapDifficulty", b =>
|
||||
{
|
||||
@ -281,6 +281,79 @@ namespace osu.Game.Migrations
|
||||
b.ToTable("RulesetInfo");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("osu.Game.Scoring.ScoreFileInfo", b =>
|
||||
{
|
||||
b.Property<int>("ID")
|
||||
.ValueGeneratedOnAdd();
|
||||
|
||||
b.Property<int>("FileInfoID");
|
||||
|
||||
b.Property<string>("Filename")
|
||||
.IsRequired();
|
||||
|
||||
b.Property<int?>("ScoreInfoID");
|
||||
|
||||
b.HasKey("ID");
|
||||
|
||||
b.HasIndex("FileInfoID");
|
||||
|
||||
b.HasIndex("ScoreInfoID");
|
||||
|
||||
b.ToTable("ScoreFileInfo");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("osu.Game.Scoring.ScoreInfo", b =>
|
||||
{
|
||||
b.Property<int>("ID")
|
||||
.ValueGeneratedOnAdd();
|
||||
|
||||
b.Property<double>("Accuracy");
|
||||
|
||||
b.Property<int>("BeatmapInfoID");
|
||||
|
||||
b.Property<int>("Combo");
|
||||
|
||||
b.Property<DateTimeOffset>("Date");
|
||||
|
||||
b.Property<bool>("DeletePending");
|
||||
|
||||
b.Property<string>("Hash");
|
||||
|
||||
b.Property<double>("Health");
|
||||
|
||||
b.Property<int>("MaxCombo");
|
||||
|
||||
b.Property<string>("ModsJson")
|
||||
.HasColumnName("Mods");
|
||||
|
||||
b.Property<long?>("OnlineScoreID");
|
||||
|
||||
b.Property<double?>("PP");
|
||||
|
||||
b.Property<int>("Rank");
|
||||
|
||||
b.Property<int>("RulesetID");
|
||||
|
||||
b.Property<string>("StatisticsJson")
|
||||
.HasColumnName("Statistics");
|
||||
|
||||
b.Property<double>("TotalScore");
|
||||
|
||||
b.Property<string>("UserString")
|
||||
.HasColumnName("User");
|
||||
|
||||
b.HasKey("ID");
|
||||
|
||||
b.HasIndex("BeatmapInfoID");
|
||||
|
||||
b.HasIndex("OnlineScoreID")
|
||||
.IsUnique();
|
||||
|
||||
b.HasIndex("RulesetID");
|
||||
|
||||
b.ToTable("ScoreInfo");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("osu.Game.Skinning.SkinFileInfo", b =>
|
||||
{
|
||||
b.Property<int>("ID")
|
||||
@ -311,10 +384,17 @@ namespace osu.Game.Migrations
|
||||
|
||||
b.Property<bool>("DeletePending");
|
||||
|
||||
b.Property<string>("Hash");
|
||||
|
||||
b.Property<string>("Name");
|
||||
|
||||
b.HasKey("ID");
|
||||
|
||||
b.HasIndex("DeletePending");
|
||||
|
||||
b.HasIndex("Hash")
|
||||
.IsUnique();
|
||||
|
||||
b.ToTable("SkinInfo");
|
||||
});
|
||||
|
||||
@ -360,6 +440,31 @@ namespace osu.Game.Migrations
|
||||
.HasForeignKey("MetadataID");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("osu.Game.Scoring.ScoreFileInfo", b =>
|
||||
{
|
||||
b.HasOne("osu.Game.IO.FileInfo", "FileInfo")
|
||||
.WithMany()
|
||||
.HasForeignKey("FileInfoID")
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
|
||||
b.HasOne("osu.Game.Scoring.ScoreInfo")
|
||||
.WithMany("Files")
|
||||
.HasForeignKey("ScoreInfoID");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("osu.Game.Scoring.ScoreInfo", b =>
|
||||
{
|
||||
b.HasOne("osu.Game.Beatmaps.BeatmapInfo", "Beatmap")
|
||||
.WithMany()
|
||||
.HasForeignKey("BeatmapInfoID")
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
|
||||
b.HasOne("osu.Game.Rulesets.RulesetInfo", "Ruleset")
|
||||
.WithMany()
|
||||
.HasForeignKey("RulesetID")
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("osu.Game.Skinning.SkinFileInfo", b =>
|
||||
{
|
||||
b.HasOne("osu.Game.IO.FileInfo", "FileInfo")
|
||||
|
@ -33,8 +33,8 @@ namespace osu.Game.Online.API.Requests
|
||||
|
||||
private void onSuccess(APIScores r)
|
||||
{
|
||||
foreach (APIScore score in r.Scores)
|
||||
score.ApplyBeatmap(beatmap);
|
||||
foreach (APIScoreInfo score in r.Scores)
|
||||
score.Beatmap = beatmap;
|
||||
}
|
||||
|
||||
protected override WebRequest CreateWebRequest()
|
||||
|
@ -6,7 +6,7 @@ using osu.Game.Online.API.Requests.Responses;
|
||||
|
||||
namespace osu.Game.Online.API.Requests
|
||||
{
|
||||
public class GetUserScoresRequest : APIRequest<List<APIScore>>
|
||||
public class GetUserScoresRequest : APIRequest<List<APIScoreInfo>>
|
||||
{
|
||||
private readonly long userId;
|
||||
private readonly ScoreType type;
|
||||
|
@ -4,7 +4,7 @@
|
||||
using System;
|
||||
using Humanizer;
|
||||
using Newtonsoft.Json;
|
||||
using osu.Game.Rulesets.Scoring;
|
||||
using osu.Game.Scoring;
|
||||
|
||||
namespace osu.Game.Online.API.Requests.Responses
|
||||
{
|
||||
|
@ -7,13 +7,13 @@ using System.Linq;
|
||||
using Newtonsoft.Json;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Rulesets;
|
||||
using osu.Game.Rulesets.Replays;
|
||||
using osu.Game.Rulesets.Scoring;
|
||||
using osu.Game.Scoring;
|
||||
using osu.Game.Users;
|
||||
|
||||
namespace osu.Game.Online.API.Requests.Responses
|
||||
{
|
||||
public class APIScore : Score
|
||||
public class APIScoreInfo : ScoreInfo
|
||||
{
|
||||
[JsonProperty(@"score")]
|
||||
private double totalScore
|
||||
@ -33,15 +33,6 @@ namespace osu.Game.Online.API.Requests.Responses
|
||||
set => User = value;
|
||||
}
|
||||
|
||||
[JsonProperty(@"replay_data")]
|
||||
private Replay replay
|
||||
{
|
||||
set => Replay = value;
|
||||
}
|
||||
|
||||
[JsonProperty(@"mode_int")]
|
||||
public int OnlineRulesetID { get; set; }
|
||||
|
||||
[JsonProperty(@"score_id")]
|
||||
private long onlineScoreID
|
||||
{
|
||||
@ -104,21 +95,36 @@ namespace osu.Game.Online.API.Requests.Responses
|
||||
}
|
||||
}
|
||||
|
||||
[JsonProperty(@"mode_int")]
|
||||
public int OnlineRulesetID { get; set; }
|
||||
|
||||
[JsonProperty(@"mods")]
|
||||
private string[] modStrings { get; set; }
|
||||
|
||||
public void ApplyBeatmap(BeatmapInfo beatmap)
|
||||
public override BeatmapInfo Beatmap
|
||||
{
|
||||
Beatmap = beatmap;
|
||||
ApplyRuleset(beatmap.Ruleset);
|
||||
get => base.Beatmap;
|
||||
set
|
||||
{
|
||||
base.Beatmap = value;
|
||||
if (Beatmap.Ruleset != null)
|
||||
Ruleset = value.Ruleset;
|
||||
}
|
||||
}
|
||||
|
||||
public void ApplyRuleset(RulesetInfo ruleset)
|
||||
public override RulesetInfo Ruleset
|
||||
{
|
||||
Ruleset = ruleset;
|
||||
get => base.Ruleset;
|
||||
set
|
||||
{
|
||||
base.Ruleset = value;
|
||||
|
||||
// Evaluate the mod string
|
||||
Mods = Ruleset.CreateInstance().GetAllMods().Where(mod => modStrings.Contains(mod.ShortenedName)).ToArray();
|
||||
if (modStrings != null)
|
||||
{
|
||||
// Evaluate the mod string
|
||||
Mods = Ruleset.CreateInstance().GetAllMods().Where(mod => modStrings.Contains(mod.Acronym)).ToArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user