mirror of
https://github.com/ppy/osu.git
synced 2025-01-28 06:03:08 +08:00
Move clock construction to Editor
This commit is contained in:
parent
5e742eb466
commit
c8f6a6980b
@ -3,6 +3,7 @@
|
||||
|
||||
using System.Collections.Generic;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Timing;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Rulesets.Edit;
|
||||
using osu.Game.Rulesets.Edit.Layers.Selection;
|
||||
@ -16,8 +17,8 @@ namespace osu.Game.Rulesets.Osu.Edit
|
||||
{
|
||||
public class OsuHitObjectComposer : HitObjectComposer
|
||||
{
|
||||
public OsuHitObjectComposer(Ruleset ruleset)
|
||||
: base(ruleset)
|
||||
public OsuHitObjectComposer(Ruleset ruleset, IAdjustableClock adjustableClock, IFrameBasedClock framedClock)
|
||||
: base(ruleset, adjustableClock, framedClock)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -13,6 +13,7 @@ using System.Linq;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Game.Overlays.Settings;
|
||||
using osu.Framework.Input.Bindings;
|
||||
using osu.Framework.Timing;
|
||||
using osu.Game.Rulesets.Scoring;
|
||||
using osu.Game.Rulesets.Osu.Scoring;
|
||||
using osu.Game.Rulesets.Osu.Edit;
|
||||
@ -137,7 +138,7 @@ namespace osu.Game.Rulesets.Osu
|
||||
|
||||
public override PerformanceCalculator CreatePerformanceCalculator(Beatmap beatmap, Score score) => new OsuPerformanceCalculator(this, beatmap, score);
|
||||
|
||||
public override HitObjectComposer CreateHitObjectComposer() => new OsuHitObjectComposer(this);
|
||||
public override HitObjectComposer CreateHitObjectComposer(IAdjustableClock adjustableClock, IFrameBasedClock framedClock) => new OsuHitObjectComposer(this, adjustableClock, framedClock);
|
||||
|
||||
public override string Description => "osu!";
|
||||
|
||||
|
@ -32,12 +32,15 @@ namespace osu.Game.Rulesets.Edit
|
||||
|
||||
private readonly Bindable<WorkingBeatmap> beatmap = new Bindable<WorkingBeatmap>();
|
||||
|
||||
private IAdjustableClock sourceClock;
|
||||
private DecoupleableInterpolatingFramedClock adjustableClock;
|
||||
private readonly IAdjustableClock adjustableClock;
|
||||
private readonly IFrameBasedClock framedClock;
|
||||
|
||||
protected HitObjectComposer(Ruleset ruleset)
|
||||
protected HitObjectComposer(Ruleset ruleset, IAdjustableClock adjustableClock, IFrameBasedClock framedClock)
|
||||
{
|
||||
this.ruleset = ruleset;
|
||||
this.adjustableClock = adjustableClock;
|
||||
this.framedClock = framedClock;
|
||||
|
||||
RelativeSizeAxes = Axes.Both;
|
||||
}
|
||||
|
||||
@ -49,14 +52,7 @@ namespace osu.Game.Rulesets.Edit
|
||||
try
|
||||
{
|
||||
rulesetContainer = CreateRulesetContainer(ruleset, beatmap.Value);
|
||||
|
||||
// TODO: should probably be done at a RulesetContainer level to share logic with Player.
|
||||
sourceClock = (IAdjustableClock)beatmap.Value.Track ?? new StopwatchClock();
|
||||
adjustableClock = new DecoupleableInterpolatingFramedClock { IsCoupled = false };
|
||||
adjustableClock.ChangeSource(sourceClock);
|
||||
|
||||
rulesetContainer.Clock = adjustableClock;
|
||||
|
||||
rulesetContainer.Clock = framedClock;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
@ -6,6 +6,7 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Input.Bindings;
|
||||
using osu.Framework.Timing;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Overlays.Settings;
|
||||
@ -53,7 +54,7 @@ namespace osu.Game.Rulesets
|
||||
|
||||
public virtual PerformanceCalculator CreatePerformanceCalculator(Beatmap beatmap, Score score) => null;
|
||||
|
||||
public virtual HitObjectComposer CreateHitObjectComposer() => null;
|
||||
public virtual HitObjectComposer CreateHitObjectComposer(IAdjustableClock adjustableClock, IFrameBasedClock framedClock) => null;
|
||||
|
||||
public virtual Drawable CreateIcon() => new SpriteIcon { Icon = FontAwesome.fa_question_circle };
|
||||
|
||||
|
@ -12,6 +12,7 @@ using osu.Game.Screens.Edit.Menus;
|
||||
using osu.Game.Screens.Edit.Components.Timelines.Summary;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics.UserInterface;
|
||||
using osu.Framework.Timing;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
using osu.Game.Screens.Edit.Screens;
|
||||
using osu.Game.Screens.Edit.Screens.Compose;
|
||||
@ -31,9 +32,16 @@ namespace osu.Game.Screens.Edit
|
||||
|
||||
private EditorScreen currentScreen;
|
||||
|
||||
private DecoupleableInterpolatingFramedClock adjustableClock;
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuColour colours)
|
||||
{
|
||||
// TODO: should probably be done at a RulesetContainer level to share logic with Player.
|
||||
var sourceClock = (IAdjustableClock)Beatmap.Value.Track ?? new StopwatchClock();
|
||||
adjustableClock = new DecoupleableInterpolatingFramedClock { IsCoupled = false };
|
||||
adjustableClock.ChangeSource(sourceClock);
|
||||
|
||||
EditorMenuBar menuBar;
|
||||
TimeInfoContainer timeInfo;
|
||||
SummaryTimeline timeline;
|
||||
@ -148,7 +156,7 @@ namespace osu.Game.Screens.Edit
|
||||
switch (mode)
|
||||
{
|
||||
case EditorScreenMode.Compose:
|
||||
currentScreen = new Compose();
|
||||
currentScreen = new Compose(adjustableClock, adjustableClock);
|
||||
break;
|
||||
case EditorScreenMode.Design:
|
||||
currentScreen = new Design();
|
||||
|
@ -1,12 +1,14 @@
|
||||
// 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.Allocation;
|
||||
using OpenTK.Graphics;
|
||||
using osu.Framework.Extensions.Color4Extensions;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Framework.Logging;
|
||||
using osu.Framework.Timing;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Screens.Edit.Screens.Compose.Timeline;
|
||||
|
||||
@ -17,9 +19,19 @@ namespace osu.Game.Screens.Edit.Screens.Compose
|
||||
private const float vertical_margins = 10;
|
||||
private const float horizontal_margins = 20;
|
||||
|
||||
private readonly Container composerContainer;
|
||||
private Container composerContainer;
|
||||
|
||||
public Compose()
|
||||
private readonly IAdjustableClock adjustableClock;
|
||||
private readonly IFrameBasedClock framedClock;
|
||||
|
||||
public Compose(IAdjustableClock adjustableClock, IFrameBasedClock framedClock)
|
||||
{
|
||||
this.adjustableClock = adjustableClock;
|
||||
this.framedClock = framedClock;
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
ScrollableTimeline timeline;
|
||||
Children = new Drawable[]
|
||||
@ -90,7 +102,7 @@ namespace osu.Game.Screens.Edit.Screens.Compose
|
||||
return;
|
||||
}
|
||||
|
||||
var composer = ruleset.CreateHitObjectComposer();
|
||||
var composer = ruleset.CreateHitObjectComposer(adjustableClock, framedClock);
|
||||
if (composer == null)
|
||||
{
|
||||
Logger.Log($"Ruleset {ruleset.Description} doesn't support hitobject composition.");
|
||||
|
Loading…
Reference in New Issue
Block a user