mirror of
https://github.com/ppy/osu.git
synced 2025-03-23 08:27:23 +08:00
Merge branch 'master' into leaderboards
This commit is contained in:
commit
4aea06be22
@ -1 +1 @@
|
||||
Subproject commit 036b124eb2387dde29af56e06391c42063ec85e2
|
||||
Subproject commit db310bfc10cd1c9ed12c9e19cdc0edfa53117353
|
@ -1 +1 @@
|
||||
Subproject commit 4f9ed4e703777ede98737c7e2af31efa4694c395
|
||||
Subproject commit f85c594c182db2b01233e29ca52639b7baa00402
|
@ -48,7 +48,7 @@ namespace osu.Desktop.VisualTests.Tests
|
||||
HitObjects = objects,
|
||||
BeatmapInfo = new BeatmapInfo
|
||||
{
|
||||
BaseDifficulty = new BaseDifficulty(),
|
||||
Difficulty = new BeatmapDifficulty(),
|
||||
Metadata = new BeatmapMetadata
|
||||
{
|
||||
Artist = @"Unknown",
|
||||
|
@ -8,6 +8,7 @@ using osu.Framework.MathUtils;
|
||||
using osu.Game.Database;
|
||||
using osu.Game.Modes;
|
||||
using osu.Game.Screens.Select;
|
||||
using osu.Game.Screens.Select.Filter;
|
||||
|
||||
namespace osu.Desktop.VisualTests.Tests
|
||||
{
|
||||
@ -39,10 +40,10 @@ namespace osu.Desktop.VisualTests.Tests
|
||||
|
||||
Add(songSelect = new PlaySongSelect());
|
||||
|
||||
AddButton(@"Sort by Artist", delegate { songSelect.Filter.Sort = FilterControl.SortMode.Artist; });
|
||||
AddButton(@"Sort by Title", delegate { songSelect.Filter.Sort = FilterControl.SortMode.Title; });
|
||||
AddButton(@"Sort by Author", delegate { songSelect.Filter.Sort = FilterControl.SortMode.Author; });
|
||||
AddButton(@"Sort by Difficulty", delegate { songSelect.Filter.Sort = FilterControl.SortMode.Difficulty; });
|
||||
AddButton(@"Sort by Artist", delegate { songSelect.FilterControl.Sort = SortMode.Artist; });
|
||||
AddButton(@"Sort by Title", delegate { songSelect.FilterControl.Sort = SortMode.Title; });
|
||||
AddButton(@"Sort by Author", delegate { songSelect.FilterControl.Sort = SortMode.Author; });
|
||||
AddButton(@"Sort by Difficulty", delegate { songSelect.FilterControl.Sort = SortMode.Difficulty; });
|
||||
}
|
||||
|
||||
protected override void Dispose(bool isDisposing)
|
||||
@ -79,7 +80,7 @@ namespace osu.Desktop.VisualTests.Tests
|
||||
Mode = PlayMode.Osu,
|
||||
Path = "normal.osu",
|
||||
Version = "Normal",
|
||||
BaseDifficulty = new BaseDifficulty
|
||||
Difficulty = new BeatmapDifficulty
|
||||
{
|
||||
OverallDifficulty = 3.5f,
|
||||
}
|
||||
@ -90,7 +91,7 @@ namespace osu.Desktop.VisualTests.Tests
|
||||
Mode = PlayMode.Osu,
|
||||
Path = "hard.osu",
|
||||
Version = "Hard",
|
||||
BaseDifficulty = new BaseDifficulty
|
||||
Difficulty = new BeatmapDifficulty
|
||||
{
|
||||
OverallDifficulty = 5,
|
||||
}
|
||||
@ -101,7 +102,7 @@ namespace osu.Desktop.VisualTests.Tests
|
||||
Mode = PlayMode.Osu,
|
||||
Path = "insane.osu",
|
||||
Version = "Insane",
|
||||
BaseDifficulty = new BaseDifficulty
|
||||
Difficulty = new BeatmapDifficulty
|
||||
{
|
||||
OverallDifficulty = 7,
|
||||
}
|
||||
|
@ -65,7 +65,7 @@ namespace osu.Desktop.VisualTests.Tests
|
||||
HitObjects = objects,
|
||||
BeatmapInfo = new BeatmapInfo
|
||||
{
|
||||
BaseDifficulty = new BaseDifficulty(),
|
||||
Difficulty = new BeatmapDifficulty(),
|
||||
Metadata = new BeatmapMetadata
|
||||
{
|
||||
Artist = @"Unknown",
|
||||
|
45
osu.Desktop.VisualTests/Tests/TestCaseTabControl.cs
Normal file
45
osu.Desktop.VisualTests/Tests/TestCaseTabControl.cs
Normal file
@ -0,0 +1,45 @@
|
||||
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using OpenTK;
|
||||
using osu.Framework.Graphics.Primitives;
|
||||
using osu.Framework.Screens.Testing;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
using osu.Game.Screens.Select.Filter;
|
||||
|
||||
namespace osu.Desktop.VisualTests.Tests
|
||||
{
|
||||
public class TestCaseTabControl : TestCase
|
||||
{
|
||||
public override string Description => @"Filter for song select";
|
||||
|
||||
public override void Reset()
|
||||
{
|
||||
base.Reset();
|
||||
|
||||
OsuSpriteText text;
|
||||
OsuTabControl<GroupMode> filter;
|
||||
Add(filter = new OsuTabControl<GroupMode>
|
||||
{
|
||||
Margin = new MarginPadding(4),
|
||||
Size = new Vector2(229, 24),
|
||||
AutoSort = true
|
||||
});
|
||||
Add(text = new OsuSpriteText
|
||||
{
|
||||
Text = "None",
|
||||
Margin = new MarginPadding(4),
|
||||
Position = new Vector2(275, 5)
|
||||
});
|
||||
|
||||
filter.PinItem(GroupMode.All);
|
||||
filter.PinItem(GroupMode.RecentlyPlayed);
|
||||
|
||||
filter.ItemChanged += (sender, mode) =>
|
||||
{
|
||||
text.Text = "Currently Selected: " + mode.ToString();
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
@ -193,6 +193,7 @@
|
||||
<Compile Include="Tests\TestCaseMenuButtonSystem.cs" />
|
||||
<Compile Include="Tests\TestCaseReplay.cs" />
|
||||
<Compile Include="Tests\TestCaseScoreCounter.cs" />
|
||||
<Compile Include="Tests\TestCaseTabControl.cs" />
|
||||
<Compile Include="Tests\TestCaseTextAwesome.cs" />
|
||||
<Compile Include="Tests\TestCasePlaySongSelect.cs" />
|
||||
<Compile Include="Tests\TestCaseTwoLayerButton.cs" />
|
||||
|
@ -87,8 +87,8 @@ namespace osu.Game.Modes.Catch
|
||||
new KeyCounterMouse(MouseButton.Right)
|
||||
};
|
||||
|
||||
public override ScoreProcessor CreateScoreProcessor(int hitObjectCount = 0) => null;
|
||||
|
||||
public override DifficultyCalculator CreateDifficultyCalculator(Beatmap beatmap) => new CatchDifficultyCalculator(beatmap);
|
||||
|
||||
public override ScoreProcessor CreateScoreProcessor() => new CatchScoreProcessor();
|
||||
}
|
||||
}
|
||||
|
25
osu.Game.Modes.Catch/CatchScoreProcessor.cs
Normal file
25
osu.Game.Modes.Catch/CatchScoreProcessor.cs
Normal file
@ -0,0 +1,25 @@
|
||||
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using osu.Game.Modes.Catch.Judgements;
|
||||
using osu.Game.Modes.Catch.Objects;
|
||||
using osu.Game.Modes.UI;
|
||||
|
||||
namespace osu.Game.Modes.Catch
|
||||
{
|
||||
internal class CatchScoreProcessor : ScoreProcessor<CatchBaseHit, CatchJudgementInfo>
|
||||
{
|
||||
public CatchScoreProcessor()
|
||||
{
|
||||
}
|
||||
|
||||
public CatchScoreProcessor(HitRenderer<CatchBaseHit, CatchJudgementInfo> hitRenderer)
|
||||
: base(hitRenderer)
|
||||
{
|
||||
}
|
||||
|
||||
protected override void UpdateCalculations(CatchJudgementInfo newJudgement)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
@ -17,11 +17,13 @@ namespace osu.Game.Modes.Catch.UI
|
||||
{
|
||||
}
|
||||
|
||||
public override ScoreProcessor CreateScoreProcessor() => new CatchScoreProcessor(this);
|
||||
|
||||
protected override IBeatmapConverter<CatchBaseHit> CreateBeatmapConverter() => new CatchBeatmapConverter();
|
||||
|
||||
protected override IBeatmapProcessor<CatchBaseHit> CreateBeatmapProcessor() => new CatchBeatmapProcessor();
|
||||
protected override Playfield<CatchBaseHit, CatchJudgementInfo> CreatePlayfield() => new CatchPlayfield();
|
||||
|
||||
protected override Playfield<CatchBaseHit, CatchJudgementInfo> CreatePlayfield() => new CatchPlayfield();
|
||||
|
||||
protected override DrawableHitObject<CatchBaseHit, CatchJudgementInfo> GetVisualRepresentation(CatchBaseHit h) => null;
|
||||
}
|
||||
|
@ -50,6 +50,7 @@
|
||||
<Compile Include="Beatmaps\CatchBeatmapConverter.cs" />
|
||||
<Compile Include="Beatmaps\CatchBeatmapProcessor.cs" />
|
||||
<Compile Include="CatchDifficultyCalculator.cs" />
|
||||
<Compile Include="CatchScoreProcessor.cs" />
|
||||
<Compile Include="Judgements\CatchJudgementInfo.cs" />
|
||||
<Compile Include="Objects\CatchBaseHit.cs" />
|
||||
<Compile Include="Objects\Drawable\DrawableFruit.cs" />
|
||||
|
@ -1,4 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<!--
|
||||
Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
||||
Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
@ -102,8 +102,8 @@ namespace osu.Game.Modes.Mania
|
||||
|
||||
public override IEnumerable<KeyCounter> CreateGameplayKeys() => new KeyCounter[] { /* Todo: Should be keymod specific */ };
|
||||
|
||||
public override ScoreProcessor CreateScoreProcessor(int hitObjectCount = 0) => null;
|
||||
|
||||
public override DifficultyCalculator CreateDifficultyCalculator(Beatmap beatmap) => new ManiaDifficultyCalculator(beatmap);
|
||||
|
||||
public override ScoreProcessor CreateScoreProcessor() => new ManiaScoreProcessor();
|
||||
}
|
||||
}
|
||||
|
25
osu.Game.Modes.Mania/ManiaScoreProcessor.cs
Normal file
25
osu.Game.Modes.Mania/ManiaScoreProcessor.cs
Normal file
@ -0,0 +1,25 @@
|
||||
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using osu.Game.Modes.Mania.Judgements;
|
||||
using osu.Game.Modes.Mania.Objects;
|
||||
using osu.Game.Modes.UI;
|
||||
|
||||
namespace osu.Game.Modes.Mania
|
||||
{
|
||||
internal class ManiaScoreProcessor : ScoreProcessor<ManiaBaseHit, ManiaJudgementInfo>
|
||||
{
|
||||
public ManiaScoreProcessor()
|
||||
{
|
||||
}
|
||||
|
||||
public ManiaScoreProcessor(HitRenderer<ManiaBaseHit, ManiaJudgementInfo> hitRenderer)
|
||||
: base(hitRenderer)
|
||||
{
|
||||
}
|
||||
|
||||
protected override void UpdateCalculations(ManiaJudgementInfo newJudgement)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
@ -20,11 +20,13 @@ namespace osu.Game.Modes.Mania.UI
|
||||
this.columns = columns;
|
||||
}
|
||||
|
||||
public override ScoreProcessor CreateScoreProcessor() => new ManiaScoreProcessor(this);
|
||||
|
||||
protected override IBeatmapConverter<ManiaBaseHit> CreateBeatmapConverter() => new ManiaBeatmapConverter();
|
||||
|
||||
protected override IBeatmapProcessor<ManiaBaseHit> CreateBeatmapProcessor() => new ManiaBeatmapProcessor();
|
||||
protected override Playfield<ManiaBaseHit, ManiaJudgementInfo> CreatePlayfield() => new ManiaPlayfield(columns);
|
||||
|
||||
protected override Playfield<ManiaBaseHit, ManiaJudgementInfo> CreatePlayfield() => new ManiaPlayfield(columns);
|
||||
|
||||
protected override DrawableHitObject<ManiaBaseHit, ManiaJudgementInfo> GetVisualRepresentation(ManiaBaseHit h) => null;
|
||||
}
|
||||
|
@ -51,6 +51,7 @@
|
||||
<Compile Include="Beatmaps\ManiaBeatmapProcessor.cs" />
|
||||
<Compile Include="Judgements\ManiaJudgementInfo.cs" />
|
||||
<Compile Include="ManiaDifficultyCalculator.cs" />
|
||||
<Compile Include="ManiaScoreProcessor.cs" />
|
||||
<Compile Include="Objects\Drawable\DrawableNote.cs" />
|
||||
<Compile Include="Objects\HoldNote.cs" />
|
||||
<Compile Include="Objects\ManiaBaseHit.cs" />
|
||||
|
@ -1,4 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<!--
|
||||
Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
||||
Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
@ -8,11 +8,6 @@ namespace osu.Game.Modes.Osu.Beatmaps
|
||||
{
|
||||
internal class OsuBeatmapProcessor : IBeatmapProcessor<OsuHitObject>
|
||||
{
|
||||
public void SetDefaults(OsuHitObject hitObject, Beatmap<OsuHitObject> beatmap)
|
||||
{
|
||||
hitObject.SetDefaultsFromBeatmap(beatmap);
|
||||
}
|
||||
|
||||
public void PostProcess(Beatmap<OsuHitObject> beatmap)
|
||||
{
|
||||
if (beatmap.ComboColors.Count == 0)
|
||||
|
@ -28,6 +28,10 @@ namespace osu.Game.Modes.Osu.Objects.Drawables
|
||||
|
||||
public DrawableSlider(Slider s) : base(s)
|
||||
{
|
||||
// Since the DrawableSlider itself is just a container without a size we need to
|
||||
// pass all input through.
|
||||
AlwaysReceiveInput = true;
|
||||
|
||||
SliderBouncer bouncer1;
|
||||
slider = s;
|
||||
|
||||
@ -91,10 +95,6 @@ namespace osu.Game.Modes.Osu.Objects.Drawables
|
||||
}
|
||||
}
|
||||
|
||||
// Since the DrawableSlider itself is just a container without a size we need to
|
||||
// pass all input through.
|
||||
public override bool Contains(Vector2 screenSpacePos) => true;
|
||||
|
||||
private int currentRepeat;
|
||||
|
||||
protected override void Update()
|
||||
|
@ -24,6 +24,8 @@ namespace osu.Game.Modes.Osu.Objects.Drawables
|
||||
|
||||
public DrawableSpinner(Spinner s) : base(s)
|
||||
{
|
||||
AlwaysReceiveInput = true;
|
||||
|
||||
Origin = Anchor.Centre;
|
||||
Position = s.Position;
|
||||
|
||||
@ -69,8 +71,6 @@ namespace osu.Game.Modes.Osu.Objects.Drawables
|
||||
disc.Scale = scaleToCircle;
|
||||
}
|
||||
|
||||
public override bool Contains(Vector2 screenSpacePos) => true;
|
||||
|
||||
protected override void CheckJudgement(bool userTriggered)
|
||||
{
|
||||
if (Time.Current < HitObject.StartTime) return;
|
||||
|
@ -19,8 +19,6 @@ namespace osu.Game.Modes.Osu.Objects.Drawables.Pieces
|
||||
{
|
||||
public class SpinnerDisc : CircularContainer
|
||||
{
|
||||
public override bool Contains(Vector2 screenSpacePos) => true;
|
||||
|
||||
protected Sprite Disc;
|
||||
|
||||
public SRGBColour DiscColour
|
||||
@ -101,6 +99,8 @@ namespace osu.Game.Modes.Osu.Objects.Drawables.Pieces
|
||||
|
||||
public SpinnerDisc()
|
||||
{
|
||||
AlwaysReceiveInput = true;
|
||||
|
||||
RelativeSizeAxes = Axes.Both;
|
||||
|
||||
Children = new Drawable[]
|
||||
|
@ -3,10 +3,11 @@
|
||||
|
||||
using osu.Game.Modes.Objects;
|
||||
using OpenTK;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Modes.Osu.Objects.Drawables;
|
||||
using osu.Game.Modes.Objects.Types;
|
||||
using OpenTK.Graphics;
|
||||
using osu.Game.Beatmaps.Timing;
|
||||
using osu.Game.Database;
|
||||
|
||||
namespace osu.Game.Modes.Osu.Objects
|
||||
{
|
||||
@ -67,9 +68,11 @@ namespace osu.Game.Modes.Osu.Objects
|
||||
return OsuScoreResult.Miss;
|
||||
}
|
||||
|
||||
public virtual void SetDefaultsFromBeatmap(Beatmap<OsuHitObject> beatmap)
|
||||
public override void ApplyDefaults(TimingInfo timing, BeatmapDifficulty difficulty)
|
||||
{
|
||||
Scale = (1.0f - 0.7f * (beatmap.BeatmapInfo.BaseDifficulty.CircleSize - 5) / 5) / 2;
|
||||
base.ApplyDefaults(timing, difficulty);
|
||||
|
||||
Scale = (1.0f - 0.7f * (difficulty.CircleSize - 5) / 5) / 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,13 +2,13 @@
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using OpenTK;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Beatmaps.Samples;
|
||||
using osu.Game.Beatmaps.Timing;
|
||||
using osu.Game.Modes.Objects.Types;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using osu.Game.Modes.Objects;
|
||||
using osu.Game.Database;
|
||||
|
||||
namespace osu.Game.Modes.Osu.Objects
|
||||
{
|
||||
@ -47,19 +47,17 @@ namespace osu.Game.Modes.Osu.Objects
|
||||
public double Velocity;
|
||||
public double TickDistance;
|
||||
|
||||
public override void SetDefaultsFromBeatmap(Beatmap<OsuHitObject> beatmap)
|
||||
public override void ApplyDefaults(TimingInfo timing, BeatmapDifficulty difficulty)
|
||||
{
|
||||
base.SetDefaultsFromBeatmap(beatmap);
|
||||
|
||||
var baseDifficulty = beatmap.BeatmapInfo.BaseDifficulty;
|
||||
base.ApplyDefaults(timing, difficulty);
|
||||
|
||||
ControlPoint overridePoint;
|
||||
ControlPoint timingPoint = beatmap.TimingPointAt(StartTime, out overridePoint);
|
||||
ControlPoint timingPoint = timing.TimingPointAt(StartTime, out overridePoint);
|
||||
var velocityAdjustment = overridePoint?.VelocityAdjustment ?? 1;
|
||||
var baseVelocity = 100 * baseDifficulty.SliderMultiplier / velocityAdjustment;
|
||||
var baseVelocity = 100 * difficulty.SliderMultiplier / velocityAdjustment;
|
||||
|
||||
Velocity = baseVelocity / timingPoint.BeatLength;
|
||||
TickDistance = baseVelocity / baseDifficulty.SliderTickRate;
|
||||
TickDistance = baseVelocity / difficulty.SliderTickRate;
|
||||
}
|
||||
|
||||
public IEnumerable<SliderTick> Ticks
|
||||
|
@ -95,8 +95,6 @@ namespace osu.Game.Modes.Osu
|
||||
|
||||
public override FontAwesome Icon => FontAwesome.fa_osu_osu_o;
|
||||
|
||||
public override ScoreProcessor CreateScoreProcessor(int hitObjectCount = 0) => new OsuScoreProcessor(hitObjectCount);
|
||||
|
||||
public override DifficultyCalculator CreateDifficultyCalculator(Beatmap beatmap) => new OsuDifficultyCalculator(beatmap);
|
||||
|
||||
protected override PlayMode PlayMode => PlayMode.Osu;
|
||||
@ -110,5 +108,7 @@ namespace osu.Game.Modes.Osu
|
||||
new KeyCounterMouse(MouseButton.Left),
|
||||
new KeyCounterMouse(MouseButton.Right)
|
||||
};
|
||||
|
||||
public override ScoreProcessor CreateScoreProcessor() => new OsuScoreProcessor();
|
||||
}
|
||||
}
|
||||
|
@ -1,22 +1,33 @@
|
||||
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using osu.Game.Modes.Judgements;
|
||||
using osu.Game.Modes.Objects.Drawables;
|
||||
using osu.Game.Modes.Osu.Judgements;
|
||||
using osu.Game.Modes.Osu.Objects;
|
||||
using osu.Game.Modes.UI;
|
||||
|
||||
namespace osu.Game.Modes.Osu
|
||||
{
|
||||
internal class OsuScoreProcessor : ScoreProcessor
|
||||
internal class OsuScoreProcessor : ScoreProcessor<OsuHitObject, OsuJudgementInfo>
|
||||
{
|
||||
public OsuScoreProcessor(int hitObjectCount = 0)
|
||||
: base(hitObjectCount)
|
||||
public OsuScoreProcessor()
|
||||
{
|
||||
}
|
||||
|
||||
public OsuScoreProcessor(HitRenderer<OsuHitObject, OsuJudgementInfo> hitRenderer)
|
||||
: base(hitRenderer)
|
||||
{
|
||||
}
|
||||
|
||||
protected override void Reset()
|
||||
{
|
||||
base.Reset();
|
||||
|
||||
Health.Value = 1;
|
||||
Accuracy.Value = 1;
|
||||
}
|
||||
|
||||
protected override void UpdateCalculations(JudgementInfo judgement)
|
||||
protected override void UpdateCalculations(OsuJudgementInfo judgement)
|
||||
{
|
||||
if (judgement != null)
|
||||
{
|
||||
@ -38,7 +49,7 @@ namespace osu.Game.Modes.Osu
|
||||
|
||||
foreach (var judgementInfo in Judgements)
|
||||
{
|
||||
var j = (OsuJudgementInfo)judgementInfo;
|
||||
var j = judgementInfo;
|
||||
score += j.ScoreValue;
|
||||
maxScore += j.MaxScoreValue;
|
||||
}
|
||||
|
@ -19,11 +19,13 @@ namespace osu.Game.Modes.Osu.UI
|
||||
{
|
||||
}
|
||||
|
||||
public override ScoreProcessor CreateScoreProcessor() => new OsuScoreProcessor(this);
|
||||
|
||||
protected override IBeatmapConverter<OsuHitObject> CreateBeatmapConverter() => new OsuBeatmapConverter();
|
||||
|
||||
protected override IBeatmapProcessor<OsuHitObject> CreateBeatmapProcessor() => new OsuBeatmapProcessor();
|
||||
protected override Playfield<OsuHitObject, OsuJudgementInfo> CreatePlayfield() => new OsuPlayfield();
|
||||
|
||||
protected override Playfield<OsuHitObject, OsuJudgementInfo> CreatePlayfield() => new OsuPlayfield();
|
||||
|
||||
protected override KeyConversionInputManager CreateKeyConversionInputManager() => new OsuKeyConversionInputManager();
|
||||
|
||||
|
@ -12,7 +12,6 @@ using osu.Game.Modes.UI;
|
||||
using System.Linq;
|
||||
using osu.Game.Graphics.Cursor;
|
||||
using osu.Game.Modes.Osu.Judgements;
|
||||
using OpenTK.Graphics;
|
||||
|
||||
namespace osu.Game.Modes.Osu.UI
|
||||
{
|
||||
@ -63,7 +62,7 @@ namespace osu.Game.Modes.Osu.UI
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
AddInternal(new OsuCursorContainer { Colour = Color4.LightYellow });
|
||||
AddInternal(new GameplayCursor());
|
||||
}
|
||||
|
||||
public override void Add(DrawableHitObject<OsuHitObject, OsuJudgementInfo> h)
|
||||
|
@ -1,4 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<!--
|
||||
Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
||||
Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
@ -88,8 +88,8 @@ namespace osu.Game.Modes.Taiko
|
||||
new KeyCounterKeyboard(Key.K)
|
||||
};
|
||||
|
||||
public override ScoreProcessor CreateScoreProcessor(int hitObjectCount = 0) => null;
|
||||
|
||||
public override DifficultyCalculator CreateDifficultyCalculator(Beatmap beatmap) => new TaikoDifficultyCalculator(beatmap);
|
||||
|
||||
public override ScoreProcessor CreateScoreProcessor() => new TaikoScoreProcessor();
|
||||
}
|
||||
}
|
||||
|
25
osu.Game.Modes.Taiko/TaikoScoreProcessor.cs
Normal file
25
osu.Game.Modes.Taiko/TaikoScoreProcessor.cs
Normal file
@ -0,0 +1,25 @@
|
||||
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using osu.Game.Modes.Taiko.Judgements;
|
||||
using osu.Game.Modes.Taiko.Objects;
|
||||
using osu.Game.Modes.UI;
|
||||
|
||||
namespace osu.Game.Modes.Taiko
|
||||
{
|
||||
internal class TaikoScoreProcessor : ScoreProcessor<TaikoBaseHit, TaikoJudgementInfo>
|
||||
{
|
||||
public TaikoScoreProcessor()
|
||||
{
|
||||
}
|
||||
|
||||
public TaikoScoreProcessor(HitRenderer<TaikoBaseHit, TaikoJudgementInfo> hitRenderer)
|
||||
: base(hitRenderer)
|
||||
{
|
||||
}
|
||||
|
||||
protected override void UpdateCalculations(TaikoJudgementInfo newJudgement)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
@ -17,11 +17,13 @@ namespace osu.Game.Modes.Taiko.UI
|
||||
{
|
||||
}
|
||||
|
||||
public override ScoreProcessor CreateScoreProcessor() => new TaikoScoreProcessor(this);
|
||||
|
||||
protected override IBeatmapConverter<TaikoBaseHit> CreateBeatmapConverter() => new TaikoBeatmapConverter();
|
||||
|
||||
protected override IBeatmapProcessor<TaikoBaseHit> CreateBeatmapProcessor() => new TaikoBeatmapProcessor();
|
||||
protected override Playfield<TaikoBaseHit, TaikoJudgementInfo> CreatePlayfield() => new TaikoPlayfield();
|
||||
|
||||
protected override Playfield<TaikoBaseHit, TaikoJudgementInfo> CreatePlayfield() => new TaikoPlayfield();
|
||||
|
||||
protected override DrawableHitObject<TaikoBaseHit, TaikoJudgementInfo> GetVisualRepresentation(TaikoBaseHit h) => null;
|
||||
}
|
||||
|
@ -54,6 +54,7 @@
|
||||
<Compile Include="Objects\Drawable\DrawableTaikoHit.cs" />
|
||||
<Compile Include="Objects\TaikoBaseHit.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="TaikoScoreProcessor.cs" />
|
||||
<Compile Include="UI\TaikoHitRenderer.cs" />
|
||||
<Compile Include="UI\TaikoPlayfield.cs" />
|
||||
<Compile Include="TaikoRuleset.cs" />
|
||||
|
@ -1,4 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<!--
|
||||
Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
||||
Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
@ -94,7 +94,7 @@ namespace osu.Game.Tests.Beatmaps.Formats
|
||||
using (var stream = Resource.OpenResource("Soleily - Renatus (Gamu) [Insane].osu"))
|
||||
{
|
||||
var beatmap = decoder.Decode(new StreamReader(stream));
|
||||
var difficulty = beatmap.BeatmapInfo.BaseDifficulty;
|
||||
var difficulty = beatmap.BeatmapInfo.Difficulty;
|
||||
Assert.AreEqual(6.5f, difficulty.DrainRate);
|
||||
Assert.AreEqual(4, difficulty.CircleSize);
|
||||
Assert.AreEqual(8, difficulty.OverallDifficulty);
|
||||
|
@ -7,7 +7,6 @@ using osu.Game.Database;
|
||||
using osu.Game.Modes;
|
||||
using osu.Game.Modes.Objects;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace osu.Game.Beatmaps
|
||||
{
|
||||
@ -18,7 +17,7 @@ namespace osu.Game.Beatmaps
|
||||
where T : HitObject
|
||||
{
|
||||
public BeatmapInfo BeatmapInfo;
|
||||
public List<ControlPoint> ControlPoints;
|
||||
public TimingInfo TimingInfo = new TimingInfo();
|
||||
public readonly List<Color4> ComboColors = new List<Color4>
|
||||
{
|
||||
new Color4(17, 136, 170, 255),
|
||||
@ -41,49 +40,23 @@ namespace osu.Game.Beatmaps
|
||||
public Beatmap(Beatmap original = null)
|
||||
{
|
||||
BeatmapInfo = original?.BeatmapInfo ?? BeatmapInfo;
|
||||
ControlPoints = original?.ControlPoints ?? ControlPoints;
|
||||
TimingInfo = original?.TimingInfo ?? TimingInfo;
|
||||
ComboColors = original?.ComboColors ?? ComboColors;
|
||||
}
|
||||
|
||||
public double BPMMaximum => 60000 / (ControlPoints?.Where(c => c.BeatLength != 0).OrderBy(c => c.BeatLength).FirstOrDefault() ?? ControlPoint.Default).BeatLength;
|
||||
public double BPMMinimum => 60000 / (ControlPoints?.Where(c => c.BeatLength != 0).OrderByDescending(c => c.BeatLength).FirstOrDefault() ?? ControlPoint.Default).BeatLength;
|
||||
public double BPMMode => BPMAt(ControlPoints.Where(c => c.BeatLength != 0).GroupBy(c => c.BeatLength).OrderByDescending(grp => grp.Count()).First().First().Time);
|
||||
|
||||
public double BPMAt(double time)
|
||||
/// <summary>
|
||||
/// Finds the slider velocity at a time.
|
||||
/// </summary>
|
||||
/// <param name="time">The time to find the slider velocity at.</param>
|
||||
/// <returns>The slider velocity in positional length units.</returns>
|
||||
public double SliderVelocityAt(double time)
|
||||
{
|
||||
return 60000 / BeatLengthAt(time);
|
||||
}
|
||||
double scoringDistance = 100 * BeatmapInfo.Difficulty.SliderMultiplier;
|
||||
double beatDistance = TimingInfo.BeatDistanceAt(time);
|
||||
|
||||
public double BeatLengthAt(double time)
|
||||
{
|
||||
ControlPoint overridePoint;
|
||||
ControlPoint timingPoint = TimingPointAt(time, out overridePoint);
|
||||
return timingPoint.BeatLength;
|
||||
}
|
||||
|
||||
public ControlPoint TimingPointAt(double time, out ControlPoint overridePoint)
|
||||
{
|
||||
overridePoint = null;
|
||||
|
||||
ControlPoint timingPoint = null;
|
||||
foreach (var controlPoint in ControlPoints)
|
||||
{
|
||||
// Some beatmaps have the first timingPoint (accidentally) start after the first HitObject(s).
|
||||
// This null check makes it so that the first ControlPoint that makes a timing change is used as
|
||||
// the timingPoint for those HitObject(s).
|
||||
if (controlPoint.Time <= time || timingPoint == null)
|
||||
{
|
||||
if (controlPoint.TimingChange)
|
||||
{
|
||||
timingPoint = controlPoint;
|
||||
overridePoint = null;
|
||||
}
|
||||
else overridePoint = controlPoint;
|
||||
}
|
||||
else break;
|
||||
}
|
||||
|
||||
return timingPoint ?? ControlPoint.Default;
|
||||
if (beatDistance > 0)
|
||||
return scoringDistance / beatDistance * 1000;
|
||||
return scoringDistance;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -10,7 +10,7 @@ using osu.Game.Database;
|
||||
|
||||
namespace osu.Game.Beatmaps.Drawables
|
||||
{
|
||||
internal class BeatmapGroup : IStateful<BeatmapGroupState>
|
||||
public class BeatmapGroup : IStateful<BeatmapGroupState>
|
||||
{
|
||||
public BeatmapPanel SelectedPanel;
|
||||
|
||||
@ -63,8 +63,6 @@ namespace osu.Game.Beatmaps.Drawables
|
||||
{
|
||||
BeatmapSet = beatmapSet;
|
||||
WorkingBeatmap beatmap = database.GetWorkingBeatmap(BeatmapSet.Beatmaps.FirstOrDefault());
|
||||
foreach (var b in BeatmapSet.Beatmaps)
|
||||
b.StarDifficulty = (float)(database.GetWorkingBeatmap(b).Beatmap?.CalculateStarDifficulty() ?? -1f);
|
||||
|
||||
Header = new BeatmapSetHeader(beatmap)
|
||||
{
|
||||
|
@ -18,7 +18,7 @@ using osu.Game.Graphics.Sprites;
|
||||
|
||||
namespace osu.Game.Beatmaps.Drawables
|
||||
{
|
||||
internal class BeatmapPanel : Panel
|
||||
public class BeatmapPanel : Panel
|
||||
{
|
||||
public BeatmapInfo Beatmap;
|
||||
private Sprite background;
|
||||
@ -59,6 +59,8 @@ namespace osu.Game.Beatmaps.Drawables
|
||||
|
||||
protected override void ApplyState(PanelSelectedState last = PanelSelectedState.Hidden)
|
||||
{
|
||||
if (!IsLoaded) return;
|
||||
|
||||
base.ApplyState(last);
|
||||
|
||||
if (last == PanelSelectedState.Hidden && State != last)
|
||||
@ -138,7 +140,7 @@ namespace osu.Game.Beatmaps.Drawables
|
||||
},
|
||||
starCounter = new StarCounter
|
||||
{
|
||||
Count = beatmap.StarDifficulty,
|
||||
Count = (float)beatmap.StarDifficulty,
|
||||
Scale = new Vector2(0.8f),
|
||||
}
|
||||
}
|
||||
|
@ -17,7 +17,7 @@ using OpenTK.Graphics;
|
||||
|
||||
namespace osu.Game.Beatmaps.Drawables
|
||||
{
|
||||
internal class BeatmapSetHeader : Panel
|
||||
public class BeatmapSetHeader : Panel
|
||||
{
|
||||
public Action<BeatmapSetHeader> GainedSelection;
|
||||
private SpriteText title, artist;
|
||||
@ -32,10 +32,6 @@ namespace osu.Game.Beatmaps.Drawables
|
||||
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new PanelBackground(beatmap)
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
},
|
||||
new FillFlowContainer
|
||||
{
|
||||
Direction = FillDirection.Vertical,
|
||||
@ -74,13 +70,23 @@ namespace osu.Game.Beatmaps.Drawables
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuConfigManager config)
|
||||
private void load(OsuConfigManager config, OsuGameBase game)
|
||||
{
|
||||
this.config = config;
|
||||
|
||||
preferUnicode = config.GetBindable<bool>(OsuConfig.ShowUnicode);
|
||||
preferUnicode.ValueChanged += preferUnicode_changed;
|
||||
preferUnicode_changed(preferUnicode, null);
|
||||
|
||||
new PanelBackground(beatmap)
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Depth = 1,
|
||||
}.LoadAsync(game, b =>
|
||||
{
|
||||
Add(b);
|
||||
b.FadeInFromZero(200);
|
||||
});
|
||||
}
|
||||
|
||||
private void preferUnicode_changed(object sender, EventArgs e)
|
||||
@ -98,16 +104,18 @@ namespace osu.Game.Beatmaps.Drawables
|
||||
|
||||
private class PanelBackground : BufferedContainer
|
||||
{
|
||||
private readonly WorkingBeatmap working;
|
||||
|
||||
public PanelBackground(WorkingBeatmap working)
|
||||
{
|
||||
this.working = working;
|
||||
|
||||
CacheDrawnFrameBuffer = true;
|
||||
|
||||
Children = new[]
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new BeatmapBackgroundSprite(working)
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
FillMode = FillMode.Fill,
|
||||
},
|
||||
new FillFlowContainer
|
||||
{
|
||||
Depth = -1,
|
||||
@ -151,21 +159,6 @@ namespace osu.Game.Beatmaps.Drawables
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuGameBase game)
|
||||
{
|
||||
new BeatmapBackgroundSprite(working)
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
FillMode = FillMode.Fill,
|
||||
}.LoadAsync(game, bg =>
|
||||
{
|
||||
Add(bg);
|
||||
ForceRedraw();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public void AddDifficultyIcons(IEnumerable<BeatmapPanel> panels)
|
||||
|
@ -12,7 +12,7 @@ using osu.Framework.Extensions.Color4Extensions;
|
||||
|
||||
namespace osu.Game.Beatmaps.Drawables
|
||||
{
|
||||
internal class Panel : Container, IStateful<PanelSelectedState>
|
||||
public class Panel : Container, IStateful<PanelSelectedState>
|
||||
{
|
||||
public const float MAX_HEIGHT = 80;
|
||||
|
||||
@ -51,6 +51,8 @@ namespace osu.Game.Beatmaps.Drawables
|
||||
|
||||
protected virtual void ApplyState(PanelSelectedState last = PanelSelectedState.Hidden)
|
||||
{
|
||||
if (!IsLoaded) return;
|
||||
|
||||
switch (state)
|
||||
{
|
||||
case PanelSelectedState.Hidden:
|
||||
@ -115,7 +117,7 @@ namespace osu.Game.Beatmaps.Drawables
|
||||
}
|
||||
}
|
||||
|
||||
internal enum PanelSelectedState
|
||||
public enum PanelSelectedState
|
||||
{
|
||||
Hidden,
|
||||
NotSelected,
|
||||
|
@ -5,7 +5,6 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using osu.Game.Modes.Objects;
|
||||
using osu.Game.Beatmaps.Timing;
|
||||
using osu.Game.Database;
|
||||
|
||||
namespace osu.Game.Beatmaps.Formats
|
||||
@ -43,11 +42,10 @@ namespace osu.Game.Beatmaps.Formats
|
||||
var beatmap = new Beatmap
|
||||
{
|
||||
HitObjects = new List<HitObject>(),
|
||||
ControlPoints = new List<ControlPoint>(),
|
||||
BeatmapInfo = new BeatmapInfo
|
||||
{
|
||||
Metadata = new BeatmapMetadata(),
|
||||
BaseDifficulty = new BaseDifficulty(),
|
||||
Difficulty = new BeatmapDifficulty(),
|
||||
},
|
||||
};
|
||||
ParseFile(stream, beatmap);
|
||||
|
@ -144,7 +144,7 @@ namespace osu.Game.Beatmaps.Formats
|
||||
|
||||
private void handleDifficulty(Beatmap beatmap, string key, string val)
|
||||
{
|
||||
var difficulty = beatmap.BeatmapInfo.BaseDifficulty;
|
||||
var difficulty = beatmap.BeatmapInfo.Difficulty;
|
||||
switch (key)
|
||||
{
|
||||
case @"HPDrainRate":
|
||||
@ -197,7 +197,7 @@ namespace osu.Game.Beatmaps.Formats
|
||||
|
||||
if (split.Length > 2)
|
||||
{
|
||||
//int kiaiFlags = split.Length > 7 ? Convert.ToInt32(split[7], NumberFormatInfo.InvariantInfo) : 0;
|
||||
int effectFlags = split.Length > 7 ? Convert.ToInt32(split[7], NumberFormatInfo.InvariantInfo) : 0;
|
||||
double beatLength = double.Parse(split[1].Trim(), NumberFormatInfo.InvariantInfo);
|
||||
cp = new ControlPoint
|
||||
{
|
||||
@ -205,11 +205,13 @@ namespace osu.Game.Beatmaps.Formats
|
||||
BeatLength = beatLength > 0 ? beatLength : 0,
|
||||
VelocityAdjustment = beatLength < 0 ? -beatLength / 100.0 : 1,
|
||||
TimingChange = split.Length <= 6 || split[6][0] == '1',
|
||||
KiaiMode = (effectFlags & 1) > 0,
|
||||
OmitFirstBarLine = (effectFlags & 8) > 0
|
||||
};
|
||||
}
|
||||
|
||||
if (cp != null)
|
||||
beatmap.ControlPoints.Add(cp);
|
||||
beatmap.TimingInfo.ControlPoints.Add(cp);
|
||||
}
|
||||
|
||||
private void handleColours(Beatmap beatmap, string key, string val, ref bool hasCustomColours)
|
||||
|
@ -8,17 +8,10 @@ namespace osu.Game.Beatmaps
|
||||
/// <summary>
|
||||
/// Processes a post-converted Beatmap.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of HitObject contained in the Beatmap.</typeparam>
|
||||
public interface IBeatmapProcessor<T>
|
||||
where T : HitObject
|
||||
/// <typeparam name="TObject">The type of HitObject contained in the Beatmap.</typeparam>
|
||||
public interface IBeatmapProcessor<TObject>
|
||||
where TObject : HitObject
|
||||
{
|
||||
/// <summary>
|
||||
/// Sets default values for a HitObject.
|
||||
/// </summary>
|
||||
/// <param name="hitObject">The HitObject to set default values for.</param>
|
||||
/// <param name="beatmap">The Beatmap to extract the default values from.</param>
|
||||
void SetDefaults(T hitObject, Beatmap<T> beatmap);
|
||||
|
||||
/// <summary>
|
||||
/// Post-processes a Beatmap to add mode-specific components that aren't added during conversion.
|
||||
/// <para>
|
||||
@ -26,6 +19,6 @@ namespace osu.Game.Beatmaps
|
||||
/// </para>
|
||||
/// </summary>
|
||||
/// <param name="beatmap">The Beatmap to process.</param>
|
||||
void PostProcess(Beatmap<T> beatmap);
|
||||
void PostProcess(Beatmap<TObject> beatmap);
|
||||
}
|
||||
}
|
||||
|
@ -16,6 +16,7 @@ namespace osu.Game.Beatmaps.Timing
|
||||
public double VelocityAdjustment;
|
||||
public bool TimingChange;
|
||||
public bool KiaiMode;
|
||||
public bool OmitFirstBarLine;
|
||||
|
||||
}
|
||||
|
||||
|
106
osu.Game/Beatmaps/Timing/TimingInfo.cs
Normal file
106
osu.Game/Beatmaps/Timing/TimingInfo.cs
Normal file
@ -0,0 +1,106 @@
|
||||
// Copyright (c) 2007-2017 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.Linq;
|
||||
|
||||
namespace osu.Game.Beatmaps.Timing
|
||||
{
|
||||
public class TimingInfo
|
||||
{
|
||||
public readonly List<ControlPoint> ControlPoints = new List<ControlPoint>();
|
||||
|
||||
public double BPMMaximum => 60000 / (ControlPoints?.Where(c => c.BeatLength != 0).OrderBy(c => c.BeatLength).FirstOrDefault() ?? ControlPoint.Default).BeatLength;
|
||||
public double BPMMinimum => 60000 / (ControlPoints?.Where(c => c.BeatLength != 0).OrderByDescending(c => c.BeatLength).FirstOrDefault() ?? ControlPoint.Default).BeatLength;
|
||||
public double BPMMode => BPMAt(ControlPoints.Where(c => c.BeatLength != 0).GroupBy(c => c.BeatLength).OrderByDescending(grp => grp.Count()).First().First().Time);
|
||||
|
||||
public double BPMAt(double time)
|
||||
{
|
||||
return 60000 / BeatLengthAt(time);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Finds the BPM multiplier at a time.
|
||||
/// </summary>
|
||||
/// <param name="time">The time to find the BPM multiplier at.</param>
|
||||
/// <returns>The BPM multiplier.</returns>
|
||||
public double BPMMultiplierAt(double time)
|
||||
{
|
||||
ControlPoint overridePoint;
|
||||
ControlPoint timingPoint = TimingPointAt(time, out overridePoint);
|
||||
|
||||
return overridePoint?.VelocityAdjustment ?? timingPoint?.VelocityAdjustment ?? 1;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Finds the beat length at a time.
|
||||
/// </summary>
|
||||
/// <param name="time">The time to find the beat length at.</param>
|
||||
/// <returns>The beat length in milliseconds.</returns>
|
||||
public double BeatLengthAt(double time)
|
||||
{
|
||||
ControlPoint overridePoint;
|
||||
ControlPoint timingPoint = TimingPointAt(time, out overridePoint);
|
||||
|
||||
return timingPoint.BeatLength;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Finds the beat velocity at a time.
|
||||
/// </summary>
|
||||
/// <param name="time">The time to find the velocity at.</param>
|
||||
/// <returns>The velocity.</returns>
|
||||
public double BeatVelocityAt(double time)
|
||||
{
|
||||
ControlPoint overridePoint;
|
||||
ControlPoint timingPoint = TimingPointAt(time, out overridePoint);
|
||||
|
||||
return overridePoint?.VelocityAdjustment ?? timingPoint?.VelocityAdjustment ?? 1;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Finds the beat length at a time.
|
||||
/// </summary>
|
||||
/// <param name="time">The time to find the beat length at.</param>
|
||||
/// <returns>The beat length in positional length units.</returns>
|
||||
public double BeatDistanceAt(double time)
|
||||
{
|
||||
ControlPoint overridePoint;
|
||||
ControlPoint timingPoint = TimingPointAt(time, out overridePoint);
|
||||
|
||||
return (timingPoint?.BeatLength ?? 1) * (overridePoint?.VelocityAdjustment ?? timingPoint?.VelocityAdjustment ?? 1);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Finds the timing point at a time.
|
||||
/// </summary>
|
||||
/// <param name="time">The time to find the timing point at.</param>
|
||||
/// <param name="overridePoint">The timing point containing the velocity change of the returned timing point.</param>
|
||||
/// <returns>The timing point.</returns>
|
||||
public ControlPoint TimingPointAt(double time, out ControlPoint overridePoint)
|
||||
{
|
||||
overridePoint = null;
|
||||
|
||||
ControlPoint timingPoint = null;
|
||||
foreach (var controlPoint in ControlPoints)
|
||||
{
|
||||
// Some beatmaps have the first timingPoint (accidentally) start after the first HitObject(s).
|
||||
// This null check makes it so that the first ControlPoint that makes a timing change is used as
|
||||
// the timingPoint for those HitObject(s).
|
||||
if (controlPoint.Time <= time || timingPoint == null)
|
||||
{
|
||||
if (controlPoint.TimingChange)
|
||||
{
|
||||
timingPoint = controlPoint;
|
||||
overridePoint = null;
|
||||
}
|
||||
else
|
||||
overridePoint = controlPoint;
|
||||
}
|
||||
else break;
|
||||
}
|
||||
|
||||
return timingPoint ?? ControlPoint.Default;
|
||||
}
|
||||
}
|
||||
}
|
@ -5,7 +5,7 @@ using SQLite.Net.Attributes;
|
||||
|
||||
namespace osu.Game.Database
|
||||
{
|
||||
public class BaseDifficulty
|
||||
public class BeatmapDifficulty
|
||||
{
|
||||
[PrimaryKey, AutoIncrement]
|
||||
public int ID { get; set; }
|
||||
@ -15,6 +15,23 @@ namespace osu.Game.Database
|
||||
public float ApproachRate { get; set; }
|
||||
public float SliderMultiplier { get; set; }
|
||||
public float SliderTickRate { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Maps a difficulty value [0, 10] to a two-piece linear range of values.
|
||||
/// </summary>
|
||||
/// <param name="difficulty">The difficulty value to be mapped.</param>
|
||||
/// <param name="min">Minimum of the resulting range which will be achieved by a difficulty value of 0.</param>
|
||||
/// <param name="mid">Midpoint of the resulting range which will be achieved by a difficulty value of 5.</param>
|
||||
/// <param name="max">Maximum of the resulting range which will be achieved by a difficulty value of 10.</param>
|
||||
/// <returns>Value to which the difficulty value maps in the specified range.</returns>
|
||||
public static double DifficultyRange(double difficulty, double min, double mid, double max)
|
||||
{
|
||||
if (difficulty > 5)
|
||||
return mid + (max - mid) * (difficulty - 5) / 5;
|
||||
if (difficulty < 5)
|
||||
return mid - (mid - min) * (5 - difficulty) / 5;
|
||||
return mid;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -64,7 +64,7 @@ namespace osu.Game.Database
|
||||
foreach (var i in b.Beatmaps)
|
||||
{
|
||||
if (i.Metadata != null) connection.Delete(i.Metadata);
|
||||
if (i.BaseDifficulty != null) connection.Delete(i.BaseDifficulty);
|
||||
if (i.Difficulty != null) connection.Delete(i.Difficulty);
|
||||
|
||||
connection.Delete(i);
|
||||
}
|
||||
@ -90,7 +90,7 @@ namespace osu.Game.Database
|
||||
try
|
||||
{
|
||||
conn.CreateTable<BeatmapMetadata>();
|
||||
conn.CreateTable<BaseDifficulty>();
|
||||
conn.CreateTable<BeatmapDifficulty>();
|
||||
conn.CreateTable<BeatmapSetInfo>();
|
||||
conn.CreateTable<BeatmapInfo>();
|
||||
}
|
||||
@ -112,7 +112,7 @@ namespace osu.Game.Database
|
||||
}
|
||||
|
||||
connection.DeleteAll<BeatmapMetadata>();
|
||||
connection.DeleteAll<BaseDifficulty>();
|
||||
connection.DeleteAll<BeatmapDifficulty>();
|
||||
connection.DeleteAll<BeatmapSetInfo>();
|
||||
connection.DeleteAll<BeatmapInfo>();
|
||||
}
|
||||
@ -123,16 +123,15 @@ namespace osu.Game.Database
|
||||
/// <param name="paths">Multiple locations on disk</param>
|
||||
public void Import(IEnumerable<string> paths)
|
||||
{
|
||||
Stack<BeatmapSetInfo> sets = new Stack<BeatmapSetInfo>();
|
||||
|
||||
foreach (string p in paths)
|
||||
{
|
||||
try
|
||||
{
|
||||
BeatmapSetInfo set = getBeatmapSet(p);
|
||||
|
||||
//If we have an ID then we already exist in the database.
|
||||
if (set.ID == 0)
|
||||
sets.Push(set);
|
||||
Import(new[] { set });
|
||||
|
||||
// We may or may not want to delete the file depending on where it is stored.
|
||||
// e.g. reconstructing/repairing database with beatmaps from default storage.
|
||||
@ -152,9 +151,7 @@ namespace osu.Game.Database
|
||||
e = e.InnerException ?? e;
|
||||
Logger.Error(e, @"Could not import beatmap set");
|
||||
}
|
||||
|
||||
// Batch commit with multiple sets to database
|
||||
Import(sets);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -236,6 +233,8 @@ namespace osu.Game.Database
|
||||
// TODO: Diff beatmap metadata with set metadata and leave it here if necessary
|
||||
beatmap.BeatmapInfo.Metadata = null;
|
||||
|
||||
beatmap.BeatmapInfo.StarDifficulty = beatmap.CalculateStarDifficulty();
|
||||
|
||||
beatmapSet.Beatmaps.Add(beatmap.BeatmapInfo);
|
||||
}
|
||||
beatmapSet.StoryboardFile = archive.StoryboardFilename;
|
||||
@ -329,7 +328,7 @@ namespace osu.Game.Database
|
||||
typeof(BeatmapSetInfo),
|
||||
typeof(BeatmapInfo),
|
||||
typeof(BeatmapMetadata),
|
||||
typeof(BaseDifficulty),
|
||||
typeof(BeatmapDifficulty),
|
||||
};
|
||||
|
||||
public void Update<T>(T record, bool cascade = true) where T : class
|
||||
|
@ -31,11 +31,11 @@ namespace osu.Game.Database
|
||||
[OneToOne(CascadeOperations = CascadeOperation.All)]
|
||||
public BeatmapMetadata Metadata { get; set; }
|
||||
|
||||
[ForeignKey(typeof(BaseDifficulty)), NotNull]
|
||||
[ForeignKey(typeof(BeatmapDifficulty)), NotNull]
|
||||
public int BaseDifficultyID { get; set; }
|
||||
|
||||
[OneToOne(CascadeOperations = CascadeOperation.All)]
|
||||
public BaseDifficulty BaseDifficulty { get; set; }
|
||||
public BeatmapDifficulty Difficulty { get; set; }
|
||||
|
||||
public string Path { get; set; }
|
||||
|
||||
@ -75,16 +75,7 @@ namespace osu.Game.Database
|
||||
// Metadata
|
||||
public string Version { get; set; }
|
||||
|
||||
private float starDifficulty = -1;
|
||||
public float StarDifficulty
|
||||
{
|
||||
get
|
||||
{
|
||||
return starDifficulty < 0 ? (BaseDifficulty?.OverallDifficulty ?? 5) : starDifficulty;
|
||||
}
|
||||
|
||||
set { starDifficulty = value; }
|
||||
}
|
||||
public double StarDifficulty { get; set; }
|
||||
|
||||
public bool Equals(BeatmapInfo other)
|
||||
{
|
||||
|
@ -2,6 +2,7 @@
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using SQLite.Net.Attributes;
|
||||
using SQLiteNetExtensions.Attributes;
|
||||
|
||||
@ -23,6 +24,8 @@ namespace osu.Game.Database
|
||||
[OneToMany(CascadeOperations = CascadeOperation.All)]
|
||||
public List<BeatmapInfo> Beatmaps { get; set; }
|
||||
|
||||
public double MaxStarDifficulty => Beatmaps.Max(b => b.StarDifficulty);
|
||||
|
||||
public bool DeletePending { get; set; }
|
||||
|
||||
public string Hash { get; set; }
|
||||
|
@ -39,9 +39,7 @@ namespace osu.Game.Database
|
||||
using (SerializationReader sr = new SerializationReader(s))
|
||||
{
|
||||
var ruleset = Ruleset.GetRuleset((PlayMode)sr.ReadByte());
|
||||
var processor = ruleset.CreateScoreProcessor();
|
||||
|
||||
score = processor.GetScore();
|
||||
score = ruleset.CreateScoreProcessor().CreateScore();
|
||||
|
||||
/* score.Pass = true;*/
|
||||
var version = sr.ReadInt32();
|
||||
|
@ -18,10 +18,10 @@ namespace osu.Game.Graphics.Containers
|
||||
|
||||
private Bindable<bool> parallaxEnabled;
|
||||
|
||||
public override bool Contains(Vector2 screenSpacePos) => true;
|
||||
|
||||
public ParallaxContainer()
|
||||
{
|
||||
AlwaysReceiveInput = true;
|
||||
|
||||
RelativeSizeAxes = Axes.Both;
|
||||
AddInternal(content = new Container
|
||||
{
|
||||
|
@ -18,7 +18,6 @@ namespace osu.Game.Graphics.Cursor
|
||||
{
|
||||
internal class CursorTrail : Drawable
|
||||
{
|
||||
public override bool Contains(Vector2 screenSpacePos) => true;
|
||||
public override bool HandleInput => true;
|
||||
|
||||
private int currentIndex;
|
||||
@ -59,6 +58,7 @@ namespace osu.Game.Graphics.Cursor
|
||||
|
||||
public CursorTrail()
|
||||
{
|
||||
AlwaysReceiveInput = true;
|
||||
RelativeSizeAxes = Axes.Both;
|
||||
|
||||
for (int i = 0; i < max_sprites; i++)
|
||||
|
131
osu.Game/Graphics/Cursor/GameplayCursor.cs
Normal file
131
osu.Game/Graphics/Cursor/GameplayCursor.cs
Normal file
@ -0,0 +1,131 @@
|
||||
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using OpenTK;
|
||||
using OpenTK.Graphics;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Configuration;
|
||||
using osu.Framework.Extensions.Color4Extensions;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Cursor;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Framework.Graphics.Transforms;
|
||||
using osu.Framework.Input;
|
||||
using osu.Game.Configuration;
|
||||
using System;
|
||||
|
||||
namespace osu.Game.Graphics.Cursor
|
||||
{
|
||||
public class GameplayCursor : CursorContainer
|
||||
{
|
||||
protected override Drawable CreateCursor() => new OsuCursor();
|
||||
|
||||
public GameplayCursor()
|
||||
{
|
||||
Add(new CursorTrail { Depth = 1 });
|
||||
}
|
||||
|
||||
protected override bool OnMouseDown(InputState state, MouseDownEventArgs args)
|
||||
{
|
||||
ActiveCursor.Scale = new Vector2(1);
|
||||
ActiveCursor.ScaleTo(1.2f, 100, EasingTypes.OutQuad);
|
||||
return base.OnMouseDown(state, args);
|
||||
}
|
||||
|
||||
protected override bool OnMouseUp(InputState state, MouseUpEventArgs args)
|
||||
{
|
||||
if (!state.Mouse.HasMainButtonPressed)
|
||||
ActiveCursor.ScaleTo(1, 200, EasingTypes.OutQuad);
|
||||
return base.OnMouseUp(state, args);
|
||||
}
|
||||
|
||||
public class OsuCursor : Container
|
||||
{
|
||||
private Container cursorContainer;
|
||||
private Bindable<double> cursorScale;
|
||||
|
||||
public OsuCursor()
|
||||
{
|
||||
Origin = Anchor.Centre;
|
||||
Size = new Vector2(42);
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuConfigManager config)
|
||||
{
|
||||
cursorScale = config.GetBindable<double>(OsuConfig.CursorSize);
|
||||
|
||||
Children = new Drawable[]
|
||||
{
|
||||
cursorContainer = new CircularContainer
|
||||
{
|
||||
Origin = Anchor.Centre,
|
||||
Anchor = Anchor.Centre,
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Scale = new Vector2((float)cursorScale),
|
||||
Masking = true,
|
||||
BorderThickness = Size.X / 6,
|
||||
BorderColour = Color4.White,
|
||||
EdgeEffect = new EdgeEffect
|
||||
{
|
||||
Type = EdgeEffectType.Shadow,
|
||||
Colour = Color4.Pink.Opacity(0.5f),
|
||||
Radius = 5,
|
||||
},
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Alpha = 0,
|
||||
AlwaysPresent = true,
|
||||
},
|
||||
new CircularContainer
|
||||
{
|
||||
Origin = Anchor.Centre,
|
||||
Anchor = Anchor.Centre,
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Masking = true,
|
||||
BorderThickness = Size.X / 3,
|
||||
BorderColour = Color4.White.Opacity(0.5f),
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Alpha = 0,
|
||||
AlwaysPresent = true,
|
||||
},
|
||||
},
|
||||
},
|
||||
new CircularContainer
|
||||
{
|
||||
Origin = Anchor.Centre,
|
||||
Anchor = Anchor.Centre,
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Scale = new Vector2(0.1f),
|
||||
Masking = true,
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Colour = Color4.White,
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
cursorScale.ValueChanged += scaleChanged;
|
||||
}
|
||||
|
||||
private void scaleChanged(object sender, EventArgs e)
|
||||
{
|
||||
cursorContainer.Scale = new Vector2((float)cursorScale);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
121
osu.Game/Graphics/Cursor/MenuCursor.cs
Normal file
121
osu.Game/Graphics/Cursor/MenuCursor.cs
Normal file
@ -0,0 +1,121 @@
|
||||
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using OpenTK;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Configuration;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Cursor;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Framework.Input;
|
||||
using osu.Game.Configuration;
|
||||
using System;
|
||||
using osu.Framework.Graphics.Textures;
|
||||
using osu.Framework.Graphics.Transforms;
|
||||
|
||||
namespace osu.Game.Graphics.Cursor
|
||||
{
|
||||
public class MenuCursor : CursorContainer
|
||||
{
|
||||
protected override Drawable CreateCursor() => new Cursor();
|
||||
|
||||
protected override bool OnMouseDown(InputState state, MouseDownEventArgs args)
|
||||
{
|
||||
ActiveCursor.Scale = new Vector2(1);
|
||||
ActiveCursor.ScaleTo(0.90f, 800, EasingTypes.OutQuint);
|
||||
|
||||
((Cursor)ActiveCursor).AdditiveLayer.Alpha = 0;
|
||||
((Cursor)ActiveCursor).AdditiveLayer.FadeInFromZero(800, EasingTypes.OutQuint);
|
||||
return base.OnMouseDown(state, args);
|
||||
}
|
||||
|
||||
protected override bool OnMouseUp(InputState state, MouseUpEventArgs args)
|
||||
{
|
||||
if (!state.Mouse.HasMainButtonPressed)
|
||||
{
|
||||
((Cursor)ActiveCursor).AdditiveLayer.FadeOut(500, EasingTypes.OutQuint);
|
||||
ActiveCursor.RotateTo(0, 200, EasingTypes.OutQuint);
|
||||
ActiveCursor.ScaleTo(1, 500, EasingTypes.OutElastic);
|
||||
}
|
||||
|
||||
return base.OnMouseUp(state, args);
|
||||
}
|
||||
|
||||
protected override bool OnClick(InputState state)
|
||||
{
|
||||
((Cursor)ActiveCursor).AdditiveLayer.FadeOutFromOne(500, EasingTypes.OutQuint);
|
||||
|
||||
return base.OnClick(state);
|
||||
}
|
||||
|
||||
protected override bool OnDragStart(InputState state)
|
||||
{
|
||||
ActiveCursor.RotateTo(-30, 600, EasingTypes.OutElastic);
|
||||
return base.OnDragStart(state);
|
||||
}
|
||||
|
||||
protected override void PopIn()
|
||||
{
|
||||
ActiveCursor.FadeTo(1, 250, EasingTypes.OutQuint);
|
||||
ActiveCursor.ScaleTo(1, 1000, EasingTypes.OutElastic);
|
||||
}
|
||||
|
||||
protected override void PopOut()
|
||||
{
|
||||
ActiveCursor.FadeTo(0, 1400, EasingTypes.OutQuint);
|
||||
ActiveCursor.ScaleTo(1.1f, 100, EasingTypes.Out);
|
||||
ActiveCursor.Delay(100);
|
||||
ActiveCursor.ScaleTo(0, 500, EasingTypes.In);
|
||||
}
|
||||
|
||||
public class Cursor : Container
|
||||
{
|
||||
private Container cursorContainer;
|
||||
private Bindable<double> cursorScale;
|
||||
|
||||
public Sprite AdditiveLayer;
|
||||
|
||||
public Cursor()
|
||||
{
|
||||
Size = new Vector2(42);
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuConfigManager config, TextureStore textures, OsuColour colour)
|
||||
{
|
||||
cursorScale = config.GetBindable<double>(OsuConfig.CursorSize);
|
||||
|
||||
Children = new Drawable[]
|
||||
{
|
||||
cursorContainer = new Container
|
||||
{
|
||||
Size = new Vector2(32),
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new Sprite
|
||||
{
|
||||
FillMode = FillMode.Fit,
|
||||
Texture = textures.Get(@"Cursor/menu-cursor"),
|
||||
},
|
||||
AdditiveLayer = new Sprite
|
||||
{
|
||||
FillMode = FillMode.Fit,
|
||||
BlendingMode = BlendingMode.Additive,
|
||||
Colour = colour.Pink,
|
||||
Alpha = 0,
|
||||
Texture = textures.Get(@"Cursor/menu-cursor-additive"),
|
||||
},
|
||||
}
|
||||
}
|
||||
};
|
||||
cursorScale.ValueChanged += scaleChanged;
|
||||
}
|
||||
|
||||
private void scaleChanged(object sender, EventArgs e)
|
||||
{
|
||||
cursorContainer.Scale = new Vector2((float)cursorScale);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -10,10 +10,9 @@ namespace osu.Game.Graphics.Processing
|
||||
{
|
||||
internal class RatioAdjust : Container
|
||||
{
|
||||
public override bool Contains(Vector2 screenSpacePos) => true;
|
||||
|
||||
public RatioAdjust()
|
||||
{
|
||||
AlwaysReceiveInput = true;
|
||||
RelativeSizeAxes = Axes.Both;
|
||||
}
|
||||
|
||||
|
@ -88,7 +88,7 @@ namespace osu.Game.Graphics.UserInterface
|
||||
|
||||
private bool didClick; // Used for making sure that the OnMouseDown animation can call instead of OnHoverLost's when clicking
|
||||
|
||||
public override bool Contains(Vector2 screenSpacePos) => backgroundContainer.Contains(screenSpacePos);
|
||||
protected override bool InternalContains(Vector2 screenSpacePos) => backgroundContainer.Contains(screenSpacePos);
|
||||
|
||||
protected override bool OnClick(Framework.Input.InputState state)
|
||||
{
|
||||
|
@ -21,6 +21,17 @@ namespace osu.Game.Graphics.UserInterface
|
||||
set { label.Text = value; }
|
||||
}
|
||||
|
||||
private Color4? accentColour;
|
||||
public virtual Color4 AccentColour
|
||||
{
|
||||
get { return accentColour.GetValueOrDefault(); }
|
||||
set
|
||||
{
|
||||
accentColour = value;
|
||||
BackgroundColourHover = value;
|
||||
}
|
||||
}
|
||||
|
||||
public OsuDropDownHeader()
|
||||
{
|
||||
Foreground.Padding = new MarginPadding(4);
|
||||
@ -30,7 +41,7 @@ namespace osu.Game.Graphics.UserInterface
|
||||
CornerRadius = 4;
|
||||
Height = 40;
|
||||
|
||||
Children = new[]
|
||||
Foreground.Children = new Drawable[]
|
||||
{
|
||||
label = new OsuSpriteText
|
||||
{
|
||||
@ -51,7 +62,7 @@ namespace osu.Game.Graphics.UserInterface
|
||||
private void load(OsuColour colours)
|
||||
{
|
||||
BackgroundColour = Color4.Black.Opacity(0.5f);
|
||||
BackgroundColourHover = colours.PinkDarker;
|
||||
BackgroundColourHover = accentColour ?? colours.PinkDarker;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,39 +1,61 @@
|
||||
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using osu.Framework.Graphics.Transforms;
|
||||
using osu.Framework.Graphics.UserInterface;
|
||||
using System.Linq;
|
||||
using osu.Framework.Allocation;
|
||||
using OpenTK;
|
||||
using OpenTK.Graphics;
|
||||
using osu.Framework.Extensions.Color4Extensions;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Primitives;
|
||||
using osu.Framework.Graphics.Transforms;
|
||||
using osu.Framework.Graphics.UserInterface;
|
||||
|
||||
namespace osu.Game.Graphics.UserInterface
|
||||
{
|
||||
public class OsuDropDownMenu<U> : DropDownMenu<U>
|
||||
public class OsuDropDownMenu<T> : DropDownMenu<T>
|
||||
{
|
||||
protected override DropDownHeader CreateHeader() => new OsuDropDownHeader();
|
||||
protected override DropDownHeader CreateHeader() => new OsuDropDownHeader { AccentColour = AccentColour };
|
||||
|
||||
private Color4? accentColour;
|
||||
public virtual Color4 AccentColour
|
||||
{
|
||||
get { return accentColour.GetValueOrDefault(); }
|
||||
set
|
||||
{
|
||||
accentColour = value;
|
||||
if (Header != null)
|
||||
((OsuDropDownHeader)Header).AccentColour = value;
|
||||
foreach (var item in ItemList.OfType<OsuDropDownMenuItem<T>>())
|
||||
item.AccentColour = value;
|
||||
}
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuColour colours)
|
||||
{
|
||||
if (accentColour == null)
|
||||
AccentColour = colours.PinkDarker;
|
||||
}
|
||||
|
||||
public OsuDropDownMenu()
|
||||
{
|
||||
ContentContainer.CornerRadius = 4;
|
||||
ContentBackground.Colour = Color4.Black.Opacity(0.5f);
|
||||
|
||||
DropDownItemsContainer.Padding = new MarginPadding(5);
|
||||
}
|
||||
|
||||
protected override void AnimateOpen()
|
||||
{
|
||||
ContentContainer.FadeIn(300, EasingTypes.OutQuint);
|
||||
}
|
||||
protected override void AnimateOpen() => ContentContainer.FadeIn(300, EasingTypes.OutQuint);
|
||||
|
||||
protected override void AnimateClose()
|
||||
{
|
||||
ContentContainer.FadeOut(300, EasingTypes.OutQuint);
|
||||
}
|
||||
protected override void AnimateClose() => ContentContainer.FadeOut(300, EasingTypes.OutQuint);
|
||||
|
||||
protected override void UpdateContentHeight()
|
||||
{
|
||||
ContentContainer.ResizeTo(State == DropDownMenuState.Opened ? new Vector2(1, ContentHeight) : new Vector2(1, 0), 300, EasingTypes.OutQuint);
|
||||
var actualHeight = (RelativeSizeAxes & Axes.Y) > 0 ? 1 : ContentHeight;
|
||||
ContentContainer.ResizeTo(new Vector2(1, State == DropDownMenuState.Opened ? actualHeight : 0), 300, EasingTypes.OutQuint);
|
||||
}
|
||||
|
||||
protected override DropDownMenuItem<U> CreateDropDownItem(string key, U value) => new OsuDropDownMenuItem<U>(key, value);
|
||||
protected override DropDownMenuItem<T> CreateDropDownItem(string key, T value) => new OsuDropDownMenuItem<T>(key, value) { AccentColour = AccentColour };
|
||||
}
|
||||
}
|
@ -18,6 +18,9 @@ namespace osu.Game.Graphics.UserInterface
|
||||
{
|
||||
Foreground.Padding = new MarginPadding(2);
|
||||
|
||||
Masking = true;
|
||||
CornerRadius = 6;
|
||||
|
||||
Children = new[]
|
||||
{
|
||||
new FillFlowContainer
|
||||
@ -27,12 +30,15 @@ namespace osu.Game.Graphics.UserInterface
|
||||
AutoSizeAxes = Axes.Y,
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new TextAwesome
|
||||
chevron = new TextAwesome
|
||||
{
|
||||
AlwaysPresent = true,
|
||||
Icon = FontAwesome.fa_chevron_right,
|
||||
UseFullGlyphHeight = false,
|
||||
Colour = Color4.Black,
|
||||
TextSize = 12,
|
||||
Margin = new MarginPadding { Right = 3 },
|
||||
Alpha = 0.5f,
|
||||
TextSize = 8,
|
||||
Margin = new MarginPadding { Left = 3, Right = 3 },
|
||||
Origin = Anchor.CentreLeft,
|
||||
Anchor = Anchor.CentreLeft,
|
||||
},
|
||||
@ -46,11 +52,33 @@ namespace osu.Game.Graphics.UserInterface
|
||||
};
|
||||
}
|
||||
|
||||
private Color4? accentColour;
|
||||
|
||||
private TextAwesome chevron;
|
||||
|
||||
protected override void FormatForeground(bool hover = false)
|
||||
{
|
||||
base.FormatForeground(hover);
|
||||
chevron.Alpha = hover ? 1 : 0;
|
||||
}
|
||||
|
||||
public Color4 AccentColour
|
||||
{
|
||||
get { return accentColour.GetValueOrDefault(); }
|
||||
set
|
||||
{
|
||||
accentColour = value;
|
||||
BackgroundColourHover = BackgroundColourSelected = value;
|
||||
FormatBackground();
|
||||
FormatForeground();
|
||||
}
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuColour colours)
|
||||
{
|
||||
BackgroundColour = Color4.Black.Opacity(0.5f);
|
||||
BackgroundColourHover = colours.PinkDarker;
|
||||
BackgroundColour = Color4.Transparent;
|
||||
BackgroundColourHover = accentColour ?? colours.PinkDarker;
|
||||
BackgroundColourSelected = Color4.Black.Opacity(0.5f);
|
||||
}
|
||||
}
|
||||
|
139
osu.Game/Graphics/UserInterface/OsuTabControl.cs
Normal file
139
osu.Game/Graphics/UserInterface/OsuTabControl.cs
Normal file
@ -0,0 +1,139 @@
|
||||
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using System;
|
||||
using System.Linq;
|
||||
using OpenTK;
|
||||
using OpenTK.Graphics;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Extensions.Color4Extensions;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Primitives;
|
||||
using osu.Framework.Graphics.UserInterface;
|
||||
using osu.Framework.Input;
|
||||
|
||||
namespace osu.Game.Graphics.UserInterface
|
||||
{
|
||||
public class OsuTabControl<T> : TabControl<T>
|
||||
{
|
||||
protected override DropDownMenu<T> CreateDropDownMenu() => new OsuTabDropDownMenu<T>();
|
||||
|
||||
protected override TabItem<T> CreateTabItem(T value) => new OsuTabItem<T> { Value = value };
|
||||
|
||||
protected override bool InternalContains(Vector2 screenSpacePos) => base.InternalContains(screenSpacePos) || DropDown.Contains(screenSpacePos);
|
||||
|
||||
public OsuTabControl()
|
||||
{
|
||||
if (!typeof(T).IsEnum)
|
||||
throw new InvalidOperationException("OsuTabControl only supports enums as the generic type argument");
|
||||
|
||||
foreach (var val in (T[])Enum.GetValues(typeof(T)))
|
||||
AddItem(val);
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuColour colours)
|
||||
{
|
||||
if (accentColour == null)
|
||||
AccentColour = colours.Blue;
|
||||
}
|
||||
|
||||
private Color4? accentColour;
|
||||
public Color4 AccentColour
|
||||
{
|
||||
get { return accentColour.GetValueOrDefault(); }
|
||||
set
|
||||
{
|
||||
accentColour = value;
|
||||
var dropDown = DropDown as OsuTabDropDownMenu<T>;
|
||||
if (dropDown != null)
|
||||
dropDown.AccentColour = value;
|
||||
foreach (var item in TabContainer.Children.OfType<OsuTabItem<T>>())
|
||||
item.AccentColour = value;
|
||||
}
|
||||
}
|
||||
|
||||
public class OsuTabDropDownMenu<T1> : OsuDropDownMenu<T1>
|
||||
{
|
||||
protected override DropDownHeader CreateHeader() => new OsuTabDropDownHeader
|
||||
{
|
||||
AccentColour = AccentColour,
|
||||
Anchor = Anchor.TopRight,
|
||||
Origin = Anchor.TopRight,
|
||||
};
|
||||
|
||||
protected override DropDownMenuItem<T1> CreateDropDownItem(string key, T1 value)
|
||||
{
|
||||
var item = base.CreateDropDownItem(key, value);
|
||||
item.ForegroundColourHover = Color4.Black;
|
||||
return item;
|
||||
}
|
||||
|
||||
public OsuTabDropDownMenu()
|
||||
{
|
||||
ContentContainer.Anchor = Anchor.TopRight;
|
||||
ContentContainer.Origin = Anchor.TopRight;
|
||||
|
||||
RelativeSizeAxes = Axes.X;
|
||||
|
||||
ContentBackground.Colour = Color4.Black.Opacity(0.7f);
|
||||
MaxDropDownHeight = 400;
|
||||
}
|
||||
|
||||
public class OsuTabDropDownHeader : OsuDropDownHeader
|
||||
{
|
||||
public override Color4 AccentColour
|
||||
{
|
||||
get { return base.AccentColour; }
|
||||
set
|
||||
{
|
||||
base.AccentColour = value;
|
||||
Foreground.Colour = value;
|
||||
}
|
||||
}
|
||||
|
||||
protected override bool OnHover(InputState state)
|
||||
{
|
||||
Foreground.Colour = BackgroundColour;
|
||||
return base.OnHover(state);
|
||||
}
|
||||
|
||||
protected override void OnHoverLost(InputState state)
|
||||
{
|
||||
Foreground.Colour = BackgroundColourHover;
|
||||
base.OnHoverLost(state);
|
||||
}
|
||||
|
||||
public OsuTabDropDownHeader()
|
||||
{
|
||||
RelativeSizeAxes = Axes.None;
|
||||
AutoSizeAxes = Axes.X;
|
||||
|
||||
BackgroundColour = Color4.Black.Opacity(0.5f);
|
||||
|
||||
Background.Height = 0.5f;
|
||||
Background.CornerRadius = 5;
|
||||
Background.Masking = true;
|
||||
|
||||
Foreground.RelativeSizeAxes = Axes.None;
|
||||
Foreground.AutoSizeAxes = Axes.X;
|
||||
Foreground.RelativeSizeAxes = Axes.Y;
|
||||
Foreground.Margin = new MarginPadding(5);
|
||||
|
||||
Foreground.Children = new Drawable[]
|
||||
{
|
||||
new TextAwesome
|
||||
{
|
||||
Icon = FontAwesome.fa_ellipsis_h,
|
||||
TextSize = 14,
|
||||
Origin = Anchor.Centre,
|
||||
Anchor = Anchor.Centre,
|
||||
}
|
||||
};
|
||||
|
||||
Padding = new MarginPadding { Left = 5, Right = 5 };
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
121
osu.Game/Graphics/UserInterface/OsuTabItem.cs
Normal file
121
osu.Game/Graphics/UserInterface/OsuTabItem.cs
Normal file
@ -0,0 +1,121 @@
|
||||
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using System;
|
||||
using OpenTK.Graphics;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Extensions;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Primitives;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Framework.Graphics.Transforms;
|
||||
using osu.Framework.Graphics.UserInterface;
|
||||
using osu.Framework.Input;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
|
||||
namespace osu.Game.Graphics.UserInterface
|
||||
{
|
||||
public class OsuTabItem<T> : TabItem<T>
|
||||
{
|
||||
private SpriteText text;
|
||||
private Box box;
|
||||
|
||||
private Color4? accentColour;
|
||||
public Color4 AccentColour
|
||||
{
|
||||
get { return accentColour.GetValueOrDefault(); }
|
||||
set
|
||||
{
|
||||
accentColour = value;
|
||||
if (!Active)
|
||||
text.Colour = value;
|
||||
}
|
||||
}
|
||||
|
||||
public new T Value
|
||||
{
|
||||
get { return base.Value; }
|
||||
set
|
||||
{
|
||||
base.Value = value;
|
||||
text.Text = (value as Enum)?.GetDescription();
|
||||
}
|
||||
}
|
||||
|
||||
public override bool Active
|
||||
{
|
||||
get { return base.Active; }
|
||||
set
|
||||
{
|
||||
if (Active == value) return;
|
||||
|
||||
if (value)
|
||||
fadeActive();
|
||||
else
|
||||
fadeInactive();
|
||||
base.Active = value;
|
||||
}
|
||||
}
|
||||
|
||||
private const float transition_length = 500;
|
||||
|
||||
private void fadeActive()
|
||||
{
|
||||
box.FadeIn(transition_length, EasingTypes.OutQuint);
|
||||
text.FadeColour(Color4.White, transition_length, EasingTypes.OutQuint);
|
||||
}
|
||||
|
||||
private void fadeInactive()
|
||||
{
|
||||
box.FadeOut(transition_length, EasingTypes.OutQuint);
|
||||
text.FadeColour(AccentColour, transition_length, EasingTypes.OutQuint);
|
||||
}
|
||||
|
||||
protected override bool OnHover(InputState state)
|
||||
{
|
||||
if (!Active)
|
||||
fadeActive();
|
||||
return true;
|
||||
}
|
||||
|
||||
protected override void OnHoverLost(InputState state)
|
||||
{
|
||||
if (!Active)
|
||||
fadeInactive();
|
||||
}
|
||||
|
||||
public OsuTabItem()
|
||||
{
|
||||
AutoSizeAxes = Axes.X;
|
||||
RelativeSizeAxes = Axes.Y;
|
||||
|
||||
Children = new Drawable[]
|
||||
{
|
||||
text = new OsuSpriteText
|
||||
{
|
||||
Margin = new MarginPadding(5),
|
||||
Origin = Anchor.BottomLeft,
|
||||
Anchor = Anchor.BottomLeft,
|
||||
TextSize = 14,
|
||||
Font = @"Exo2.0-Bold", // Font should only turn bold when active?
|
||||
},
|
||||
box = new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
Height = 1,
|
||||
Alpha = 0,
|
||||
Colour = Color4.White,
|
||||
Origin = Anchor.BottomLeft,
|
||||
Anchor = Anchor.BottomLeft,
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuColour colours)
|
||||
{
|
||||
if (accentColour == null)
|
||||
AccentColour = colours.Blue;
|
||||
}
|
||||
}
|
||||
}
|
@ -158,7 +158,7 @@ namespace osu.Game.Graphics.UserInterface
|
||||
}
|
||||
}
|
||||
|
||||
public override bool Contains(Vector2 screenSpacePos) => IconLayer.Contains(screenSpacePos) || TextLayer.Contains(screenSpacePos);
|
||||
protected override bool InternalContains(Vector2 screenSpacePos) => IconLayer.Contains(screenSpacePos) || TextLayer.Contains(screenSpacePos);
|
||||
|
||||
protected override bool OnHover(InputState state)
|
||||
{
|
||||
|
@ -2,6 +2,8 @@
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using osu.Game.Beatmaps.Samples;
|
||||
using osu.Game.Beatmaps.Timing;
|
||||
using osu.Game.Database;
|
||||
|
||||
namespace osu.Game.Modes.Objects
|
||||
{
|
||||
@ -22,5 +24,12 @@ namespace osu.Game.Modes.Objects
|
||||
/// The sample to be played when this HitObject is hit.
|
||||
/// </summary>
|
||||
public HitSampleInfo Sample { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Applies default values to this HitObject.
|
||||
/// </summary>
|
||||
/// <param name="difficulty">The difficulty settings to use.</param>
|
||||
/// <param name="timing">The timing settings to use.</param>
|
||||
public virtual void ApplyDefaults(TimingInfo timing, BeatmapDifficulty difficulty) { }
|
||||
}
|
||||
}
|
||||
|
@ -29,12 +29,12 @@ namespace osu.Game.Modes
|
||||
|
||||
public abstract IEnumerable<Mod> GetModsFor(ModType type);
|
||||
|
||||
public abstract ScoreProcessor CreateScoreProcessor(int hitObjectCount = 0);
|
||||
|
||||
public abstract HitRenderer CreateHitRendererWith(WorkingBeatmap beatmap);
|
||||
|
||||
public abstract DifficultyCalculator CreateDifficultyCalculator(Beatmap beatmap);
|
||||
|
||||
public abstract ScoreProcessor CreateScoreProcessor();
|
||||
|
||||
public static void Register(Ruleset ruleset) => availableRulesets.TryAdd(ruleset.PlayMode, ruleset.GetType());
|
||||
|
||||
protected abstract PlayMode PlayMode { get; }
|
||||
|
164
osu.Game/Modes/ScoreProcessor.cs
Normal file
164
osu.Game/Modes/ScoreProcessor.cs
Normal file
@ -0,0 +1,164 @@
|
||||
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using osu.Framework.Configuration;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using osu.Game.Modes.Judgements;
|
||||
using osu.Game.Modes.UI;
|
||||
using osu.Game.Modes.Objects;
|
||||
using osu.Game.Beatmaps;
|
||||
|
||||
namespace osu.Game.Modes
|
||||
{
|
||||
public abstract class ScoreProcessor
|
||||
{
|
||||
/// <summary>
|
||||
/// Invoked when the ScoreProcessor is in a failed state.
|
||||
/// </summary>
|
||||
public event Action Failed;
|
||||
|
||||
/// <summary>
|
||||
/// The current total score.
|
||||
/// </summary>
|
||||
public readonly BindableDouble TotalScore = new BindableDouble { MinValue = 0 };
|
||||
|
||||
/// <summary>
|
||||
/// The current accuracy.
|
||||
/// </summary>
|
||||
public readonly BindableDouble Accuracy = new BindableDouble { MinValue = 0, MaxValue = 1 };
|
||||
|
||||
/// <summary>
|
||||
/// The current health.
|
||||
/// </summary>
|
||||
public readonly BindableDouble Health = new BindableDouble { MinValue = 0, MaxValue = 1 };
|
||||
|
||||
/// <summary>
|
||||
/// The current combo.
|
||||
/// </summary>
|
||||
public readonly BindableInt Combo = new BindableInt();
|
||||
|
||||
/// <summary>
|
||||
/// THe highest combo achieved by this score.
|
||||
/// </summary>
|
||||
public readonly BindableInt HighestCombo = new BindableInt();
|
||||
|
||||
/// <summary>
|
||||
/// Whether the score is in a failed state.
|
||||
/// </summary>
|
||||
public virtual bool HasFailed => false;
|
||||
|
||||
/// <summary>
|
||||
/// Whether this ScoreProcessor has already triggered the failed state.
|
||||
/// </summary>
|
||||
private bool alreadyFailed;
|
||||
|
||||
protected ScoreProcessor()
|
||||
{
|
||||
Combo.ValueChanged += delegate { HighestCombo.Value = Math.Max(HighestCombo.Value, Combo.Value); };
|
||||
|
||||
Reset();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a Score applicable to the game mode in which this ScoreProcessor resides.
|
||||
/// </summary>
|
||||
/// <returns>The Score.</returns>
|
||||
public virtual Score CreateScore() => new Score
|
||||
{
|
||||
TotalScore = TotalScore,
|
||||
Combo = Combo,
|
||||
MaxCombo = HighestCombo,
|
||||
Accuracy = Accuracy,
|
||||
Health = Health,
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// Resets this ScoreProcessor to a default state.
|
||||
/// </summary>
|
||||
protected virtual void Reset()
|
||||
{
|
||||
TotalScore.Value = 0;
|
||||
Accuracy.Value = 0;
|
||||
Health.Value = 0;
|
||||
Combo.Value = 0;
|
||||
HighestCombo.Value = 0;
|
||||
|
||||
alreadyFailed = false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks if the score is in a failed state and notifies subscribers.
|
||||
/// <para>
|
||||
/// This can only ever notify subscribers once.
|
||||
/// </para>
|
||||
/// </summary>
|
||||
protected void UpdateFailed()
|
||||
{
|
||||
if (alreadyFailed || !HasFailed)
|
||||
return;
|
||||
|
||||
alreadyFailed = true;
|
||||
Failed?.Invoke();
|
||||
}
|
||||
}
|
||||
|
||||
public abstract class ScoreProcessor<TObject, TJudgement> : ScoreProcessor
|
||||
where TObject : HitObject
|
||||
where TJudgement : JudgementInfo
|
||||
{
|
||||
/// <summary>
|
||||
/// All judgements held by this ScoreProcessor.
|
||||
/// </summary>
|
||||
protected readonly List<TJudgement> Judgements = new List<TJudgement>();
|
||||
|
||||
public override bool HasFailed => Health.Value == Health.MinValue;
|
||||
|
||||
protected ScoreProcessor()
|
||||
{
|
||||
}
|
||||
|
||||
protected ScoreProcessor(HitRenderer<TObject, TJudgement> hitRenderer)
|
||||
{
|
||||
Judgements.Capacity = hitRenderer.Beatmap.HitObjects.Count;
|
||||
|
||||
hitRenderer.OnJudgement += addJudgement;
|
||||
|
||||
ComputeTargets(hitRenderer.Beatmap);
|
||||
|
||||
Reset();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Computes target scoring values for this ScoreProcessor. This is equivalent to performing an auto-play of the score to find the values.
|
||||
/// </summary>
|
||||
/// <param name="beatmap">The Beatmap containing the objects that will be judged by this ScoreProcessor.</param>
|
||||
protected virtual void ComputeTargets(Beatmap<TObject> beatmap) { }
|
||||
|
||||
/// <summary>
|
||||
/// Adds a judgement to this ScoreProcessor.
|
||||
/// </summary>
|
||||
/// <param name="judgement">The judgement to add.</param>
|
||||
private void addJudgement(TJudgement judgement)
|
||||
{
|
||||
Judgements.Add(judgement);
|
||||
|
||||
UpdateCalculations(judgement);
|
||||
|
||||
judgement.ComboAtHit = (ulong)Combo.Value;
|
||||
|
||||
UpdateFailed();
|
||||
}
|
||||
|
||||
protected override void Reset()
|
||||
{
|
||||
Judgements.Clear();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Update any values that potentially need post-processing on a judgement change.
|
||||
/// </summary>
|
||||
/// <param name="newJudgement">A new JudgementInfo that triggered this calculation. May be null.</param>
|
||||
protected abstract void UpdateCalculations(TJudgement newJudgement);
|
||||
}
|
||||
}
|
@ -1,80 +0,0 @@
|
||||
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using osu.Framework.Configuration;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using osu.Game.Modes.Judgements;
|
||||
|
||||
namespace osu.Game.Modes
|
||||
{
|
||||
public abstract class ScoreProcessor
|
||||
{
|
||||
public virtual Score GetScore() => new Score
|
||||
{
|
||||
TotalScore = TotalScore,
|
||||
Combo = Combo,
|
||||
MaxCombo = HighestCombo,
|
||||
Accuracy = Accuracy,
|
||||
Health = Health,
|
||||
};
|
||||
|
||||
public readonly BindableDouble TotalScore = new BindableDouble { MinValue = 0 };
|
||||
|
||||
public readonly BindableDouble Accuracy = new BindableDouble { MinValue = 0, MaxValue = 1 };
|
||||
|
||||
public readonly BindableDouble Health = new BindableDouble { MinValue = 0, MaxValue = 1 };
|
||||
|
||||
public readonly BindableInt Combo = new BindableInt();
|
||||
|
||||
/// <summary>
|
||||
/// Are we allowed to fail?
|
||||
/// </summary>
|
||||
protected bool CanFail => true;
|
||||
|
||||
protected bool HasFailed { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Called when we reach a failing health of zero.
|
||||
/// </summary>
|
||||
public event Action Failed;
|
||||
|
||||
/// <summary>
|
||||
/// Keeps track of the highest combo ever achieved in this play.
|
||||
/// This is handled automatically by ScoreProcessor.
|
||||
/// </summary>
|
||||
public readonly BindableInt HighestCombo = new BindableInt();
|
||||
|
||||
public readonly List<JudgementInfo> Judgements;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ScoreProcessor"/> class.
|
||||
/// </summary>
|
||||
/// <param name="hitObjectCount">Number of HitObjects. It is used for specifying Judgements collection Capacity</param>
|
||||
protected ScoreProcessor(int hitObjectCount = 0)
|
||||
{
|
||||
Combo.ValueChanged += delegate { HighestCombo.Value = Math.Max(HighestCombo.Value, Combo.Value); };
|
||||
Judgements = new List<JudgementInfo>(hitObjectCount);
|
||||
}
|
||||
|
||||
public void AddJudgement(JudgementInfo judgement)
|
||||
{
|
||||
Judgements.Add(judgement);
|
||||
|
||||
UpdateCalculations(judgement);
|
||||
|
||||
judgement.ComboAtHit = (ulong)Combo.Value;
|
||||
if (Health.Value == Health.MinValue && !HasFailed)
|
||||
{
|
||||
HasFailed = true;
|
||||
Failed?.Invoke();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Update any values that potentially need post-processing on a judgement change.
|
||||
/// </summary>
|
||||
/// <param name="newJudgement">A new JudgementInfo that triggered this calculation. May be null.</param>
|
||||
protected abstract void UpdateCalculations(JudgementInfo newJudgement);
|
||||
}
|
||||
}
|
@ -26,12 +26,7 @@ namespace osu.Game.Modes.UI
|
||||
public abstract class HitRenderer : Container
|
||||
{
|
||||
/// <summary>
|
||||
/// The event that's fired when a hit object is judged.
|
||||
/// </summary>
|
||||
public event Action<JudgementInfo> OnJudgement;
|
||||
|
||||
/// <summary>
|
||||
/// The event that's fired when all hit objects have been judged.
|
||||
/// Invoked when all the judgeable HitObjects have been judged.
|
||||
/// </summary>
|
||||
public event Action OnAllJudged;
|
||||
|
||||
@ -57,17 +52,16 @@ namespace osu.Game.Modes.UI
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Triggers a judgement for further processing.
|
||||
/// Checks whether all HitObjects have been judged, and invokes OnAllJudged.
|
||||
/// </summary>
|
||||
/// <param name="j">The judgement to trigger.</param>
|
||||
protected void TriggerOnJudgement(JudgementInfo j)
|
||||
protected void CheckAllJudged()
|
||||
{
|
||||
OnJudgement?.Invoke(j);
|
||||
|
||||
if (AllObjectsJudged)
|
||||
OnAllJudged?.Invoke();
|
||||
}
|
||||
|
||||
public abstract ScoreProcessor CreateScoreProcessor();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a key conversion input manager.
|
||||
/// </summary>
|
||||
@ -95,16 +89,26 @@ namespace osu.Game.Modes.UI
|
||||
{
|
||||
Debug.Assert(beatmap != null, "HitRenderer initialized with a null beatmap.");
|
||||
|
||||
// Convert + process the beatmap
|
||||
Beatmap = CreateBeatmapConverter().Convert(beatmap.Beatmap);
|
||||
Beatmap.HitObjects.ForEach(h => CreateBeatmapProcessor().SetDefaults(h, Beatmap));
|
||||
CreateBeatmapProcessor().PostProcess(Beatmap);
|
||||
|
||||
applyMods(beatmap.Mods.Value);
|
||||
|
||||
RelativeSizeAxes = Axes.Both;
|
||||
|
||||
IBeatmapConverter<TObject> converter = CreateBeatmapConverter();
|
||||
IBeatmapProcessor<TObject> processor = CreateBeatmapProcessor();
|
||||
|
||||
// Convert the beatmap
|
||||
Beatmap = converter.Convert(beatmap.Beatmap);
|
||||
|
||||
// Apply defaults
|
||||
foreach (var h in Beatmap.HitObjects)
|
||||
h.ApplyDefaults(Beatmap.TimingInfo, Beatmap.BeatmapInfo.Difficulty);
|
||||
|
||||
// Post-process the beatmap
|
||||
processor.PostProcess(Beatmap);
|
||||
|
||||
// Add mods, should always be the last thing applied to give full control to mods
|
||||
applyMods(beatmap.Mods.Value);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Applies the active mods to this HitRenderer.
|
||||
/// </summary>
|
||||
@ -141,6 +145,8 @@ namespace osu.Game.Modes.UI
|
||||
where TObject : HitObject
|
||||
where TJudgement : JudgementInfo
|
||||
{
|
||||
public event Action<TJudgement> OnJudgement;
|
||||
|
||||
protected override Container<Drawable> Content => content;
|
||||
protected override bool AllObjectsJudged => Playfield.HitObjects.Children.All(h => h.Judgement.Result.HasValue);
|
||||
|
||||
@ -197,8 +203,11 @@ namespace osu.Game.Modes.UI
|
||||
/// <param name="judgedObject">The object that Judgement has been updated for.</param>
|
||||
private void onJudgement(DrawableHitObject<TObject, TJudgement> judgedObject)
|
||||
{
|
||||
TriggerOnJudgement(judgedObject.Judgement);
|
||||
Playfield.OnJudgement(judgedObject);
|
||||
|
||||
OnJudgement?.Invoke(judgedObject.Judgement);
|
||||
|
||||
CheckAllJudged();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -18,7 +18,6 @@ namespace osu.Game.Modes.UI
|
||||
/// The HitObjects contained in this Playfield.
|
||||
/// </summary>
|
||||
public HitObjectContainer<DrawableHitObject<TObject, TJudgement>> HitObjects;
|
||||
public override bool Contains(Vector2 screenSpacePos) => true;
|
||||
|
||||
internal Container<Drawable> ScaledContent;
|
||||
|
||||
@ -31,6 +30,8 @@ namespace osu.Game.Modes.UI
|
||||
/// <param name="customWidth">Whether we want our internal coordinate system to be scaled to a specified width.</param>
|
||||
protected Playfield(float? customWidth = null)
|
||||
{
|
||||
AlwaysReceiveInput = true;
|
||||
|
||||
AddInternal(ScaledContent = new ScaledContainer
|
||||
{
|
||||
CustomWidth = customWidth,
|
||||
@ -77,12 +78,18 @@ namespace osu.Game.Modes.UI
|
||||
//dividing by the customwidth will effectively scale our content to the required container size.
|
||||
protected override Vector2 DrawScale => CustomWidth.HasValue ? new Vector2(DrawSize.X / CustomWidth.Value) : base.DrawScale;
|
||||
|
||||
public override bool Contains(Vector2 screenSpacePos) => true;
|
||||
public ScaledContainer()
|
||||
{
|
||||
AlwaysReceiveInput = true;
|
||||
}
|
||||
}
|
||||
|
||||
public class HitObjectContainer<U> : Container<U> where U : Drawable
|
||||
{
|
||||
public override bool Contains(Vector2 screenSpacePos) => true;
|
||||
public HitObjectContainer()
|
||||
{
|
||||
AlwaysReceiveInput = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -220,7 +220,7 @@ namespace osu.Game
|
||||
}
|
||||
};
|
||||
|
||||
Cursor.Alpha = 0;
|
||||
Cursor.State = Visibility.Hidden;
|
||||
}
|
||||
|
||||
private bool globalHotkeyPressed(InputState state, KeyDownEventArgs args)
|
||||
@ -264,10 +264,20 @@ namespace osu.Game
|
||||
|
||||
private Container overlayContent;
|
||||
|
||||
private OsuScreen currentScreen;
|
||||
|
||||
private void screenChanged(Screen newScreen)
|
||||
{
|
||||
currentScreen = newScreen as OsuScreen;
|
||||
|
||||
if (currentScreen == null)
|
||||
{
|
||||
Exit();
|
||||
return;
|
||||
}
|
||||
|
||||
//central game mode change logic.
|
||||
if ((newScreen as OsuScreen)?.ShowOverlays != true)
|
||||
if (!currentScreen.ShowOverlays)
|
||||
{
|
||||
Toolbar.State = Visibility.Hidden;
|
||||
musicController.State = Visibility.Hidden;
|
||||
@ -278,13 +288,7 @@ namespace osu.Game
|
||||
Toolbar.State = Visibility.Visible;
|
||||
}
|
||||
|
||||
if (newScreen is MainMenu)
|
||||
Cursor.FadeIn(100);
|
||||
|
||||
ScreenChanged?.Invoke(newScreen);
|
||||
|
||||
if (newScreen == null)
|
||||
Exit();
|
||||
}
|
||||
|
||||
protected override bool OnExiting()
|
||||
@ -308,6 +312,8 @@ namespace osu.Game
|
||||
|
||||
if (intro?.ChildScreen != null)
|
||||
intro.ChildScreen.Padding = new MarginPadding { Top = Toolbar.Position.Y + Toolbar.DrawHeight };
|
||||
|
||||
Cursor.State = currentScreen == null || currentScreen.HasLocalCursorDisplayed ? Visibility.Hidden : Visibility.Visible;
|
||||
}
|
||||
|
||||
private void screenAdded(Screen newScreen)
|
||||
|
@ -8,7 +8,6 @@ using osu.Framework.Allocation;
|
||||
using osu.Framework.Configuration;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Cursor;
|
||||
using osu.Framework.IO.Stores;
|
||||
using osu.Framework.Platform;
|
||||
using osu.Game.Beatmaps;
|
||||
@ -38,7 +37,7 @@ namespace osu.Game
|
||||
|
||||
private RatioAdjust ratioContainer;
|
||||
|
||||
protected CursorContainer Cursor;
|
||||
protected MenuCursor Cursor;
|
||||
|
||||
public readonly Bindable<WorkingBeatmap> Beatmap = new Bindable<WorkingBeatmap>();
|
||||
|
||||
@ -137,7 +136,7 @@ namespace osu.Game
|
||||
{
|
||||
Children = new[]
|
||||
{
|
||||
Cursor = new OsuCursorContainer { Depth = float.MinValue }
|
||||
Cursor = new MenuCursor { Depth = float.MinValue }
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -35,10 +35,10 @@ namespace osu.Game.Overlays.Toolbar
|
||||
private const float alpha_hovering = 0.8f;
|
||||
private const float alpha_normal = 0.6f;
|
||||
|
||||
public override bool Contains(Vector2 screenSpacePos) => true;
|
||||
|
||||
public Toolbar()
|
||||
{
|
||||
AlwaysReceiveInput = true;
|
||||
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new ToolbarBackground(),
|
||||
@ -63,8 +63,9 @@ namespace osu.Game.Overlays.Toolbar
|
||||
}
|
||||
}
|
||||
},
|
||||
new PassThroughFlowContainer
|
||||
new FillFlowContainer
|
||||
{
|
||||
AlwaysReceiveInput = true,
|
||||
Anchor = Anchor.TopRight,
|
||||
Origin = Anchor.TopRight,
|
||||
Direction = FillDirection.Horizontal,
|
||||
@ -144,11 +145,5 @@ namespace osu.Game.Overlays.Toolbar
|
||||
MoveToY(-DrawSize.Y, transition_time, EasingTypes.OutQuint);
|
||||
FadeOut(transition_time);
|
||||
}
|
||||
|
||||
private class PassThroughFlowContainer : FillFlowContainer
|
||||
{
|
||||
//needed to get input to the login overlay.
|
||||
public override bool Contains(Vector2 screenSpacePos) => true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -15,10 +15,10 @@ namespace osu.Game.Overlays.Toolbar
|
||||
|
||||
public override RectangleF BoundingBox => button.BoundingBox;
|
||||
|
||||
public override bool Contains(Vector2 screenSpacePos) => true;
|
||||
|
||||
public ToolbarUserArea()
|
||||
{
|
||||
AlwaysReceiveInput = true;
|
||||
|
||||
RelativeSizeAxes = Axes.Y;
|
||||
AutoSizeAxes = Axes.X;
|
||||
|
||||
|
@ -35,10 +35,7 @@ namespace osu.Game.Screens.Menu
|
||||
private Key triggerKey;
|
||||
private SampleChannel sampleClick;
|
||||
|
||||
public override bool Contains(Vector2 screenSpacePos)
|
||||
{
|
||||
return box.Contains(screenSpacePos);
|
||||
}
|
||||
protected override bool InternalContains(Vector2 screenSpacePos) => box.Contains(screenSpacePos);
|
||||
|
||||
public Button(string text, string internalName, FontAwesome symbol, Color4 colour, Action clickAction = null, float extraWidth = 0, Key triggerKey = Key.Unknown)
|
||||
{
|
||||
|
@ -21,6 +21,8 @@ namespace osu.Game.Screens.Menu
|
||||
|
||||
internal override bool ShowOverlays => false;
|
||||
|
||||
internal override bool HasLocalCursorDisplayed => false;
|
||||
|
||||
public Disclaimer()
|
||||
{
|
||||
ValidForResume = false;
|
||||
|
@ -28,6 +28,8 @@ namespace osu.Game.Screens.Menu
|
||||
private SampleChannel seeya;
|
||||
private Track bgm;
|
||||
|
||||
internal override bool HasLocalCursorDisplayed => true;
|
||||
|
||||
internal override bool ShowOverlays => false;
|
||||
|
||||
protected override BackgroundScreen CreateBackground() => new BackgroundScreenEmpty();
|
||||
|
@ -27,6 +27,7 @@ namespace osu.Game.Screens.Menu
|
||||
internal override bool ShowOverlays => buttons.State != MenuState.Initial;
|
||||
|
||||
private BackgroundScreen background;
|
||||
private Screen songSelect;
|
||||
|
||||
protected override BackgroundScreen CreateBackground() => background;
|
||||
|
||||
@ -46,7 +47,7 @@ namespace osu.Game.Screens.Menu
|
||||
OnChart = delegate { Push(new ChartListing()); },
|
||||
OnDirect = delegate { Push(new OnlineListing()); },
|
||||
OnEdit = delegate { Push(new Editor()); },
|
||||
OnSolo = delegate { Push(new PlaySongSelect()); },
|
||||
OnSolo = delegate { Push(consumeSongSelect()); },
|
||||
OnMulti = delegate { Push(new Lobby()); },
|
||||
OnTest = delegate { Push(new TestBrowser()); },
|
||||
OnExit = delegate { Exit(); },
|
||||
@ -62,6 +63,24 @@ namespace osu.Game.Screens.Menu
|
||||
background.LoadAsync(game);
|
||||
|
||||
buttons.OnSettings = game.ToggleOptions;
|
||||
|
||||
preloadSongSelect();
|
||||
}
|
||||
|
||||
private void preloadSongSelect()
|
||||
{
|
||||
if (songSelect == null)
|
||||
{
|
||||
songSelect = new PlaySongSelect();
|
||||
songSelect.LoadAsync(Game);
|
||||
}
|
||||
}
|
||||
|
||||
private Screen consumeSongSelect()
|
||||
{
|
||||
var s = songSelect;
|
||||
songSelect = null;
|
||||
return s;
|
||||
}
|
||||
|
||||
protected override void OnEntering(Screen last)
|
||||
@ -86,6 +105,9 @@ namespace osu.Game.Screens.Menu
|
||||
{
|
||||
base.OnResuming(last);
|
||||
|
||||
//we may have consumed our preloaded instance, so let's make another.
|
||||
preloadSongSelect();
|
||||
|
||||
const float length = 300;
|
||||
|
||||
buttons.State = MenuState.TopLevel;
|
||||
|
@ -50,10 +50,7 @@ namespace osu.Game.Screens.Menu
|
||||
}
|
||||
}
|
||||
|
||||
public override bool Contains(Vector2 screenSpacePos)
|
||||
{
|
||||
return logoContainer.Contains(screenSpacePos);
|
||||
}
|
||||
protected override bool InternalContains(Vector2 screenSpacePos) => logoContainer.Contains(screenSpacePos);
|
||||
|
||||
public bool Ripple
|
||||
{
|
||||
|
@ -24,6 +24,8 @@ namespace osu.Game.Screens
|
||||
|
||||
protected new OsuGameBase Game => base.Game as OsuGameBase;
|
||||
|
||||
internal virtual bool HasLocalCursorDisplayed => false;
|
||||
|
||||
private readonly Bindable<WorkingBeatmap> beatmap = new Bindable<WorkingBeatmap>();
|
||||
|
||||
public WorkingBeatmap Beatmap
|
||||
|
@ -4,7 +4,6 @@
|
||||
using System.Linq;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using OpenTK;
|
||||
using OpenTK.Graphics;
|
||||
using osu.Framework.Input;
|
||||
|
||||
@ -14,6 +13,8 @@ namespace osu.Game.Screens.Play
|
||||
{
|
||||
public KeyCounterCollection()
|
||||
{
|
||||
AlwaysReceiveInput = true;
|
||||
|
||||
Direction = FillDirection.Horizontal;
|
||||
AutoSizeAxes = Axes.Both;
|
||||
}
|
||||
@ -33,8 +34,6 @@ namespace osu.Game.Screens.Play
|
||||
counter.ResetCount();
|
||||
}
|
||||
|
||||
public override bool Contains(Vector2 screenSpacePos) => true;
|
||||
|
||||
//further: change default values here and in KeyCounter if needed, instead of passing them in every constructor
|
||||
private bool isCounting;
|
||||
public bool IsCounting
|
||||
@ -111,12 +110,11 @@ namespace osu.Game.Screens.Play
|
||||
|
||||
public Receptor(KeyCounterCollection target)
|
||||
{
|
||||
AlwaysReceiveInput = true;
|
||||
RelativeSizeAxes = Axes.Both;
|
||||
this.target = target;
|
||||
}
|
||||
|
||||
public override bool Contains(Vector2 screenSpacePos) => true;
|
||||
|
||||
public override bool HandleInput => true;
|
||||
|
||||
protected override bool OnKeyDown(InputState state, KeyDownEventArgs args) => target.Children.Any(c => c.TriggerKeyDown(state, args));
|
||||
|
@ -2,7 +2,6 @@
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using osu.Framework.Input;
|
||||
using OpenTK;
|
||||
using OpenTK.Input;
|
||||
|
||||
namespace osu.Game.Screens.Play
|
||||
@ -13,6 +12,7 @@ namespace osu.Game.Screens.Play
|
||||
|
||||
public KeyCounterMouse(MouseButton button) : base(getStringRepresentation(button))
|
||||
{
|
||||
AlwaysReceiveInput = true;
|
||||
Button = button;
|
||||
}
|
||||
|
||||
@ -29,8 +29,6 @@ namespace osu.Game.Screens.Play
|
||||
}
|
||||
}
|
||||
|
||||
public override bool Contains(Vector2 screenSpacePos) => true;
|
||||
|
||||
protected override bool OnMouseDown(InputState state, MouseDownEventArgs args)
|
||||
{
|
||||
if (args.Button == Button) IsLit = true;
|
||||
|
@ -70,7 +70,6 @@ namespace osu.Game.Screens.Play
|
||||
|
||||
private FillFlowContainer retryCounterContainer;
|
||||
|
||||
public override bool Contains(Vector2 screenSpacePos) => true;
|
||||
public override bool HandleInput => State == Visibility.Visible;
|
||||
|
||||
protected override void PopIn() => FadeIn(transition_duration, EasingTypes.In);
|
||||
@ -79,6 +78,8 @@ namespace osu.Game.Screens.Play
|
||||
// Don't let mouse down events through the overlay or people can click circles while paused.
|
||||
protected override bool OnMouseDown(InputState state, MouseDownEventArgs args) => true;
|
||||
|
||||
protected override bool OnMouseMove(InputState state) => true;
|
||||
|
||||
protected override bool OnKeyDown(InputState state, KeyDownEventArgs args)
|
||||
{
|
||||
if (args.Key == Key.Escape)
|
||||
@ -217,6 +218,7 @@ namespace osu.Game.Screens.Play
|
||||
|
||||
public PauseOverlay()
|
||||
{
|
||||
AlwaysReceiveInput = true;
|
||||
RelativeSizeAxes = Axes.Both;
|
||||
}
|
||||
}
|
||||
|
@ -32,6 +32,10 @@ namespace osu.Game.Screens.Play
|
||||
|
||||
internal override bool ShowOverlays => false;
|
||||
|
||||
internal override bool HasLocalCursorDisplayed => !hasReplayLoaded && !IsPaused;
|
||||
|
||||
private bool hasReplayLoaded => hitRenderer.InputManager.ReplayInputHandler != null;
|
||||
|
||||
public BeatmapInfo BeatmapInfo;
|
||||
|
||||
public bool IsPaused { get; private set; }
|
||||
@ -108,10 +112,13 @@ namespace osu.Game.Screens.Play
|
||||
});
|
||||
|
||||
ruleset = Ruleset.GetRuleset(Beatmap.PlayMode);
|
||||
hitRenderer = ruleset.CreateHitRendererWith(Beatmap);
|
||||
|
||||
scoreProcessor = hitRenderer.CreateScoreProcessor();
|
||||
|
||||
hudOverlay = new StandardHudOverlay();
|
||||
hudOverlay.KeyCounter.Add(ruleset.CreateGameplayKeys());
|
||||
hudOverlay.BindProcessor(scoreProcessor = ruleset.CreateScoreProcessor(beatmap.HitObjects.Count));
|
||||
hudOverlay.BindProcessor(scoreProcessor);
|
||||
|
||||
pauseOverlay = new PauseOverlay
|
||||
{
|
||||
@ -125,7 +132,6 @@ namespace osu.Game.Screens.Play
|
||||
OnQuit = Exit
|
||||
};
|
||||
|
||||
hitRenderer = ruleset.CreateHitRendererWith(Beatmap);
|
||||
|
||||
if (ReplayInputHandler != null)
|
||||
hitRenderer.InputManager.ReplayInputHandler = ReplayInputHandler;
|
||||
@ -133,8 +139,7 @@ namespace osu.Game.Screens.Play
|
||||
hudOverlay.BindHitRenderer(hitRenderer);
|
||||
|
||||
//bind HitRenderer to ScoreProcessor and ourselves (for a pass situation)
|
||||
hitRenderer.OnJudgement += scoreProcessor.AddJudgement;
|
||||
hitRenderer.OnAllJudged += onPass;
|
||||
hitRenderer.OnAllJudged += onCompletion;
|
||||
|
||||
//bind ScoreProcessor to ourselves (for a fail situation)
|
||||
scoreProcessor.Failed += onFail;
|
||||
@ -236,15 +241,19 @@ namespace osu.Game.Screens.Play
|
||||
});
|
||||
}
|
||||
|
||||
private void onPass()
|
||||
private void onCompletion()
|
||||
{
|
||||
// Only show the completion screen if the player hasn't failed
|
||||
if (scoreProcessor.HasFailed)
|
||||
return;
|
||||
|
||||
Delay(1000);
|
||||
Schedule(delegate
|
||||
{
|
||||
ValidForResume = false;
|
||||
Push(new Results
|
||||
{
|
||||
Score = scoreProcessor.GetScore()
|
||||
Score = scoreProcessor.CreateScore()
|
||||
});
|
||||
});
|
||||
}
|
||||
@ -299,7 +308,7 @@ namespace osu.Game.Screens.Play
|
||||
{
|
||||
if (pauseOverlay == null) return false;
|
||||
|
||||
if (hitRenderer.InputManager.ReplayInputHandler != null)
|
||||
if (hasReplayLoaded)
|
||||
return false;
|
||||
|
||||
if (pauseOverlay.State != Visibility.Visible && !canPause) return true;
|
||||
|
@ -15,46 +15,234 @@ using OpenTK.Input;
|
||||
using System.Collections;
|
||||
using osu.Framework.MathUtils;
|
||||
using System.Diagnostics;
|
||||
using System.Threading.Tasks;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Threading;
|
||||
|
||||
namespace osu.Game.Screens.Select
|
||||
{
|
||||
internal class CarouselContainer : ScrollContainer, IEnumerable<BeatmapGroup>
|
||||
internal class BeatmapCarousel : ScrollContainer, IEnumerable<BeatmapGroup>
|
||||
{
|
||||
private Container<Panel> scrollableContent;
|
||||
private List<BeatmapGroup> groups = new List<BeatmapGroup>();
|
||||
private List<Panel> panels = new List<Panel>();
|
||||
public BeatmapInfo SelectedBeatmap => selectedPanel?.Beatmap;
|
||||
|
||||
public BeatmapGroup SelectedGroup { get; private set; }
|
||||
public BeatmapPanel SelectedPanel { get; private set; }
|
||||
public Action BeatmapsChanged;
|
||||
|
||||
public IEnumerable<BeatmapSetInfo> Beatmaps
|
||||
{
|
||||
get
|
||||
{
|
||||
return groups.Select(g => g.BeatmapSet);
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
scrollableContent.Clear(false);
|
||||
panels.Clear();
|
||||
groups.Clear();
|
||||
|
||||
List<BeatmapGroup> newGroups = null;
|
||||
|
||||
Task.Run(() =>
|
||||
{
|
||||
newGroups = value.Select(createGroup).ToList();
|
||||
criteria.Filter(newGroups);
|
||||
}).ContinueWith(t =>
|
||||
{
|
||||
Schedule(() =>
|
||||
{
|
||||
foreach (var g in newGroups)
|
||||
addGroup(g);
|
||||
|
||||
computeYPositions();
|
||||
BeatmapsChanged?.Invoke();
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private List<float> yPositions = new List<float>();
|
||||
|
||||
public CarouselContainer()
|
||||
{
|
||||
DistanceDecayJump = 0.01;
|
||||
/// <summary>
|
||||
/// Required for now unfortunately.
|
||||
/// </summary>
|
||||
private BeatmapDatabase database;
|
||||
|
||||
private Container<Panel> scrollableContent;
|
||||
|
||||
private List<BeatmapGroup> groups = new List<BeatmapGroup>();
|
||||
|
||||
private List<Panel> panels = new List<Panel>();
|
||||
|
||||
private BeatmapGroup selectedGroup;
|
||||
|
||||
private BeatmapPanel selectedPanel;
|
||||
|
||||
public BeatmapCarousel()
|
||||
{
|
||||
Add(scrollableContent = new Container<Panel>
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
});
|
||||
}
|
||||
|
||||
public void AddGroup(BeatmapGroup group)
|
||||
public void AddBeatmap(BeatmapSetInfo beatmapSet)
|
||||
{
|
||||
groups.Add(group);
|
||||
var group = createGroup(beatmapSet);
|
||||
|
||||
panels.Add(group.Header);
|
||||
group.Header.UpdateClock(Clock);
|
||||
foreach (BeatmapPanel panel in group.BeatmapPanels)
|
||||
//for the time being, let's completely load the difficulty panels in the background.
|
||||
//this likely won't scale so well, but allows us to completely async the loading flow.
|
||||
Schedule(delegate
|
||||
{
|
||||
panels.Add(panel);
|
||||
panel.UpdateClock(Clock);
|
||||
}
|
||||
|
||||
computeYPositions();
|
||||
addGroup(group);
|
||||
computeYPositions();
|
||||
if (selectedGroup == null)
|
||||
selectGroup(group);
|
||||
});
|
||||
}
|
||||
|
||||
public void RemoveGroup(BeatmapGroup group)
|
||||
public void SelectBeatmap(BeatmapInfo beatmap, bool animated = true)
|
||||
{
|
||||
if (beatmap == null)
|
||||
{
|
||||
SelectNext();
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (BeatmapGroup group in groups)
|
||||
{
|
||||
var panel = group.BeatmapPanels.FirstOrDefault(p => p.Beatmap.Equals(beatmap));
|
||||
if (panel != null)
|
||||
{
|
||||
selectGroup(group, panel, animated);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void RemoveBeatmap(BeatmapSetInfo info) => removeGroup(groups.Find(b => b.BeatmapSet.ID == info.ID));
|
||||
|
||||
public Action<BeatmapGroup, BeatmapInfo> SelectionChanged;
|
||||
|
||||
public Action StartRequested;
|
||||
|
||||
public void SelectNext(int direction = 1, bool skipDifficulties = true)
|
||||
{
|
||||
if (groups.Count == 0)
|
||||
{
|
||||
selectedGroup = null;
|
||||
selectedPanel = null;
|
||||
return;
|
||||
}
|
||||
|
||||
if (!skipDifficulties && selectedGroup != null)
|
||||
{
|
||||
int i = selectedGroup.BeatmapPanels.IndexOf(selectedPanel) + direction;
|
||||
|
||||
if (i >= 0 && i < selectedGroup.BeatmapPanels.Count)
|
||||
{
|
||||
//changing difficulty panel, not set.
|
||||
selectGroup(selectedGroup, selectedGroup.BeatmapPanels[i]);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
int startIndex = groups.IndexOf(selectedGroup);
|
||||
int index = startIndex;
|
||||
|
||||
do
|
||||
{
|
||||
index = (index + direction + groups.Count) % groups.Count;
|
||||
if (groups[index].State != BeatmapGroupState.Hidden)
|
||||
{
|
||||
SelectBeatmap(groups[index].BeatmapPanels.First().Beatmap);
|
||||
return;
|
||||
}
|
||||
} while (index != startIndex);
|
||||
}
|
||||
|
||||
public void SelectRandom()
|
||||
{
|
||||
List<BeatmapGroup> visibleGroups = groups.Where(selectGroup => selectGroup.State != BeatmapGroupState.Hidden).ToList();
|
||||
if (visibleGroups.Count < 1)
|
||||
return;
|
||||
BeatmapGroup group = visibleGroups[RNG.Next(visibleGroups.Count)];
|
||||
BeatmapPanel panel = group?.BeatmapPanels.First();
|
||||
|
||||
if (panel == null)
|
||||
return;
|
||||
|
||||
selectGroup(group, panel);
|
||||
}
|
||||
|
||||
private FilterCriteria criteria = new FilterCriteria();
|
||||
|
||||
private ScheduledDelegate filterTask;
|
||||
|
||||
public void Filter(FilterCriteria newCriteria = null, bool debounce = true)
|
||||
{
|
||||
if (!IsLoaded) return;
|
||||
|
||||
criteria = newCriteria ?? criteria ?? new FilterCriteria();
|
||||
|
||||
Action perform = delegate
|
||||
{
|
||||
filterTask = null;
|
||||
|
||||
criteria.Filter(groups);
|
||||
|
||||
var filtered = new List<BeatmapGroup>(groups);
|
||||
|
||||
scrollableContent.Clear(false);
|
||||
panels.Clear();
|
||||
groups.Clear();
|
||||
|
||||
foreach (var g in filtered)
|
||||
addGroup(g);
|
||||
|
||||
computeYPositions();
|
||||
|
||||
if (selectedGroup == null || selectedGroup.State == BeatmapGroupState.Hidden)
|
||||
SelectNext();
|
||||
};
|
||||
|
||||
filterTask?.Cancel();
|
||||
if (debounce)
|
||||
filterTask = Scheduler.AddDelayed(perform, 250);
|
||||
else
|
||||
perform();
|
||||
}
|
||||
|
||||
public IEnumerator<BeatmapGroup> GetEnumerator() => groups.GetEnumerator();
|
||||
|
||||
IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
|
||||
|
||||
private BeatmapGroup createGroup(BeatmapSetInfo beatmapSet)
|
||||
{
|
||||
database.GetChildren(beatmapSet);
|
||||
beatmapSet.Beatmaps.ForEach(b => { if (b.Metadata == null) b.Metadata = beatmapSet.Metadata; });
|
||||
|
||||
return new BeatmapGroup(beatmapSet, database)
|
||||
{
|
||||
SelectionChanged = SelectionChanged,
|
||||
StartRequested = b => StartRequested?.Invoke(),
|
||||
State = BeatmapGroupState.Collapsed
|
||||
};
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader(permitNulls: true)]
|
||||
private void load(BeatmapDatabase database)
|
||||
{
|
||||
this.database = database;
|
||||
}
|
||||
|
||||
private void addGroup(BeatmapGroup group)
|
||||
{
|
||||
groups.Add(group);
|
||||
panels.Add(group.Header);
|
||||
panels.AddRange(group.BeatmapPanels);
|
||||
}
|
||||
|
||||
private void removeGroup(BeatmapGroup group)
|
||||
{
|
||||
groups.Remove(group);
|
||||
panels.Remove(group.Header);
|
||||
@ -64,18 +252,12 @@ namespace osu.Game.Screens.Select
|
||||
scrollableContent.Remove(group.Header);
|
||||
scrollableContent.Remove(group.BeatmapPanels);
|
||||
|
||||
if (selectedGroup == group)
|
||||
SelectNext();
|
||||
|
||||
computeYPositions();
|
||||
}
|
||||
|
||||
private void movePanel(Panel panel, bool advance, bool animated, ref float currentY)
|
||||
{
|
||||
yPositions.Add(currentY);
|
||||
panel.MoveToY(currentY, animated ? 750 : 0, EasingTypes.OutExpo);
|
||||
|
||||
if (advance)
|
||||
currentY += panel.DrawHeight + 5;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Computes the target Y positions for every panel in the carousel.
|
||||
/// </summary>
|
||||
@ -98,7 +280,7 @@ namespace osu.Game.Screens.Select
|
||||
|
||||
foreach (BeatmapPanel panel in group.BeatmapPanels)
|
||||
{
|
||||
if (panel == SelectedPanel)
|
||||
if (panel == selectedPanel)
|
||||
selectedY = currentY + panel.DrawHeight / 2 - DrawHeight / 2;
|
||||
|
||||
panel.MoveToX(-50, 500, EasingTypes.OutExpo);
|
||||
@ -128,125 +310,62 @@ namespace osu.Game.Screens.Select
|
||||
return selectedY;
|
||||
}
|
||||
|
||||
public void SelectBeatmap(BeatmapInfo beatmap, bool animated = true)
|
||||
private void movePanel(Panel panel, bool advance, bool animated, ref float currentY)
|
||||
{
|
||||
foreach (BeatmapGroup group in groups)
|
||||
{
|
||||
var panel = group.BeatmapPanels.FirstOrDefault(p => p.Beatmap.Equals(beatmap));
|
||||
if (panel != null)
|
||||
{
|
||||
selectGroup(group, panel, animated);
|
||||
return;
|
||||
}
|
||||
}
|
||||
yPositions.Add(currentY);
|
||||
panel.MoveToY(currentY, animated ? 750 : 0, EasingTypes.OutExpo);
|
||||
|
||||
if (advance)
|
||||
currentY += panel.DrawHeight + 5;
|
||||
}
|
||||
|
||||
private void selectGroup(BeatmapGroup group, BeatmapPanel panel, bool animated = true)
|
||||
private void selectGroup(BeatmapGroup group, BeatmapPanel panel = null, bool animated = true)
|
||||
{
|
||||
if (panel == null)
|
||||
panel = group.BeatmapPanels.First();
|
||||
|
||||
Trace.Assert(group.BeatmapPanels.Contains(panel), @"Selected panel must be in provided group");
|
||||
|
||||
if (SelectedGroup != null && SelectedGroup != group && SelectedGroup.State != BeatmapGroupState.Hidden)
|
||||
SelectedGroup.State = BeatmapGroupState.Collapsed;
|
||||
if (selectedGroup != null && selectedGroup != group && selectedGroup.State != BeatmapGroupState.Hidden)
|
||||
selectedGroup.State = BeatmapGroupState.Collapsed;
|
||||
|
||||
group.State = BeatmapGroupState.Expanded;
|
||||
SelectedGroup = group;
|
||||
selectedGroup = group;
|
||||
panel.State = PanelSelectedState.Selected;
|
||||
SelectedPanel = panel;
|
||||
selectedPanel = panel;
|
||||
|
||||
float selectedY = computeYPositions(animated);
|
||||
ScrollTo(selectedY, animated);
|
||||
}
|
||||
|
||||
public void Sort(FilterControl.SortMode mode)
|
||||
protected override bool OnKeyDown(InputState state, KeyDownEventArgs args)
|
||||
{
|
||||
List<BeatmapGroup> sortedGroups = new List<BeatmapGroup>(groups);
|
||||
switch (mode)
|
||||
int direction = 0;
|
||||
bool skipDifficulties = false;
|
||||
|
||||
switch (args.Key)
|
||||
{
|
||||
case FilterControl.SortMode.Artist:
|
||||
sortedGroups.Sort((x, y) => string.Compare(x.BeatmapSet.Metadata.Artist, y.BeatmapSet.Metadata.Artist, StringComparison.InvariantCultureIgnoreCase));
|
||||
case Key.Up:
|
||||
direction = -1;
|
||||
break;
|
||||
case FilterControl.SortMode.Title:
|
||||
sortedGroups.Sort((x, y) => string.Compare(x.BeatmapSet.Metadata.Title, y.BeatmapSet.Metadata.Title, StringComparison.InvariantCultureIgnoreCase));
|
||||
case Key.Down:
|
||||
direction = 1;
|
||||
break;
|
||||
case FilterControl.SortMode.Author:
|
||||
sortedGroups.Sort((x, y) => string.Compare(x.BeatmapSet.Metadata.Author, y.BeatmapSet.Metadata.Author, StringComparison.InvariantCultureIgnoreCase));
|
||||
case Key.Left:
|
||||
direction = -1;
|
||||
skipDifficulties = true;
|
||||
break;
|
||||
case FilterControl.SortMode.Difficulty:
|
||||
sortedGroups.Sort((x, y) =>
|
||||
{
|
||||
float xAverage = 0, yAverage = 0;
|
||||
int counter = 0;
|
||||
foreach (BeatmapInfo set in x.BeatmapSet.Beatmaps)
|
||||
{
|
||||
xAverage += set.StarDifficulty;
|
||||
counter++;
|
||||
}
|
||||
xAverage /= counter;
|
||||
counter = 0;
|
||||
foreach (BeatmapInfo set in y.BeatmapSet.Beatmaps)
|
||||
{
|
||||
yAverage += set.StarDifficulty;
|
||||
counter++;
|
||||
}
|
||||
yAverage /= counter;
|
||||
if (xAverage > yAverage)
|
||||
return 1;
|
||||
else
|
||||
return -1;
|
||||
});
|
||||
case Key.Right:
|
||||
direction = 1;
|
||||
skipDifficulties = true;
|
||||
break;
|
||||
default:
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
scrollableContent.Clear(false);
|
||||
panels.Clear();
|
||||
groups.Clear();
|
||||
if (direction == 0)
|
||||
return base.OnKeyDown(state, args);
|
||||
|
||||
foreach (BeatmapGroup group in sortedGroups)
|
||||
AddGroup(group);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Computes the x-offset of currently visible panels. Makes the carousel appear round.
|
||||
/// </summary>
|
||||
/// <param name="dist">
|
||||
/// Vertical distance from the center of the carousel container
|
||||
/// ranging from -1 to 1.
|
||||
/// </param>
|
||||
/// <param name="halfHeight">Half the height of the carousel container.</param>
|
||||
private static float offsetX(float dist, float halfHeight)
|
||||
{
|
||||
// The radius of the circle the carousel moves on.
|
||||
const float circle_radius = 3;
|
||||
double discriminant = Math.Max(0, circle_radius * circle_radius - dist * dist);
|
||||
float x = (circle_radius - (float)Math.Sqrt(discriminant)) * halfHeight;
|
||||
|
||||
return 125 + x;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Update a panel's x position and multiplicative alpha based on its y position and
|
||||
/// the current scroll position.
|
||||
/// </summary>
|
||||
/// <param name="p">The panel to be updated.</param>
|
||||
/// <param name="halfHeight">Half the draw height of the carousel container.</param>
|
||||
private void updatePanel(Panel p, float halfHeight)
|
||||
{
|
||||
var height = p.IsPresent ? p.DrawHeight : 0;
|
||||
|
||||
float panelDrawY = p.Position.Y - Current + height / 2;
|
||||
float dist = Math.Abs(1f - panelDrawY / halfHeight);
|
||||
|
||||
// Setting the origin position serves as an additive position on top of potential
|
||||
// local transformation we may want to apply (e.g. when a panel gets selected, we
|
||||
// may want to smoothly transform it leftwards.)
|
||||
p.OriginPosition = new Vector2(-offsetX(dist, halfHeight), 0);
|
||||
|
||||
// We are applying a multiplicative alpha (which is internally done by nesting an
|
||||
// additional container and setting that container's alpha) such that we can
|
||||
// layer transformations on top, with a similar reasoning to the previous comment.
|
||||
p.SetMultiplicativeAlpha(MathHelper.Clamp(1.75f - 1.5f * dist, 0, 1));
|
||||
SelectNext(direction, skipDifficulties);
|
||||
return true;
|
||||
}
|
||||
|
||||
protected override void Update()
|
||||
@ -295,80 +414,46 @@ namespace osu.Game.Screens.Select
|
||||
updatePanel(p, halfHeight);
|
||||
}
|
||||
|
||||
protected override bool OnKeyDown(InputState state, KeyDownEventArgs args)
|
||||
/// <summary>
|
||||
/// Computes the x-offset of currently visible panels. Makes the carousel appear round.
|
||||
/// </summary>
|
||||
/// <param name="dist">
|
||||
/// Vertical distance from the center of the carousel container
|
||||
/// ranging from -1 to 1.
|
||||
/// </param>
|
||||
/// <param name="halfHeight">Half the height of the carousel container.</param>
|
||||
private static float offsetX(float dist, float halfHeight)
|
||||
{
|
||||
int direction = 0;
|
||||
bool skipDifficulties = false;
|
||||
// The radius of the circle the carousel moves on.
|
||||
const float circle_radius = 3;
|
||||
double discriminant = Math.Max(0, circle_radius * circle_radius - dist * dist);
|
||||
float x = (circle_radius - (float)Math.Sqrt(discriminant)) * halfHeight;
|
||||
|
||||
switch (args.Key)
|
||||
{
|
||||
case Key.Up:
|
||||
direction = -1;
|
||||
break;
|
||||
case Key.Down:
|
||||
direction = 1;
|
||||
break;
|
||||
case Key.Left:
|
||||
direction = -1;
|
||||
skipDifficulties = true;
|
||||
break;
|
||||
case Key.Right:
|
||||
direction = 1;
|
||||
skipDifficulties = true;
|
||||
break;
|
||||
}
|
||||
|
||||
if (direction == 0)
|
||||
return base.OnKeyDown(state, args);
|
||||
|
||||
SelectNext(direction, skipDifficulties);
|
||||
return true;
|
||||
return 125 + x;
|
||||
}
|
||||
|
||||
public void SelectNext(int direction = 1, bool skipDifficulties = true)
|
||||
/// <summary>
|
||||
/// Update a panel's x position and multiplicative alpha based on its y position and
|
||||
/// the current scroll position.
|
||||
/// </summary>
|
||||
/// <param name="p">The panel to be updated.</param>
|
||||
/// <param name="halfHeight">Half the draw height of the carousel container.</param>
|
||||
private void updatePanel(Panel p, float halfHeight)
|
||||
{
|
||||
if (!skipDifficulties && SelectedGroup != null)
|
||||
{
|
||||
int i = SelectedGroup.BeatmapPanels.IndexOf(SelectedPanel) + direction;
|
||||
var height = p.IsPresent ? p.DrawHeight : 0;
|
||||
|
||||
if (i >= 0 && i < SelectedGroup.BeatmapPanels.Count)
|
||||
{
|
||||
//changing difficulty panel, not set.
|
||||
selectGroup(SelectedGroup, SelectedGroup.BeatmapPanels[i]);
|
||||
return;
|
||||
}
|
||||
}
|
||||
float panelDrawY = p.Position.Y - Current + height / 2;
|
||||
float dist = Math.Abs(1f - panelDrawY / halfHeight);
|
||||
|
||||
int startIndex = groups.IndexOf(SelectedGroup);
|
||||
int index = startIndex;
|
||||
// Setting the origin position serves as an additive position on top of potential
|
||||
// local transformation we may want to apply (e.g. when a panel gets selected, we
|
||||
// may want to smoothly transform it leftwards.)
|
||||
p.OriginPosition = new Vector2(-offsetX(dist, halfHeight), 0);
|
||||
|
||||
do
|
||||
{
|
||||
index = (index + direction + groups.Count) % groups.Count;
|
||||
if (groups[index].State != BeatmapGroupState.Hidden)
|
||||
{
|
||||
SelectBeatmap(groups[index].BeatmapPanels.First().Beatmap);
|
||||
return;
|
||||
}
|
||||
} while (index != startIndex);
|
||||
// We are applying a multiplicative alpha (which is internally done by nesting an
|
||||
// additional container and setting that container's alpha) such that we can
|
||||
// layer transformations on top, with a similar reasoning to the previous comment.
|
||||
p.SetMultiplicativeAlpha(MathHelper.Clamp(1.75f - 1.5f * dist, 0, 1));
|
||||
}
|
||||
|
||||
public void SelectRandom()
|
||||
{
|
||||
List<BeatmapGroup> visibleGroups = groups.Where(selectGroup => selectGroup.State != BeatmapGroupState.Hidden).ToList();
|
||||
if (visibleGroups.Count < 1)
|
||||
return;
|
||||
BeatmapGroup group = visibleGroups[RNG.Next(visibleGroups.Count)];
|
||||
BeatmapPanel panel = group?.BeatmapPanels.First();
|
||||
|
||||
if (panel == null)
|
||||
return;
|
||||
|
||||
selectGroup(group, panel);
|
||||
}
|
||||
|
||||
public IEnumerator<BeatmapGroup> GetEnumerator() => groups.GetEnumerator();
|
||||
|
||||
IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
|
||||
}
|
||||
}
|
@ -217,12 +217,12 @@ namespace osu.Game.Screens.Select
|
||||
|
||||
private string getBPMRange(Beatmap beatmap)
|
||||
{
|
||||
double bpmMax = beatmap.BPMMaximum;
|
||||
double bpmMin = beatmap.BPMMinimum;
|
||||
double bpmMax = beatmap.TimingInfo.BPMMaximum;
|
||||
double bpmMin = beatmap.TimingInfo.BPMMinimum;
|
||||
|
||||
if (Precision.AlmostEquals(bpmMin, bpmMax)) return Math.Round(bpmMin) + "bpm";
|
||||
|
||||
return Math.Round(bpmMin) + "-" + Math.Round(bpmMax) + "bpm (mostly " + Math.Round(beatmap.BPMMode) + "bpm)";
|
||||
return Math.Round(bpmMin) + "-" + Math.Round(bpmMax) + "bpm (mostly " + Math.Round(beatmap.TimingInfo.BPMMode) + "bpm)";
|
||||
}
|
||||
|
||||
public class InfoLabel : Container
|
||||
|
41
osu.Game/Screens/Select/Filter/GroupMode.cs
Normal file
41
osu.Game/Screens/Select/Filter/GroupMode.cs
Normal file
@ -0,0 +1,41 @@
|
||||
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace osu.Game.Screens.Select.Filter
|
||||
{
|
||||
public enum GroupMode
|
||||
{
|
||||
[Description("All")]
|
||||
All,
|
||||
[Description("Artist")]
|
||||
Artist,
|
||||
[Description("Author")]
|
||||
Author,
|
||||
[Description("BPM")]
|
||||
BPM,
|
||||
[Description("Collections")]
|
||||
Collections,
|
||||
[Description("Date Added")]
|
||||
DateAdded,
|
||||
[Description("Difficulty")]
|
||||
Difficulty,
|
||||
[Description("Favorites")]
|
||||
Favorites,
|
||||
[Description("Length")]
|
||||
Length,
|
||||
[Description("My Maps")]
|
||||
MyMaps,
|
||||
[Description("No Grouping")]
|
||||
NoGrouping,
|
||||
[Description("Rank Achieved")]
|
||||
RankAchieved,
|
||||
[Description("Ranked Status")]
|
||||
RankedStatus,
|
||||
[Description("Recently Played")]
|
||||
RecentlyPlayed,
|
||||
[Description("Title")]
|
||||
Title
|
||||
}
|
||||
}
|
27
osu.Game/Screens/Select/Filter/SortMode.cs
Normal file
27
osu.Game/Screens/Select/Filter/SortMode.cs
Normal file
@ -0,0 +1,27 @@
|
||||
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace osu.Game.Screens.Select.Filter
|
||||
{
|
||||
public enum SortMode
|
||||
{
|
||||
[Description("Artist")]
|
||||
Artist,
|
||||
[Description("Author")]
|
||||
Author,
|
||||
[Description("BPM")]
|
||||
BPM,
|
||||
[Description("Date Added")]
|
||||
DateAdded,
|
||||
[Description("Difficulty")]
|
||||
Difficulty,
|
||||
[Description("Length")]
|
||||
Length,
|
||||
[Description("Rank Achieved")]
|
||||
RankAchieved,
|
||||
[Description("Title")]
|
||||
Title
|
||||
}
|
||||
}
|
@ -5,37 +5,71 @@ using System;
|
||||
using OpenTK;
|
||||
using OpenTK.Graphics;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Configuration;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Primitives;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Framework.Input;
|
||||
using osu.Framework.Graphics.UserInterface;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
using osu.Game.Screens.Select.Filter;
|
||||
using Container = osu.Framework.Graphics.Containers.Container;
|
||||
using osu.Framework.Input;
|
||||
using osu.Game.Modes;
|
||||
|
||||
namespace osu.Game.Screens.Select
|
||||
{
|
||||
public class FilterControl : Container
|
||||
{
|
||||
public Action FilterChanged;
|
||||
public Action<FilterCriteria> FilterChanged;
|
||||
|
||||
private OsuTabControl<SortMode> sortTabs;
|
||||
|
||||
private TabControl<GroupMode> groupTabs;
|
||||
|
||||
public string Search => searchTextBox.Text;
|
||||
private SortMode sort = SortMode.Title;
|
||||
public SortMode Sort {
|
||||
get { return sort; }
|
||||
set {
|
||||
public SortMode Sort
|
||||
{
|
||||
get { return sort; }
|
||||
set
|
||||
{
|
||||
if (sort != value)
|
||||
{
|
||||
sort = value;
|
||||
FilterChanged?.Invoke();
|
||||
FilterChanged?.Invoke(CreateCriteria());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private GroupMode group = GroupMode.All;
|
||||
public GroupMode Group
|
||||
{
|
||||
get { return group; }
|
||||
set
|
||||
{
|
||||
if (group != value)
|
||||
{
|
||||
group = value;
|
||||
FilterChanged?.Invoke(CreateCriteria());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public FilterCriteria CreateCriteria() => new FilterCriteria
|
||||
{
|
||||
Group = group,
|
||||
Sort = sort,
|
||||
SearchText = searchTextBox.Text,
|
||||
Mode = playMode
|
||||
};
|
||||
|
||||
public Action Exit;
|
||||
|
||||
private SearchTextBox searchTextBox;
|
||||
|
||||
protected override bool InternalContains(Vector2 screenSpacePos) => base.InternalContains(screenSpacePos) || groupTabs.Contains(screenSpacePos) || sortTabs.Contains(screenSpacePos);
|
||||
|
||||
public FilterControl()
|
||||
{
|
||||
Children = new Drawable[]
|
||||
@ -46,30 +80,79 @@ namespace osu.Game.Screens.Select
|
||||
Alpha = 0.8f,
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
},
|
||||
new FillFlowContainer
|
||||
new Container
|
||||
{
|
||||
Padding = new MarginPadding(20),
|
||||
AutoSizeAxes = Axes.Y,
|
||||
RelativeSizeAxes = Axes.X,
|
||||
AlwaysReceiveInput = true,
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Width = 0.5f,
|
||||
Anchor = Anchor.TopRight,
|
||||
Origin = Anchor.TopRight,
|
||||
Width = 0.4f, // TODO: InnerWidth property or something
|
||||
Direction = FillDirection.Vertical,
|
||||
Children = new Drawable[]
|
||||
{
|
||||
searchTextBox = new SearchTextBox {
|
||||
searchTextBox = new SearchTextBox
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
OnChange = (sender, newText) =>
|
||||
{
|
||||
if (newText)
|
||||
FilterChanged?.Invoke();
|
||||
FilterChanged?.Invoke(CreateCriteria());
|
||||
},
|
||||
Exit = () => Exit?.Invoke(),
|
||||
},
|
||||
new GroupSortTabs()
|
||||
new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
Height = 1,
|
||||
Colour = OsuColour.Gray(80),
|
||||
Origin = Anchor.BottomLeft,
|
||||
Anchor = Anchor.BottomLeft,
|
||||
},
|
||||
new FillFlowContainer
|
||||
{
|
||||
Anchor = Anchor.BottomRight,
|
||||
Origin = Anchor.BottomRight,
|
||||
Direction = FillDirection.Horizontal,
|
||||
RelativeSizeAxes = Axes.X,
|
||||
AutoSizeAxes = Axes.Y,
|
||||
AlwaysReceiveInput = true,
|
||||
Children = new Drawable[]
|
||||
{
|
||||
groupTabs = new OsuTabControl<GroupMode>
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
Height = 24,
|
||||
Width = 0.5f,
|
||||
AutoSort = true
|
||||
},
|
||||
//spriteText = new OsuSpriteText
|
||||
//{
|
||||
// Font = @"Exo2.0-Bold",
|
||||
// Text = "Sort results by",
|
||||
// TextSize = 14,
|
||||
// Margin = new MarginPadding
|
||||
// {
|
||||
// Top = 5,
|
||||
// Bottom = 5
|
||||
// },
|
||||
//},
|
||||
sortTabs = new OsuTabControl<SortMode>()
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
Width = 0.5f,
|
||||
Height = 24,
|
||||
AutoSort = true,
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
groupTabs.PinItem(GroupMode.All);
|
||||
groupTabs.PinItem(GroupMode.RecentlyPlayed);
|
||||
groupTabs.ItemChanged += (sender, value) => Group = value;
|
||||
sortTabs.ItemChanged += (sender, value) => Sort = value;
|
||||
}
|
||||
|
||||
public void Deactivate()
|
||||
@ -77,214 +160,29 @@ namespace osu.Game.Screens.Select
|
||||
searchTextBox.HoldFocus = false;
|
||||
searchTextBox.TriggerFocusLost();
|
||||
}
|
||||
|
||||
|
||||
public void Activate()
|
||||
{
|
||||
searchTextBox.HoldFocus = true;
|
||||
}
|
||||
|
||||
private class TabItem : ClickableContainer
|
||||
private readonly Bindable<PlayMode> playMode = new Bindable<PlayMode>();
|
||||
|
||||
[BackgroundDependencyLoader(permitNulls:true)]
|
||||
private void load(OsuColour colours, OsuGame osu)
|
||||
{
|
||||
public string Text
|
||||
{
|
||||
get { return text.Text; }
|
||||
set { text.Text = value; }
|
||||
}
|
||||
sortTabs.AccentColour = colours.GreenLight;
|
||||
|
||||
private void fadeActive()
|
||||
{
|
||||
box.FadeIn(300);
|
||||
text.FadeColour(Color4.White, 300);
|
||||
}
|
||||
|
||||
private void fadeInactive()
|
||||
{
|
||||
box.FadeOut(300);
|
||||
text.FadeColour(fadeColour, 300);
|
||||
}
|
||||
|
||||
private bool active;
|
||||
public bool Active
|
||||
{
|
||||
get { return active; }
|
||||
set
|
||||
{
|
||||
active = value;
|
||||
if (active)
|
||||
fadeActive();
|
||||
else
|
||||
fadeInactive();
|
||||
}
|
||||
}
|
||||
|
||||
private SpriteText text;
|
||||
private Box box;
|
||||
private Color4 fadeColour;
|
||||
|
||||
protected override bool OnHover(InputState state)
|
||||
{
|
||||
if (!active)
|
||||
fadeActive();
|
||||
return true;
|
||||
}
|
||||
|
||||
protected override void OnHoverLost(InputState state)
|
||||
{
|
||||
if (!active)
|
||||
fadeInactive();
|
||||
}
|
||||
|
||||
public TabItem()
|
||||
{
|
||||
AutoSizeAxes = Axes.Both;
|
||||
Children = new Drawable[]
|
||||
{
|
||||
text = new OsuSpriteText
|
||||
{
|
||||
Margin = new MarginPadding(5),
|
||||
TextSize = 14,
|
||||
Font = @"Exo2.0-Bold",
|
||||
},
|
||||
box = new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
Height = 1,
|
||||
Alpha = 0,
|
||||
Colour = Color4.White,
|
||||
Origin = Anchor.BottomLeft,
|
||||
Anchor = Anchor.BottomLeft,
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuColour colours)
|
||||
{
|
||||
text.Colour = colours.Blue;
|
||||
fadeColour = colours.Blue;
|
||||
}
|
||||
if (osu != null)
|
||||
playMode.BindTo(osu.PlayMode);
|
||||
}
|
||||
|
||||
private class GroupSortTabs : Container
|
||||
{
|
||||
private TextAwesome groupsEllipsis, sortEllipsis;
|
||||
private SpriteText sortLabel;
|
||||
|
||||
public GroupSortTabs()
|
||||
{
|
||||
RelativeSizeAxes = Axes.X;
|
||||
AutoSizeAxes = Axes.Y;
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
Height = 1,
|
||||
Colour = OsuColour.Gray(80),
|
||||
Origin = Anchor.BottomLeft,
|
||||
Anchor = Anchor.BottomLeft,
|
||||
},
|
||||
new FillFlowContainer
|
||||
{
|
||||
AutoSizeAxes = Axes.Both,
|
||||
Direction = FillDirection.Horizontal,
|
||||
Spacing = new Vector2(10, 0),
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new TabItem
|
||||
{
|
||||
Text = "All",
|
||||
Active = true,
|
||||
},
|
||||
new TabItem
|
||||
{
|
||||
Text = "Recently Played",
|
||||
Active = false,
|
||||
},
|
||||
new TabItem
|
||||
{
|
||||
Text = "Collections",
|
||||
Active = false,
|
||||
},
|
||||
groupsEllipsis = new TextAwesome
|
||||
{
|
||||
Icon = FontAwesome.fa_ellipsis_h,
|
||||
Origin = Anchor.TopLeft,
|
||||
TextSize = 14,
|
||||
Margin = new MarginPadding { Top = 5, Bottom = 5 },
|
||||
}
|
||||
}
|
||||
},
|
||||
new FillFlowContainer
|
||||
{
|
||||
AutoSizeAxes = Axes.Both,
|
||||
Direction = FillDirection.Horizontal,
|
||||
Spacing = new Vector2(10, 0),
|
||||
Origin = Anchor.TopRight,
|
||||
Anchor = Anchor.TopRight,
|
||||
Children = new Drawable[]
|
||||
{
|
||||
sortLabel = new OsuSpriteText
|
||||
{
|
||||
Font = @"Exo2.0-Bold",
|
||||
Text = "Sort results by",
|
||||
TextSize = 14,
|
||||
Margin = new MarginPadding { Top = 5, Bottom = 5 },
|
||||
},
|
||||
new TabItem
|
||||
{
|
||||
Text = "Artist",
|
||||
Active = true,
|
||||
},
|
||||
sortEllipsis = new TextAwesome
|
||||
{
|
||||
Icon = FontAwesome.fa_ellipsis_h,
|
||||
Origin = Anchor.TopLeft,
|
||||
TextSize = 14,
|
||||
Margin = new MarginPadding { Top = 5, Bottom = 5 },
|
||||
}
|
||||
}
|
||||
},
|
||||
};
|
||||
}
|
||||
protected override bool OnMouseDown(InputState state, MouseDownEventArgs args) => true;
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuColour colours)
|
||||
{
|
||||
groupsEllipsis.Colour = colours.Blue;
|
||||
sortLabel.Colour = colours.GreenLight;
|
||||
sortEllipsis.Colour = colours.GreenLight;
|
||||
}
|
||||
}
|
||||
|
||||
public enum SortMode
|
||||
{
|
||||
Artist,
|
||||
BPM,
|
||||
Author,
|
||||
DateAdded,
|
||||
Difficulty,
|
||||
Length,
|
||||
RankAchieved,
|
||||
Title
|
||||
}
|
||||
protected override bool OnMouseMove(InputState state) => true;
|
||||
|
||||
public enum GroupMode
|
||||
{
|
||||
NoGrouping,
|
||||
Artist,
|
||||
BPM,
|
||||
Author,
|
||||
DateAdded,
|
||||
Difficulty,
|
||||
Length,
|
||||
RankAchieved,
|
||||
Title,
|
||||
Collections,
|
||||
Favorites,
|
||||
MyMaps,
|
||||
RankedStatus,
|
||||
RecentlyPlayed
|
||||
}
|
||||
protected override bool OnClick(InputState state) => true;
|
||||
|
||||
protected override bool OnDragStart(InputState state) => true;
|
||||
}
|
||||
}
|
65
osu.Game/Screens/Select/FilterCriteria.cs
Normal file
65
osu.Game/Screens/Select/FilterCriteria.cs
Normal file
@ -0,0 +1,65 @@
|
||||
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using osu.Game.Beatmaps.Drawables;
|
||||
using osu.Game.Modes;
|
||||
using osu.Game.Screens.Select.Filter;
|
||||
|
||||
namespace osu.Game.Screens.Select
|
||||
{
|
||||
public class FilterCriteria
|
||||
{
|
||||
public GroupMode Group;
|
||||
public SortMode Sort;
|
||||
public string SearchText;
|
||||
public PlayMode Mode;
|
||||
|
||||
public void Filter(List<BeatmapGroup> groups)
|
||||
{
|
||||
foreach (var g in groups)
|
||||
{
|
||||
var set = g.BeatmapSet;
|
||||
|
||||
bool hasCurrentMode = set.Beatmaps.Any(bm => bm.Mode == Mode);
|
||||
|
||||
bool match = hasCurrentMode;
|
||||
|
||||
match &= string.IsNullOrEmpty(SearchText)
|
||||
|| (set.Metadata.Artist ?? string.Empty).IndexOf(SearchText, StringComparison.InvariantCultureIgnoreCase) != -1
|
||||
|| (set.Metadata.ArtistUnicode ?? string.Empty).IndexOf(SearchText, StringComparison.InvariantCultureIgnoreCase) != -1
|
||||
|| (set.Metadata.Title ?? string.Empty).IndexOf(SearchText, StringComparison.InvariantCultureIgnoreCase) != -1
|
||||
|| (set.Metadata.TitleUnicode ?? string.Empty).IndexOf(SearchText, StringComparison.InvariantCultureIgnoreCase) != -1;
|
||||
|
||||
switch (g.State)
|
||||
{
|
||||
case BeatmapGroupState.Hidden:
|
||||
if (match) g.State = BeatmapGroupState.Collapsed;
|
||||
break;
|
||||
default:
|
||||
if (!match) g.State = BeatmapGroupState.Hidden;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
switch (Sort)
|
||||
{
|
||||
default:
|
||||
case SortMode.Artist:
|
||||
groups.Sort((x, y) => string.Compare(x.BeatmapSet.Metadata.Artist, y.BeatmapSet.Metadata.Artist, StringComparison.InvariantCultureIgnoreCase));
|
||||
break;
|
||||
case SortMode.Title:
|
||||
groups.Sort((x, y) => string.Compare(x.BeatmapSet.Metadata.Title, y.BeatmapSet.Metadata.Title, StringComparison.InvariantCultureIgnoreCase));
|
||||
break;
|
||||
case SortMode.Author:
|
||||
groups.Sort((x, y) => string.Compare(x.BeatmapSet.Metadata.Author, y.BeatmapSet.Metadata.Author, StringComparison.InvariantCultureIgnoreCase));
|
||||
break;
|
||||
case SortMode.Difficulty:
|
||||
groups.Sort((x, y) => x.BeatmapSet.MaxStarDifficulty.CompareTo(y.BeatmapSet.MaxStarDifficulty));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -26,8 +26,6 @@ namespace osu.Game.Screens.Select
|
||||
|
||||
private const float padding = 80;
|
||||
|
||||
public override bool Contains(Vector2 screenSpacePos) => true;
|
||||
|
||||
public Action OnBack;
|
||||
public Action OnStart;
|
||||
|
||||
@ -69,6 +67,8 @@ namespace osu.Game.Screens.Select
|
||||
|
||||
public Footer()
|
||||
{
|
||||
AlwaysReceiveInput = true;
|
||||
|
||||
const float bottom_tool_height = 50;
|
||||
|
||||
RelativeSizeAxes = Axes.X;
|
||||
|
@ -83,7 +83,7 @@ namespace osu.Game.Screens.Select.Options
|
||||
return false;
|
||||
}
|
||||
|
||||
public override bool Contains(Vector2 screenSpacePos) => box.Contains(screenSpacePos);
|
||||
protected override bool InternalContains(Vector2 screenSpacePos) => box.Contains(screenSpacePos);
|
||||
|
||||
public BeatmapOptionsButton()
|
||||
{
|
||||
|
@ -2,10 +2,8 @@
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using OpenTK;
|
||||
using OpenTK.Input;
|
||||
using osu.Framework.Allocation;
|
||||
@ -19,7 +17,6 @@ using osu.Framework.Graphics.Primitives;
|
||||
using osu.Framework.Graphics.Transforms;
|
||||
using osu.Framework.Input;
|
||||
using osu.Framework.Screens;
|
||||
using osu.Framework.Threading;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Beatmaps.Drawables;
|
||||
using osu.Game.Database;
|
||||
@ -38,7 +35,7 @@ namespace osu.Game.Screens.Select
|
||||
private BeatmapDatabase database;
|
||||
protected override BackgroundScreen CreateBackground() => new BackgroundScreenBeatmap(Beatmap);
|
||||
|
||||
private CarouselContainer carousel;
|
||||
private BeatmapCarousel carousel;
|
||||
private TrackManager trackManager;
|
||||
private DialogOverlay dialogOverlay;
|
||||
|
||||
@ -57,43 +54,25 @@ namespace osu.Game.Screens.Select
|
||||
private SampleChannel sampleChangeDifficulty;
|
||||
private SampleChannel sampleChangeBeatmap;
|
||||
|
||||
private List<BeatmapGroup> beatmapGroups;
|
||||
|
||||
protected virtual bool ShowFooter => true;
|
||||
|
||||
/// <summary>
|
||||
/// Can be null if <see cref="ShowFooter"/> == false
|
||||
/// Can be null if <see cref="ShowFooter"/> is false.
|
||||
/// </summary>
|
||||
protected readonly BeatmapOptionsOverlay BeatmapOptions;
|
||||
|
||||
/// <summary>
|
||||
/// Can be null if <see cref="ShowFooter"/> == false
|
||||
/// Can be null if <see cref="ShowFooter"/> is false.
|
||||
/// </summary>
|
||||
protected readonly Footer Footer;
|
||||
|
||||
private FilterControl filter;
|
||||
public FilterControl Filter
|
||||
{
|
||||
get
|
||||
{
|
||||
return filter;
|
||||
}
|
||||
private set
|
||||
{
|
||||
if (filter != value)
|
||||
{
|
||||
filter = value;
|
||||
filterChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
public readonly FilterControl FilterControl;
|
||||
|
||||
protected SongSelect()
|
||||
{
|
||||
const float carousel_width = 640;
|
||||
const float filter_height = 100;
|
||||
|
||||
beatmapGroups = new List<BeatmapGroup>();
|
||||
Add(new ParallaxContainer
|
||||
{
|
||||
Padding = new MarginPadding { Top = filter_height },
|
||||
@ -122,18 +101,20 @@ namespace osu.Game.Screens.Select
|
||||
Right = left_area_padding * 2,
|
||||
}
|
||||
});
|
||||
Add(carousel = new CarouselContainer
|
||||
Add(carousel = new BeatmapCarousel
|
||||
{
|
||||
RelativeSizeAxes = Axes.Y,
|
||||
Size = new Vector2(carousel_width, 1),
|
||||
Anchor = Anchor.CentreRight,
|
||||
Origin = Anchor.CentreRight,
|
||||
SelectionChanged = selectionChanged,
|
||||
StartRequested = raiseSelect
|
||||
});
|
||||
Add(filter = new FilterControl
|
||||
Add(FilterControl = new FilterControl
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
Height = filter_height,
|
||||
FilterChanged = () => filterChanged(),
|
||||
FilterChanged = criteria => filterChanged(criteria),
|
||||
Exit = Exit,
|
||||
});
|
||||
Add(beatmapInfoWedge = new BeatmapInfoWedge
|
||||
@ -167,8 +148,7 @@ namespace osu.Game.Screens.Select
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader(permitNulls: true)]
|
||||
private void load(BeatmapDatabase beatmaps, AudioManager audio, DialogOverlay dialog, Framework.Game game,
|
||||
OsuGame osu, OsuColour colours)
|
||||
private void load(BeatmapDatabase beatmaps, AudioManager audio, DialogOverlay dialog, OsuGame osu, OsuColour colours)
|
||||
{
|
||||
if (Footer != null)
|
||||
{
|
||||
@ -196,7 +176,16 @@ namespace osu.Game.Screens.Select
|
||||
|
||||
initialAddSetsTask = new CancellationTokenSource();
|
||||
|
||||
Task.Factory.StartNew(() => addBeatmapSets(game, initialAddSetsTask.Token), initialAddSetsTask.Token);
|
||||
carousel.BeatmapsChanged = beatmapsLoaded;
|
||||
carousel.Beatmaps = database.Query<BeatmapSetInfo>().Where(b => !b.DeletePending);
|
||||
}
|
||||
|
||||
private void beatmapsLoaded()
|
||||
{
|
||||
if (Beatmap != null)
|
||||
carousel.SelectBeatmap(Beatmap.BeatmapInfo, false);
|
||||
else
|
||||
carousel.SelectNext();
|
||||
}
|
||||
|
||||
private void raiseSelect()
|
||||
@ -208,61 +197,15 @@ namespace osu.Game.Screens.Select
|
||||
}
|
||||
|
||||
public void SelectRandom() => carousel.SelectRandom();
|
||||
|
||||
protected abstract void OnSelected();
|
||||
|
||||
private ScheduledDelegate filterTask;
|
||||
|
||||
private void filterChanged(bool debounce = true, bool eagerSelection = true)
|
||||
private void filterChanged(FilterCriteria criteria, bool debounce = true)
|
||||
{
|
||||
filterTask?.Cancel();
|
||||
filterTask = Scheduler.AddDelayed(() =>
|
||||
{
|
||||
filterTask = null;
|
||||
var search = filter.Search;
|
||||
BeatmapGroup newSelection = null;
|
||||
carousel.Sort(filter.Sort);
|
||||
foreach (var beatmapGroup in carousel)
|
||||
{
|
||||
var set = beatmapGroup.BeatmapSet;
|
||||
|
||||
bool hasCurrentMode = set.Beatmaps.Any(bm => bm.Mode == playMode);
|
||||
|
||||
bool match = hasCurrentMode;
|
||||
|
||||
match &= string.IsNullOrEmpty(search)
|
||||
|| (set.Metadata.Artist ?? "").IndexOf(search, StringComparison.InvariantCultureIgnoreCase) != -1
|
||||
|| (set.Metadata.ArtistUnicode ?? "").IndexOf(search, StringComparison.InvariantCultureIgnoreCase) != -1
|
||||
|| (set.Metadata.Title ?? "").IndexOf(search, StringComparison.InvariantCultureIgnoreCase) != -1
|
||||
|| (set.Metadata.TitleUnicode ?? "").IndexOf(search, StringComparison.InvariantCultureIgnoreCase) != -1;
|
||||
|
||||
if (match)
|
||||
{
|
||||
if (newSelection == null || beatmapGroup.BeatmapSet.OnlineBeatmapSetID == Beatmap.BeatmapSetInfo.OnlineBeatmapSetID)
|
||||
{
|
||||
if (newSelection != null)
|
||||
newSelection.State = BeatmapGroupState.Collapsed;
|
||||
newSelection = beatmapGroup;
|
||||
}
|
||||
else
|
||||
beatmapGroup.State = BeatmapGroupState.Collapsed;
|
||||
}
|
||||
else
|
||||
{
|
||||
beatmapGroup.State = BeatmapGroupState.Hidden;
|
||||
}
|
||||
}
|
||||
|
||||
if (newSelection != null)
|
||||
{
|
||||
if (newSelection.BeatmapPanels.Any(b => b.Beatmap.ID == Beatmap.BeatmapInfo.ID))
|
||||
carousel.SelectBeatmap(Beatmap.BeatmapInfo, false);
|
||||
else if (eagerSelection)
|
||||
carousel.SelectBeatmap(newSelection.BeatmapSet.Beatmaps[0], false);
|
||||
}
|
||||
}, debounce ? 250 : 0);
|
||||
carousel.Filter(criteria, debounce);
|
||||
}
|
||||
|
||||
private void onBeatmapSetAdded(BeatmapSetInfo s) => Schedule(() => addBeatmapSet(s, Game, true));
|
||||
private void onBeatmapSetAdded(BeatmapSetInfo s) => carousel.AddBeatmap(s);
|
||||
|
||||
private void onBeatmapSetRemoved(BeatmapSetInfo s) => Schedule(() => removeBeatmapSet(s));
|
||||
|
||||
@ -277,7 +220,7 @@ namespace osu.Game.Screens.Select
|
||||
|
||||
beatmapInfoWedge.State = Visibility.Visible;
|
||||
|
||||
filter.Activate();
|
||||
FilterControl.Activate();
|
||||
}
|
||||
|
||||
protected override void OnResuming(Screen last)
|
||||
@ -290,7 +233,7 @@ namespace osu.Game.Screens.Select
|
||||
|
||||
Content.ScaleTo(1, 250, EasingTypes.OutSine);
|
||||
|
||||
filter.Activate();
|
||||
FilterControl.Activate();
|
||||
}
|
||||
|
||||
protected override void OnSuspending(Screen next)
|
||||
@ -299,7 +242,7 @@ namespace osu.Game.Screens.Select
|
||||
|
||||
Content.FadeOut(250);
|
||||
|
||||
filter.Deactivate();
|
||||
FilterControl.Deactivate();
|
||||
base.OnSuspending(next);
|
||||
}
|
||||
|
||||
@ -309,7 +252,7 @@ namespace osu.Game.Screens.Select
|
||||
|
||||
Content.FadeOut(100);
|
||||
|
||||
filter.Deactivate();
|
||||
FilterControl.Deactivate();
|
||||
return base.OnExiting(next);
|
||||
}
|
||||
|
||||
@ -323,10 +266,7 @@ namespace osu.Game.Screens.Select
|
||||
initialAddSetsTask.Cancel();
|
||||
}
|
||||
|
||||
private void playMode_ValueChanged(object sender, EventArgs e)
|
||||
{
|
||||
filterChanged(false);
|
||||
}
|
||||
private void playMode_ValueChanged(object sender, EventArgs e) => carousel.Filter();
|
||||
|
||||
private void changeBackground(WorkingBeatmap beatmap)
|
||||
{
|
||||
@ -387,63 +327,18 @@ namespace osu.Game.Screens.Select
|
||||
}
|
||||
}
|
||||
|
||||
private void addBeatmapSet(BeatmapSetInfo beatmapSet, Framework.Game game, bool select = false)
|
||||
private void selectBeatmap(BeatmapSetInfo beatmapSet = null)
|
||||
{
|
||||
beatmapSet = database.GetWithChildren<BeatmapSetInfo>(beatmapSet.ID);
|
||||
beatmapSet.Beatmaps.ForEach(b =>
|
||||
{
|
||||
database.GetChildren(b);
|
||||
if (b.Metadata == null) b.Metadata = beatmapSet.Metadata;
|
||||
});
|
||||
|
||||
var group = new BeatmapGroup(beatmapSet, database)
|
||||
{
|
||||
SelectionChanged = selectionChanged,
|
||||
StartRequested = b => raiseSelect()
|
||||
};
|
||||
|
||||
//for the time being, let's completely load the difficulty panels in the background.
|
||||
//this likely won't scale so well, but allows us to completely async the loading flow.
|
||||
Task.WhenAll(group.BeatmapPanels.Select(panel => panel.LoadAsync(game))).ContinueWith(task => Schedule(delegate
|
||||
{
|
||||
beatmapGroups.Add(group);
|
||||
|
||||
group.State = BeatmapGroupState.Collapsed;
|
||||
carousel.AddGroup(group);
|
||||
|
||||
filterChanged(false, false);
|
||||
|
||||
if (Beatmap == null || select)
|
||||
carousel.SelectBeatmap(beatmapSet.Beatmaps.First());
|
||||
else
|
||||
carousel.SelectBeatmap(Beatmap.BeatmapInfo);
|
||||
}));
|
||||
carousel.SelectBeatmap(beatmapSet != null ? beatmapSet.Beatmaps.First() : Beatmap?.BeatmapInfo);
|
||||
}
|
||||
|
||||
private void removeBeatmapSet(BeatmapSetInfo beatmapSet)
|
||||
{
|
||||
var group = beatmapGroups.Find(b => b.BeatmapSet.ID == beatmapSet.ID);
|
||||
if (group == null) return;
|
||||
|
||||
if (carousel.SelectedGroup == group)
|
||||
carousel.SelectNext();
|
||||
|
||||
beatmapGroups.Remove(group);
|
||||
carousel.RemoveGroup(group);
|
||||
|
||||
if (beatmapGroups.Count == 0)
|
||||
carousel.RemoveBeatmap(beatmapSet);
|
||||
if (carousel.SelectedBeatmap == null)
|
||||
Beatmap = null;
|
||||
}
|
||||
|
||||
private void addBeatmapSets(Framework.Game game, CancellationToken token)
|
||||
{
|
||||
foreach (var beatmapSet in database.Query<BeatmapSetInfo>().Where(b => !b.DeletePending))
|
||||
{
|
||||
if (token.IsCancellationRequested) return;
|
||||
addBeatmapSet(beatmapSet, game);
|
||||
}
|
||||
}
|
||||
|
||||
private void promptDelete()
|
||||
{
|
||||
if (Beatmap != null)
|
||||
|
@ -75,9 +75,11 @@
|
||||
<Compile Include="Beatmaps\DifficultyCalculator.cs" />
|
||||
<Compile Include="Beatmaps\IBeatmapCoverter.cs" />
|
||||
<Compile Include="Beatmaps\IBeatmapProcessor.cs" />
|
||||
<Compile Include="Beatmaps\Timing\TimingInfo.cs" />
|
||||
<Compile Include="Database\ScoreDatabase.cs" />
|
||||
<Compile Include="Graphics\Backgrounds\Triangles.cs" />
|
||||
<Compile Include="Graphics\Cursor\CursorTrail.cs" />
|
||||
<Compile Include="Graphics\Cursor\GameplayCursor.cs" />
|
||||
<Compile Include="Graphics\Sprites\OsuSpriteText.cs" />
|
||||
<Compile Include="Graphics\UserInterface\BackButton.cs" />
|
||||
<Compile Include="Graphics\UserInterface\FocusedTextBox.cs" />
|
||||
@ -119,7 +121,7 @@
|
||||
<Compile Include="Modes\Objects\Legacy\LegacyHitObjectType.cs" />
|
||||
<Compile Include="Modes\Replay.cs" />
|
||||
<Compile Include="Modes\Score.cs" />
|
||||
<Compile Include="Modes\ScoreProcesssor.cs" />
|
||||
<Compile Include="Modes\ScoreProcessor.cs" />
|
||||
<Compile Include="Modes\UI\HealthDisplay.cs" />
|
||||
<Compile Include="Modes\UI\HudOverlay.cs" />
|
||||
<Compile Include="Modes\UI\StandardHealthDisplay.cs" />
|
||||
@ -196,7 +198,10 @@
|
||||
<Compile Include="Screens\Play\PlayerLoader.cs" />
|
||||
<Compile Include="Screens\Play\SkipButton.cs" />
|
||||
<Compile Include="Modes\UI\StandardComboCounter.cs" />
|
||||
<Compile Include="Screens\Select\CarouselContainer.cs" />
|
||||
<Compile Include="Screens\Select\BeatmapCarousel.cs" />
|
||||
<Compile Include="Screens\Select\FilterCriteria.cs" />
|
||||
<Compile Include="Screens\Select\Filter\GroupMode.cs" />
|
||||
<Compile Include="Screens\Select\Filter\SortMode.cs" />
|
||||
<Compile Include="Screens\Select\MatchSongSelect.cs" />
|
||||
<Compile Include="Screens\OsuGameScreen.cs" />
|
||||
<Compile Include="Beatmaps\Drawables\BeatmapGroup.cs" />
|
||||
@ -219,7 +224,7 @@
|
||||
<Compile Include="Input\GlobalHotkeys.cs" />
|
||||
<Compile Include="Graphics\Backgrounds\Background.cs" />
|
||||
<Compile Include="Graphics\Containers\ParallaxContainer.cs" />
|
||||
<Compile Include="Graphics\Cursor\OsuCursorContainer.cs" />
|
||||
<Compile Include="Graphics\Cursor\MenuCursor.cs" />
|
||||
<Compile Include="Graphics\Processing\RatioAdjust.cs" />
|
||||
<Compile Include="Graphics\TextAwesome.cs" />
|
||||
<Compile Include="Screens\Play\KeyCounter.cs" />
|
||||
@ -355,6 +360,8 @@
|
||||
<Compile Include="Modes\ScoreRank.cs" />
|
||||
<Compile Include="Users\Avatar.cs" />
|
||||
<Compile Include="Screens\Select\Leaderboards\DrawableRank.cs" />
|
||||
<Compile Include="Graphics\UserInterface\OsuTabControl.cs" />
|
||||
<Compile Include="Graphics\UserInterface\OsuTabItem.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="$(SolutionDir)\osu-framework\osu.Framework\osu.Framework.csproj">
|
||||
|
@ -1,4 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<!--
|
||||
Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
||||
Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
Loading…
x
Reference in New Issue
Block a user