1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-21 18:47:27 +08:00

Merge branch 'master' into use-switch-over-if

This commit is contained in:
Dan Balasescu 2018-07-17 16:44:57 +09:00 committed by GitHub
commit 64cde1ebad
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
18 changed files with 70 additions and 40 deletions

View File

@ -23,8 +23,10 @@ namespace osu.Game.Rulesets.Catch.UI
private readonly CatcherArea catcherArea;
public CatchPlayfield(BeatmapDifficulty difficulty, Func<CatchHitObject, DrawableHitObject<CatchHitObject>> getVisualRepresentation)
: base(ScrollingDirection.Down, BASE_WIDTH)
: base(BASE_WIDTH)
{
Direction.Value = ScrollingDirection.Down;
Container explodingFruitContainer;
Anchor = Anchor.TopCentre;

View File

@ -86,7 +86,7 @@ namespace osu.Game.Rulesets.Mania.Tests
private Drawable createColumn(ScrollingDirection direction, ManiaAction action)
{
var column = new Column(direction)
var column = new Column
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,

View File

@ -105,7 +105,7 @@ namespace osu.Game.Rulesets.Mania.Tests
{
var specialAction = ManiaAction.Special1;
var stage = new ManiaStage(direction, 0, new StageDefinition { Columns = 2 }, ref action, ref specialAction) { VisibleTimeRange = { Value = 2000 } };
var stage = new ManiaStage(0, new StageDefinition { Columns = 2 }, ref action, ref specialAction) { VisibleTimeRange = { Value = 2000 } };
stages.Add(stage);
return new ScrollingTestContainer(direction)

View File

@ -32,8 +32,7 @@ namespace osu.Game.Rulesets.Mania.UI
protected override Container<Drawable> Content => hitObjectArea;
public Column(ScrollingDirection direction)
: base(direction)
public Column()
{
RelativeSizeAxes = Axes.Y;
Width = column_width;

View File

@ -12,7 +12,6 @@ using osu.Game.Rulesets.Judgements;
using osu.Game.Rulesets.Mania.Beatmaps;
using osu.Game.Rulesets.Objects.Drawables;
using osu.Game.Rulesets.Mania.Configuration;
using osu.Game.Rulesets.UI.Scrolling;
namespace osu.Game.Rulesets.Mania.UI
{
@ -21,8 +20,7 @@ namespace osu.Game.Rulesets.Mania.UI
public List<Column> Columns => stages.SelectMany(x => x.Columns).ToList();
private readonly List<ManiaStage> stages = new List<ManiaStage>();
public ManiaPlayfield(ScrollingDirection direction, List<StageDefinition> stageDefinitions)
: base(direction)
public ManiaPlayfield(List<StageDefinition> stageDefinitions)
{
if (stageDefinitions == null)
throw new ArgumentNullException(nameof(stageDefinitions));
@ -42,7 +40,7 @@ namespace osu.Game.Rulesets.Mania.UI
int firstColumnIndex = 0;
for (int i = 0; i < stageDefinitions.Count; i++)
{
var newStage = new ManiaStage(direction, firstColumnIndex, stageDefinitions[i], ref normalColumnAction, ref specialColumnAction);
var newStage = new ManiaStage(firstColumnIndex, stageDefinitions[i], ref normalColumnAction, ref specialColumnAction);
newStage.VisibleTimeRange.BindTo(VisibleTimeRange);
playfieldGrid.Content[0][i] = newStage;

View File

@ -87,7 +87,7 @@ namespace osu.Game.Rulesets.Mania.UI
return dependencies;
}
protected sealed override Playfield CreatePlayfield() => new ManiaPlayfield(scrollingInfo.Direction, Beatmap.Stages)
protected sealed override Playfield CreatePlayfield() => new ManiaPlayfield(Beatmap.Stages)
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,

View File

@ -11,11 +11,6 @@ namespace osu.Game.Rulesets.Mania.UI
{
private readonly IBindable<ScrollingDirection> direction = new Bindable<ScrollingDirection>();
public ManiaScrollingPlayfield(ScrollingDirection direction)
: base(direction)
{
}
[BackgroundDependencyLoader]
private void load(IScrollingInfo scrollingInfo)
{

View File

@ -43,8 +43,7 @@ namespace osu.Game.Rulesets.Mania.UI
private readonly int firstColumnIndex;
public ManiaStage(ScrollingDirection direction, int firstColumnIndex, StageDefinition definition, ref ManiaAction normalColumnStartAction, ref ManiaAction specialColumnStartAction)
: base(direction)
public ManiaStage(int firstColumnIndex, StageDefinition definition, ref ManiaAction normalColumnStartAction, ref ManiaAction specialColumnStartAction)
{
this.firstColumnIndex = firstColumnIndex;
@ -124,7 +123,7 @@ namespace osu.Game.Rulesets.Mania.UI
for (int i = 0; i < definition.Columns; i++)
{
var isSpecial = definition.IsSpecialColumn(i);
var column = new Column(direction)
var column = new Column
{
IsSpecial = isSpecial,
Action = { Value = isSpecial ? specialColumnStartAction++ : normalColumnStartAction++ }

View File

@ -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 System.Linq;
using osu.Framework.Graphics.Cursor;
using osu.Framework.Input;
using OpenTK;
@ -48,6 +49,15 @@ namespace osu.Game.Rulesets.Osu.UI
protected override ReplayInputHandler CreateReplayInputHandler(Replay replay) => new OsuReplayInputHandler(replay);
public override double GameplayStartTime
{
get
{
var first = (OsuHitObject)Objects.First();
return first.StartTime - first.TimePreempt;
}
}
protected override Vector2 GetAspectAdjustedSize()
{
var aspectSize = DrawSize.X * 0.75f < DrawSize.Y ? new Vector2(DrawSize.X, DrawSize.X * 0.75f) : new Vector2(DrawSize.Y * 4f / 3f, DrawSize.Y);

View File

@ -58,8 +58,9 @@ namespace osu.Game.Rulesets.Taiko.UI
private readonly Box background;
public TaikoPlayfield(ControlPointInfo controlPoints)
: base(ScrollingDirection.Left)
{
Direction.Value = ScrollingDirection.Left;
AddRangeInternal(new Drawable[]
{
backgroundContainer = new Container

View File

@ -117,7 +117,6 @@ namespace osu.Game.Tests.Visual
public new readonly ScrollingDirection Direction;
public TestPlayfield(ScrollingDirection direction)
: base(direction)
{
Direction = direction;

View File

@ -44,6 +44,8 @@ namespace osu.Game.Overlays.Mods
private void rulesetChanged(RulesetInfo newRuleset)
{
if (newRuleset == null) return;
var instance = newRuleset.CreateInstance();
foreach (ModSection section in ModSectionsContainer.Children)
@ -173,7 +175,10 @@ namespace osu.Game.Overlays.Mods
refreshSelectedMods();
}
private void refreshSelectedMods() => SelectedMods.Value = ModSectionsContainer.Children.SelectMany(s => s.SelectedMods).ToArray();
private void refreshSelectedMods()
{
SelectedMods.Value = ModSectionsContainer.Children.SelectMany(s => s.SelectedMods).ToArray();
}
public ModSelectOverlay()
{

View File

@ -11,7 +11,7 @@ using osu.Game.Rulesets.UI;
namespace osu.Game.Rulesets.Mods
{
public class ModAutoplay<T> : ModAutoplay, IApplicableToRulesetContainer<T>
public abstract class ModAutoplay<T> : ModAutoplay, IApplicableToRulesetContainer<T>
where T : HitObject
{
protected virtual Score CreateReplayScore(Beatmap<T> beatmap) => new Score { Replay = new Replay() };

View File

@ -56,6 +56,12 @@ namespace osu.Game.Rulesets.UI
public abstract IEnumerable<HitObject> Objects { get; }
/// <summary>
/// The point in time at which gameplay starts, including any required lead-in for display purposes.
/// Defaults to two seconds before the first <see cref="HitObject"/>. Override as necessary.
/// </summary>
public virtual double GameplayStartTime => Objects.First().StartTime - 2000;
private readonly Lazy<Playfield> playfield;
/// <summary>

View File

@ -57,22 +57,23 @@ namespace osu.Game.Rulesets.UI.Scrolling
/// </summary>
public new ScrollingHitObjectContainer HitObjects => (ScrollingHitObjectContainer)base.HitObjects;
/// <summary>
/// The direction in which <see cref="DrawableHitObject"/>s in this <see cref="ScrollingPlayfield"/> should scroll.
/// </summary>
protected readonly Bindable<ScrollingDirection> Direction = new Bindable<ScrollingDirection>();
/// <summary>
/// Creates a new <see cref="ScrollingPlayfield"/>.
/// </summary>
/// <param name="direction">The direction in which <see cref="DrawableHitObject"/>s in this container should scroll.</param>
/// <param name="customWidth">The width to scale the internal coordinate space to.
/// May be null if scaling based on <paramref name="customHeight"/> is desired. If <paramref name="customHeight"/> is also null, no scaling will occur.
/// </param>
/// <param name="customHeight">The height to scale the internal coordinate space to.
/// May be null if scaling based on <paramref name="customWidth"/> is desired. If <paramref name="customWidth"/> is also null, no scaling will occur.
/// </param>
protected ScrollingPlayfield(ScrollingDirection direction, float? customWidth = null, float? customHeight = null)
protected ScrollingPlayfield(float? customWidth = null, float? customHeight = null)
: base(customWidth, customHeight)
{
Direction.Value = direction;
}
[BackgroundDependencyLoader]

View File

@ -138,10 +138,9 @@ namespace osu.Game.Screens.Play
sourceClock = (IAdjustableClock)working.Track ?? new StopwatchClock();
adjustableClock = new DecoupleableInterpolatingFramedClock { IsCoupled = false };
var firstObjectTime = RulesetContainer.Objects.First().StartTime;
adjustableClock.Seek(AllowLeadIn
? Math.Min(0, firstObjectTime - Math.Max(beatmap.ControlPointInfo.TimingPointAt(firstObjectTime).BeatLength * 4, beatmap.BeatmapInfo.AudioLeadIn))
: firstObjectTime);
? Math.Min(RulesetContainer.GameplayStartTime, beatmap.HitObjects.First().StartTime - beatmap.BeatmapInfo.AudioLeadIn)
: RulesetContainer.GameplayStartTime);
adjustableClock.ProcessFrame();
@ -199,7 +198,7 @@ namespace osu.Game.Screens.Play
Anchor = Anchor.Centre,
Origin = Anchor.Centre
},
new SkipOverlay(firstObjectTime)
new SkipOverlay(RulesetContainer.GameplayStartTime)
{
Clock = Clock, // skip button doesn't want to use the audio clock directly
ProcessCustomClock = false,

View File

@ -84,10 +84,10 @@ namespace osu.Game.Screens.Select
protected override void UpdateBeatmap(WorkingBeatmap beatmap)
{
base.UpdateBeatmap(beatmap);
beatmap.Mods.BindTo(SelectedMods);
base.UpdateBeatmap(beatmap);
BeatmapDetails.Beatmap = beatmap;
if (beatmap.Track != null)

View File

@ -2,6 +2,7 @@
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System;
using System.Linq;
using OpenTK;
using OpenTK.Input;
using osu.Framework.Allocation;
@ -20,6 +21,7 @@ using osu.Game.Graphics.Containers;
using osu.Game.Input.Bindings;
using osu.Game.Overlays;
using osu.Game.Rulesets;
using osu.Game.Rulesets.Mods;
using osu.Game.Screens.Backgrounds;
using osu.Game.Screens.Edit;
using osu.Game.Screens.Menu;
@ -70,7 +72,14 @@ namespace osu.Game.Screens.Select
private DependencyContainer dependencies;
protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent)
=> dependencies = new DependencyContainer(base.CreateChildDependencies(parent));
{
dependencies = new DependencyContainer(base.CreateChildDependencies(parent));
dependencies.CacheAs(this);
dependencies.CacheAs(Ruleset);
dependencies.CacheAs<IBindable<RulesetInfo>>(Ruleset);
return dependencies;
}
protected SongSelect()
{
@ -189,9 +198,9 @@ namespace osu.Game.Screens.Select
[BackgroundDependencyLoader(true)]
private void load(BeatmapManager beatmaps, AudioManager audio, DialogOverlay dialog, OsuColour colours)
{
dependencies.CacheAs(this);
dependencies.CacheAs(Ruleset);
dependencies.CacheAs<IBindable<RulesetInfo>>(Ruleset);
// manual binding to parent ruleset to allow for delayed load in the incoming direction.
base.Ruleset.ValueChanged += r => updateSelectedBeatmap(beatmapNoDebounce);
Ruleset.ValueChanged += r => base.Ruleset.Value = r;
if (Footer != null)
{
@ -277,7 +286,7 @@ namespace osu.Game.Screens.Select
// If selecting new beatmap without bypassing filters failed, there's possibly a ruleset mismatch
if (beatmap?.BeatmapInfo?.Ruleset != null && beatmap.BeatmapInfo.Ruleset != Ruleset.Value)
{
Ruleset.Value = beatmap.BeatmapInfo.Ruleset;
base.Ruleset.Value = beatmap.BeatmapInfo.Ruleset;
Carousel.SelectBeatmap(beatmap.BeatmapInfo);
}
}
@ -295,18 +304,25 @@ namespace osu.Game.Screens.Select
void performLoad()
{
WorkingBeatmap working = Beatmap.Value;
bool preview = false;
// We may be arriving here due to another component changing the bindable Beatmap.
// In these cases, the other component has already loaded the beatmap, so we don't need to do so again.
if (beatmap?.Equals(Beatmap.Value.BeatmapInfo) != true)
{
bool preview = beatmap?.BeatmapSetInfoID != Beatmap.Value?.BeatmapInfo.BeatmapSetInfoID;
Beatmap.Value = beatmaps.GetWorkingBeatmap(beatmap, Beatmap.Value);
ensurePlayingSelected(preview);
preview = beatmap?.BeatmapSetInfoID != Beatmap.Value?.BeatmapInfo.BeatmapSetInfoID;
working = beatmaps.GetWorkingBeatmap(beatmap, Beatmap.Value);
}
working.Mods.Value = Enumerable.Empty<Mod>();
Beatmap.Value = working;
Ruleset.Value = ruleset;
ensurePlayingSelected(preview);
UpdateBeatmap(Beatmap.Value);
}