Merge branch 'master' into replay_ruleset

This commit is contained in:
Dan Balasescu 2018-05-02 14:57:02 +08:00 committed by GitHub
commit 9f327525a7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 104 additions and 40 deletions

@ -1 +1 @@
Subproject commit 61e676094d25436bb9e8858946f65c43d15d8e01 Subproject commit 0773d895d9aa0729995cd4a23efc28238e35ceed

View File

@ -52,6 +52,9 @@ namespace osu.Game.Tests.Visual
infoWedge.UpdateBeatmap(beatmap); infoWedge.UpdateBeatmap(beatmap);
}); });
// select part is redundant, but wait for load isn't
selectBeatmap(beatmap.Value.Beatmap);
AddWaitStep(3); AddWaitStep(3);
AddStep("hide", () => { infoWedge.State = Visibility.Hidden; }); AddStep("hide", () => { infoWedge.State = Visibility.Hidden; });
@ -63,10 +66,11 @@ namespace osu.Game.Tests.Visual
foreach (var rulesetInfo in rulesets.AvailableRulesets) foreach (var rulesetInfo in rulesets.AvailableRulesets)
{ {
var ruleset = rulesetInfo.CreateInstance(); var ruleset = rulesetInfo.CreateInstance();
beatmaps.Add(createTestBeatmap(rulesetInfo)); var testBeatmap = createTestBeatmap(rulesetInfo);
var name = rulesetInfo.ShortName; beatmaps.Add(testBeatmap);
selectBeatmap(name);
selectBeatmap(testBeatmap);
// TODO: adjust cases once more info is shown for other gamemodes // TODO: adjust cases once more info is shown for other gamemodes
switch (ruleset) switch (ruleset)
@ -108,16 +112,14 @@ namespace osu.Game.Tests.Visual
AddAssert("check no infolabels", () => !infoWedge.Info.InfoLabelContainer.Children.Any()); AddAssert("check no infolabels", () => !infoWedge.Info.InfoLabelContainer.Children.Any());
} }
private void selectBeatmap(string name) private void selectBeatmap(Beatmap b)
{ {
BeatmapInfoWedge.BufferedWedgeInfo infoBefore = null; BeatmapInfoWedge.BufferedWedgeInfo infoBefore = null;
AddStep($"select {name} beatmap", () => AddStep($"select {b.Metadata.Title} beatmap", () =>
{ {
infoBefore = infoWedge.Info; infoBefore = infoWedge.Info;
WorkingBeatmap bm = new TestWorkingBeatmap(beatmaps.First(b => b.BeatmapInfo.Ruleset.ShortName == name)); infoWedge.UpdateBeatmap(beatmap.Value = new TestWorkingBeatmap(b));
beatmap.Value = bm;
infoWedge.UpdateBeatmap(beatmap);
}); });
AddUntilStep(() => infoWedge.Info != infoBefore, "wait for async load"); AddUntilStep(() => infoWedge.Info != infoBefore, "wait for async load");

View File

@ -373,17 +373,18 @@ namespace osu.Game.Beatmaps.Formats
if (parser == null) if (parser == null)
parser = new Rulesets.Objects.Legacy.Osu.ConvertHitObjectParser(); parser = new Rulesets.Objects.Legacy.Osu.ConvertHitObjectParser();
var obj = parser.Parse(line); var obj = parser.Parse(line, getOffsetTime());
if (obj != null) if (obj != null)
{ {
obj.StartTime = getOffsetTime(obj.StartTime);
beatmap.HitObjects.Add(obj); beatmap.HitObjects.Add(obj);
} }
} }
private int getOffsetTime(int time) => time + (ApplyOffsets ? offset : 0); private int getOffsetTime(int time) => time + (ApplyOffsets ? offset : 0);
private double getOffsetTime() => ApplyOffsets ? offset : 0;
private double getOffsetTime(double time) => time + (ApplyOffsets ? offset : 0); private double getOffsetTime(double time) => time + (ApplyOffsets ? offset : 0);
} }
} }

