mirror of
https://github.com/osukey/osukey.git
synced 2025-08-04 15:16:38 +09:00
Merge branch 'master' into beatmap-serialization
This commit is contained in:
@ -8,7 +8,6 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using osu.Game.Beatmaps.ControlPoints;
|
||||
using osu.Game.IO.Serialization;
|
||||
using osu.Game.Storyboards;
|
||||
using Newtonsoft.Json;
|
||||
using osu.Game.IO.Serialization.Converters;
|
||||
|
||||
@ -46,11 +45,6 @@ namespace osu.Game.Beatmaps
|
||||
[JsonIgnore]
|
||||
public double TotalBreakTime => Breaks.Sum(b => b.Duration);
|
||||
|
||||
/// <summary>
|
||||
/// The Beatmap's Storyboard.
|
||||
/// </summary>
|
||||
public Storyboard Storyboard = new Storyboard();
|
||||
|
||||
/// <summary>
|
||||
/// Constructs a new beatmap.
|
||||
/// </summary>
|
||||
@ -62,7 +56,6 @@ namespace osu.Game.Beatmaps
|
||||
Breaks = original?.Breaks ?? Breaks;
|
||||
ComboColors = original?.ComboColors ?? ComboColors;
|
||||
HitObjects = original?.HitObjects ?? HitObjects;
|
||||
Storyboard = original?.Storyboard ?? Storyboard;
|
||||
|
||||
if (original == null && Metadata == null)
|
||||
{
|
||||
|
@ -121,9 +121,12 @@ namespace osu.Game.Beatmaps
|
||||
// Metadata
|
||||
public string Version { get; set; }
|
||||
|
||||
[JsonProperty("difficulty_rating")]
|
||||
public double StarDifficulty { get; set; }
|
||||
public bool ShouldSerializeStarDifficulty() => false;
|
||||
|
||||
public override string ToString() => $"{Metadata} [{Version}]";
|
||||
|
||||
public bool Equals(BeatmapInfo other)
|
||||
{
|
||||
if (ID == 0 || other?.ID == 0)
|
||||
|
@ -26,6 +26,7 @@ using osu.Game.Online.API;
|
||||
using osu.Game.Online.API.Requests;
|
||||
using osu.Game.Overlays.Notifications;
|
||||
using osu.Game.Rulesets;
|
||||
using osu.Game.Storyboards;
|
||||
|
||||
namespace osu.Game.Beatmaps
|
||||
{
|
||||
@ -134,6 +135,7 @@ namespace osu.Game.Beatmaps
|
||||
var notification = new ProgressNotification
|
||||
{
|
||||
Text = "Beatmap import is initialising...",
|
||||
CompletionText = "Import successful!",
|
||||
Progress = 0,
|
||||
State = ProgressNotificationState.Active,
|
||||
};
|
||||
@ -245,8 +247,9 @@ namespace osu.Game.Beatmaps
|
||||
return;
|
||||
}
|
||||
|
||||
ProgressNotification downloadNotification = new ProgressNotification
|
||||
var downloadNotification = new ProgressNotification
|
||||
{
|
||||
CompletionText = $"Imported {beatmapSetInfo.Metadata.Artist} - {beatmapSetInfo.Metadata.Title}!",
|
||||
Text = $"Downloading {beatmapSetInfo.Metadata.Artist} - {beatmapSetInfo.Metadata.Title}",
|
||||
};
|
||||
|
||||
@ -374,12 +377,9 @@ namespace osu.Game.Beatmaps
|
||||
/// <returns>A <see cref="WorkingBeatmap"/> instance correlating to the provided <see cref="BeatmapInfo"/>.</returns>
|
||||
public WorkingBeatmap GetWorkingBeatmap(BeatmapInfo beatmapInfo, WorkingBeatmap previous = null)
|
||||
{
|
||||
if (beatmapInfo == null || beatmapInfo == DefaultBeatmap?.BeatmapInfo)
|
||||
if (beatmapInfo?.BeatmapSet == null || beatmapInfo == DefaultBeatmap?.BeatmapInfo)
|
||||
return DefaultBeatmap;
|
||||
|
||||
if (beatmapInfo.BeatmapSet == null)
|
||||
throw new InvalidOperationException($@"Beatmap set {beatmapInfo.BeatmapSetInfoID} is not in the local database.");
|
||||
|
||||
if (beatmapInfo.Metadata == null)
|
||||
beatmapInfo.Metadata = beatmapInfo.BeatmapSet.Metadata;
|
||||
|
||||
@ -495,17 +495,23 @@ namespace osu.Game.Beatmaps
|
||||
BeatmapMetadata metadata;
|
||||
|
||||
using (var stream = new StreamReader(reader.GetStream(mapName)))
|
||||
metadata = BeatmapDecoder.GetDecoder(stream).Decode(stream).Metadata;
|
||||
metadata = Decoder.GetDecoder(stream).DecodeBeatmap(stream).Metadata;
|
||||
|
||||
|
||||
// check if a set already exists with the same online id.
|
||||
beatmapSet = beatmaps.BeatmapSets.FirstOrDefault(b => b.OnlineBeatmapSetID == metadata.OnlineBeatmapSetID) ?? new BeatmapSetInfo
|
||||
{
|
||||
OnlineBeatmapSetID = metadata.OnlineBeatmapSetID,
|
||||
Beatmaps = new List<BeatmapInfo>(),
|
||||
Hash = hash,
|
||||
Files = fileInfos,
|
||||
Metadata = metadata
|
||||
};
|
||||
if (metadata.OnlineBeatmapSetID != null)
|
||||
beatmapSet = beatmaps.BeatmapSets.FirstOrDefault(b => b.OnlineBeatmapSetID == metadata.OnlineBeatmapSetID);
|
||||
|
||||
if (beatmapSet == null)
|
||||
beatmapSet = new BeatmapSetInfo
|
||||
{
|
||||
OnlineBeatmapSetID = metadata.OnlineBeatmapSetID,
|
||||
Beatmaps = new List<BeatmapInfo>(),
|
||||
Hash = hash,
|
||||
Files = fileInfos,
|
||||
Metadata = metadata
|
||||
};
|
||||
|
||||
|
||||
var mapNames = reader.Filenames.Where(f => f.EndsWith(".osu"));
|
||||
|
||||
@ -518,19 +524,20 @@ namespace osu.Game.Beatmaps
|
||||
raw.CopyTo(ms);
|
||||
ms.Position = 0;
|
||||
|
||||
var decoder = BeatmapDecoder.GetDecoder(sr);
|
||||
Beatmap beatmap = decoder.Decode(sr);
|
||||
var decoder = Decoder.GetDecoder(sr);
|
||||
Beatmap beatmap = decoder.DecodeBeatmap(sr);
|
||||
|
||||
beatmap.BeatmapInfo.Path = name;
|
||||
beatmap.BeatmapInfo.Hash = ms.ComputeSHA2Hash();
|
||||
beatmap.BeatmapInfo.MD5Hash = ms.ComputeMD5Hash();
|
||||
|
||||
var existing = beatmaps.Beatmaps.FirstOrDefault(b => b.Hash == beatmap.BeatmapInfo.Hash || b.OnlineBeatmapID == beatmap.BeatmapInfo.OnlineBeatmapID);
|
||||
var existing = beatmaps.Beatmaps.FirstOrDefault(b => b.Hash == beatmap.BeatmapInfo.Hash || beatmap.BeatmapInfo.OnlineBeatmapID != null && b.OnlineBeatmapID == beatmap.BeatmapInfo.OnlineBeatmapID);
|
||||
|
||||
if (existing == null)
|
||||
{
|
||||
// TODO: Diff beatmap metadata with set metadata and leave it here if necessary
|
||||
beatmap.BeatmapInfo.Metadata = null;
|
||||
// Exclude beatmap-metadata if it's equal to beatmapset-metadata
|
||||
if (metadata.Equals(beatmap.Metadata))
|
||||
beatmap.BeatmapInfo.Metadata = null;
|
||||
|
||||
RulesetInfo ruleset = rulesets.GetRuleset(beatmap.BeatmapInfo.RulesetID);
|
||||
|
||||
@ -639,23 +646,11 @@ namespace osu.Game.Beatmaps
|
||||
{
|
||||
try
|
||||
{
|
||||
Beatmap beatmap;
|
||||
|
||||
BeatmapDecoder decoder;
|
||||
using (var stream = new StreamReader(store.GetStream(getPathForFile(BeatmapInfo.Path))))
|
||||
{
|
||||
decoder = BeatmapDecoder.GetDecoder(stream);
|
||||
beatmap = decoder.Decode(stream);
|
||||
Decoder decoder = Decoder.GetDecoder(stream);
|
||||
return decoder.DecodeBeatmap(stream);
|
||||
}
|
||||
|
||||
if (beatmap == null || BeatmapSetInfo.StoryboardFile == null)
|
||||
return beatmap;
|
||||
|
||||
using (var stream = new StreamReader(store.GetStream(getPathForFile(BeatmapSetInfo.StoryboardFile))))
|
||||
decoder.Decode(stream, beatmap);
|
||||
|
||||
|
||||
return beatmap;
|
||||
}
|
||||
catch
|
||||
{
|
||||
@ -694,6 +689,28 @@ namespace osu.Game.Beatmaps
|
||||
}
|
||||
|
||||
protected override Waveform GetWaveform() => new Waveform(store.GetStream(getPathForFile(Metadata.AudioFile)));
|
||||
|
||||
protected override Storyboard GetStoryboard()
|
||||
{
|
||||
if (BeatmapInfo?.Path == null && BeatmapSetInfo?.StoryboardFile == null)
|
||||
return new Storyboard();
|
||||
|
||||
try
|
||||
{
|
||||
Decoder decoder;
|
||||
using (var stream = new StreamReader(store.GetStream(getPathForFile(BeatmapInfo?.Path))))
|
||||
decoder = Decoder.GetDecoder(stream);
|
||||
|
||||
// try for .osb first and fall back to .osu
|
||||
string storyboardFile = BeatmapSetInfo.StoryboardFile ?? BeatmapInfo.Path;
|
||||
using (var stream = new StreamReader(store.GetStream(getPathForFile(storyboardFile))))
|
||||
return decoder.GetStoryboardDecoder().DecodeStoryboard(stream);
|
||||
}
|
||||
catch
|
||||
{
|
||||
return new Storyboard();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -721,6 +738,7 @@ namespace osu.Game.Beatmaps
|
||||
var notification = new ProgressNotification
|
||||
{
|
||||
Progress = 0,
|
||||
CompletionText = "Deleted all beatmaps!",
|
||||
State = ProgressNotificationState.Active,
|
||||
};
|
||||
|
||||
|
@ -11,7 +11,7 @@ using osu.Game.Users;
|
||||
namespace osu.Game.Beatmaps
|
||||
{
|
||||
[Serializable]
|
||||
public class BeatmapMetadata
|
||||
public class BeatmapMetadata : IEquatable<BeatmapMetadata>
|
||||
{
|
||||
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||
[JsonIgnore]
|
||||
@ -63,6 +63,8 @@ namespace osu.Game.Beatmaps
|
||||
public string AudioFile { get; set; }
|
||||
public string BackgroundFile { get; set; }
|
||||
|
||||
public override string ToString() => $"{Artist} - {Title} ({Author})";
|
||||
|
||||
[JsonIgnore]
|
||||
public string[] SearchableTerms => new[]
|
||||
{
|
||||
@ -74,5 +76,23 @@ namespace osu.Game.Beatmaps
|
||||
Source,
|
||||
Tags
|
||||
}.Where(s => !string.IsNullOrEmpty(s)).ToArray();
|
||||
|
||||
public bool Equals(BeatmapMetadata other)
|
||||
{
|
||||
if (other == null)
|
||||
return false;
|
||||
|
||||
return onlineBeatmapSetID == other.onlineBeatmapSetID
|
||||
&& Title == other.Title
|
||||
&& TitleUnicode == other.TitleUnicode
|
||||
&& Artist == other.Artist
|
||||
&& ArtistUnicode == other.ArtistUnicode
|
||||
&& AuthorString == other.AuthorString
|
||||
&& Source == other.Source
|
||||
&& Tags == other.Tags
|
||||
&& PreviewTime == other.PreviewTime
|
||||
&& AudioFile == other.AudioFile
|
||||
&& BackgroundFile == other.BackgroundFile;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -33,6 +33,8 @@ namespace osu.Game.Beatmaps
|
||||
|
||||
public List<BeatmapSetFileInfo> Files { get; set; }
|
||||
|
||||
public override string ToString() => Metadata.ToString();
|
||||
|
||||
public bool Protected { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -32,6 +32,18 @@ namespace osu.Game.Beatmaps
|
||||
{
|
||||
var context = GetContext();
|
||||
|
||||
foreach (var beatmap in beatmapSet.Beatmaps.Where(b => b.Metadata != null))
|
||||
{
|
||||
// If we detect a new metadata object it'll be attached to the current context so it can be reused
|
||||
// to prevent duplicate entries when persisting. To accomplish this we look in the cache (.Local)
|
||||
// of the corresponding table (.Set<BeatmapMetadata>()) for matching entries to our criteria.
|
||||
var contextMetadata = context.Set<BeatmapMetadata>().Local.SingleOrDefault(e => e.Equals(beatmap.Metadata));
|
||||
if (contextMetadata != null)
|
||||
beatmap.Metadata = contextMetadata;
|
||||
else
|
||||
context.BeatmapMetadata.Attach(beatmap.Metadata);
|
||||
}
|
||||
|
||||
context.BeatmapSetInfo.Attach(beatmapSet);
|
||||
context.SaveChanges();
|
||||
|
||||
|
@ -1,138 +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 System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using osu.Framework;
|
||||
using osu.Framework.Graphics;
|
||||
|
||||
namespace osu.Game.Beatmaps.Drawables
|
||||
{
|
||||
public class BeatmapGroup : IStateful<BeatmapGroupState>
|
||||
{
|
||||
public event Action<BeatmapGroupState> StateChanged;
|
||||
|
||||
public BeatmapPanel SelectedPanel;
|
||||
|
||||
/// <summary>
|
||||
/// Fires when one of our difficulties was selected. Will fire on first expand.
|
||||
/// </summary>
|
||||
public Action<BeatmapGroup, BeatmapPanel> SelectionChanged;
|
||||
|
||||
/// <summary>
|
||||
/// Fires when one of our difficulties is clicked when already selected. Should start playing the map.
|
||||
/// </summary>
|
||||
public Action<BeatmapInfo> StartRequested;
|
||||
|
||||
public Action<BeatmapSetInfo> DeleteRequested;
|
||||
|
||||
public Action<BeatmapSetInfo> RestoreHiddenRequested;
|
||||
|
||||
public Action<BeatmapInfo> HideDifficultyRequested;
|
||||
|
||||
public Action<BeatmapInfo> EditRequested;
|
||||
|
||||
public BeatmapSetHeader Header;
|
||||
|
||||
public List<BeatmapPanel> BeatmapPanels;
|
||||
|
||||
public BeatmapSetInfo BeatmapSet;
|
||||
|
||||
private BeatmapGroupState state;
|
||||
public BeatmapGroupState State
|
||||
{
|
||||
get { return state; }
|
||||
set
|
||||
{
|
||||
state = value;
|
||||
|
||||
switch (value)
|
||||
{
|
||||
case BeatmapGroupState.Expanded:
|
||||
Header.State = PanelSelectedState.Selected;
|
||||
foreach (BeatmapPanel panel in BeatmapPanels)
|
||||
panel.State = panel == SelectedPanel ? PanelSelectedState.Selected : PanelSelectedState.NotSelected;
|
||||
break;
|
||||
case BeatmapGroupState.Collapsed:
|
||||
Header.State = PanelSelectedState.NotSelected;
|
||||
foreach (BeatmapPanel panel in BeatmapPanels)
|
||||
panel.State = PanelSelectedState.Hidden;
|
||||
break;
|
||||
case BeatmapGroupState.Hidden:
|
||||
Header.State = PanelSelectedState.Hidden;
|
||||
foreach (BeatmapPanel panel in BeatmapPanels)
|
||||
panel.State = PanelSelectedState.Hidden;
|
||||
break;
|
||||
}
|
||||
|
||||
StateChanged?.Invoke(state);
|
||||
}
|
||||
}
|
||||
|
||||
public BeatmapGroup(BeatmapSetInfo beatmapSet, BeatmapManager manager)
|
||||
{
|
||||
if (beatmapSet == null)
|
||||
throw new ArgumentNullException(nameof(beatmapSet));
|
||||
if (manager == null)
|
||||
throw new ArgumentNullException(nameof(manager));
|
||||
|
||||
BeatmapSet = beatmapSet;
|
||||
WorkingBeatmap beatmap = manager.GetWorkingBeatmap(BeatmapSet.Beatmaps.FirstOrDefault());
|
||||
|
||||
Header = new BeatmapSetHeader(beatmap)
|
||||
{
|
||||
GainedSelection = headerGainedSelection,
|
||||
DeleteRequested = b => DeleteRequested(b),
|
||||
RestoreHiddenRequested = b => RestoreHiddenRequested(b),
|
||||
RelativeSizeAxes = Axes.X,
|
||||
};
|
||||
|
||||
BeatmapPanels = BeatmapSet.Beatmaps.Where(b => !b.Hidden).OrderBy(b => b.StarDifficulty).Select(b => new BeatmapPanel(b)
|
||||
{
|
||||
Alpha = 0,
|
||||
GainedSelection = panelGainedSelection,
|
||||
HideRequested = p => HideDifficultyRequested?.Invoke(p),
|
||||
StartRequested = p => StartRequested?.Invoke(p.Beatmap),
|
||||
EditRequested = p => EditRequested?.Invoke(p.Beatmap),
|
||||
RelativeSizeAxes = Axes.X,
|
||||
}).ToList();
|
||||
|
||||
Header.AddDifficultyIcons(BeatmapPanels);
|
||||
}
|
||||
|
||||
|
||||
private void headerGainedSelection(BeatmapSetHeader panel)
|
||||
{
|
||||
State = BeatmapGroupState.Expanded;
|
||||
|
||||
//we want to make sure one of our children is selected in the case none have been selected yet.
|
||||
if (SelectedPanel == null)
|
||||
BeatmapPanels.First().State = PanelSelectedState.Selected;
|
||||
}
|
||||
|
||||
private void panelGainedSelection(BeatmapPanel panel)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (SelectedPanel == panel) return;
|
||||
|
||||
if (SelectedPanel != null)
|
||||
SelectedPanel.State = PanelSelectedState.NotSelected;
|
||||
SelectedPanel = panel;
|
||||
}
|
||||
finally
|
||||
{
|
||||
State = BeatmapGroupState.Expanded;
|
||||
SelectionChanged?.Invoke(this, SelectedPanel);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public enum BeatmapGroupState
|
||||
{
|
||||
Collapsed,
|
||||
Expanded,
|
||||
Hidden,
|
||||
}
|
||||
}
|
@ -11,21 +11,44 @@ namespace osu.Game.Beatmaps.Drawables
|
||||
public class BeatmapSetCover : Sprite
|
||||
{
|
||||
private readonly BeatmapSetInfo set;
|
||||
public BeatmapSetCover(BeatmapSetInfo set)
|
||||
private readonly BeatmapSetCoverType type;
|
||||
|
||||
public BeatmapSetCover(BeatmapSetInfo set, BeatmapSetCoverType type = BeatmapSetCoverType.Cover)
|
||||
{
|
||||
if (set == null)
|
||||
throw new ArgumentNullException(nameof(set));
|
||||
|
||||
this.set = set;
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(TextureStore textures)
|
||||
{
|
||||
string resource = set.OnlineInfo.Covers.Cover;
|
||||
string resource = null;
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case BeatmapSetCoverType.Cover:
|
||||
resource = set.OnlineInfo.Covers.Cover;
|
||||
break;
|
||||
case BeatmapSetCoverType.Card:
|
||||
resource = set.OnlineInfo.Covers.Card;
|
||||
break;
|
||||
case BeatmapSetCoverType.List:
|
||||
resource = set.OnlineInfo.Covers.List;
|
||||
break;
|
||||
}
|
||||
|
||||
if (resource != null)
|
||||
Texture = textures.Get(resource);
|
||||
}
|
||||
}
|
||||
|
||||
public enum BeatmapSetCoverType
|
||||
{
|
||||
Cover,
|
||||
Card,
|
||||
List,
|
||||
}
|
||||
}
|
||||
|
@ -63,6 +63,8 @@ namespace osu.Game.Beatmaps
|
||||
|
||||
public override string Description => "dummy";
|
||||
|
||||
public override string ShortName => "dummy";
|
||||
|
||||
public DummyRuleset(RulesetInfo rulesetInfo)
|
||||
: base(rulesetInfo)
|
||||
{
|
||||
|
@ -1,75 +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 System.Collections.Generic;
|
||||
using System.IO;
|
||||
|
||||
namespace osu.Game.Beatmaps.Formats
|
||||
{
|
||||
public abstract class BeatmapDecoder
|
||||
{
|
||||
private static readonly Dictionary<string, Type> decoders = new Dictionary<string, Type>();
|
||||
|
||||
static BeatmapDecoder()
|
||||
{
|
||||
OsuLegacyDecoder.Register();
|
||||
OsuJsonDecoder.Register();
|
||||
}
|
||||
|
||||
public static BeatmapDecoder GetDecoder(StreamReader stream)
|
||||
{
|
||||
if (stream == null)
|
||||
throw new ArgumentNullException(nameof(stream));
|
||||
|
||||
string line;
|
||||
do { line = stream.ReadLine()?.Trim(); }
|
||||
while (line != null && line.Length == 0);
|
||||
|
||||
if (line == null || !decoders.ContainsKey(line))
|
||||
throw new IOException(@"Unknown file format");
|
||||
|
||||
try
|
||||
{
|
||||
return (BeatmapDecoder)Activator.CreateInstance(decoders[line], line);
|
||||
}
|
||||
catch
|
||||
{
|
||||
// As a default case, try a parameterless constructor
|
||||
return (BeatmapDecoder)Activator.CreateInstance(decoders[line]);
|
||||
}
|
||||
}
|
||||
|
||||
protected static void AddDecoder<T>(string magic) where T : BeatmapDecoder
|
||||
{
|
||||
decoders[magic] = typeof(T);
|
||||
}
|
||||
|
||||
public virtual Beatmap Decode(StreamReader stream)
|
||||
{
|
||||
return ParseFile(stream);
|
||||
}
|
||||
|
||||
public virtual void Decode(StreamReader stream, Beatmap beatmap)
|
||||
{
|
||||
ParseFile(stream, beatmap);
|
||||
}
|
||||
|
||||
protected virtual Beatmap ParseFile(StreamReader stream)
|
||||
{
|
||||
var beatmap = new Beatmap
|
||||
{
|
||||
BeatmapInfo = new BeatmapInfo
|
||||
{
|
||||
Metadata = new BeatmapMetadata(),
|
||||
BaseDifficulty = new BeatmapDifficulty(),
|
||||
},
|
||||
};
|
||||
|
||||
ParseFile(stream, beatmap);
|
||||
return beatmap;
|
||||
}
|
||||
|
||||
protected abstract void ParseFile(StreamReader stream, Beatmap beatmap);
|
||||
}
|
||||
}
|
80
osu.Game/Beatmaps/Formats/Decoder.cs
Normal file
80
osu.Game/Beatmaps/Formats/Decoder.cs
Normal file
@ -0,0 +1,80 @@
|
||||
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using osu.Game.Storyboards;
|
||||
|
||||
namespace osu.Game.Beatmaps.Formats
|
||||
{
|
||||
public abstract class Decoder
|
||||
{
|
||||
private static readonly Dictionary<string, Type> decoders = new Dictionary<string, Type>();
|
||||
|
||||
static Decoder()
|
||||
{
|
||||
LegacyDecoder.Register();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves a <see cref="Decoder"/> to parse a <see cref="Beatmap"/>.
|
||||
/// </summary>
|
||||
/// <param name="stream">A stream pointing to the <see cref="Beatmap"/>.</param>
|
||||
public static Decoder GetDecoder(StreamReader stream)
|
||||
{
|
||||
if (stream == null)
|
||||
throw new ArgumentNullException(nameof(stream));
|
||||
|
||||
string line;
|
||||
do
|
||||
{ line = stream.ReadLine()?.Trim(); }
|
||||
while (line != null && line.Length == 0);
|
||||
|
||||
if (line == null || !decoders.ContainsKey(line))
|
||||
throw new IOException(@"Unknown file format");
|
||||
return (Decoder)Activator.CreateInstance(decoders[line], line);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds the <see cref="Decoder"/> to the list of <see cref="Beatmap"/> and <see cref="Storyboard"/> decoder.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">Type to decode a <see cref="Beatmap"/> with.</typeparam>
|
||||
/// <param name="version">A string representation of the version.</param>
|
||||
protected static void AddDecoder<T>(string version) where T : Decoder
|
||||
{
|
||||
decoders[version] = typeof(T);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves a <see cref="Decoder"/> to parse a <see cref="Storyboard"/>
|
||||
/// </summary>
|
||||
public abstract Decoder GetStoryboardDecoder();
|
||||
|
||||
public virtual Beatmap DecodeBeatmap(StreamReader stream)
|
||||
{
|
||||
var beatmap = new Beatmap
|
||||
{
|
||||
BeatmapInfo = new BeatmapInfo
|
||||
{
|
||||
Metadata = new BeatmapMetadata(),
|
||||
BaseDifficulty = new BeatmapDifficulty(),
|
||||
},
|
||||
};
|
||||
|
||||
ParseBeatmap(stream, beatmap);
|
||||
return beatmap;
|
||||
}
|
||||
|
||||
protected abstract void ParseBeatmap(StreamReader stream, Beatmap beatmap);
|
||||
|
||||
public virtual Storyboard DecodeStoryboard(StreamReader stream)
|
||||
{
|
||||
var storyboard = new Storyboard();
|
||||
ParseStoryboard(stream, storyboard);
|
||||
return storyboard;
|
||||
}
|
||||
|
||||
protected abstract void ParseStoryboard(StreamReader stream, Storyboard storyboard);
|
||||
}
|
||||
}
|
421
osu.Game/Beatmaps/Formats/LegacyBeatmapDecoder.cs
Normal file
421
osu.Game/Beatmaps/Formats/LegacyBeatmapDecoder.cs
Normal file
@ -0,0 +1,421 @@
|
||||
// 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.Globalization;
|
||||
using System.IO;
|
||||
using OpenTK.Graphics;
|
||||
using osu.Game.Beatmaps.Timing;
|
||||
using osu.Game.Rulesets.Objects.Legacy;
|
||||
using osu.Game.Beatmaps.ControlPoints;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace osu.Game.Beatmaps.Formats
|
||||
{
|
||||
public class LegacyBeatmapDecoder : LegacyDecoder
|
||||
{
|
||||
private Beatmap beatmap;
|
||||
|
||||
private bool hasCustomColours;
|
||||
private ConvertHitObjectParser parser;
|
||||
|
||||
private LegacySampleBank defaultSampleBank;
|
||||
private int defaultSampleVolume = 100;
|
||||
|
||||
public LegacyBeatmapDecoder()
|
||||
{
|
||||
}
|
||||
|
||||
public LegacyBeatmapDecoder(string header)
|
||||
{
|
||||
BeatmapVersion = int.Parse(header.Substring(17));
|
||||
}
|
||||
|
||||
protected override void ParseBeatmap(StreamReader stream, Beatmap beatmap)
|
||||
{
|
||||
if (stream == null)
|
||||
throw new ArgumentNullException(nameof(stream));
|
||||
if (beatmap == null)
|
||||
throw new ArgumentNullException(nameof(beatmap));
|
||||
|
||||
this.beatmap = beatmap;
|
||||
this.beatmap.BeatmapInfo.BeatmapVersion = BeatmapVersion;
|
||||
|
||||
ParseContent(stream);
|
||||
|
||||
foreach (var hitObject in this.beatmap.HitObjects)
|
||||
hitObject.ApplyDefaults(this.beatmap.ControlPointInfo, this.beatmap.BeatmapInfo.BaseDifficulty);
|
||||
}
|
||||
|
||||
protected override bool ShouldSkipLine(string line)
|
||||
{
|
||||
if (base.ShouldSkipLine(line) || line.StartsWith(" ") || line.StartsWith("_"))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
protected override void ProcessSection(Section section, string line)
|
||||
{
|
||||
switch (section)
|
||||
{
|
||||
case Section.General:
|
||||
handleGeneral(line);
|
||||
break;
|
||||
case Section.Editor:
|
||||
handleEditor(line);
|
||||
break;
|
||||
case Section.Metadata:
|
||||
handleMetadata(line);
|
||||
break;
|
||||
case Section.Difficulty:
|
||||
handleDifficulty(line);
|
||||
break;
|
||||
case Section.Events:
|
||||
handleEvents(line);
|
||||
break;
|
||||
case Section.TimingPoints:
|
||||
handleTimingPoints(line);
|
||||
break;
|
||||
case Section.Colours:
|
||||
handleColours(line);
|
||||
break;
|
||||
case Section.HitObjects:
|
||||
handleHitObjects(line);
|
||||
break;
|
||||
case Section.Variables:
|
||||
handleVariables(line);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void handleGeneral(string line)
|
||||
{
|
||||
var pair = splitKeyVal(line, ':');
|
||||
|
||||
var metadata = beatmap.BeatmapInfo.Metadata;
|
||||
switch (pair.Key)
|
||||
{
|
||||
case @"AudioFilename":
|
||||
metadata.AudioFile = pair.Value;
|
||||
break;
|
||||
case @"AudioLeadIn":
|
||||
beatmap.BeatmapInfo.AudioLeadIn = int.Parse(pair.Value);
|
||||
break;
|
||||
case @"PreviewTime":
|
||||
metadata.PreviewTime = int.Parse(pair.Value);
|
||||
break;
|
||||
case @"Countdown":
|
||||
beatmap.BeatmapInfo.Countdown = int.Parse(pair.Value) == 1;
|
||||
break;
|
||||
case @"SampleSet":
|
||||
defaultSampleBank = (LegacySampleBank)Enum.Parse(typeof(LegacySampleBank), pair.Value);
|
||||
break;
|
||||
case @"SampleVolume":
|
||||
defaultSampleVolume = int.Parse(pair.Value);
|
||||
break;
|
||||
case @"StackLeniency":
|
||||
beatmap.BeatmapInfo.StackLeniency = float.Parse(pair.Value, NumberFormatInfo.InvariantInfo);
|
||||
break;
|
||||
case @"Mode":
|
||||
beatmap.BeatmapInfo.RulesetID = int.Parse(pair.Value);
|
||||
|
||||
switch (beatmap.BeatmapInfo.RulesetID)
|
||||
{
|
||||
case 0:
|
||||
parser = new Rulesets.Objects.Legacy.Osu.ConvertHitObjectParser();
|
||||
break;
|
||||
case 1:
|
||||
parser = new Rulesets.Objects.Legacy.Taiko.ConvertHitObjectParser();
|
||||
break;
|
||||
case 2:
|
||||
parser = new Rulesets.Objects.Legacy.Catch.ConvertHitObjectParser();
|
||||
break;
|
||||
case 3:
|
||||
parser = new Rulesets.Objects.Legacy.Mania.ConvertHitObjectParser();
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case @"LetterboxInBreaks":
|
||||
beatmap.BeatmapInfo.LetterboxInBreaks = int.Parse(pair.Value) == 1;
|
||||
break;
|
||||
case @"SpecialStyle":
|
||||
beatmap.BeatmapInfo.SpecialStyle = int.Parse(pair.Value) == 1;
|
||||
break;
|
||||
case @"WidescreenStoryboard":
|
||||
beatmap.BeatmapInfo.WidescreenStoryboard = int.Parse(pair.Value) == 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void handleEditor(string line)
|
||||
{
|
||||
var pair = splitKeyVal(line, ':');
|
||||
|
||||
switch (pair.Key)
|
||||
{
|
||||
case @"Bookmarks":
|
||||
beatmap.BeatmapInfo.StoredBookmarks = pair.Value;
|
||||
break;
|
||||
case @"DistanceSpacing":
|
||||
beatmap.BeatmapInfo.DistanceSpacing = double.Parse(pair.Value, NumberFormatInfo.InvariantInfo);
|
||||
break;
|
||||
case @"BeatDivisor":
|
||||
beatmap.BeatmapInfo.BeatDivisor = int.Parse(pair.Value);
|
||||
break;
|
||||
case @"GridSize":
|
||||
beatmap.BeatmapInfo.GridSize = int.Parse(pair.Value);
|
||||
break;
|
||||
case @"TimelineZoom":
|
||||
beatmap.BeatmapInfo.TimelineZoom = double.Parse(pair.Value, NumberFormatInfo.InvariantInfo);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void handleMetadata(string line)
|
||||
{
|
||||
var pair = splitKeyVal(line, ':');
|
||||
|
||||
var metadata = beatmap.BeatmapInfo.Metadata;
|
||||
switch (pair.Key)
|
||||
{
|
||||
case @"Title":
|
||||
metadata.Title = pair.Value;
|
||||
break;
|
||||
case @"TitleUnicode":
|
||||
metadata.TitleUnicode = pair.Value;
|
||||
break;
|
||||
case @"Artist":
|
||||
metadata.Artist = pair.Value;
|
||||
break;
|
||||
case @"ArtistUnicode":
|
||||
metadata.ArtistUnicode = pair.Value;
|
||||
break;
|
||||
case @"Creator":
|
||||
metadata.AuthorString = pair.Value;
|
||||
break;
|
||||
case @"Version":
|
||||
beatmap.BeatmapInfo.Version = pair.Value;
|
||||
break;
|
||||
case @"Source":
|
||||
beatmap.BeatmapInfo.Metadata.Source = pair.Value;
|
||||
break;
|
||||
case @"Tags":
|
||||
beatmap.BeatmapInfo.Metadata.Tags = pair.Value;
|
||||
break;
|
||||
case @"BeatmapID":
|
||||
beatmap.BeatmapInfo.OnlineBeatmapID = int.Parse(pair.Value);
|
||||
break;
|
||||
case @"BeatmapSetID":
|
||||
beatmap.BeatmapInfo.OnlineBeatmapSetID = int.Parse(pair.Value);
|
||||
metadata.OnlineBeatmapSetID = int.Parse(pair.Value);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void handleDifficulty(string line)
|
||||
{
|
||||
var pair = splitKeyVal(line, ':');
|
||||
|
||||
var difficulty = beatmap.BeatmapInfo.BaseDifficulty;
|
||||
switch (pair.Key)
|
||||
{
|
||||
case @"HPDrainRate":
|
||||
difficulty.DrainRate = float.Parse(pair.Value, NumberFormatInfo.InvariantInfo);
|
||||
break;
|
||||
case @"CircleSize":
|
||||
difficulty.CircleSize = float.Parse(pair.Value, NumberFormatInfo.InvariantInfo);
|
||||
break;
|
||||
case @"OverallDifficulty":
|
||||
difficulty.OverallDifficulty = float.Parse(pair.Value, NumberFormatInfo.InvariantInfo);
|
||||
break;
|
||||
case @"ApproachRate":
|
||||
difficulty.ApproachRate = float.Parse(pair.Value, NumberFormatInfo.InvariantInfo);
|
||||
break;
|
||||
case @"SliderMultiplier":
|
||||
difficulty.SliderMultiplier = float.Parse(pair.Value, NumberFormatInfo.InvariantInfo);
|
||||
break;
|
||||
case @"SliderTickRate":
|
||||
difficulty.SliderTickRate = float.Parse(pair.Value, NumberFormatInfo.InvariantInfo);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void handleEvents(string line)
|
||||
{
|
||||
DecodeVariables(ref line);
|
||||
|
||||
string[] split = line.Split(',');
|
||||
|
||||
EventType type;
|
||||
if (!Enum.TryParse(split[0], out type))
|
||||
throw new InvalidDataException($@"Unknown event type {split[0]}");
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case EventType.Background:
|
||||
string filename = split[2].Trim('"');
|
||||
beatmap.BeatmapInfo.Metadata.BackgroundFile = filename;
|
||||
break;
|
||||
case EventType.Break:
|
||||
var breakEvent = new BreakPeriod
|
||||
{
|
||||
StartTime = double.Parse(split[1], NumberFormatInfo.InvariantInfo),
|
||||
EndTime = double.Parse(split[2], NumberFormatInfo.InvariantInfo)
|
||||
};
|
||||
|
||||
if (!breakEvent.HasEffect)
|
||||
return;
|
||||
|
||||
beatmap.Breaks.Add(breakEvent);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void handleTimingPoints(string line)
|
||||
{
|
||||
string[] split = line.Split(',');
|
||||
|
||||
double time = double.Parse(split[0].Trim(), NumberFormatInfo.InvariantInfo);
|
||||
double beatLength = double.Parse(split[1].Trim(), NumberFormatInfo.InvariantInfo);
|
||||
double speedMultiplier = beatLength < 0 ? 100.0 / -beatLength : 1;
|
||||
|
||||
TimeSignatures timeSignature = TimeSignatures.SimpleQuadruple;
|
||||
if (split.Length >= 3)
|
||||
timeSignature = split[2][0] == '0' ? TimeSignatures.SimpleQuadruple : (TimeSignatures)int.Parse(split[2]);
|
||||
|
||||
LegacySampleBank sampleSet = defaultSampleBank;
|
||||
if (split.Length >= 4)
|
||||
sampleSet = (LegacySampleBank)int.Parse(split[3]);
|
||||
|
||||
//SampleBank sampleBank = SampleBank.Default;
|
||||
//if (split.Length >= 5)
|
||||
// sampleBank = (SampleBank)int.Parse(split[4]);
|
||||
|
||||
int sampleVolume = defaultSampleVolume;
|
||||
if (split.Length >= 6)
|
||||
sampleVolume = int.Parse(split[5]);
|
||||
|
||||
bool timingChange = true;
|
||||
if (split.Length >= 7)
|
||||
timingChange = split[6][0] == '1';
|
||||
|
||||
bool kiaiMode = false;
|
||||
bool omitFirstBarSignature = false;
|
||||
if (split.Length >= 8)
|
||||
{
|
||||
int effectFlags = int.Parse(split[7]);
|
||||
kiaiMode = (effectFlags & 1) > 0;
|
||||
omitFirstBarSignature = (effectFlags & 8) > 0;
|
||||
}
|
||||
|
||||
string stringSampleSet = sampleSet.ToString().ToLower();
|
||||
if (stringSampleSet == @"none")
|
||||
stringSampleSet = @"normal";
|
||||
|
||||
DifficultyControlPoint difficultyPoint = beatmap.ControlPointInfo.DifficultyPointAt(time);
|
||||
SoundControlPoint soundPoint = beatmap.ControlPointInfo.SoundPointAt(time);
|
||||
EffectControlPoint effectPoint = beatmap.ControlPointInfo.EffectPointAt(time);
|
||||
|
||||
if (timingChange)
|
||||
{
|
||||
beatmap.ControlPointInfo.TimingPoints.Add(new TimingControlPoint
|
||||
{
|
||||
Time = time,
|
||||
BeatLength = beatLength,
|
||||
TimeSignature = timeSignature
|
||||
});
|
||||
}
|
||||
|
||||
if (speedMultiplier != difficultyPoint.SpeedMultiplier)
|
||||
{
|
||||
beatmap.ControlPointInfo.DifficultyPoints.RemoveAll(x => x.Time == time);
|
||||
beatmap.ControlPointInfo.DifficultyPoints.Add(new DifficultyControlPoint
|
||||
{
|
||||
Time = time,
|
||||
SpeedMultiplier = speedMultiplier
|
||||
});
|
||||
}
|
||||
|
||||
if (stringSampleSet != soundPoint.SampleBank || sampleVolume != soundPoint.SampleVolume)
|
||||
{
|
||||
beatmap.ControlPointInfo.SoundPoints.Add(new SoundControlPoint
|
||||
{
|
||||
Time = time,
|
||||
SampleBank = stringSampleSet,
|
||||
SampleVolume = sampleVolume
|
||||
});
|
||||
}
|
||||
|
||||
if (kiaiMode != effectPoint.KiaiMode || omitFirstBarSignature != effectPoint.OmitFirstBarLine)
|
||||
{
|
||||
beatmap.ControlPointInfo.EffectPoints.Add(new EffectControlPoint
|
||||
{
|
||||
Time = time,
|
||||
KiaiMode = kiaiMode,
|
||||
OmitFirstBarLine = omitFirstBarSignature
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private void handleColours(string line)
|
||||
{
|
||||
var pair = splitKeyVal(line, ':');
|
||||
|
||||
string[] split = pair.Value.Split(',');
|
||||
|
||||
if (split.Length != 3)
|
||||
throw new InvalidOperationException($@"Color specified in incorrect format (should be R,G,B): {pair.Value}");
|
||||
|
||||
byte r, g, b;
|
||||
if (!byte.TryParse(split[0], out r) || !byte.TryParse(split[1], out g) || !byte.TryParse(split[2], out b))
|
||||
throw new InvalidOperationException(@"Color must be specified with 8-bit integer components");
|
||||
|
||||
if (!hasCustomColours)
|
||||
{
|
||||
beatmap.ComboColors.Clear();
|
||||
hasCustomColours = true;
|
||||
}
|
||||
|
||||
// Note: the combo index specified in the beatmap is discarded
|
||||
if (pair.Key.StartsWith(@"Combo"))
|
||||
{
|
||||
beatmap.ComboColors.Add(new Color4
|
||||
{
|
||||
R = r / 255f,
|
||||
G = g / 255f,
|
||||
B = b / 255f,
|
||||
A = 1f,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private void handleHitObjects(string line)
|
||||
{
|
||||
// If the ruleset wasn't specified, assume the osu!standard ruleset.
|
||||
if (parser == null)
|
||||
parser = new Rulesets.Objects.Legacy.Osu.ConvertHitObjectParser();
|
||||
|
||||
var obj = parser.Parse(line);
|
||||
|
||||
if (obj != null)
|
||||
beatmap.HitObjects.Add(obj);
|
||||
}
|
||||
|
||||
private void handleVariables(string line)
|
||||
{
|
||||
var pair = splitKeyVal(line, '=');
|
||||
Variables[pair.Key] = pair.Value;
|
||||
}
|
||||
|
||||
private KeyValuePair<string, string> splitKeyVal(string line, char separator)
|
||||
{
|
||||
var split = line.Trim().Split(new[] { separator }, 2);
|
||||
|
||||
return new KeyValuePair<string, string>
|
||||
(
|
||||
split[0].Trim(),
|
||||
split.Length > 1 ? split[1].Trim() : string.Empty
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
163
osu.Game/Beatmaps/Formats/LegacyDecoder.cs
Normal file
163
osu.Game/Beatmaps/Formats/LegacyDecoder.cs
Normal file
@ -0,0 +1,163 @@
|
||||
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using osu.Game.Beatmaps.Legacy;
|
||||
using osu.Game.Storyboards;
|
||||
|
||||
namespace osu.Game.Beatmaps.Formats
|
||||
{
|
||||
public abstract class LegacyDecoder : Decoder
|
||||
{
|
||||
public static void Register()
|
||||
{
|
||||
AddDecoder<LegacyBeatmapDecoder>(@"osu file format v14");
|
||||
AddDecoder<LegacyBeatmapDecoder>(@"osu file format v13");
|
||||
AddDecoder<LegacyBeatmapDecoder>(@"osu file format v12");
|
||||
AddDecoder<LegacyBeatmapDecoder>(@"osu file format v11");
|
||||
AddDecoder<LegacyBeatmapDecoder>(@"osu file format v10");
|
||||
AddDecoder<LegacyBeatmapDecoder>(@"osu file format v9");
|
||||
AddDecoder<LegacyBeatmapDecoder>(@"osu file format v8");
|
||||
AddDecoder<LegacyBeatmapDecoder>(@"osu file format v7");
|
||||
AddDecoder<LegacyBeatmapDecoder>(@"osu file format v6");
|
||||
AddDecoder<LegacyBeatmapDecoder>(@"osu file format v5");
|
||||
AddDecoder<LegacyBeatmapDecoder>(@"osu file format v4");
|
||||
AddDecoder<LegacyBeatmapDecoder>(@"osu file format v3");
|
||||
// TODO: differences between versions
|
||||
}
|
||||
|
||||
protected int BeatmapVersion;
|
||||
protected readonly Dictionary<string, string> Variables = new Dictionary<string, string>();
|
||||
|
||||
public override Decoder GetStoryboardDecoder() => new LegacyStoryboardDecoder(BeatmapVersion);
|
||||
|
||||
public override Beatmap DecodeBeatmap(StreamReader stream) => new LegacyBeatmap(base.DecodeBeatmap(stream));
|
||||
|
||||
protected override void ParseBeatmap(StreamReader stream, Beatmap beatmap)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
protected override void ParseStoryboard(StreamReader stream, Storyboard storyboard)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
protected void ParseContent(StreamReader stream)
|
||||
{
|
||||
Section section = Section.None;
|
||||
|
||||
string line;
|
||||
while ((line = stream.ReadLine()) != null)
|
||||
{
|
||||
if (ShouldSkipLine(line))
|
||||
continue;
|
||||
|
||||
// It's already set in ParseBeatmap... why do it again?
|
||||
//if (line.StartsWith(@"osu file format v"))
|
||||
//{
|
||||
// Beatmap.BeatmapInfo.BeatmapVersion = int.Parse(line.Substring(17));
|
||||
// continue;
|
||||
//}
|
||||
|
||||
if (line.StartsWith(@"[") && line.EndsWith(@"]"))
|
||||
{
|
||||
if (!Enum.TryParse(line.Substring(1, line.Length - 2), out section))
|
||||
throw new InvalidDataException($@"Unknown osu section {line}");
|
||||
continue;
|
||||
}
|
||||
|
||||
ProcessSection(section, line);
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual bool ShouldSkipLine(string line)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(line) || line.StartsWith("//"))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
protected abstract void ProcessSection(Section section, string line);
|
||||
|
||||
/// <summary>
|
||||
/// Decodes any beatmap variables present in a line into their real values.
|
||||
/// </summary>
|
||||
/// <param name="line">The line which may contains variables.</param>
|
||||
protected void DecodeVariables(ref string line)
|
||||
{
|
||||
while (line.IndexOf('$') >= 0)
|
||||
{
|
||||
string origLine = line;
|
||||
string[] split = line.Split(',');
|
||||
for (int i = 0; i < split.Length; i++)
|
||||
{
|
||||
var item = split[i];
|
||||
if (item.StartsWith("$") && Variables.ContainsKey(item))
|
||||
split[i] = Variables[item];
|
||||
}
|
||||
|
||||
line = string.Join(",", split);
|
||||
if (line == origLine)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
protected enum Section
|
||||
{
|
||||
None,
|
||||
General,
|
||||
Editor,
|
||||
Metadata,
|
||||
Difficulty,
|
||||
Events,
|
||||
TimingPoints,
|
||||
Colours,
|
||||
HitObjects,
|
||||
Variables,
|
||||
}
|
||||
|
||||
internal enum LegacySampleBank
|
||||
{
|
||||
None = 0,
|
||||
Normal = 1,
|
||||
Soft = 2,
|
||||
Drum = 3
|
||||
}
|
||||
|
||||
internal enum EventType
|
||||
{
|
||||
Background = 0,
|
||||
Video = 1,
|
||||
Break = 2,
|
||||
Colour = 3,
|
||||
Sprite = 4,
|
||||
Sample = 5,
|
||||
Animation = 6
|
||||
}
|
||||
|
||||
internal enum LegacyOrigins
|
||||
{
|
||||
TopLeft,
|
||||
Centre,
|
||||
CentreLeft,
|
||||
TopRight,
|
||||
BottomCentre,
|
||||
TopCentre,
|
||||
Custom,
|
||||
CentreRight,
|
||||
BottomLeft,
|
||||
BottomRight
|
||||
};
|
||||
|
||||
internal enum StoryLayer
|
||||
{
|
||||
Background = 0,
|
||||
Fail = 1,
|
||||
Pass = 2,
|
||||
Foreground = 3
|
||||
}
|
||||
}
|
||||
}
|
271
osu.Game/Beatmaps/Formats/LegacyStoryboardDecoder.cs
Normal file
271
osu.Game/Beatmaps/Formats/LegacyStoryboardDecoder.cs
Normal file
@ -0,0 +1,271 @@
|
||||
// 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.Globalization;
|
||||
using System.IO;
|
||||
using OpenTK;
|
||||
using OpenTK.Graphics;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.IO.File;
|
||||
using osu.Game.Storyboards;
|
||||
|
||||
namespace osu.Game.Beatmaps.Formats
|
||||
{
|
||||
public class LegacyStoryboardDecoder : LegacyDecoder
|
||||
{
|
||||
private Storyboard storyboard;
|
||||
|
||||
private StoryboardSprite storyboardSprite;
|
||||
private CommandTimelineGroup timelineGroup;
|
||||
|
||||
public LegacyStoryboardDecoder()
|
||||
{
|
||||
}
|
||||
|
||||
public LegacyStoryboardDecoder(int beatmapVersion)
|
||||
{
|
||||
BeatmapVersion = beatmapVersion;
|
||||
}
|
||||
|
||||
protected override void ParseStoryboard(StreamReader stream, Storyboard storyboard)
|
||||
{
|
||||
if (stream == null)
|
||||
throw new ArgumentNullException(nameof(stream));
|
||||
if (storyboard == null)
|
||||
throw new ArgumentNullException(nameof(storyboard));
|
||||
|
||||
this.storyboard = storyboard;
|
||||
|
||||
ParseContent(stream);
|
||||
}
|
||||
|
||||
protected override void ProcessSection(Section section, string line)
|
||||
{
|
||||
switch (section)
|
||||
{
|
||||
case Section.Events:
|
||||
handleEvents(line);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void handleEvents(string line)
|
||||
{
|
||||
var depth = 0;
|
||||
while (line.StartsWith(" ") || line.StartsWith("_"))
|
||||
{
|
||||
++depth;
|
||||
line = line.Substring(1);
|
||||
}
|
||||
|
||||
DecodeVariables(ref line);
|
||||
|
||||
string[] split = line.Split(',');
|
||||
|
||||
if (depth == 0)
|
||||
{
|
||||
storyboardSprite = null;
|
||||
|
||||
EventType type;
|
||||
if (!Enum.TryParse(split[0], out type))
|
||||
throw new InvalidDataException($@"Unknown event type {split[0]}");
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case EventType.Sprite:
|
||||
{
|
||||
var layer = parseLayer(split[1]);
|
||||
var origin = parseOrigin(split[2]);
|
||||
var path = cleanFilename(split[3]);
|
||||
var x = float.Parse(split[4], NumberFormatInfo.InvariantInfo);
|
||||
var y = float.Parse(split[5], NumberFormatInfo.InvariantInfo);
|
||||
storyboardSprite = new StoryboardSprite(path, origin, new Vector2(x, y));
|
||||
storyboard.GetLayer(layer).Add(storyboardSprite);
|
||||
}
|
||||
break;
|
||||
case EventType.Animation:
|
||||
{
|
||||
var layer = parseLayer(split[1]);
|
||||
var origin = parseOrigin(split[2]);
|
||||
var path = cleanFilename(split[3]);
|
||||
var x = float.Parse(split[4], NumberFormatInfo.InvariantInfo);
|
||||
var y = float.Parse(split[5], NumberFormatInfo.InvariantInfo);
|
||||
var frameCount = int.Parse(split[6]);
|
||||
var frameDelay = double.Parse(split[7], NumberFormatInfo.InvariantInfo);
|
||||
var loopType = split.Length > 8 ? (AnimationLoopType)Enum.Parse(typeof(AnimationLoopType), split[8]) : AnimationLoopType.LoopForever;
|
||||
storyboardSprite = new StoryboardAnimation(path, origin, new Vector2(x, y), frameCount, frameDelay, loopType);
|
||||
storyboard.GetLayer(layer).Add(storyboardSprite);
|
||||
}
|
||||
break;
|
||||
case EventType.Sample:
|
||||
{
|
||||
var time = double.Parse(split[1], CultureInfo.InvariantCulture);
|
||||
var layer = parseLayer(split[2]);
|
||||
var path = cleanFilename(split[3]);
|
||||
var volume = split.Length > 4 ? float.Parse(split[4], CultureInfo.InvariantCulture) : 100;
|
||||
storyboard.GetLayer(layer).Add(new StoryboardSample(path, time, volume));
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (depth < 2)
|
||||
timelineGroup = storyboardSprite?.TimelineGroup;
|
||||
|
||||
var commandType = split[0];
|
||||
switch (commandType)
|
||||
{
|
||||
case "T":
|
||||
{
|
||||
var triggerName = split[1];
|
||||
var startTime = split.Length > 2 ? double.Parse(split[2], CultureInfo.InvariantCulture) : double.MinValue;
|
||||
var endTime = split.Length > 3 ? double.Parse(split[3], CultureInfo.InvariantCulture) : double.MaxValue;
|
||||
var groupNumber = split.Length > 4 ? int.Parse(split[4]) : 0;
|
||||
timelineGroup = storyboardSprite?.AddTrigger(triggerName, startTime, endTime, groupNumber);
|
||||
}
|
||||
break;
|
||||
case "L":
|
||||
{
|
||||
var startTime = double.Parse(split[1], CultureInfo.InvariantCulture);
|
||||
var loopCount = int.Parse(split[2]);
|
||||
timelineGroup = storyboardSprite?.AddLoop(startTime, loopCount);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
{
|
||||
if (string.IsNullOrEmpty(split[3]))
|
||||
split[3] = split[2];
|
||||
|
||||
var easing = (Easing)int.Parse(split[1]);
|
||||
var startTime = double.Parse(split[2], CultureInfo.InvariantCulture);
|
||||
var endTime = double.Parse(split[3], CultureInfo.InvariantCulture);
|
||||
|
||||
switch (commandType)
|
||||
{
|
||||
case "F":
|
||||
{
|
||||
var startValue = float.Parse(split[4], CultureInfo.InvariantCulture);
|
||||
var endValue = split.Length > 5 ? float.Parse(split[5], CultureInfo.InvariantCulture) : startValue;
|
||||
timelineGroup?.Alpha.Add(easing, startTime, endTime, startValue, endValue);
|
||||
}
|
||||
break;
|
||||
case "S":
|
||||
{
|
||||
var startValue = float.Parse(split[4], CultureInfo.InvariantCulture);
|
||||
var endValue = split.Length > 5 ? float.Parse(split[5], CultureInfo.InvariantCulture) : startValue;
|
||||
timelineGroup?.Scale.Add(easing, startTime, endTime, new Vector2(startValue), new Vector2(endValue));
|
||||
}
|
||||
break;
|
||||
case "V":
|
||||
{
|
||||
var startX = float.Parse(split[4], CultureInfo.InvariantCulture);
|
||||
var startY = float.Parse(split[5], CultureInfo.InvariantCulture);
|
||||
var endX = split.Length > 6 ? float.Parse(split[6], CultureInfo.InvariantCulture) : startX;
|
||||
var endY = split.Length > 7 ? float.Parse(split[7], CultureInfo.InvariantCulture) : startY;
|
||||
timelineGroup?.Scale.Add(easing, startTime, endTime, new Vector2(startX, startY), new Vector2(endX, endY));
|
||||
}
|
||||
break;
|
||||
case "R":
|
||||
{
|
||||
var startValue = float.Parse(split[4], CultureInfo.InvariantCulture);
|
||||
var endValue = split.Length > 5 ? float.Parse(split[5], CultureInfo.InvariantCulture) : startValue;
|
||||
timelineGroup?.Rotation.Add(easing, startTime, endTime, MathHelper.RadiansToDegrees(startValue), MathHelper.RadiansToDegrees(endValue));
|
||||
}
|
||||
break;
|
||||
case "M":
|
||||
{
|
||||
var startX = float.Parse(split[4], CultureInfo.InvariantCulture);
|
||||
var startY = float.Parse(split[5], CultureInfo.InvariantCulture);
|
||||
var endX = split.Length > 6 ? float.Parse(split[6], CultureInfo.InvariantCulture) : startX;
|
||||
var endY = split.Length > 7 ? float.Parse(split[7], CultureInfo.InvariantCulture) : startY;
|
||||
timelineGroup?.X.Add(easing, startTime, endTime, startX, endX);
|
||||
timelineGroup?.Y.Add(easing, startTime, endTime, startY, endY);
|
||||
}
|
||||
break;
|
||||
case "MX":
|
||||
{
|
||||
var startValue = float.Parse(split[4], CultureInfo.InvariantCulture);
|
||||
var endValue = split.Length > 5 ? float.Parse(split[5], CultureInfo.InvariantCulture) : startValue;
|
||||
timelineGroup?.X.Add(easing, startTime, endTime, startValue, endValue);
|
||||
}
|
||||
break;
|
||||
case "MY":
|
||||
{
|
||||
var startValue = float.Parse(split[4], CultureInfo.InvariantCulture);
|
||||
var endValue = split.Length > 5 ? float.Parse(split[5], CultureInfo.InvariantCulture) : startValue;
|
||||
timelineGroup?.Y.Add(easing, startTime, endTime, startValue, endValue);
|
||||
}
|
||||
break;
|
||||
case "C":
|
||||
{
|
||||
var startRed = float.Parse(split[4], CultureInfo.InvariantCulture);
|
||||
var startGreen = float.Parse(split[5], CultureInfo.InvariantCulture);
|
||||
var startBlue = float.Parse(split[6], CultureInfo.InvariantCulture);
|
||||
var endRed = split.Length > 7 ? float.Parse(split[7], CultureInfo.InvariantCulture) : startRed;
|
||||
var endGreen = split.Length > 8 ? float.Parse(split[8], CultureInfo.InvariantCulture) : startGreen;
|
||||
var endBlue = split.Length > 9 ? float.Parse(split[9], CultureInfo.InvariantCulture) : startBlue;
|
||||
timelineGroup?.Colour.Add(easing, startTime, endTime,
|
||||
new Color4(startRed / 255f, startGreen / 255f, startBlue / 255f, 1),
|
||||
new Color4(endRed / 255f, endGreen / 255f, endBlue / 255f, 1));
|
||||
}
|
||||
break;
|
||||
case "P":
|
||||
{
|
||||
var type = split[4];
|
||||
switch (type)
|
||||
{
|
||||
case "A":
|
||||
timelineGroup?.BlendingMode.Add(easing, startTime, endTime, BlendingMode.Additive, startTime == endTime ? BlendingMode.Additive : BlendingMode.Inherit);
|
||||
break;
|
||||
case "H":
|
||||
timelineGroup?.FlipH.Add(easing, startTime, endTime, true, startTime == endTime);
|
||||
break;
|
||||
case "V":
|
||||
timelineGroup?.FlipV.Add(easing, startTime, endTime, true, startTime == endTime);
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
throw new InvalidDataException($@"Unknown command type: {commandType}");
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private string parseLayer(string value) => Enum.Parse(typeof(StoryLayer), value).ToString();
|
||||
|
||||
private Anchor parseOrigin(string value)
|
||||
{
|
||||
var origin = (LegacyOrigins)Enum.Parse(typeof(LegacyOrigins), value);
|
||||
switch (origin)
|
||||
{
|
||||
case LegacyOrigins.TopLeft:
|
||||
return Anchor.TopLeft;
|
||||
case LegacyOrigins.TopCentre:
|
||||
return Anchor.TopCentre;
|
||||
case LegacyOrigins.TopRight:
|
||||
return Anchor.TopRight;
|
||||
case LegacyOrigins.CentreLeft:
|
||||
return Anchor.CentreLeft;
|
||||
case LegacyOrigins.Centre:
|
||||
return Anchor.Centre;
|
||||
case LegacyOrigins.CentreRight:
|
||||
return Anchor.CentreRight;
|
||||
case LegacyOrigins.BottomLeft:
|
||||
return Anchor.BottomLeft;
|
||||
case LegacyOrigins.BottomCentre:
|
||||
return Anchor.BottomCentre;
|
||||
case LegacyOrigins.BottomRight:
|
||||
return Anchor.BottomRight;
|
||||
}
|
||||
throw new InvalidDataException($@"Unknown origin: {value}");
|
||||
}
|
||||
|
||||
private string cleanFilename(string path) => FileSafety.PathStandardise(path.Trim('\"'));
|
||||
}
|
||||
}
|
@ -1,781 +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 System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using OpenTK.Graphics;
|
||||
using osu.Game.Beatmaps.Timing;
|
||||
using osu.Game.Beatmaps.Legacy;
|
||||
using osu.Game.Rulesets.Objects.Legacy;
|
||||
using osu.Game.Beatmaps.ControlPoints;
|
||||
using osu.Game.Storyboards;
|
||||
using OpenTK;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.IO.File;
|
||||
|
||||
namespace osu.Game.Beatmaps.Formats
|
||||
{
|
||||
public class OsuLegacyDecoder : BeatmapDecoder
|
||||
{
|
||||
public static void Register()
|
||||
{
|
||||
AddDecoder<OsuLegacyDecoder>(@"osu file format v14");
|
||||
AddDecoder<OsuLegacyDecoder>(@"osu file format v13");
|
||||
AddDecoder<OsuLegacyDecoder>(@"osu file format v12");
|
||||
AddDecoder<OsuLegacyDecoder>(@"osu file format v11");
|
||||
AddDecoder<OsuLegacyDecoder>(@"osu file format v10");
|
||||
AddDecoder<OsuLegacyDecoder>(@"osu file format v9");
|
||||
AddDecoder<OsuLegacyDecoder>(@"osu file format v8");
|
||||
AddDecoder<OsuLegacyDecoder>(@"osu file format v7");
|
||||
AddDecoder<OsuLegacyDecoder>(@"osu file format v6");
|
||||
AddDecoder<OsuLegacyDecoder>(@"osu file format v5");
|
||||
AddDecoder<OsuLegacyDecoder>(@"osu file format v4");
|
||||
AddDecoder<OsuLegacyDecoder>(@"osu file format v3");
|
||||
// TODO: differences between versions
|
||||
}
|
||||
|
||||
private ConvertHitObjectParser parser;
|
||||
|
||||
private readonly Dictionary<string, string> variables = new Dictionary<string, string>();
|
||||
|
||||
private LegacySampleBank defaultSampleBank;
|
||||
private int defaultSampleVolume = 100;
|
||||
|
||||
private readonly int beatmapVersion;
|
||||
|
||||
public OsuLegacyDecoder()
|
||||
{
|
||||
}
|
||||
|
||||
public OsuLegacyDecoder(string header)
|
||||
{
|
||||
beatmapVersion = int.Parse(header.Substring(17));
|
||||
}
|
||||
|
||||
private enum Section
|
||||
{
|
||||
None,
|
||||
General,
|
||||
Editor,
|
||||
Metadata,
|
||||
Difficulty,
|
||||
Events,
|
||||
TimingPoints,
|
||||
Colours,
|
||||
HitObjects,
|
||||
Variables,
|
||||
}
|
||||
|
||||
private void handleGeneral(Beatmap beatmap, string line)
|
||||
{
|
||||
if (beatmap == null)
|
||||
throw new ArgumentNullException(nameof(beatmap));
|
||||
if (line == null)
|
||||
throw new ArgumentNullException(nameof(line));
|
||||
|
||||
var pair = splitKeyVal(line, ':');
|
||||
|
||||
var metadata = beatmap.BeatmapInfo.Metadata;
|
||||
switch (pair.Key)
|
||||
{
|
||||
case @"AudioFilename":
|
||||
metadata.AudioFile = pair.Value;
|
||||
break;
|
||||
case @"AudioLeadIn":
|
||||
beatmap.BeatmapInfo.AudioLeadIn = int.Parse(pair.Value);
|
||||
break;
|
||||
case @"PreviewTime":
|
||||
metadata.PreviewTime = int.Parse(pair.Value);
|
||||
break;
|
||||
case @"Countdown":
|
||||
beatmap.BeatmapInfo.Countdown = int.Parse(pair.Value) == 1;
|
||||
break;
|
||||
case @"SampleSet":
|
||||
defaultSampleBank = (LegacySampleBank)Enum.Parse(typeof(LegacySampleBank), pair.Value);
|
||||
break;
|
||||
case @"SampleVolume":
|
||||
defaultSampleVolume = int.Parse(pair.Value);
|
||||
break;
|
||||
case @"StackLeniency":
|
||||
beatmap.BeatmapInfo.StackLeniency = float.Parse(pair.Value, NumberFormatInfo.InvariantInfo);
|
||||
break;
|
||||
case @"Mode":
|
||||
beatmap.BeatmapInfo.RulesetID = int.Parse(pair.Value);
|
||||
|
||||
switch (beatmap.BeatmapInfo.RulesetID)
|
||||
{
|
||||
case 0:
|
||||
parser = new Rulesets.Objects.Legacy.Osu.ConvertHitObjectParser();
|
||||
break;
|
||||
case 1:
|
||||
parser = new Rulesets.Objects.Legacy.Taiko.ConvertHitObjectParser();
|
||||
break;
|
||||
case 2:
|
||||
parser = new Rulesets.Objects.Legacy.Catch.ConvertHitObjectParser();
|
||||
break;
|
||||
case 3:
|
||||
parser = new Rulesets.Objects.Legacy.Mania.ConvertHitObjectParser();
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case @"LetterboxInBreaks":
|
||||
beatmap.BeatmapInfo.LetterboxInBreaks = int.Parse(pair.Value) == 1;
|
||||
break;
|
||||
case @"SpecialStyle":
|
||||
beatmap.BeatmapInfo.SpecialStyle = int.Parse(pair.Value) == 1;
|
||||
break;
|
||||
case @"WidescreenStoryboard":
|
||||
beatmap.BeatmapInfo.WidescreenStoryboard = int.Parse(pair.Value) == 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void handleEditor(Beatmap beatmap, string line)
|
||||
{
|
||||
if (beatmap == null)
|
||||
throw new ArgumentNullException(nameof(beatmap));
|
||||
if (line == null)
|
||||
throw new ArgumentNullException(nameof(line));
|
||||
|
||||
var pair = splitKeyVal(line, ':');
|
||||
|
||||
switch (pair.Key)
|
||||
{
|
||||
case @"Bookmarks":
|
||||
beatmap.BeatmapInfo.StoredBookmarks = pair.Value;
|
||||
break;
|
||||
case @"DistanceSpacing":
|
||||
beatmap.BeatmapInfo.DistanceSpacing = double.Parse(pair.Value, NumberFormatInfo.InvariantInfo);
|
||||
break;
|
||||
case @"BeatDivisor":
|
||||
beatmap.BeatmapInfo.BeatDivisor = int.Parse(pair.Value);
|
||||
break;
|
||||
case @"GridSize":
|
||||
beatmap.BeatmapInfo.GridSize = int.Parse(pair.Value);
|
||||
break;
|
||||
case @"TimelineZoom":
|
||||
beatmap.BeatmapInfo.TimelineZoom = double.Parse(pair.Value, NumberFormatInfo.InvariantInfo);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void handleMetadata(Beatmap beatmap, string line)
|
||||
{
|
||||
if (beatmap == null)
|
||||
throw new ArgumentNullException(nameof(beatmap));
|
||||
if (line == null)
|
||||
throw new ArgumentNullException(nameof(line));
|
||||
|
||||
var pair = splitKeyVal(line, ':');
|
||||
|
||||
var metadata = beatmap.BeatmapInfo.Metadata;
|
||||
switch (pair.Key)
|
||||
{
|
||||
case @"Title":
|
||||
metadata.Title = pair.Value;
|
||||
break;
|
||||
case @"TitleUnicode":
|
||||
metadata.TitleUnicode = pair.Value;
|
||||
break;
|
||||
case @"Artist":
|
||||
metadata.Artist = pair.Value;
|
||||
break;
|
||||
case @"ArtistUnicode":
|
||||
metadata.ArtistUnicode = pair.Value;
|
||||
break;
|
||||
case @"Creator":
|
||||
metadata.AuthorString = pair.Value;
|
||||
break;
|
||||
case @"Version":
|
||||
beatmap.BeatmapInfo.Version = pair.Value;
|
||||
break;
|
||||
case @"Source":
|
||||
beatmap.BeatmapInfo.Metadata.Source = pair.Value;
|
||||
break;
|
||||
case @"Tags":
|
||||
beatmap.BeatmapInfo.Metadata.Tags = pair.Value;
|
||||
break;
|
||||
case @"BeatmapID":
|
||||
beatmap.BeatmapInfo.OnlineBeatmapID = int.Parse(pair.Value);
|
||||
break;
|
||||
case @"BeatmapSetID":
|
||||
beatmap.BeatmapInfo.OnlineBeatmapSetID = int.Parse(pair.Value);
|
||||
metadata.OnlineBeatmapSetID = int.Parse(pair.Value);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void handleDifficulty(Beatmap beatmap, string line)
|
||||
{
|
||||
if (beatmap == null)
|
||||
throw new ArgumentNullException(nameof(beatmap));
|
||||
if (line == null)
|
||||
throw new ArgumentNullException(nameof(line));
|
||||
|
||||
var pair = splitKeyVal(line, ':');
|
||||
|
||||
var difficulty = beatmap.BeatmapInfo.BaseDifficulty;
|
||||
switch (pair.Key)
|
||||
{
|
||||
case @"HPDrainRate":
|
||||
difficulty.DrainRate = float.Parse(pair.Value, NumberFormatInfo.InvariantInfo);
|
||||
break;
|
||||
case @"CircleSize":
|
||||
difficulty.CircleSize = float.Parse(pair.Value, NumberFormatInfo.InvariantInfo);
|
||||
break;
|
||||
case @"OverallDifficulty":
|
||||
difficulty.OverallDifficulty = float.Parse(pair.Value, NumberFormatInfo.InvariantInfo);
|
||||
break;
|
||||
case @"ApproachRate":
|
||||
difficulty.ApproachRate = float.Parse(pair.Value, NumberFormatInfo.InvariantInfo);
|
||||
break;
|
||||
case @"SliderMultiplier":
|
||||
difficulty.SliderMultiplier = float.Parse(pair.Value, NumberFormatInfo.InvariantInfo);
|
||||
break;
|
||||
case @"SliderTickRate":
|
||||
difficulty.SliderTickRate = float.Parse(pair.Value, NumberFormatInfo.InvariantInfo);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Decodes any beatmap variables present in a line into their real values.
|
||||
/// </summary>
|
||||
/// <param name="line">The line which may contains variables.</param>
|
||||
private void decodeVariables(ref string line)
|
||||
{
|
||||
if (line == null)
|
||||
throw new ArgumentNullException(nameof(line));
|
||||
|
||||
while (line.IndexOf('$') >= 0)
|
||||
{
|
||||
string origLine = line;
|
||||
string[] split = line.Split(',');
|
||||
for (int i = 0; i < split.Length; i++)
|
||||
{
|
||||
var item = split[i];
|
||||
if (item.StartsWith("$") && variables.ContainsKey(item))
|
||||
split[i] = variables[item];
|
||||
}
|
||||
|
||||
line = string.Join(",", split);
|
||||
if (line == origLine) break;
|
||||
}
|
||||
}
|
||||
|
||||
private void handleEvents(Beatmap beatmap, string line, ref StoryboardSprite storyboardSprite, ref CommandTimelineGroup timelineGroup)
|
||||
{
|
||||
if (line == null)
|
||||
throw new ArgumentNullException(nameof(line));
|
||||
if (beatmap == null)
|
||||
throw new ArgumentNullException(nameof(beatmap));
|
||||
|
||||
var depth = 0;
|
||||
while (line.StartsWith(" ") || line.StartsWith("_"))
|
||||
{
|
||||
++depth;
|
||||
line = line.Substring(1);
|
||||
}
|
||||
|
||||
decodeVariables(ref line);
|
||||
|
||||
string[] split = line.Split(',');
|
||||
|
||||
if (depth == 0)
|
||||
{
|
||||
storyboardSprite = null;
|
||||
|
||||
EventType type;
|
||||
if (!Enum.TryParse(split[0], out type))
|
||||
throw new InvalidDataException($@"Unknown event type {split[0]}");
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case EventType.Video:
|
||||
case EventType.Background:
|
||||
string filename = split[2].Trim('"');
|
||||
|
||||
if (type == EventType.Background)
|
||||
beatmap.BeatmapInfo.Metadata.BackgroundFile = filename;
|
||||
|
||||
break;
|
||||
case EventType.Break:
|
||||
var breakEvent = new BreakPeriod
|
||||
{
|
||||
StartTime = double.Parse(split[1], NumberFormatInfo.InvariantInfo),
|
||||
EndTime = double.Parse(split[2], NumberFormatInfo.InvariantInfo)
|
||||
};
|
||||
|
||||
if (!breakEvent.HasEffect)
|
||||
return;
|
||||
|
||||
beatmap.Breaks.Add(breakEvent);
|
||||
break;
|
||||
case EventType.Sprite:
|
||||
{
|
||||
var layer = parseLayer(split[1]);
|
||||
var origin = parseOrigin(split[2]);
|
||||
var path = cleanFilename(split[3]);
|
||||
var x = float.Parse(split[4], NumberFormatInfo.InvariantInfo);
|
||||
var y = float.Parse(split[5], NumberFormatInfo.InvariantInfo);
|
||||
storyboardSprite = new StoryboardSprite(path, origin, new Vector2(x, y));
|
||||
beatmap.Storyboard.GetLayer(layer).Add(storyboardSprite);
|
||||
}
|
||||
break;
|
||||
case EventType.Animation:
|
||||
{
|
||||
var layer = parseLayer(split[1]);
|
||||
var origin = parseOrigin(split[2]);
|
||||
var path = cleanFilename(split[3]);
|
||||
var x = float.Parse(split[4], NumberFormatInfo.InvariantInfo);
|
||||
var y = float.Parse(split[5], NumberFormatInfo.InvariantInfo);
|
||||
var frameCount = int.Parse(split[6]);
|
||||
var frameDelay = double.Parse(split[7], NumberFormatInfo.InvariantInfo);
|
||||
var loopType = split.Length > 8 ? (AnimationLoopType)Enum.Parse(typeof(AnimationLoopType), split[8]) : AnimationLoopType.LoopForever;
|
||||
storyboardSprite = new StoryboardAnimation(path, origin, new Vector2(x, y), frameCount, frameDelay, loopType);
|
||||
beatmap.Storyboard.GetLayer(layer).Add(storyboardSprite);
|
||||
}
|
||||
break;
|
||||
case EventType.Sample:
|
||||
{
|
||||
var time = double.Parse(split[1], CultureInfo.InvariantCulture);
|
||||
var layer = parseLayer(split[2]);
|
||||
var path = cleanFilename(split[3]);
|
||||
var volume = split.Length > 4 ? float.Parse(split[4], CultureInfo.InvariantCulture) : 100;
|
||||
beatmap.Storyboard.GetLayer(layer).Add(new StoryboardSample(path, time, volume));
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (depth < 2)
|
||||
timelineGroup = storyboardSprite?.TimelineGroup;
|
||||
|
||||
var commandType = split[0];
|
||||
switch (commandType)
|
||||
{
|
||||
case "T":
|
||||
{
|
||||
var triggerName = split[1];
|
||||
var startTime = split.Length > 2 ? double.Parse(split[2], CultureInfo.InvariantCulture) : double.MinValue;
|
||||
var endTime = split.Length > 3 ? double.Parse(split[3], CultureInfo.InvariantCulture) : double.MaxValue;
|
||||
var groupNumber = split.Length > 4 ? int.Parse(split[4]) : 0;
|
||||
timelineGroup = storyboardSprite?.AddTrigger(triggerName, startTime, endTime, groupNumber);
|
||||
}
|
||||
break;
|
||||
case "L":
|
||||
{
|
||||
var startTime = double.Parse(split[1], CultureInfo.InvariantCulture);
|
||||
var loopCount = int.Parse(split[2]);
|
||||
timelineGroup = storyboardSprite?.AddLoop(startTime, loopCount);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
{
|
||||
if (string.IsNullOrEmpty(split[3]))
|
||||
split[3] = split[2];
|
||||
|
||||
var easing = (Easing)int.Parse(split[1]);
|
||||
var startTime = double.Parse(split[2], CultureInfo.InvariantCulture);
|
||||
var endTime = double.Parse(split[3], CultureInfo.InvariantCulture);
|
||||
|
||||
switch (commandType)
|
||||
{
|
||||
case "F":
|
||||
{
|
||||
var startValue = float.Parse(split[4], CultureInfo.InvariantCulture);
|
||||
var endValue = split.Length > 5 ? float.Parse(split[5], CultureInfo.InvariantCulture) : startValue;
|
||||
timelineGroup?.Alpha.Add(easing, startTime, endTime, startValue, endValue);
|
||||
}
|
||||
break;
|
||||
case "S":
|
||||
{
|
||||
var startValue = float.Parse(split[4], CultureInfo.InvariantCulture);
|
||||
var endValue = split.Length > 5 ? float.Parse(split[5], CultureInfo.InvariantCulture) : startValue;
|
||||
timelineGroup?.Scale.Add(easing, startTime, endTime, new Vector2(startValue), new Vector2(endValue));
|
||||
}
|
||||
break;
|
||||
case "V":
|
||||
{
|
||||
var startX = float.Parse(split[4], CultureInfo.InvariantCulture);
|
||||
var startY = float.Parse(split[5], CultureInfo.InvariantCulture);
|
||||
var endX = split.Length > 6 ? float.Parse(split[6], CultureInfo.InvariantCulture) : startX;
|
||||
var endY = split.Length > 7 ? float.Parse(split[7], CultureInfo.InvariantCulture) : startY;
|
||||
timelineGroup?.Scale.Add(easing, startTime, endTime, new Vector2(startX, startY), new Vector2(endX, endY));
|
||||
}
|
||||
break;
|
||||
case "R":
|
||||
{
|
||||
var startValue = float.Parse(split[4], CultureInfo.InvariantCulture);
|
||||
var endValue = split.Length > 5 ? float.Parse(split[5], CultureInfo.InvariantCulture) : startValue;
|
||||
timelineGroup?.Rotation.Add(easing, startTime, endTime, MathHelper.RadiansToDegrees(startValue), MathHelper.RadiansToDegrees(endValue));
|
||||
}
|
||||
break;
|
||||
case "M":
|
||||
{
|
||||
var startX = float.Parse(split[4], CultureInfo.InvariantCulture);
|
||||
var startY = float.Parse(split[5], CultureInfo.InvariantCulture);
|
||||
var endX = split.Length > 6 ? float.Parse(split[6], CultureInfo.InvariantCulture) : startX;
|
||||
var endY = split.Length > 7 ? float.Parse(split[7], CultureInfo.InvariantCulture) : startY;
|
||||
timelineGroup?.X.Add(easing, startTime, endTime, startX, endX);
|
||||
timelineGroup?.Y.Add(easing, startTime, endTime, startY, endY);
|
||||
}
|
||||
break;
|
||||
case "MX":
|
||||
{
|
||||
var startValue = float.Parse(split[4], CultureInfo.InvariantCulture);
|
||||
var endValue = split.Length > 5 ? float.Parse(split[5], CultureInfo.InvariantCulture) : startValue;
|
||||
timelineGroup?.X.Add(easing, startTime, endTime, startValue, endValue);
|
||||
}
|
||||
break;
|
||||
case "MY":
|
||||
{
|
||||
var startValue = float.Parse(split[4], CultureInfo.InvariantCulture);
|
||||
var endValue = split.Length > 5 ? float.Parse(split[5], CultureInfo.InvariantCulture) : startValue;
|
||||
timelineGroup?.Y.Add(easing, startTime, endTime, startValue, endValue);
|
||||
}
|
||||
break;
|
||||
case "C":
|
||||
{
|
||||
var startRed = float.Parse(split[4], CultureInfo.InvariantCulture);
|
||||
var startGreen = float.Parse(split[5], CultureInfo.InvariantCulture);
|
||||
var startBlue = float.Parse(split[6], CultureInfo.InvariantCulture);
|
||||
var endRed = split.Length > 7 ? float.Parse(split[7], CultureInfo.InvariantCulture) : startRed;
|
||||
var endGreen = split.Length > 8 ? float.Parse(split[8], CultureInfo.InvariantCulture) : startGreen;
|
||||
var endBlue = split.Length > 9 ? float.Parse(split[9], CultureInfo.InvariantCulture) : startBlue;
|
||||
timelineGroup?.Colour.Add(easing, startTime, endTime,
|
||||
new Color4(startRed / 255f, startGreen / 255f, startBlue / 255f, 1),
|
||||
new Color4(endRed / 255f, endGreen / 255f, endBlue / 255f, 1));
|
||||
}
|
||||
break;
|
||||
case "P":
|
||||
{
|
||||
var type = split[4];
|
||||
switch (type)
|
||||
{
|
||||
case "A": timelineGroup?.BlendingMode.Add(easing, startTime, endTime, BlendingMode.Additive, startTime == endTime ? BlendingMode.Additive : BlendingMode.Inherit); break;
|
||||
case "H": timelineGroup?.FlipH.Add(easing, startTime, endTime, true, startTime == endTime); break;
|
||||
case "V": timelineGroup?.FlipV.Add(easing, startTime, endTime, true, startTime == endTime); break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
throw new InvalidDataException($@"Unknown command type: {commandType}");
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static string cleanFilename(string path)
|
||||
=> FileSafety.PathStandardise(path.Trim('\"'));
|
||||
|
||||
private static Anchor parseOrigin(string value)
|
||||
{
|
||||
var origin = (LegacyOrigins)Enum.Parse(typeof(LegacyOrigins), value);
|
||||
switch (origin)
|
||||
{
|
||||
case LegacyOrigins.TopLeft: return Anchor.TopLeft;
|
||||
case LegacyOrigins.TopCentre: return Anchor.TopCentre;
|
||||
case LegacyOrigins.TopRight: return Anchor.TopRight;
|
||||
case LegacyOrigins.CentreLeft: return Anchor.CentreLeft;
|
||||
case LegacyOrigins.Centre: return Anchor.Centre;
|
||||
case LegacyOrigins.CentreRight: return Anchor.CentreRight;
|
||||
case LegacyOrigins.BottomLeft: return Anchor.BottomLeft;
|
||||
case LegacyOrigins.BottomCentre: return Anchor.BottomCentre;
|
||||
case LegacyOrigins.BottomRight: return Anchor.BottomRight;
|
||||
}
|
||||
throw new InvalidDataException($@"Unknown origin: {value}");
|
||||
}
|
||||
|
||||
private static string parseLayer(string value)
|
||||
=> Enum.Parse(typeof(StoryLayer), value).ToString();
|
||||
|
||||
private void handleTimingPoints(Beatmap beatmap, string line)
|
||||
{
|
||||
if (beatmap == null)
|
||||
throw new ArgumentNullException(nameof(beatmap));
|
||||
if (line == null)
|
||||
throw new ArgumentNullException(nameof(line));
|
||||
|
||||
string[] split = line.Split(',');
|
||||
|
||||
double time = double.Parse(split[0].Trim(), NumberFormatInfo.InvariantInfo);
|
||||
double beatLength = double.Parse(split[1].Trim(), NumberFormatInfo.InvariantInfo);
|
||||
double speedMultiplier = beatLength < 0 ? 100.0 / -beatLength : 1;
|
||||
|
||||
TimeSignatures timeSignature = TimeSignatures.SimpleQuadruple;
|
||||
if (split.Length >= 3)
|
||||
timeSignature = split[2][0] == '0' ? TimeSignatures.SimpleQuadruple : (TimeSignatures)int.Parse(split[2]);
|
||||
|
||||
LegacySampleBank sampleSet = defaultSampleBank;
|
||||
if (split.Length >= 4)
|
||||
sampleSet = (LegacySampleBank)int.Parse(split[3]);
|
||||
|
||||
//SampleBank sampleBank = SampleBank.Default;
|
||||
//if (split.Length >= 5)
|
||||
// sampleBank = (SampleBank)int.Parse(split[4]);
|
||||
|
||||
int sampleVolume = defaultSampleVolume;
|
||||
if (split.Length >= 6)
|
||||
sampleVolume = int.Parse(split[5]);
|
||||
|
||||
bool timingChange = true;
|
||||
if (split.Length >= 7)
|
||||
timingChange = split[6][0] == '1';
|
||||
|
||||
bool kiaiMode = false;
|
||||
bool omitFirstBarSignature = false;
|
||||
if (split.Length >= 8)
|
||||
{
|
||||
int effectFlags = int.Parse(split[7]);
|
||||
kiaiMode = (effectFlags & 1) > 0;
|
||||
omitFirstBarSignature = (effectFlags & 8) > 0;
|
||||
}
|
||||
|
||||
string stringSampleSet = sampleSet.ToString().ToLower();
|
||||
if (stringSampleSet == @"none")
|
||||
stringSampleSet = @"normal";
|
||||
|
||||
DifficultyControlPoint difficultyPoint = beatmap.ControlPointInfo.DifficultyPointAt(time);
|
||||
SoundControlPoint soundPoint = beatmap.ControlPointInfo.SoundPointAt(time);
|
||||
EffectControlPoint effectPoint = beatmap.ControlPointInfo.EffectPointAt(time);
|
||||
|
||||
if (timingChange)
|
||||
{
|
||||
beatmap.ControlPointInfo.TimingPoints.Add(new TimingControlPoint
|
||||
{
|
||||
Time = time,
|
||||
BeatLength = beatLength,
|
||||
TimeSignature = timeSignature
|
||||
});
|
||||
}
|
||||
|
||||
if (speedMultiplier != difficultyPoint.SpeedMultiplier)
|
||||
{
|
||||
beatmap.ControlPointInfo.DifficultyPoints.RemoveAll(x => x.Time == time);
|
||||
beatmap.ControlPointInfo.DifficultyPoints.Add(new DifficultyControlPoint
|
||||
{
|
||||
Time = time,
|
||||
SpeedMultiplier = speedMultiplier
|
||||
});
|
||||
}
|
||||
|
||||
if (stringSampleSet != soundPoint.SampleBank || sampleVolume != soundPoint.SampleVolume)
|
||||
{
|
||||
beatmap.ControlPointInfo.SoundPoints.Add(new SoundControlPoint
|
||||
{
|
||||
Time = time,
|
||||
SampleBank = stringSampleSet,
|
||||
SampleVolume = sampleVolume
|
||||
});
|
||||
}
|
||||
|
||||
if (kiaiMode != effectPoint.KiaiMode || omitFirstBarSignature != effectPoint.OmitFirstBarLine)
|
||||
{
|
||||
beatmap.ControlPointInfo.EffectPoints.Add(new EffectControlPoint
|
||||
{
|
||||
Time = time,
|
||||
KiaiMode = kiaiMode,
|
||||
OmitFirstBarLine = omitFirstBarSignature
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private void handleColours(Beatmap beatmap, string line, ref bool hasCustomColours)
|
||||
{
|
||||
if (beatmap == null)
|
||||
throw new ArgumentNullException(nameof(beatmap));
|
||||
if (line == null)
|
||||
throw new ArgumentNullException(nameof(line));
|
||||
|
||||
var pair = splitKeyVal(line, ':');
|
||||
|
||||
string[] split = pair.Value.Split(',');
|
||||
|
||||
if (split.Length != 3)
|
||||
throw new InvalidOperationException($@"Color specified in incorrect format (should be R,G,B): {pair.Value}");
|
||||
|
||||
byte r, g, b;
|
||||
if (!byte.TryParse(split[0], out r) || !byte.TryParse(split[1], out g) || !byte.TryParse(split[2], out b))
|
||||
throw new InvalidOperationException(@"Color must be specified with 8-bit integer components");
|
||||
|
||||
if (!hasCustomColours)
|
||||
{
|
||||
beatmap.ComboColors.Clear();
|
||||
hasCustomColours = true;
|
||||
}
|
||||
|
||||
// Note: the combo index specified in the beatmap is discarded
|
||||
if (pair.Key.StartsWith(@"Combo"))
|
||||
{
|
||||
beatmap.ComboColors.Add(new Color4
|
||||
{
|
||||
R = r / 255f,
|
||||
G = g / 255f,
|
||||
B = b / 255f,
|
||||
A = 1f,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private void handleVariables(string line)
|
||||
{
|
||||
if (line == null)
|
||||
throw new ArgumentNullException(nameof(line));
|
||||
|
||||
var pair = splitKeyVal(line, '=');
|
||||
variables[pair.Key] = pair.Value;
|
||||
}
|
||||
|
||||
protected override Beatmap ParseFile(StreamReader stream)
|
||||
{
|
||||
return new LegacyBeatmap(base.ParseFile(stream));
|
||||
}
|
||||
|
||||
public override Beatmap Decode(StreamReader stream)
|
||||
{
|
||||
return new LegacyBeatmap(base.Decode(stream));
|
||||
}
|
||||
|
||||
protected override void ParseFile(StreamReader stream, Beatmap beatmap)
|
||||
{
|
||||
if (beatmap == null)
|
||||
throw new ArgumentNullException(nameof(beatmap));
|
||||
if (stream == null)
|
||||
throw new ArgumentNullException(nameof(stream));
|
||||
|
||||
beatmap.BeatmapInfo.BeatmapVersion = beatmapVersion;
|
||||
|
||||
Section section = Section.None;
|
||||
bool hasCustomColours = false;
|
||||
StoryboardSprite storyboardSprite = null;
|
||||
CommandTimelineGroup timelineGroup = null;
|
||||
|
||||
string line;
|
||||
while ((line = stream.ReadLine()) != null)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(line))
|
||||
continue;
|
||||
|
||||
if (line.StartsWith("//"))
|
||||
continue;
|
||||
|
||||
if (line.StartsWith(@"osu file format v"))
|
||||
{
|
||||
beatmap.BeatmapInfo.BeatmapVersion = int.Parse(line.Substring(17));
|
||||
continue;
|
||||
}
|
||||
|
||||
if (line.StartsWith(@"[") && line.EndsWith(@"]"))
|
||||
{
|
||||
if (!Enum.TryParse(line.Substring(1, line.Length - 2), out section))
|
||||
throw new InvalidDataException($@"Unknown osu section {line}");
|
||||
continue;
|
||||
}
|
||||
|
||||
switch (section)
|
||||
{
|
||||
case Section.General:
|
||||
handleGeneral(beatmap, line);
|
||||
break;
|
||||
case Section.Editor:
|
||||
handleEditor(beatmap, line);
|
||||
break;
|
||||
case Section.Metadata:
|
||||
handleMetadata(beatmap, line);
|
||||
break;
|
||||
case Section.Difficulty:
|
||||
handleDifficulty(beatmap, line);
|
||||
break;
|
||||
case Section.Events:
|
||||
handleEvents(beatmap, line, ref storyboardSprite, ref timelineGroup);
|
||||
break;
|
||||
case Section.TimingPoints:
|
||||
handleTimingPoints(beatmap, line);
|
||||
break;
|
||||
case Section.Colours:
|
||||
handleColours(beatmap, line, ref hasCustomColours);
|
||||
break;
|
||||
case Section.HitObjects:
|
||||
|
||||
// If the ruleset wasn't specified, assume the osu!standard ruleset.
|
||||
if (parser == null)
|
||||
parser = new Rulesets.Objects.Legacy.Osu.ConvertHitObjectParser();
|
||||
|
||||
var obj = parser.Parse(line);
|
||||
|
||||
if (obj != null)
|
||||
beatmap.HitObjects.Add(obj);
|
||||
|
||||
break;
|
||||
case Section.Variables:
|
||||
handleVariables(line);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var hitObject in beatmap.HitObjects)
|
||||
hitObject.ApplyDefaults(beatmap.ControlPointInfo, beatmap.BeatmapInfo.BaseDifficulty);
|
||||
}
|
||||
|
||||
private KeyValuePair<string, string> splitKeyVal(string line, char separator)
|
||||
{
|
||||
if (line == null)
|
||||
throw new ArgumentNullException(nameof(line));
|
||||
|
||||
var split = line.Trim().Split(new[] { separator }, 2);
|
||||
|
||||
return new KeyValuePair<string, string>
|
||||
(
|
||||
split[0].Trim(),
|
||||
split.Length > 1 ? split[1].Trim() : string.Empty
|
||||
);
|
||||
}
|
||||
|
||||
internal enum LegacySampleBank
|
||||
{
|
||||
None = 0,
|
||||
Normal = 1,
|
||||
Soft = 2,
|
||||
Drum = 3
|
||||
}
|
||||
|
||||
internal enum EventType
|
||||
{
|
||||
Background = 0,
|
||||
Video = 1,
|
||||
Break = 2,
|
||||
Colour = 3,
|
||||
Sprite = 4,
|
||||
Sample = 5,
|
||||
Animation = 6
|
||||
}
|
||||
|
||||
internal enum LegacyOrigins
|
||||
{
|
||||
TopLeft,
|
||||
Centre,
|
||||
CentreLeft,
|
||||
TopRight,
|
||||
BottomCentre,
|
||||
TopCentre,
|
||||
Custom,
|
||||
CentreRight,
|
||||
BottomLeft,
|
||||
BottomRight
|
||||
};
|
||||
|
||||
internal enum StoryLayer
|
||||
{
|
||||
Background = 0,
|
||||
Fail = 1,
|
||||
Pass = 2,
|
||||
Foreground = 3
|
||||
}
|
||||
}
|
||||
}
|
@ -9,6 +9,7 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using osu.Game.Storyboards;
|
||||
|
||||
namespace osu.Game.Beatmaps
|
||||
{
|
||||
@ -34,12 +35,14 @@ namespace osu.Game.Beatmaps
|
||||
background = new AsyncLazy<Texture>(populateBackground, b => b == null || !b.IsDisposed);
|
||||
track = new AsyncLazy<Track>(populateTrack);
|
||||
waveform = new AsyncLazy<Waveform>(populateWaveform);
|
||||
storyboard = new AsyncLazy<Storyboard>(populateStoryboard);
|
||||
}
|
||||
|
||||
protected abstract Beatmap GetBeatmap();
|
||||
protected abstract Texture GetBackground();
|
||||
protected abstract Track GetTrack();
|
||||
protected virtual Waveform GetWaveform() => new Waveform();
|
||||
protected virtual Storyboard GetStoryboard() => new Storyboard();
|
||||
|
||||
public bool BeatmapLoaded => beatmap.IsResultAvailable;
|
||||
public Beatmap Beatmap => beatmap.Value.Result;
|
||||
@ -84,6 +87,13 @@ namespace osu.Game.Beatmaps
|
||||
|
||||
private Waveform populateWaveform() => GetWaveform();
|
||||
|
||||
public bool StoryboardLoaded => storyboard.IsResultAvailable;
|
||||
public Storyboard Storyboard => storyboard.Value.Result;
|
||||
public async Task<Storyboard> GetStoryboardAsync() => await storyboard.Value;
|
||||
private readonly AsyncLazy<Storyboard> storyboard;
|
||||
|
||||
private Storyboard populateStoryboard() => GetStoryboard();
|
||||
|
||||
public void TransferTo(WorkingBeatmap other)
|
||||
{
|
||||
if (track.IsResultAvailable && Track != null && BeatmapInfo.AudioEquals(other.BeatmapInfo))
|
||||
@ -97,6 +107,7 @@ namespace osu.Game.Beatmaps
|
||||
{
|
||||
if (BackgroundLoaded) Background?.Dispose();
|
||||
if (WaveformLoaded) Waveform?.Dispose();
|
||||
if (StoryboardLoaded) Storyboard?.Dispose();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -20,7 +20,7 @@ namespace osu.Game.Configuration
|
||||
Set(OsuSetting.DisplayStarsMinimum, 0.0, 0, 10, 0.1);
|
||||
Set(OsuSetting.DisplayStarsMaximum, 10.0, 0, 10, 0.1);
|
||||
|
||||
Set(OsuSetting.SelectionRandomType, SelectionRandomType.RandomPermutation);
|
||||
Set(OsuSetting.RandomSelectAlgorithm, RandomSelectAlgorithm.RandomPermutation);
|
||||
|
||||
Set(OsuSetting.ChatDisplayHeight, ChatOverlay.DEFAULT_HEIGHT, 0.2, 1);
|
||||
|
||||
@ -108,7 +108,7 @@ namespace osu.Game.Configuration
|
||||
SaveUsername,
|
||||
DisplayStarsMinimum,
|
||||
DisplayStarsMaximum,
|
||||
SelectionRandomType,
|
||||
RandomSelectAlgorithm,
|
||||
SnakingInSliders,
|
||||
SnakingOutSliders,
|
||||
ShowFpsDisplay,
|
||||
|
@ -5,11 +5,11 @@ using System.ComponentModel;
|
||||
|
||||
namespace osu.Game.Configuration
|
||||
{
|
||||
public enum SelectionRandomType
|
||||
public enum RandomSelectAlgorithm
|
||||
{
|
||||
[Description("Never repeat")]
|
||||
RandomPermutation,
|
||||
[Description("Random")]
|
||||
Random
|
||||
}
|
||||
}
|
||||
}
|
@ -93,6 +93,7 @@ namespace osu.Game.Database
|
||||
modelBuilder.Entity<FileInfo>().HasIndex(b => b.ReferenceCount);
|
||||
|
||||
modelBuilder.Entity<RulesetInfo>().HasIndex(b => b.Available);
|
||||
modelBuilder.Entity<RulesetInfo>().HasIndex(b => b.ShortName).IsUnique();
|
||||
|
||||
modelBuilder.Entity<BeatmapInfo>().HasOne(b => b.BaseDifficulty);
|
||||
}
|
||||
|
@ -15,14 +15,19 @@ namespace osu.Game.Graphics
|
||||
{
|
||||
public class SpriteIcon : CompositeDrawable
|
||||
{
|
||||
private readonly Sprite spriteShadow;
|
||||
private readonly Sprite spriteMain;
|
||||
private Sprite spriteShadow;
|
||||
private Sprite spriteMain;
|
||||
|
||||
private Cached layout = new Cached();
|
||||
private readonly Container shadowVisibility;
|
||||
private Container shadowVisibility;
|
||||
|
||||
public SpriteIcon()
|
||||
private FontStore store;
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(FontStore store)
|
||||
{
|
||||
this.store = store;
|
||||
|
||||
InternalChildren = new Drawable[]
|
||||
{
|
||||
shadowVisibility = new Container
|
||||
@ -39,7 +44,7 @@ namespace osu.Game.Graphics
|
||||
Y = 2,
|
||||
Colour = new Color4(0f, 0f, 0f, 0.2f),
|
||||
},
|
||||
Alpha = 0,
|
||||
Alpha = shadow ? 1 : 0,
|
||||
},
|
||||
spriteMain = new Sprite
|
||||
{
|
||||
@ -49,14 +54,7 @@ namespace osu.Game.Graphics
|
||||
FillMode = FillMode.Fit
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
private FontStore store;
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(FontStore store)
|
||||
{
|
||||
this.store = store;
|
||||
updateTexture();
|
||||
}
|
||||
|
||||
@ -105,12 +103,15 @@ namespace osu.Game.Graphics
|
||||
}
|
||||
}
|
||||
|
||||
private bool shadow;
|
||||
public bool Shadow
|
||||
{
|
||||
get { return spriteShadow.IsPresent; }
|
||||
get { return shadow; }
|
||||
set
|
||||
{
|
||||
shadowVisibility.Alpha = value ? 1 : 0;
|
||||
shadow = value;
|
||||
if (shadowVisibility != null)
|
||||
shadowVisibility.Alpha = value ? 1 : 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -12,6 +12,8 @@ using osu.Game.Graphics.Backgrounds;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using osu.Framework.Extensions.Color4Extensions;
|
||||
using osu.Game.Graphics.Containers;
|
||||
using osu.Framework.Configuration;
|
||||
using osu.Framework.Input;
|
||||
|
||||
namespace osu.Game.Graphics.UserInterface
|
||||
{
|
||||
@ -22,62 +24,7 @@ namespace osu.Game.Graphics.UserInterface
|
||||
private const float glow_fade_duration = 250;
|
||||
private const float click_duration = 200;
|
||||
|
||||
private Color4 buttonColour;
|
||||
public Color4 ButtonColour
|
||||
{
|
||||
get
|
||||
{
|
||||
return buttonColour;
|
||||
}
|
||||
set
|
||||
{
|
||||
buttonColour = value;
|
||||
updateGlow();
|
||||
colourContainer.Colour = value;
|
||||
}
|
||||
}
|
||||
|
||||
private Color4 backgroundColour = OsuColour.Gray(34);
|
||||
public Color4 BackgroundColour
|
||||
{
|
||||
get
|
||||
{
|
||||
return backgroundColour;
|
||||
}
|
||||
set
|
||||
{
|
||||
backgroundColour = value;
|
||||
background.Colour = value;
|
||||
}
|
||||
}
|
||||
|
||||
private string text;
|
||||
public string Text
|
||||
{
|
||||
get
|
||||
{
|
||||
return text;
|
||||
}
|
||||
set
|
||||
{
|
||||
text = value;
|
||||
spriteText.Text = Text;
|
||||
}
|
||||
}
|
||||
|
||||
private float textSize = 28;
|
||||
public float TextSize
|
||||
{
|
||||
get
|
||||
{
|
||||
return textSize;
|
||||
}
|
||||
set
|
||||
{
|
||||
textSize = value;
|
||||
spriteText.TextSize = value;
|
||||
}
|
||||
}
|
||||
public readonly BindableBool Selected = new BindableBool();
|
||||
|
||||
private readonly Container backgroundContainer;
|
||||
private readonly Container colourContainer;
|
||||
@ -89,71 +36,6 @@ namespace osu.Game.Graphics.UserInterface
|
||||
private readonly SpriteText spriteText;
|
||||
private Vector2 hoverSpacing => new Vector2(3f, 0f);
|
||||
|
||||
private bool didClick; // Used for making sure that the OnMouseDown animation can call instead of OnHoverLost's when clicking
|
||||
|
||||
public override bool ReceiveMouseInputAt(Vector2 screenSpacePos) => backgroundContainer.ReceiveMouseInputAt(screenSpacePos);
|
||||
|
||||
protected override bool OnClick(Framework.Input.InputState state)
|
||||
{
|
||||
didClick = true;
|
||||
colourContainer.ResizeTo(new Vector2(1.5f, 1f), click_duration, Easing.In);
|
||||
flash();
|
||||
|
||||
this.Delay(click_duration).Schedule(delegate
|
||||
{
|
||||
colourContainer.ResizeTo(new Vector2(0.8f, 1f));
|
||||
spriteText.Spacing = Vector2.Zero;
|
||||
glowContainer.FadeOut();
|
||||
});
|
||||
|
||||
return base.OnClick(state);
|
||||
}
|
||||
|
||||
protected override bool OnHover(Framework.Input.InputState state)
|
||||
{
|
||||
spriteText.TransformSpacingTo(hoverSpacing, hover_duration, Easing.OutElastic);
|
||||
|
||||
colourContainer.ResizeTo(new Vector2(hover_width, 1f), hover_duration, Easing.OutElastic);
|
||||
glowContainer.FadeIn(glow_fade_duration, Easing.Out);
|
||||
base.OnHover(state);
|
||||
return true;
|
||||
}
|
||||
|
||||
protected override void OnHoverLost(Framework.Input.InputState state)
|
||||
{
|
||||
if (!didClick)
|
||||
{
|
||||
colourContainer.ResizeTo(new Vector2(0.8f, 1f), hover_duration, Easing.OutElastic);
|
||||
spriteText.TransformSpacingTo(Vector2.Zero, hover_duration, Easing.OutElastic);
|
||||
glowContainer.FadeOut(glow_fade_duration, Easing.Out);
|
||||
}
|
||||
|
||||
didClick = false;
|
||||
}
|
||||
|
||||
private void flash()
|
||||
{
|
||||
var flash = new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both
|
||||
};
|
||||
|
||||
colourContainer.Add(flash);
|
||||
|
||||
flash.Colour = ButtonColour;
|
||||
flash.Blending = BlendingMode.Additive;
|
||||
flash.Alpha = 0.3f;
|
||||
flash.FadeOutFromOne(click_duration);
|
||||
flash.Expire();
|
||||
}
|
||||
|
||||
private void updateGlow()
|
||||
{
|
||||
leftGlow.Colour = ColourInfo.GradientHorizontal(new Color4(ButtonColour.R, ButtonColour.G, ButtonColour.B, 0f), ButtonColour);
|
||||
centerGlow.Colour = ButtonColour;
|
||||
rightGlow.Colour = ColourInfo.GradientHorizontal(ButtonColour, new Color4(ButtonColour.R, ButtonColour.G, ButtonColour.B, 0f));
|
||||
}
|
||||
|
||||
public DialogButton()
|
||||
{
|
||||
RelativeSizeAxes = Axes.X;
|
||||
@ -268,6 +150,135 @@ namespace osu.Game.Graphics.UserInterface
|
||||
};
|
||||
|
||||
updateGlow();
|
||||
|
||||
Selected.ValueChanged += selectionChanged;
|
||||
}
|
||||
|
||||
private Color4 buttonColour;
|
||||
public Color4 ButtonColour
|
||||
{
|
||||
get
|
||||
{
|
||||
return buttonColour;
|
||||
}
|
||||
set
|
||||
{
|
||||
buttonColour = value;
|
||||
updateGlow();
|
||||
colourContainer.Colour = value;
|
||||
}
|
||||
}
|
||||
|
||||
private Color4 backgroundColour = OsuColour.Gray(34);
|
||||
public Color4 BackgroundColour
|
||||
{
|
||||
get
|
||||
{
|
||||
return backgroundColour;
|
||||
}
|
||||
set
|
||||
{
|
||||
backgroundColour = value;
|
||||
background.Colour = value;
|
||||
}
|
||||
}
|
||||
|
||||
private string text;
|
||||
public string Text
|
||||
{
|
||||
get
|
||||
{
|
||||
return text;
|
||||
}
|
||||
set
|
||||
{
|
||||
text = value;
|
||||
spriteText.Text = Text;
|
||||
}
|
||||
}
|
||||
|
||||
private float textSize = 28;
|
||||
public float TextSize
|
||||
{
|
||||
get
|
||||
{
|
||||
return textSize;
|
||||
}
|
||||
set
|
||||
{
|
||||
textSize = value;
|
||||
spriteText.TextSize = value;
|
||||
}
|
||||
}
|
||||
|
||||
public override bool ReceiveMouseInputAt(Vector2 screenSpacePos) => backgroundContainer.ReceiveMouseInputAt(screenSpacePos);
|
||||
|
||||
protected override bool OnClick(InputState state)
|
||||
{
|
||||
colourContainer.ResizeTo(new Vector2(1.5f, 1f), click_duration, Easing.In);
|
||||
flash();
|
||||
|
||||
this.Delay(click_duration).Schedule(delegate
|
||||
{
|
||||
colourContainer.ResizeTo(new Vector2(0.8f, 1f));
|
||||
spriteText.Spacing = Vector2.Zero;
|
||||
glowContainer.FadeOut();
|
||||
});
|
||||
|
||||
return base.OnClick(state);
|
||||
}
|
||||
|
||||
protected override bool OnHover(InputState state)
|
||||
{
|
||||
base.OnHover(state);
|
||||
|
||||
Selected.Value = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
protected override void OnHoverLost(InputState state)
|
||||
{
|
||||
base.OnHoverLost(state);
|
||||
Selected.Value = false;
|
||||
}
|
||||
|
||||
private void selectionChanged(bool isSelected)
|
||||
{
|
||||
if (isSelected)
|
||||
{
|
||||
spriteText.TransformSpacingTo(hoverSpacing, hover_duration, Easing.OutElastic);
|
||||
colourContainer.ResizeTo(new Vector2(hover_width, 1f), hover_duration, Easing.OutElastic);
|
||||
glowContainer.FadeIn(glow_fade_duration, Easing.Out);
|
||||
}
|
||||
else
|
||||
{
|
||||
colourContainer.ResizeTo(new Vector2(0.8f, 1f), hover_duration, Easing.OutElastic);
|
||||
spriteText.TransformSpacingTo(Vector2.Zero, hover_duration, Easing.OutElastic);
|
||||
glowContainer.FadeOut(glow_fade_duration, Easing.Out);
|
||||
}
|
||||
}
|
||||
|
||||
private void flash()
|
||||
{
|
||||
var flash = new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both
|
||||
};
|
||||
|
||||
colourContainer.Add(flash);
|
||||
|
||||
flash.Colour = ButtonColour;
|
||||
flash.Blending = BlendingMode.Additive;
|
||||
flash.Alpha = 0.3f;
|
||||
flash.FadeOutFromOne(click_duration);
|
||||
flash.Expire();
|
||||
}
|
||||
|
||||
private void updateGlow()
|
||||
{
|
||||
leftGlow.Colour = ColourInfo.GradientHorizontal(new Color4(ButtonColour.R, ButtonColour.G, ButtonColour.B, 0f), ButtonColour);
|
||||
centerGlow.Colour = ButtonColour;
|
||||
rightGlow.Colour = ColourInfo.GradientHorizontal(ButtonColour, new Color4(ButtonColour.R, ButtonColour.G, ButtonColour.B, 0f));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -6,6 +6,7 @@ using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.MathUtils;
|
||||
using System;
|
||||
using System.Linq;
|
||||
|
||||
namespace osu.Game.Graphics.UserInterface
|
||||
{
|
||||
@ -72,16 +73,9 @@ namespace osu.Game.Graphics.UserInterface
|
||||
AutoSizeAxes = Axes.Both,
|
||||
Direction = FillDirection.Horizontal,
|
||||
Spacing = new Vector2(star_spacing),
|
||||
ChildrenEnumerable = Enumerable.Range(0, StarCount).Select(i => new Star { Alpha = minStarAlpha })
|
||||
}
|
||||
};
|
||||
|
||||
for (int i = 0; i < StarCount; i++)
|
||||
{
|
||||
stars.Add(new Star
|
||||
{
|
||||
Alpha = minStarAlpha,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
@ -147,15 +141,12 @@ namespace osu.Game.Graphics.UserInterface
|
||||
{
|
||||
Size = new Vector2(star_size);
|
||||
|
||||
Children = new[]
|
||||
Child = Icon = new SpriteIcon
|
||||
{
|
||||
Icon = new SpriteIcon
|
||||
{
|
||||
Size = new Vector2(star_size),
|
||||
Icon = FontAwesome.fa_star,
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
}
|
||||
Size = new Vector2(star_size),
|
||||
Icon = FontAwesome.fa_star,
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -14,7 +14,7 @@ namespace osu.Game.Input.Bindings
|
||||
/// A KeyBindingInputManager with a database backing for custom overrides.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of the custom action.</typeparam>
|
||||
public abstract class DatabasedKeyBindingInputManager<T> : KeyBindingInputManager<T>
|
||||
public class DatabasedKeyBindingInputManager<T> : KeyBindingContainer<T>
|
||||
where T : struct
|
||||
{
|
||||
private readonly RulesetInfo ruleset;
|
||||
@ -31,7 +31,7 @@ namespace osu.Game.Input.Bindings
|
||||
/// <param name="ruleset">A reference to identify the current <see cref="Ruleset"/>. Used to lookup mappings. Null for global mappings.</param>
|
||||
/// <param name="variant">An optional variant for the specified <see cref="Ruleset"/>. Used when a ruleset has more than one possible keyboard layouts.</param>
|
||||
/// <param name="simultaneousMode">Specify how to deal with multiple matches of <see cref="KeyCombination"/>s and <see cref="T"/>s.</param>
|
||||
protected DatabasedKeyBindingInputManager(RulesetInfo ruleset = null, int? variant = null, SimultaneousBindingMode simultaneousMode = SimultaneousBindingMode.None)
|
||||
public DatabasedKeyBindingInputManager(RulesetInfo ruleset = null, int? variant = null, SimultaneousBindingMode simultaneousMode = SimultaneousBindingMode.None)
|
||||
: base(simultaneousMode)
|
||||
{
|
||||
this.ruleset = ruleset;
|
||||
|
@ -27,7 +27,7 @@ namespace osu.Game.Input
|
||||
}
|
||||
}
|
||||
|
||||
public void Register(KeyBindingInputManager manager) => insertDefaults(manager.DefaultKeyBindings);
|
||||
public void Register(KeyBindingContainer manager) => insertDefaults(manager.DefaultKeyBindings);
|
||||
|
||||
private void insertDefaults(IEnumerable<KeyBinding> defaults, int? rulesetId = null, int? variant = null)
|
||||
{
|
||||
|
307
osu.Game/Migrations/20171209034410_AddRulesetInfoShortName.Designer.cs
generated
Normal file
307
osu.Game/Migrations/20171209034410_AddRulesetInfoShortName.Designer.cs
generated
Normal file
@ -0,0 +1,307 @@
|
||||
// <auto-generated />
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Metadata;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Storage;
|
||||
using osu.Game.Database;
|
||||
using System;
|
||||
|
||||
namespace osu.Game.Migrations
|
||||
{
|
||||
[DbContext(typeof(OsuDbContext))]
|
||||
[Migration("20171209034410_AddRulesetInfoShortName")]
|
||||
partial class AddRulesetInfoShortName
|
||||
{
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "2.0.0-rtm-26452");
|
||||
|
||||
modelBuilder.Entity("osu.Game.Beatmaps.BeatmapDifficulty", b =>
|
||||
{
|
||||
b.Property<int>("ID")
|
||||
.ValueGeneratedOnAdd();
|
||||
|
||||
b.Property<float>("ApproachRate");
|
||||
|
||||
b.Property<float>("CircleSize");
|
||||
|
||||
b.Property<float>("DrainRate");
|
||||
|
||||
b.Property<float>("OverallDifficulty");
|
||||
|
||||
b.Property<float>("SliderMultiplier");
|
||||
|
||||
b.Property<float>("SliderTickRate");
|
||||
|
||||
b.HasKey("ID");
|
||||
|
||||
b.ToTable("BeatmapDifficulty");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("osu.Game.Beatmaps.BeatmapInfo", b =>
|
||||
{
|
||||
b.Property<int>("ID")
|
||||
.ValueGeneratedOnAdd();
|
||||
|
||||
b.Property<int>("AudioLeadIn");
|
||||
|
||||
b.Property<int>("BaseDifficultyID");
|
||||
|
||||
b.Property<int>("BeatDivisor");
|
||||
|
||||
b.Property<int>("BeatmapSetInfoID");
|
||||
|
||||
b.Property<bool>("Countdown");
|
||||
|
||||
b.Property<double>("DistanceSpacing");
|
||||
|
||||
b.Property<int>("GridSize");
|
||||
|
||||
b.Property<string>("Hash");
|
||||
|
||||
b.Property<bool>("Hidden");
|
||||
|
||||
b.Property<bool>("LetterboxInBreaks");
|
||||
|
||||
b.Property<string>("MD5Hash");
|
||||
|
||||
b.Property<int?>("MetadataID");
|
||||
|
||||
b.Property<int?>("OnlineBeatmapID");
|
||||
|
||||
b.Property<string>("Path");
|
||||
|
||||
b.Property<int>("RulesetID");
|
||||
|
||||
b.Property<bool>("SpecialStyle");
|
||||
|
||||
b.Property<float>("StackLeniency");
|
||||
|
||||
b.Property<double>("StarDifficulty");
|
||||
|
||||
b.Property<string>("StoredBookmarks");
|
||||
|
||||
b.Property<double>("TimelineZoom");
|
||||
|
||||
b.Property<string>("Version");
|
||||
|
||||
b.Property<bool>("WidescreenStoryboard");
|
||||
|
||||
b.HasKey("ID");
|
||||
|
||||
b.HasIndex("BaseDifficultyID");
|
||||
|
||||
b.HasIndex("BeatmapSetInfoID");
|
||||
|
||||
b.HasIndex("Hash")
|
||||
.IsUnique();
|
||||
|
||||
b.HasIndex("MD5Hash")
|
||||
.IsUnique();
|
||||
|
||||
b.HasIndex("MetadataID");
|
||||
|
||||
b.HasIndex("OnlineBeatmapID")
|
||||
.IsUnique();
|
||||
|
||||
b.HasIndex("RulesetID");
|
||||
|
||||
b.ToTable("BeatmapInfo");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("osu.Game.Beatmaps.BeatmapMetadata", b =>
|
||||
{
|
||||
b.Property<int>("ID")
|
||||
.ValueGeneratedOnAdd();
|
||||
|
||||
b.Property<string>("Artist");
|
||||
|
||||
b.Property<string>("ArtistUnicode");
|
||||
|
||||
b.Property<string>("AudioFile");
|
||||
|
||||
b.Property<string>("AuthorString")
|
||||
.HasColumnName("Author");
|
||||
|
||||
b.Property<string>("BackgroundFile");
|
||||
|
||||
b.Property<int>("PreviewTime");
|
||||
|
||||
b.Property<string>("Source");
|
||||
|
||||
b.Property<string>("Tags");
|
||||
|
||||
b.Property<string>("Title");
|
||||
|
||||
b.Property<string>("TitleUnicode");
|
||||
|
||||
b.HasKey("ID");
|
||||
|
||||
b.ToTable("BeatmapMetadata");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("osu.Game.Beatmaps.BeatmapSetFileInfo", b =>
|
||||
{
|
||||
b.Property<int>("ID")
|
||||
.ValueGeneratedOnAdd();
|
||||
|
||||
b.Property<int>("BeatmapSetInfoID");
|
||||
|
||||
b.Property<int>("FileInfoID");
|
||||
|
||||
b.Property<string>("Filename")
|
||||
.IsRequired();
|
||||
|
||||
b.HasKey("ID");
|
||||
|
||||
b.HasIndex("BeatmapSetInfoID");
|
||||
|
||||
b.HasIndex("FileInfoID");
|
||||
|
||||
b.ToTable("BeatmapSetFileInfo");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("osu.Game.Beatmaps.BeatmapSetInfo", b =>
|
||||
{
|
||||
b.Property<int>("ID")
|
||||
.ValueGeneratedOnAdd();
|
||||
|
||||
b.Property<bool>("DeletePending");
|
||||
|
||||
b.Property<string>("Hash");
|
||||
|
||||
b.Property<int?>("MetadataID");
|
||||
|
||||
b.Property<int?>("OnlineBeatmapSetID");
|
||||
|
||||
b.Property<bool>("Protected");
|
||||
|
||||
b.HasKey("ID");
|
||||
|
||||
b.HasIndex("DeletePending");
|
||||
|
||||
b.HasIndex("Hash")
|
||||
.IsUnique();
|
||||
|
||||
b.HasIndex("MetadataID");
|
||||
|
||||
b.HasIndex("OnlineBeatmapSetID")
|
||||
.IsUnique();
|
||||
|
||||
b.ToTable("BeatmapSetInfo");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("osu.Game.Input.Bindings.DatabasedKeyBinding", b =>
|
||||
{
|
||||
b.Property<int>("ID")
|
||||
.ValueGeneratedOnAdd();
|
||||
|
||||
b.Property<int>("IntAction")
|
||||
.HasColumnName("Action");
|
||||
|
||||
b.Property<string>("KeysString")
|
||||
.HasColumnName("Keys");
|
||||
|
||||
b.Property<int?>("RulesetID");
|
||||
|
||||
b.Property<int?>("Variant");
|
||||
|
||||
b.HasKey("ID");
|
||||
|
||||
b.HasIndex("IntAction");
|
||||
|
||||
b.HasIndex("Variant");
|
||||
|
||||
b.ToTable("KeyBinding");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("osu.Game.IO.FileInfo", b =>
|
||||
{
|
||||
b.Property<int>("ID")
|
||||
.ValueGeneratedOnAdd();
|
||||
|
||||
b.Property<string>("Hash");
|
||||
|
||||
b.Property<int>("ReferenceCount");
|
||||
|
||||
b.HasKey("ID");
|
||||
|
||||
b.HasIndex("Hash")
|
||||
.IsUnique();
|
||||
|
||||
b.HasIndex("ReferenceCount");
|
||||
|
||||
b.ToTable("FileInfo");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("osu.Game.Rulesets.RulesetInfo", b =>
|
||||
{
|
||||
b.Property<int?>("ID")
|
||||
.ValueGeneratedOnAdd();
|
||||
|
||||
b.Property<bool>("Available");
|
||||
|
||||
b.Property<string>("InstantiationInfo");
|
||||
|
||||
b.Property<string>("Name");
|
||||
|
||||
b.Property<string>("ShortName");
|
||||
|
||||
b.HasKey("ID");
|
||||
|
||||
b.HasIndex("Available");
|
||||
|
||||
b.HasIndex("ShortName")
|
||||
.IsUnique();
|
||||
|
||||
b.ToTable("RulesetInfo");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("osu.Game.Beatmaps.BeatmapInfo", b =>
|
||||
{
|
||||
b.HasOne("osu.Game.Beatmaps.BeatmapDifficulty", "BaseDifficulty")
|
||||
.WithMany()
|
||||
.HasForeignKey("BaseDifficultyID")
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
|
||||
b.HasOne("osu.Game.Beatmaps.BeatmapSetInfo", "BeatmapSet")
|
||||
.WithMany("Beatmaps")
|
||||
.HasForeignKey("BeatmapSetInfoID")
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
|
||||
b.HasOne("osu.Game.Beatmaps.BeatmapMetadata", "Metadata")
|
||||
.WithMany("Beatmaps")
|
||||
.HasForeignKey("MetadataID");
|
||||
|
||||
b.HasOne("osu.Game.Rulesets.RulesetInfo", "Ruleset")
|
||||
.WithMany()
|
||||
.HasForeignKey("RulesetID")
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("osu.Game.Beatmaps.BeatmapSetFileInfo", b =>
|
||||
{
|
||||
b.HasOne("osu.Game.Beatmaps.BeatmapSetInfo")
|
||||
.WithMany("Files")
|
||||
.HasForeignKey("BeatmapSetInfoID")
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
|
||||
b.HasOne("osu.Game.IO.FileInfo", "FileInfo")
|
||||
.WithMany()
|
||||
.HasForeignKey("FileInfoID")
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("osu.Game.Beatmaps.BeatmapSetInfo", b =>
|
||||
{
|
||||
b.HasOne("osu.Game.Beatmaps.BeatmapMetadata", "Metadata")
|
||||
.WithMany("BeatmapSets")
|
||||
.HasForeignKey("MetadataID");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,35 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace osu.Game.Migrations
|
||||
{
|
||||
public partial class AddRulesetInfoShortName : Migration
|
||||
{
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AddColumn<string>(
|
||||
name: "ShortName",
|
||||
table: "RulesetInfo",
|
||||
type: "TEXT",
|
||||
nullable: true);
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_RulesetInfo_ShortName",
|
||||
table: "RulesetInfo",
|
||||
column: "ShortName",
|
||||
unique: true);
|
||||
}
|
||||
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropIndex(
|
||||
name: "IX_RulesetInfo_ShortName",
|
||||
table: "RulesetInfo");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "ShortName",
|
||||
table: "RulesetInfo");
|
||||
}
|
||||
}
|
||||
}
|
@ -247,10 +247,15 @@ namespace osu.Game.Migrations
|
||||
|
||||
b.Property<string>("Name");
|
||||
|
||||
b.Property<string>("ShortName");
|
||||
|
||||
b.HasKey("ID");
|
||||
|
||||
b.HasIndex("Available");
|
||||
|
||||
b.HasIndex("ShortName")
|
||||
.IsUnique();
|
||||
|
||||
b.ToTable("RulesetInfo");
|
||||
});
|
||||
|
||||
|
@ -10,7 +10,7 @@ using System;
|
||||
|
||||
namespace osu.Game.Online.API.Requests
|
||||
{
|
||||
public class GetBeatmapSetsResponse : BeatmapMetadata // todo: this is a bit wrong...
|
||||
public class APIResponseBeatmapSet : BeatmapMetadata // todo: this is a bit wrong...
|
||||
{
|
||||
[JsonProperty(@"covers")]
|
||||
private BeatmapSetOnlineCovers covers { get; set; }
|
||||
@ -45,7 +45,7 @@ namespace osu.Game.Online.API.Requests
|
||||
}
|
||||
|
||||
[JsonProperty(@"beatmaps")]
|
||||
private IEnumerable<GetBeatmapSetsBeatmapResponse> beatmaps { get; set; }
|
||||
private IEnumerable<APIResponseBeatmap> beatmaps { get; set; }
|
||||
|
||||
public BeatmapSetInfo ToBeatmapSet(RulesetStore rulesets)
|
||||
{
|
||||
@ -65,11 +65,11 @@ namespace osu.Game.Online.API.Requests
|
||||
Ranked = ranked,
|
||||
LastUpdated = lastUpdated,
|
||||
},
|
||||
Beatmaps = beatmaps.Select(b => b.ToBeatmap(rulesets)).ToList(),
|
||||
Beatmaps = beatmaps?.Select(b => b.ToBeatmap(rulesets)).ToList(),
|
||||
};
|
||||
}
|
||||
|
||||
private class GetBeatmapSetsBeatmapResponse : BeatmapMetadata
|
||||
private class APIResponseBeatmap : BeatmapMetadata
|
||||
{
|
||||
[JsonProperty(@"id")]
|
||||
private int onlineBeatmapID { get; set; }
|
@ -3,7 +3,7 @@
|
||||
|
||||
namespace osu.Game.Online.API.Requests
|
||||
{
|
||||
public class GetBeatmapSetRequest : APIRequest<GetBeatmapSetsResponse>
|
||||
public class GetBeatmapSetRequest : APIRequest<APIResponseBeatmapSet>
|
||||
{
|
||||
private readonly int beatmapSetId;
|
||||
|
||||
|
@ -6,7 +6,7 @@ using System.Collections.Generic;
|
||||
|
||||
namespace osu.Game.Online.API.Requests
|
||||
{
|
||||
public class GetUserBeatmapsRequest : APIRequest<List<GetBeatmapSetsResponse>>
|
||||
public class GetUserBeatmapsRequest : APIRequest<List<APIResponseBeatmapSet>>
|
||||
{
|
||||
private readonly long userId;
|
||||
private readonly int offset;
|
||||
@ -24,7 +24,6 @@ namespace osu.Game.Online.API.Requests
|
||||
|
||||
public enum BeatmapSetType
|
||||
{
|
||||
MostPlayed,
|
||||
Favourite,
|
||||
RankedAndApproved,
|
||||
Unranked,
|
||||
|
@ -0,0 +1,48 @@
|
||||
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using Newtonsoft.Json;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Rulesets;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace osu.Game.Online.API.Requests
|
||||
{
|
||||
public class GetUserMostPlayedBeatmapsRequest : APIRequest<List<MostPlayedBeatmap>>
|
||||
{
|
||||
private readonly long userId;
|
||||
private readonly int offset;
|
||||
|
||||
public GetUserMostPlayedBeatmapsRequest(long userId, int offset = 0)
|
||||
{
|
||||
this.userId = userId;
|
||||
this.offset = offset;
|
||||
}
|
||||
|
||||
protected override string Target => $@"users/{userId}/beatmapsets/most_played?offset={offset}";
|
||||
}
|
||||
|
||||
public class MostPlayedBeatmap
|
||||
{
|
||||
[JsonProperty("beatmap_id")]
|
||||
public int BeatmapID;
|
||||
|
||||
[JsonProperty("count")]
|
||||
public int PlayCount;
|
||||
|
||||
[JsonProperty]
|
||||
private BeatmapInfo beatmap;
|
||||
|
||||
[JsonProperty]
|
||||
private APIResponseBeatmapSet beatmapSet;
|
||||
|
||||
public BeatmapInfo GetBeatmapInfo(RulesetStore rulesets)
|
||||
{
|
||||
BeatmapSetInfo setInfo = beatmapSet.ToBeatmapSet(rulesets);
|
||||
beatmap.BeatmapSet = setInfo;
|
||||
beatmap.OnlineBeatmapSetID = setInfo.OnlineBeatmapSetID;
|
||||
beatmap.Metadata = setInfo.Metadata;
|
||||
return beatmap;
|
||||
}
|
||||
}
|
||||
}
|
@ -9,7 +9,7 @@ using osu.Game.Rulesets;
|
||||
|
||||
namespace osu.Game.Online.API.Requests
|
||||
{
|
||||
public class SearchBeatmapSetsRequest : APIRequest<IEnumerable<GetBeatmapSetsResponse>>
|
||||
public class SearchBeatmapSetsRequest : APIRequest<IEnumerable<APIResponseBeatmapSet>>
|
||||
{
|
||||
private readonly string query;
|
||||
private readonly RulesetInfo ruleset;
|
||||
|
@ -14,10 +14,10 @@ namespace osu.Game.Overlays.BeatmapSet
|
||||
public DownloadButton(string title, string subtitle)
|
||||
{
|
||||
Width = 120;
|
||||
RelativeSizeAxes = Axes.Y;
|
||||
|
||||
Child = new Container
|
||||
Add(new Container
|
||||
{
|
||||
Depth = -1,
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Padding = new MarginPadding { Horizontal = 10 },
|
||||
Children = new Drawable[]
|
||||
@ -53,7 +53,7 @@ namespace osu.Game.Overlays.BeatmapSet
|
||||
Margin = new MarginPadding { Right = 5 },
|
||||
},
|
||||
},
|
||||
};
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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 osu.Framework.Allocation;
|
||||
using osu.Framework.Configuration;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
@ -15,13 +16,12 @@ namespace osu.Game.Overlays.BeatmapSet
|
||||
{
|
||||
public readonly Bindable<bool> Favourited = new Bindable<bool>();
|
||||
|
||||
public FavouriteButton()
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
RelativeSizeAxes = Axes.Y;
|
||||
|
||||
Container pink;
|
||||
SpriteIcon icon;
|
||||
Children = new Drawable[]
|
||||
AddRange(new Drawable[]
|
||||
{
|
||||
pink = new Container
|
||||
{
|
||||
@ -51,7 +51,7 @@ namespace osu.Game.Overlays.BeatmapSet
|
||||
Size = new Vector2(18),
|
||||
Shadow = false,
|
||||
},
|
||||
};
|
||||
});
|
||||
|
||||
Favourited.ValueChanged += value =>
|
||||
{
|
||||
|
@ -2,44 +2,27 @@
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.Backgrounds;
|
||||
using osu.Game.Graphics.Containers;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
using osu.Framework.Allocation;
|
||||
|
||||
namespace osu.Game.Overlays.BeatmapSet
|
||||
{
|
||||
public class HeaderButton : OsuClickableContainer
|
||||
public class HeaderButton : TriangleButton
|
||||
{
|
||||
private readonly Container content;
|
||||
|
||||
protected override Container<Drawable> Content => content;
|
||||
|
||||
public HeaderButton()
|
||||
{
|
||||
CornerRadius = 3;
|
||||
Masking = true;
|
||||
Height = 0;
|
||||
RelativeSizeAxes = Axes.Y;
|
||||
}
|
||||
|
||||
InternalChildren = new Drawable[]
|
||||
{
|
||||
new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Colour = OsuColour.FromHex(@"094c5f"),
|
||||
},
|
||||
new Triangles
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
ColourLight = OsuColour.FromHex(@"0f7c9b"),
|
||||
ColourDark = OsuColour.FromHex(@"094c5f"),
|
||||
TriangleScale = 1.5f,
|
||||
},
|
||||
content = new Container
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
},
|
||||
};
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
BackgroundColour = OsuColour.FromHex(@"094c5f");
|
||||
Triangles.ColourLight = OsuColour.FromHex(@"0f7c9b");
|
||||
Triangles.ColourDark = OsuColour.FromHex(@"094c5f");
|
||||
Triangles.TriangleScale = 1.5f;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -117,7 +117,7 @@ namespace osu.Game.Overlays.Direct
|
||||
{
|
||||
base.Update();
|
||||
|
||||
if (PreviewPlaying && Preview != null)
|
||||
if (PreviewPlaying && Preview != null && Preview.IsLoaded)
|
||||
{
|
||||
PreviewBar.Width = (float)(Preview.CurrentTime / Preview.Length);
|
||||
}
|
||||
|
@ -105,6 +105,7 @@ namespace osu.Game.Overlays.Direct
|
||||
|
||||
public enum DirectSortCriteria
|
||||
{
|
||||
Relevance,
|
||||
Title,
|
||||
Artist,
|
||||
Creator,
|
||||
|
@ -43,6 +43,7 @@ namespace osu.Game.Overlays
|
||||
protected override SearchableListFilterControl<DirectSortCriteria, RankStatus> CreateFilterControl() => new FilterControl();
|
||||
|
||||
private IEnumerable<BeatmapSetInfo> beatmapSets;
|
||||
|
||||
public IEnumerable<BeatmapSetInfo> BeatmapSets
|
||||
{
|
||||
get { return beatmapSets; }
|
||||
@ -69,6 +70,7 @@ namespace osu.Game.Overlays
|
||||
}
|
||||
|
||||
private ResultCounts resultAmounts;
|
||||
|
||||
public ResultCounts ResultAmounts
|
||||
{
|
||||
get { return resultAmounts; }
|
||||
@ -115,7 +117,23 @@ namespace osu.Game.Overlays
|
||||
},
|
||||
};
|
||||
|
||||
Filter.Search.Current.ValueChanged += text => { if (text != string.Empty) Header.Tabs.Current.Value = DirectTab.Search; };
|
||||
Filter.Search.Current.ValueChanged += text =>
|
||||
{
|
||||
if (text != string.Empty)
|
||||
{
|
||||
Header.Tabs.Current.Value = DirectTab.Search;
|
||||
|
||||
if (Filter.Tabs.Current.Value == DirectSortCriteria.Ranked)
|
||||
Filter.Tabs.Current.Value = DirectSortCriteria.Relevance;
|
||||
}
|
||||
else
|
||||
{
|
||||
Header.Tabs.Current.Value = DirectTab.NewestMaps;
|
||||
|
||||
if (Filter.Tabs.Current.Value == DirectSortCriteria.Relevance)
|
||||
Filter.Tabs.Current.Value = DirectSortCriteria.Ranked;
|
||||
}
|
||||
};
|
||||
((FilterControl)Filter).Ruleset.ValueChanged += ruleset => Scheduler.AddOnce(updateSearch);
|
||||
Filter.DisplayStyleControl.DisplayStyle.ValueChanged += recreatePanels;
|
||||
Filter.DisplayStyleControl.Dropdown.Current.ValueChanged += rankStatus => Scheduler.AddOnce(updateSearch);
|
||||
@ -271,9 +289,9 @@ namespace osu.Game.Overlays
|
||||
if (Header.Tabs.Current.Value == DirectTab.Search && (Filter.Search.Text == string.Empty || currentQuery == string.Empty)) return;
|
||||
|
||||
getSetsRequest = new SearchBeatmapSetsRequest(currentQuery.Value ?? string.Empty,
|
||||
((FilterControl)Filter).Ruleset.Value,
|
||||
Filter.DisplayStyleControl.Dropdown.Current.Value,
|
||||
Filter.Tabs.Current.Value); //todo: sort direction (?)
|
||||
((FilterControl)Filter).Ruleset.Value,
|
||||
Filter.DisplayStyleControl.Dropdown.Current.Value,
|
||||
Filter.Tabs.Current.Value); //todo: sort direction (?)
|
||||
|
||||
getSetsRequest.Success += response =>
|
||||
{
|
||||
|
@ -12,7 +12,7 @@ namespace osu.Game.Overlays.KeyBinding
|
||||
public override FontAwesome Icon => FontAwesome.fa_osu_hot;
|
||||
public override string Header => "Global";
|
||||
|
||||
public GlobalKeyBindingsSection(KeyBindingInputManager manager)
|
||||
public GlobalKeyBindingsSection(KeyBindingContainer manager)
|
||||
{
|
||||
Add(new DefaultBindingsSubsection(manager));
|
||||
}
|
||||
@ -21,7 +21,7 @@ namespace osu.Game.Overlays.KeyBinding
|
||||
{
|
||||
protected override string Header => string.Empty;
|
||||
|
||||
public DefaultBindingsSubsection(KeyBindingInputManager manager)
|
||||
public DefaultBindingsSubsection(KeyBindingContainer manager)
|
||||
: base(null)
|
||||
{
|
||||
Defaults = manager.DefaultKeyBindings;
|
||||
|
@ -17,22 +17,21 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Game.Rulesets;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
|
||||
namespace osu.Game.Overlays.Mods
|
||||
{
|
||||
public class ModSelectOverlay : WaveOverlayContainer
|
||||
{
|
||||
private const int button_duration = 700;
|
||||
private const int ranked_multiplier_duration = 700;
|
||||
private const float content_width = 0.8f;
|
||||
|
||||
private Color4 lowMultiplierColour, highMultiplierColour;
|
||||
protected Color4 LowMultiplierColour, HighMultiplierColour;
|
||||
|
||||
private readonly OsuSpriteText rankedLabel;
|
||||
private readonly OsuSpriteText multiplierLabel;
|
||||
private readonly FillFlowContainer rankedMultiplerContainer;
|
||||
protected readonly TriangleButton DeselectAllButton;
|
||||
protected readonly OsuSpriteText MultiplierLabel;
|
||||
private readonly FillFlowContainer footerContainer;
|
||||
|
||||
private readonly FillFlowContainer<ModSection> modSectionsContainer;
|
||||
protected readonly FillFlowContainer<ModSection> ModSectionsContainer;
|
||||
|
||||
public readonly Bindable<IEnumerable<Mod>> SelectedMods = new Bindable<IEnumerable<Mod>>();
|
||||
|
||||
@ -42,7 +41,7 @@ namespace osu.Game.Overlays.Mods
|
||||
{
|
||||
var instance = newRuleset.CreateInstance();
|
||||
|
||||
foreach (ModSection section in modSectionsContainer.Children)
|
||||
foreach (ModSection section in ModSectionsContainer.Children)
|
||||
section.Mods = instance.GetModsFor(section.ModType);
|
||||
refreshSelectedMods();
|
||||
}
|
||||
@ -50,8 +49,8 @@ namespace osu.Game.Overlays.Mods
|
||||
[BackgroundDependencyLoader(permitNulls: true)]
|
||||
private void load(OsuColour colours, OsuGame osu, RulesetStore rulesets)
|
||||
{
|
||||
lowMultiplierColour = colours.Red;
|
||||
highMultiplierColour = colours.Green;
|
||||
LowMultiplierColour = colours.Red;
|
||||
HighMultiplierColour = colours.Green;
|
||||
|
||||
if (osu != null)
|
||||
Ruleset.BindTo(osu.Ruleset);
|
||||
@ -66,14 +65,14 @@ namespace osu.Game.Overlays.Mods
|
||||
{
|
||||
base.PopOut();
|
||||
|
||||
rankedMultiplerContainer.MoveToX(rankedMultiplerContainer.DrawSize.X, APPEAR_DURATION, Easing.InSine);
|
||||
rankedMultiplerContainer.FadeOut(APPEAR_DURATION, Easing.InSine);
|
||||
footerContainer.MoveToX(footerContainer.DrawSize.X, DISAPPEAR_DURATION, Easing.InSine);
|
||||
footerContainer.FadeOut(DISAPPEAR_DURATION, Easing.InSine);
|
||||
|
||||
foreach (ModSection section in modSectionsContainer.Children)
|
||||
foreach (ModSection section in ModSectionsContainer.Children)
|
||||
{
|
||||
section.ButtonsContainer.TransformSpacingTo(new Vector2(100f, 0f), APPEAR_DURATION, Easing.InSine);
|
||||
section.ButtonsContainer.MoveToX(100f, APPEAR_DURATION, Easing.InSine);
|
||||
section.ButtonsContainer.FadeOut(APPEAR_DURATION, Easing.InSine);
|
||||
section.ButtonsContainer.TransformSpacingTo(new Vector2(100f, 0f), DISAPPEAR_DURATION, Easing.InSine);
|
||||
section.ButtonsContainer.MoveToX(100f, DISAPPEAR_DURATION, Easing.InSine);
|
||||
section.ButtonsContainer.FadeOut(DISAPPEAR_DURATION, Easing.InSine);
|
||||
}
|
||||
}
|
||||
|
||||
@ -81,27 +80,28 @@ namespace osu.Game.Overlays.Mods
|
||||
{
|
||||
base.PopIn();
|
||||
|
||||
rankedMultiplerContainer.MoveToX(0, ranked_multiplier_duration, Easing.OutQuint);
|
||||
rankedMultiplerContainer.FadeIn(ranked_multiplier_duration, Easing.OutQuint);
|
||||
footerContainer.MoveToX(0, APPEAR_DURATION, Easing.OutQuint);
|
||||
footerContainer.FadeIn(APPEAR_DURATION, Easing.OutQuint);
|
||||
|
||||
foreach (ModSection section in modSectionsContainer.Children)
|
||||
foreach (ModSection section in ModSectionsContainer.Children)
|
||||
{
|
||||
section.ButtonsContainer.TransformSpacingTo(new Vector2(50f, 0f), button_duration, Easing.OutQuint);
|
||||
section.ButtonsContainer.MoveToX(0, button_duration, Easing.OutQuint);
|
||||
section.ButtonsContainer.FadeIn(button_duration, Easing.OutQuint);
|
||||
section.ButtonsContainer.TransformSpacingTo(new Vector2(50f, 0f), APPEAR_DURATION, Easing.OutQuint);
|
||||
section.ButtonsContainer.MoveToX(0, APPEAR_DURATION, Easing.OutQuint);
|
||||
section.ButtonsContainer.FadeIn(APPEAR_DURATION, Easing.OutQuint);
|
||||
}
|
||||
}
|
||||
|
||||
public void DeselectAll()
|
||||
{
|
||||
foreach (ModSection section in modSectionsContainer.Children)
|
||||
foreach (ModSection section in ModSectionsContainer.Children)
|
||||
section.DeselectAll();
|
||||
refreshSelectedMods();
|
||||
}
|
||||
|
||||
public void DeselectTypes(Type[] modTypes)
|
||||
{
|
||||
if (modTypes.Length == 0) return;
|
||||
foreach (ModSection section in modSectionsContainer.Children)
|
||||
foreach (ModSection section in ModSectionsContainer.Children)
|
||||
section.DeselectTypes(modTypes);
|
||||
}
|
||||
|
||||
@ -114,7 +114,7 @@ namespace osu.Game.Overlays.Mods
|
||||
|
||||
private void refreshSelectedMods()
|
||||
{
|
||||
SelectedMods.Value = modSectionsContainer.Children.SelectMany(s => s.SelectedMods).ToArray();
|
||||
SelectedMods.Value = ModSectionsContainer.Children.SelectMany(s => s.SelectedMods).ToArray();
|
||||
|
||||
double multiplier = 1.0;
|
||||
bool ranked = true;
|
||||
@ -129,16 +129,16 @@ namespace osu.Game.Overlays.Mods
|
||||
// 1.05x
|
||||
// 1.20x
|
||||
|
||||
multiplierLabel.Text = $"{multiplier:N2}x";
|
||||
string rankedString = ranked ? "Ranked" : "Unranked";
|
||||
rankedLabel.Text = $@"{rankedString}, Score Multiplier: ";
|
||||
MultiplierLabel.Text = $"{multiplier:N2}x";
|
||||
if (!ranked)
|
||||
MultiplierLabel.Text += " (Unranked)";
|
||||
|
||||
if (multiplier > 1.0)
|
||||
multiplierLabel.FadeColour(highMultiplierColour, 200);
|
||||
MultiplierLabel.FadeColour(HighMultiplierColour, 200);
|
||||
else if (multiplier < 1.0)
|
||||
multiplierLabel.FadeColour(lowMultiplierColour, 200);
|
||||
MultiplierLabel.FadeColour(LowMultiplierColour, 200);
|
||||
else
|
||||
multiplierLabel.FadeColour(Color4.White, 200);
|
||||
MultiplierLabel.FadeColour(Color4.White, 200);
|
||||
}
|
||||
|
||||
public ModSelectOverlay()
|
||||
@ -232,7 +232,7 @@ namespace osu.Game.Overlays.Mods
|
||||
},
|
||||
new OsuSpriteText
|
||||
{
|
||||
Text = @"Others are just for fun",
|
||||
Text = @"Others are just for fun.",
|
||||
TextSize = 18,
|
||||
Shadow = true,
|
||||
},
|
||||
@ -241,7 +241,7 @@ namespace osu.Game.Overlays.Mods
|
||||
},
|
||||
},
|
||||
// Body
|
||||
modSectionsContainer = new FillFlowContainer<ModSection>
|
||||
ModSectionsContainer = new FillFlowContainer<ModSection>
|
||||
{
|
||||
Origin = Anchor.TopCentre,
|
||||
Anchor = Anchor.TopCentre,
|
||||
@ -289,7 +289,7 @@ namespace osu.Game.Overlays.Mods
|
||||
Colour = new Color4(172, 20, 116, 255),
|
||||
Alpha = 0.5f,
|
||||
},
|
||||
rankedMultiplerContainer = new FillFlowContainer
|
||||
footerContainer = new FillFlowContainer
|
||||
{
|
||||
Origin = Anchor.BottomCentre,
|
||||
Anchor = Anchor.BottomCentre,
|
||||
@ -299,26 +299,42 @@ namespace osu.Game.Overlays.Mods
|
||||
Direction = FillDirection.Horizontal,
|
||||
Padding = new MarginPadding
|
||||
{
|
||||
Top = 20,
|
||||
Bottom = 20,
|
||||
Vertical = 15
|
||||
},
|
||||
Children = new Drawable[]
|
||||
{
|
||||
rankedLabel = new OsuSpriteText
|
||||
DeselectAllButton = new TriangleButton
|
||||
{
|
||||
Text = @"Ranked, Score Multiplier: ",
|
||||
Width = 180,
|
||||
Text = "Deselect All",
|
||||
Action = DeselectAll,
|
||||
Margin = new MarginPadding
|
||||
{
|
||||
Right = 20
|
||||
}
|
||||
},
|
||||
new OsuSpriteText
|
||||
{
|
||||
Text = @"Score Multiplier: ",
|
||||
TextSize = 30,
|
||||
Shadow = true,
|
||||
Margin = new MarginPadding
|
||||
{
|
||||
Top = 5
|
||||
}
|
||||
},
|
||||
multiplierLabel = new OsuSpriteText
|
||||
MultiplierLabel = new OsuSpriteText
|
||||
{
|
||||
Font = @"Exo2.0-Bold",
|
||||
Text = @"1.00x",
|
||||
TextSize = 30,
|
||||
Shadow = true,
|
||||
},
|
||||
},
|
||||
},
|
||||
Margin = new MarginPadding
|
||||
{
|
||||
Top = 5
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -251,7 +251,7 @@ namespace osu.Game.Overlays
|
||||
|
||||
playButton.Icon = track.IsRunning ? FontAwesome.fa_pause_circle_o : FontAwesome.fa_play_circle_o;
|
||||
|
||||
if (track.HasCompleted && !beatmapBacking.Disabled && playlist.BeatmapSets.Any())
|
||||
if (track.HasCompleted && !track.Looping && !beatmapBacking.Disabled && playlist.BeatmapSets.Any())
|
||||
next();
|
||||
}
|
||||
else
|
||||
|
@ -22,6 +22,8 @@ namespace osu.Game.Overlays.Notifications
|
||||
}
|
||||
}
|
||||
|
||||
public string CompletionText { get; set; } = "Task has completed!";
|
||||
|
||||
public float Progress
|
||||
{
|
||||
get { return progressBar.Progress; }
|
||||
@ -87,7 +89,7 @@ namespace osu.Game.Overlays.Notifications
|
||||
protected virtual Notification CreateCompletionNotification() => new ProgressCompletionNotification
|
||||
{
|
||||
Activated = CompletionClickAction,
|
||||
Text = "Task has completed!"
|
||||
Text = CompletionText
|
||||
};
|
||||
|
||||
protected virtual void Completed()
|
||||
|
@ -53,6 +53,7 @@ namespace osu.Game.Overlays.Profile
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
Height = cover_height,
|
||||
Masking = true,
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new Box
|
||||
@ -324,8 +325,7 @@ namespace osu.Game.Overlays.Profile
|
||||
FillMode = FillMode.Fill,
|
||||
OnLoadComplete = d => d.FadeInFromZero(200),
|
||||
Depth = float.MaxValue,
|
||||
},
|
||||
coverContainer.Add);
|
||||
}, coverContainer.Add);
|
||||
|
||||
if (user.IsSupporter) supporterTag.Show();
|
||||
|
||||
@ -382,7 +382,7 @@ namespace osu.Game.Overlays.Profile
|
||||
}
|
||||
|
||||
tryAddInfoRightLine(FontAwesome.fa_map_marker, user.Location);
|
||||
tryAddInfoRightLine(FontAwesome.fa_heart_o, user.Intrerests);
|
||||
tryAddInfoRightLine(FontAwesome.fa_heart_o, user.Interests);
|
||||
tryAddInfoRightLine(FontAwesome.fa_suitcase, user.Occupation);
|
||||
infoTextRight.NewParagraph();
|
||||
if (!string.IsNullOrEmpty(user.Twitter))
|
||||
@ -514,7 +514,7 @@ namespace osu.Game.Overlays.Profile
|
||||
{
|
||||
set
|
||||
{
|
||||
if(value != null)
|
||||
if (value != null)
|
||||
content.Action = () => Process.Start(value);
|
||||
}
|
||||
}
|
||||
|
@ -81,12 +81,12 @@ namespace osu.Game.Overlays.Profile
|
||||
{
|
||||
rankText.Text = user.Statistics.Rank > 0 ? $"#{user.Statistics.Rank:#,0}" : "no rank";
|
||||
performanceText.Text = user.Statistics.PP != null ? $"{user.Statistics.PP:#,0}pp" : string.Empty;
|
||||
relativeText.Text = $"{user.Country?.FullName} #{user.CountryRank:#,0}";
|
||||
relativeText.Text = user.CountryRank > 0 ? $"{user.Country?.FullName} #{user.CountryRank:#,0}" : $"{user.Country?.FullName}";
|
||||
}
|
||||
|
||||
private void showHistoryRankTexts(int dayIndex)
|
||||
{
|
||||
rankText.Text = $"#{ranks[dayIndex]:#,0}";
|
||||
rankText.Text = ranks[dayIndex] > 0 ? $"#{ranks[dayIndex]:#,0}" : "no rank";
|
||||
dayIndex++;
|
||||
relativeText.Text = dayIndex == ranks.Length ? "Now" : $"{ranks.Length - dayIndex} days ago";
|
||||
//plural should be handled in a general way
|
||||
@ -99,7 +99,7 @@ namespace osu.Game.Overlays.Profile
|
||||
{
|
||||
graph.Colour = colours.Yellow;
|
||||
// use logarithmic coordinates
|
||||
graph.Values = ranks.Select(x => -(float)Math.Log(x));
|
||||
graph.Values = ranks.Select(x => x == 0 ? float.MinValue : -(float)Math.Log(x));
|
||||
graph.SetStaticBallPosition();
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,63 @@
|
||||
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Cursor;
|
||||
using osu.Framework.Localisation;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Graphics.Containers;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
namespace osu.Game.Overlays.Profile.Sections
|
||||
{
|
||||
/// <summary>
|
||||
/// Display artist/title/mapper information, commonly used as the left portion of a profile or score display row (see <see cref="DrawableProfileRow"/>).
|
||||
/// </summary>
|
||||
public class BeatmapMetadataContainer : OsuHoverContainer, IHasTooltip
|
||||
{
|
||||
private readonly BeatmapInfo beatmap;
|
||||
|
||||
public BeatmapMetadataContainer(BeatmapInfo beatmap)
|
||||
{
|
||||
this.beatmap = beatmap;
|
||||
AutoSizeAxes = Axes.Both;
|
||||
TooltipText = $"{beatmap.Metadata.Artist} - {beatmap.Metadata.Title}";
|
||||
}
|
||||
|
||||
public string TooltipText { get; }
|
||||
|
||||
[BackgroundDependencyLoader(true)]
|
||||
private void load(LocalisationEngine locale, BeatmapSetOverlay beatmapSetOverlay)
|
||||
{
|
||||
Action = () =>
|
||||
{
|
||||
if (beatmap.OnlineBeatmapSetID.HasValue) beatmapSetOverlay?.ShowBeatmapSet(beatmap.OnlineBeatmapSetID.Value);
|
||||
};
|
||||
|
||||
Child = new FillFlowContainer
|
||||
{
|
||||
AutoSizeAxes = Axes.Both,
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new OsuSpriteText
|
||||
{
|
||||
Current = locale.GetUnicodePreference(
|
||||
$"{beatmap.Metadata.TitleUnicode ?? beatmap.Metadata.Title} [{beatmap.Version}] ",
|
||||
$"{beatmap.Metadata.Title ?? beatmap.Metadata.TitleUnicode} [{beatmap.Version}] "
|
||||
),
|
||||
TextSize = 15,
|
||||
Font = "Exo2.0-SemiBoldItalic",
|
||||
},
|
||||
new OsuSpriteText
|
||||
{
|
||||
Current = locale.GetUnicodePreference(beatmap.Metadata.ArtistUnicode, beatmap.Metadata.Artist),
|
||||
TextSize = 12,
|
||||
Padding = new MarginPadding { Top = 3 },
|
||||
Font = "Exo2.0-RegularItalic",
|
||||
},
|
||||
},
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
124
osu.Game/Overlays/Profile/Sections/DrawableProfileRow.cs
Normal file
124
osu.Game/Overlays/Profile/Sections/DrawableProfileRow.cs
Normal file
@ -0,0 +1,124 @@
|
||||
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Extensions.Color4Extensions;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Framework.Input;
|
||||
using osu.Game.Graphics;
|
||||
using OpenTK;
|
||||
using OpenTK.Graphics;
|
||||
|
||||
namespace osu.Game.Overlays.Profile.Sections
|
||||
{
|
||||
public abstract class DrawableProfileRow : Container
|
||||
{
|
||||
private const int fade_duration = 200;
|
||||
|
||||
private Box underscoreLine;
|
||||
private readonly Box coloredBackground;
|
||||
private readonly Container background;
|
||||
|
||||
/// <summary>
|
||||
/// A visual element displayed to the left of <see cref="LeftFlowContainer"/> content.
|
||||
/// </summary>
|
||||
protected abstract Drawable CreateLeftVisual();
|
||||
|
||||
protected FillFlowContainer LeftFlowContainer { get; private set; }
|
||||
protected FillFlowContainer RightFlowContainer { get; private set; }
|
||||
|
||||
protected override Container<Drawable> Content { get; }
|
||||
|
||||
protected DrawableProfileRow()
|
||||
{
|
||||
RelativeSizeAxes = Axes.X;
|
||||
Height = 60;
|
||||
InternalChildren = new Drawable[]
|
||||
{
|
||||
background = new Container
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Masking = true,
|
||||
CornerRadius = 3,
|
||||
Alpha = 0,
|
||||
EdgeEffect = new EdgeEffectParameters
|
||||
{
|
||||
Type = EdgeEffectType.Shadow,
|
||||
Offset = new Vector2(0f, 1f),
|
||||
Radius = 1f,
|
||||
Colour = Color4.Black.Opacity(0.2f),
|
||||
},
|
||||
Child = coloredBackground = new Box { RelativeSizeAxes = Axes.Both }
|
||||
},
|
||||
Content = new Container
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Anchor = Anchor.TopCentre,
|
||||
Origin = Anchor.TopCentre,
|
||||
Width = 0.97f,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader(true)]
|
||||
private void load(OsuColour colour)
|
||||
{
|
||||
AddRange(new Drawable[]
|
||||
{
|
||||
underscoreLine = new Box
|
||||
{
|
||||
Anchor = Anchor.BottomCentre,
|
||||
Origin = Anchor.BottomCentre,
|
||||
RelativeSizeAxes = Axes.X,
|
||||
Height = 1,
|
||||
},
|
||||
new FillFlowContainer
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Direction = FillDirection.Horizontal,
|
||||
Children = new[]
|
||||
{
|
||||
CreateLeftVisual(),
|
||||
LeftFlowContainer = new FillFlowContainer
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
AutoSizeAxes = Axes.Y,
|
||||
Anchor = Anchor.CentreLeft,
|
||||
Origin = Anchor.CentreLeft,
|
||||
Margin = new MarginPadding { Left = 10 },
|
||||
Direction = FillDirection.Vertical,
|
||||
},
|
||||
}
|
||||
},
|
||||
RightFlowContainer = new FillFlowContainer
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
AutoSizeAxes = Axes.Y,
|
||||
Anchor = Anchor.CentreRight,
|
||||
Origin = Anchor.CentreRight,
|
||||
Direction = FillDirection.Vertical,
|
||||
},
|
||||
});
|
||||
|
||||
coloredBackground.Colour = underscoreLine.Colour = colour.Gray4;
|
||||
}
|
||||
|
||||
protected override bool OnClick(InputState state) => true;
|
||||
|
||||
protected override bool OnHover(InputState state)
|
||||
{
|
||||
background.FadeIn(fade_duration, Easing.OutQuint);
|
||||
underscoreLine.FadeOut(fade_duration, Easing.OutQuint);
|
||||
return true;
|
||||
}
|
||||
|
||||
protected override void OnHoverLost(InputState state)
|
||||
{
|
||||
background.FadeOut(fade_duration, Easing.OutQuint);
|
||||
underscoreLine.FadeIn(fade_duration, Easing.OutQuint);
|
||||
base.OnHoverLost(state);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,105 @@
|
||||
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Beatmaps.Drawables;
|
||||
using osu.Game.Graphics.Containers;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using OpenTK;
|
||||
|
||||
namespace osu.Game.Overlays.Profile.Sections.Historical
|
||||
{
|
||||
public class DrawableMostPlayedRow : DrawableProfileRow
|
||||
{
|
||||
private readonly BeatmapInfo beatmap;
|
||||
private readonly int playCount;
|
||||
private OsuHoverContainer mapperContainer;
|
||||
|
||||
public DrawableMostPlayedRow(BeatmapInfo beatmap, int playCount)
|
||||
{
|
||||
this.beatmap = beatmap;
|
||||
this.playCount = playCount;
|
||||
}
|
||||
|
||||
protected override Drawable CreateLeftVisual() => new DelayedLoadWrapper(new BeatmapSetCover(beatmap.BeatmapSet, BeatmapSetCoverType.List)
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
FillMode = FillMode.Fit,
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
OnLoadComplete = d => d.FadeInFromZero(500, Easing.OutQuint)
|
||||
})
|
||||
{
|
||||
Origin = Anchor.CentreLeft,
|
||||
Anchor = Anchor.CentreLeft,
|
||||
RelativeSizeAxes = Axes.None,
|
||||
Size = new Vector2(80, 50),
|
||||
};
|
||||
|
||||
[BackgroundDependencyLoader(true)]
|
||||
private void load(UserProfileOverlay profileOverlay)
|
||||
{
|
||||
LeftFlowContainer.Add(new BeatmapMetadataContainer(beatmap));
|
||||
LeftFlowContainer.Add(new FillFlowContainer
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
AutoSizeAxes = Axes.Y,
|
||||
Direction = FillDirection.Horizontal,
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new OsuSpriteText
|
||||
{
|
||||
Text = @"mapped by ",
|
||||
TextSize = 12,
|
||||
},
|
||||
mapperContainer = new OsuHoverContainer
|
||||
{
|
||||
AutoSizeAxes = Axes.Both,
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new OsuSpriteText
|
||||
{
|
||||
Text = beatmap.Metadata.AuthorString,
|
||||
TextSize = 12,
|
||||
Font = @"Exo2.0-MediumItalic"
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
});
|
||||
|
||||
RightFlowContainer.Add(new FillFlowContainer
|
||||
{
|
||||
Anchor = Anchor.TopRight,
|
||||
Origin = Anchor.TopRight,
|
||||
AutoSizeAxes = Axes.Both,
|
||||
Direction = FillDirection.Horizontal,
|
||||
Children = new[]
|
||||
{
|
||||
new OsuSpriteText
|
||||
{
|
||||
Anchor = Anchor.BottomRight,
|
||||
Origin = Anchor.BottomRight,
|
||||
Text = playCount.ToString(),
|
||||
TextSize = 18,
|
||||
Font = @"Exo2.0-SemiBoldItalic"
|
||||
},
|
||||
new OsuSpriteText
|
||||
{
|
||||
Anchor = Anchor.BottomRight,
|
||||
Origin = Anchor.BottomRight,
|
||||
Text = @"times played ",
|
||||
TextSize = 12,
|
||||
Font = @"Exo2.0-RegularItalic"
|
||||
},
|
||||
}
|
||||
});
|
||||
|
||||
if (profileOverlay != null)
|
||||
mapperContainer.Action = () => profileOverlay.ShowUser(beatmap.BeatmapSet.Metadata.Author);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,51 @@
|
||||
// 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.Linq;
|
||||
using osu.Framework.Configuration;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Game.Online.API.Requests;
|
||||
using osu.Game.Users;
|
||||
|
||||
namespace osu.Game.Overlays.Profile.Sections.Historical
|
||||
{
|
||||
public class PaginatedMostPlayedBeatmapContainer : PaginatedContainer
|
||||
{
|
||||
public PaginatedMostPlayedBeatmapContainer(Bindable<User> user)
|
||||
:base(user, "Most Played Beatmaps", "No records. :(")
|
||||
{
|
||||
ItemsPerPage = 5;
|
||||
|
||||
ItemsContainer.Direction = FillDirection.Vertical;
|
||||
}
|
||||
|
||||
protected override void ShowMore()
|
||||
{
|
||||
base.ShowMore();
|
||||
|
||||
var req = new GetUserMostPlayedBeatmapsRequest(User.Value.Id, VisiblePages++ * ItemsPerPage);
|
||||
|
||||
req.Success += beatmaps =>
|
||||
{
|
||||
ShowMoreButton.FadeTo(beatmaps.Count == ItemsPerPage ? 1 : 0);
|
||||
ShowMoreLoading.Hide();
|
||||
|
||||
if (!beatmaps.Any() && VisiblePages == 1)
|
||||
{
|
||||
MissingText.Show();
|
||||
return;
|
||||
}
|
||||
|
||||
MissingText.Hide();
|
||||
|
||||
foreach (var beatmap in beatmaps)
|
||||
{
|
||||
ItemsContainer.Add(new DrawableMostPlayedRow(beatmap.GetBeatmapInfo(Rulesets), beatmap.PlayCount));
|
||||
}
|
||||
};
|
||||
|
||||
Api.Queue(req);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,7 +1,9 @@
|
||||
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Game.Online.API.Requests;
|
||||
using osu.Game.Overlays.Profile.Sections.Historical;
|
||||
using osu.Game.Overlays.Profile.Sections.Ranks;
|
||||
|
||||
namespace osu.Game.Overlays.Profile.Sections
|
||||
@ -14,7 +16,11 @@ namespace osu.Game.Overlays.Profile.Sections
|
||||
|
||||
public HistoricalSection()
|
||||
{
|
||||
Child = new PaginatedScoreContainer(ScoreType.Recent, User, "Recent Plays (24h)", "No performance records. :(");
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new PaginatedMostPlayedBeatmapContainer(User),
|
||||
new PaginatedScoreContainer(ScoreType.Recent, User, "Recent Plays (24h)", "No performance records. :("),
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -9,7 +9,7 @@ using osu.Game.Rulesets.Scoring;
|
||||
|
||||
namespace osu.Game.Overlays.Profile.Sections.Ranks
|
||||
{
|
||||
public class DrawablePerformanceScore : DrawableScore
|
||||
public class DrawablePerformanceScore : DrawableProfileScore
|
||||
{
|
||||
private readonly double? weight;
|
||||
|
||||
@ -23,7 +23,7 @@ namespace osu.Game.Overlays.Profile.Sections.Ranks
|
||||
private void load(OsuColour colour)
|
||||
{
|
||||
double pp = Score.PP ?? 0;
|
||||
Stats.Add(new OsuSpriteText
|
||||
RightFlowContainer.Add(new OsuSpriteText
|
||||
{
|
||||
Text = $"{pp:0}pp",
|
||||
Anchor = Anchor.TopRight,
|
||||
@ -34,7 +34,7 @@ namespace osu.Game.Overlays.Profile.Sections.Ranks
|
||||
|
||||
if (weight.HasValue)
|
||||
{
|
||||
Stats.Add(new OsuSpriteText
|
||||
RightFlowContainer.Add(new OsuSpriteText
|
||||
{
|
||||
Text = $"weighted: {pp * weight:0}pp ({weight:P0})",
|
||||
Anchor = Anchor.TopRight,
|
||||
|
@ -0,0 +1,75 @@
|
||||
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using OpenTK;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using osu.Game.Rulesets.Mods;
|
||||
using osu.Game.Screens.Select.Leaderboards;
|
||||
using osu.Game.Rulesets.Scoring;
|
||||
using osu.Game.Rulesets.UI;
|
||||
|
||||
namespace osu.Game.Overlays.Profile.Sections.Ranks
|
||||
{
|
||||
public abstract class DrawableProfileScore : DrawableProfileRow
|
||||
{
|
||||
private readonly FillFlowContainer metadata;
|
||||
private readonly ScoreModsContainer modsContainer;
|
||||
protected readonly Score Score;
|
||||
|
||||
protected DrawableProfileScore(Score score)
|
||||
{
|
||||
Score = score;
|
||||
|
||||
RelativeSizeAxes = Axes.X;
|
||||
Height = 60;
|
||||
Children = new Drawable[]
|
||||
{
|
||||
modsContainer = new ScoreModsContainer
|
||||
{
|
||||
AutoSizeAxes = Axes.Y,
|
||||
Anchor = Anchor.CentreRight,
|
||||
Origin = Anchor.CentreRight,
|
||||
Width = 60,
|
||||
Margin = new MarginPadding { Right = 160 }
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader(true)]
|
||||
private void load(OsuColour colour)
|
||||
{
|
||||
RightFlowContainer.Add(new OsuSpriteText
|
||||
{
|
||||
Text = $"accuracy: {Score.Accuracy:P2}",
|
||||
Anchor = Anchor.TopRight,
|
||||
Origin = Anchor.TopRight,
|
||||
Colour = colour.GrayA,
|
||||
TextSize = 11,
|
||||
Font = "Exo2.0-RegularItalic",
|
||||
Depth = -1,
|
||||
});
|
||||
|
||||
LeftFlowContainer.Add(new BeatmapMetadataContainer(Score.Beatmap));
|
||||
LeftFlowContainer.Add(new OsuSpriteText
|
||||
{
|
||||
Text = Score.Date.LocalDateTime.ToShortDateString(),
|
||||
TextSize = 11,
|
||||
Colour = OsuColour.Gray(0xAA),
|
||||
});
|
||||
|
||||
foreach (Mod mod in Score.Mods)
|
||||
modsContainer.Add(new ModIcon(mod) { Scale = new Vector2(0.5f) });
|
||||
}
|
||||
|
||||
protected override Drawable CreateLeftVisual() => new DrawableRank(Score.Rank)
|
||||
{
|
||||
RelativeSizeAxes = Axes.Y,
|
||||
Width = 60,
|
||||
FillMode = FillMode.Fit,
|
||||
};
|
||||
}
|
||||
}
|
@ -1,195 +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 OpenTK;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using osu.Game.Rulesets.Mods;
|
||||
using osu.Game.Screens.Select.Leaderboards;
|
||||
using osu.Framework.Localisation;
|
||||
using osu.Game.Rulesets.Scoring;
|
||||
using osu.Game.Rulesets.UI;
|
||||
using OpenTK.Graphics;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Framework.Graphics.Cursor;
|
||||
using osu.Framework.Input;
|
||||
using osu.Framework.Extensions.Color4Extensions;
|
||||
using osu.Game.Graphics.Containers;
|
||||
|
||||
namespace osu.Game.Overlays.Profile.Sections.Ranks
|
||||
{
|
||||
public abstract class DrawableScore : Container
|
||||
{
|
||||
private const int fade_duration = 200;
|
||||
|
||||
protected readonly FillFlowContainer<OsuSpriteText> Stats;
|
||||
private readonly FillFlowContainer metadata;
|
||||
private readonly ScoreModsContainer modsContainer;
|
||||
protected readonly Score Score;
|
||||
private readonly Box underscoreLine;
|
||||
private readonly Box coloredBackground;
|
||||
private readonly Container background;
|
||||
|
||||
protected DrawableScore(Score score)
|
||||
{
|
||||
Score = score;
|
||||
|
||||
RelativeSizeAxes = Axes.X;
|
||||
Height = 60;
|
||||
Children = new Drawable[]
|
||||
{
|
||||
background = new Container
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Masking = true,
|
||||
CornerRadius = 3,
|
||||
Alpha = 0,
|
||||
EdgeEffect = new EdgeEffectParameters
|
||||
{
|
||||
Type = EdgeEffectType.Shadow,
|
||||
Offset = new Vector2(0f, 1f),
|
||||
Radius = 1f,
|
||||
Colour = Color4.Black.Opacity(0.2f),
|
||||
},
|
||||
Child = coloredBackground = new Box { RelativeSizeAxes = Axes.Both }
|
||||
},
|
||||
new Container
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Anchor = Anchor.TopCentre,
|
||||
Origin = Anchor.TopCentre,
|
||||
Width = 0.97f,
|
||||
Children = new Drawable[]
|
||||
{
|
||||
underscoreLine = new Box
|
||||
{
|
||||
Anchor = Anchor.BottomCentre,
|
||||
Origin = Anchor.BottomCentre,
|
||||
RelativeSizeAxes = Axes.X,
|
||||
Height = 1,
|
||||
},
|
||||
new DrawableRank(score.Rank)
|
||||
{
|
||||
RelativeSizeAxes = Axes.Y,
|
||||
Width = 60,
|
||||
FillMode = FillMode.Fit,
|
||||
},
|
||||
Stats = new FillFlowContainer<OsuSpriteText>
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
AutoSizeAxes = Axes.Y,
|
||||
Anchor = Anchor.CentreRight,
|
||||
Origin = Anchor.CentreRight,
|
||||
Direction = FillDirection.Vertical,
|
||||
},
|
||||
metadata = new FillFlowContainer
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
AutoSizeAxes = Axes.Y,
|
||||
Anchor = Anchor.CentreLeft,
|
||||
Origin = Anchor.CentreLeft,
|
||||
Margin = new MarginPadding { Left = 70 },
|
||||
Direction = FillDirection.Vertical,
|
||||
Child = new OsuSpriteText
|
||||
{
|
||||
Text = score.Date.LocalDateTime.ToShortDateString(),
|
||||
TextSize = 11,
|
||||
Colour = OsuColour.Gray(0xAA),
|
||||
Depth = -1,
|
||||
},
|
||||
},
|
||||
modsContainer = new ScoreModsContainer
|
||||
{
|
||||
AutoSizeAxes = Axes.Y,
|
||||
Anchor = Anchor.CentreRight,
|
||||
Origin = Anchor.CentreRight,
|
||||
Width = 60,
|
||||
Margin = new MarginPadding { Right = 160 }
|
||||
}
|
||||
}
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader(true)]
|
||||
private void load(OsuColour colour, LocalisationEngine locale, BeatmapSetOverlay beatmapSetOverlay)
|
||||
{
|
||||
coloredBackground.Colour = underscoreLine.Colour = colour.Gray4;
|
||||
|
||||
Stats.Add(new OsuSpriteText
|
||||
{
|
||||
Text = $"accuracy: {Score.Accuracy:P2}",
|
||||
Anchor = Anchor.TopRight,
|
||||
Origin = Anchor.TopRight,
|
||||
Colour = colour.GrayA,
|
||||
TextSize = 11,
|
||||
Font = "Exo2.0-RegularItalic",
|
||||
Depth = -1,
|
||||
});
|
||||
|
||||
metadata.Add(new MetadataContainer(Score.Beatmap.Metadata.Title, Score.Beatmap.Metadata.Artist)
|
||||
{
|
||||
AutoSizeAxes = Axes.Both,
|
||||
Action = () =>
|
||||
{
|
||||
if (Score.Beatmap.OnlineBeatmapSetID.HasValue) beatmapSetOverlay?.ShowBeatmapSet(Score.Beatmap.OnlineBeatmapSetID.Value);
|
||||
},
|
||||
Child = new FillFlowContainer
|
||||
{
|
||||
AutoSizeAxes = Axes.Both,
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new OsuSpriteText
|
||||
{
|
||||
Current = locale.GetUnicodePreference(
|
||||
$"{Score.Beatmap.Metadata.TitleUnicode ?? Score.Beatmap.Metadata.Title} [{Score.Beatmap.Version}] ",
|
||||
$"{Score.Beatmap.Metadata.Title ?? Score.Beatmap.Metadata.TitleUnicode} [{Score.Beatmap.Version}] "
|
||||
),
|
||||
TextSize = 15,
|
||||
Font = "Exo2.0-SemiBoldItalic",
|
||||
},
|
||||
new OsuSpriteText
|
||||
{
|
||||
Current = locale.GetUnicodePreference(Score.Beatmap.Metadata.ArtistUnicode, Score.Beatmap.Metadata.Artist),
|
||||
TextSize = 12,
|
||||
Padding = new MarginPadding { Top = 3 },
|
||||
Font = "Exo2.0-RegularItalic",
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
foreach (Mod mod in Score.Mods)
|
||||
modsContainer.Add(new ModIcon(mod) { Scale = new Vector2(0.5f) });
|
||||
}
|
||||
|
||||
protected override bool OnClick(InputState state) => true;
|
||||
|
||||
protected override bool OnHover(InputState state)
|
||||
{
|
||||
background.FadeIn(fade_duration, Easing.OutQuint);
|
||||
underscoreLine.FadeOut(fade_duration, Easing.OutQuint);
|
||||
return true;
|
||||
}
|
||||
|
||||
protected override void OnHoverLost(InputState state)
|
||||
{
|
||||
background.FadeOut(fade_duration, Easing.OutQuint);
|
||||
underscoreLine.FadeIn(fade_duration, Easing.OutQuint);
|
||||
base.OnHoverLost(state);
|
||||
}
|
||||
|
||||
private class MetadataContainer : OsuHoverContainer, IHasTooltip
|
||||
{
|
||||
public string TooltipText { get; set; }
|
||||
|
||||
public MetadataContainer(string title, string artist)
|
||||
{
|
||||
TooltipText = $"{artist} - {title}";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -8,7 +8,7 @@ using osu.Game.Rulesets.Scoring;
|
||||
|
||||
namespace osu.Game.Overlays.Profile.Sections.Ranks
|
||||
{
|
||||
public class DrawableTotalScore : DrawableScore
|
||||
public class DrawableTotalScore : DrawableProfileScore
|
||||
{
|
||||
public DrawableTotalScore(Score score)
|
||||
: base(score)
|
||||
@ -18,7 +18,7 @@ namespace osu.Game.Overlays.Profile.Sections.Ranks
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
Stats.Add(new OsuSpriteText
|
||||
RightFlowContainer.Add(new OsuSpriteText
|
||||
{
|
||||
Text = Score.TotalScore.ToString("#,###"),
|
||||
Anchor = Anchor.TopRight,
|
||||
|
@ -51,7 +51,7 @@ namespace osu.Game.Overlays.Profile.Sections.Ranks
|
||||
|
||||
foreach (OnlineScore score in scores)
|
||||
{
|
||||
DrawableScore drawableScore;
|
||||
DrawableProfileScore drawableScore;
|
||||
|
||||
switch (type)
|
||||
{
|
||||
|
@ -34,10 +34,10 @@ namespace osu.Game.Overlays.Settings.Sections.Gameplay
|
||||
Bindable = config.GetBindable<double>(OsuSetting.DisplayStarsMaximum),
|
||||
KeyboardStep = 1f
|
||||
},
|
||||
new SettingsEnumDropdown<SelectionRandomType>
|
||||
new SettingsEnumDropdown<RandomSelectAlgorithm>
|
||||
{
|
||||
LabelText = "Random beatmap selection",
|
||||
Bindable = config.GetBindable<SelectionRandomType>(OsuSetting.SelectionRandomType),
|
||||
LabelText = "Random selection algorithm",
|
||||
Bindable = config.GetBindable<RandomSelectAlgorithm>(OsuSetting.RandomSelectAlgorithm),
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -97,6 +97,11 @@ namespace osu.Game.Overlays.Settings.Sections.Input
|
||||
doubleValue.ValueChanged += newValue => base.Bindable.Value = newValue;
|
||||
}
|
||||
}
|
||||
|
||||
public SensitivitySetting()
|
||||
{
|
||||
KeyboardStep = 0.01f;
|
||||
}
|
||||
}
|
||||
|
||||
private class SensitivitySlider : OsuSliderBar<double>
|
||||
@ -105,8 +110,6 @@ namespace osu.Game.Overlays.Settings.Sections.Input
|
||||
|
||||
public SensitivitySlider()
|
||||
{
|
||||
KeyboardStep = 0.01f;
|
||||
|
||||
Current.ValueChanged += newValue =>
|
||||
{
|
||||
if (!isDragging && Sensitivity != null)
|
||||
@ -133,4 +136,4 @@ namespace osu.Game.Overlays.Settings.Sections.Input
|
||||
public override string TooltipText => Current.Disabled ? "Enable raw input to adjust sensitivity" : Current.Value.ToString(@"0.##x");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -159,8 +159,6 @@ namespace osu.Game.Overlays.Settings
|
||||
|
||||
public string TooltipText => "Revert to default";
|
||||
|
||||
public override bool HandleInput => true;
|
||||
|
||||
protected override bool OnMouseDown(InputState state, MouseDownEventArgs args) => true;
|
||||
|
||||
protected override bool OnMouseUp(InputState state, MouseUpEventArgs args) => true;
|
||||
|
@ -12,6 +12,7 @@ using osu.Framework.Graphics.Shapes;
|
||||
using osu.Framework.Logging;
|
||||
using osu.Framework.Timing;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Rulesets.Edit.Layers.Selection;
|
||||
using osu.Game.Rulesets.Edit.Tools;
|
||||
using osu.Game.Rulesets.UI;
|
||||
using osu.Game.Screens.Edit.Screens.Compose.RadioButtons;
|
||||
@ -77,7 +78,8 @@ namespace osu.Game.Rulesets.Edit
|
||||
Alpha = 0,
|
||||
AlwaysPresent = true,
|
||||
},
|
||||
rulesetContainer
|
||||
rulesetContainer,
|
||||
new SelectionLayer(rulesetContainer.Playfield)
|
||||
}
|
||||
}
|
||||
},
|
||||
|
105
osu.Game/Rulesets/Edit/Layers/Selection/Handle.cs
Normal file
105
osu.Game/Rulesets/Edit/Layers/Selection/Handle.cs
Normal file
@ -0,0 +1,105 @@
|
||||
// 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.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Primitives;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Framework.Input;
|
||||
using osu.Game.Graphics;
|
||||
using OpenTK;
|
||||
using OpenTK.Graphics;
|
||||
|
||||
namespace osu.Game.Rulesets.Edit.Layers.Selection
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a marker visible on the border of a <see cref="HandleContainer"/> which exposes
|
||||
/// properties that are used to resize a <see cref="HitObjectSelectionBox"/>.
|
||||
/// </summary>
|
||||
public class Handle : CompositeDrawable
|
||||
{
|
||||
private const float marker_size = 10;
|
||||
|
||||
/// <summary>
|
||||
/// Invoked when this <see cref="Handle"/> requires the current drag rectangle.
|
||||
/// </summary>
|
||||
public Func<RectangleF> GetDragRectangle;
|
||||
|
||||
/// <summary>
|
||||
/// Invoked when this <see cref="Handle"/> wants to update the drag rectangle.
|
||||
/// </summary>
|
||||
public Action<RectangleF> UpdateDragRectangle;
|
||||
|
||||
/// <summary>
|
||||
/// Invoked when this <see cref="Handle"/> has finished updates to the drag rectangle.
|
||||
/// </summary>
|
||||
public Action FinishDrag;
|
||||
|
||||
private Color4 normalColour;
|
||||
private Color4 hoverColour;
|
||||
|
||||
public Handle()
|
||||
{
|
||||
Size = new Vector2(marker_size);
|
||||
|
||||
InternalChild = new CircularContainer
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Masking = true,
|
||||
Child = new Box { RelativeSizeAxes = Axes.Both }
|
||||
};
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuColour colours)
|
||||
{
|
||||
Colour = normalColour = colours.Yellow;
|
||||
hoverColour = colours.YellowDarker;
|
||||
}
|
||||
|
||||
protected override bool OnDragStart(InputState state) => true;
|
||||
|
||||
protected override bool OnDrag(InputState state)
|
||||
{
|
||||
var currentRectangle = GetDragRectangle();
|
||||
|
||||
float left = currentRectangle.Left;
|
||||
float right = currentRectangle.Right;
|
||||
float top = currentRectangle.Top;
|
||||
float bottom = currentRectangle.Bottom;
|
||||
|
||||
// Apply modifications to the capture rectangle
|
||||
if ((Anchor & Anchor.y0) > 0)
|
||||
top += state.Mouse.Delta.Y;
|
||||
else if ((Anchor & Anchor.y2) > 0)
|
||||
bottom += state.Mouse.Delta.Y;
|
||||
|
||||
if ((Anchor & Anchor.x0) > 0)
|
||||
left += state.Mouse.Delta.X;
|
||||
else if ((Anchor & Anchor.x2) > 0)
|
||||
right += state.Mouse.Delta.X;
|
||||
|
||||
UpdateDragRectangle(RectangleF.FromLTRB(left, top, right, bottom));
|
||||
return true;
|
||||
}
|
||||
|
||||
protected override bool OnDragEnd(InputState state)
|
||||
{
|
||||
FinishDrag();
|
||||
return true;
|
||||
}
|
||||
|
||||
protected override bool OnHover(InputState state)
|
||||
{
|
||||
this.FadeColour(hoverColour, 100);
|
||||
return true;
|
||||
}
|
||||
|
||||
protected override void OnHoverLost(InputState state)
|
||||
{
|
||||
this.FadeColour(normalColour, 100);
|
||||
}
|
||||
}
|
||||
}
|
92
osu.Game/Rulesets/Edit/Layers/Selection/HandleContainer.cs
Normal file
92
osu.Game/Rulesets/Edit/Layers/Selection/HandleContainer.cs
Normal file
@ -0,0 +1,92 @@
|
||||
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using System;
|
||||
using System.Linq;
|
||||
using osu.Framework.Extensions.IEnumerableExtensions;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Primitives;
|
||||
|
||||
namespace osu.Game.Rulesets.Edit.Layers.Selection
|
||||
{
|
||||
/// <summary>
|
||||
/// A <see cref="CompositeDrawable"/> that has <see cref="Handle"/>s around its border.
|
||||
/// </summary>
|
||||
public class HandleContainer : CompositeDrawable
|
||||
{
|
||||
/// <summary>
|
||||
/// Invoked when a <see cref="Handle"/> requires the current drag rectangle.
|
||||
/// </summary>
|
||||
public Func<RectangleF> GetDragRectangle;
|
||||
|
||||
/// <summary>
|
||||
/// Invoked when a <see cref="Handle"/> wants to update the drag rectangle.
|
||||
/// </summary>
|
||||
public Action<RectangleF> UpdateDragRectangle;
|
||||
|
||||
/// <summary>
|
||||
/// Invoked when a <see cref="Handle"/> has finished updates to the drag rectangle.
|
||||
/// </summary>
|
||||
public Action FinishDrag;
|
||||
|
||||
public HandleContainer()
|
||||
{
|
||||
InternalChildren = new Drawable[]
|
||||
{
|
||||
new Handle
|
||||
{
|
||||
Anchor = Anchor.TopLeft,
|
||||
Origin = Anchor.Centre
|
||||
},
|
||||
new Handle
|
||||
{
|
||||
Anchor = Anchor.TopCentre,
|
||||
Origin = Anchor.Centre
|
||||
},
|
||||
new Handle
|
||||
{
|
||||
Anchor = Anchor.TopRight,
|
||||
Origin = Anchor.Centre
|
||||
},
|
||||
new Handle
|
||||
{
|
||||
Anchor = Anchor.CentreLeft,
|
||||
Origin = Anchor.Centre
|
||||
},
|
||||
new Handle
|
||||
{
|
||||
Anchor = Anchor.BottomLeft,
|
||||
Origin = Anchor.Centre
|
||||
},
|
||||
new Handle
|
||||
{
|
||||
Anchor = Anchor.CentreRight,
|
||||
Origin = Anchor.Centre
|
||||
},
|
||||
new Handle
|
||||
{
|
||||
Anchor = Anchor.BottomRight,
|
||||
Origin = Anchor.Centre
|
||||
},
|
||||
new Handle
|
||||
{
|
||||
Anchor = Anchor.BottomCentre,
|
||||
Origin = Anchor.Centre
|
||||
},
|
||||
new OriginHandle
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre
|
||||
}
|
||||
};
|
||||
|
||||
InternalChildren.OfType<Handle>().ForEach(m =>
|
||||
{
|
||||
m.GetDragRectangle = () => GetDragRectangle();
|
||||
m.UpdateDragRectangle = r => UpdateDragRectangle(r);
|
||||
m.FinishDrag = () => FinishDrag();
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
178
osu.Game/Rulesets/Edit/Layers/Selection/HitObjectSelectionBox.cs
Normal file
178
osu.Game/Rulesets/Edit/Layers/Selection/HitObjectSelectionBox.cs
Normal file
@ -0,0 +1,178 @@
|
||||
// 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.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Primitives;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Rulesets.Objects.Drawables;
|
||||
using OpenTK;
|
||||
using OpenTK.Graphics;
|
||||
using osu.Framework.Configuration;
|
||||
|
||||
namespace osu.Game.Rulesets.Edit.Layers.Selection
|
||||
{
|
||||
/// <summary>
|
||||
/// A box that represents a drag selection.
|
||||
/// </summary>
|
||||
public class HitObjectSelectionBox : CompositeDrawable
|
||||
{
|
||||
public readonly Bindable<SelectionInfo> Selection = new Bindable<SelectionInfo>();
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="DrawableHitObject"/>s that can be selected through a drag-selection.
|
||||
/// </summary>
|
||||
public IEnumerable<DrawableHitObject> CapturableObjects;
|
||||
|
||||
private readonly Container borderMask;
|
||||
private readonly Drawable background;
|
||||
private readonly HandleContainer handles;
|
||||
|
||||
private Color4 captureFinishedColour;
|
||||
|
||||
private readonly Vector2 startPos;
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="HitObjectSelectionBox"/>.
|
||||
/// </summary>
|
||||
/// <param name="startPos">The point at which the drag was initiated, in the parent's coordinates.</param>
|
||||
public HitObjectSelectionBox(Vector2 startPos)
|
||||
{
|
||||
this.startPos = startPos;
|
||||
|
||||
InternalChildren = new Drawable[]
|
||||
{
|
||||
new Container
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Padding = new MarginPadding(-1),
|
||||
Child = borderMask = new Container
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Masking = true,
|
||||
BorderColour = Color4.White,
|
||||
BorderThickness = 2,
|
||||
MaskingSmoothness = 1,
|
||||
Child = background = new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Alpha = 0.1f,
|
||||
AlwaysPresent = true
|
||||
},
|
||||
}
|
||||
},
|
||||
handles = new HandleContainer
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Alpha = 0,
|
||||
GetDragRectangle = () => dragRectangle,
|
||||
UpdateDragRectangle = updateDragRectangle,
|
||||
FinishDrag = FinishCapture
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuColour colours)
|
||||
{
|
||||
captureFinishedColour = colours.Yellow;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The secondary corner of the drag selection box. A rectangle will be fit between the starting position and this value.
|
||||
/// </summary>
|
||||
public Vector2 DragEndPosition { set => updateDragRectangle(RectangleF.FromLTRB(startPos.X, startPos.Y, value.X, value.Y)); }
|
||||
|
||||
private RectangleF dragRectangle;
|
||||
private void updateDragRectangle(RectangleF rectangle)
|
||||
{
|
||||
dragRectangle = rectangle;
|
||||
|
||||
Position = new Vector2(
|
||||
Math.Min(rectangle.Left, rectangle.Right),
|
||||
Math.Min(rectangle.Top, rectangle.Bottom));
|
||||
|
||||
Size = new Vector2(
|
||||
Math.Max(rectangle.Left, rectangle.Right) - Position.X,
|
||||
Math.Max(rectangle.Top, rectangle.Bottom) - Position.Y);
|
||||
}
|
||||
|
||||
private readonly List<DrawableHitObject> capturedHitObjects = new List<DrawableHitObject>();
|
||||
|
||||
/// <summary>
|
||||
/// Processes hitobjects to determine which ones are captured by the drag selection.
|
||||
/// Captured hitobjects will be enclosed by the drag selection upon <see cref="FinishCapture"/>.
|
||||
/// </summary>
|
||||
public void BeginCapture()
|
||||
{
|
||||
capturedHitObjects.Clear();
|
||||
|
||||
foreach (var obj in CapturableObjects)
|
||||
{
|
||||
if (!obj.IsAlive || !obj.IsPresent)
|
||||
continue;
|
||||
|
||||
if (ScreenSpaceDrawQuad.Contains(obj.SelectionPoint))
|
||||
capturedHitObjects.Add(obj);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Encloses hitobjects captured through <see cref="BeginCapture"/> in the drag selection box.
|
||||
/// </summary>
|
||||
public void FinishCapture()
|
||||
{
|
||||
if (capturedHitObjects.Count == 0)
|
||||
{
|
||||
Hide();
|
||||
return;
|
||||
}
|
||||
|
||||
// Move the rectangle to cover the hitobjects
|
||||
var topLeft = new Vector2(float.MaxValue, float.MaxValue);
|
||||
var bottomRight = new Vector2(float.MinValue, float.MinValue);
|
||||
|
||||
foreach (var obj in capturedHitObjects)
|
||||
{
|
||||
topLeft = Vector2.ComponentMin(topLeft, Parent.ToLocalSpace(obj.SelectionQuad.TopLeft));
|
||||
bottomRight = Vector2.ComponentMax(bottomRight, Parent.ToLocalSpace(obj.SelectionQuad.BottomRight));
|
||||
}
|
||||
|
||||
topLeft -= new Vector2(5);
|
||||
bottomRight += new Vector2(5);
|
||||
|
||||
this.MoveTo(topLeft, 200, Easing.OutQuint)
|
||||
.ResizeTo(bottomRight - topLeft, 200, Easing.OutQuint);
|
||||
|
||||
dragRectangle = RectangleF.FromLTRB(topLeft.X, topLeft.Y, bottomRight.X, bottomRight.Y);
|
||||
|
||||
borderMask.BorderThickness = 3;
|
||||
borderMask.FadeColour(captureFinishedColour, 200);
|
||||
|
||||
// Transform into markers to let the user modify the drag selection further.
|
||||
background.Delay(50).FadeOut(200);
|
||||
handles.FadeIn(200);
|
||||
|
||||
Selection.Value = new SelectionInfo
|
||||
{
|
||||
Objects = capturedHitObjects,
|
||||
SelectionQuad = Parent.ToScreenSpace(dragRectangle)
|
||||
};
|
||||
}
|
||||
|
||||
private bool isActive = true;
|
||||
public override bool HandleInput => isActive;
|
||||
|
||||
public override void Hide()
|
||||
{
|
||||
isActive = false;
|
||||
this.FadeOut(400, Easing.OutQuint).Expire();
|
||||
|
||||
Selection.Value = null;
|
||||
}
|
||||
}
|
||||
}
|
50
osu.Game/Rulesets/Edit/Layers/Selection/OriginHandle.cs
Normal file
50
osu.Game/Rulesets/Edit/Layers/Selection/OriginHandle.cs
Normal file
@ -0,0 +1,50 @@
|
||||
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Game.Graphics;
|
||||
using OpenTK;
|
||||
|
||||
namespace osu.Game.Rulesets.Edit.Layers.Selection
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents the origin of a <see cref="HandleContainer"/>.
|
||||
/// </summary>
|
||||
public class OriginHandle : CompositeDrawable
|
||||
{
|
||||
private const float marker_size = 10;
|
||||
private const float line_width = 2;
|
||||
|
||||
public OriginHandle()
|
||||
{
|
||||
Size = new Vector2(marker_size);
|
||||
|
||||
InternalChildren = new[]
|
||||
{
|
||||
new Box
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
RelativeSizeAxes = Axes.X,
|
||||
Height = line_width
|
||||
},
|
||||
new Box
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
RelativeSizeAxes = Axes.Y,
|
||||
Width = line_width
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuColour colours)
|
||||
{
|
||||
Colour = colours.Yellow;
|
||||
}
|
||||
}
|
||||
}
|
22
osu.Game/Rulesets/Edit/Layers/Selection/SelectionInfo.cs
Normal file
22
osu.Game/Rulesets/Edit/Layers/Selection/SelectionInfo.cs
Normal file
@ -0,0 +1,22 @@
|
||||
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using System.Collections.Generic;
|
||||
using osu.Framework.Graphics.Primitives;
|
||||
using osu.Game.Rulesets.Objects.Drawables;
|
||||
|
||||
namespace osu.Game.Rulesets.Edit.Layers.Selection
|
||||
{
|
||||
public class SelectionInfo
|
||||
{
|
||||
/// <summary>
|
||||
/// The objects that are captured by the selection.
|
||||
/// </summary>
|
||||
public IEnumerable<DrawableHitObject> Objects;
|
||||
|
||||
/// <summary>
|
||||
/// The screen space quad of the selection box surrounding <see cref="Objects"/>.
|
||||
/// </summary>
|
||||
public Quad SelectionQuad;
|
||||
}
|
||||
}
|
61
osu.Game/Rulesets/Edit/Layers/Selection/SelectionLayer.cs
Normal file
61
osu.Game/Rulesets/Edit/Layers/Selection/SelectionLayer.cs
Normal file
@ -0,0 +1,61 @@
|
||||
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using osu.Framework.Configuration;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Input;
|
||||
using osu.Game.Rulesets.UI;
|
||||
|
||||
namespace osu.Game.Rulesets.Edit.Layers.Selection
|
||||
{
|
||||
public class SelectionLayer : CompositeDrawable
|
||||
{
|
||||
public readonly Bindable<SelectionInfo> Selection = new Bindable<SelectionInfo>();
|
||||
|
||||
private readonly Playfield playfield;
|
||||
|
||||
public SelectionLayer(Playfield playfield)
|
||||
{
|
||||
this.playfield = playfield;
|
||||
|
||||
RelativeSizeAxes = Axes.Both;
|
||||
}
|
||||
|
||||
private HitObjectSelectionBox selectionBoxBox;
|
||||
|
||||
protected override bool OnDragStart(InputState state)
|
||||
{
|
||||
// Hide the previous drag box - we won't be working with it any longer
|
||||
selectionBoxBox?.Hide();
|
||||
|
||||
AddInternal(selectionBoxBox = new HitObjectSelectionBox(ToLocalSpace(state.Mouse.NativeState.Position))
|
||||
{
|
||||
CapturableObjects = playfield.HitObjects.Objects,
|
||||
});
|
||||
|
||||
Selection.BindTo(selectionBoxBox.Selection);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
protected override bool OnDrag(InputState state)
|
||||
{
|
||||
selectionBoxBox.DragEndPosition = ToLocalSpace(state.Mouse.NativeState.Position);
|
||||
selectionBoxBox.BeginCapture();
|
||||
return true;
|
||||
}
|
||||
|
||||
protected override bool OnDragEnd(InputState state)
|
||||
{
|
||||
selectionBoxBox.FinishCapture();
|
||||
return true;
|
||||
}
|
||||
|
||||
protected override bool OnClick(InputState state)
|
||||
{
|
||||
selectionBoxBox?.Hide();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
@ -14,6 +14,8 @@ using osu.Game.Audio;
|
||||
using System.Linq;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Framework.Configuration;
|
||||
using OpenTK;
|
||||
using osu.Framework.Graphics.Primitives;
|
||||
|
||||
namespace osu.Game.Rulesets.Objects.Drawables
|
||||
{
|
||||
@ -38,6 +40,16 @@ namespace osu.Game.Rulesets.Objects.Drawables
|
||||
{
|
||||
HitObject = hitObject;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The screen-space point that causes this <see cref="DrawableHitObject"/> to be selected in the Editor.
|
||||
/// </summary>
|
||||
public virtual Vector2 SelectionPoint => ScreenSpaceDrawQuad.Centre;
|
||||
|
||||
/// <summary>
|
||||
/// The screen-space quad that outlines this <see cref="DrawableHitObject"/> for selections in the Editor.
|
||||
/// </summary>
|
||||
public virtual Quad SelectionQuad => ScreenSpaceDrawQuad;
|
||||
}
|
||||
|
||||
public abstract class DrawableHitObject<TObject> : DrawableHitObject
|
||||
|
@ -177,8 +177,8 @@ namespace osu.Game.Rulesets.Objects.Legacy
|
||||
|
||||
string[] split = str.Split(':');
|
||||
|
||||
var bank = (OsuLegacyDecoder.LegacySampleBank)Convert.ToInt32(split[0]);
|
||||
var addbank = (OsuLegacyDecoder.LegacySampleBank)Convert.ToInt32(split[1]);
|
||||
var bank = (LegacyDecoder.LegacySampleBank)Convert.ToInt32(split[0]);
|
||||
var addbank = (LegacyDecoder.LegacySampleBank)Convert.ToInt32(split[1]);
|
||||
|
||||
// Let's not implement this for now, because this doesn't fit nicely into the bank structure
|
||||
//string sampleFile = split2.Length > 4 ? split2[4] : string.Empty;
|
||||
|
@ -23,13 +23,12 @@ namespace osu.Game.Rulesets
|
||||
public virtual IEnumerable<BeatmapStatistic> GetBeatmapStatistics(WorkingBeatmap beatmap) => new BeatmapStatistic[] { };
|
||||
|
||||
public IEnumerable<Mod> GetAllMods() => Enum.GetValues(typeof(ModType)).Cast<ModType>()
|
||||
// Get all mod types as an IEnumerable<ModType>
|
||||
.SelectMany(GetModsFor)
|
||||
// Confine all mods of each mod type into a single IEnumerable<Mod>
|
||||
.Where(mod => mod != null)
|
||||
// Filter out all null mods
|
||||
.SelectMany(mod => (mod as MultiMod)?.Mods ?? new[] { mod });
|
||||
// Resolve MultiMods as their .Mods property
|
||||
// Confine all mods of each mod type into a single IEnumerable<Mod>
|
||||
.SelectMany(GetModsFor)
|
||||
// Filter out all null mods
|
||||
.Where(mod => mod != null)
|
||||
// Resolve MultiMods as their .Mods property
|
||||
.SelectMany(mod => (mod as MultiMod)?.Mods ?? new[] { mod });
|
||||
|
||||
public abstract IEnumerable<Mod> GetModsFor(ModType type);
|
||||
|
||||
@ -66,6 +65,11 @@ namespace osu.Game.Rulesets
|
||||
/// </summary>
|
||||
public virtual int LegacyID => -1;
|
||||
|
||||
/// <summary>
|
||||
/// A unique short name to reference this ruleset in online requests.
|
||||
/// </summary>
|
||||
public abstract string ShortName { get; }
|
||||
|
||||
/// <summary>
|
||||
/// A list of available variant ids.
|
||||
/// </summary>
|
||||
|
@ -15,6 +15,8 @@ namespace osu.Game.Rulesets
|
||||
|
||||
public string Name { get; set; }
|
||||
|
||||
public string ShortName { get; set; }
|
||||
|
||||
public string InstantiationInfo { get; set; }
|
||||
|
||||
[JsonIgnore]
|
||||
|
@ -83,7 +83,11 @@ namespace osu.Game.Rulesets
|
||||
{
|
||||
try
|
||||
{
|
||||
r.CreateInstance();
|
||||
var instance = r.CreateInstance();
|
||||
|
||||
r.Name = instance.Description;
|
||||
r.ShortName = instance.ShortName;
|
||||
|
||||
r.Available = true;
|
||||
}
|
||||
catch
|
||||
@ -117,6 +121,7 @@ namespace osu.Game.Rulesets
|
||||
private RulesetInfo createRulesetInfo(Ruleset ruleset) => new RulesetInfo
|
||||
{
|
||||
Name = ruleset.Description,
|
||||
ShortName = ruleset.ShortName,
|
||||
InstantiationInfo = ruleset.GetType().AssemblyQualifiedName,
|
||||
ID = ruleset.LegacyID
|
||||
};
|
||||
|
@ -55,10 +55,11 @@ namespace osu.Game.Rulesets.UI
|
||||
|
||||
public abstract IEnumerable<HitObject> Objects { get; }
|
||||
|
||||
private readonly Lazy<Playfield> playfield;
|
||||
/// <summary>
|
||||
/// The playfield.
|
||||
/// </summary>
|
||||
public Playfield Playfield { get; protected set; }
|
||||
public Playfield Playfield => playfield.Value;
|
||||
|
||||
protected readonly Ruleset Ruleset;
|
||||
|
||||
@ -69,6 +70,7 @@ namespace osu.Game.Rulesets.UI
|
||||
protected RulesetContainer(Ruleset ruleset)
|
||||
{
|
||||
Ruleset = ruleset;
|
||||
playfield = new Lazy<Playfield>(CreatePlayfield);
|
||||
}
|
||||
|
||||
public abstract ScoreProcessor CreateScoreProcessor();
|
||||
@ -95,6 +97,12 @@ namespace osu.Game.Rulesets.UI
|
||||
Replay = replay;
|
||||
ReplayInputManager.ReplayInputHandler = replay != null ? CreateReplayInputHandler(replay) : null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a Playfield.
|
||||
/// </summary>
|
||||
/// <returns>The Playfield.</returns>
|
||||
protected abstract Playfield CreatePlayfield();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -198,7 +206,7 @@ namespace osu.Game.Rulesets.UI
|
||||
});
|
||||
|
||||
AddInternal(KeyBindingInputManager);
|
||||
KeyBindingInputManager.Add(Playfield = CreatePlayfield());
|
||||
KeyBindingInputManager.Add(Playfield);
|
||||
|
||||
loadObjects();
|
||||
}
|
||||
@ -286,12 +294,6 @@ namespace osu.Game.Rulesets.UI
|
||||
/// <param name="h">The HitObject to make drawable.</param>
|
||||
/// <returns>The DrawableHitObject.</returns>
|
||||
protected abstract DrawableHitObject<TObject> GetVisualRepresentation(TObject h);
|
||||
|
||||
/// <summary>
|
||||
/// Creates a Playfield.
|
||||
/// </summary>
|
||||
/// <returns>The Playfield.</returns>
|
||||
protected abstract Playfield CreatePlayfield();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -5,6 +5,8 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Configuration;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Input;
|
||||
using osu.Framework.Input.Bindings;
|
||||
using osu.Framework.Timing;
|
||||
@ -16,11 +18,24 @@ using OpenTK.Input;
|
||||
|
||||
namespace osu.Game.Rulesets.UI
|
||||
{
|
||||
public abstract class RulesetInputManager<T> : DatabasedKeyBindingInputManager<T>, ICanAttachKeyCounter, IHasReplayHandler
|
||||
public abstract class RulesetInputManager<T> : PassThroughInputManager, ICanAttachKeyCounter, IHasReplayHandler
|
||||
where T : struct
|
||||
{
|
||||
protected RulesetInputManager(RulesetInfo ruleset, int variant, SimultaneousBindingMode unique) : base(ruleset, variant, unique)
|
||||
public class RulesetKeyBindingContainer : DatabasedKeyBindingInputManager<T>
|
||||
{
|
||||
public RulesetKeyBindingContainer(RulesetInfo ruleset, int variant, SimultaneousBindingMode unique)
|
||||
: base(ruleset, variant, unique)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
protected readonly KeyBindingContainer<T> KeyBindingContainer;
|
||||
|
||||
protected override Container<Drawable> Content => KeyBindingContainer;
|
||||
|
||||
protected RulesetInputManager(RulesetInfo ruleset, int variant, SimultaneousBindingMode unique)
|
||||
{
|
||||
InternalChild = KeyBindingContainer = new RulesetKeyBindingContainer(ruleset, variant, unique);
|
||||
}
|
||||
|
||||
#region Action mapping (for replays)
|
||||
@ -41,10 +56,10 @@ namespace osu.Game.Rulesets.UI
|
||||
List<T> newActions = replayState.PressedActions;
|
||||
|
||||
foreach (var released in lastPressedActions.Except(newActions))
|
||||
PropagateReleased(KeyBindingInputQueue, released);
|
||||
KeyBindingContainer.TriggerReleased(released);
|
||||
|
||||
foreach (var pressed in newActions.Except(lastPressedActions))
|
||||
PropagatePressed(KeyBindingInputQueue, pressed);
|
||||
KeyBindingContainer.TriggerPressed(pressed);
|
||||
|
||||
lastPressedActions = newActions;
|
||||
}
|
||||
@ -203,7 +218,7 @@ namespace osu.Game.Rulesets.UI
|
||||
Add(receptor);
|
||||
keyCounter.SetReceptor(receptor);
|
||||
|
||||
keyCounter.AddRange(DefaultKeyBindings.Select(b => b.GetAction<T>()).Distinct().Select(b => new KeyCounterAction<T>(b)));
|
||||
keyCounter.AddRange(KeyBindingContainer.DefaultKeyBindings.Select(b => b.GetAction<T>()).Distinct().Select(b => new KeyCounterAction<T>(b)));
|
||||
}
|
||||
|
||||
public class ActionReceptor : KeyCounterCollection.Receptor, IKeyBindingHandler<T>
|
||||
|
@ -10,7 +10,7 @@ using System.Linq;
|
||||
|
||||
namespace osu.Game.Screens.Play
|
||||
{
|
||||
public class FailOverlay : MenuOverlay
|
||||
public class FailOverlay : GameplayMenuOverlay
|
||||
{
|
||||
public override string Header => "failed";
|
||||
public override string Description => "you're dead, try again?";
|
||||
@ -18,15 +18,15 @@ namespace osu.Game.Screens.Play
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuColour colours)
|
||||
{
|
||||
AddButton("Retry", colours.YellowDark, OnRetry);
|
||||
AddButton("Quit", new Color4(170, 27, 39, 255), OnQuit);
|
||||
AddButton("Retry", colours.YellowDark, () => OnRetry?.Invoke());
|
||||
AddButton("Quit", new Color4(170, 27, 39, 255), () => OnQuit?.Invoke());
|
||||
}
|
||||
|
||||
protected override bool OnKeyDown(InputState state, KeyDownEventArgs args)
|
||||
{
|
||||
if (!args.Repeat && args.Key == Key.Escape)
|
||||
{
|
||||
Buttons.Children.Last().TriggerOnClick();
|
||||
InternalButtons.Children.Last().TriggerOnClick();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -13,10 +13,12 @@ using osu.Game.Graphics;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using OpenTK.Input;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace osu.Game.Screens.Play
|
||||
{
|
||||
public abstract class MenuOverlay : OverlayContainer, IRequireHighFrequencyMousePosition
|
||||
public abstract class GameplayMenuOverlay : OverlayContainer, IRequireHighFrequencyMousePosition
|
||||
{
|
||||
private const int transition_duration = 200;
|
||||
private const int button_height = 70;
|
||||
@ -30,75 +32,16 @@ namespace osu.Game.Screens.Play
|
||||
public abstract string Header { get; }
|
||||
public abstract string Description { get; }
|
||||
|
||||
protected FillFlowContainer<DialogButton> Buttons;
|
||||
|
||||
public int Retries
|
||||
{
|
||||
set
|
||||
{
|
||||
if (retryCounterContainer != null)
|
||||
{
|
||||
// "You've retried 1,065 times in this session"
|
||||
// "You've retried 1 time in this session"
|
||||
|
||||
retryCounterContainer.Children = new Drawable[]
|
||||
{
|
||||
new OsuSpriteText
|
||||
{
|
||||
Text = "You've retried ",
|
||||
Shadow = true,
|
||||
ShadowColour = new Color4(0, 0, 0, 0.25f),
|
||||
TextSize = 18
|
||||
},
|
||||
new OsuSpriteText
|
||||
{
|
||||
Text = $"{value:n0}",
|
||||
Font = @"Exo2.0-Bold",
|
||||
Shadow = true,
|
||||
ShadowColour = new Color4(0, 0, 0, 0.25f),
|
||||
TextSize = 18
|
||||
},
|
||||
new OsuSpriteText
|
||||
{
|
||||
Text = $" time{(value == 1 ? "" : "s")} in this session",
|
||||
Shadow = true,
|
||||
ShadowColour = new Color4(0, 0, 0, 0.25f),
|
||||
TextSize = 18
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
protected internal FillFlowContainer<DialogButton> InternalButtons;
|
||||
public IReadOnlyList<DialogButton> Buttons => InternalButtons;
|
||||
|
||||
private FillFlowContainer retryCounterContainer;
|
||||
|
||||
public override bool HandleInput => State == Visibility.Visible;
|
||||
|
||||
protected override void PopIn() => this.FadeIn(transition_duration, Easing.In);
|
||||
protected override void PopOut() => this.FadeOut(transition_duration, Easing.In);
|
||||
|
||||
// Don't let mouse down events through the overlay or people can click circles while paused.
|
||||
protected override bool OnMouseDown(InputState state, MouseDownEventArgs args) => true;
|
||||
|
||||
protected override bool OnMouseUp(InputState state, MouseUpEventArgs args) => true;
|
||||
|
||||
protected override bool OnMouseMove(InputState state) => true;
|
||||
|
||||
protected void AddButton(string text, Color4 colour, Action action)
|
||||
protected GameplayMenuOverlay()
|
||||
{
|
||||
Buttons.Add(new Button
|
||||
{
|
||||
Text = text,
|
||||
ButtonColour = colour,
|
||||
Origin = Anchor.TopCentre,
|
||||
Anchor = Anchor.TopCentre,
|
||||
Height = button_height,
|
||||
Action = delegate
|
||||
{
|
||||
action?.Invoke();
|
||||
Hide();
|
||||
}
|
||||
});
|
||||
RelativeSizeAxes = Axes.Both;
|
||||
|
||||
StateChanged += s => selectionIndex = -1;
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
@ -154,7 +97,7 @@ namespace osu.Game.Screens.Play
|
||||
}
|
||||
}
|
||||
},
|
||||
Buttons = new FillFlowContainer<DialogButton>
|
||||
InternalButtons = new FillFlowContainer<DialogButton>
|
||||
{
|
||||
Origin = Anchor.TopCentre,
|
||||
Anchor = Anchor.TopCentre,
|
||||
@ -182,13 +125,140 @@ namespace osu.Game.Screens.Play
|
||||
Retries = 0;
|
||||
}
|
||||
|
||||
protected MenuOverlay()
|
||||
public int Retries
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both;
|
||||
set
|
||||
{
|
||||
if (retryCounterContainer != null)
|
||||
{
|
||||
// "You've retried 1,065 times in this session"
|
||||
// "You've retried 1 time in this session"
|
||||
|
||||
retryCounterContainer.Children = new Drawable[]
|
||||
{
|
||||
new OsuSpriteText
|
||||
{
|
||||
Text = "You've retried ",
|
||||
Shadow = true,
|
||||
ShadowColour = new Color4(0, 0, 0, 0.25f),
|
||||
TextSize = 18
|
||||
},
|
||||
new OsuSpriteText
|
||||
{
|
||||
Text = $"{value:n0}",
|
||||
Font = @"Exo2.0-Bold",
|
||||
Shadow = true,
|
||||
ShadowColour = new Color4(0, 0, 0, 0.25f),
|
||||
TextSize = 18
|
||||
},
|
||||
new OsuSpriteText
|
||||
{
|
||||
Text = $" time{(value == 1 ? "" : "s")} in this session",
|
||||
Shadow = true,
|
||||
ShadowColour = new Color4(0, 0, 0, 0.25f),
|
||||
TextSize = 18
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class Button : DialogButton
|
||||
public override bool HandleInput => State == Visibility.Visible;
|
||||
|
||||
protected override void PopIn() => this.FadeIn(transition_duration, Easing.In);
|
||||
protected override void PopOut() => this.FadeOut(transition_duration, Easing.In);
|
||||
|
||||
// Don't let mouse down events through the overlay or people can click circles while paused.
|
||||
protected override bool OnMouseDown(InputState state, MouseDownEventArgs args) => true;
|
||||
|
||||
protected override bool OnMouseUp(InputState state, MouseUpEventArgs args) => true;
|
||||
|
||||
protected override bool OnMouseMove(InputState state) => true;
|
||||
|
||||
protected void AddButton(string text, Color4 colour, Action action)
|
||||
{
|
||||
var button = new Button
|
||||
{
|
||||
Text = text,
|
||||
ButtonColour = colour,
|
||||
Origin = Anchor.TopCentre,
|
||||
Anchor = Anchor.TopCentre,
|
||||
Height = button_height,
|
||||
Action = delegate
|
||||
{
|
||||
action?.Invoke();
|
||||
Hide();
|
||||
}
|
||||
};
|
||||
|
||||
button.Selected.ValueChanged += s => buttonSelectionChanged(button, s);
|
||||
|
||||
InternalButtons.Add(button);
|
||||
}
|
||||
|
||||
private int _selectionIndex = -1;
|
||||
private int selectionIndex
|
||||
{
|
||||
get { return _selectionIndex; }
|
||||
set
|
||||
{
|
||||
if (_selectionIndex == value)
|
||||
return;
|
||||
|
||||
// Deselect the previously-selected button
|
||||
if (_selectionIndex != -1)
|
||||
InternalButtons[_selectionIndex].Selected.Value = false;
|
||||
|
||||
_selectionIndex = value;
|
||||
|
||||
// Select the newly-selected button
|
||||
if (_selectionIndex != -1)
|
||||
InternalButtons[_selectionIndex].Selected.Value = true;
|
||||
}
|
||||
}
|
||||
|
||||
protected override bool OnKeyDown(InputState state, KeyDownEventArgs args)
|
||||
{
|
||||
if (args.Repeat)
|
||||
return false;
|
||||
|
||||
switch (args.Key)
|
||||
{
|
||||
case Key.Up:
|
||||
if (selectionIndex == -1 || selectionIndex == 0)
|
||||
selectionIndex = InternalButtons.Count - 1;
|
||||
else
|
||||
selectionIndex--;
|
||||
return true;
|
||||
case Key.Down:
|
||||
if (selectionIndex == -1 || selectionIndex == InternalButtons.Count - 1)
|
||||
selectionIndex = 0;
|
||||
else
|
||||
selectionIndex++;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private void buttonSelectionChanged(DialogButton button, bool isSelected)
|
||||
{
|
||||
if (!isSelected)
|
||||
selectionIndex = -1;
|
||||
else
|
||||
selectionIndex = InternalButtons.IndexOf(button);
|
||||
}
|
||||
|
||||
private class Button : DialogButton
|
||||
{
|
||||
protected override bool OnKeyDown(InputState state, KeyDownEventArgs args)
|
||||
{
|
||||
if (args.Repeat || args.Key != Key.Enter || !Selected)
|
||||
return false;
|
||||
|
||||
OnClick(state);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -16,8 +16,6 @@ namespace osu.Game.Screens.Play.HUD
|
||||
|
||||
public bool ReplayLoaded;
|
||||
|
||||
public override bool HandleInput => true;
|
||||
|
||||
public readonly PlaybackSettings PlaybackSettings;
|
||||
//public readonly CollectionSettings CollectionSettings;
|
||||
//public readonly DiscussionSettings DiscussionSettings;
|
||||
@ -35,7 +33,7 @@ namespace osu.Game.Screens.Play.HUD
|
||||
Direction = FillDirection.Vertical,
|
||||
Spacing = new Vector2(0, 20),
|
||||
Margin = new MarginPadding { Top = 100, Right = 10 },
|
||||
Children = new []
|
||||
Children = new[]
|
||||
{
|
||||
//CollectionSettings = new CollectionSettings(),
|
||||
//DiscussionSettings = new DiscussionSettings(),
|
||||
|
@ -141,8 +141,6 @@ namespace osu.Game.Screens.Play
|
||||
|
||||
public override bool ReceiveMouseInputAt(Vector2 screenSpacePos) => true;
|
||||
|
||||
public override bool HandleInput => true;
|
||||
|
||||
protected override bool OnKeyDown(InputState state, KeyDownEventArgs args) => Target.Children.Any(c => c.TriggerOnKeyDown(state, args));
|
||||
|
||||
protected override bool OnKeyUp(InputState state, KeyUpEventArgs args) => Target.Children.Any(c => c.TriggerOnKeyUp(state, args));
|
||||
|
@ -119,7 +119,7 @@ namespace osu.Game.Screens.Play
|
||||
base.Update();
|
||||
}
|
||||
|
||||
public class PauseOverlay : MenuOverlay
|
||||
public class PauseOverlay : GameplayMenuOverlay
|
||||
{
|
||||
public Action OnResume;
|
||||
|
||||
@ -130,7 +130,7 @@ namespace osu.Game.Screens.Play
|
||||
{
|
||||
if (!args.Repeat && args.Key == Key.Escape)
|
||||
{
|
||||
Buttons.Children.First().TriggerOnClick();
|
||||
InternalButtons.Children.First().TriggerOnClick();
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -140,9 +140,9 @@ namespace osu.Game.Screens.Play
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuColour colours)
|
||||
{
|
||||
AddButton("Continue", colours.Green, OnResume);
|
||||
AddButton("Retry", colours.YellowDark, OnRetry);
|
||||
AddButton("Quit", new Color4(170, 27, 39, 255), OnQuit);
|
||||
AddButton("Continue", colours.Green, () => OnResume?.Invoke());
|
||||
AddButton("Retry", colours.YellowDark, () => OnRetry?.Invoke());
|
||||
AddButton("Quit", new Color4(170, 27, 39, 255), () => OnQuit?.Invoke());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -245,7 +245,7 @@ namespace osu.Game.Screens.Play
|
||||
|
||||
private void initializeStoryboard(bool asyncLoad)
|
||||
{
|
||||
var beatmap = Beatmap.Value.Beatmap;
|
||||
var beatmap = Beatmap.Value;
|
||||
|
||||
storyboard = beatmap.Storyboard.CreateDrawable(Beatmap.Value);
|
||||
storyboard.Masking = true;
|
||||
@ -388,7 +388,7 @@ namespace osu.Game.Screens.Play
|
||||
initializeStoryboard(true);
|
||||
|
||||
var beatmap = Beatmap.Value;
|
||||
var storyboardVisible = showStoryboard && beatmap.Beatmap.Storyboard.HasDrawable;
|
||||
var storyboardVisible = showStoryboard && beatmap.Storyboard.HasDrawable;
|
||||
|
||||
storyboardContainer.FadeColour(new Color4(opacity, opacity, opacity, 1), 800);
|
||||
storyboardContainer.FadeTo(storyboardVisible && opacity > 0 ? 1 : 0);
|
||||
|
@ -7,7 +7,6 @@ using osu.Framework.Graphics.Containers;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using osu.Game.Beatmaps.Drawables;
|
||||
using osu.Game.Configuration;
|
||||
using osu.Framework.Input;
|
||||
using OpenTK.Input;
|
||||
@ -15,493 +14,304 @@ using osu.Framework.MathUtils;
|
||||
using System.Diagnostics;
|
||||
using System.Threading.Tasks;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Caching;
|
||||
using osu.Framework.Threading;
|
||||
using osu.Framework.Configuration;
|
||||
using osu.Framework.Extensions.IEnumerableExtensions;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Graphics.Containers;
|
||||
using osu.Game.Graphics.Cursor;
|
||||
using osu.Game.Screens.Select.Carousel;
|
||||
|
||||
namespace osu.Game.Screens.Select
|
||||
{
|
||||
public class BeatmapCarousel : OsuScrollContainer
|
||||
{
|
||||
public BeatmapInfo SelectedBeatmap => selectedPanel?.Beatmap;
|
||||
/// <summary>
|
||||
/// Triggered when the <see cref="BeatmapSets"/> loaded change and are completely loaded.
|
||||
/// </summary>
|
||||
public Action BeatmapSetsChanged;
|
||||
|
||||
/// <summary>
|
||||
/// The currently selected beatmap.
|
||||
/// </summary>
|
||||
public BeatmapInfo SelectedBeatmap => selectedBeatmap?.Beatmap;
|
||||
|
||||
private CarouselBeatmap selectedBeatmap => selectedBeatmapSet?.Beatmaps.FirstOrDefault(s => s.State == CarouselItemState.Selected);
|
||||
|
||||
/// <summary>
|
||||
/// The currently selected beatmap set.
|
||||
/// </summary>
|
||||
public BeatmapSetInfo SelectedBeatmapSet => selectedBeatmapSet?.BeatmapSet;
|
||||
|
||||
private CarouselBeatmapSet selectedBeatmapSet;
|
||||
|
||||
/// <summary>
|
||||
/// Raised when the <see cref="SelectedBeatmap"/> is changed.
|
||||
/// </summary>
|
||||
public Action<BeatmapInfo> SelectionChanged;
|
||||
|
||||
public override bool HandleInput => AllowSelection;
|
||||
|
||||
public Action BeatmapsChanged;
|
||||
private IEnumerable<CarouselBeatmapSet> beatmapSets => root.Children.OfType<CarouselBeatmapSet>();
|
||||
|
||||
public IEnumerable<BeatmapSetInfo> Beatmaps
|
||||
public IEnumerable<BeatmapSetInfo> BeatmapSets
|
||||
{
|
||||
get { return groups.Select(g => g.BeatmapSet); }
|
||||
|
||||
get { return beatmapSets.Select(g => g.BeatmapSet); }
|
||||
set
|
||||
{
|
||||
scrollableContent.Clear(false);
|
||||
panels.Clear();
|
||||
groups.Clear();
|
||||
|
||||
List<BeatmapGroup> newGroups = null;
|
||||
CarouselGroup newRoot = new CarouselGroupEagerSelect();
|
||||
|
||||
Task.Run(() =>
|
||||
{
|
||||
newGroups = value.Select(createGroup).Where(g => g != null).ToList();
|
||||
criteria.Filter(newGroups);
|
||||
}).ContinueWith(t =>
|
||||
{
|
||||
Schedule(() =>
|
||||
{
|
||||
foreach (var g in newGroups)
|
||||
if (g != null) addGroup(g);
|
||||
value.Select(createCarouselSet).Where(g => g != null).ForEach(newRoot.AddChild);
|
||||
newRoot.Filter(activeCriteria);
|
||||
|
||||
computeYPositions();
|
||||
BeatmapsChanged?.Invoke();
|
||||
});
|
||||
});
|
||||
// preload drawables as the ctor overhead is quite high currently.
|
||||
var _ = newRoot.Drawables;
|
||||
}).ContinueWith(_ => Schedule(() =>
|
||||
{
|
||||
root = newRoot;
|
||||
scrollableContent.Clear(false);
|
||||
itemsCache.Invalidate();
|
||||
scrollPositionCache.Invalidate();
|
||||
BeatmapSetsChanged?.Invoke();
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
private readonly List<float> yPositions = new List<float>();
|
||||
private Cached itemsCache = new Cached();
|
||||
private Cached scrollPositionCache = new Cached();
|
||||
|
||||
/// <summary>
|
||||
/// Required for now unfortunately.
|
||||
/// </summary>
|
||||
private BeatmapManager manager;
|
||||
private readonly Container<DrawableCarouselItem> scrollableContent;
|
||||
|
||||
private readonly Container<Panel> scrollableContent;
|
||||
public Bindable<RandomSelectAlgorithm> RandomAlgorithm = new Bindable<RandomSelectAlgorithm>();
|
||||
private readonly List<CarouselBeatmapSet> previouslyVisitedRandomSets = new List<CarouselBeatmapSet>();
|
||||
private readonly Stack<CarouselBeatmap> randomSelectedBeatmaps = new Stack<CarouselBeatmap>();
|
||||
|
||||
private readonly List<BeatmapGroup> groups = new List<BeatmapGroup>();
|
||||
|
||||
private Bindable<SelectionRandomType> randomType;
|
||||
private readonly List<BeatmapGroup> seenGroups = new List<BeatmapGroup>();
|
||||
|
||||
private readonly List<Panel> panels = new List<Panel>();
|
||||
|
||||
private readonly Stack<KeyValuePair<BeatmapGroup, BeatmapPanel>> randomSelectedBeatmaps = new Stack<KeyValuePair<BeatmapGroup, BeatmapPanel>>();
|
||||
|
||||
private BeatmapGroup selectedGroup;
|
||||
private BeatmapPanel selectedPanel;
|
||||
protected List<DrawableCarouselItem> Items = new List<DrawableCarouselItem>();
|
||||
private CarouselGroup root = new CarouselGroupEagerSelect();
|
||||
|
||||
public BeatmapCarousel()
|
||||
{
|
||||
Add(new OsuContextMenuContainer
|
||||
Child = new OsuContextMenuContainer
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
AutoSizeAxes = Axes.Y,
|
||||
Child = scrollableContent = new Container<Panel>
|
||||
Child = scrollableContent = new Container<DrawableCarouselItem>
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
}
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
public void AddBeatmap(BeatmapSetInfo beatmapSet)
|
||||
[BackgroundDependencyLoader(permitNulls: true)]
|
||||
private void load(OsuConfigManager config)
|
||||
{
|
||||
config.BindWith(OsuSetting.RandomSelectAlgorithm, RandomAlgorithm);
|
||||
}
|
||||
|
||||
public void RemoveBeatmapSet(BeatmapSetInfo beatmapSet)
|
||||
{
|
||||
Schedule(() =>
|
||||
{
|
||||
var group = createGroup(beatmapSet);
|
||||
var existingSet = beatmapSets.FirstOrDefault(b => b.BeatmapSet.ID == beatmapSet.ID);
|
||||
|
||||
if (group == null)
|
||||
if (existingSet == null)
|
||||
return;
|
||||
|
||||
addGroup(group);
|
||||
computeYPositions();
|
||||
if (selectedGroup == null)
|
||||
selectGroup(group);
|
||||
root.RemoveChild(existingSet);
|
||||
itemsCache.Invalidate();
|
||||
});
|
||||
}
|
||||
|
||||
public void RemoveBeatmap(BeatmapSetInfo beatmapSet)
|
||||
public void UpdateBeatmapSet(BeatmapSetInfo beatmapSet)
|
||||
{
|
||||
Schedule(() => removeGroup(groups.Find(b => b.BeatmapSet.ID == beatmapSet.ID)));
|
||||
}
|
||||
|
||||
public void UpdateBeatmap(BeatmapInfo beatmap)
|
||||
{
|
||||
// todo: this method should not run more than once for the same BeatmapSetInfo.
|
||||
var set = manager.QueryBeatmapSet(s => s.ID == beatmap.BeatmapSetInfoID);
|
||||
|
||||
// todo: this method should be smarter as to not recreate panels that haven't changed, etc.
|
||||
var group = groups.Find(b => b.BeatmapSet.ID == set.ID);
|
||||
|
||||
int i = groups.IndexOf(group);
|
||||
if (i >= 0)
|
||||
groups.RemoveAt(i);
|
||||
|
||||
var newGroup = createGroup(set);
|
||||
|
||||
if (newGroup != null)
|
||||
Schedule(() =>
|
||||
{
|
||||
if (i >= 0)
|
||||
groups.Insert(i, newGroup);
|
||||
else
|
||||
groups.Add(newGroup);
|
||||
}
|
||||
CarouselBeatmapSet existingSet = beatmapSets.FirstOrDefault(b => b.BeatmapSet.ID == beatmapSet.ID);
|
||||
|
||||
bool hadSelection = selectedGroup == group;
|
||||
bool hadSelection = existingSet?.State?.Value == CarouselItemState.Selected;
|
||||
|
||||
if (hadSelection && newGroup == null)
|
||||
selectedGroup = null;
|
||||
var newSet = createCarouselSet(beatmapSet);
|
||||
|
||||
Filter(null, false);
|
||||
if (existingSet != null)
|
||||
root.RemoveChild(existingSet);
|
||||
|
||||
//check if we can/need to maintain our current selection.
|
||||
if (hadSelection && newGroup != null)
|
||||
{
|
||||
var newSelection =
|
||||
newGroup.BeatmapPanels.Find(p => p.Beatmap.ID == selectedPanel?.Beatmap.ID) ??
|
||||
newGroup.BeatmapPanels[Math.Min(newGroup.BeatmapPanels.Count - 1, group.BeatmapPanels.IndexOf(selectedPanel))];
|
||||
|
||||
selectGroup(newGroup, newSelection);
|
||||
}
|
||||
}
|
||||
|
||||
public void SelectBeatmap(BeatmapInfo beatmap, bool animated = true)
|
||||
{
|
||||
if (beatmap == null || beatmap.Hidden)
|
||||
{
|
||||
SelectNext();
|
||||
return;
|
||||
}
|
||||
|
||||
if (beatmap == SelectedBeatmap) return;
|
||||
|
||||
foreach (BeatmapGroup group in groups)
|
||||
{
|
||||
var panel = group.BeatmapPanels.FirstOrDefault(p => p.Beatmap.Equals(beatmap));
|
||||
if (panel != null)
|
||||
if (newSet == null)
|
||||
{
|
||||
selectGroup(group, panel, animated);
|
||||
itemsCache.Invalidate();
|
||||
SelectNext();
|
||||
return;
|
||||
}
|
||||
|
||||
root.AddChild(newSet);
|
||||
|
||||
applyActiveCriteria(false, false);
|
||||
|
||||
//check if we can/need to maintain our current selection.
|
||||
if (hadSelection)
|
||||
select((CarouselItem)newSet.Beatmaps.FirstOrDefault(b => b.Beatmap.ID == selectedBeatmap?.Beatmap.ID) ?? newSet);
|
||||
|
||||
itemsCache.Invalidate();
|
||||
});
|
||||
}
|
||||
|
||||
public void SelectBeatmap(BeatmapInfo beatmap)
|
||||
{
|
||||
if (beatmap?.Hidden != false)
|
||||
return;
|
||||
|
||||
foreach (CarouselBeatmapSet group in beatmapSets)
|
||||
{
|
||||
var item = group.Beatmaps.FirstOrDefault(p => p.Beatmap.Equals(beatmap));
|
||||
if (item != null)
|
||||
{
|
||||
select(item);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Action<BeatmapInfo> SelectionChanged;
|
||||
|
||||
public Action StartRequested;
|
||||
|
||||
public Action<BeatmapSetInfo> DeleteRequested;
|
||||
|
||||
public Action<BeatmapSetInfo> RestoreRequested;
|
||||
|
||||
public Action<BeatmapInfo> EditRequested;
|
||||
|
||||
public Action<BeatmapInfo> HideDifficultyRequested;
|
||||
|
||||
private void selectNullBeatmap()
|
||||
{
|
||||
selectedGroup = null;
|
||||
selectedPanel = null;
|
||||
SelectionChanged?.Invoke(null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Increment selection in the carousel in a chosen direction.
|
||||
/// </summary>
|
||||
/// <param name="direction">The direction to increment. Negative is backwards.</param>
|
||||
/// <param name="skipDifficulties">Whether to skip individual difficulties and only increment over full groups.</param>
|
||||
public void SelectNext(int direction = 1, bool skipDifficulties = true)
|
||||
{
|
||||
if (groups.All(g => g.State == BeatmapGroupState.Hidden))
|
||||
{
|
||||
selectNullBeatmap();
|
||||
return;
|
||||
}
|
||||
int originalIndex = Items.IndexOf(selectedBeatmap?.Drawables.First());
|
||||
int currentIndex = originalIndex;
|
||||
|
||||
if (!skipDifficulties && selectedGroup != null)
|
||||
{
|
||||
int i = selectedGroup.BeatmapPanels.IndexOf(selectedPanel) + direction;
|
||||
// local function to increment the index in the required direction, wrapping over extremities.
|
||||
int incrementIndex() => currentIndex = (currentIndex + direction + Items.Count) % Items.Count;
|
||||
|
||||
if (i >= 0 && i < selectedGroup.BeatmapPanels.Count)
|
||||
while (incrementIndex() != originalIndex)
|
||||
{
|
||||
var item = Items[currentIndex].Item;
|
||||
|
||||
if (item.Filtered || item.State == CarouselItemState.Selected) continue;
|
||||
|
||||
switch (item)
|
||||
{
|
||||
//changing difficulty panel, not set.
|
||||
selectGroup(selectedGroup, selectedGroup.BeatmapPanels[i]);
|
||||
return;
|
||||
case CarouselBeatmap beatmap:
|
||||
if (skipDifficulties) continue;
|
||||
select(beatmap);
|
||||
return;
|
||||
case CarouselBeatmapSet set:
|
||||
if (skipDifficulties)
|
||||
select(set);
|
||||
else
|
||||
select(direction > 0 ? set.Beatmaps.First(b => !b.Filtered) : set.Beatmaps.Last(b => !b.Filtered));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
int startIndex = Math.Max(0, groups.IndexOf(selectedGroup));
|
||||
int index = startIndex;
|
||||
|
||||
do
|
||||
{
|
||||
index = (index + direction + groups.Count) % groups.Count;
|
||||
if (groups[index].State != BeatmapGroupState.Hidden)
|
||||
{
|
||||
if (skipDifficulties)
|
||||
SelectBeatmap(groups[index].SelectedPanel != null ? groups[index].SelectedPanel.Beatmap : groups[index].BeatmapPanels.First().Beatmap);
|
||||
else
|
||||
SelectBeatmap(direction == 1 ? groups[index].BeatmapPanels.First().Beatmap : groups[index].BeatmapPanels.Last().Beatmap);
|
||||
|
||||
return;
|
||||
}
|
||||
} while (index != startIndex);
|
||||
}
|
||||
|
||||
private IEnumerable<BeatmapGroup> getVisibleGroups() => groups.Where(selectGroup => selectGroup.State != BeatmapGroupState.Hidden);
|
||||
|
||||
public void SelectNextRandom()
|
||||
{
|
||||
if (groups.Count == 0)
|
||||
var visible = beatmapSets.Where(s => !s.Filtered).ToList();
|
||||
if (!visible.Any())
|
||||
return;
|
||||
|
||||
var visibleGroups = getVisibleGroups();
|
||||
if (!visibleGroups.Any())
|
||||
return;
|
||||
|
||||
if (selectedGroup != null)
|
||||
randomSelectedBeatmaps.Push(new KeyValuePair<BeatmapGroup, BeatmapPanel>(selectedGroup, selectedGroup.SelectedPanel));
|
||||
|
||||
BeatmapGroup group;
|
||||
|
||||
if (randomType == SelectionRandomType.RandomPermutation)
|
||||
if (selectedBeatmap != null)
|
||||
{
|
||||
var notSeenGroups = visibleGroups.Except(seenGroups);
|
||||
if (!notSeenGroups.Any())
|
||||
randomSelectedBeatmaps.Push(selectedBeatmap);
|
||||
|
||||
// when performing a random, we want to add the current set to the previously visited list
|
||||
// else the user may be "randomised" to the existing selection.
|
||||
if (previouslyVisitedRandomSets.LastOrDefault() != selectedBeatmapSet)
|
||||
previouslyVisitedRandomSets.Add(selectedBeatmapSet);
|
||||
}
|
||||
|
||||
CarouselBeatmapSet set;
|
||||
|
||||
if (RandomAlgorithm == RandomSelectAlgorithm.RandomPermutation)
|
||||
{
|
||||
var notYetVisitedSets = visible.Except(previouslyVisitedRandomSets).ToList();
|
||||
if (!notYetVisitedSets.Any())
|
||||
{
|
||||
seenGroups.Clear();
|
||||
notSeenGroups = visibleGroups;
|
||||
previouslyVisitedRandomSets.Clear();
|
||||
notYetVisitedSets = visible;
|
||||
}
|
||||
|
||||
group = notSeenGroups.ElementAt(RNG.Next(notSeenGroups.Count()));
|
||||
seenGroups.Add(group);
|
||||
set = notYetVisitedSets.ElementAt(RNG.Next(notYetVisitedSets.Count));
|
||||
previouslyVisitedRandomSets.Add(set);
|
||||
}
|
||||
else
|
||||
group = visibleGroups.ElementAt(RNG.Next(visibleGroups.Count()));
|
||||
set = visible.ElementAt(RNG.Next(visible.Count));
|
||||
|
||||
BeatmapPanel panel = group.BeatmapPanels[RNG.Next(group.BeatmapPanels.Count)];
|
||||
|
||||
selectGroup(group, panel);
|
||||
select(set.Beatmaps.Skip(RNG.Next(set.Beatmaps.Count())).FirstOrDefault());
|
||||
}
|
||||
|
||||
public void SelectPreviousRandom()
|
||||
{
|
||||
if (!randomSelectedBeatmaps.Any())
|
||||
return;
|
||||
|
||||
var visibleGroups = getVisibleGroups();
|
||||
if (!visibleGroups.Any())
|
||||
return;
|
||||
|
||||
while (randomSelectedBeatmaps.Any())
|
||||
{
|
||||
var beatmapCoordinates = randomSelectedBeatmaps.Pop();
|
||||
var group = beatmapCoordinates.Key;
|
||||
if (visibleGroups.Contains(group))
|
||||
var beatmap = randomSelectedBeatmaps.Pop();
|
||||
|
||||
if (!beatmap.Filtered)
|
||||
{
|
||||
selectGroup(group, beatmapCoordinates.Value);
|
||||
if (RandomAlgorithm == RandomSelectAlgorithm.RandomPermutation)
|
||||
previouslyVisitedRandomSets.Remove(selectedBeatmapSet);
|
||||
select(beatmap);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private FilterCriteria criteria = new FilterCriteria();
|
||||
private void select(CarouselItem item)
|
||||
{
|
||||
if (item == null) return;
|
||||
item.State.Value = CarouselItemState.Selected;
|
||||
}
|
||||
|
||||
private ScheduledDelegate filterTask;
|
||||
private FilterCriteria activeCriteria = new FilterCriteria();
|
||||
|
||||
protected ScheduledDelegate FilterTask;
|
||||
|
||||
public bool AllowSelection = true;
|
||||
|
||||
public void FlushPendingFilters()
|
||||
public void FlushPendingFilterOperations()
|
||||
{
|
||||
if (filterTask?.Completed == false)
|
||||
Filter(null, false);
|
||||
if (FilterTask?.Completed == false)
|
||||
applyActiveCriteria(false, false);
|
||||
}
|
||||
|
||||
public void Filter(FilterCriteria newCriteria = null, bool debounce = true)
|
||||
public void Filter(FilterCriteria newCriteria, bool debounce = true)
|
||||
{
|
||||
if (newCriteria != null)
|
||||
criteria = newCriteria;
|
||||
activeCriteria = newCriteria;
|
||||
|
||||
if (!IsLoaded) return;
|
||||
applyActiveCriteria(debounce, true);
|
||||
}
|
||||
|
||||
Action perform = delegate
|
||||
private void applyActiveCriteria(bool debounce, bool scroll)
|
||||
{
|
||||
if (root.Children.Any() != true) return;
|
||||
|
||||
void perform()
|
||||
{
|
||||
filterTask = null;
|
||||
FilterTask = null;
|
||||
|
||||
criteria.Filter(groups);
|
||||
root.Filter(activeCriteria);
|
||||
itemsCache.Invalidate();
|
||||
if (scroll) scrollPositionCache.Invalidate();
|
||||
}
|
||||
|
||||
var filtered = new List<BeatmapGroup>(groups);
|
||||
|
||||
scrollableContent.Clear(false);
|
||||
panels.Clear();
|
||||
groups.Clear();
|
||||
|
||||
foreach (var g in filtered)
|
||||
addGroup(g);
|
||||
|
||||
computeYPositions();
|
||||
|
||||
if (selectedGroup == null || selectedGroup.State == BeatmapGroupState.Hidden)
|
||||
SelectNext();
|
||||
else
|
||||
selectGroup(selectedGroup, selectedPanel);
|
||||
};
|
||||
|
||||
filterTask?.Cancel();
|
||||
filterTask = null;
|
||||
FilterTask?.Cancel();
|
||||
FilterTask = null;
|
||||
|
||||
if (debounce)
|
||||
filterTask = Scheduler.AddDelayed(perform, 250);
|
||||
FilterTask = Scheduler.AddDelayed(perform, 250);
|
||||
else
|
||||
perform();
|
||||
}
|
||||
|
||||
public void ScrollToSelected(bool animated = true)
|
||||
{
|
||||
float selectedY = computeYPositions(animated);
|
||||
ScrollTo(selectedY, animated);
|
||||
}
|
||||
private float? scrollTarget;
|
||||
|
||||
private BeatmapGroup createGroup(BeatmapSetInfo beatmapSet)
|
||||
{
|
||||
if (beatmapSet.Beatmaps.All(b => b.Hidden))
|
||||
return null;
|
||||
|
||||
foreach (var b in beatmapSet.Beatmaps)
|
||||
{
|
||||
if (b.Metadata == null)
|
||||
b.Metadata = beatmapSet.Metadata;
|
||||
}
|
||||
|
||||
return new BeatmapGroup(beatmapSet, manager)
|
||||
{
|
||||
SelectionChanged = (g, p) => selectGroup(g, p),
|
||||
StartRequested = b => StartRequested?.Invoke(),
|
||||
DeleteRequested = b => DeleteRequested?.Invoke(b),
|
||||
RestoreHiddenRequested = s => RestoreRequested?.Invoke(s),
|
||||
EditRequested = b => EditRequested?.Invoke(b),
|
||||
HideDifficultyRequested = b => HideDifficultyRequested?.Invoke(b),
|
||||
State = BeatmapGroupState.Collapsed
|
||||
};
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader(permitNulls: true)]
|
||||
private void load(BeatmapManager manager, OsuConfigManager config)
|
||||
{
|
||||
this.manager = manager;
|
||||
|
||||
randomType = config.GetBindable<SelectionRandomType>(OsuSetting.SelectionRandomType);
|
||||
}
|
||||
|
||||
private void addGroup(BeatmapGroup group)
|
||||
{
|
||||
groups.Add(group);
|
||||
panels.Add(group.Header);
|
||||
panels.AddRange(group.BeatmapPanels);
|
||||
}
|
||||
|
||||
private void removeGroup(BeatmapGroup group)
|
||||
{
|
||||
if (group == null)
|
||||
return;
|
||||
|
||||
if (selectedGroup == group)
|
||||
{
|
||||
if (getVisibleGroups().Count() == 1)
|
||||
selectNullBeatmap();
|
||||
else
|
||||
SelectNext();
|
||||
}
|
||||
|
||||
groups.Remove(group);
|
||||
panels.Remove(group.Header);
|
||||
foreach (var p in group.BeatmapPanels)
|
||||
panels.Remove(p);
|
||||
|
||||
scrollableContent.Remove(group.Header);
|
||||
scrollableContent.RemoveRange(group.BeatmapPanels);
|
||||
|
||||
computeYPositions();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Computes the target Y positions for every panel in the carousel.
|
||||
/// </summary>
|
||||
/// <returns>The Y position of the currently selected panel.</returns>
|
||||
private float computeYPositions(bool animated = true)
|
||||
{
|
||||
yPositions.Clear();
|
||||
|
||||
float currentY = DrawHeight / 2;
|
||||
float selectedY = currentY;
|
||||
|
||||
foreach (BeatmapGroup group in groups)
|
||||
{
|
||||
movePanel(group.Header, group.State != BeatmapGroupState.Hidden, animated, ref currentY);
|
||||
|
||||
if (group.State == BeatmapGroupState.Expanded)
|
||||
{
|
||||
group.Header.MoveToX(-100, 500, Easing.OutExpo);
|
||||
var headerY = group.Header.Position.Y;
|
||||
|
||||
foreach (BeatmapPanel panel in group.BeatmapPanels)
|
||||
{
|
||||
if (panel == selectedPanel)
|
||||
selectedY = currentY + panel.DrawHeight / 2 - DrawHeight / 2;
|
||||
|
||||
panel.MoveToX(-50, 500, Easing.OutExpo);
|
||||
|
||||
//on first display we want to begin hidden under our group's header.
|
||||
if (panel.Alpha == 0)
|
||||
panel.MoveToY(headerY);
|
||||
|
||||
movePanel(panel, true, animated, ref currentY);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
group.Header.MoveToX(0, 500, Easing.OutExpo);
|
||||
|
||||
foreach (BeatmapPanel panel in group.BeatmapPanels)
|
||||
{
|
||||
panel.MoveToX(0, 500, Easing.OutExpo);
|
||||
movePanel(panel, false, animated, ref currentY);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
currentY += DrawHeight / 2;
|
||||
scrollableContent.Height = currentY;
|
||||
|
||||
return selectedY;
|
||||
}
|
||||
|
||||
private void movePanel(Panel panel, bool advance, bool animated, ref float currentY)
|
||||
{
|
||||
yPositions.Add(currentY);
|
||||
panel.MoveToY(currentY, animated ? 750 : 0, Easing.OutExpo);
|
||||
|
||||
if (advance)
|
||||
currentY += panel.DrawHeight + 5;
|
||||
}
|
||||
|
||||
private void selectGroup(BeatmapGroup group, BeatmapPanel panel = null, bool animated = true)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (panel == null)
|
||||
panel = group.BeatmapPanels.First();
|
||||
|
||||
if (selectedPanel == panel) return;
|
||||
|
||||
Trace.Assert(group.BeatmapPanels.Contains(panel), @"Selected panel must be in provided group");
|
||||
|
||||
if (selectedGroup != null && selectedGroup != group && selectedGroup.State != BeatmapGroupState.Hidden)
|
||||
selectedGroup.State = BeatmapGroupState.Collapsed;
|
||||
|
||||
group.State = BeatmapGroupState.Expanded;
|
||||
group.SelectedPanel = panel;
|
||||
|
||||
panel.State = PanelSelectedState.Selected;
|
||||
|
||||
if (selectedPanel == panel) return;
|
||||
|
||||
selectedPanel = panel;
|
||||
selectedGroup = group;
|
||||
|
||||
SelectionChanged?.Invoke(panel.Beatmap);
|
||||
}
|
||||
finally
|
||||
{
|
||||
ScrollToSelected(animated);
|
||||
}
|
||||
}
|
||||
public void ScrollToSelected() => scrollPositionCache.Invalidate();
|
||||
|
||||
protected override bool OnKeyDown(InputState state, KeyDownEventArgs args)
|
||||
{
|
||||
@ -537,68 +347,185 @@ namespace osu.Game.Screens.Select
|
||||
{
|
||||
base.Update();
|
||||
|
||||
if (!itemsCache.IsValid)
|
||||
updateItems();
|
||||
|
||||
if (!scrollPositionCache.IsValid)
|
||||
updateScrollPosition();
|
||||
|
||||
float drawHeight = DrawHeight;
|
||||
|
||||
// Remove all panels that should no longer be on-screen
|
||||
scrollableContent.RemoveAll(delegate(Panel p)
|
||||
{
|
||||
float panelPosY = p.Position.Y;
|
||||
bool remove = panelPosY < Current - p.DrawHeight || panelPosY > Current + drawHeight || !p.IsPresent;
|
||||
return remove;
|
||||
});
|
||||
// Remove all items that should no longer be on-screen
|
||||
scrollableContent.RemoveAll(p => p.Y < Current - p.DrawHeight || p.Y > Current + drawHeight || !p.IsPresent);
|
||||
|
||||
// Find index range of all panels that should be on-screen
|
||||
Trace.Assert(panels.Count == yPositions.Count);
|
||||
// Find index range of all items that should be on-screen
|
||||
Trace.Assert(Items.Count == yPositions.Count);
|
||||
|
||||
int firstIndex = yPositions.BinarySearch(Current - Panel.MAX_HEIGHT);
|
||||
int firstIndex = yPositions.BinarySearch(Current - DrawableCarouselItem.MAX_HEIGHT);
|
||||
if (firstIndex < 0) firstIndex = ~firstIndex;
|
||||
int lastIndex = yPositions.BinarySearch(Current + drawHeight);
|
||||
if (lastIndex < 0)
|
||||
{
|
||||
lastIndex = ~lastIndex;
|
||||
if (lastIndex < 0) lastIndex = ~lastIndex;
|
||||
|
||||
// Add the first panel of the last visible beatmap group to preload its data.
|
||||
if (lastIndex != 0 && panels[lastIndex - 1] is BeatmapSetHeader)
|
||||
lastIndex++;
|
||||
}
|
||||
int notVisibleCount = 0;
|
||||
|
||||
// Add those panels within the previously found index range that should be displayed.
|
||||
// Add those items within the previously found index range that should be displayed.
|
||||
for (int i = firstIndex; i < lastIndex; ++i)
|
||||
{
|
||||
Panel panel = panels[i];
|
||||
if (panel.State == PanelSelectedState.Hidden)
|
||||
DrawableCarouselItem item = Items[i];
|
||||
|
||||
if (!item.Item.Visible)
|
||||
{
|
||||
if (!item.IsPresent)
|
||||
notVisibleCount++;
|
||||
continue;
|
||||
}
|
||||
|
||||
// Only add if we're not already part of the content.
|
||||
if (!scrollableContent.Contains(panel))
|
||||
if (!scrollableContent.Contains(item))
|
||||
{
|
||||
// Makes sure headers are always _below_ panels,
|
||||
// Makes sure headers are always _below_ items,
|
||||
// and depth flows downward.
|
||||
panel.Depth = i + (panel is BeatmapSetHeader ? panels.Count : 0);
|
||||
item.Depth = i + (item is DrawableCarouselBeatmapSet ? -Items.Count : 0);
|
||||
|
||||
switch (panel.LoadState)
|
||||
switch (item.LoadState)
|
||||
{
|
||||
case LoadState.NotLoaded:
|
||||
LoadComponentAsync(panel);
|
||||
LoadComponentAsync(item);
|
||||
break;
|
||||
case LoadState.Loading:
|
||||
break;
|
||||
default:
|
||||
scrollableContent.Add(panel);
|
||||
scrollableContent.Add(item);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Update externally controlled state of currently visible panels
|
||||
// this is not actually useful right now, but once we have groups may well be.
|
||||
if (notVisibleCount > 50)
|
||||
itemsCache.Invalidate();
|
||||
|
||||
// Update externally controlled state of currently visible items
|
||||
// (e.g. x-offset and opacity).
|
||||
float halfHeight = drawHeight / 2;
|
||||
foreach (Panel p in scrollableContent.Children)
|
||||
updatePanel(p, halfHeight);
|
||||
foreach (DrawableCarouselItem p in scrollableContent.Children)
|
||||
updateItem(p, halfHeight);
|
||||
}
|
||||
|
||||
private CarouselBeatmapSet createCarouselSet(BeatmapSetInfo beatmapSet)
|
||||
{
|
||||
if (beatmapSet.Beatmaps.All(b => b.Hidden))
|
||||
return null;
|
||||
|
||||
// todo: remove the need for this.
|
||||
foreach (var b in beatmapSet.Beatmaps)
|
||||
{
|
||||
if (b.Metadata == null)
|
||||
b.Metadata = beatmapSet.Metadata;
|
||||
}
|
||||
|
||||
var set = new CarouselBeatmapSet(beatmapSet);
|
||||
|
||||
foreach (var c in set.Beatmaps)
|
||||
{
|
||||
c.State.ValueChanged += v =>
|
||||
{
|
||||
if (v == CarouselItemState.Selected)
|
||||
{
|
||||
selectedBeatmapSet = set;
|
||||
SelectionChanged?.Invoke(c.Beatmap);
|
||||
|
||||
itemsCache.Invalidate();
|
||||
scrollPositionCache.Invalidate();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
return set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Computes the x-offset of currently visible panels. Makes the carousel appear round.
|
||||
/// Computes the target Y positions for every item in the carousel.
|
||||
/// </summary>
|
||||
/// <returns>The Y position of the currently selected item.</returns>
|
||||
private void updateItems()
|
||||
{
|
||||
Items = root.Drawables.ToList();
|
||||
|
||||
yPositions.Clear();
|
||||
|
||||
float currentY = DrawHeight / 2;
|
||||
DrawableCarouselBeatmapSet lastSet = null;
|
||||
|
||||
scrollTarget = null;
|
||||
|
||||
foreach (DrawableCarouselItem d in Items)
|
||||
{
|
||||
if (d.IsPresent)
|
||||
{
|
||||
switch (d)
|
||||
{
|
||||
case DrawableCarouselBeatmapSet set:
|
||||
lastSet = set;
|
||||
|
||||
set.MoveToX(set.Item.State == CarouselItemState.Selected ? -100 : 0, 500, Easing.OutExpo);
|
||||
set.MoveToY(currentY, 750, Easing.OutExpo);
|
||||
break;
|
||||
case DrawableCarouselBeatmap beatmap:
|
||||
if (beatmap.Item.State.Value == CarouselItemState.Selected)
|
||||
scrollTarget = currentY + beatmap.DrawHeight / 2 - DrawHeight / 2;
|
||||
|
||||
void performMove(float y, float? startY = null)
|
||||
{
|
||||
if (startY != null) beatmap.MoveTo(new Vector2(0, startY.Value));
|
||||
beatmap.MoveToX(beatmap.Item.State == CarouselItemState.Selected ? -50 : 0, 500, Easing.OutExpo);
|
||||
beatmap.MoveToY(y, 750, Easing.OutExpo);
|
||||
}
|
||||
|
||||
Debug.Assert(lastSet != null);
|
||||
|
||||
float? setY = null;
|
||||
if (!d.IsLoaded || beatmap.Alpha == 0) // can't use IsPresent due to DrawableCarouselItem override.
|
||||
setY = lastSet.Y + lastSet.DrawHeight + 5;
|
||||
|
||||
if (d.IsLoaded)
|
||||
performMove(currentY, setY);
|
||||
else
|
||||
{
|
||||
float y = currentY;
|
||||
d.OnLoadComplete = _ => performMove(y, setY);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
yPositions.Add(currentY);
|
||||
|
||||
if (d.Item.Visible)
|
||||
currentY += d.DrawHeight + 5;
|
||||
}
|
||||
|
||||
currentY += DrawHeight / 2;
|
||||
scrollableContent.Height = currentY;
|
||||
|
||||
if (selectedBeatmapSet != null && selectedBeatmapSet.State.Value != CarouselItemState.Selected)
|
||||
{
|
||||
selectedBeatmapSet = null;
|
||||
SelectionChanged?.Invoke(null);
|
||||
}
|
||||
|
||||
itemsCache.Validate();
|
||||
}
|
||||
|
||||
private void updateScrollPosition()
|
||||
{
|
||||
if (scrollTarget != null) ScrollTo(scrollTarget.Value);
|
||||
scrollPositionCache.Validate();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Computes the x-offset of currently visible items. Makes the carousel appear round.
|
||||
/// </summary>
|
||||
/// <param name="dist">
|
||||
/// Vertical distance from the center of the carousel container
|
||||
@ -616,20 +543,20 @@ namespace osu.Game.Screens.Select
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Update a panel's x position and multiplicative alpha based on its y position and
|
||||
/// Update a item's x position and multiplicative alpha based on its y position and
|
||||
/// the current scroll position.
|
||||
/// </summary>
|
||||
/// <param name="p">The panel to be updated.</param>
|
||||
/// <param name="p">The item to be updated.</param>
|
||||
/// <param name="halfHeight">Half the draw height of the carousel container.</param>
|
||||
private void updatePanel(Panel p, float halfHeight)
|
||||
private void updateItem(DrawableCarouselItem p, float halfHeight)
|
||||
{
|
||||
var height = p.IsPresent ? p.DrawHeight : 0;
|
||||
|
||||
float panelDrawY = p.Position.Y - Current + height / 2;
|
||||
float dist = Math.Abs(1f - panelDrawY / halfHeight);
|
||||
float itemDrawY = p.Position.Y - Current + height / 2;
|
||||
float dist = Math.Abs(1f - itemDrawY / halfHeight);
|
||||
|
||||
// Setting the origin position serves as an additive position on top of potential
|
||||
// local transformation we may want to apply (e.g. when a panel gets selected, we
|
||||
// local transformation we may want to apply (e.g. when a item gets selected, we
|
||||
// may want to smoothly transform it leftwards.)
|
||||
p.OriginPosition = new Vector2(-offsetX(dist, halfHeight), 0);
|
||||
|
||||
|
@ -19,6 +19,7 @@ using osu.Game.Graphics.Sprites;
|
||||
using osu.Game.Rulesets.Objects;
|
||||
using osu.Game.Rulesets.Objects.Types;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Framework.Graphics.Cursor;
|
||||
|
||||
namespace osu.Game.Screens.Select
|
||||
{
|
||||
@ -217,8 +218,8 @@ namespace osu.Game.Screens.Select
|
||||
},
|
||||
new FillFlowContainer
|
||||
{
|
||||
Margin = new MarginPadding { Top = 20, Left = 10 },
|
||||
Spacing = new Vector2(40, 0),
|
||||
Margin = new MarginPadding { Top = 20 },
|
||||
Spacing = new Vector2(20, 0),
|
||||
AutoSizeAxes = Axes.Both,
|
||||
Children = labels
|
||||
},
|
||||
@ -232,43 +233,59 @@ namespace osu.Game.Screens.Select
|
||||
double bpmMax = beatmap.ControlPointInfo.BPMMaximum;
|
||||
double bpmMin = beatmap.ControlPointInfo.BPMMinimum;
|
||||
|
||||
if (Precision.AlmostEquals(bpmMin, bpmMax)) return $"{bpmMin:0}bpm";
|
||||
if (Precision.AlmostEquals(bpmMin, bpmMax)) return $"{bpmMin:0}";
|
||||
|
||||
return $"{bpmMin:0}-{bpmMax:0}bpm (mostly {beatmap.ControlPointInfo.BPMMode:0}bpm)";
|
||||
return $"{bpmMin:0}-{bpmMax:0} (mostly {beatmap.ControlPointInfo.BPMMode:0})";
|
||||
}
|
||||
|
||||
public class InfoLabel : Container
|
||||
public class InfoLabel : Container, IHasTooltip
|
||||
{
|
||||
public string TooltipText { get; private set; }
|
||||
|
||||
public InfoLabel(BeatmapStatistic statistic)
|
||||
{
|
||||
TooltipText = statistic.Name;
|
||||
AutoSizeAxes = Axes.Both;
|
||||
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new SpriteIcon
|
||||
new Container
|
||||
{
|
||||
Icon = FontAwesome.fa_square,
|
||||
Origin = Anchor.Centre,
|
||||
Colour = new Color4(68, 17, 136, 255),
|
||||
Rotation = 45,
|
||||
Size = new Vector2(20),
|
||||
},
|
||||
new SpriteIcon
|
||||
{
|
||||
Icon = statistic.Icon,
|
||||
Origin = Anchor.Centre,
|
||||
Colour = new Color4(255, 221, 85, 255),
|
||||
Scale = new Vector2(0.8f),
|
||||
Anchor = Anchor.CentreLeft,
|
||||
Origin = Anchor.CentreLeft,
|
||||
Size = new Vector2(20),
|
||||
Children = new[]
|
||||
{
|
||||
new SpriteIcon
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Colour = OsuColour.FromHex(@"441288"),
|
||||
Icon = FontAwesome.fa_square,
|
||||
Rotation = 45,
|
||||
},
|
||||
new SpriteIcon
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Scale = new Vector2(0.8f),
|
||||
Colour = OsuColour.FromHex(@"f7dd55"),
|
||||
Icon = statistic.Icon,
|
||||
},
|
||||
}
|
||||
},
|
||||
new OsuSpriteText
|
||||
{
|
||||
Margin = new MarginPadding { Left = 13 },
|
||||
Font = @"Exo2.0-Bold",
|
||||
Anchor = Anchor.CentreLeft,
|
||||
Origin = Anchor.CentreLeft,
|
||||
Colour = new Color4(255, 221, 85, 255),
|
||||
Font = @"Exo2.0-Bold",
|
||||
Margin = new MarginPadding { Left = 30 },
|
||||
Text = statistic.Content,
|
||||
TextSize = 17,
|
||||
Origin = Anchor.CentreLeft
|
||||
},
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
55
osu.Game/Screens/Select/Carousel/CarouselBeatmap.cs
Normal file
55
osu.Game/Screens/Select/Carousel/CarouselBeatmap.cs
Normal file
@ -0,0 +1,55 @@
|
||||
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using System;
|
||||
using System.Linq;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Screens.Select.Filter;
|
||||
|
||||
namespace osu.Game.Screens.Select.Carousel
|
||||
{
|
||||
public class CarouselBeatmap : CarouselItem
|
||||
{
|
||||
public readonly BeatmapInfo Beatmap;
|
||||
|
||||
public CarouselBeatmap(BeatmapInfo beatmap)
|
||||
{
|
||||
Beatmap = beatmap;
|
||||
State.Value = CarouselItemState.Collapsed;
|
||||
}
|
||||
|
||||
protected override DrawableCarouselItem CreateDrawableRepresentation() => new DrawableCarouselBeatmap(this);
|
||||
|
||||
public override void Filter(FilterCriteria criteria)
|
||||
{
|
||||
base.Filter(criteria);
|
||||
|
||||
bool match = criteria.Ruleset == null || Beatmap.RulesetID == criteria.Ruleset.ID || Beatmap.RulesetID == 0 && criteria.Ruleset.ID > 0 && criteria.AllowConvertedBeatmaps;
|
||||
|
||||
if (!string.IsNullOrEmpty(criteria.SearchText))
|
||||
match &=
|
||||
Beatmap.Metadata.SearchableTerms.Any(term => term.IndexOf(criteria.SearchText, StringComparison.InvariantCultureIgnoreCase) >= 0) ||
|
||||
Beatmap.Version.IndexOf(criteria.SearchText, StringComparison.InvariantCultureIgnoreCase) >= 0;
|
||||
|
||||
Filtered.Value = !match;
|
||||
}
|
||||
|
||||
public override int CompareTo(FilterCriteria criteria, CarouselItem other)
|
||||
{
|
||||
if (!(other is CarouselBeatmap otherBeatmap))
|
||||
return base.CompareTo(criteria, other);
|
||||
|
||||
switch (criteria.Sort)
|
||||
{
|
||||
default:
|
||||
case SortMode.Difficulty:
|
||||
var ruleset = Beatmap.RulesetID.CompareTo(otherBeatmap.Beatmap.RulesetID);
|
||||
if (ruleset != 0) return ruleset;
|
||||
|
||||
return Beatmap.StarDifficulty.CompareTo(otherBeatmap.Beatmap.StarDifficulty);
|
||||
}
|
||||
}
|
||||
|
||||
public override string ToString() => Beatmap.ToString();
|
||||
}
|
||||
}
|
58
osu.Game/Screens/Select/Carousel/CarouselBeatmapSet.cs
Normal file
58
osu.Game/Screens/Select/Carousel/CarouselBeatmapSet.cs
Normal file
@ -0,0 +1,58 @@
|
||||
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using osu.Framework.Extensions.IEnumerableExtensions;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Screens.Select.Filter;
|
||||
|
||||
namespace osu.Game.Screens.Select.Carousel
|
||||
{
|
||||
public class CarouselBeatmapSet : CarouselGroupEagerSelect
|
||||
{
|
||||
public IEnumerable<CarouselBeatmap> Beatmaps => InternalChildren.OfType<CarouselBeatmap>();
|
||||
|
||||
public BeatmapSetInfo BeatmapSet;
|
||||
|
||||
public CarouselBeatmapSet(BeatmapSetInfo beatmapSet)
|
||||
{
|
||||
BeatmapSet = beatmapSet ?? throw new ArgumentNullException(nameof(beatmapSet));
|
||||
|
||||
beatmapSet.Beatmaps
|
||||
.Where(b => !b.Hidden)
|
||||
.Select(b => new CarouselBeatmap(b))
|
||||
.ForEach(AddChild);
|
||||
}
|
||||
|
||||
protected override DrawableCarouselItem CreateDrawableRepresentation() => new DrawableCarouselBeatmapSet(this);
|
||||
|
||||
public override int CompareTo(FilterCriteria criteria, CarouselItem other)
|
||||
{
|
||||
if (!(other is CarouselBeatmapSet otherSet))
|
||||
return base.CompareTo(criteria, other);
|
||||
|
||||
switch (criteria.Sort)
|
||||
{
|
||||
default:
|
||||
case SortMode.Artist:
|
||||
return string.Compare(BeatmapSet.Metadata.Artist, otherSet.BeatmapSet.Metadata.Artist, StringComparison.InvariantCultureIgnoreCase);
|
||||
case SortMode.Title:
|
||||
return string.Compare(BeatmapSet.Metadata.Title, otherSet.BeatmapSet.Metadata.Title, StringComparison.InvariantCultureIgnoreCase);
|
||||
case SortMode.Author:
|
||||
return string.Compare(BeatmapSet.Metadata.Author.Username, otherSet.BeatmapSet.Metadata.Author.Username, StringComparison.InvariantCultureIgnoreCase);
|
||||
case SortMode.Difficulty:
|
||||
return BeatmapSet.MaxStarDifficulty.CompareTo(otherSet.BeatmapSet.MaxStarDifficulty);
|
||||
}
|
||||
}
|
||||
|
||||
public override void Filter(FilterCriteria criteria)
|
||||
{
|
||||
base.Filter(criteria);
|
||||
Filtered.Value = InternalChildren.All(i => i.Filtered);
|
||||
}
|
||||
|
||||
public override string ToString() => BeatmapSet.ToString();
|
||||
}
|
||||
}
|
91
osu.Game/Screens/Select/Carousel/CarouselGroup.cs
Normal file
91
osu.Game/Screens/Select/Carousel/CarouselGroup.cs
Normal file
@ -0,0 +1,91 @@
|
||||
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace osu.Game.Screens.Select.Carousel
|
||||
{
|
||||
/// <summary>
|
||||
/// A group which ensures only one child is selected.
|
||||
/// </summary>
|
||||
public class CarouselGroup : CarouselItem
|
||||
{
|
||||
private readonly List<CarouselItem> items;
|
||||
|
||||
protected override DrawableCarouselItem CreateDrawableRepresentation() => null;
|
||||
|
||||
public IReadOnlyList<CarouselItem> Children => InternalChildren;
|
||||
|
||||
protected List<CarouselItem> InternalChildren = new List<CarouselItem>();
|
||||
|
||||
public override List<DrawableCarouselItem> Drawables
|
||||
{
|
||||
get
|
||||
{
|
||||
var drawables = base.Drawables;
|
||||
foreach (var c in InternalChildren)
|
||||
drawables.AddRange(c.Drawables);
|
||||
return drawables;
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void RemoveChild(CarouselItem i)
|
||||
{
|
||||
InternalChildren.Remove(i);
|
||||
|
||||
// it's important we do the deselection after removing, so any further actions based on
|
||||
// State.ValueChanged make decisions post-removal.
|
||||
i.State.Value = CarouselItemState.Collapsed;
|
||||
}
|
||||
|
||||
public virtual void AddChild(CarouselItem i)
|
||||
{
|
||||
i.State.ValueChanged += v => ChildItemStateChanged(i, v);
|
||||
InternalChildren.Add(i);
|
||||
}
|
||||
|
||||
public CarouselGroup(List<CarouselItem> items = null)
|
||||
{
|
||||
if (items != null) InternalChildren = items;
|
||||
|
||||
State.ValueChanged += v =>
|
||||
{
|
||||
switch (v)
|
||||
{
|
||||
case CarouselItemState.Collapsed:
|
||||
case CarouselItemState.NotSelected:
|
||||
InternalChildren.ForEach(c => c.State.Value = CarouselItemState.Collapsed);
|
||||
break;
|
||||
case CarouselItemState.Selected:
|
||||
InternalChildren.ForEach(c =>
|
||||
{
|
||||
if (c.State == CarouselItemState.Collapsed) c.State.Value = CarouselItemState.NotSelected;
|
||||
});
|
||||
break;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public override void Filter(FilterCriteria criteria)
|
||||
{
|
||||
base.Filter(criteria);
|
||||
InternalChildren.Sort((x, y) => x.CompareTo(criteria, y));
|
||||
InternalChildren.ForEach(c => c.Filter(criteria));
|
||||
}
|
||||
|
||||
protected virtual void ChildItemStateChanged(CarouselItem item, CarouselItemState value)
|
||||
{
|
||||
// ensure we are the only item selected
|
||||
if (value == CarouselItemState.Selected)
|
||||
{
|
||||
foreach (var b in InternalChildren)
|
||||
{
|
||||
if (item == b) continue;
|
||||
b.State.Value = CarouselItemState.NotSelected;
|
||||
}
|
||||
|
||||
State.Value = CarouselItemState.Selected;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
104
osu.Game/Screens/Select/Carousel/CarouselGroupEagerSelect.cs
Normal file
104
osu.Game/Screens/Select/Carousel/CarouselGroupEagerSelect.cs
Normal file
@ -0,0 +1,104 @@
|
||||
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using System;
|
||||
using System.Linq;
|
||||
|
||||
namespace osu.Game.Screens.Select.Carousel
|
||||
{
|
||||
/// <summary>
|
||||
/// A group which ensures at least one child is selected (if the group itself is selected).
|
||||
/// </summary>
|
||||
public class CarouselGroupEagerSelect : CarouselGroup
|
||||
{
|
||||
public CarouselGroupEagerSelect()
|
||||
{
|
||||
State.ValueChanged += v =>
|
||||
{
|
||||
if (v == CarouselItemState.Selected)
|
||||
attemptSelection();
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// We need to keep track of the index for cases where the selection is removed but we want to select a new item based on its old location.
|
||||
/// </summary>
|
||||
private int lastSelectedIndex;
|
||||
|
||||
private CarouselItem lastSelected;
|
||||
|
||||
/// <summary>
|
||||
/// To avoid overhead during filter operations, we don't attempt any selections until after all
|
||||
/// children have been filtered. This bool will be true during the base <see cref="Filter(FilterCriteria)"/>
|
||||
/// operation.
|
||||
/// </summary>
|
||||
private bool filteringChildren;
|
||||
|
||||
public override void Filter(FilterCriteria criteria)
|
||||
{
|
||||
filteringChildren = true;
|
||||
base.Filter(criteria);
|
||||
filteringChildren = false;
|
||||
|
||||
attemptSelection();
|
||||
}
|
||||
|
||||
public override void RemoveChild(CarouselItem i)
|
||||
{
|
||||
base.RemoveChild(i);
|
||||
|
||||
if (i != lastSelected)
|
||||
updateSelectedIndex();
|
||||
}
|
||||
|
||||
public override void AddChild(CarouselItem i)
|
||||
{
|
||||
base.AddChild(i);
|
||||
attemptSelection();
|
||||
}
|
||||
|
||||
protected override void ChildItemStateChanged(CarouselItem item, CarouselItemState value)
|
||||
{
|
||||
base.ChildItemStateChanged(item, value);
|
||||
|
||||
switch (value)
|
||||
{
|
||||
case CarouselItemState.Selected:
|
||||
updateSelected(item);
|
||||
break;
|
||||
case CarouselItemState.NotSelected:
|
||||
case CarouselItemState.Collapsed:
|
||||
attemptSelection();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void attemptSelection()
|
||||
{
|
||||
if (filteringChildren) return;
|
||||
|
||||
// we only perform eager selection if we are a currently selected group.
|
||||
if (State != CarouselItemState.Selected) return;
|
||||
|
||||
// we only perform eager selection if none of our children are in a selected state already.
|
||||
if (Children.Any(i => i.State == CarouselItemState.Selected)) return;
|
||||
|
||||
CarouselItem nextToSelect =
|
||||
Children.Skip(lastSelectedIndex).FirstOrDefault(i => !i.Filtered) ??
|
||||
Children.Reverse().Skip(InternalChildren.Count - lastSelectedIndex).FirstOrDefault(i => !i.Filtered);
|
||||
|
||||
if (nextToSelect != null)
|
||||
nextToSelect.State.Value = CarouselItemState.Selected;
|
||||
else
|
||||
updateSelected(null);
|
||||
}
|
||||
|
||||
private void updateSelected(CarouselItem newSelection)
|
||||
{
|
||||
lastSelected = newSelection;
|
||||
updateSelectedIndex();
|
||||
}
|
||||
|
||||
private void updateSelectedIndex() => lastSelectedIndex = lastSelected == null ? 0 : Math.Max(0, InternalChildren.IndexOf(lastSelected));
|
||||
}
|
||||
}
|
62
osu.Game/Screens/Select/Carousel/CarouselItem.cs
Normal file
62
osu.Game/Screens/Select/Carousel/CarouselItem.cs
Normal file
@ -0,0 +1,62 @@
|
||||
// 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.Configuration;
|
||||
|
||||
namespace osu.Game.Screens.Select.Carousel
|
||||
{
|
||||
public abstract class CarouselItem
|
||||
{
|
||||
public readonly BindableBool Filtered = new BindableBool();
|
||||
|
||||
public readonly Bindable<CarouselItemState> State = new Bindable<CarouselItemState>(CarouselItemState.NotSelected);
|
||||
|
||||
/// <summary>
|
||||
/// This item is not in a hidden state.
|
||||
/// </summary>
|
||||
public bool Visible => State.Value != CarouselItemState.Collapsed && !Filtered;
|
||||
|
||||
public virtual List<DrawableCarouselItem> Drawables
|
||||
{
|
||||
get
|
||||
{
|
||||
var items = new List<DrawableCarouselItem>();
|
||||
|
||||
var self = drawableRepresentation.Value;
|
||||
if (self?.IsPresent == true) items.Add(self);
|
||||
|
||||
return items;
|
||||
}
|
||||
}
|
||||
|
||||
protected CarouselItem()
|
||||
{
|
||||
drawableRepresentation = new Lazy<DrawableCarouselItem>(CreateDrawableRepresentation);
|
||||
|
||||
Filtered.ValueChanged += v =>
|
||||
{
|
||||
if (v && State == CarouselItemState.Selected)
|
||||
State.Value = CarouselItemState.NotSelected;
|
||||
};
|
||||
}
|
||||
|
||||
private readonly Lazy<DrawableCarouselItem> drawableRepresentation;
|
||||
|
||||
protected abstract DrawableCarouselItem CreateDrawableRepresentation();
|
||||
|
||||
public virtual void Filter(FilterCriteria criteria)
|
||||
{
|
||||
}
|
||||
|
||||
public virtual int CompareTo(FilterCriteria criteria, CarouselItem other) => GetHashCode().CompareTo(other.GetHashCode());
|
||||
}
|
||||
|
||||
public enum CarouselItemState
|
||||
{
|
||||
Collapsed,
|
||||
NotSelected,
|
||||
Selected,
|
||||
}
|
||||
}
|
@ -2,82 +2,56 @@
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using System;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Colour;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Cursor;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Framework.Graphics.UserInterface;
|
||||
using osu.Framework.Input;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Beatmaps.Drawables;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.Backgrounds;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
using OpenTK;
|
||||
using OpenTK.Graphics;
|
||||
using osu.Framework.Input;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Framework.Graphics.UserInterface;
|
||||
|
||||
namespace osu.Game.Beatmaps.Drawables
|
||||
namespace osu.Game.Screens.Select.Carousel
|
||||
{
|
||||
public class BeatmapPanel : Panel, IHasContextMenu
|
||||
public class DrawableCarouselBeatmap : DrawableCarouselItem, IHasContextMenu
|
||||
{
|
||||
public BeatmapInfo Beatmap;
|
||||
private readonly Sprite background;
|
||||
private readonly BeatmapInfo beatmap;
|
||||
|
||||
public Action<BeatmapPanel> GainedSelection;
|
||||
public Action<BeatmapPanel> StartRequested;
|
||||
public Action<BeatmapPanel> EditRequested;
|
||||
public Action<BeatmapInfo> HideRequested;
|
||||
private Sprite background;
|
||||
|
||||
private readonly Triangles triangles;
|
||||
private readonly StarCounter starCounter;
|
||||
private Action<BeatmapInfo> startRequested;
|
||||
private Action<BeatmapInfo> editRequested;
|
||||
private Action<BeatmapInfo> hideRequested;
|
||||
|
||||
protected override void Selected()
|
||||
private Triangles triangles;
|
||||
private StarCounter starCounter;
|
||||
|
||||
public DrawableCarouselBeatmap(CarouselBeatmap panel) : base(panel)
|
||||
{
|
||||
base.Selected();
|
||||
|
||||
GainedSelection?.Invoke(this);
|
||||
|
||||
background.Colour = ColourInfo.GradientVertical(
|
||||
new Color4(20, 43, 51, 255),
|
||||
new Color4(40, 86, 102, 255));
|
||||
|
||||
triangles.Colour = Color4.White;
|
||||
}
|
||||
|
||||
protected override void Deselected()
|
||||
{
|
||||
base.Deselected();
|
||||
|
||||
background.Colour = new Color4(20, 43, 51, 255);
|
||||
triangles.Colour = OsuColour.Gray(0.5f);
|
||||
}
|
||||
|
||||
protected override bool OnClick(InputState state)
|
||||
{
|
||||
if (State == PanelSelectedState.Selected)
|
||||
StartRequested?.Invoke(this);
|
||||
|
||||
return base.OnClick(state);
|
||||
}
|
||||
|
||||
protected override void ApplyState(PanelSelectedState last = PanelSelectedState.Hidden)
|
||||
{
|
||||
if (!IsLoaded) return;
|
||||
|
||||
base.ApplyState(last);
|
||||
|
||||
if (last == PanelSelectedState.Hidden && State != last)
|
||||
starCounter.ReplayAnimation();
|
||||
}
|
||||
|
||||
public BeatmapPanel(BeatmapInfo beatmap)
|
||||
{
|
||||
if (beatmap == null)
|
||||
throw new ArgumentNullException(nameof(beatmap));
|
||||
|
||||
Beatmap = beatmap;
|
||||
beatmap = panel.Beatmap;
|
||||
Height *= 0.60f;
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader(true)]
|
||||
private void load(SongSelect songSelect, BeatmapManager manager)
|
||||
{
|
||||
if (songSelect != null)
|
||||
{
|
||||
startRequested = songSelect.Start;
|
||||
editRequested = songSelect.Edit;
|
||||
}
|
||||
|
||||
if (manager != null)
|
||||
hideRequested = manager.Hide;
|
||||
|
||||
Children = new Drawable[]
|
||||
{
|
||||
@ -157,11 +131,46 @@ namespace osu.Game.Beatmaps.Drawables
|
||||
};
|
||||
}
|
||||
|
||||
protected override void Selected()
|
||||
{
|
||||
base.Selected();
|
||||
|
||||
background.Colour = ColourInfo.GradientVertical(
|
||||
new Color4(20, 43, 51, 255),
|
||||
new Color4(40, 86, 102, 255));
|
||||
|
||||
triangles.Colour = Color4.White;
|
||||
}
|
||||
|
||||
protected override void Deselected()
|
||||
{
|
||||
base.Deselected();
|
||||
|
||||
background.Colour = new Color4(20, 43, 51, 255);
|
||||
triangles.Colour = OsuColour.Gray(0.5f);
|
||||
}
|
||||
|
||||
protected override bool OnClick(InputState state)
|
||||
{
|
||||
if (Item.State == CarouselItemState.Selected)
|
||||
startRequested?.Invoke(beatmap);
|
||||
|
||||
return base.OnClick(state);
|
||||
}
|
||||
|
||||
protected override void ApplyState()
|
||||
{
|
||||
if (Item.State.Value != CarouselItemState.Collapsed && Alpha == 0)
|
||||
starCounter.ReplayAnimation();
|
||||
|
||||
base.ApplyState();
|
||||
}
|
||||
|
||||
public MenuItem[] ContextMenuItems => new MenuItem[]
|
||||
{
|
||||
new OsuMenuItem("Play", MenuItemType.Highlighted, () => StartRequested?.Invoke(this)),
|
||||
new OsuMenuItem("Edit", MenuItemType.Standard, () => EditRequested?.Invoke(this)),
|
||||
new OsuMenuItem("Hide", MenuItemType.Destructive, () => HideRequested?.Invoke(Beatmap)),
|
||||
new OsuMenuItem("Play", MenuItemType.Highlighted, () => startRequested?.Invoke(beatmap)),
|
||||
new OsuMenuItem("Edit", MenuItemType.Standard, () => editRequested?.Invoke(beatmap)),
|
||||
new OsuMenuItem("Hide", MenuItemType.Destructive, () => hideRequested?.Invoke(beatmap)),
|
||||
};
|
||||
}
|
||||
}
|
@ -4,67 +4,57 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using OpenTK;
|
||||
using OpenTK.Graphics;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Configuration;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Colour;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Cursor;
|
||||
using osu.Framework.Localisation;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Framework.Graphics.UserInterface;
|
||||
using osu.Framework.Localisation;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Beatmaps.Drawables;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
using OpenTK;
|
||||
using OpenTK.Graphics;
|
||||
|
||||
namespace osu.Game.Beatmaps.Drawables
|
||||
namespace osu.Game.Screens.Select.Carousel
|
||||
{
|
||||
public class BeatmapSetHeader : Panel, IHasContextMenu
|
||||
public class DrawableCarouselBeatmapSet : DrawableCarouselItem, IHasContextMenu
|
||||
{
|
||||
public Action<BeatmapSetHeader> GainedSelection;
|
||||
private Action<BeatmapSetInfo> deleteRequested;
|
||||
private Action<BeatmapSetInfo> restoreHiddenRequested;
|
||||
|
||||
public Action<BeatmapSetInfo> DeleteRequested;
|
||||
|
||||
public Action<BeatmapSetInfo> RestoreHiddenRequested;
|
||||
|
||||
private readonly WorkingBeatmap beatmap;
|
||||
private readonly BeatmapSetInfo beatmapSet;
|
||||
|
||||
private readonly FillFlowContainer difficultyIcons;
|
||||
|
||||
public BeatmapSetHeader(WorkingBeatmap beatmap)
|
||||
public DrawableCarouselBeatmapSet(CarouselBeatmapSet set)
|
||||
: base(set)
|
||||
{
|
||||
if (beatmap == null)
|
||||
throw new ArgumentNullException(nameof(beatmap));
|
||||
|
||||
this.beatmap = beatmap;
|
||||
|
||||
difficultyIcons = new FillFlowContainer
|
||||
{
|
||||
Margin = new MarginPadding { Top = 5 },
|
||||
AutoSizeAxes = Axes.Both,
|
||||
};
|
||||
}
|
||||
|
||||
protected override void Selected()
|
||||
{
|
||||
base.Selected();
|
||||
GainedSelection?.Invoke(this);
|
||||
beatmapSet = set.BeatmapSet;
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(LocalisationEngine localisation)
|
||||
private void load(LocalisationEngine localisation, BeatmapManager manager)
|
||||
{
|
||||
if (localisation == null)
|
||||
throw new ArgumentNullException(nameof(localisation));
|
||||
|
||||
restoreHiddenRequested = s => s.Beatmaps.ForEach(manager.Restore);
|
||||
deleteRequested = manager.Delete;
|
||||
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new DelayedLoadWrapper(
|
||||
new PanelBackground(beatmap)
|
||||
new PanelBackground(manager.GetWorkingBeatmap(beatmapSet.Beatmaps.FirstOrDefault()))
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
OnLoadComplete = d => d.FadeInFromZero(400, Easing.Out),
|
||||
}, 300),
|
||||
OnLoadComplete = d => d.FadeInFromZero(1000, Easing.OutQuint),
|
||||
}, 300
|
||||
),
|
||||
new FillFlowContainer
|
||||
{
|
||||
Direction = FillDirection.Vertical,
|
||||
@ -75,23 +65,46 @@ namespace osu.Game.Beatmaps.Drawables
|
||||
new OsuSpriteText
|
||||
{
|
||||
Font = @"Exo2.0-BoldItalic",
|
||||
Current = localisation.GetUnicodePreference(beatmap.Metadata.TitleUnicode, beatmap.Metadata.Title),
|
||||
Current = localisation.GetUnicodePreference(beatmapSet.Metadata.TitleUnicode, beatmapSet.Metadata.Title),
|
||||
TextSize = 22,
|
||||
Shadow = true,
|
||||
},
|
||||
new OsuSpriteText
|
||||
{
|
||||
Font = @"Exo2.0-SemiBoldItalic",
|
||||
Current = localisation.GetUnicodePreference(beatmap.Metadata.ArtistUnicode, beatmap.Metadata.Artist),
|
||||
Current = localisation.GetUnicodePreference(beatmapSet.Metadata.ArtistUnicode, beatmapSet.Metadata.Artist),
|
||||
TextSize = 17,
|
||||
Shadow = true,
|
||||
},
|
||||
difficultyIcons
|
||||
new FillFlowContainer<FilterableDifficultyIcon>
|
||||
{
|
||||
Margin = new MarginPadding { Top = 5 },
|
||||
AutoSizeAxes = Axes.Both,
|
||||
Children = ((CarouselBeatmapSet)Item).Beatmaps.Select(b => new FilterableDifficultyIcon(b)).ToList()
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public MenuItem[] ContextMenuItems
|
||||
{
|
||||
get
|
||||
{
|
||||
List<MenuItem> items = new List<MenuItem>();
|
||||
|
||||
if (Item.State == CarouselItemState.NotSelected)
|
||||
items.Add(new OsuMenuItem("Expand", MenuItemType.Highlighted, () => Item.State.Value = CarouselItemState.Selected));
|
||||
|
||||
if (beatmapSet.Beatmaps.Any(b => b.Hidden))
|
||||
items.Add(new OsuMenuItem("Restore all hidden", MenuItemType.Standard, () => restoreHiddenRequested?.Invoke(beatmapSet)));
|
||||
|
||||
items.Add(new OsuMenuItem("Delete", MenuItemType.Destructive, () => deleteRequested?.Invoke(beatmapSet)));
|
||||
|
||||
return items.ToArray();
|
||||
}
|
||||
}
|
||||
|
||||
private class PanelBackground : BufferedContainer
|
||||
{
|
||||
public PanelBackground(WorkingBeatmap working)
|
||||
@ -128,22 +141,19 @@ namespace osu.Game.Beatmaps.Drawables
|
||||
new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Colour = ColourInfo.GradientHorizontal(
|
||||
Color4.Black, new Color4(0f, 0f, 0f, 0.9f)),
|
||||
Colour = ColourInfo.GradientHorizontal(Color4.Black, new Color4(0f, 0f, 0f, 0.9f)),
|
||||
Width = 0.05f,
|
||||
},
|
||||
new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Colour = ColourInfo.GradientHorizontal(
|
||||
new Color4(0f, 0f, 0f, 0.9f), new Color4(0f, 0f, 0f, 0.1f)),
|
||||
Colour = ColourInfo.GradientHorizontal(new Color4(0f, 0f, 0f, 0.9f), new Color4(0f, 0f, 0f, 0.1f)),
|
||||
Width = 0.2f,
|
||||
},
|
||||
new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Colour = ColourInfo.GradientHorizontal(
|
||||
new Color4(0f, 0f, 0f, 0.1f), new Color4(0, 0, 0, 0)),
|
||||
Colour = ColourInfo.GradientHorizontal(new Color4(0f, 0f, 0f, 0.1f), new Color4(0, 0, 0, 0)),
|
||||
Width = 0.05f,
|
||||
},
|
||||
}
|
||||
@ -152,30 +162,16 @@ namespace osu.Game.Beatmaps.Drawables
|
||||
}
|
||||
}
|
||||
|
||||
public void AddDifficultyIcons(IEnumerable<BeatmapPanel> panels)
|
||||
public class FilterableDifficultyIcon : DifficultyIcon
|
||||
{
|
||||
if (panels == null)
|
||||
throw new ArgumentNullException(nameof(panels));
|
||||
private readonly BindableBool filtered = new BindableBool();
|
||||
|
||||
foreach (var p in panels)
|
||||
difficultyIcons.Add(new DifficultyIcon(p.Beatmap));
|
||||
}
|
||||
|
||||
public MenuItem[] ContextMenuItems
|
||||
{
|
||||
get
|
||||
public FilterableDifficultyIcon(CarouselBeatmap item)
|
||||
: base(item.Beatmap)
|
||||
{
|
||||
List<MenuItem> items = new List<MenuItem>();
|
||||
|
||||
if (State == PanelSelectedState.NotSelected)
|
||||
items.Add(new OsuMenuItem("Expand", MenuItemType.Highlighted, () => State = PanelSelectedState.Selected));
|
||||
|
||||
if (beatmap.BeatmapSetInfo.Beatmaps.Any(b => b.Hidden))
|
||||
items.Add(new OsuMenuItem("Restore all hidden", MenuItemType.Standard, () => RestoreHiddenRequested?.Invoke(beatmap.BeatmapSetInfo)));
|
||||
|
||||
items.Add(new OsuMenuItem("Delete", MenuItemType.Destructive, () => DeleteRequested?.Invoke(beatmap.BeatmapSetInfo)));
|
||||
|
||||
return items.ToArray();
|
||||
filtered.BindTo(item.Filtered);
|
||||
filtered.ValueChanged += v => Schedule(() => this.FadeTo(v ? 0.1f : 1, 100));
|
||||
filtered.TriggerChange();
|
||||
}
|
||||
}
|
||||
}
|
@ -1,45 +1,53 @@
|
||||
// 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;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Audio;
|
||||
using osu.Framework.Audio.Sample;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Extensions.Color4Extensions;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Framework.Input;
|
||||
using osu.Framework.MathUtils;
|
||||
using osu.Game.Graphics;
|
||||
using OpenTK;
|
||||
using OpenTK.Graphics;
|
||||
using osu.Framework.Extensions.Color4Extensions;
|
||||
using osu.Framework.MathUtils;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Game.Graphics;
|
||||
|
||||
namespace osu.Game.Beatmaps.Drawables
|
||||
namespace osu.Game.Screens.Select.Carousel
|
||||
{
|
||||
public class Panel : Container, IStateful<PanelSelectedState>
|
||||
public abstract class DrawableCarouselItem : Container
|
||||
{
|
||||
public const float MAX_HEIGHT = 80;
|
||||
|
||||
public event Action<PanelSelectedState> StateChanged;
|
||||
|
||||
public override bool RemoveWhenNotAlive => false;
|
||||
|
||||
private readonly Container nestedContainer;
|
||||
public override bool IsPresent => base.IsPresent || Item.Visible;
|
||||
|
||||
private readonly Container borderContainer;
|
||||
public readonly CarouselItem Item;
|
||||
|
||||
private readonly Box hoverLayer;
|
||||
private Container nestedContainer;
|
||||
private Container borderContainer;
|
||||
|
||||
private Box hoverLayer;
|
||||
|
||||
protected override Container<Drawable> Content => nestedContainer;
|
||||
|
||||
protected Panel()
|
||||
protected DrawableCarouselItem(CarouselItem item)
|
||||
{
|
||||
Item = item;
|
||||
|
||||
Height = MAX_HEIGHT;
|
||||
RelativeSizeAxes = Axes.X;
|
||||
Alpha = 0;
|
||||
}
|
||||
|
||||
AddInternal(borderContainer = new Container
|
||||
private SampleChannel sampleHover;
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(AudioManager audio, OsuColour colours)
|
||||
{
|
||||
InternalChild = borderContainer = new Container
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Masking = true,
|
||||
@ -58,16 +66,8 @@ namespace osu.Game.Beatmaps.Drawables
|
||||
Blending = BlendingMode.Additive,
|
||||
},
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
Alpha = 0;
|
||||
}
|
||||
|
||||
private SampleChannel sampleHover;
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(AudioManager audio, OsuColour colours)
|
||||
{
|
||||
sampleHover = audio.Sample.Get($@"SongSelect/song-ping-variation-{RNG.Next(1, 5)}");
|
||||
hoverLayer.Colour = colours.Blue.Opacity(0.1f);
|
||||
}
|
||||
@ -86,60 +86,41 @@ namespace osu.Game.Beatmaps.Drawables
|
||||
base.OnHoverLost(state);
|
||||
}
|
||||
|
||||
public void SetMultiplicativeAlpha(float alpha)
|
||||
{
|
||||
borderContainer.Alpha = alpha;
|
||||
}
|
||||
public void SetMultiplicativeAlpha(float alpha) => borderContainer.Alpha = alpha;
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
|
||||
ApplyState();
|
||||
Item.Filtered.ValueChanged += _ => Schedule(ApplyState);
|
||||
Item.State.ValueChanged += _ => Schedule(ApplyState);
|
||||
}
|
||||
|
||||
protected virtual void ApplyState(PanelSelectedState last = PanelSelectedState.Hidden)
|
||||
protected virtual void ApplyState()
|
||||
{
|
||||
if (!IsLoaded) return;
|
||||
|
||||
switch (state)
|
||||
switch (Item.State.Value)
|
||||
{
|
||||
case PanelSelectedState.Hidden:
|
||||
case PanelSelectedState.NotSelected:
|
||||
case CarouselItemState.NotSelected:
|
||||
Deselected();
|
||||
break;
|
||||
case PanelSelectedState.Selected:
|
||||
case CarouselItemState.Selected:
|
||||
Selected();
|
||||
break;
|
||||
}
|
||||
|
||||
if (state == PanelSelectedState.Hidden)
|
||||
if (!Item.Visible)
|
||||
this.FadeOut(300, Easing.OutQuint);
|
||||
else
|
||||
this.FadeIn(250);
|
||||
}
|
||||
|
||||
private PanelSelectedState state = PanelSelectedState.NotSelected;
|
||||
|
||||
public PanelSelectedState State
|
||||
{
|
||||
get { return state; }
|
||||
|
||||
set
|
||||
{
|
||||
if (state == value)
|
||||
return;
|
||||
|
||||
var last = state;
|
||||
state = value;
|
||||
|
||||
ApplyState(last);
|
||||
|
||||
StateChanged?.Invoke(State);
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual void Selected()
|
||||
{
|
||||
Item.State.Value = CarouselItemState.Selected;
|
||||
|
||||
borderContainer.BorderThickness = 2.5f;
|
||||
borderContainer.EdgeEffect = new EdgeEffectParameters
|
||||
{
|
||||
@ -152,6 +133,8 @@ namespace osu.Game.Beatmaps.Drawables
|
||||
|
||||
protected virtual void Deselected()
|
||||
{
|
||||
Item.State.Value = CarouselItemState.NotSelected;
|
||||
|
||||
borderContainer.BorderThickness = 0;
|
||||
borderContainer.EdgeEffect = new EdgeEffectParameters
|
||||
{
|
||||
@ -164,15 +147,8 @@ namespace osu.Game.Beatmaps.Drawables
|
||||
|
||||
protected override bool OnClick(InputState state)
|
||||
{
|
||||
State = PanelSelectedState.Selected;
|
||||
Item.State.Value = CarouselItemState.Selected;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public enum PanelSelectedState
|
||||
{
|
||||
Hidden,
|
||||
NotSelected,
|
||||
Selected
|
||||
}
|
||||
}
|
@ -1,14 +1,12 @@
|
||||
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using osu.Framework.Input;
|
||||
|
||||
namespace osu.Game.Screens.Select
|
||||
{
|
||||
public class EditSongSelect : SongSelect
|
||||
{
|
||||
protected override bool ShowFooter => false;
|
||||
|
||||
protected override void OnSelected(InputState state) => Exit();
|
||||
protected override void Start() => Exit();
|
||||
}
|
||||
}
|
||||
|
@ -1,10 +1,6 @@
|
||||
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using osu.Game.Beatmaps.Drawables;
|
||||
using osu.Game.Rulesets;
|
||||
using osu.Game.Screens.Select.Filter;
|
||||
|
||||
@ -17,47 +13,5 @@ namespace osu.Game.Screens.Select
|
||||
public string SearchText;
|
||||
public RulesetInfo Ruleset;
|
||||
public bool AllowConvertedBeatmaps;
|
||||
|
||||
public void Filter(List<BeatmapGroup> groups)
|
||||
{
|
||||
foreach (var g in groups)
|
||||
{
|
||||
var set = g.BeatmapSet;
|
||||
|
||||
bool hasCurrentMode = AllowConvertedBeatmaps || set.Beatmaps.Any(bm => bm.RulesetID == (Ruleset?.ID ?? 0));
|
||||
|
||||
bool match = hasCurrentMode;
|
||||
|
||||
if (!string.IsNullOrEmpty(SearchText))
|
||||
match &= set.Metadata.SearchableTerms.Any(term => term.IndexOf(SearchText, StringComparison.InvariantCultureIgnoreCase) >= 0);
|
||||
|
||||
switch (g.State)
|
||||
{
|
||||
case BeatmapGroupState.Hidden:
|
||||
if (match) g.State = BeatmapGroupState.Collapsed;
|
||||
break;
|
||||
default:
|
||||
if (!match) g.State = BeatmapGroupState.Hidden;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
switch (Sort)
|
||||
{
|
||||
default:
|
||||
case SortMode.Artist:
|
||||
groups.Sort((x, y) => string.Compare(x.BeatmapSet.Metadata.Artist, y.BeatmapSet.Metadata.Artist, StringComparison.InvariantCultureIgnoreCase));
|
||||
break;
|
||||
case SortMode.Title:
|
||||
groups.Sort((x, y) => string.Compare(x.BeatmapSet.Metadata.Title, y.BeatmapSet.Metadata.Title, StringComparison.InvariantCultureIgnoreCase));
|
||||
break;
|
||||
case SortMode.Author:
|
||||
groups.Sort((x, y) => string.Compare(x.BeatmapSet.Metadata.Author.Username, y.BeatmapSet.Metadata.Author.Username, StringComparison.InvariantCultureIgnoreCase));
|
||||
break;
|
||||
case SortMode.Difficulty:
|
||||
groups.Sort((x, y) => x.BeatmapSet.MaxStarDifficulty.CompareTo(y.BeatmapSet.MaxStarDifficulty));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,12 +1,10 @@
|
||||
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using osu.Framework.Input;
|
||||
|
||||
namespace osu.Game.Screens.Select
|
||||
{
|
||||
public class MatchSongSelect : SongSelect
|
||||
{
|
||||
protected override void OnSelected(InputState state) => Exit();
|
||||
protected override void Start() => Exit();
|
||||
}
|
||||
}
|
||||
|
@ -8,7 +8,6 @@ using osu.Framework.Audio;
|
||||
using osu.Framework.Audio.Sample;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Input;
|
||||
using osu.Framework.Screens;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Graphics;
|
||||
@ -114,11 +113,12 @@ namespace osu.Game.Screens.Select
|
||||
return false;
|
||||
}
|
||||
|
||||
protected override void OnSelected(InputState state)
|
||||
protected override void Start()
|
||||
{
|
||||
if (player != null) return;
|
||||
|
||||
if (state?.Keyboard.ControlPressed == true)
|
||||
// Ctrl+Enter should start map with autoplay enabled.
|
||||
if (GetContainingInputManager().CurrentState?.Keyboard.ControlPressed == true)
|
||||
{
|
||||
var auto = Ruleset.Value.CreateInstance().GetAutoplayMod();
|
||||
var autoType = auto.GetType();
|
||||
|
@ -27,25 +27,11 @@ namespace osu.Game.Screens.Select
|
||||
{
|
||||
public abstract class SongSelect : OsuScreen
|
||||
{
|
||||
private BeatmapManager beatmaps;
|
||||
protected override BackgroundScreen CreateBackground() => new BackgroundScreenBeatmap();
|
||||
|
||||
private readonly BeatmapCarousel carousel;
|
||||
private DialogOverlay dialogOverlay;
|
||||
|
||||
private static readonly Vector2 wedged_container_size = new Vector2(0.5f, 245);
|
||||
|
||||
private static readonly Vector2 background_blur = new Vector2(20);
|
||||
private const float left_area_padding = 20;
|
||||
|
||||
private readonly BeatmapInfoWedge beatmapInfoWedge;
|
||||
|
||||
protected Container LeftContent;
|
||||
|
||||
private static readonly Vector2 background_blur = new Vector2(20);
|
||||
private CancellationTokenSource initialAddSetsTask;
|
||||
|
||||
private SampleChannel sampleChangeDifficulty;
|
||||
private SampleChannel sampleChangeBeatmap;
|
||||
public readonly FilterControl FilterControl;
|
||||
|
||||
protected virtual bool ShowFooter => true;
|
||||
|
||||
@ -65,77 +51,90 @@ namespace osu.Game.Screens.Select
|
||||
/// </summary>
|
||||
protected readonly Container FooterPanels;
|
||||
|
||||
public readonly FilterControl FilterControl;
|
||||
protected override BackgroundScreen CreateBackground() => new BackgroundScreenBeatmap();
|
||||
|
||||
protected Container LeftContent;
|
||||
|
||||
private readonly BeatmapCarousel carousel;
|
||||
private readonly BeatmapInfoWedge beatmapInfoWedge;
|
||||
private DialogOverlay dialogOverlay;
|
||||
private BeatmapManager beatmaps;
|
||||
|
||||
private SampleChannel sampleChangeDifficulty;
|
||||
private SampleChannel sampleChangeBeatmap;
|
||||
|
||||
private CancellationTokenSource initialAddSetsTask;
|
||||
|
||||
private DependencyContainer dependencies;
|
||||
protected override IReadOnlyDependencyContainer CreateLocalDependencies(IReadOnlyDependencyContainer parent) => dependencies = new DependencyContainer(parent);
|
||||
|
||||
protected SongSelect()
|
||||
{
|
||||
const float carousel_width = 640;
|
||||
const float filter_height = 100;
|
||||
|
||||
Add(new ParallaxContainer
|
||||
AddRange(new Drawable[]
|
||||
{
|
||||
Padding = new MarginPadding { Top = filter_height },
|
||||
ParallaxAmount = 0.005f,
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Children = new[]
|
||||
new ParallaxContainer
|
||||
{
|
||||
new WedgeBackground
|
||||
Padding = new MarginPadding { Top = filter_height },
|
||||
ParallaxAmount = 0.005f,
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Children = new[]
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Padding = new MarginPadding { Right = carousel_width * 0.76f },
|
||||
new WedgeBackground
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Padding = new MarginPadding { Right = carousel_width * 0.76f },
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
Add(LeftContent = new Container
|
||||
{
|
||||
Origin = Anchor.BottomLeft,
|
||||
Anchor = Anchor.BottomLeft,
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Size = new Vector2(wedged_container_size.X, 1),
|
||||
Padding = new MarginPadding
|
||||
{
|
||||
Bottom = 50,
|
||||
Top = wedged_container_size.Y + left_area_padding,
|
||||
Left = left_area_padding,
|
||||
Right = left_area_padding * 2,
|
||||
}
|
||||
});
|
||||
Add(carousel = new BeatmapCarousel
|
||||
{
|
||||
RelativeSizeAxes = Axes.Y,
|
||||
Size = new Vector2(carousel_width, 1),
|
||||
Anchor = Anchor.CentreRight,
|
||||
Origin = Anchor.CentreRight,
|
||||
SelectionChanged = carouselSelectionChanged,
|
||||
BeatmapsChanged = carouselBeatmapsLoaded,
|
||||
DeleteRequested = promptDelete,
|
||||
RestoreRequested = s => { foreach (var b in s.Beatmaps) beatmaps.Restore(b); },
|
||||
EditRequested = editRequested,
|
||||
HideDifficultyRequested = b => beatmaps.Hide(b),
|
||||
StartRequested = () => carouselRaisedStart(),
|
||||
});
|
||||
Add(FilterControl = new FilterControl
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
Height = filter_height,
|
||||
FilterChanged = criteria => filterChanged(criteria),
|
||||
Exit = Exit,
|
||||
});
|
||||
Add(beatmapInfoWedge = new BeatmapInfoWedge
|
||||
{
|
||||
Alpha = 0,
|
||||
Size = wedged_container_size,
|
||||
RelativeSizeAxes = Axes.X,
|
||||
Margin = new MarginPadding
|
||||
{
|
||||
Top = left_area_padding,
|
||||
Right = left_area_padding,
|
||||
},
|
||||
});
|
||||
Add(new ResetScrollContainer(() => carousel.ScrollToSelected())
|
||||
{
|
||||
RelativeSizeAxes = Axes.Y,
|
||||
Width = 250,
|
||||
LeftContent = new Container
|
||||
{
|
||||
Origin = Anchor.BottomLeft,
|
||||
Anchor = Anchor.BottomLeft,
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Size = new Vector2(wedged_container_size.X, 1),
|
||||
Padding = new MarginPadding
|
||||
{
|
||||
Bottom = 50,
|
||||
Top = wedged_container_size.Y + left_area_padding,
|
||||
Left = left_area_padding,
|
||||
Right = left_area_padding * 2,
|
||||
}
|
||||
},
|
||||
carousel = new BeatmapCarousel
|
||||
{
|
||||
RelativeSizeAxes = Axes.Y,
|
||||
Size = new Vector2(carousel_width, 1),
|
||||
Anchor = Anchor.CentreRight,
|
||||
Origin = Anchor.CentreRight,
|
||||
SelectionChanged = carouselSelectionChanged,
|
||||
BeatmapSetsChanged = carouselBeatmapsLoaded,
|
||||
},
|
||||
FilterControl = new FilterControl
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
Height = filter_height,
|
||||
FilterChanged = c => carousel.Filter(c),
|
||||
Exit = Exit,
|
||||
},
|
||||
beatmapInfoWedge = new BeatmapInfoWedge
|
||||
{
|
||||
Alpha = 0,
|
||||
Size = wedged_container_size,
|
||||
RelativeSizeAxes = Axes.X,
|
||||
Margin = new MarginPadding
|
||||
{
|
||||
Top = left_area_padding,
|
||||
Right = left_area_padding,
|
||||
},
|
||||
},
|
||||
new ResetScrollContainer(() => carousel.ScrollToSelected())
|
||||
{
|
||||
RelativeSizeAxes = Axes.Y,
|
||||
Width = 250,
|
||||
}
|
||||
});
|
||||
|
||||
if (ShowFooter)
|
||||
@ -163,12 +162,14 @@ namespace osu.Game.Screens.Select
|
||||
[BackgroundDependencyLoader(permitNulls: true)]
|
||||
private void load(BeatmapManager beatmaps, AudioManager audio, DialogOverlay dialog, OsuGame osu, OsuColour colours)
|
||||
{
|
||||
dependencies.Cache(this);
|
||||
|
||||
if (Footer != null)
|
||||
{
|
||||
Footer.AddButton(@"random", colours.Green, triggerRandom, Key.F2);
|
||||
Footer.AddButton(@"options", colours.Blue, BeatmapOptions, Key.F3);
|
||||
|
||||
BeatmapOptions.AddButton(@"Delete", @"Beatmap", FontAwesome.fa_trash, colours.Pink, () => promptDelete(Beatmap.Value.BeatmapSetInfo), Key.Number4, float.MaxValue);
|
||||
BeatmapOptions.AddButton(@"Delete", @"Beatmap", FontAwesome.fa_trash, colours.Pink, () => delete(Beatmap.Value.BeatmapSetInfo), Key.Number4, float.MaxValue);
|
||||
}
|
||||
|
||||
if (this.beatmaps == null)
|
||||
@ -189,36 +190,31 @@ namespace osu.Game.Screens.Select
|
||||
|
||||
initialAddSetsTask = new CancellationTokenSource();
|
||||
|
||||
carousel.Beatmaps = this.beatmaps.GetAllUsableBeatmapSets();
|
||||
|
||||
Beatmap.ValueChanged += beatmap_ValueChanged;
|
||||
carousel.BeatmapSets = this.beatmaps.GetAllUsableBeatmapSets();
|
||||
|
||||
Beatmap.DisabledChanged += disabled => carousel.AllowSelection = !disabled;
|
||||
carousel.AllowSelection = !Beatmap.Disabled;
|
||||
Beatmap.TriggerChange();
|
||||
|
||||
Beatmap.ValueChanged += b =>
|
||||
{
|
||||
if (IsCurrentScreen)
|
||||
carousel.SelectBeatmap(b?.BeatmapInfo);
|
||||
};
|
||||
}
|
||||
|
||||
private void editRequested(BeatmapInfo beatmap)
|
||||
public void Edit(BeatmapInfo beatmap)
|
||||
{
|
||||
Beatmap.Value = beatmaps.GetWorkingBeatmap(beatmap, Beatmap);
|
||||
Push(new Editor());
|
||||
}
|
||||
|
||||
private void onBeatmapRestored(BeatmapInfo b) => Schedule(() => carousel.UpdateBeatmap(b));
|
||||
private void onBeatmapHidden(BeatmapInfo b) => Schedule(() => carousel.UpdateBeatmap(b));
|
||||
|
||||
private void carouselBeatmapsLoaded()
|
||||
{
|
||||
if (Beatmap.Value.BeatmapSetInfo?.DeletePending == false)
|
||||
carousel.SelectBeatmap(Beatmap.Value.BeatmapInfo, false);
|
||||
else
|
||||
carousel.SelectNextRandom();
|
||||
}
|
||||
|
||||
private void carouselRaisedStart(InputState state = null)
|
||||
public void Start(BeatmapInfo beatmap)
|
||||
{
|
||||
// if we have a pending filter operation, we want to run it now.
|
||||
// it could change selection (ie. if the ruleset has been changed).
|
||||
carousel.FlushPendingFilters();
|
||||
carousel.FlushPendingFilterOperations();
|
||||
|
||||
carousel.SelectBeatmap(beatmap);
|
||||
|
||||
if (selectionChangedDebounce?.Completed == false)
|
||||
{
|
||||
@ -227,9 +223,14 @@ namespace osu.Game.Screens.Select
|
||||
selectionChangedDebounce = null;
|
||||
}
|
||||
|
||||
OnSelected(state);
|
||||
Start();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called when a selection is made.
|
||||
/// </summary>
|
||||
protected abstract void Start();
|
||||
|
||||
private ScheduledDelegate selectionChangedDebounce;
|
||||
|
||||
// We need to keep track of the last selected beatmap ignoring debounce to play the correct selection sounds.
|
||||
@ -246,7 +247,7 @@ namespace osu.Game.Screens.Select
|
||||
// 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;
|
||||
bool preview = beatmap?.BeatmapSetInfoID != Beatmap.Value?.BeatmapInfo.BeatmapSetInfoID;
|
||||
|
||||
Beatmap.Value = beatmaps.GetWorkingBeatmap(beatmap, Beatmap);
|
||||
ensurePlayingSelected(preview);
|
||||
@ -255,11 +256,11 @@ namespace osu.Game.Screens.Select
|
||||
UpdateBeatmap(Beatmap.Value);
|
||||
};
|
||||
|
||||
selectionChangedDebounce?.Cancel();
|
||||
|
||||
if (beatmap?.Equals(beatmapNoDebounce) == true)
|
||||
return;
|
||||
|
||||
selectionChangedDebounce?.Cancel();
|
||||
|
||||
beatmapNoDebounce = beatmap;
|
||||
|
||||
if (beatmap == null)
|
||||
@ -286,23 +287,11 @@ namespace osu.Game.Screens.Select
|
||||
carousel.SelectNextRandom();
|
||||
}
|
||||
|
||||
protected abstract void OnSelected(InputState state);
|
||||
|
||||
private void filterChanged(FilterCriteria criteria, bool debounce = true)
|
||||
{
|
||||
carousel.Filter(criteria, debounce);
|
||||
}
|
||||
|
||||
private void onBeatmapSetAdded(BeatmapSetInfo s) => Schedule(() => addBeatmapSet(s));
|
||||
|
||||
private void onBeatmapSetRemoved(BeatmapSetInfo s) => Schedule(() => removeBeatmapSet(s));
|
||||
|
||||
protected override void OnEntering(Screen last)
|
||||
{
|
||||
base.OnEntering(last);
|
||||
|
||||
Content.FadeInFromZero(250);
|
||||
|
||||
FilterControl.Activate();
|
||||
}
|
||||
|
||||
@ -331,7 +320,7 @@ namespace osu.Game.Screens.Select
|
||||
|
||||
logo.Action = () =>
|
||||
{
|
||||
carouselRaisedStart();
|
||||
Start();
|
||||
return false;
|
||||
};
|
||||
}
|
||||
@ -343,13 +332,6 @@ namespace osu.Game.Screens.Select
|
||||
logo.FadeOut(logo_transition / 2, Easing.Out);
|
||||
}
|
||||
|
||||
private void beatmap_ValueChanged(WorkingBeatmap beatmap)
|
||||
{
|
||||
if (!IsCurrentScreen) return;
|
||||
|
||||
carousel.SelectBeatmap(beatmap?.BeatmapInfo);
|
||||
}
|
||||
|
||||
protected override void OnResuming(Screen last)
|
||||
{
|
||||
if (Beatmap != null && !Beatmap.Value.BeatmapSetInfo.DeletePending)
|
||||
@ -410,8 +392,7 @@ namespace osu.Game.Screens.Select
|
||||
/// <param name="beatmap">The working beatmap.</param>
|
||||
protected virtual void UpdateBeatmap(WorkingBeatmap beatmap)
|
||||
{
|
||||
var backgroundModeBeatmap = Background as BackgroundScreenBeatmap;
|
||||
if (backgroundModeBeatmap != null)
|
||||
if (Background is BackgroundScreenBeatmap backgroundModeBeatmap)
|
||||
{
|
||||
backgroundModeBeatmap.Beatmap = beatmap;
|
||||
backgroundModeBeatmap.BlurTo(background_blur, 750, Easing.OutQuint);
|
||||
@ -436,20 +417,22 @@ namespace osu.Game.Screens.Select
|
||||
}
|
||||
}
|
||||
|
||||
private void addBeatmapSet(BeatmapSetInfo beatmapSet) => carousel.AddBeatmap(beatmapSet);
|
||||
private void onBeatmapSetAdded(BeatmapSetInfo s) => carousel.UpdateBeatmapSet(s);
|
||||
private void onBeatmapSetRemoved(BeatmapSetInfo s) => carousel.RemoveBeatmapSet(s);
|
||||
private void onBeatmapRestored(BeatmapInfo b) => carousel.UpdateBeatmapSet(beatmaps.QueryBeatmapSet(s => s.ID == b.BeatmapSetInfoID));
|
||||
private void onBeatmapHidden(BeatmapInfo b) => carousel.UpdateBeatmapSet(beatmaps.QueryBeatmapSet(s => s.ID == b.BeatmapSetInfoID));
|
||||
|
||||
private void removeBeatmapSet(BeatmapSetInfo beatmapSet)
|
||||
private void carouselBeatmapsLoaded()
|
||||
{
|
||||
carousel.RemoveBeatmap(beatmapSet);
|
||||
if (carousel.SelectedBeatmap == null)
|
||||
Beatmap.SetDefault();
|
||||
if (Beatmap.Value.BeatmapSetInfo?.DeletePending == false)
|
||||
carousel.SelectBeatmap(Beatmap.Value.BeatmapInfo);
|
||||
else
|
||||
carousel.SelectNextRandom();
|
||||
}
|
||||
|
||||
private void promptDelete(BeatmapSetInfo beatmap)
|
||||
private void delete(BeatmapSetInfo beatmap)
|
||||
{
|
||||
if (beatmap == null)
|
||||
return;
|
||||
|
||||
if (beatmap == null) return;
|
||||
dialogOverlay?.Push(new BeatmapDeleteDialog(beatmap));
|
||||
}
|
||||
|
||||
@ -461,15 +444,16 @@ namespace osu.Game.Screens.Select
|
||||
{
|
||||
case Key.KeypadEnter:
|
||||
case Key.Enter:
|
||||
carouselRaisedStart(state);
|
||||
Start();
|
||||
return true;
|
||||
case Key.Delete:
|
||||
if (state.Keyboard.ShiftPressed)
|
||||
{
|
||||
if (!Beatmap.IsDefault)
|
||||
promptDelete(Beatmap.Value.BeatmapSetInfo);
|
||||
delete(Beatmap.Value.BeatmapSetInfo);
|
||||
return true;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -5,10 +5,11 @@ using osu.Game.Beatmaps;
|
||||
using osu.Game.Storyboards.Drawables;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System;
|
||||
|
||||
namespace osu.Game.Storyboards
|
||||
{
|
||||
public class Storyboard
|
||||
public class Storyboard : IDisposable
|
||||
{
|
||||
private readonly Dictionary<string, StoryboardLayer> layers = new Dictionary<string, StoryboardLayer>();
|
||||
public IEnumerable<StoryboardLayer> Layers => layers.Values;
|
||||
@ -59,5 +60,29 @@ namespace osu.Game.Storyboards
|
||||
}
|
||||
return drawable;
|
||||
}
|
||||
|
||||
#region Disposal
|
||||
|
||||
~Storyboard()
|
||||
{
|
||||
Dispose(false);
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Dispose(true);
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
private bool isDisposed;
|
||||
|
||||
protected virtual void Dispose(bool isDisposing)
|
||||
{
|
||||
if (isDisposed)
|
||||
return;
|
||||
isDisposed = true;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
@ -8,7 +8,6 @@ using System.Text;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Beatmaps.Formats;
|
||||
using osu.Game.Rulesets;
|
||||
using osu.Game.Rulesets.Mods;
|
||||
using osu.Game.Screens.Play;
|
||||
@ -63,7 +62,7 @@ namespace osu.Game.Tests.Visual
|
||||
|
||||
using (var stream = new MemoryStream(Encoding.UTF8.GetBytes(test_beatmap_data)))
|
||||
using (var reader = new StreamReader(stream))
|
||||
beatmap = BeatmapDecoder.GetDecoder(reader).Decode(reader);
|
||||
beatmap = Game.Beatmaps.Formats.Decoder.GetDecoder(reader).DecodeBeatmap(reader);
|
||||
|
||||
return beatmap;
|
||||
}
|
||||
|
@ -75,7 +75,7 @@ namespace osu.Game.Users
|
||||
public bool Active;
|
||||
|
||||
[JsonProperty(@"interests")]
|
||||
public string Intrerests;
|
||||
public string Interests;
|
||||
|
||||
[JsonProperty(@"occupation")]
|
||||
public string Occupation;
|
||||
@ -136,5 +136,7 @@ namespace osu.Game.Users
|
||||
|
||||
[JsonProperty(@"rankHistory")]
|
||||
public RankHistoryData RankHistory;
|
||||
|
||||
public override string ToString() => Username;
|
||||
}
|
||||
}
|
||||
|
@ -262,11 +262,10 @@
|
||||
<Compile Include="Beatmaps\ControlPoints\TimingControlPoint.cs" />
|
||||
<Compile Include="Beatmaps\DifficultyCalculator.cs" />
|
||||
<Compile Include="Beatmaps\Drawables\BeatmapBackgroundSprite.cs" />
|
||||
<Compile Include="Beatmaps\Drawables\BeatmapGroup.cs" />
|
||||
<Compile Include="Beatmaps\Drawables\BeatmapPanel.cs" />
|
||||
<Compile Include="Beatmaps\Drawables\BeatmapSetCover.cs" />
|
||||
<Compile Include="Beatmaps\Drawables\BeatmapSetHeader.cs" />
|
||||
<Compile Include="Beatmaps\Formats\OsuJsonDecoder.cs" />
|
||||
<Compile Include="Beatmaps\Formats\LegacyDecoder.cs" />
|
||||
<Compile Include="Beatmaps\Formats\LegacyStoryboardDecoder.cs" />
|
||||
<Compile Include="Database\DatabaseContextFactory.cs" />
|
||||
<Compile Include="Database\IHasPrimaryKey.cs" />
|
||||
<Compile Include="Graphics\UserInterface\HoverClickSounds.cs" />
|
||||
@ -285,15 +284,24 @@
|
||||
<Compile Include="Migrations\20171119065731_AddBeatmapOnlineIDUniqueConstraint.Designer.cs">
|
||||
<DependentUpon>20171119065731_AddBeatmapOnlineIDUniqueConstraint.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Migrations\20171209034410_AddRulesetInfoShortName.cs" />
|
||||
<Compile Include="Migrations\20171209034410_AddRulesetInfoShortName.Designer.cs">
|
||||
<DependentUpon>20171209034410_AddRulesetInfoShortName.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Migrations\OsuDbContextModelSnapshot.cs" />
|
||||
<Compile Include="Online\API\Requests\GetBeatmapSetRequest.cs" />
|
||||
<Compile Include="Online\API\Requests\GetBeatmapSetsResponse.cs" />
|
||||
<Compile Include="Online\API\Requests\APIResponseBeatmapSet.cs" />
|
||||
<Compile Include="Online\API\Requests\GetUserMostPlayedBeatmapsRequest.cs" />
|
||||
<Compile Include="Overlays\BeatmapSet\Scores\ClickableUsername.cs" />
|
||||
<Compile Include="Overlays\BeatmapSet\Scores\DrawableScore.cs" />
|
||||
<Compile Include="Overlays\BeatmapSet\Scores\DrawableTopScore.cs" />
|
||||
<Compile Include="Overlays\BeatmapSet\Scores\ScoresContainer.cs" />
|
||||
<Compile Include="Online\API\Requests\GetUserBeatmapsRequest.cs" />
|
||||
<Compile Include="Overlays\Profile\Sections\BeatmapMetadataContainer.cs" />
|
||||
<Compile Include="Overlays\Profile\Sections\Beatmaps\PaginatedBeatmapContainer.cs" />
|
||||
<Compile Include="Overlays\Profile\Sections\DrawableProfileRow.cs" />
|
||||
<Compile Include="Overlays\Profile\Sections\Historical\DrawableMostPlayedRow.cs" />
|
||||
<Compile Include="Overlays\Profile\Sections\Historical\PaginatedMostPlayedBeatmapContainer.cs" />
|
||||
<Compile Include="Overlays\Profile\Sections\Kudosu\KudosuInfo.cs" />
|
||||
<Compile Include="Overlays\Profile\Sections\PaginatedContainer.cs" />
|
||||
<Compile Include="Overlays\Profile\Sections\Ranks\DrawablePerformanceScore.cs" />
|
||||
@ -301,16 +309,21 @@
|
||||
<Compile Include="Overlays\Profile\Sections\Ranks\DrawableTotalScore.cs" />
|
||||
<Compile Include="Overlays\Profile\Sections\Ranks\ScoreModsContainer.cs" />
|
||||
<Compile Include="Overlays\Settings\SettingsButton.cs" />
|
||||
<Compile Include="Rulesets\Edit\Layers\Selection\OriginHandle.cs" />
|
||||
<Compile Include="Rulesets\Edit\Layers\Selection\HitObjectSelectionBox.cs" />
|
||||
<Compile Include="Rulesets\Edit\Layers\Selection\Handle.cs" />
|
||||
<Compile Include="Rulesets\Edit\Layers\Selection\HandleContainer.cs" />
|
||||
<Compile Include="Rulesets\Edit\Layers\Selection\SelectionInfo.cs" />
|
||||
<Compile Include="Rulesets\Edit\Layers\Selection\SelectionLayer.cs" />
|
||||
<Compile Include="Screens\Edit\Components\BottomBarContainer.cs" />
|
||||
<Compile Include="Screens\Edit\Components\PlaybackControl.cs" />
|
||||
<Compile Include="Screens\Edit\Components\TimeInfoContainer.cs" />
|
||||
<Compile Include="Rulesets\Mods\IApplicableToScoreProcessor.cs" />
|
||||
<Compile Include="Beatmaps\Drawables\DifficultyColouredContainer.cs" />
|
||||
<Compile Include="Beatmaps\Drawables\DifficultyIcon.cs" />
|
||||
<Compile Include="Beatmaps\Drawables\Panel.cs" />
|
||||
<Compile Include="Beatmaps\DummyWorkingBeatmap.cs" />
|
||||
<Compile Include="Beatmaps\Formats\BeatmapDecoder.cs" />
|
||||
<Compile Include="Beatmaps\Formats\OsuLegacyDecoder.cs" />
|
||||
<Compile Include="Beatmaps\Formats\Decoder.cs" />
|
||||
<Compile Include="Beatmaps\Formats\LegacyBeatmapDecoder.cs" />
|
||||
<Compile Include="Beatmaps\IO\ArchiveReader.cs" />
|
||||
<Compile Include="Beatmaps\IO\LegacyFilesystemReader.cs" />
|
||||
<Compile Include="Online\API\Requests\GetUserScoresRequest.cs" />
|
||||
@ -338,7 +351,7 @@
|
||||
<Compile Include="Configuration\ReleaseStream.cs" />
|
||||
<Compile Include="Configuration\ScoreMeterType.cs" />
|
||||
<Compile Include="Configuration\ScreenshotFormat.cs" />
|
||||
<Compile Include="Configuration\SelectionRandomType.cs" />
|
||||
<Compile Include="Configuration\RandomSelectAlgorithm.cs" />
|
||||
<Compile Include="Database\DatabaseBackedStore.cs" />
|
||||
<Compile Include="Database\OsuDbContext.cs" />
|
||||
<Compile Include="Graphics\Backgrounds\Background.cs" />
|
||||
@ -485,7 +498,7 @@
|
||||
<Compile Include="Overlays\Notifications\ProgressNotification.cs" />
|
||||
<Compile Include="Overlays\Notifications\SimpleNotification.cs" />
|
||||
<Compile Include="Overlays\OnScreenDisplay.cs" />
|
||||
<Compile Include="Overlays\Profile\Sections\Ranks\DrawableScore.cs" />
|
||||
<Compile Include="Overlays\Profile\Sections\Ranks\DrawableProfileScore.cs" />
|
||||
<Compile Include="Overlays\Profile\ProfileHeader.cs" />
|
||||
<Compile Include="Overlays\Profile\ProfileSection.cs" />
|
||||
<Compile Include="Overlays\Profile\RankChart.cs" />
|
||||
@ -716,7 +729,7 @@
|
||||
<Compile Include="Screens\Play\KeyCounterCollection.cs" />
|
||||
<Compile Include="Screens\Play\KeyCounterKeyboard.cs" />
|
||||
<Compile Include="Screens\Play\KeyCounterMouse.cs" />
|
||||
<Compile Include="Screens\Play\MenuOverlay.cs" />
|
||||
<Compile Include="Screens\Play\GameplayMenuOverlay.cs" />
|
||||
<Compile Include="Screens\Play\PauseContainer.cs" />
|
||||
<Compile Include="Screens\Play\Player.cs" />
|
||||
<Compile Include="Screens\Play\PlayerLoader.cs" />
|
||||
@ -749,6 +762,14 @@
|
||||
<Compile Include="Screens\Select\BeatmapDetailAreaTabControl.cs" />
|
||||
<Compile Include="Screens\Select\BeatmapDetails.cs" />
|
||||
<Compile Include="Screens\Select\BeatmapInfoWedge.cs" />
|
||||
<Compile Include="Screens\Select\Carousel\CarouselBeatmap.cs" />
|
||||
<Compile Include="Screens\Select\Carousel\CarouselBeatmapSet.cs" />
|
||||
<Compile Include="Screens\Select\Carousel\CarouselGroup.cs" />
|
||||
<Compile Include="Screens\Select\Carousel\CarouselGroupEagerSelect.cs" />
|
||||
<Compile Include="Screens\Select\Carousel\CarouselItem.cs" />
|
||||
<Compile Include="Screens\Select\Carousel\DrawableCarouselBeatmap.cs" />
|
||||
<Compile Include="Screens\Select\Carousel\DrawableCarouselBeatmapSet.cs" />
|
||||
<Compile Include="Screens\Select\Carousel\DrawableCarouselItem.cs" />
|
||||
<Compile Include="Screens\Select\Details\AdvancedStats.cs" />
|
||||
<Compile Include="Screens\Select\Details\FailRetryGraph.cs" />
|
||||
<Compile Include="Screens\Select\Details\UserRatings.cs" />
|
||||
@ -822,6 +843,9 @@
|
||||
<Compile Include="Overlays\BeatmapSet\SuccessRate.cs" />
|
||||
<Compile Include="Overlays\BeatmapSet\PreviewButton.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
|
Reference in New Issue
Block a user