mirror of
https://github.com/ppy/osu.git
synced 2024-11-06 06:57:39 +08:00
Merge branch 'master' into fixes
This commit is contained in:
commit
451f92772a
@ -1 +1 @@
|
||||
Subproject commit 991177da4fbed2dd8260c215f2d341ebc858b03e
|
||||
Subproject commit 2d2e2fe698ab32d80d5e856f52c8c398ceb35540
|
@ -10,7 +10,7 @@ namespace osu.Desktop.VisualTests.Beatmaps
|
||||
public class TestWorkingBeatmap : WorkingBeatmap
|
||||
{
|
||||
public TestWorkingBeatmap(Beatmap beatmap)
|
||||
: base(beatmap.BeatmapInfo)
|
||||
: base(beatmap.BeatmapInfo, true)
|
||||
{
|
||||
this.beatmap = beatmap;
|
||||
}
|
||||
|
@ -151,6 +151,8 @@ namespace osu.Desktop.VisualTests.Tests
|
||||
|
||||
private int calculateBeatCount(TimingControlPoint current)
|
||||
{
|
||||
if (timingPoints.Count == 0) return 0;
|
||||
|
||||
if (timingPoints[timingPoints.Count - 1] == current)
|
||||
return (int)Math.Ceiling((Beatmap.Value.Track.Length - current.Time) / current.BeatLength);
|
||||
|
||||
|
@ -81,7 +81,7 @@ namespace osu.Desktop.VisualTests.Tests
|
||||
{
|
||||
return new Player
|
||||
{
|
||||
Beatmap = beatmap
|
||||
InitialBeatmap = beatmap
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -59,7 +59,7 @@ namespace osu.Desktop.VisualTests.Tests
|
||||
}
|
||||
})
|
||||
{
|
||||
Beatmap = beatmap
|
||||
InitialBeatmap = beatmap
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -113,7 +113,7 @@ namespace osu.Game.Rulesets.Mania.UI
|
||||
{
|
||||
base.ApplyBeatmap();
|
||||
|
||||
PreferredColumns = (int)Math.Round(Beatmap.BeatmapInfo.Difficulty.CircleSize);
|
||||
PreferredColumns = (int)Math.Max(1, Math.Round(Beatmap.BeatmapInfo.Difficulty.CircleSize));
|
||||
}
|
||||
|
||||
protected override void ApplySpeedAdjustments()
|
||||
|
@ -5,7 +5,7 @@ using System;
|
||||
|
||||
namespace osu.Game.Beatmaps.ControlPoints
|
||||
{
|
||||
public class ControlPoint : IComparable<ControlPoint>
|
||||
public class ControlPoint : IComparable<ControlPoint>, IEquatable<ControlPoint>
|
||||
{
|
||||
/// <summary>
|
||||
/// The time at which the control point takes effect.
|
||||
@ -13,5 +13,7 @@ namespace osu.Game.Beatmaps.ControlPoints
|
||||
public double Time;
|
||||
|
||||
public int CompareTo(ControlPoint other) => Time.CompareTo(other.Time);
|
||||
|
||||
public bool Equals(ControlPoint other) => Time.Equals(other?.Time);
|
||||
}
|
||||
}
|
||||
|
82
osu.Game/Beatmaps/DummyWorkingBeatmap.cs
Normal file
82
osu.Game/Beatmaps/DummyWorkingBeatmap.cs
Normal file
@ -0,0 +1,82 @@
|
||||
// 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 osu.Framework.Audio.Track;
|
||||
using osu.Framework.Graphics.Textures;
|
||||
using osu.Game.Database;
|
||||
using osu.Game.Rulesets;
|
||||
using osu.Game.Rulesets.Mods;
|
||||
using osu.Game.Rulesets.Objects;
|
||||
using osu.Game.Rulesets.Scoring;
|
||||
using osu.Game.Rulesets.UI;
|
||||
using osu.Game.Screens.Play;
|
||||
|
||||
namespace osu.Game.Beatmaps
|
||||
{
|
||||
internal class DummyWorkingBeatmap : WorkingBeatmap
|
||||
{
|
||||
private readonly OsuGameBase game;
|
||||
|
||||
public DummyWorkingBeatmap(OsuGameBase game)
|
||||
: base(new BeatmapInfo
|
||||
{
|
||||
Metadata = new BeatmapMetadata
|
||||
{
|
||||
Artist = "please load a beatmap!",
|
||||
Title = "no beatmaps available!",
|
||||
Author = "no one",
|
||||
},
|
||||
BeatmapSet = new BeatmapSetInfo(),
|
||||
Difficulty = new BeatmapDifficulty
|
||||
{
|
||||
DrainRate = 0,
|
||||
CircleSize = 0,
|
||||
OverallDifficulty = 0,
|
||||
ApproachRate = 0,
|
||||
SliderMultiplier = 0,
|
||||
SliderTickRate = 0,
|
||||
},
|
||||
Ruleset = new DummyRulesetInfo()
|
||||
})
|
||||
{
|
||||
this.game = game;
|
||||
}
|
||||
|
||||
protected override Beatmap GetBeatmap() => new Beatmap
|
||||
{
|
||||
HitObjects = new List<HitObject>(),
|
||||
};
|
||||
|
||||
protected override Texture GetBackground() => game.Textures.Get(@"Backgrounds/bg4");
|
||||
|
||||
protected override Track GetTrack() => new TrackVirtual();
|
||||
|
||||
private class DummyRulesetInfo : RulesetInfo
|
||||
{
|
||||
public override Ruleset CreateInstance() => new DummyRuleset();
|
||||
|
||||
private class DummyRuleset : Ruleset
|
||||
{
|
||||
public override IEnumerable<Mod> GetModsFor(ModType type) => new Mod[] { };
|
||||
|
||||
public override HitRenderer CreateHitRendererWith(WorkingBeatmap beatmap, bool isForCurrentRuleset)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public override DifficultyCalculator CreateDifficultyCalculator(Beatmap beatmap) => null;
|
||||
|
||||
public override ScoreProcessor CreateScoreProcessor()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public override string Description => "dummy";
|
||||
|
||||
public override IEnumerable<KeyCounter> CreateGameplayKeys() => new List<KeyCounter>();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -15,7 +15,7 @@ namespace osu.Game.Beatmaps.IO
|
||||
AddReader<OszArchiveReader>((storage, path) =>
|
||||
{
|
||||
using (var stream = storage.GetStream(path))
|
||||
return ZipFile.IsZipFile(stream, false);
|
||||
return stream != null && ZipFile.IsZipFile(stream, false);
|
||||
});
|
||||
OsuLegacyDecoder.Register();
|
||||
}
|
||||
|
@ -22,14 +22,17 @@ namespace osu.Game.Beatmaps
|
||||
|
||||
public readonly Bindable<IEnumerable<Mod>> Mods = new Bindable<IEnumerable<Mod>>(new Mod[] { });
|
||||
|
||||
public readonly bool WithStoryboard;
|
||||
/// <summary>
|
||||
/// Denotes whether extras like storyboards have been loaded for this <see cref="WorkingBeatmap"/>.
|
||||
/// </summary>
|
||||
public bool FullyLoaded { get; protected set; }
|
||||
|
||||
protected WorkingBeatmap(BeatmapInfo beatmapInfo, bool withStoryboard = false)
|
||||
protected WorkingBeatmap(BeatmapInfo beatmapInfo, bool fullyLoaded = false)
|
||||
{
|
||||
BeatmapInfo = beatmapInfo;
|
||||
BeatmapSetInfo = beatmapInfo.BeatmapSet;
|
||||
Metadata = beatmapInfo.Metadata ?? BeatmapSetInfo.Metadata;
|
||||
WithStoryboard = withStoryboard;
|
||||
FullyLoaded = fullyLoaded;
|
||||
|
||||
Mods.ValueChanged += mods => applyRateAdjustments();
|
||||
}
|
||||
|
@ -28,6 +28,11 @@ namespace osu.Game.Database
|
||||
// ReSharper disable once NotAccessedField.Local (we should keep a reference to this so it is not finalised)
|
||||
private BeatmapIPCChannel ipc;
|
||||
|
||||
/// <summary>
|
||||
/// A default representation of a WorkingBeatmap to use when no beatmap is available.
|
||||
/// </summary>
|
||||
public WorkingBeatmap DefaultBeatmap { private get; set; }
|
||||
|
||||
public BeatmapDatabase(Storage storage, SQLiteConnection connection, RulesetDatabase rulesets, IIpcHost importHost = null) : base(storage, connection)
|
||||
{
|
||||
this.rulesets = rulesets;
|
||||
@ -144,7 +149,11 @@ namespace osu.Game.Database
|
||||
public void Import(params string[] paths)
|
||||
{
|
||||
foreach (string p in paths)
|
||||
Import(p);
|
||||
{
|
||||
//In case the file was imported twice and deleted after the first time
|
||||
if (File.Exists(p))
|
||||
Import(p);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -178,6 +187,8 @@ namespace osu.Game.Database
|
||||
|
||||
if (existing != null)
|
||||
{
|
||||
GetChildren(existing);
|
||||
|
||||
if (existing.DeletePending)
|
||||
{
|
||||
existing.DeletePending = false;
|
||||
@ -268,6 +279,9 @@ namespace osu.Game.Database
|
||||
|
||||
public WorkingBeatmap GetWorkingBeatmap(BeatmapInfo beatmapInfo, WorkingBeatmap previous = null, bool withStoryboard = false)
|
||||
{
|
||||
if (beatmapInfo == null || beatmapInfo == DefaultBeatmap?.BeatmapInfo)
|
||||
return DefaultBeatmap;
|
||||
|
||||
if (beatmapInfo.BeatmapSet == null || beatmapInfo.Ruleset == null)
|
||||
beatmapInfo = GetChildren(beatmapInfo, true);
|
||||
|
||||
|
@ -14,8 +14,8 @@ namespace osu.Game.Database
|
||||
{
|
||||
private readonly BeatmapDatabase database;
|
||||
|
||||
public DatabaseWorkingBeatmap(BeatmapDatabase database, BeatmapInfo beatmapInfo, bool withStoryboard = false)
|
||||
: base(beatmapInfo, withStoryboard)
|
||||
public DatabaseWorkingBeatmap(BeatmapDatabase database, BeatmapInfo beatmapInfo, bool fullyLoaded = false)
|
||||
: base(beatmapInfo, fullyLoaded)
|
||||
{
|
||||
this.database = database;
|
||||
}
|
||||
@ -37,7 +37,7 @@ namespace osu.Game.Database
|
||||
beatmap = decoder.Decode(stream);
|
||||
}
|
||||
|
||||
if (beatmap == null || !WithStoryboard || BeatmapSetInfo.StoryboardFile == null)
|
||||
if (beatmap == null || !FullyLoaded || BeatmapSetInfo.StoryboardFile == null)
|
||||
return beatmap;
|
||||
|
||||
using (var stream = new StreamReader(reader.GetStream(BeatmapSetInfo.StoryboardFile)))
|
||||
|
@ -21,6 +21,6 @@ namespace osu.Game.Database
|
||||
[Indexed]
|
||||
public bool Available { get; set; }
|
||||
|
||||
public Ruleset CreateInstance() => (Ruleset)Activator.CreateInstance(Type.GetType(InstantiationInfo));
|
||||
public virtual Ruleset CreateInstance() => (Ruleset)Activator.CreateInstance(Type.GetType(InstantiationInfo));
|
||||
}
|
||||
}
|
@ -35,10 +35,12 @@ namespace osu.Game.Graphics.Containers
|
||||
|
||||
protected override void Update()
|
||||
{
|
||||
if (Beatmap.Value?.Track == null)
|
||||
var track = Beatmap.Value.Track;
|
||||
|
||||
if (track == null)
|
||||
return;
|
||||
|
||||
double currentTrackTime = Beatmap.Value.Track.CurrentTime + EarlyActivationMilliseconds;
|
||||
double currentTrackTime = track.Length > 0 ? track.CurrentTime + EarlyActivationMilliseconds : Clock.CurrentTime;
|
||||
|
||||
TimingControlPoint timingPoint = Beatmap.Value.Beatmap.ControlPointInfo.TimingPointAt(currentTrackTime);
|
||||
EffectControlPoint effectPoint = Beatmap.Value.Beatmap.ControlPointInfo.EffectPointAt(currentTrackTime);
|
||||
@ -58,7 +60,7 @@ namespace osu.Game.Graphics.Containers
|
||||
|
||||
TimeSinceLastBeat = timingPoint.BeatLength - TimeUntilNextBeat;
|
||||
|
||||
if (timingPoint == lastTimingPoint && beatIndex == lastBeat)
|
||||
if (timingPoint.Equals(lastTimingPoint) && beatIndex == lastBeat)
|
||||
return;
|
||||
|
||||
using (BeginDelayedSequence(-TimeSinceLastBeat, true))
|
||||
|
@ -83,6 +83,8 @@ namespace osu.Game.Graphics.Cursor
|
||||
protected override void PopIn()
|
||||
{
|
||||
instantMovement |= !IsPresent;
|
||||
|
||||
ClearTransforms();
|
||||
FadeIn(500, EasingTypes.OutQuint);
|
||||
}
|
||||
|
||||
|
@ -177,6 +177,7 @@ namespace osu.Game
|
||||
LoadComponentAsync(social = new SocialOverlay { Depth = -1 }, mainContent.Add);
|
||||
LoadComponentAsync(chat = new ChatOverlay { Depth = -1 }, mainContent.Add);
|
||||
LoadComponentAsync(settings = new SettingsOverlay { Depth = -1 }, overlayContent.Add);
|
||||
LoadComponentAsync(userProfile = new UserProfileOverlay { Depth = -2 }, mainContent.Add);
|
||||
LoadComponentAsync(musicController = new MusicController
|
||||
{
|
||||
Depth = -3,
|
||||
|
@ -43,7 +43,7 @@ namespace osu.Game
|
||||
|
||||
protected MenuCursor Cursor;
|
||||
|
||||
public readonly Bindable<WorkingBeatmap> Beatmap = new Bindable<WorkingBeatmap>();
|
||||
public Bindable<WorkingBeatmap> Beatmap { get; private set; }
|
||||
|
||||
private Bindable<bool> fpsDisplayVisible;
|
||||
|
||||
@ -121,6 +121,10 @@ namespace osu.Game
|
||||
Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Venera"));
|
||||
Fonts.AddStore(new GlyphStore(Resources, @"Fonts/Venera-Light"));
|
||||
|
||||
var defaultBeatmap = new DummyWorkingBeatmap(this);
|
||||
Beatmap = new NonNullableBindable<WorkingBeatmap>(defaultBeatmap);
|
||||
BeatmapDatabase.DefaultBeatmap = defaultBeatmap;
|
||||
|
||||
OszArchiveReader.Register();
|
||||
|
||||
Dependencies.Cache(API = new APIAccess
|
||||
@ -129,9 +133,27 @@ namespace osu.Game
|
||||
Token = LocalConfig.Get<string>(OsuSetting.Token)
|
||||
});
|
||||
|
||||
Beatmap.ValueChanged += b =>
|
||||
{
|
||||
// compare to last baetmap as sometimes the two may share a track representation (optimisation, see WorkingBeatmap.TransferTo)
|
||||
if (lastBeatmap?.Track != b.Track)
|
||||
{
|
||||
// this disposal is done to stop the audio track.
|
||||
// it may not be exactly what we want for cases beatmaps are reused, as it will
|
||||
// trigger a fresh load of contained resources.
|
||||
lastBeatmap?.Dispose();
|
||||
|
||||
Audio.Track.AddItem(b.Track);
|
||||
}
|
||||
|
||||
lastBeatmap = b;
|
||||
};
|
||||
|
||||
API.Register(this);
|
||||
}
|
||||
|
||||
private WorkingBeatmap lastBeatmap;
|
||||
|
||||
public void APIStateChanged(APIAccess api, APIState state)
|
||||
{
|
||||
switch (state)
|
||||
|
@ -1,6 +1,7 @@
|
||||
// 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 osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Game.Graphics;
|
||||
@ -8,6 +9,10 @@ using osu.Game.Graphics.Sprites;
|
||||
using osu.Game.Online.Chat;
|
||||
using OpenTK;
|
||||
using OpenTK.Graphics;
|
||||
using osu.Framework.Graphics.Effects;
|
||||
using osu.Framework.Extensions.Color4Extensions;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Game.Users;
|
||||
|
||||
namespace osu.Game.Overlays.Chat
|
||||
{
|
||||
@ -53,21 +58,16 @@ namespace osu.Game.Overlays.Chat
|
||||
OsuColour.FromHex("992861"),
|
||||
};
|
||||
|
||||
private Color4 getUsernameColour(Message message)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(message.Sender?.Colour))
|
||||
return OsuColour.FromHex(message.Sender.Colour);
|
||||
|
||||
//todo: use User instead of Message when user_id is correctly populated.
|
||||
return username_colours[message.UserId % username_colours.Length];
|
||||
}
|
||||
|
||||
public const float LEFT_PADDING = message_padding + padding * 2;
|
||||
|
||||
private const float padding = 15;
|
||||
private const float message_padding = 200;
|
||||
private const float text_size = 20;
|
||||
|
||||
private Action<User> loadProfile;
|
||||
|
||||
private Color4 customUsernameColour;
|
||||
|
||||
public ChatLine(Message message)
|
||||
{
|
||||
Message = message;
|
||||
@ -76,6 +76,59 @@ namespace osu.Game.Overlays.Chat
|
||||
AutoSizeAxes = Axes.Y;
|
||||
|
||||
Padding = new MarginPadding { Left = padding, Right = padding };
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuColour colours, UserProfileOverlay profile)
|
||||
{
|
||||
customUsernameColour = colours.ChatBlue;
|
||||
loadProfile = u => profile?.ShowUser(u);
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
|
||||
bool hasBackground = !string.IsNullOrEmpty(Message.Sender.Colour);
|
||||
Drawable username = new OsuSpriteText
|
||||
{
|
||||
Font = @"Exo2.0-BoldItalic",
|
||||
Text = $@"{Message.Sender.Username}" + (hasBackground ? "" : ":"),
|
||||
Colour = hasBackground ? customUsernameColour : username_colours[Message.UserId % username_colours.Length],
|
||||
TextSize = text_size,
|
||||
};
|
||||
|
||||
if (hasBackground)
|
||||
{
|
||||
// Background effect
|
||||
username = username.WithEffect(new EdgeEffect
|
||||
{
|
||||
CornerRadius = 4,
|
||||
Parameters = new EdgeEffectParameters
|
||||
{
|
||||
Radius = 1,
|
||||
Colour = OsuColour.FromHex(Message.Sender.Colour),
|
||||
Type = EdgeEffectType.Shadow,
|
||||
}
|
||||
}, d =>
|
||||
{
|
||||
d.Padding = new MarginPadding { Left = 3, Right = 3, Bottom = 1, Top = -3 };
|
||||
d.Y = 3;
|
||||
})
|
||||
// Drop shadow effect
|
||||
.WithEffect(new EdgeEffect
|
||||
{
|
||||
CornerRadius = 4,
|
||||
Parameters = new EdgeEffectParameters
|
||||
{
|
||||
Roundness = 1,
|
||||
Offset = new Vector2(0, 3),
|
||||
Radius = 3,
|
||||
Colour = Color4.Black.Opacity(0.3f),
|
||||
Type = EdgeEffectType.Shadow,
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Children = new Drawable[]
|
||||
{
|
||||
@ -94,15 +147,14 @@ namespace osu.Game.Overlays.Chat
|
||||
TextSize = text_size * 0.75f,
|
||||
Alpha = 0.4f,
|
||||
},
|
||||
new OsuSpriteText
|
||||
new ClickableContainer
|
||||
{
|
||||
Font = @"Exo2.0-BoldItalic",
|
||||
Text = $@"{Message.Sender.Username}:",
|
||||
Colour = getUsernameColour(Message),
|
||||
TextSize = text_size,
|
||||
AutoSizeAxes = Axes.Both,
|
||||
Origin = Anchor.TopRight,
|
||||
Anchor = Anchor.TopRight,
|
||||
}
|
||||
Child = username,
|
||||
Action = () => loadProfile(Message.Sender),
|
||||
},
|
||||
}
|
||||
},
|
||||
new Container
|
||||
|
@ -29,6 +29,9 @@ namespace osu.Game.Overlays.Chat
|
||||
scroll = new OsuScrollContainer
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
// Some chat lines have effects that slightly protrude to the bottom,
|
||||
// which we do not want to mask away, hence the padding.
|
||||
Padding = new MarginPadding { Bottom = 5 },
|
||||
Children = new Drawable[]
|
||||
{
|
||||
flow = new FillFlowContainer<ChatLine>
|
||||
|
@ -111,7 +111,7 @@ namespace osu.Game.Overlays
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Padding = new MarginPadding
|
||||
{
|
||||
Bottom = textbox_height + padding
|
||||
Bottom = textbox_height
|
||||
},
|
||||
},
|
||||
new Container
|
||||
|
@ -1,107 +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 System;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Transforms;
|
||||
using osu.Framework.Input;
|
||||
using OpenTK;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
|
||||
namespace osu.Game.Overlays
|
||||
{
|
||||
public class DragBar : Container
|
||||
{
|
||||
protected readonly Container Fill;
|
||||
|
||||
public Action<float> SeekRequested;
|
||||
|
||||
public bool IsSeeking { get; private set; }
|
||||
|
||||
private bool enabled = true;
|
||||
public bool IsEnabled
|
||||
{
|
||||
get { return enabled; }
|
||||
set
|
||||
{
|
||||
enabled = value;
|
||||
if (!enabled)
|
||||
Fill.Width = 0;
|
||||
}
|
||||
}
|
||||
|
||||
public DragBar()
|
||||
{
|
||||
RelativeSizeAxes = Axes.X;
|
||||
|
||||
Children = new Drawable[]
|
||||
{
|
||||
Fill = new Container
|
||||
{
|
||||
Name = "FillContainer",
|
||||
Origin = Anchor.BottomLeft,
|
||||
Anchor = Anchor.BottomLeft,
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Width = 0,
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public void UpdatePosition(float position)
|
||||
{
|
||||
if (IsSeeking || !IsEnabled) return;
|
||||
|
||||
updatePosition(position, false);
|
||||
}
|
||||
|
||||
private void seek(InputState state)
|
||||
{
|
||||
float seekLocation = state.Mouse.Position.X / DrawWidth;
|
||||
|
||||
if (!IsEnabled) return;
|
||||
|
||||
SeekRequested?.Invoke(seekLocation);
|
||||
updatePosition(seekLocation);
|
||||
}
|
||||
|
||||
private void updatePosition(float position, bool easing = true)
|
||||
{
|
||||
position = MathHelper.Clamp(position, 0, 1);
|
||||
Fill.TransformTo(position, easing ? 200 : 0, EasingTypes.OutQuint, new TransformSeek());
|
||||
}
|
||||
|
||||
protected override bool OnMouseDown(InputState state, MouseDownEventArgs args)
|
||||
{
|
||||
seek(state);
|
||||
return true;
|
||||
}
|
||||
|
||||
protected override bool OnDrag(InputState state)
|
||||
{
|
||||
seek(state);
|
||||
return true;
|
||||
}
|
||||
|
||||
protected override bool OnDragStart(InputState state) => IsSeeking = true;
|
||||
|
||||
protected override bool OnDragEnd(InputState state)
|
||||
{
|
||||
IsSeeking = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
private class TransformSeek : TransformFloat<Drawable>
|
||||
{
|
||||
public override void Apply(Drawable d) => d.Width = CurrentValue;
|
||||
public override void ReadIntoStartValue(Drawable d) => StartValue = d.Width;
|
||||
}
|
||||
}
|
||||
}
|
@ -3,9 +3,7 @@
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Audio.Track;
|
||||
using osu.Framework.Configuration;
|
||||
using osu.Framework.Extensions.Color4Extensions;
|
||||
using osu.Framework.Graphics;
|
||||
@ -15,7 +13,6 @@ using osu.Game.Database;
|
||||
using osu.Game.Graphics;
|
||||
using OpenTK;
|
||||
using OpenTK.Graphics;
|
||||
using osu.Framework.Extensions;
|
||||
using osu.Framework.Input;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
|
||||
@ -30,7 +27,6 @@ namespace osu.Game.Overlays.Music
|
||||
private FilterControl filter;
|
||||
private PlaylistList list;
|
||||
|
||||
private TrackManager trackManager;
|
||||
private BeatmapDatabase beatmaps;
|
||||
|
||||
private readonly Bindable<WorkingBeatmap> beatmapBacking = new Bindable<WorkingBeatmap>();
|
||||
@ -43,7 +39,6 @@ namespace osu.Game.Overlays.Music
|
||||
{
|
||||
this.inputManager = inputManager;
|
||||
this.beatmaps = beatmaps;
|
||||
trackManager = game.Audio.Track;
|
||||
|
||||
Children = new Drawable[]
|
||||
{
|
||||
@ -83,11 +78,12 @@ namespace osu.Game.Overlays.Music
|
||||
},
|
||||
};
|
||||
|
||||
list.BeatmapSets = BeatmapSets = beatmaps.GetAllWithChildren<BeatmapSetInfo>().ToList();
|
||||
list.BeatmapSets = BeatmapSets = beatmaps.GetAllWithChildren<BeatmapSetInfo>(b => !b.DeletePending).ToList();
|
||||
|
||||
beatmapBacking.BindTo(game.Beatmap);
|
||||
|
||||
filter.Search.OnCommit = (sender, newText) => {
|
||||
filter.Search.OnCommit = (sender, newText) =>
|
||||
{
|
||||
var beatmap = list.FirstVisibleSet?.Beatmaps?.FirstOrDefault();
|
||||
if (beatmap != null) playSpecified(beatmap);
|
||||
};
|
||||
@ -153,13 +149,7 @@ namespace osu.Game.Overlays.Music
|
||||
private void playSpecified(BeatmapInfo info)
|
||||
{
|
||||
beatmapBacking.Value = beatmaps.GetWorkingBeatmap(info, beatmapBacking);
|
||||
|
||||
Task.Run(() =>
|
||||
{
|
||||
var track = beatmapBacking.Value.Track;
|
||||
trackManager.SetExclusive(track);
|
||||
track.Start();
|
||||
}).ContinueWith(task => Schedule(task.ThrowIfFaulted), TaskContinuationOptions.OnlyOnFaulted);
|
||||
beatmapBacking.Value.Track.Start();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -14,6 +14,7 @@ using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Framework.Graphics.Textures;
|
||||
using osu.Framework.Graphics.UserInterface;
|
||||
using osu.Framework.Input;
|
||||
using osu.Framework.Localisation;
|
||||
using osu.Game.Beatmaps;
|
||||
@ -39,7 +40,7 @@ namespace osu.Game.Overlays
|
||||
private const float bottom_black_area_height = 55;
|
||||
|
||||
private Drawable currentBackground;
|
||||
private DragBar progressBar;
|
||||
private ProgressBar progressBar;
|
||||
|
||||
private IconButton playButton;
|
||||
private IconButton playlistButton;
|
||||
@ -187,13 +188,13 @@ namespace osu.Game.Overlays
|
||||
},
|
||||
}
|
||||
},
|
||||
progressBar = new DragBar
|
||||
progressBar = new ProgressBar
|
||||
{
|
||||
Origin = Anchor.BottomCentre,
|
||||
Anchor = Anchor.BottomCentre,
|
||||
Height = progress_height,
|
||||
Colour = colours.Yellow,
|
||||
SeekRequested = seek
|
||||
FillColour = colours.Yellow,
|
||||
OnSeek = progress => current?.Track.Seek(progress)
|
||||
}
|
||||
},
|
||||
},
|
||||
@ -228,7 +229,9 @@ namespace osu.Game.Overlays
|
||||
{
|
||||
var track = current.Track;
|
||||
|
||||
progressBar.UpdatePosition(track.Length == 0 ? 0 : (float)(track.CurrentTime / track.Length));
|
||||
progressBar.EndTime = track.Length;
|
||||
progressBar.CurrentTime = track.CurrentTime;
|
||||
|
||||
playButton.Icon = track.IsRunning ? FontAwesome.fa_pause_circle_o : FontAwesome.fa_play_circle_o;
|
||||
|
||||
if (track.HasCompleted && !track.Looping) next();
|
||||
@ -274,13 +277,11 @@ namespace osu.Game.Overlays
|
||||
|
||||
private void beatmapChanged(WorkingBeatmap beatmap)
|
||||
{
|
||||
progressBar.IsEnabled = beatmap != null;
|
||||
|
||||
TransformDirection direction = TransformDirection.None;
|
||||
|
||||
if (current != null)
|
||||
{
|
||||
bool audioEquals = beatmapBacking.Value?.BeatmapInfo?.AudioEquals(current.BeatmapInfo) ?? false;
|
||||
bool audioEquals = beatmap?.BeatmapInfo?.AudioEquals(current.BeatmapInfo) ?? false;
|
||||
|
||||
if (audioEquals)
|
||||
direction = TransformDirection.None;
|
||||
@ -293,15 +294,18 @@ namespace osu.Game.Overlays
|
||||
{
|
||||
//figure out the best direction based on order in playlist.
|
||||
var last = playlist.BeatmapSets.TakeWhile(b => b.ID != current.BeatmapSetInfo.ID).Count();
|
||||
var next = beatmapBacking.Value == null ? -1 : playlist.BeatmapSets.TakeWhile(b => b.ID != beatmapBacking.Value.BeatmapSetInfo.ID).Count();
|
||||
var next = beatmap == null ? -1 : playlist.BeatmapSets.TakeWhile(b => b.ID != beatmap.BeatmapSetInfo.ID).Count();
|
||||
|
||||
direction = last > next ? TransformDirection.Prev : TransformDirection.Next;
|
||||
}
|
||||
}
|
||||
|
||||
current = beatmapBacking.Value;
|
||||
current = beatmap;
|
||||
|
||||
progressBar.CurrentTime = 0;
|
||||
|
||||
updateDisplay(current, direction);
|
||||
|
||||
updateDisplay(beatmapBacking, direction);
|
||||
queuedDirection = null;
|
||||
}
|
||||
|
||||
@ -360,12 +364,6 @@ namespace osu.Game.Overlays
|
||||
});
|
||||
}
|
||||
|
||||
private void seek(float position)
|
||||
{
|
||||
var track = current?.Track;
|
||||
track?.Seek(track.Length * position);
|
||||
}
|
||||
|
||||
protected override void PopIn()
|
||||
{
|
||||
base.PopIn();
|
||||
@ -426,5 +424,49 @@ namespace osu.Game.Overlays
|
||||
sprite.Texture = beatmap?.Background ?? textures.Get(@"Backgrounds/bg4");
|
||||
}
|
||||
}
|
||||
|
||||
private class ProgressBar : SliderBar<double>
|
||||
{
|
||||
public Action<double> OnSeek;
|
||||
|
||||
private readonly Box fill;
|
||||
|
||||
public Color4 FillColour
|
||||
{
|
||||
set { fill.Colour = value; }
|
||||
}
|
||||
|
||||
public double EndTime
|
||||
{
|
||||
set { CurrentNumber.MaxValue = value; }
|
||||
}
|
||||
|
||||
public double CurrentTime
|
||||
{
|
||||
set { CurrentNumber.Value = value; }
|
||||
}
|
||||
|
||||
public ProgressBar()
|
||||
{
|
||||
CurrentNumber.MinValue = 0;
|
||||
CurrentNumber.MaxValue = 1;
|
||||
RelativeSizeAxes = Axes.X;
|
||||
|
||||
Children = new Drawable[]
|
||||
{
|
||||
fill = new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Y
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
protected override void UpdateValue(float value)
|
||||
{
|
||||
fill.Width = value * UsableWidth;
|
||||
}
|
||||
|
||||
protected override void OnUserChange() => OnSeek?.Invoke(Current);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -12,16 +12,20 @@ using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Framework.Graphics.Textures;
|
||||
using osu.Framework.Input;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.Containers;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using osu.Game.Users;
|
||||
using System.Diagnostics;
|
||||
using System.Globalization;
|
||||
|
||||
namespace osu.Game.Overlays.Profile
|
||||
{
|
||||
public class ProfileHeader : Container
|
||||
{
|
||||
private readonly OsuTextFlowContainer infoTextLeft, infoTextRight;
|
||||
private readonly OsuTextFlowContainer infoTextLeft;
|
||||
private readonly LinkFlowContainer infoTextRight;
|
||||
private readonly FillFlowContainer<SpriteText> scoreText, scoreNumberText;
|
||||
|
||||
private readonly Container coverContainer, chartContainer, supporterTag;
|
||||
@ -29,6 +33,7 @@ namespace osu.Game.Overlays.Profile
|
||||
private readonly SpriteText levelText;
|
||||
private readonly GradeBadge gradeSSPlus, gradeSS, gradeSPlus, gradeS, gradeA;
|
||||
private readonly Box colourBar;
|
||||
private readonly DrawableFlag countryFlag;
|
||||
|
||||
private const float cover_height = 350;
|
||||
private const float info_height = 150;
|
||||
@ -114,16 +119,17 @@ namespace osu.Game.Overlays.Profile
|
||||
}
|
||||
}
|
||||
},
|
||||
new OsuSpriteText
|
||||
new LinkFlowContainer.LinkText
|
||||
{
|
||||
Text = user.Username,
|
||||
Url = $@"https://osu.ppy.sh/users/{user.Id}",
|
||||
TextSize = 30,
|
||||
Font = @"Exo2.0-RegularItalic",
|
||||
Anchor = Anchor.BottomLeft,
|
||||
Origin = Anchor.BottomLeft,
|
||||
Y = -48
|
||||
},
|
||||
new DrawableFlag(user.Country?.FlagName ?? "__")
|
||||
countryFlag = new DrawableFlag(user.Country?.FlagName ?? "__")
|
||||
{
|
||||
Anchor = Anchor.BottomLeft,
|
||||
Origin = Anchor.BottomLeft,
|
||||
@ -158,7 +164,7 @@ namespace osu.Game.Overlays.Profile
|
||||
ParagraphSpacing = 0.8f,
|
||||
LineSpacing = 0.2f
|
||||
},
|
||||
infoTextRight = new OsuTextFlowContainer(t =>
|
||||
infoTextRight = new LinkFlowContainer(t =>
|
||||
{
|
||||
t.TextSize = 14;
|
||||
t.Font = @"Exo2.0-RegularItalic";
|
||||
@ -350,6 +356,7 @@ namespace osu.Game.Overlays.Profile
|
||||
{
|
||||
infoTextLeft.AddText("from ");
|
||||
infoTextLeft.AddText(user.Country.FullName, boldItalic);
|
||||
countryFlag.FlagName = user.Country.FlagName;
|
||||
}
|
||||
infoTextLeft.NewParagraph();
|
||||
|
||||
@ -373,14 +380,22 @@ namespace osu.Game.Overlays.Profile
|
||||
infoTextLeft.AddText(string.Join(", ", user.PlayStyle), boldItalic);
|
||||
}
|
||||
|
||||
string websiteWithoutProtcol = user.Website;
|
||||
if (!string.IsNullOrEmpty(websiteWithoutProtcol))
|
||||
{
|
||||
int protocolIndex = websiteWithoutProtcol.IndexOf("//", StringComparison.Ordinal);
|
||||
if (protocolIndex >= 0)
|
||||
websiteWithoutProtcol = websiteWithoutProtcol.Substring(protocolIndex + 2);
|
||||
}
|
||||
|
||||
tryAddInfoRightLine(FontAwesome.fa_map_marker, user.Location);
|
||||
tryAddInfoRightLine(FontAwesome.fa_heart_o, user.Intrerests);
|
||||
tryAddInfoRightLine(FontAwesome.fa_suitcase, user.Occupation);
|
||||
infoTextRight.NewParagraph();
|
||||
if (!string.IsNullOrEmpty(user.Twitter))
|
||||
tryAddInfoRightLine(FontAwesome.fa_twitter, "@" + user.Twitter);
|
||||
tryAddInfoRightLine(FontAwesome.fa_globe, user.Website);
|
||||
tryAddInfoRightLine(FontAwesome.fa_skype, user.Skype);
|
||||
tryAddInfoRightLine(FontAwesome.fa_twitter, "@" + user.Twitter, $@"https://twitter.com/{user.Twitter}");
|
||||
tryAddInfoRightLine(FontAwesome.fa_globe, websiteWithoutProtcol, user.Website);
|
||||
tryAddInfoRightLine(FontAwesome.fa_skype, user.Skype, @"skype:" + user.Skype + @"?chat");
|
||||
|
||||
if (user.Statistics != null)
|
||||
{
|
||||
@ -390,7 +405,7 @@ namespace osu.Game.Overlays.Profile
|
||||
scoreText.Add(createScoreText("Ranked Score"));
|
||||
scoreNumberText.Add(createScoreNumberText(user.Statistics.RankedScore.ToString(@"#,0")));
|
||||
scoreText.Add(createScoreText("Accuracy"));
|
||||
scoreNumberText.Add(createScoreNumberText($"{user.Statistics.Accuracy}%"));
|
||||
scoreNumberText.Add(createScoreNumberText($"{user.Statistics.Accuracy.ToString("0.##", CultureInfo.CurrentCulture)}%"));
|
||||
scoreText.Add(createScoreText("Play Count"));
|
||||
scoreNumberText.Add(createScoreNumberText(user.Statistics.PlayCount.ToString(@"#,0")));
|
||||
scoreText.Add(createScoreText("Total Score"));
|
||||
@ -433,12 +448,12 @@ namespace osu.Game.Overlays.Profile
|
||||
Text = text
|
||||
};
|
||||
|
||||
private void tryAddInfoRightLine(FontAwesome icon, string str)
|
||||
private void tryAddInfoRightLine(FontAwesome icon, string str, string url = null)
|
||||
{
|
||||
if (string.IsNullOrEmpty(str)) return;
|
||||
|
||||
infoTextRight.AddIcon(icon);
|
||||
infoTextRight.AddText(" " + str);
|
||||
infoTextRight.AddLink(" " + str, url);
|
||||
infoTextRight.NewLine();
|
||||
}
|
||||
|
||||
@ -479,5 +494,51 @@ namespace osu.Game.Overlays.Profile
|
||||
badge.Texture = textures.Get($"Grades/{grade}");
|
||||
}
|
||||
}
|
||||
|
||||
private class LinkFlowContainer : OsuTextFlowContainer
|
||||
{
|
||||
public override bool HandleInput => true;
|
||||
|
||||
public LinkFlowContainer(Action<SpriteText> defaultCreationParameters = null) : base(defaultCreationParameters)
|
||||
{
|
||||
}
|
||||
|
||||
protected override SpriteText CreateSpriteText() => new LinkText();
|
||||
|
||||
public void AddLink(string text, string url) => AddText(text, link => ((LinkText)link).Url = url);
|
||||
|
||||
public class LinkText : OsuSpriteText
|
||||
{
|
||||
public override bool HandleInput => Url != null;
|
||||
|
||||
public string Url;
|
||||
|
||||
private Color4 hoverColour;
|
||||
|
||||
protected override bool OnHover(InputState state)
|
||||
{
|
||||
FadeColour(hoverColour, 500, EasingTypes.OutQuint);
|
||||
return base.OnHover(state);
|
||||
}
|
||||
|
||||
protected override void OnHoverLost(InputState state)
|
||||
{
|
||||
FadeColour(Color4.White, 500, EasingTypes.OutQuint);
|
||||
base.OnHoverLost(state);
|
||||
}
|
||||
|
||||
protected override bool OnClick(InputState state)
|
||||
{
|
||||
Process.Start(Url);
|
||||
return true;
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuColour colours)
|
||||
{
|
||||
hoverColour = colours.Yellow;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3,6 +3,7 @@
|
||||
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Textures;
|
||||
using OpenTK;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Graphics.Backgrounds;
|
||||
@ -26,11 +27,12 @@ namespace osu.Game.Screens.Backgrounds
|
||||
{
|
||||
if (beatmap == value && beatmap != null)
|
||||
return;
|
||||
|
||||
beatmap = value;
|
||||
|
||||
Schedule(() =>
|
||||
{
|
||||
var newBackground = beatmap == null ? new Background(@"Backgrounds/bg1") : new BeatmapBackground(beatmap);
|
||||
var newBackground = new BeatmapBackground(beatmap);
|
||||
|
||||
LoadComponentAsync(newBackground, delegate
|
||||
{
|
||||
@ -51,7 +53,7 @@ namespace osu.Game.Screens.Backgrounds
|
||||
}
|
||||
}
|
||||
|
||||
public BackgroundScreenBeatmap(WorkingBeatmap beatmap)
|
||||
public BackgroundScreenBeatmap(WorkingBeatmap beatmap = null)
|
||||
{
|
||||
Beatmap = beatmap;
|
||||
}
|
||||
@ -80,9 +82,9 @@ namespace osu.Game.Screens.Backgrounds
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
private void load(TextureStore textures)
|
||||
{
|
||||
Sprite.Texture = beatmap?.Background;
|
||||
Sprite.Texture = beatmap?.Background ?? textures.Get(@"Backgrounds/bg1");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -18,7 +18,7 @@ namespace osu.Game.Screens.Edit
|
||||
|
||||
protected override void OnResuming(Screen last)
|
||||
{
|
||||
Beatmap?.Track?.Stop();
|
||||
Beatmap.Value.Track?.Stop();
|
||||
base.OnResuming(last);
|
||||
}
|
||||
|
||||
@ -26,13 +26,13 @@ namespace osu.Game.Screens.Edit
|
||||
{
|
||||
base.OnEntering(last);
|
||||
Background.FadeColour(Color4.DarkGray, 500);
|
||||
Beatmap?.Track?.Stop();
|
||||
Beatmap.Value.Track?.Stop();
|
||||
}
|
||||
|
||||
protected override bool OnExiting(Screen next)
|
||||
{
|
||||
Background.FadeColour(Color4.White, 500);
|
||||
Beatmap?.Track?.Start();
|
||||
Beatmap.Value.Track?.Start();
|
||||
return base.OnExiting(next);
|
||||
}
|
||||
}
|
||||
|
@ -72,8 +72,6 @@ namespace osu.Game.Screens.Menu
|
||||
menuVoice = config.GetBindable<bool>(OsuSetting.MenuVoice);
|
||||
menuMusic = config.GetBindable<bool>(OsuSetting.MenuMusic);
|
||||
|
||||
var trackManager = audio.Track;
|
||||
|
||||
BeatmapSetInfo setInfo = null;
|
||||
|
||||
if (!menuMusic)
|
||||
@ -103,10 +101,9 @@ namespace osu.Game.Screens.Menu
|
||||
}
|
||||
|
||||
beatmaps.GetChildren(setInfo);
|
||||
Beatmap = beatmaps.GetWorkingBeatmap(setInfo.Beatmaps[0]);
|
||||
Beatmap.Value = beatmaps.GetWorkingBeatmap(setInfo.Beatmaps[0]);
|
||||
|
||||
track = Beatmap.Track;
|
||||
trackManager.SetExclusive(track);
|
||||
track = Beatmap.Value.Track;
|
||||
|
||||
welcome = audio.Sample.Get(@"welcome");
|
||||
seeya = audio.Sample.Get(@"seeya");
|
||||
@ -121,7 +118,9 @@ namespace osu.Game.Screens.Menu
|
||||
|
||||
Scheduler.AddDelayed(delegate
|
||||
{
|
||||
track.Start();
|
||||
// Only start the current track if it is the menu music. A beatmap's track is started when entering the Main Manu.
|
||||
if (menuMusic)
|
||||
track.Start();
|
||||
|
||||
LoadComponentAsync(mainMenu = new MainMenu());
|
||||
|
||||
|
@ -4,7 +4,6 @@
|
||||
using OpenTK;
|
||||
using OpenTK.Graphics;
|
||||
using OpenTK.Graphics.ES30;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Configuration;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Batches;
|
||||
@ -16,6 +15,7 @@ using osu.Framework.Graphics.Textures;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Graphics;
|
||||
using System;
|
||||
using osu.Framework.Allocation;
|
||||
|
||||
namespace osu.Game.Screens.Menu
|
||||
{
|
||||
@ -76,23 +76,24 @@ namespace osu.Game.Screens.Menu
|
||||
BlendingMode = BlendingMode.Additive;
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader(true)]
|
||||
private void load(ShaderManager shaders, OsuGame game)
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(ShaderManager shaders, OsuGameBase game)
|
||||
{
|
||||
if (game?.Beatmap != null)
|
||||
beatmap.BindTo(game.Beatmap);
|
||||
shader = shaders?.Load(VertexShaderDescriptor.TEXTURE_2, FragmentShaderDescriptor.TEXTURE_ROUNDED);
|
||||
beatmap.BindTo(game.Beatmap);
|
||||
shader = shaders.Load(VertexShaderDescriptor.TEXTURE_2, FragmentShaderDescriptor.TEXTURE_ROUNDED);
|
||||
}
|
||||
|
||||
private void updateAmplitudes()
|
||||
{
|
||||
float[] temporalAmplitudes = beatmap.Value?.Track?.CurrentAmplitudes.FrequencyAmplitudes ?? new float[256];
|
||||
var track = beatmap.Value.Track;
|
||||
|
||||
var effect = beatmap.Value?.Beatmap.ControlPointInfo.EffectPointAt(beatmap.Value.Track?.CurrentTime ?? Time.Current);
|
||||
float[] temporalAmplitudes = track?.CurrentAmplitudes.FrequencyAmplitudes ?? new float[256];
|
||||
|
||||
var effect = beatmap.Value.Beatmap.ControlPointInfo.EffectPointAt(track?.CurrentTime ?? Time.Current);
|
||||
|
||||
for (int i = 0; i < bars_per_visualiser; i++)
|
||||
{
|
||||
if (beatmap?.Value?.Track?.IsRunning ?? false)
|
||||
if (track?.IsRunning ?? false)
|
||||
{
|
||||
float targetAmplitude = temporalAmplitudes[(i + indexOffset) % bars_per_visualiser] * (effect?.KiaiMode == true ? 1 : 0.5f);
|
||||
if (targetAmplitude > frequencyAmplitudes[i])
|
||||
|
@ -28,6 +28,8 @@ namespace osu.Game.Screens.Menu
|
||||
private readonly BackgroundScreenDefault background;
|
||||
private Screen songSelect;
|
||||
|
||||
private readonly MenuSideFlashes sideFlashes;
|
||||
|
||||
protected override BackgroundScreen CreateBackground() => background;
|
||||
|
||||
public MainMenu()
|
||||
@ -49,10 +51,10 @@ namespace osu.Game.Screens.Menu
|
||||
OnSolo = delegate { Push(consumeSongSelect()); },
|
||||
OnMulti = delegate { Push(new Lobby()); },
|
||||
OnExit = delegate { Exit(); },
|
||||
},
|
||||
new MenuSideFlashes(),
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
sideFlashes = new MenuSideFlashes(),
|
||||
};
|
||||
}
|
||||
|
||||
@ -67,12 +69,6 @@ namespace osu.Game.Screens.Menu
|
||||
preloadSongSelect();
|
||||
}
|
||||
|
||||
protected override void OnBeatmapChanged(WorkingBeatmap beatmap)
|
||||
{
|
||||
base.OnBeatmapChanged(beatmap);
|
||||
background.Next();
|
||||
}
|
||||
|
||||
private void preloadSongSelect()
|
||||
{
|
||||
if (songSelect == null)
|
||||
@ -90,16 +86,30 @@ namespace osu.Game.Screens.Menu
|
||||
{
|
||||
base.OnEntering(last);
|
||||
buttons.FadeInFromZero(500);
|
||||
if (last is Intro && Beatmap != null)
|
||||
|
||||
var track = Beatmap.Value.Track;
|
||||
var metadata = Beatmap.Value.Metadata;
|
||||
|
||||
if (last is Intro && track != null)
|
||||
{
|
||||
if (!Beatmap.Track.IsRunning)
|
||||
if (!track.IsRunning)
|
||||
{
|
||||
Beatmap.Track.Seek(Beatmap.Metadata.PreviewTime);
|
||||
if (Beatmap.Metadata.PreviewTime == -1)
|
||||
Beatmap.Track.Seek(Beatmap.Track.Length * 0.4f);
|
||||
Beatmap.Track.Start();
|
||||
track.Seek(metadata.PreviewTime);
|
||||
if (metadata.PreviewTime == -1)
|
||||
track.Seek(track.Length * 0.4f);
|
||||
track.Start();
|
||||
}
|
||||
}
|
||||
|
||||
Beatmap.ValueChanged += beatmap_ValueChanged;
|
||||
}
|
||||
|
||||
private void beatmap_ValueChanged(WorkingBeatmap newValue)
|
||||
{
|
||||
if (!IsCurrentScreen)
|
||||
return;
|
||||
|
||||
background.Next();
|
||||
}
|
||||
|
||||
protected override void OnSuspending(Screen next)
|
||||
@ -112,6 +122,8 @@ namespace osu.Game.Screens.Menu
|
||||
|
||||
Content.FadeOut(length, EasingTypes.InSine);
|
||||
Content.MoveTo(new Vector2(-800, 0), length, EasingTypes.InSine);
|
||||
|
||||
sideFlashes.FadeOut(length / 4, EasingTypes.OutQuint);
|
||||
}
|
||||
|
||||
protected override void OnResuming(Screen last)
|
||||
@ -129,6 +141,8 @@ namespace osu.Game.Screens.Menu
|
||||
|
||||
Content.FadeIn(length, EasingTypes.OutQuint);
|
||||
Content.MoveTo(new Vector2(0, 0), length, EasingTypes.OutQuint);
|
||||
|
||||
sideFlashes.FadeIn(length / 4, EasingTypes.InQuint);
|
||||
}
|
||||
|
||||
protected override bool OnExiting(Screen next)
|
||||
|
@ -275,7 +275,7 @@ namespace osu.Game.Screens.Menu
|
||||
const float scale_adjust_cutoff = 0.4f;
|
||||
const float velocity_adjust_cutoff = 0.98f;
|
||||
|
||||
var maxAmplitude = lastBeatIndex >= 0 ? Beatmap.Value?.Track?.CurrentAmplitudes.Maximum ?? 0 : 0;
|
||||
var maxAmplitude = lastBeatIndex >= 0 ? Beatmap.Value.Track?.CurrentAmplitudes.Maximum ?? 0 : 0;
|
||||
logoAmplitudeContainer.ScaleTo(1 - Math.Max(0, maxAmplitude - scale_adjust_cutoff) * 0.04f, 75, EasingTypes.OutQuint);
|
||||
|
||||
if (maxAmplitude > velocity_adjust_cutoff)
|
||||
|
@ -1,6 +1,7 @@
|
||||
// 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 osu.Framework.Allocation;
|
||||
using osu.Framework.Configuration;
|
||||
using osu.Framework.Screens;
|
||||
@ -35,34 +36,31 @@ namespace osu.Game.Screens
|
||||
/// </summary>
|
||||
internal virtual bool AllowBeatmapRulesetChange => true;
|
||||
|
||||
private readonly Bindable<WorkingBeatmap> beatmap = new Bindable<WorkingBeatmap>();
|
||||
protected readonly Bindable<WorkingBeatmap> Beatmap = new Bindable<WorkingBeatmap>();
|
||||
|
||||
public WorkingBeatmap InitialBeatmap
|
||||
{
|
||||
set
|
||||
{
|
||||
if (IsLoaded) throw new InvalidOperationException($"Cannot set {nameof(InitialBeatmap)} post-load.");
|
||||
Beatmap.Value = value;
|
||||
}
|
||||
}
|
||||
|
||||
private readonly Bindable<RulesetInfo> ruleset = new Bindable<RulesetInfo>();
|
||||
|
||||
private SampleChannel sampleExit;
|
||||
|
||||
public WorkingBeatmap Beatmap
|
||||
{
|
||||
get
|
||||
{
|
||||
return beatmap.Value;
|
||||
}
|
||||
set
|
||||
{
|
||||
beatmap.Value = value;
|
||||
}
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader(permitNulls: true)]
|
||||
private void load(OsuGameBase game, OsuGame osuGame, AudioManager audio)
|
||||
{
|
||||
if (game != null)
|
||||
{
|
||||
//if we were given a beatmap at ctor time, we want to pass this on to the game-wide beatmap.
|
||||
var localMap = beatmap.Value;
|
||||
beatmap.BindTo(game.Beatmap);
|
||||
var localMap = Beatmap.Value;
|
||||
Beatmap.BindTo(game.Beatmap);
|
||||
if (localMap != null)
|
||||
beatmap.Value = localMap;
|
||||
Beatmap.Value = localMap;
|
||||
}
|
||||
|
||||
if (osuGame != null)
|
||||
@ -71,20 +69,6 @@ namespace osu.Game.Screens
|
||||
sampleExit = audio.Sample.Get(@"UI/melodic-1");
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
|
||||
beatmap.ValueChanged += OnBeatmapChanged;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The global Beatmap was changed.
|
||||
/// </summary>
|
||||
protected virtual void OnBeatmapChanged(WorkingBeatmap beatmap)
|
||||
{
|
||||
}
|
||||
|
||||
protected override void Update()
|
||||
{
|
||||
if (!IsCurrentScreen) return;
|
||||
@ -94,7 +78,7 @@ namespace osu.Game.Screens
|
||||
// we only want to apply these restrictions when we are inside a screen stack.
|
||||
// the use case for not applying is in visual/unit tests.
|
||||
ruleset.Disabled = !AllowBeatmapRulesetChange;
|
||||
beatmap.Disabled = !AllowBeatmapRulesetChange;
|
||||
Beatmap.Disabled = !AllowBeatmapRulesetChange;
|
||||
}
|
||||
}
|
||||
|
||||
@ -110,8 +94,6 @@ namespace osu.Game.Screens
|
||||
|
||||
BackgroundScreen bg = CreateBackground();
|
||||
|
||||
OnBeatmapChanged(Beatmap);
|
||||
|
||||
if (lastOsu?.Background != null)
|
||||
{
|
||||
if (bg == null || lastOsu.Background.Equals(bg))
|
||||
@ -156,11 +138,7 @@ namespace osu.Game.Screens
|
||||
if (base.OnExiting(next))
|
||||
return true;
|
||||
|
||||
// while this is not necessary as we are constructing our own bindable, there are cases where
|
||||
// the GC doesn't run as fast as expected and this is triggered post-exit.
|
||||
// added to resolve https://github.com/ppy/osu/issues/829
|
||||
beatmap.ValueChanged -= OnBeatmapChanged;
|
||||
|
||||
Beatmap.UnbindAll();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -35,8 +35,6 @@ namespace osu.Game.Screens.Play
|
||||
|
||||
internal override bool HasLocalCursorDisplayed => !pauseContainer.IsPaused && !HasFailed && HitRenderer.ProvidingUserCursor;
|
||||
|
||||
public BeatmapInfo BeatmapInfo;
|
||||
|
||||
public Action RestartRequested;
|
||||
|
||||
internal override bool AllowBeatmapRulesetChange => false;
|
||||
@ -69,6 +67,8 @@ namespace osu.Game.Screens.Play
|
||||
private HUDOverlay hudOverlay;
|
||||
private FailOverlay failOverlay;
|
||||
|
||||
private bool loadedSuccessfully => HitRenderer?.Objects.Any() == true;
|
||||
|
||||
[BackgroundDependencyLoader(permitNulls: true)]
|
||||
private void load(AudioManager audio, BeatmapDatabase beatmaps, OsuConfigManager config, OsuGame osu)
|
||||
{
|
||||
@ -81,24 +81,25 @@ namespace osu.Game.Screens.Play
|
||||
|
||||
try
|
||||
{
|
||||
if (Beatmap == null)
|
||||
Beatmap = beatmaps.GetWorkingBeatmap(BeatmapInfo, withStoryboard: true);
|
||||
if (!Beatmap.Value.FullyLoaded)
|
||||
// we need to ensure extras like storyboards are loaded.
|
||||
Beatmap.Value = beatmaps.GetWorkingBeatmap(Beatmap.Value.BeatmapInfo, withStoryboard: true);
|
||||
|
||||
if (Beatmap?.Beatmap == null)
|
||||
if (Beatmap.Value.Beatmap == null)
|
||||
throw new InvalidOperationException("Beatmap was not loaded");
|
||||
|
||||
ruleset = osu?.Ruleset.Value ?? Beatmap.BeatmapInfo.Ruleset;
|
||||
ruleset = osu?.Ruleset.Value ?? Beatmap.Value.BeatmapInfo.Ruleset;
|
||||
rulesetInstance = ruleset.CreateInstance();
|
||||
|
||||
try
|
||||
{
|
||||
HitRenderer = rulesetInstance.CreateHitRendererWith(Beatmap, ruleset.ID == Beatmap.BeatmapInfo.Ruleset.ID);
|
||||
HitRenderer = rulesetInstance.CreateHitRendererWith(Beatmap, ruleset.ID == Beatmap.Value.BeatmapInfo.Ruleset.ID);
|
||||
}
|
||||
catch (BeatmapInvalidForRulesetException)
|
||||
{
|
||||
// we may fail to create a HitRenderer if the beatmap cannot be loaded with the user's preferred ruleset
|
||||
// let's try again forcing the beatmap's ruleset.
|
||||
ruleset = Beatmap.BeatmapInfo.Ruleset;
|
||||
ruleset = Beatmap.Value.BeatmapInfo.Ruleset;
|
||||
rulesetInstance = ruleset.CreateInstance();
|
||||
HitRenderer = rulesetInstance.CreateHitRendererWith(Beatmap, true);
|
||||
}
|
||||
@ -115,22 +116,11 @@ namespace osu.Game.Screens.Play
|
||||
return;
|
||||
}
|
||||
|
||||
Track track = Beatmap.Track;
|
||||
|
||||
if (track != null)
|
||||
{
|
||||
audio.Track.SetExclusive(track);
|
||||
adjustableSourceClock = track;
|
||||
}
|
||||
else
|
||||
{
|
||||
adjustableSourceClock = new StopwatchClock();
|
||||
}
|
||||
|
||||
adjustableSourceClock = (IAdjustableClock)Beatmap.Value.Track ?? new StopwatchClock();
|
||||
decoupledClock = new DecoupleableInterpolatingFramedClock { IsCoupled = false };
|
||||
|
||||
var firstObjectTime = HitRenderer.Objects.First().StartTime;
|
||||
decoupledClock.Seek(Math.Min(0, firstObjectTime - Math.Max(Beatmap.Beatmap.ControlPointInfo.TimingPointAt(firstObjectTime).BeatLength * 4, Beatmap.BeatmapInfo.AudioLeadIn)));
|
||||
decoupledClock.Seek(Math.Min(0, firstObjectTime - Math.Max(Beatmap.Value.Beatmap.ControlPointInfo.TimingPointAt(firstObjectTime).BeatLength * 4, Beatmap.Value.BeatmapInfo.AudioLeadIn)));
|
||||
decoupledClock.ProcessFrame();
|
||||
|
||||
offsetClock = new FramedOffsetClock(decoupledClock);
|
||||
@ -143,7 +133,7 @@ namespace osu.Game.Screens.Play
|
||||
{
|
||||
adjustableSourceClock.Reset();
|
||||
|
||||
foreach (var mod in Beatmap.Mods.Value.OfType<IApplicableToClock>())
|
||||
foreach (var mod in Beatmap.Value.Mods.Value.OfType<IApplicableToClock>())
|
||||
mod.ApplyToClock(adjustableSourceClock);
|
||||
|
||||
decoupledClock.ChangeSource(adjustableSourceClock);
|
||||
@ -211,7 +201,7 @@ namespace osu.Game.Screens.Play
|
||||
hudOverlay.Progress.AllowSeeking = HitRenderer.HasReplayLoaded;
|
||||
hudOverlay.Progress.OnSeek = pos => decoupledClock.Seek(pos);
|
||||
|
||||
hudOverlay.ModDisplay.Current.BindTo(Beatmap.Mods);
|
||||
hudOverlay.ModDisplay.Current.BindTo(Beatmap.Value.Mods);
|
||||
|
||||
//bind HitRenderer to ScoreProcessor and ourselves (for a pass situation)
|
||||
HitRenderer.OnAllJudged += onCompletion;
|
||||
@ -244,7 +234,7 @@ namespace osu.Game.Screens.Play
|
||||
{
|
||||
var score = new Score
|
||||
{
|
||||
Beatmap = Beatmap.BeatmapInfo,
|
||||
Beatmap = Beatmap.Value.BeatmapInfo,
|
||||
Ruleset = ruleset
|
||||
};
|
||||
scoreProcessor.PopulateScore(score);
|
||||
@ -267,6 +257,9 @@ namespace osu.Game.Screens.Play
|
||||
{
|
||||
base.OnEntering(last);
|
||||
|
||||
if (!loadedSuccessfully)
|
||||
return;
|
||||
|
||||
(Background as BackgroundScreenBeatmap)?.BlurTo(Vector2.Zero, 1500, EasingTypes.OutQuint);
|
||||
Background?.FadeTo(1 - (float)dimLevel, 1500, EasingTypes.OutQuint);
|
||||
|
||||
@ -306,7 +299,11 @@ namespace osu.Game.Screens.Play
|
||||
return base.OnExiting(next);
|
||||
}
|
||||
|
||||
pauseContainer.Pause();
|
||||
if (loadedSuccessfully)
|
||||
{
|
||||
pauseContainer.Pause();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -35,7 +35,8 @@ namespace osu.Game.Screens.Play
|
||||
{
|
||||
this.player = player;
|
||||
|
||||
player.RestartRequested = () => {
|
||||
player.RestartRequested = () =>
|
||||
{
|
||||
showOverlays = false;
|
||||
ValidForResume = true;
|
||||
};
|
||||
@ -74,7 +75,6 @@ namespace osu.Game.Screens.Play
|
||||
{
|
||||
RestartCount = player.RestartCount + 1,
|
||||
RestartRequested = player.RestartRequested,
|
||||
Beatmap = player.Beatmap,
|
||||
});
|
||||
|
||||
Delay(400);
|
||||
|
@ -12,7 +12,6 @@ using System.Linq;
|
||||
using osu.Framework.Timing;
|
||||
using osu.Game.Rulesets.Objects;
|
||||
using osu.Game.Rulesets.Objects.Types;
|
||||
|
||||
namespace osu.Game.Screens.Play
|
||||
{
|
||||
public class SongProgress : OverlayContainer
|
||||
@ -50,6 +49,9 @@ namespace osu.Game.Screens.Play
|
||||
|
||||
info.StartTime = firstHitTime;
|
||||
info.EndTime = lastHitTime;
|
||||
|
||||
bar.StartTime = firstHitTime;
|
||||
bar.EndTime = lastHitTime;
|
||||
}
|
||||
}
|
||||
|
||||
@ -89,10 +91,7 @@ namespace osu.Game.Screens.Play
|
||||
Alpha = 0,
|
||||
Anchor = Anchor.BottomLeft,
|
||||
Origin = Anchor.BottomLeft,
|
||||
SeekRequested = delegate (float position)
|
||||
{
|
||||
OnSeek?.Invoke(firstHitTime + position * (lastHitTime - firstHitTime));
|
||||
},
|
||||
OnSeek = position => OnSeek?.Invoke(position),
|
||||
},
|
||||
};
|
||||
}
|
||||
@ -144,11 +143,12 @@ namespace osu.Game.Screens.Play
|
||||
if (objects == null)
|
||||
return;
|
||||
|
||||
double progress = ((audioClock?.CurrentTime ?? Time.Current) - firstHitTime) / (lastHitTime - firstHitTime);
|
||||
double position = audioClock?.CurrentTime ?? Time.Current;
|
||||
double progress = (position - firstHitTime) / (lastHitTime - firstHitTime);
|
||||
|
||||
if (progress < 1)
|
||||
{
|
||||
bar.UpdatePosition((float)progress);
|
||||
bar.CurrentTime = position;
|
||||
graph.Progress = (int)(graph.ColumnCount * progress);
|
||||
}
|
||||
}
|
||||
|
@ -1,74 +1,117 @@
|
||||
// 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;
|
||||
using OpenTK.Graphics;
|
||||
using osu.Game.Overlays;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Framework.Graphics.UserInterface;
|
||||
|
||||
namespace osu.Game.Screens.Play
|
||||
{
|
||||
public class SongProgressBar : DragBar
|
||||
public class SongProgressBar : SliderBar<double>
|
||||
{
|
||||
public Action<double> OnSeek;
|
||||
|
||||
private readonly Box fill;
|
||||
private readonly Container handleBase;
|
||||
|
||||
public Color4 FillColour
|
||||
{
|
||||
get { return Fill.Colour; }
|
||||
set { Fill.Colour = value; }
|
||||
set { fill.Colour = value; }
|
||||
}
|
||||
|
||||
public double StartTime
|
||||
{
|
||||
set { CurrentNumber.MinValue = value; }
|
||||
}
|
||||
|
||||
public double EndTime
|
||||
{
|
||||
set { CurrentNumber.MaxValue = value; }
|
||||
}
|
||||
|
||||
public double CurrentTime
|
||||
{
|
||||
set { CurrentNumber.Value = value; }
|
||||
}
|
||||
|
||||
public SongProgressBar(float barHeight, float handleBarHeight, Vector2 handleSize)
|
||||
{
|
||||
CurrentNumber.MinValue = 0;
|
||||
CurrentNumber.MaxValue = 1;
|
||||
|
||||
RelativeSizeAxes = Axes.X;
|
||||
Height = barHeight + handleBarHeight + handleSize.Y;
|
||||
|
||||
Fill.RelativeSizeAxes = Axes.X;
|
||||
Fill.Height = barHeight;
|
||||
|
||||
Add(new Box
|
||||
Children = new Drawable[]
|
||||
{
|
||||
Name = "Background",
|
||||
Anchor = Anchor.BottomLeft,
|
||||
Origin = Anchor.BottomLeft,
|
||||
RelativeSizeAxes = Axes.X,
|
||||
Height = barHeight,
|
||||
Colour = Color4.Black,
|
||||
Alpha = 0.5f,
|
||||
Depth = 1
|
||||
});
|
||||
|
||||
Fill.Add(new Container
|
||||
{
|
||||
Origin = Anchor.BottomRight,
|
||||
Anchor = Anchor.BottomRight,
|
||||
Width = 2,
|
||||
Height = barHeight + handleBarHeight,
|
||||
Colour = Color4.White,
|
||||
Position = new Vector2(2, 0),
|
||||
Children = new Drawable[]
|
||||
new Box
|
||||
{
|
||||
new Box
|
||||
Name = "Background",
|
||||
Anchor = Anchor.BottomLeft,
|
||||
Origin = Anchor.BottomLeft,
|
||||
RelativeSizeAxes = Axes.X,
|
||||
Height = barHeight,
|
||||
Colour = Color4.Black,
|
||||
Alpha = 0.5f,
|
||||
Depth = 1,
|
||||
},
|
||||
fill = new Box
|
||||
{
|
||||
Name = "Fill",
|
||||
Anchor = Anchor.BottomLeft,
|
||||
Origin = Anchor.BottomLeft,
|
||||
Height = barHeight,
|
||||
},
|
||||
handleBase = new Container
|
||||
{
|
||||
Name = "HandleBar container",
|
||||
Origin = Anchor.BottomLeft,
|
||||
Anchor = Anchor.BottomLeft,
|
||||
Width = 2,
|
||||
Height = barHeight + handleBarHeight,
|
||||
Colour = Color4.White,
|
||||
Position = new Vector2(2, 0),
|
||||
Children = new Drawable[]
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
},
|
||||
new Container
|
||||
{
|
||||
Origin = Anchor.BottomCentre,
|
||||
Anchor = Anchor.TopCentre,
|
||||
Size = handleSize,
|
||||
CornerRadius = 5,
|
||||
Masking = true,
|
||||
Children = new Drawable[]
|
||||
new Box
|
||||
{
|
||||
new Box
|
||||
Name = "HandleBar box",
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
},
|
||||
new Container
|
||||
{
|
||||
Name = "Handle container",
|
||||
Origin = Anchor.BottomCentre,
|
||||
Anchor = Anchor.TopCentre,
|
||||
Size = handleSize,
|
||||
CornerRadius = 5,
|
||||
Masking = true,
|
||||
Children = new Drawable[]
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Colour = Color4.White
|
||||
new Box
|
||||
{
|
||||
Name = "Handle box",
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Colour = Color4.White
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
protected override void UpdateValue(float value)
|
||||
{
|
||||
var xFill = value * UsableWidth;
|
||||
fill.Width = xFill;
|
||||
handleBase.MoveToX(xFill);
|
||||
}
|
||||
|
||||
protected override void OnUserChange() => OnSeek?.Invoke(Current);
|
||||
}
|
||||
}
|
||||
|
@ -165,7 +165,7 @@ namespace osu.Game.Screens.Ranking
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Alpha = 0.2f,
|
||||
Texture = Beatmap?.Background,
|
||||
Texture = Beatmap.Value.Background,
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
FillMode = FillMode.Fill
|
||||
|
@ -137,6 +137,7 @@ namespace osu.Game.Screens.Select
|
||||
{
|
||||
selectedGroup = null;
|
||||
selectedPanel = null;
|
||||
SelectionChanged?.Invoke(null);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -284,6 +285,7 @@ namespace osu.Game.Screens.Select
|
||||
private void load(BeatmapDatabase database, OsuConfigManager config)
|
||||
{
|
||||
this.database = database;
|
||||
|
||||
randomType = config.GetBindable<SelectionRandomType>(OsuSetting.SelectionRandomType);
|
||||
}
|
||||
|
||||
|
@ -45,6 +45,12 @@ namespace osu.Game.Screens.Select
|
||||
};
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
AlwaysPresent = true;
|
||||
}
|
||||
|
||||
protected override bool HideOnEscape => false;
|
||||
|
||||
protected override bool BlockPassThroughMouse => false;
|
||||
@ -63,18 +69,6 @@ namespace osu.Game.Screens.Select
|
||||
|
||||
public void UpdateBeatmap(WorkingBeatmap beatmap)
|
||||
{
|
||||
if (beatmap?.BeatmapInfo == null)
|
||||
{
|
||||
State = Visibility.Hidden;
|
||||
beatmapInfoContainer?.FadeOut(250);
|
||||
beatmapInfoContainer?.Expire();
|
||||
beatmapInfoContainer = null;
|
||||
return;
|
||||
}
|
||||
|
||||
State = Visibility.Visible;
|
||||
AlwaysPresent = true;
|
||||
|
||||
var lastContainer = beatmapInfoContainer;
|
||||
float newDepth = lastContainer?.Depth + 1 ?? 0;
|
||||
|
||||
|
@ -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.Graphics;
|
||||
using OpenTK.Input;
|
||||
@ -31,7 +32,7 @@ namespace osu.Game.Screens.Select
|
||||
public Action OnBack;
|
||||
public Action OnStart;
|
||||
|
||||
private readonly FillFlowContainer buttons;
|
||||
private readonly FillFlowContainer<FooterButton> buttons;
|
||||
|
||||
public OsuLogo StartButton;
|
||||
|
||||
@ -43,29 +44,21 @@ namespace osu.Game.Screens.Select
|
||||
/// <para>Higher depth to be put on the left, and lower to be put on the right.</para>
|
||||
/// <para>Notice this is different to <see cref="Options.BeatmapOptionsOverlay"/>!</para>
|
||||
/// </param>
|
||||
public void AddButton(string text, Color4 colour, Action action, Key? hotkey = null, float depth = 0)
|
||||
public void AddButton(string text, Color4 colour, Action action, Key? hotkey = null, float depth = 0) => buttons.Add(new FooterButton
|
||||
{
|
||||
var button = new FooterButton
|
||||
{
|
||||
Text = text,
|
||||
Height = play_song_select_button_height,
|
||||
Width = play_song_select_button_width,
|
||||
Depth = depth,
|
||||
SelectedColour = colour,
|
||||
DeselectedColour = colour.Opacity(0.5f),
|
||||
Hotkey = hotkey,
|
||||
};
|
||||
Text = text,
|
||||
Height = play_song_select_button_height,
|
||||
Width = play_song_select_button_width,
|
||||
Depth = depth,
|
||||
SelectedColour = colour,
|
||||
DeselectedColour = colour.Opacity(0.5f),
|
||||
Hotkey = hotkey,
|
||||
Hovered = updateModeLight,
|
||||
HoverLost = updateModeLight,
|
||||
Action = action,
|
||||
});
|
||||
|
||||
button.Hovered = () => updateModeLight(button);
|
||||
button.HoverLost = () => updateModeLight();
|
||||
button.Action = action;
|
||||
buttons.Add(button);
|
||||
}
|
||||
|
||||
private void updateModeLight(FooterButton button = null)
|
||||
{
|
||||
modeLight.FadeColour(button?.SelectedColour ?? Color4.Transparent, TRANSITION_LENGTH, EasingTypes.OutQuint);
|
||||
}
|
||||
private void updateModeLight() => modeLight.FadeColour(buttons.FirstOrDefault(b => b.IsHovered)?.SelectedColour ?? Color4.Transparent, TRANSITION_LENGTH, EasingTypes.OutQuint);
|
||||
|
||||
public Footer()
|
||||
{
|
||||
@ -111,7 +104,7 @@ namespace osu.Game.Screens.Select
|
||||
Spacing = new Vector2(padding, 0),
|
||||
Children = new Drawable[]
|
||||
{
|
||||
buttons = new FillFlowContainer
|
||||
buttons = new FillFlowContainer<FooterButton>
|
||||
{
|
||||
Direction = FillDirection.Horizontal,
|
||||
Spacing = new Vector2(0.2f, 0),
|
||||
|
@ -59,21 +59,20 @@ namespace osu.Game.Screens.Select
|
||||
ValidForResume = false;
|
||||
Push(new Editor());
|
||||
}, Key.Number3);
|
||||
|
||||
Beatmap.ValueChanged += beatmap_ValueChanged;
|
||||
}
|
||||
|
||||
protected override void OnBeatmapChanged(WorkingBeatmap beatmap)
|
||||
private void beatmap_ValueChanged(WorkingBeatmap beatmap)
|
||||
{
|
||||
beatmap?.Mods.BindTo(modSelect.SelectedMods);
|
||||
if (!IsCurrentScreen) return;
|
||||
|
||||
if (Beatmap?.Track != null)
|
||||
Beatmap.Track.Looping = false;
|
||||
beatmap.Mods.BindTo(modSelect.SelectedMods);
|
||||
|
||||
beatmapDetails.Beatmap = beatmap;
|
||||
|
||||
if (beatmap?.Track != null)
|
||||
if (beatmap.Track != null)
|
||||
beatmap.Track.Looping = true;
|
||||
|
||||
base.OnBeatmapChanged(beatmap);
|
||||
}
|
||||
|
||||
protected override void OnResuming(Screen last)
|
||||
@ -83,7 +82,7 @@ namespace osu.Game.Screens.Select
|
||||
modSelect.SelectedMods.Value = originalMods;
|
||||
originalMods = null;
|
||||
|
||||
Beatmap.Track.Looping = true;
|
||||
Beatmap.Value.Track.Looping = true;
|
||||
|
||||
base.OnResuming(last);
|
||||
}
|
||||
@ -106,8 +105,8 @@ namespace osu.Game.Screens.Select
|
||||
if (base.OnExiting(next))
|
||||
return true;
|
||||
|
||||
if (Beatmap?.Track != null)
|
||||
Beatmap.Track.Looping = false;
|
||||
if (Beatmap.Value.Track != null)
|
||||
Beatmap.Value.Track.Looping = false;
|
||||
|
||||
return false;
|
||||
}
|
||||
@ -125,12 +124,9 @@ namespace osu.Game.Screens.Select
|
||||
modSelect.SelectedMods.Value = originalMods.Concat(new[] { auto });
|
||||
}
|
||||
|
||||
Beatmap.Track.Looping = false;
|
||||
Beatmap.Value.Track.Looping = false;
|
||||
|
||||
LoadComponentAsync(player = new PlayerLoader(new Player
|
||||
{
|
||||
Beatmap = Beatmap, //eagerly set this so it's present before push.
|
||||
}), l => Push(player));
|
||||
LoadComponentAsync(player = new PlayerLoader(new Player()), l => Push(player));
|
||||
}
|
||||
|
||||
private Mod findAutoMod(IEnumerable<Mod> mods)
|
||||
|
@ -1,6 +1,7 @@
|
||||
// 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.Threading;
|
||||
using OpenTK;
|
||||
using OpenTK.Input;
|
||||
@ -28,10 +29,9 @@ namespace osu.Game.Screens.Select
|
||||
{
|
||||
protected readonly Bindable<RulesetInfo> Ruleset = new Bindable<RulesetInfo>();
|
||||
private BeatmapDatabase database;
|
||||
protected override BackgroundScreen CreateBackground() => new BackgroundScreenBeatmap(Beatmap);
|
||||
protected override BackgroundScreen CreateBackground() => new BackgroundScreenBeatmap();
|
||||
|
||||
private readonly BeatmapCarousel carousel;
|
||||
private TrackManager trackManager;
|
||||
private DialogOverlay dialogOverlay;
|
||||
|
||||
private static readonly Vector2 wedged_container_size = new Vector2(0.5f, 245);
|
||||
@ -107,8 +107,9 @@ namespace osu.Game.Screens.Select
|
||||
Size = new Vector2(carousel_width, 1),
|
||||
Anchor = Anchor.CentreRight,
|
||||
Origin = Anchor.CentreRight,
|
||||
SelectionChanged = selectionChanged,
|
||||
StartRequested = raiseSelect
|
||||
SelectionChanged = carouselSelectionChanged,
|
||||
BeatmapsChanged = carouselBeatmapsLoaded,
|
||||
StartRequested = carouselRaisedStart
|
||||
});
|
||||
Add(FilterControl = new FilterControl
|
||||
{
|
||||
@ -127,7 +128,6 @@ namespace osu.Game.Screens.Select
|
||||
Top = left_area_padding,
|
||||
Right = left_area_padding,
|
||||
},
|
||||
X = -50,
|
||||
});
|
||||
|
||||
if (ShowFooter)
|
||||
@ -146,7 +146,7 @@ namespace osu.Game.Screens.Select
|
||||
Add(Footer = new Footer
|
||||
{
|
||||
OnBack = Exit,
|
||||
OnStart = raiseSelect,
|
||||
OnStart = carouselRaisedStart,
|
||||
});
|
||||
|
||||
FooterPanels.Add(BeatmapOptions = new BeatmapOptionsOverlay());
|
||||
@ -173,7 +173,6 @@ namespace osu.Game.Screens.Select
|
||||
database.BeatmapSetAdded += onBeatmapSetAdded;
|
||||
database.BeatmapSetRemoved += onBeatmapSetRemoved;
|
||||
|
||||
trackManager = audio.Track;
|
||||
dialogOverlay = dialog;
|
||||
|
||||
sampleChangeDifficulty = audio.Sample.Get(@"SongSelect/select-difficulty");
|
||||
@ -181,34 +180,79 @@ namespace osu.Game.Screens.Select
|
||||
|
||||
initialAddSetsTask = new CancellationTokenSource();
|
||||
|
||||
carousel.BeatmapsChanged = beatmapsLoaded;
|
||||
carousel.Beatmaps = database.GetAllWithChildren<BeatmapSetInfo>(b => !b.DeletePending);
|
||||
|
||||
Beatmap.ValueChanged += beatmap_ValueChanged;
|
||||
}
|
||||
|
||||
private void beatmapsLoaded()
|
||||
private void carouselBeatmapsLoaded()
|
||||
{
|
||||
if (Beatmap != null)
|
||||
carousel.SelectBeatmap(Beatmap.BeatmapInfo, false);
|
||||
if (Beatmap.Value != null && Beatmap.Value.BeatmapSetInfo?.DeletePending != false)
|
||||
carousel.SelectBeatmap(Beatmap.Value.BeatmapInfo, false);
|
||||
else
|
||||
carousel.SelectNext();
|
||||
}
|
||||
|
||||
private void raiseSelect()
|
||||
private void carouselRaisedStart()
|
||||
{
|
||||
var pendingSelection = selectionChangedDebounce;
|
||||
selectionChangedDebounce = null;
|
||||
|
||||
if (pendingSelection?.Completed == false)
|
||||
{
|
||||
pendingSelection?.RunTask();
|
||||
pendingSelection?.Cancel(); // cancel the already scheduled task.
|
||||
pendingSelection.RunTask();
|
||||
pendingSelection.Cancel(); // cancel the already scheduled task.
|
||||
}
|
||||
|
||||
if (Beatmap == null) return;
|
||||
|
||||
OnSelected();
|
||||
}
|
||||
|
||||
private ScheduledDelegate selectionChangedDebounce;
|
||||
|
||||
// We need to keep track of the last selected beatmap ignoring debounce to play the correct selection sounds.
|
||||
private BeatmapInfo beatmapNoDebounce;
|
||||
|
||||
/// <summary>
|
||||
/// selection has been changed as the result of interaction with the carousel.
|
||||
/// </summary>
|
||||
private void carouselSelectionChanged(BeatmapInfo beatmap)
|
||||
{
|
||||
Action performLoad = delegate
|
||||
{
|
||||
bool preview = beatmap?.BeatmapSetInfoID != Beatmap.Value.BeatmapInfo.BeatmapSetInfoID;
|
||||
|
||||
Beatmap.Value = database.GetWorkingBeatmap(beatmap, Beatmap);
|
||||
|
||||
ensurePlayingSelected(preview);
|
||||
changeBackground(Beatmap.Value);
|
||||
};
|
||||
|
||||
if (beatmap == null)
|
||||
{
|
||||
if (!Beatmap.IsDefault)
|
||||
performLoad();
|
||||
}
|
||||
else
|
||||
{
|
||||
selectionChangedDebounce?.Cancel();
|
||||
|
||||
if (beatmap.Equals(beatmapNoDebounce))
|
||||
return;
|
||||
|
||||
if (beatmap.BeatmapSetInfoID == beatmapNoDebounce?.BeatmapSetInfoID)
|
||||
sampleChangeDifficulty.Play();
|
||||
else
|
||||
sampleChangeBeatmap.Play();
|
||||
|
||||
beatmapNoDebounce = beatmap;
|
||||
|
||||
if (beatmap == Beatmap.Value.BeatmapInfo)
|
||||
performLoad();
|
||||
else
|
||||
selectionChangedDebounce = Scheduler.AddDelayed(performLoad, 100);
|
||||
}
|
||||
}
|
||||
|
||||
private void triggerRandom(UserInputManager input)
|
||||
{
|
||||
if (input.CurrentState.Keyboard.ShiftPressed)
|
||||
@ -231,23 +275,27 @@ namespace osu.Game.Screens.Select
|
||||
protected override void OnEntering(Screen last)
|
||||
{
|
||||
base.OnEntering(last);
|
||||
ensurePlayingSelected();
|
||||
|
||||
changeBackground(Beatmap);
|
||||
|
||||
selectionChangeNoBounce = Beatmap?.BeatmapInfo;
|
||||
|
||||
Content.FadeInFromZero(250);
|
||||
|
||||
beatmapInfoWedge.State = Visibility.Visible;
|
||||
|
||||
FilterControl.Activate();
|
||||
}
|
||||
|
||||
private void beatmap_ValueChanged(WorkingBeatmap beatmap)
|
||||
{
|
||||
if (!IsCurrentScreen) return;
|
||||
|
||||
carousel.SelectBeatmap(beatmap?.BeatmapInfo);
|
||||
}
|
||||
|
||||
protected override void OnResuming(Screen last)
|
||||
{
|
||||
changeBackground(Beatmap);
|
||||
ensurePlayingSelected();
|
||||
if (Beatmap != null && !Beatmap.Value.BeatmapSetInfo.DeletePending)
|
||||
{
|
||||
changeBackground(Beatmap);
|
||||
ensurePlayingSelected();
|
||||
}
|
||||
|
||||
base.OnResuming(last);
|
||||
|
||||
Content.FadeIn(250);
|
||||
@ -300,61 +348,17 @@ namespace osu.Game.Screens.Select
|
||||
backgroundModeBeatmap.FadeTo(1, 250);
|
||||
}
|
||||
|
||||
beatmapInfoWedge.State = Visibility.Visible;
|
||||
beatmapInfoWedge.UpdateBeatmap(beatmap);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The global Beatmap was changed.
|
||||
/// </summary>
|
||||
protected override void OnBeatmapChanged(WorkingBeatmap beatmap)
|
||||
{
|
||||
base.OnBeatmapChanged(beatmap);
|
||||
|
||||
//todo: change background in selectionChanged instead; support per-difficulty backgrounds.
|
||||
changeBackground(beatmap);
|
||||
carousel.SelectBeatmap(beatmap?.BeatmapInfo);
|
||||
}
|
||||
|
||||
private ScheduledDelegate selectionChangedDebounce;
|
||||
|
||||
// We need to keep track of the last selected beatmap ignoring debounce to play the correct selection sounds.
|
||||
private BeatmapInfo selectionChangeNoBounce;
|
||||
|
||||
/// <summary>
|
||||
/// selection has been changed as the result of interaction with the carousel.
|
||||
/// </summary>
|
||||
private void selectionChanged(BeatmapInfo beatmap)
|
||||
{
|
||||
selectionChangedDebounce?.Cancel();
|
||||
|
||||
if (beatmap.Equals(Beatmap?.BeatmapInfo))
|
||||
return;
|
||||
|
||||
bool preview = beatmap.BeatmapSetInfoID != Beatmap?.BeatmapInfo.BeatmapSetInfoID;
|
||||
|
||||
if (beatmap.BeatmapSetInfoID == selectionChangeNoBounce?.BeatmapSetInfoID)
|
||||
sampleChangeDifficulty.Play();
|
||||
else
|
||||
sampleChangeBeatmap.Play();
|
||||
|
||||
selectionChangeNoBounce = beatmap;
|
||||
|
||||
selectionChangedDebounce = Scheduler.AddDelayed(delegate
|
||||
{
|
||||
Beatmap = database.GetWorkingBeatmap(beatmap, Beatmap);
|
||||
ensurePlayingSelected(preview);
|
||||
}, 100);
|
||||
}
|
||||
|
||||
private void ensurePlayingSelected(bool preview = false)
|
||||
{
|
||||
Track track = Beatmap?.Track;
|
||||
Track track = Beatmap.Value.Track;
|
||||
|
||||
if (track != null)
|
||||
if (!track.IsRunning)
|
||||
{
|
||||
trackManager.SetExclusive(track);
|
||||
if (preview)
|
||||
track.Seek(Beatmap.Metadata.PreviewTime);
|
||||
if (preview) track.Seek(Beatmap.Value.Metadata.PreviewTime);
|
||||
track.Start();
|
||||
}
|
||||
}
|
||||
@ -363,7 +367,7 @@ namespace osu.Game.Screens.Select
|
||||
{
|
||||
carousel.RemoveBeatmap(beatmapSet);
|
||||
if (carousel.SelectedBeatmap == null)
|
||||
Beatmap = null;
|
||||
Beatmap.SetDefault();
|
||||
}
|
||||
|
||||
private void promptDelete()
|
||||
@ -380,7 +384,7 @@ namespace osu.Game.Screens.Select
|
||||
{
|
||||
case Key.KeypadEnter:
|
||||
case Key.Enter:
|
||||
raiseSelect();
|
||||
carouselRaisedStart();
|
||||
return true;
|
||||
case Key.Delete:
|
||||
if (state.Keyboard.ShiftPressed)
|
||||
|
@ -76,6 +76,7 @@
|
||||
<Compile Include="Audio\SampleInfoList.cs" />
|
||||
<Compile Include="Beatmaps\Drawables\BeatmapBackgroundSprite.cs" />
|
||||
<Compile Include="Beatmaps\DifficultyCalculator.cs" />
|
||||
<Compile Include="Beatmaps\DummyWorkingBeatmap.cs" />
|
||||
<Compile Include="Graphics\Containers\OsuClickableContainer.cs" />
|
||||
<Compile Include="Graphics\Containers\OsuFocusedOverlayContainer.cs" />
|
||||
<Compile Include="Graphics\Containers\OsuScrollContainer.cs" />
|
||||
@ -230,7 +231,6 @@
|
||||
<Compile Include="Online\API\Requests\GetScoresRequest.cs" />
|
||||
<Compile Include="Online\API\Requests\GetBeatmapDetailsRequest.cs" />
|
||||
<Compile Include="Online\API\Requests\GetUserRequest.cs" />
|
||||
<Compile Include="Overlays\DragBar.cs" />
|
||||
<Compile Include="Overlays\LoginOverlay.cs" />
|
||||
<Compile Include="Overlays\MusicController.cs" />
|
||||
<Compile Include="Beatmaps\Beatmap.cs" />
|
||||
|
Loading…
Reference in New Issue
Block a user