mirror of
https://github.com/ppy/osu.git
synced 2026-05-14 21:53:40 +08:00
Compare commits
49 Commits
2018.701.0
...
2018.702.0
@@ -15,6 +15,8 @@ namespace osu.Game.Rulesets.Catch.Beatmaps
|
||||
{
|
||||
public class CatchBeatmapProcessor : BeatmapProcessor
|
||||
{
|
||||
public const int RNG_SEED = 1337;
|
||||
|
||||
public CatchBeatmapProcessor(IBeatmap beatmap)
|
||||
: base(beatmap)
|
||||
{
|
||||
@@ -22,12 +24,12 @@ namespace osu.Game.Rulesets.Catch.Beatmaps
|
||||
|
||||
public override void PostProcess()
|
||||
{
|
||||
base.PostProcess();
|
||||
|
||||
applyPositionOffsets();
|
||||
|
||||
initialiseHyperDash((List<CatchHitObject>)Beatmap.HitObjects);
|
||||
|
||||
base.PostProcess();
|
||||
|
||||
int index = 0;
|
||||
foreach (var obj in Beatmap.HitObjects.OfType<CatchHitObject>())
|
||||
{
|
||||
@@ -37,8 +39,6 @@ namespace osu.Game.Rulesets.Catch.Beatmaps
|
||||
}
|
||||
}
|
||||
|
||||
public const int RNG_SEED = 1337;
|
||||
|
||||
private void applyPositionOffsets()
|
||||
{
|
||||
var rng = new FastRandom(RNG_SEED);
|
||||
|
||||
@@ -69,7 +69,7 @@ namespace osu.Game.Rulesets.Mania.Tests
|
||||
var obj = new Note { Column = i, StartTime = Time.Current + 2000 };
|
||||
obj.ApplyDefaults(new ControlPointInfo(), new BeatmapDifficulty());
|
||||
|
||||
columns[i].Add(new DrawableNote(obj, columns[i].Action));
|
||||
columns[i].Add(new DrawableNote(obj));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -80,7 +80,7 @@ namespace osu.Game.Rulesets.Mania.Tests
|
||||
var obj = new HoldNote { Column = i, StartTime = Time.Current + 2000, Duration = 500 };
|
||||
obj.ApplyDefaults(new ControlPointInfo(), new BeatmapDifficulty());
|
||||
|
||||
columns[i].Add(new DrawableHoldNote(obj, columns[i].Action));
|
||||
columns[i].Add(new DrawableHoldNote(obj));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -92,7 +92,7 @@ namespace osu.Game.Rulesets.Mania.Tests
|
||||
Origin = Anchor.Centre,
|
||||
Height = 0.85f,
|
||||
AccentColour = Color4.OrangeRed,
|
||||
Action = action,
|
||||
Action = { Value = action },
|
||||
VisibleTimeRange = { Value = 2000 }
|
||||
};
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Configuration;
|
||||
using osu.Framework.Extensions.Color4Extensions;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
@@ -63,7 +64,7 @@ namespace osu.Game.Rulesets.Mania.Tests
|
||||
AutoSizeAxes = Axes.Both,
|
||||
Child = new NoteContainer(direction, $"note, scrolling {direction.ToString().ToLower()}")
|
||||
{
|
||||
Child = new DrawableNote(note, ManiaAction.Key1) { AccentColour = Color4.OrangeRed }
|
||||
Child = new DrawableNote(note) { AccentColour = Color4.OrangeRed }
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -78,7 +79,7 @@ namespace osu.Game.Rulesets.Mania.Tests
|
||||
AutoSizeAxes = Axes.Both,
|
||||
Child = new NoteContainer(direction, $"hold note, scrolling {direction.ToString().ToLower()}")
|
||||
{
|
||||
Child = new DrawableHoldNote(note, ManiaAction.Key1)
|
||||
Child = new DrawableHoldNote(note)
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
AccentColour = Color4.OrangeRed,
|
||||
@@ -136,6 +137,13 @@ namespace osu.Game.Rulesets.Mania.Tests
|
||||
};
|
||||
}
|
||||
|
||||
protected override IReadOnlyDependencyContainer CreateLocalDependencies(IReadOnlyDependencyContainer parent)
|
||||
{
|
||||
var dependencies = new DependencyContainer(base.CreateLocalDependencies(parent));
|
||||
dependencies.CacheAs<IBindable<ManiaAction>>(new Bindable<ManiaAction>());
|
||||
return dependencies;
|
||||
}
|
||||
|
||||
protected override void Update()
|
||||
{
|
||||
base.Update();
|
||||
|
||||
@@ -65,7 +65,7 @@ namespace osu.Game.Rulesets.Mania.Tests
|
||||
var obj = new Note { Column = i, StartTime = Time.Current + 2000 };
|
||||
obj.ApplyDefaults(new ControlPointInfo(), new BeatmapDifficulty());
|
||||
|
||||
stage.Add(new DrawableNote(obj, stage.Columns[i].Action));
|
||||
stage.Add(new DrawableNote(obj));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -79,7 +79,7 @@ namespace osu.Game.Rulesets.Mania.Tests
|
||||
var obj = new HoldNote { Column = i, StartTime = Time.Current + 2000, Duration = 500 };
|
||||
obj.ApplyDefaults(new ControlPointInfo(), new BeatmapDifficulty());
|
||||
|
||||
stage.Add(new DrawableHoldNote(obj, stage.Columns[i].Action));
|
||||
stage.Add(new DrawableHoldNote(obj));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,8 +38,8 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables
|
||||
|
||||
private readonly Container<DrawableHoldNoteTick> tickContainer;
|
||||
|
||||
public DrawableHoldNote(HoldNote hitObject, ManiaAction action)
|
||||
: base(hitObject, action)
|
||||
public DrawableHoldNote(HoldNote hitObject)
|
||||
: base(hitObject)
|
||||
{
|
||||
RelativeSizeAxes = Axes.X;
|
||||
|
||||
@@ -57,12 +57,12 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables
|
||||
HoldStartTime = () => holdStartTime
|
||||
})
|
||||
},
|
||||
head = new DrawableHeadNote(this, action)
|
||||
head = new DrawableHeadNote(this)
|
||||
{
|
||||
Anchor = Anchor.TopCentre,
|
||||
Origin = Anchor.TopCentre
|
||||
},
|
||||
tail = new DrawableTailNote(this, action)
|
||||
tail = new DrawableTailNote(this)
|
||||
{
|
||||
Anchor = Anchor.TopCentre,
|
||||
Origin = Anchor.TopCentre
|
||||
@@ -118,7 +118,7 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables
|
||||
if (Time.Current < HitObject.StartTime || Time.Current > HitObject.EndTime)
|
||||
return false;
|
||||
|
||||
if (action != Action)
|
||||
if (action != Action.Value)
|
||||
return false;
|
||||
|
||||
// The user has pressed during the body of the hold note, after the head note and its hit windows have passed
|
||||
@@ -135,7 +135,7 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables
|
||||
if (!holdStartTime.HasValue)
|
||||
return false;
|
||||
|
||||
if (action != Action)
|
||||
if (action != Action.Value)
|
||||
return false;
|
||||
|
||||
holdStartTime = null;
|
||||
@@ -154,8 +154,8 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables
|
||||
{
|
||||
private readonly DrawableHoldNote holdNote;
|
||||
|
||||
public DrawableHeadNote(DrawableHoldNote holdNote, ManiaAction action)
|
||||
: base(holdNote.HitObject.Head, action)
|
||||
public DrawableHeadNote(DrawableHoldNote holdNote)
|
||||
: base(holdNote.HitObject.Head)
|
||||
{
|
||||
this.holdNote = holdNote;
|
||||
}
|
||||
@@ -191,8 +191,8 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables
|
||||
|
||||
private readonly DrawableHoldNote holdNote;
|
||||
|
||||
public DrawableTailNote(DrawableHoldNote holdNote, ManiaAction action)
|
||||
: base(holdNote.HitObject.Tail, action)
|
||||
public DrawableTailNote(DrawableHoldNote holdNote)
|
||||
: base(holdNote.HitObject.Tail)
|
||||
{
|
||||
this.holdNote = holdNote;
|
||||
}
|
||||
@@ -235,7 +235,7 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables
|
||||
if (!holdNote.holdStartTime.HasValue)
|
||||
return false;
|
||||
|
||||
if (action != Action)
|
||||
if (action != Action.Value)
|
||||
return false;
|
||||
|
||||
UpdateJudgement(true);
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using JetBrains.Annotations;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Configuration;
|
||||
using osu.Framework.Graphics;
|
||||
@@ -10,30 +11,26 @@ using osu.Game.Rulesets.UI.Scrolling;
|
||||
|
||||
namespace osu.Game.Rulesets.Mania.Objects.Drawables
|
||||
{
|
||||
public abstract class DrawableManiaHitObject<TObject> : DrawableHitObject<ManiaHitObject>
|
||||
where TObject : ManiaHitObject
|
||||
public abstract class DrawableManiaHitObject : DrawableHitObject<ManiaHitObject>
|
||||
{
|
||||
/// <summary>
|
||||
/// The key that will trigger input for this hit object.
|
||||
/// The <see cref="ManiaAction"/> which causes this <see cref="DrawableManiaHitObject{TObject}"/> to be hit.
|
||||
/// </summary>
|
||||
protected ManiaAction Action { get; }
|
||||
|
||||
public new TObject HitObject;
|
||||
protected readonly IBindable<ManiaAction> Action = new Bindable<ManiaAction>();
|
||||
|
||||
protected readonly IBindable<ScrollingDirection> Direction = new Bindable<ScrollingDirection>();
|
||||
|
||||
protected DrawableManiaHitObject(TObject hitObject, ManiaAction? action = null)
|
||||
protected DrawableManiaHitObject(ManiaHitObject hitObject)
|
||||
: base(hitObject)
|
||||
{
|
||||
HitObject = hitObject;
|
||||
|
||||
if (action != null)
|
||||
Action = action.Value;
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(IScrollingInfo scrollingInfo)
|
||||
[BackgroundDependencyLoader(true)]
|
||||
private void load([CanBeNull] IBindable<ManiaAction> action, [NotNull] IScrollingInfo scrollingInfo)
|
||||
{
|
||||
if (action != null)
|
||||
Action.BindTo(action);
|
||||
|
||||
Direction.BindTo(scrollingInfo.Direction);
|
||||
Direction.BindValueChanged(OnDirectionChanged, true);
|
||||
}
|
||||
@@ -42,6 +39,18 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables
|
||||
{
|
||||
Anchor = Origin = direction == ScrollingDirection.Up ? Anchor.TopCentre : Anchor.BottomCentre;
|
||||
}
|
||||
}
|
||||
|
||||
public abstract class DrawableManiaHitObject<TObject> : DrawableManiaHitObject
|
||||
where TObject : ManiaHitObject
|
||||
{
|
||||
public new readonly TObject HitObject;
|
||||
|
||||
protected DrawableManiaHitObject(TObject hitObject)
|
||||
: base(hitObject)
|
||||
{
|
||||
HitObject = hitObject;
|
||||
}
|
||||
|
||||
protected override void UpdateState(ArmedState state)
|
||||
{
|
||||
|
||||
@@ -20,8 +20,8 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables
|
||||
{
|
||||
private readonly NotePiece headPiece;
|
||||
|
||||
public DrawableNote(Note hitObject, ManiaAction action)
|
||||
: base(hitObject, action)
|
||||
public DrawableNote(Note hitObject)
|
||||
: base(hitObject)
|
||||
{
|
||||
RelativeSizeAxes = Axes.X;
|
||||
AutoSizeAxes = Axes.Y;
|
||||
@@ -74,7 +74,7 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables
|
||||
|
||||
public virtual bool OnPressed(ManiaAction action)
|
||||
{
|
||||
if (action != Action)
|
||||
if (action != Action.Value)
|
||||
return false;
|
||||
|
||||
return UpdateJudgement(true);
|
||||
|
||||
@@ -7,6 +7,8 @@ using osu.Framework.Graphics.Containers;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Rulesets.Objects.Drawables;
|
||||
using System.Linq;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Configuration;
|
||||
using osu.Framework.Input.Bindings;
|
||||
using osu.Game.Rulesets.Judgements;
|
||||
using osu.Game.Rulesets.Mania.UI.Components;
|
||||
@@ -19,21 +21,7 @@ namespace osu.Game.Rulesets.Mania.UI
|
||||
private const float column_width = 45;
|
||||
private const float special_column_width = 70;
|
||||
|
||||
private ManiaAction action;
|
||||
|
||||
public ManiaAction Action
|
||||
{
|
||||
get => action;
|
||||
set
|
||||
{
|
||||
if (action == value)
|
||||
return;
|
||||
action = value;
|
||||
|
||||
background.Action = value;
|
||||
keyArea.Action = value;
|
||||
}
|
||||
}
|
||||
public readonly Bindable<ManiaAction> Action = new Bindable<ManiaAction>();
|
||||
|
||||
private readonly ColumnBackground background;
|
||||
private readonly ColumnKeyArea keyArea;
|
||||
@@ -130,6 +118,13 @@ namespace osu.Game.Rulesets.Mania.UI
|
||||
}
|
||||
}
|
||||
|
||||
protected override IReadOnlyDependencyContainer CreateLocalDependencies(IReadOnlyDependencyContainer parent)
|
||||
{
|
||||
var dependencies = new DependencyContainer(base.CreateLocalDependencies(parent));
|
||||
dependencies.CacheAs<IBindable<ManiaAction>>(Action);
|
||||
return dependencies;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds a DrawableHitObject to this Playfield.
|
||||
/// </summary>
|
||||
|
||||
@@ -17,7 +17,7 @@ namespace osu.Game.Rulesets.Mania.UI.Components
|
||||
{
|
||||
public class ColumnBackground : CompositeDrawable, IKeyBindingHandler<ManiaAction>, IHasAccentColour
|
||||
{
|
||||
public ManiaAction Action;
|
||||
private readonly IBindable<ManiaAction> action = new Bindable<ManiaAction>();
|
||||
|
||||
private Box background;
|
||||
private Box backgroundOverlay;
|
||||
@@ -25,8 +25,10 @@ namespace osu.Game.Rulesets.Mania.UI.Components
|
||||
private readonly IBindable<ScrollingDirection> direction = new Bindable<ScrollingDirection>();
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(IScrollingInfo scrollingInfo)
|
||||
private void load(IBindable<ManiaAction> action, IScrollingInfo scrollingInfo)
|
||||
{
|
||||
this.action.BindTo(action);
|
||||
|
||||
InternalChildren = new[]
|
||||
{
|
||||
background = new Box
|
||||
@@ -91,14 +93,14 @@ namespace osu.Game.Rulesets.Mania.UI.Components
|
||||
|
||||
public bool OnPressed(ManiaAction action)
|
||||
{
|
||||
if (action == Action)
|
||||
if (action == this.action.Value)
|
||||
backgroundOverlay.FadeTo(1, 50, Easing.OutQuint).Then().FadeTo(0.5f, 250, Easing.OutQuint);
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool OnReleased(ManiaAction action)
|
||||
{
|
||||
if (action == Action)
|
||||
if (action == this.action.Value)
|
||||
backgroundOverlay.FadeTo(0, 250, Easing.OutQuint);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -21,15 +21,16 @@ namespace osu.Game.Rulesets.Mania.UI.Components
|
||||
private const float key_icon_size = 10;
|
||||
private const float key_icon_corner_radius = 3;
|
||||
|
||||
public ManiaAction Action;
|
||||
|
||||
private readonly IBindable<ManiaAction> action = new Bindable<ManiaAction>();
|
||||
private readonly IBindable<ScrollingDirection> direction = new Bindable<ScrollingDirection>();
|
||||
|
||||
private Container keyIcon;
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(IScrollingInfo scrollingInfo)
|
||||
private void load(IBindable<ManiaAction> action, IScrollingInfo scrollingInfo)
|
||||
{
|
||||
this.action.BindTo(action);
|
||||
|
||||
Drawable gradient;
|
||||
|
||||
InternalChildren = new[]
|
||||
@@ -107,14 +108,14 @@ namespace osu.Game.Rulesets.Mania.UI.Components
|
||||
|
||||
public bool OnPressed(ManiaAction action)
|
||||
{
|
||||
if (action == Action)
|
||||
if (action == this.action.Value)
|
||||
keyIcon.ScaleTo(1.4f, 50, Easing.OutQuint).Then().ScaleTo(1.3f, 250, Easing.OutQuint);
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool OnReleased(ManiaAction action)
|
||||
{
|
||||
if (action == Action)
|
||||
if (action == this.action.Value)
|
||||
keyIcon.ScaleTo(1f, 125, Easing.OutQuint);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -101,17 +101,15 @@ namespace osu.Game.Rulesets.Mania.UI
|
||||
|
||||
protected override DrawableHitObject<ManiaHitObject> GetVisualRepresentation(ManiaHitObject h)
|
||||
{
|
||||
ManiaAction action = Playfield.Columns.ElementAt(h.Column).Action;
|
||||
|
||||
var holdNote = h as HoldNote;
|
||||
if (holdNote != null)
|
||||
return new DrawableHoldNote(holdNote, action);
|
||||
|
||||
var note = h as Note;
|
||||
if (note != null)
|
||||
return new DrawableNote(note, action);
|
||||
|
||||
return null;
|
||||
switch (h)
|
||||
{
|
||||
case HoldNote holdNote:
|
||||
return new DrawableHoldNote(holdNote);
|
||||
case Note note:
|
||||
return new DrawableNote(note);
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
protected override Vector2 PlayfieldArea => new Vector2(1, 0.8f);
|
||||
|
||||
@@ -127,7 +127,7 @@ namespace osu.Game.Rulesets.Mania.UI
|
||||
var column = new Column(direction)
|
||||
{
|
||||
IsSpecial = isSpecial,
|
||||
Action = isSpecial ? specialColumnStartAction++ : normalColumnStartAction++
|
||||
Action = { Value = isSpecial ? specialColumnStartAction++ : normalColumnStartAction++ }
|
||||
};
|
||||
|
||||
AddColumn(column);
|
||||
|
||||
@@ -15,10 +15,10 @@ namespace osu.Game.Rulesets.Osu.Beatmaps
|
||||
{
|
||||
}
|
||||
|
||||
public override void PostProcess()
|
||||
public override void PreProcess()
|
||||
{
|
||||
base.PreProcess();
|
||||
applyStacking((Beatmap<OsuHitObject>)Beatmap);
|
||||
base.PostProcess();
|
||||
}
|
||||
|
||||
private void applyStacking(Beatmap<OsuHitObject> beatmap)
|
||||
@@ -44,7 +44,7 @@ namespace osu.Game.Rulesets.Osu.Beatmaps
|
||||
continue;
|
||||
|
||||
double endTime = (stackBaseObject as IHasEndTime)?.EndTime ?? stackBaseObject.StartTime;
|
||||
double stackThreshold = objectN.TimePreempt * beatmap.BeatmapInfo?.StackLeniency ?? 0.7f;
|
||||
double stackThreshold = objectN.TimePreempt * beatmap.BeatmapInfo.StackLeniency;
|
||||
|
||||
if (objectN.StartTime - endTime > stackThreshold)
|
||||
//We are no longer within stacking range of the next object.
|
||||
@@ -87,7 +87,7 @@ namespace osu.Game.Rulesets.Osu.Beatmaps
|
||||
OsuHitObject objectI = beatmap.HitObjects[i];
|
||||
if (objectI.StackHeight != 0 || objectI is Spinner) continue;
|
||||
|
||||
double stackThreshold = objectI.TimePreempt * beatmap.BeatmapInfo?.StackLeniency ?? 0.7f;
|
||||
double stackThreshold = objectI.TimePreempt * beatmap.BeatmapInfo.StackLeniency;
|
||||
|
||||
/* If this object is a hitcircle, then we enter this "special" case.
|
||||
* It either ends with a stack of hitcircles only, or a stack of hitcircles that are underneath a slider.
|
||||
|
||||
@@ -37,7 +37,7 @@ namespace osu.Game.Rulesets.Taiko.UI
|
||||
private void loadBarLines()
|
||||
{
|
||||
TaikoHitObject lastObject = Beatmap.HitObjects[Beatmap.HitObjects.Count - 1];
|
||||
double lastHitTime = 1 + (lastObject as IHasEndTime)?.EndTime ?? lastObject.StartTime;
|
||||
double lastHitTime = 1 + ((lastObject as IHasEndTime)?.EndTime ?? lastObject.StartTime);
|
||||
|
||||
var timingPoints = Beatmap.ControlPointInfo.TimingPoints.ToList();
|
||||
|
||||
|
||||
@@ -65,17 +65,19 @@ namespace osu.Game.Tests.Visual
|
||||
|
||||
foreach (var rulesetInfo in rulesets.AvailableRulesets)
|
||||
{
|
||||
var ruleset = rulesetInfo.CreateInstance();
|
||||
var instance = rulesetInfo.CreateInstance();
|
||||
var testBeatmap = createTestBeatmap(rulesetInfo);
|
||||
|
||||
beatmaps.Add(testBeatmap);
|
||||
|
||||
AddStep("set ruleset", () => Ruleset.Value = rulesetInfo);
|
||||
|
||||
selectBeatmap(testBeatmap);
|
||||
|
||||
testBeatmapLabels(ruleset);
|
||||
testBeatmapLabels(instance);
|
||||
|
||||
// TODO: adjust cases once more info is shown for other gamemodes
|
||||
switch (ruleset)
|
||||
switch (instance)
|
||||
{
|
||||
case OsuRuleset _:
|
||||
testInfoLabels(5);
|
||||
|
||||
@@ -77,7 +77,7 @@ namespace osu.Game.Tests.Visual
|
||||
foreach (var rulesetInfo in rulesets.AvailableRulesets)
|
||||
{
|
||||
Ruleset ruleset = rulesetInfo.CreateInstance();
|
||||
AddStep($"switch to {ruleset.Description}", () => modSelect.Ruleset.Value = rulesetInfo);
|
||||
AddStep($"switch to {ruleset.Description}", () => Ruleset.Value = rulesetInfo);
|
||||
|
||||
switch (ruleset)
|
||||
{
|
||||
|
||||
@@ -6,23 +6,9 @@ using osu.Game.Rulesets.Objects.Types;
|
||||
|
||||
namespace osu.Game.Beatmaps
|
||||
{
|
||||
public interface IBeatmapProcessor
|
||||
{
|
||||
IBeatmap Beatmap { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Post-processes <see cref="Beatmap"/> to add mode-specific components that aren't added during conversion.
|
||||
/// <para>
|
||||
/// An example of such a usage is for combo colours.
|
||||
/// </para>
|
||||
/// </summary>
|
||||
void PostProcess();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Processes a post-converted Beatmap.
|
||||
/// Provides functionality to alter a <see cref="IBeatmap"/> after it has been converted.
|
||||
/// </summary>
|
||||
/// <typeparam name="TObject">The type of HitObject contained in the Beatmap.</typeparam>
|
||||
public class BeatmapProcessor : IBeatmapProcessor
|
||||
{
|
||||
public IBeatmap Beatmap { get; }
|
||||
@@ -32,13 +18,7 @@ namespace osu.Game.Beatmaps
|
||||
Beatmap = beatmap;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Post-processes a Beatmap to add mode-specific components that aren't added during conversion.
|
||||
/// <para>
|
||||
/// An example of such a usage is for combo colours.
|
||||
/// </para>
|
||||
/// </summary>
|
||||
public virtual void PostProcess()
|
||||
public virtual void PreProcess()
|
||||
{
|
||||
IHasComboInformation lastObj = null;
|
||||
|
||||
@@ -62,5 +42,9 @@ namespace osu.Game.Beatmaps
|
||||
lastObj = obj;
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void PostProcess()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,6 +7,9 @@ using osu.Game.Rulesets.Objects;
|
||||
|
||||
namespace osu.Game.Beatmaps
|
||||
{
|
||||
/// <summary>
|
||||
/// Provides functionality to convert a <see cref="IBeatmap"/> for a <see cref="Ruleset"/>.
|
||||
/// </summary>
|
||||
public interface IBeatmapConverter
|
||||
{
|
||||
/// <summary>
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
namespace osu.Game.Beatmaps
|
||||
{
|
||||
/// <summary>
|
||||
/// Provides functionality to alter a <see cref="IBeatmap"/> after it has been converted.
|
||||
/// </summary>
|
||||
public interface IBeatmapProcessor
|
||||
{
|
||||
/// <summary>
|
||||
/// The <see cref="IBeatmap"/> to process. This should already be converted to the applicable <see cref="Ruleset"/>.
|
||||
/// </summary>
|
||||
IBeatmap Beatmap { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Processes the converted <see cref="Beatmap"/> prior to <see cref="HitObject.ApplyDefaults"/> being invoked.
|
||||
/// <para>
|
||||
/// Nested <see cref="HitObject"/>s generated during <see cref="HitObject.ApplyDefaults"/> will not be present by this point,
|
||||
/// and no mods will have been applied to the <see cref="HitObject"/>s.
|
||||
/// </para>
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This can only be used to add alterations to <see cref="HitObject"/>s generated directly through the conversion process.
|
||||
/// </remarks>
|
||||
void PreProcess();
|
||||
|
||||
/// <summary>
|
||||
/// Processes the converted <see cref="Beatmap"/> after <see cref="HitObject.ApplyDefaults"/> has been invoked.
|
||||
/// <para>
|
||||
/// Nested <see cref="HitObject"/>s generated during <see cref="HitObject.ApplyDefaults"/> will be present by this point,
|
||||
/// and mods will have been applied to all <see cref="HitObject"/>s.
|
||||
/// </para>
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This should be used to add alterations to <see cref="HitObject"/>s while they are in their most playable state.
|
||||
/// </remarks>
|
||||
void PostProcess();
|
||||
}
|
||||
}
|
||||
@@ -116,6 +116,10 @@ namespace osu.Game.Beatmaps
|
||||
mod.ApplyToDifficulty(converted.BeatmapInfo.BaseDifficulty);
|
||||
}
|
||||
|
||||
IBeatmapProcessor processor = rulesetInstance.CreateBeatmapProcessor(converted);
|
||||
|
||||
processor?.PreProcess();
|
||||
|
||||
// Compute default values for hitobjects, including creating nested hitobjects in-case they're needed
|
||||
foreach (var obj in converted.HitObjects)
|
||||
obj.ApplyDefaults(converted.ControlPointInfo, converted.BeatmapInfo.BaseDifficulty);
|
||||
@@ -124,8 +128,7 @@ namespace osu.Game.Beatmaps
|
||||
foreach (var obj in converted.HitObjects)
|
||||
mod.ApplyToHitObject(obj);
|
||||
|
||||
// Post-process
|
||||
rulesetInstance.CreateBeatmapProcessor(converted)?.PostProcess();
|
||||
processor?.PostProcess();
|
||||
|
||||
return converted;
|
||||
}
|
||||
|
||||
@@ -11,9 +11,9 @@ using osu.Framework.Graphics.Sprites;
|
||||
using osu.Framework.Input;
|
||||
using osu.Game.Configuration;
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using JetBrains.Annotations;
|
||||
using osu.Framework.Graphics.Textures;
|
||||
using OpenTK.Input;
|
||||
|
||||
namespace osu.Game.Graphics.Cursor
|
||||
{
|
||||
@@ -25,9 +25,8 @@ namespace osu.Game.Graphics.Cursor
|
||||
protected override Drawable CreateCursor() => new Cursor();
|
||||
|
||||
private Bindable<bool> cursorRotate;
|
||||
private bool dragging;
|
||||
|
||||
private bool startRotation;
|
||||
private DragRotationState dragRotationState;
|
||||
private Vector2 positionMouseDown;
|
||||
|
||||
[BackgroundDependencyLoader(true)]
|
||||
private void load([NotNull] OsuConfigManager config, [CanBeNull] ScreenshotManager screenshotManager)
|
||||
@@ -40,18 +39,18 @@ namespace osu.Game.Graphics.Cursor
|
||||
|
||||
protected override bool OnMouseMove(InputState state)
|
||||
{
|
||||
if (cursorRotate && dragging)
|
||||
if (dragRotationState != DragRotationState.NotDragging)
|
||||
{
|
||||
Debug.Assert(state.Mouse.PositionMouseDown != null);
|
||||
|
||||
var position = state.Mouse.Position;
|
||||
var distance = Vector2Extensions.Distance(position, positionMouseDown);
|
||||
// don't start rotating until we're moved a minimum distance away from the mouse down location,
|
||||
// else it can have an annoying effect.
|
||||
// ReSharper disable once PossibleInvalidOperationException
|
||||
startRotation |= Vector2Extensions.Distance(state.Mouse.Position, state.Mouse.PositionMouseDown.Value) > 30;
|
||||
|
||||
if (startRotation)
|
||||
if (dragRotationState == DragRotationState.DragStarted && distance > 30)
|
||||
dragRotationState = DragRotationState.Rotating;
|
||||
// don't rotate when distance is zero to avoid NaN
|
||||
if (dragRotationState == DragRotationState.Rotating && distance > 0)
|
||||
{
|
||||
Vector2 offset = state.Mouse.Position - state.Mouse.PositionMouseDown.Value;
|
||||
Vector2 offset = state.Mouse.Position - positionMouseDown;
|
||||
float degrees = (float)MathHelper.RadiansToDegrees(Math.Atan2(-offset.X, offset.Y)) + 24.3f;
|
||||
|
||||
// Always rotate in the direction of least distance
|
||||
@@ -67,12 +66,6 @@ namespace osu.Game.Graphics.Cursor
|
||||
return base.OnMouseMove(state);
|
||||
}
|
||||
|
||||
protected override bool OnDragStart(InputState state)
|
||||
{
|
||||
dragging = true;
|
||||
return base.OnDragStart(state);
|
||||
}
|
||||
|
||||
protected override bool OnMouseDown(InputState state, MouseDownEventArgs args)
|
||||
{
|
||||
ActiveCursor.Scale = new Vector2(1);
|
||||
@@ -80,6 +73,12 @@ namespace osu.Game.Graphics.Cursor
|
||||
|
||||
((Cursor)ActiveCursor).AdditiveLayer.Alpha = 0;
|
||||
((Cursor)ActiveCursor).AdditiveLayer.FadeInFromZero(800, Easing.OutQuint);
|
||||
|
||||
if (args.Button == MouseButton.Left && cursorRotate)
|
||||
{
|
||||
dragRotationState = DragRotationState.DragStarted;
|
||||
positionMouseDown = state.Mouse.Position;
|
||||
}
|
||||
return base.OnMouseDown(state, args);
|
||||
}
|
||||
|
||||
@@ -87,14 +86,16 @@ namespace osu.Game.Graphics.Cursor
|
||||
{
|
||||
if (!state.Mouse.HasMainButtonPressed)
|
||||
{
|
||||
dragging = false;
|
||||
startRotation = false;
|
||||
|
||||
((Cursor)ActiveCursor).AdditiveLayer.FadeOut(500, Easing.OutQuint);
|
||||
ActiveCursor.RotateTo(0, 600 * (1 + Math.Abs(ActiveCursor.Rotation / 720)), Easing.OutElasticHalf);
|
||||
ActiveCursor.ScaleTo(1, 500, Easing.OutElastic);
|
||||
}
|
||||
|
||||
if (args.Button == MouseButton.Left)
|
||||
{
|
||||
if (dragRotationState == DragRotationState.Rotating)
|
||||
ActiveCursor.RotateTo(0, 600 * (1 + Math.Abs(ActiveCursor.Rotation / 720)), Easing.OutElasticHalf);
|
||||
dragRotationState = DragRotationState.NotDragging;
|
||||
}
|
||||
return base.OnMouseUp(state, args);
|
||||
}
|
||||
|
||||
@@ -160,5 +161,12 @@ namespace osu.Game.Graphics.Cursor
|
||||
cursorScale.TriggerChange();
|
||||
}
|
||||
}
|
||||
|
||||
private enum DragRotationState
|
||||
{
|
||||
NotDragging,
|
||||
DragStarted,
|
||||
Rotating,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ using OpenTK.Graphics;
|
||||
using osu.Framework.Input;
|
||||
using System;
|
||||
using osu.Game.Input.Bindings;
|
||||
using OpenTK.Input;
|
||||
|
||||
namespace osu.Game.Graphics.UserInterface
|
||||
{
|
||||
@@ -44,6 +45,9 @@ namespace osu.Game.Graphics.UserInterface
|
||||
{
|
||||
if (!HasFocus) return false;
|
||||
|
||||
if (args.Key == Key.Escape)
|
||||
return false; // disable the framework-level handling of escape key for confority (we use GlobalAction.Back).
|
||||
|
||||
return base.OnKeyDown(state, args);
|
||||
}
|
||||
|
||||
|
||||
@@ -45,7 +45,9 @@ namespace osu.Game.Input.Bindings
|
||||
public IEnumerable<KeyBinding> InGameKeyBindings => new[]
|
||||
{
|
||||
new KeyBinding(InputKey.Space, GlobalAction.SkipCutscene),
|
||||
new KeyBinding(InputKey.Tilde, GlobalAction.QuickRetry)
|
||||
new KeyBinding(InputKey.Tilde, GlobalAction.QuickRetry),
|
||||
new KeyBinding(new[] { InputKey.Control, InputKey.Plus }, GlobalAction.IncreaseScrollSpeed),
|
||||
new KeyBinding(new[] { InputKey.Control, InputKey.Minus }, GlobalAction.DecreaseScrollSpeed),
|
||||
};
|
||||
|
||||
protected override IEnumerable<Drawable> KeyBindingInputQueue =>
|
||||
@@ -85,6 +87,12 @@ namespace osu.Game.Input.Bindings
|
||||
ToggleGameplayMouseButtons,
|
||||
|
||||
[Description("Go back")]
|
||||
Back
|
||||
Back,
|
||||
|
||||
[Description("Increase scroll speed")]
|
||||
IncreaseScrollSpeed,
|
||||
|
||||
[Description("Decrease scroll speed")]
|
||||
DecreaseScrollSpeed,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,16 +6,16 @@ using System.Linq;
|
||||
using osu.Framework.Extensions.Color4Extensions;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Framework.Input;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.Backgrounds;
|
||||
using osu.Game.Graphics.Containers;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using OpenTK;
|
||||
using OpenTK.Graphics;
|
||||
using OpenTK.Input;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Game.Graphics.Containers;
|
||||
|
||||
namespace osu.Game.Overlays.Dialog
|
||||
{
|
||||
@@ -23,6 +23,9 @@ namespace osu.Game.Overlays.Dialog
|
||||
{
|
||||
public static readonly float ENTER_DURATION = 500;
|
||||
public static readonly float EXIT_DURATION = 200;
|
||||
|
||||
protected override bool BlockPassThroughMouse => false;
|
||||
|
||||
private readonly Vector2 ringSize = new Vector2(100f);
|
||||
private readonly Vector2 ringMinifiedSize = new Vector2(20f);
|
||||
private readonly Vector2 buttonsEnterSpacing = new Vector2(0f, 50f);
|
||||
@@ -34,26 +37,28 @@ namespace osu.Game.Overlays.Dialog
|
||||
private readonly SpriteText header;
|
||||
private readonly TextFlowContainer body;
|
||||
|
||||
private bool actionInvoked;
|
||||
|
||||
public FontAwesome Icon
|
||||
{
|
||||
get { return icon.Icon; }
|
||||
set { icon.Icon = value; }
|
||||
get => icon.Icon;
|
||||
set => icon.Icon = value;
|
||||
}
|
||||
|
||||
public string HeaderText
|
||||
{
|
||||
get { return header.Text; }
|
||||
set { header.Text = value; }
|
||||
get => header.Text;
|
||||
set => header.Text = value;
|
||||
}
|
||||
|
||||
public string BodyText
|
||||
{
|
||||
set { body.Text = value; }
|
||||
set => body.Text = value;
|
||||
}
|
||||
|
||||
public IEnumerable<PopupDialogButton> Buttons
|
||||
{
|
||||
get { return buttonsContainer.Children; }
|
||||
get => buttonsContainer.Children;
|
||||
set
|
||||
{
|
||||
buttonsContainer.ChildrenEnumerable = value;
|
||||
@@ -62,71 +67,17 @@ namespace osu.Game.Overlays.Dialog
|
||||
var action = b.Action;
|
||||
b.Action = () =>
|
||||
{
|
||||
if (actionInvoked) return;
|
||||
|
||||
Hide();
|
||||
|
||||
actionInvoked = true;
|
||||
action?.Invoke();
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void pressButtonAtIndex(int index)
|
||||
{
|
||||
if (index < Buttons.Count())
|
||||
Buttons.Skip(index).First().TriggerOnClick();
|
||||
}
|
||||
|
||||
protected override bool OnKeyDown(InputState state, KeyDownEventArgs args)
|
||||
{
|
||||
if (args.Repeat) return false;
|
||||
|
||||
if (args.Key == Key.Enter || args.Key == Key.KeypadEnter)
|
||||
{
|
||||
Buttons.OfType<PopupDialogOkButton>().FirstOrDefault()?.TriggerOnClick();
|
||||
return true;
|
||||
}
|
||||
|
||||
// press button at number if 1-9 on number row or keypad are pressed
|
||||
var k = args.Key;
|
||||
if (k >= Key.Number1 && k <= Key.Number9)
|
||||
{
|
||||
pressButtonAtIndex(k - Key.Number1);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (k >= Key.Keypad1 && k <= Key.Keypad9)
|
||||
{
|
||||
pressButtonAtIndex(k - Key.Keypad1);
|
||||
return true;
|
||||
}
|
||||
|
||||
return base.OnKeyDown(state, args);
|
||||
}
|
||||
|
||||
protected override void PopIn()
|
||||
{
|
||||
base.PopIn();
|
||||
|
||||
// Reset various animations but only if the dialog animation fully completed
|
||||
if (content.Alpha == 0)
|
||||
{
|
||||
buttonsContainer.TransformSpacingTo(buttonsEnterSpacing);
|
||||
buttonsContainer.MoveToY(buttonsEnterSpacing.Y);
|
||||
ring.ResizeTo(ringMinifiedSize);
|
||||
}
|
||||
|
||||
content.FadeIn(ENTER_DURATION, Easing.OutQuint);
|
||||
ring.ResizeTo(ringSize, ENTER_DURATION, Easing.OutQuint);
|
||||
buttonsContainer.TransformSpacingTo(Vector2.Zero, ENTER_DURATION, Easing.OutQuint);
|
||||
buttonsContainer.MoveToY(0, ENTER_DURATION, Easing.OutQuint);
|
||||
}
|
||||
|
||||
protected override void PopOut()
|
||||
{
|
||||
base.PopOut();
|
||||
|
||||
content.FadeOut(EXIT_DURATION, Easing.InSine);
|
||||
}
|
||||
|
||||
public PopupDialog()
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both;
|
||||
@@ -136,9 +87,6 @@ namespace osu.Game.Overlays.Dialog
|
||||
content = new Container
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Anchor = Anchor.BottomCentre,
|
||||
Origin = Anchor.BottomCentre,
|
||||
Width = 0.4f,
|
||||
Alpha = 0f,
|
||||
Children = new Drawable[]
|
||||
{
|
||||
@@ -243,5 +191,69 @@ namespace osu.Game.Overlays.Dialog
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
protected override bool OnKeyDown(InputState state, KeyDownEventArgs args)
|
||||
{
|
||||
if (args.Repeat) return false;
|
||||
|
||||
if (args.Key == Key.Enter || args.Key == Key.KeypadEnter)
|
||||
{
|
||||
Buttons.OfType<PopupDialogOkButton>().FirstOrDefault()?.TriggerOnClick();
|
||||
return true;
|
||||
}
|
||||
|
||||
// press button at number if 1-9 on number row or keypad are pressed
|
||||
var k = args.Key;
|
||||
if (k >= Key.Number1 && k <= Key.Number9)
|
||||
{
|
||||
pressButtonAtIndex(k - Key.Number1);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (k >= Key.Keypad1 && k <= Key.Keypad9)
|
||||
{
|
||||
pressButtonAtIndex(k - Key.Keypad1);
|
||||
return true;
|
||||
}
|
||||
|
||||
return base.OnKeyDown(state, args);
|
||||
}
|
||||
|
||||
protected override void PopIn()
|
||||
{
|
||||
base.PopIn();
|
||||
|
||||
actionInvoked = false;
|
||||
|
||||
// Reset various animations but only if the dialog animation fully completed
|
||||
if (content.Alpha == 0)
|
||||
{
|
||||
buttonsContainer.TransformSpacingTo(buttonsEnterSpacing);
|
||||
buttonsContainer.MoveToY(buttonsEnterSpacing.Y);
|
||||
ring.ResizeTo(ringMinifiedSize);
|
||||
}
|
||||
|
||||
content.FadeIn(ENTER_DURATION, Easing.OutQuint);
|
||||
ring.ResizeTo(ringSize, ENTER_DURATION, Easing.OutQuint);
|
||||
buttonsContainer.TransformSpacingTo(Vector2.Zero, ENTER_DURATION, Easing.OutQuint);
|
||||
buttonsContainer.MoveToY(0, ENTER_DURATION, Easing.OutQuint);
|
||||
}
|
||||
|
||||
protected override void PopOut()
|
||||
{
|
||||
if (!actionInvoked)
|
||||
// In the case a user did not choose an action before a hide was triggered, press the last button.
|
||||
// This is presumed to always be a sane default "cancel" action.
|
||||
buttonsContainer.Last().TriggerOnClick();
|
||||
|
||||
base.PopOut();
|
||||
content.FadeOut(EXIT_DURATION, Easing.InSine);
|
||||
}
|
||||
|
||||
private void pressButtonAtIndex(int index)
|
||||
{
|
||||
if (index < Buttons.Count())
|
||||
Buttons.Skip(index).First().TriggerOnClick();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,12 +1,9 @@
|
||||
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using osu.Framework.Extensions.Color4Extensions;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Game.Overlays.Dialog;
|
||||
using OpenTK.Graphics;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Game.Graphics.Containers;
|
||||
|
||||
namespace osu.Game.Overlays
|
||||
@@ -16,6 +13,20 @@ namespace osu.Game.Overlays
|
||||
private readonly Container dialogContainer;
|
||||
private PopupDialog currentDialog;
|
||||
|
||||
public DialogOverlay()
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both;
|
||||
|
||||
Child = dialogContainer = new Container
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
};
|
||||
|
||||
Width = 0.4f;
|
||||
Anchor = Anchor.BottomCentre;
|
||||
Origin = Anchor.BottomCentre;
|
||||
}
|
||||
|
||||
public void Push(PopupDialog dialog)
|
||||
{
|
||||
if (dialog == currentDialog) return;
|
||||
@@ -32,6 +43,8 @@ namespace osu.Game.Overlays
|
||||
|
||||
protected override bool PlaySamplesOnStateChange => false;
|
||||
|
||||
protected override bool BlockPassThroughKeyboard => true;
|
||||
|
||||
private void onDialogOnStateChanged(VisibilityContainer dialog, Visibility v)
|
||||
{
|
||||
if (v != Visibility.Hidden) return;
|
||||
@@ -52,32 +65,14 @@ namespace osu.Game.Overlays
|
||||
protected override void PopOut()
|
||||
{
|
||||
base.PopOut();
|
||||
this.FadeOut(PopupDialog.EXIT_DURATION, Easing.InSine);
|
||||
}
|
||||
|
||||
public DialogOverlay()
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both;
|
||||
|
||||
Children = new Drawable[]
|
||||
if (currentDialog?.State == Visibility.Visible)
|
||||
{
|
||||
new Container
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Colour = Color4.Black.Opacity(0.5f),
|
||||
},
|
||||
},
|
||||
},
|
||||
dialogContainer = new Container
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
},
|
||||
};
|
||||
currentDialog.Hide();
|
||||
return;
|
||||
}
|
||||
|
||||
this.FadeOut(PopupDialog.EXIT_DURATION, Easing.InSine);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ namespace osu.Game.Overlays.Mods
|
||||
|
||||
public readonly Bindable<IEnumerable<Mod>> SelectedMods = new Bindable<IEnumerable<Mod>>();
|
||||
|
||||
public readonly Bindable<RulesetInfo> Ruleset = new Bindable<RulesetInfo>();
|
||||
public readonly IBindable<RulesetInfo> Ruleset = new Bindable<RulesetInfo>();
|
||||
|
||||
private void rulesetChanged(RulesetInfo newRuleset)
|
||||
{
|
||||
@@ -51,8 +51,8 @@ namespace osu.Game.Overlays.Mods
|
||||
refreshSelectedMods();
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader(permitNulls: true)]
|
||||
private void load(OsuColour colours, Bindable<RulesetInfo> ruleset, RulesetStore rulesets, AudioManager audio)
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuColour colours, IBindable<RulesetInfo> ruleset, AudioManager audio)
|
||||
{
|
||||
SelectedMods.ValueChanged += selectedModsChanged;
|
||||
|
||||
@@ -60,13 +60,8 @@ namespace osu.Game.Overlays.Mods
|
||||
HighMultiplierColour = colours.Green;
|
||||
UnrankedLabel.Colour = colours.Blue;
|
||||
|
||||
if (ruleset != null)
|
||||
Ruleset.BindTo(ruleset);
|
||||
else
|
||||
Ruleset.Value = rulesets.AvailableRulesets.First();
|
||||
|
||||
Ruleset.ValueChanged += rulesetChanged;
|
||||
Ruleset.TriggerChange();
|
||||
Ruleset.BindTo(ruleset);
|
||||
Ruleset.BindValueChanged(rulesetChanged, true);
|
||||
|
||||
sampleOn = audio.Sample.Get(@"UI/check-on");
|
||||
sampleOff = audio.Sample.Get(@"UI/check-off");
|
||||
|
||||
@@ -56,7 +56,13 @@ namespace osu.Game.Overlays.Settings.Sections
|
||||
|
||||
reloadSkins();
|
||||
|
||||
skinDropdown.Bindable = config.GetBindable<int>(OsuSetting.Skin);
|
||||
var skinBindable = config.GetBindable<int>(OsuSetting.Skin);
|
||||
|
||||
// Todo: This should not be necessary when OsuConfigManager is databased
|
||||
if (skinDropdown.Items.All(s => s.Value != skinBindable.Value))
|
||||
skinBindable.Value = 0;
|
||||
|
||||
skinDropdown.Bindable = skinBindable;
|
||||
}
|
||||
|
||||
private void reloadSkins() => skinDropdown.Items = skins.GetAllUsableSkins().Select(s => new KeyValuePair<string, int>(s.ToString(), s.ID));
|
||||
|
||||
@@ -67,7 +67,7 @@ namespace osu.Game.Overlays.Toolbar
|
||||
};
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader(true)]
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(RulesetStore rulesets, Bindable<RulesetInfo> parentRuleset)
|
||||
{
|
||||
this.rulesets = rulesets;
|
||||
@@ -82,11 +82,7 @@ namespace osu.Game.Overlays.Toolbar
|
||||
|
||||
ruleset.ValueChanged += rulesetChanged;
|
||||
ruleset.DisabledChanged += disabledChanged;
|
||||
|
||||
if (parentRuleset != null)
|
||||
ruleset.BindTo(parentRuleset);
|
||||
else
|
||||
ruleset.Value = rulesets.AvailableRulesets.FirstOrDefault();
|
||||
ruleset.BindTo(parentRuleset);
|
||||
}
|
||||
|
||||
protected override bool OnKeyDown(InputState state, KeyDownEventArgs args)
|
||||
|
||||
@@ -57,8 +57,18 @@ namespace osu.Game.Rulesets
|
||||
/// <returns></returns>
|
||||
public abstract RulesetContainer CreateRulesetContainerWith(WorkingBeatmap beatmap);
|
||||
|
||||
/// <summary>
|
||||
/// Creates a <see cref="IBeatmapConverter"/> to convert a <see cref="IBeatmap"/> to one that is applicable for this <see cref="Ruleset"/>.
|
||||
/// </summary>
|
||||
/// <param name="beatmap">The <see cref="IBeatmap"/> to be converted.</param>
|
||||
/// <returns>The <see cref="IBeatmapConverter"/>.</returns>
|
||||
public abstract IBeatmapConverter CreateBeatmapConverter(IBeatmap beatmap);
|
||||
|
||||
/// <summary>
|
||||
/// Optionally creates a <see cref="IBeatmapProcessor"/> to alter a <see cref="IBeatmap"/> after it has been converted.
|
||||
/// </summary>
|
||||
/// <param name="beatmap">The <see cref="IBeatmap"/> to be processed.</param>
|
||||
/// <returns>The <see cref="IBeatmapProcessor"/>.</returns>
|
||||
public virtual IBeatmapProcessor CreateBeatmapProcessor(IBeatmap beatmap) => null;
|
||||
|
||||
public abstract DifficultyCalculator CreateDifficultyCalculator(WorkingBeatmap beatmap);
|
||||
|
||||
@@ -84,7 +84,13 @@ namespace osu.Game.Rulesets
|
||||
{
|
||||
try
|
||||
{
|
||||
var instanceInfo = ((Ruleset)Activator.CreateInstance(Type.GetType(r.InstantiationInfo), (RulesetInfo)null)).RulesetInfo;
|
||||
var instanceInfo = ((Ruleset)Activator.CreateInstance(Type.GetType(r.InstantiationInfo, asm =>
|
||||
{
|
||||
// for the time being, let's ignore the version being loaded.
|
||||
// this allows for debug builds to successfully load rulesets (even though debug rulesets have a 0.0.0 version).
|
||||
asm.Version = null;
|
||||
return Assembly.Load(asm);
|
||||
}, null), (RulesetInfo)null)).RulesetInfo;
|
||||
|
||||
r.Name = instanceInfo.Name;
|
||||
r.ShortName = instanceInfo.ShortName;
|
||||
|
||||
@@ -4,30 +4,33 @@
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Configuration;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Input;
|
||||
using osu.Framework.Input.Bindings;
|
||||
using osu.Game.Input.Bindings;
|
||||
using osu.Game.Rulesets.Objects.Drawables;
|
||||
using OpenTK.Input;
|
||||
|
||||
namespace osu.Game.Rulesets.UI.Scrolling
|
||||
{
|
||||
/// <summary>
|
||||
/// A type of <see cref="Playfield"/> specialized towards scrolling <see cref="DrawableHitObject"/>s.
|
||||
/// </summary>
|
||||
public abstract class ScrollingPlayfield : Playfield
|
||||
public abstract class ScrollingPlayfield : Playfield, IKeyBindingHandler<GlobalAction>
|
||||
{
|
||||
/// <summary>
|
||||
/// The default span of time visible by the length of the scrolling axes.
|
||||
/// This is clamped between <see cref="time_span_min"/> and <see cref="time_span_max"/>.
|
||||
/// </summary>
|
||||
private const double time_span_default = 1500;
|
||||
|
||||
/// <summary>
|
||||
/// The minimum span of time that may be visible by the length of the scrolling axes.
|
||||
/// </summary>
|
||||
private const double time_span_min = 50;
|
||||
|
||||
/// <summary>
|
||||
/// The maximum span of time that may be visible by the length of the scrolling axes.
|
||||
/// </summary>
|
||||
private const double time_span_max = 10000;
|
||||
|
||||
/// <summary>
|
||||
/// The step increase/decrease of the span of time visible by the length of the scrolling axes.
|
||||
/// </summary>
|
||||
@@ -78,27 +81,26 @@ namespace osu.Game.Rulesets.UI.Scrolling
|
||||
HitObjects.TimeRange.BindTo(VisibleTimeRange);
|
||||
}
|
||||
|
||||
protected override bool OnKeyDown(InputState state, KeyDownEventArgs args)
|
||||
public bool OnPressed(GlobalAction action)
|
||||
{
|
||||
if (!UserScrollSpeedAdjustment)
|
||||
return false;
|
||||
|
||||
if (state.Keyboard.ControlPressed)
|
||||
switch (action)
|
||||
{
|
||||
switch (args.Key)
|
||||
{
|
||||
case Key.Minus:
|
||||
this.TransformBindableTo(VisibleTimeRange, VisibleTimeRange + time_span_step, 600, Easing.OutQuint);
|
||||
break;
|
||||
case Key.Plus:
|
||||
this.TransformBindableTo(VisibleTimeRange, VisibleTimeRange - time_span_step, 600, Easing.OutQuint);
|
||||
break;
|
||||
}
|
||||
case GlobalAction.IncreaseScrollSpeed:
|
||||
this.TransformBindableTo(VisibleTimeRange, VisibleTimeRange - time_span_step, 200, Easing.OutQuint);
|
||||
return true;
|
||||
case GlobalAction.DecreaseScrollSpeed:
|
||||
this.TransformBindableTo(VisibleTimeRange, VisibleTimeRange + time_span_step, 200, Easing.OutQuint);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool OnReleased(GlobalAction action) => false;
|
||||
|
||||
protected sealed override HitObjectContainer CreateHitObjectContainer()
|
||||
{
|
||||
var container = new ScrollingHitObjectContainer();
|
||||
|
||||
@@ -40,7 +40,14 @@ namespace osu.Game.Screens
|
||||
while (screen.LoadState < LoadState.Ready)
|
||||
Thread.Sleep(1);
|
||||
|
||||
base.Push(screen);
|
||||
try
|
||||
{
|
||||
base.Push(screen);
|
||||
}
|
||||
catch (ScreenAlreadyExitedException)
|
||||
{
|
||||
// screen may have exited before the push was successful.
|
||||
}
|
||||
}
|
||||
|
||||
protected override void Update()
|
||||
|
||||
@@ -82,11 +82,8 @@ namespace osu.Game.Screens
|
||||
[BackgroundDependencyLoader(true)]
|
||||
private void load(BindableBeatmap beatmap, OsuGame osu, AudioManager audio, Bindable<RulesetInfo> ruleset)
|
||||
{
|
||||
if (beatmap != null)
|
||||
Beatmap.BindTo(beatmap);
|
||||
|
||||
if (ruleset != null)
|
||||
Ruleset.BindTo(ruleset);
|
||||
Beatmap.BindTo(beatmap);
|
||||
Ruleset.BindTo(ruleset);
|
||||
|
||||
if (osu != null)
|
||||
{
|
||||
@@ -183,11 +180,10 @@ namespace osu.Game.Screens
|
||||
|
||||
if (Background != null && !Background.Equals(nextOsu?.Background))
|
||||
{
|
||||
if (nextOsu != null)
|
||||
//We need to use MakeCurrent in case we are jumping up multiple game screens.
|
||||
nextOsu.Background?.MakeCurrent();
|
||||
else
|
||||
Background.Exit();
|
||||
Background.Exit();
|
||||
|
||||
//We need to use MakeCurrent in case we are jumping up multiple game screens.
|
||||
nextOsu?.Background?.MakeCurrent();
|
||||
}
|
||||
|
||||
if (base.OnExiting(next))
|
||||
|
||||
@@ -55,8 +55,7 @@ namespace osu.Game.Screens.Select
|
||||
[BackgroundDependencyLoader(true)]
|
||||
private void load([CanBeNull] Bindable<RulesetInfo> parentRuleset)
|
||||
{
|
||||
if (parentRuleset != null)
|
||||
ruleset.BindTo(parentRuleset);
|
||||
ruleset.BindTo(parentRuleset);
|
||||
ruleset.ValueChanged += _ => updateDisplay();
|
||||
}
|
||||
|
||||
|
||||
@@ -29,6 +29,7 @@ namespace osu.Game.Screens.Select
|
||||
private readonly TabControl<GroupMode> groupTabs;
|
||||
|
||||
private SortMode sort = SortMode.Title;
|
||||
|
||||
public SortMode Sort
|
||||
{
|
||||
get { return sort; }
|
||||
@@ -43,6 +44,7 @@ namespace osu.Game.Screens.Select
|
||||
}
|
||||
|
||||
private GroupMode group = GroupMode.All;
|
||||
|
||||
public GroupMode Group
|
||||
{
|
||||
get { return group; }
|
||||
@@ -69,7 +71,8 @@ namespace osu.Game.Screens.Select
|
||||
|
||||
private readonly SearchTextBox searchTextBox;
|
||||
|
||||
public override bool ReceiveMouseInputAt(Vector2 screenSpacePos) => base.ReceiveMouseInputAt(screenSpacePos) || groupTabs.ReceiveMouseInputAt(screenSpacePos) || sortTabs.ReceiveMouseInputAt(screenSpacePos);
|
||||
public override bool ReceiveMouseInputAt(Vector2 screenSpacePos) =>
|
||||
base.ReceiveMouseInputAt(screenSpacePos) || groupTabs.ReceiveMouseInputAt(screenSpacePos) || sortTabs.ReceiveMouseInputAt(screenSpacePos);
|
||||
|
||||
public FilterControl()
|
||||
{
|
||||
@@ -177,8 +180,7 @@ namespace osu.Game.Screens.Select
|
||||
showConverted = config.GetBindable<bool>(OsuSetting.ShowConvertedBeatmaps);
|
||||
showConverted.ValueChanged += val => updateCriteria();
|
||||
|
||||
if (parentRuleset != null)
|
||||
ruleset.BindTo(parentRuleset);
|
||||
ruleset.BindTo(parentRuleset);
|
||||
ruleset.BindValueChanged(val => updateCriteria(), true);
|
||||
}
|
||||
|
||||
|
||||
@@ -40,7 +40,10 @@ namespace osu.Game.Screens.Select.Leaderboards
|
||||
|
||||
private ScheduledDelegate showScoresDelegate;
|
||||
|
||||
private bool scoresLoadedOnce;
|
||||
|
||||
private IEnumerable<Score> scores;
|
||||
|
||||
public IEnumerable<Score> Scores
|
||||
{
|
||||
get { return scores; }
|
||||
@@ -48,6 +51,8 @@ namespace osu.Game.Screens.Select.Leaderboards
|
||||
{
|
||||
scores = value;
|
||||
|
||||
scoresLoadedOnce = true;
|
||||
|
||||
scrollFlow?.FadeOut(fade_duration, Easing.OutQuint).Expire();
|
||||
scrollFlow = null;
|
||||
|
||||
@@ -196,9 +201,7 @@ namespace osu.Game.Screens.Select.Leaderboards
|
||||
{
|
||||
this.api = api;
|
||||
|
||||
if (parentRuleset != null)
|
||||
ruleset.BindTo(parentRuleset);
|
||||
|
||||
ruleset.BindTo(parentRuleset);
|
||||
ruleset.ValueChanged += _ => updateScores();
|
||||
|
||||
if (api != null)
|
||||
@@ -227,6 +230,10 @@ namespace osu.Game.Screens.Select.Leaderboards
|
||||
|
||||
private void updateScores()
|
||||
{
|
||||
// don't display any scores or placeholder until the first Scores_Set has been called.
|
||||
// this avoids scope changes flickering a "no scores" placeholder before initialisation of song select is finished.
|
||||
if (!scoresLoadedOnce) return;
|
||||
|
||||
getScoresRequest?.Cancel();
|
||||
getScoresRequest = null;
|
||||
|
||||
|
||||
@@ -1,10 +1,13 @@
|
||||
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using System.Linq;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Audio;
|
||||
using osu.Framework.Configuration;
|
||||
using osu.Framework.Testing;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Rulesets;
|
||||
|
||||
namespace osu.Game.Tests.Visual
|
||||
{
|
||||
@@ -13,6 +16,8 @@ namespace osu.Game.Tests.Visual
|
||||
private readonly OsuTestBeatmap beatmap = new OsuTestBeatmap(new DummyWorkingBeatmap());
|
||||
protected BindableBeatmap Beatmap => beatmap;
|
||||
|
||||
protected readonly Bindable<RulesetInfo> Ruleset = new Bindable<RulesetInfo>();
|
||||
|
||||
protected DependencyContainer Dependencies { get; private set; }
|
||||
|
||||
protected override IReadOnlyDependencyContainer CreateLocalDependencies(IReadOnlyDependencyContainer parent)
|
||||
@@ -22,13 +27,18 @@ namespace osu.Game.Tests.Visual
|
||||
Dependencies.CacheAs<BindableBeatmap>(beatmap);
|
||||
Dependencies.CacheAs<IBindableBeatmap>(beatmap);
|
||||
|
||||
Dependencies.CacheAs(Ruleset);
|
||||
Dependencies.CacheAs<IBindable<RulesetInfo>>(Ruleset);
|
||||
|
||||
return Dependencies;
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(AudioManager audioManager)
|
||||
private void load(AudioManager audioManager, RulesetStore rulesets)
|
||||
{
|
||||
beatmap.SetAudioManager(audioManager);
|
||||
|
||||
Ruleset.Value = rulesets.AvailableRulesets.First();
|
||||
}
|
||||
|
||||
protected override void Dispose(bool isDisposing)
|
||||
|
||||
@@ -86,7 +86,11 @@ namespace osu.Game.Tests.Visual
|
||||
private readonly WeakList<WorkingBeatmap> workingWeakReferences = new WeakList<WorkingBeatmap>();
|
||||
private readonly WeakList<Player> playerWeakReferences = new WeakList<Player>();
|
||||
|
||||
private Player loadPlayerFor(RulesetInfo ri) => loadPlayerFor(ri.CreateInstance());
|
||||
private Player loadPlayerFor(RulesetInfo ri)
|
||||
{
|
||||
Ruleset.Value = ri;
|
||||
return loadPlayerFor(ri.CreateInstance());
|
||||
}
|
||||
|
||||
private Player loadPlayerFor(Ruleset r)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user