View File

@ -60,6 +60,9 @@ namespace osu.Game.Configuration
Set(OsuSetting.ShowFpsDisplay, false); Set(OsuSetting.ShowFpsDisplay, false);
Set(OsuSetting.ShowStoryboard, true); Set(OsuSetting.ShowStoryboard, true);
Set(OsuSetting.BeatmapSkins, true);
Set(OsuSetting.BeatmapHitsounds, true);
Set(OsuSetting.CursorRotation, true); Set(OsuSetting.CursorRotation, true);
Set(OsuSetting.MenuParallax, true); Set(OsuSetting.MenuParallax, true);
@ -133,6 +136,8 @@ namespace osu.Game.Configuration
Skin, Skin,
ScreenshotFormat, ScreenshotFormat,
ScreenshotCaptureMenuCursor, ScreenshotCaptureMenuCursor,
SongSelectRightMouseScroll SongSelectRightMouseScroll,
BeatmapSkins,
BeatmapHitsounds
} }
} }

View File

@ -307,6 +307,8 @@ namespace osu.Game.Overlays.Chat
{ {
public override bool IsRemovable => false; public override bool IsRemovable => false;
public override bool IsSwitchable => false;
public ChannelSelectorTabItem(Channel value) : base(value) public ChannelSelectorTabItem(Channel value) : base(value)
{ {
Depth = float.MaxValue; Depth = float.MaxValue;

View File

@ -71,6 +71,7 @@ namespace osu.Game.Overlays
{ {
base.PopOut(); base.PopOut();
FadeEdgeEffectTo(0, WaveContainer.DISAPPEAR_DURATION, Easing.Out); FadeEdgeEffectTo(0, WaveContainer.DISAPPEAR_DURATION, Easing.Out);
cleanup();
} }
public void ShowUser(long userId) public void ShowUser(long userId)
@ -83,9 +84,7 @@ namespace osu.Game.Overlays
public void ShowUser(User user, bool fetchOnline = true) public void ShowUser(User user, bool fetchOnline = true)
{ {
userReq?.Cancel(); cleanup();
Clear();
lastSection = null;
sections = new ProfileSection[] sections = new ProfileSection[]
{ {
@ -165,6 +164,13 @@ namespace osu.Game.Overlays
sectionsContainer.ScrollToTop(); sectionsContainer.ScrollToTop();
} }
private void cleanup()
{
userReq?.Cancel();
Clear();
lastSection = null;
}
private void userLoadComplete(User user) private void userLoadComplete(User user)
{ {
Header.User = user; Header.User = user;

View File

@ -19,6 +19,11 @@ namespace osu.Game.Rulesets.Objects.Legacy
public abstract class ConvertHitObjectParser : HitObjectParser public abstract class ConvertHitObjectParser : HitObjectParser
{ {
public override HitObject Parse(string text) public override HitObject Parse(string text)
{
return Parse(text, 0);
}
public HitObject Parse(string text, double offset)
{ {
try try
{ {
@ -146,7 +151,7 @@ namespace osu.Game.Rulesets.Objects.Legacy
} }
else if ((type & ConvertHitObjectType.Spinner) > 0) else if ((type & ConvertHitObjectType.Spinner) > 0)
{ {
result = CreateSpinner(new Vector2(512, 384) / 2, Convert.ToDouble(split[5], CultureInfo.InvariantCulture)); result = CreateSpinner(new Vector2(512, 384) / 2, Convert.ToDouble(split[5], CultureInfo.InvariantCulture) + offset);
if (split.Length > 6) if (split.Length > 6)
readCustomSampleBanks(split[6], bankInfo); readCustomSampleBanks(split[6], bankInfo);
@ -164,13 +169,13 @@ namespace osu.Game.Rulesets.Objects.Legacy
readCustomSampleBanks(string.Join(":", ss.Skip(1)), bankInfo); readCustomSampleBanks(string.Join(":", ss.Skip(1)), bankInfo);
} }
result = CreateHold(new Vector2(int.Parse(split[0]), int.Parse(split[1])), combo, endTime); result = CreateHold(new Vector2(int.Parse(split[0]), int.Parse(split[1])), combo, endTime + offset);
} }
if (result == null) if (result == null)
throw new InvalidOperationException($@"Unknown hit object type {type}."); throw new InvalidOperationException($@"Unknown hit object type {type}.");
result.StartTime = Convert.ToDouble(split[2], CultureInfo.InvariantCulture); result.StartTime = Convert.ToDouble(split[2], CultureInfo.InvariantCulture) + offset;
result.Samples = convertSoundType(soundType, bankInfo); result.Samples = convertSoundType(soundType, bankInfo);
return result; return result;

View File

@ -15,6 +15,8 @@ namespace osu.Game.Screens.Play.PlayerSettings
private readonly PlayerSliderBar<double> dimSliderBar; private readonly PlayerSliderBar<double> dimSliderBar;
private readonly PlayerSliderBar<double> blurSliderBar; private readonly PlayerSliderBar<double> blurSliderBar;
private readonly PlayerCheckbox showStoryboardToggle; private readonly PlayerCheckbox showStoryboardToggle;
private readonly PlayerCheckbox beatmapSkinsToggle;
private readonly PlayerCheckbox beatmapHitsoundsToggle;
public VisualSettings() public VisualSettings()
{ {
@ -34,7 +36,9 @@ namespace osu.Game.Screens.Play.PlayerSettings
{ {
Text = "Toggles:" Text = "Toggles:"
}, },
showStoryboardToggle = new PlayerCheckbox { LabelText = "Storyboards" } showStoryboardToggle = new PlayerCheckbox { LabelText = "Storyboards" },
beatmapSkinsToggle = new PlayerCheckbox { LabelText = "Beatmap skins" },
beatmapHitsoundsToggle = new PlayerCheckbox { LabelText = "Beatmap hitsounds" }
}; };
} }
@ -44,6 +48,8 @@ namespace osu.Game.Screens.Play.PlayerSettings
dimSliderBar.Bindable = config.GetBindable<double>(OsuSetting.DimLevel); dimSliderBar.Bindable = config.GetBindable<double>(OsuSetting.DimLevel);
blurSliderBar.Bindable = config.GetBindable<double>(OsuSetting.BlurLevel); blurSliderBar.Bindable = config.GetBindable<double>(OsuSetting.BlurLevel);
showStoryboardToggle.Bindable = config.GetBindable<bool>(OsuSetting.ShowStoryboard); showStoryboardToggle.Bindable = config.GetBindable<bool>(OsuSetting.ShowStoryboard);
beatmapSkinsToggle.Bindable = config.GetBindable<bool>(OsuSetting.BeatmapSkins);
beatmapHitsoundsToggle.Bindable = config.GetBindable<bool>(OsuSetting.BeatmapHitsounds);
} }
} }
} }

View File

@ -27,6 +27,11 @@ namespace osu.Game.Screens.Select.Carousel
get get
{ {
var drawables = base.Drawables; var drawables = base.Drawables;
// if we are explicitly not present, don't ever present children.
// without this check, children drawables can potentially be presented without their group header.
if (DrawableRepresentation.Value?.IsPresent == false) return drawables;
foreach (var c in InternalChildren) foreach (var c in InternalChildren)
drawables.AddRange(c.Drawables); drawables.AddRange(c.Drawables);
return drawables; return drawables;

View File

@ -24,7 +24,7 @@ namespace osu.Game.Screens.Select.Carousel
{ {
var items = new List<DrawableCarouselItem>(); var items = new List<DrawableCarouselItem>();
var self = drawableRepresentation.Value; var self = DrawableRepresentation.Value;
if (self?.IsPresent == true) items.Add(self); if (self?.IsPresent == true) items.Add(self);
return items; return items;
@ -35,7 +35,7 @@ namespace osu.Game.Screens.Select.Carousel
protected CarouselItem() protected CarouselItem()
{ {
drawableRepresentation = new Lazy<DrawableCarouselItem>(CreateDrawableRepresentation); DrawableRepresentation = new Lazy<DrawableCarouselItem>(CreateDrawableRepresentation);
Filtered.ValueChanged += v => Filtered.ValueChanged += v =>
{ {
@ -44,13 +44,16 @@ namespace osu.Game.Screens.Select.Carousel
}; };
} }
private readonly Lazy<DrawableCarouselItem> drawableRepresentation; protected readonly Lazy<DrawableCarouselItem> DrawableRepresentation;
/// <summary> /// <summary>
/// Used as a default sort method for <see cref="CarouselItem"/>s of differing types. /// Used as a default sort method for <see cref="CarouselItem"/>s of differing types.
/// </summary> /// </summary>
internal ulong ChildID; internal ulong ChildID;
/// <summary>
/// Create a fresh drawable version of this item. If you wish to consume the current representation, use <see cref="DrawableRepresentation"/> instead.
/// </summary>
protected abstract DrawableCarouselItem CreateDrawableRepresentation(); protected abstract DrawableCarouselItem CreateDrawableRepresentation();
public virtual void Filter(FilterCriteria criteria) public virtual void Filter(FilterCriteria criteria)

View File

@ -4,9 +4,11 @@
using System; using System;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Audio.Sample; using osu.Framework.Audio.Sample;
using osu.Framework.Configuration;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Textures; using osu.Framework.Graphics.Textures;
using osu.Game.Configuration;
namespace osu.Game.Skinning namespace osu.Game.Skinning
{ {
@ -14,17 +16,37 @@ namespace osu.Game.Skinning
{ {
public event Action SourceChanged; public event Action SourceChanged;
public Drawable GetDrawableComponent(string componentName) => source.GetDrawableComponent(componentName) ?? fallbackSource?.GetDrawableComponent(componentName); private Bindable<bool> beatmapSkins = new Bindable<bool>();
private Bindable<bool> beatmapHitsounds = new Bindable<bool>();
public Texture GetTexture(string componentName) => source.GetTexture(componentName) ?? fallbackSource.GetTexture(componentName); public Drawable GetDrawableComponent(string componentName)
{
Drawable sourceDrawable;
if (beatmapSkins && (sourceDrawable = source.GetDrawableComponent(componentName)) != null)
return sourceDrawable;
return fallbackSource?.GetDrawableComponent(componentName);
}
public SampleChannel GetSample(string sampleName) => source.GetSample(sampleName) ?? fallbackSource?.GetSample(sampleName); public Texture GetTexture(string componentName)
{
Texture sourceTexture;
if (beatmapSkins && (sourceTexture = source.GetTexture(componentName)) != null)
return sourceTexture;
return fallbackSource.GetTexture(componentName);
}
public SampleChannel GetSample(string sampleName)
{
SampleChannel sourceChannel;
if (beatmapHitsounds && (sourceChannel = source.GetSample(sampleName)) != null)
return sourceChannel;
return fallbackSource?.GetSample(sampleName);
}
public TValue? GetValue<TConfiguration, TValue>(Func<TConfiguration, TValue?> query) where TConfiguration : SkinConfiguration where TValue : struct public TValue? GetValue<TConfiguration, TValue>(Func<TConfiguration, TValue?> query) where TConfiguration : SkinConfiguration where TValue : struct
{ {
TValue? val = null; TValue? val = null;
var conf = (source as Skin)?.Configuration as TConfiguration; if ((source as Skin)?.Configuration is TConfiguration conf)
if (conf != null)
val = query?.Invoke(conf); val = query?.Invoke(conf);
return val ?? fallbackSource?.GetValue(query); return val ?? fallbackSource?.GetValue(query);
@ -33,8 +55,7 @@ namespace osu.Game.Skinning
public TValue GetValue<TConfiguration, TValue>(Func<TConfiguration, TValue> query) where TConfiguration : SkinConfiguration where TValue : class public TValue GetValue<TConfiguration, TValue>(Func<TConfiguration, TValue> query) where TConfiguration : SkinConfiguration where TValue : class
{ {
TValue val = null; TValue val = null;
var conf = (source as Skin)?.Configuration as TConfiguration; if ((source as Skin)?.Configuration is TConfiguration conf)
if (conf != null)
val = query?.Invoke(conf); val = query?.Invoke(conf);
return val ?? fallbackSource?.GetValue(query); return val ?? fallbackSource?.GetValue(query);
@ -60,6 +81,18 @@ namespace osu.Game.Skinning
return dependencies; return dependencies;
} }
[BackgroundDependencyLoader]
private void load(OsuConfigManager config)
{
beatmapSkins = config.GetBindable<bool>(OsuSetting.BeatmapSkins);
beatmapSkins.ValueChanged += val => onSourceChanged();
beatmapSkins.TriggerChange();
beatmapHitsounds = config.GetBindable<bool>(OsuSetting.BeatmapHitsounds);
beatmapHitsounds.ValueChanged += val => onSourceChanged();
beatmapHitsounds.TriggerChange();
}
protected override void LoadComplete() protected override void LoadComplete()
{ {
base.LoadComplete(); base.LoadComplete();

View File

@ -12,12 +12,13 @@ namespace osu.Game.Users
public abstract Color4 GetAppropriateColour(OsuColour colours); public abstract Color4 GetAppropriateColour(OsuColour colours);
} }
public abstract class UserStatusAvailable : UserStatus public class UserStatusOnline : UserStatus
{ {
public override string Message => @"Online";
public override Color4 GetAppropriateColour(OsuColour colours) => colours.BlueDarker; public override Color4 GetAppropriateColour(OsuColour colours) => colours.BlueDarker;
} }
public abstract class UserStatusBusy : UserStatus public abstract class UserStatusBusy : UserStatusOnline
{ {
public override Color4 GetAppropriateColour(OsuColour colours) => colours.YellowDark; public override Color4 GetAppropriateColour(OsuColour colours) => colours.YellowDark;
} }
@ -28,17 +29,12 @@ namespace osu.Game.Users
public override Color4 GetAppropriateColour(OsuColour colours) => colours.Gray7; public override Color4 GetAppropriateColour(OsuColour colours) => colours.Gray7;
} }
public class UserStatusOnline : UserStatusAvailable public class UserStatusSpectating : UserStatusOnline
{
public override string Message => @"Online";
}
public class UserStatusSpectating : UserStatusAvailable
{ {
public override string Message => @"Spectating a game"; public override string Message => @"Spectating a game";
} }
public class UserStatusInLobby : UserStatusAvailable public class UserStatusInLobby : UserStatusOnline
{ {
public override string Message => @"in Multiplayer Lobby"; public override string Message => @"in Multiplayer Lobby";
} }
@ -53,13 +49,13 @@ namespace osu.Game.Users
public override string Message => @"Multiplaying"; public override string Message => @"Multiplaying";
} }
public class UserStatusModding : UserStatus public class UserStatusModding : UserStatusOnline
{ {
public override string Message => @"Modding a map"; public override string Message => @"Modding a map";
public override Color4 GetAppropriateColour(OsuColour colours) => colours.PurpleDark; public override Color4 GetAppropriateColour(OsuColour colours) => colours.PurpleDark;
} }
public class UserStatusDoNotDisturb : UserStatus public class UserStatusDoNotDisturb : UserStatusBusy
{ {
public override string Message => @"Do not disturb"; public override string Message => @"Do not disturb";
public override Color4 GetAppropriateColour(OsuColour colours) => colours.RedDark; public override Color4 GetAppropriateColour(OsuColour colours) => colours.RedDark;