1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-15 01:43:20 +08:00

Merge branch 'master' into update-direct-categories-sorting

This commit is contained in:
Dan Balasescu 2019-08-05 17:11:48 +09:00 committed by GitHub
commit cd27e1eb70
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 168 additions and 85 deletions

View File

@ -28,8 +28,8 @@
<ItemGroup Label="Package References">
<PackageReference Include="System.IO.Packaging" Version="4.5.0" />
<PackageReference Include="ppy.squirrel.windows" Version="1.9.0.4" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="2.2.4" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="2.2.4" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="2.2.6" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="2.2.6" />
</ItemGroup>
<ItemGroup Label="Resources">
<EmbeddedResource Include="lazer.ico" />

View File

@ -35,11 +35,37 @@ namespace osu.Game.Rulesets.Mania.Tests
};
}
protected override ManiaConvertMapping CreateConvertMapping() => new ManiaConvertMapping(Converter);
private readonly Dictionary<HitObject, RngSnapshot> rngSnapshots = new Dictionary<HitObject, RngSnapshot>();
protected override void OnConversionGenerated(HitObject original, IEnumerable<HitObject> result, IBeatmapConverter beatmapConverter)
{
base.OnConversionGenerated(original, result, beatmapConverter);
rngSnapshots[original] = new RngSnapshot(beatmapConverter);
}
protected override ManiaConvertMapping CreateConvertMapping(HitObject source) => new ManiaConvertMapping(rngSnapshots[source]);
protected override Ruleset CreateRuleset() => new ManiaRuleset();
}
public class RngSnapshot
{
public readonly uint RandomW;
public readonly uint RandomX;
public readonly uint RandomY;
public readonly uint RandomZ;
public RngSnapshot(IBeatmapConverter converter)
{
var maniaConverter = (ManiaBeatmapConverter)converter;
RandomW = maniaConverter.Random.W;
RandomX = maniaConverter.Random.X;
RandomY = maniaConverter.Random.Y;
RandomZ = maniaConverter.Random.Z;
}
}
public class ManiaConvertMapping : ConvertMapping<ConvertValue>, IEquatable<ManiaConvertMapping>
{
public uint RandomW;
@ -51,13 +77,12 @@ namespace osu.Game.Rulesets.Mania.Tests
{
}
public ManiaConvertMapping(IBeatmapConverter converter)
public ManiaConvertMapping(RngSnapshot snapshot)
{
var maniaConverter = (ManiaBeatmapConverter)converter;
RandomW = maniaConverter.Random.W;
RandomX = maniaConverter.Random.X;
RandomY = maniaConverter.Random.Y;
RandomZ = maniaConverter.Random.Z;
RandomW = snapshot.RandomW;
RandomX = snapshot.RandomX;
RandomY = snapshot.RandomY;
RandomZ = snapshot.RandomZ;
}
public bool Equals(ManiaConvertMapping other) => other != null && RandomW == other.RandomW && RandomX == other.RandomX && RandomY == other.RandomY && RandomZ == other.RandomZ;

View File

@ -9,6 +9,8 @@ using osu.Game.Rulesets.Catch;
using osu.Game.Rulesets.Mania;
using osu.Game.Rulesets.Osu;
using osu.Game.Rulesets.Taiko;
using osu.Game.Users;
using osu.Framework.Bindables;
namespace osu.Game.Tests.Visual.Online
{
@ -23,18 +25,25 @@ namespace osu.Game.Tests.Visual.Online
public TestSceneProfileRulesetSelector()
{
ProfileRulesetSelector selector;
Bindable<User> user = new Bindable<User>();
Child = selector = new ProfileRulesetSelector
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
User = { BindTarget = user }
};
AddStep("set osu! as default", () => selector.SetDefaultRuleset(new OsuRuleset().RulesetInfo));
AddStep("set mania as default", () => selector.SetDefaultRuleset(new ManiaRuleset().RulesetInfo));
AddStep("set taiko as default", () => selector.SetDefaultRuleset(new TaikoRuleset().RulesetInfo));
AddStep("set catch as default", () => selector.SetDefaultRuleset(new CatchRuleset().RulesetInfo));
AddStep("select default ruleset", selector.SelectDefaultRuleset);
AddStep("User with osu as default", () => user.Value = new User { PlayMode = "osu" });
AddStep("User with mania as default", () => user.Value = new User { PlayMode = "mania" });
AddStep("User with taiko as default", () => user.Value = new User { PlayMode = "taiko" });
AddStep("User with catch as default", () => user.Value = new User { PlayMode = "fruits" });
AddStep("null user", () => user.Value = null);
}
}
}

View File

@ -89,6 +89,14 @@ namespace osu.Game.Beatmaps
return path;
}
/// <summary>
/// Creates a <see cref="IBeatmapConverter"/> to convert a <see cref="IBeatmap"/> for a specified <see cref="Ruleset"/>.
/// </summary>
/// <param name="beatmap">The <see cref="IBeatmap"/> to be converted.</param>
/// <param name="ruleset">The <see cref="Ruleset"/> for which <paramref name="beatmap"/> should be converted.</param>
/// <returns>The applicable <see cref="IBeatmapConverter"/>.</returns>
protected virtual IBeatmapConverter CreateBeatmapConverter(IBeatmap beatmap, Ruleset ruleset) => ruleset.CreateBeatmapConverter(beatmap);
/// <summary>
/// Constructs a playable <see cref="IBeatmap"/> from <see cref="Beatmap"/> using the applicable converters for a specific <see cref="RulesetInfo"/>.
/// <para>
@ -104,7 +112,7 @@ namespace osu.Game.Beatmaps
{
var rulesetInstance = ruleset.CreateInstance();
IBeatmapConverter converter = rulesetInstance.CreateBeatmapConverter(Beatmap);
IBeatmapConverter converter = CreateBeatmapConverter(Beatmap, rulesetInstance);
// Check if the beatmap can be converted
if (!converter.CanConvert)

View File

@ -0,0 +1,44 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using osuTK.Graphics;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Extensions.Color4Extensions;
namespace osu.Game.Graphics.UserInterface
{
public class DimmedLoadingLayer : VisibilityContainer
{
private const float transition_duration = 250;
private readonly LoadingAnimation loading;
public DimmedLoadingLayer()
{
RelativeSizeAxes = Axes.Both;
Children = new Drawable[]
{
new Box
{
RelativeSizeAxes = Axes.Both,
Colour = Color4.Black.Opacity(0.5f),
},
loading = new LoadingAnimation(),
};
}
protected override void PopIn()
{
this.FadeIn(transition_duration, Easing.OutQuint);
loading.Show();
}
protected override void PopOut()
{
this.FadeOut(transition_duration, Easing.OutQuint);
loading.Hide();
}
}
}

View File

@ -81,7 +81,8 @@ namespace osu.Game.Graphics.UserInterface
Colour = Color4.White,
Origin = Anchor.BottomLeft,
Anchor = Anchor.BottomLeft,
}
},
new HoverClickSounds()
};
Current.ValueChanged += selected =>

View File

@ -2,11 +2,13 @@
// See the LICENCE file in the repository root for full licence text.
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.UserInterface;
using osu.Game.Graphics;
using osu.Game.Rulesets;
using osu.Game.Users;
using osuTK;
using osuTK.Graphics;
@ -16,6 +18,8 @@ namespace osu.Game.Overlays.Profile.Header.Components
{
private Color4 accentColour = Color4.White;
public readonly Bindable<User> User = new Bindable<User>();
public ProfileRulesetSelector()
{
TabContainer.Masking = false;
@ -32,24 +36,17 @@ namespace osu.Game.Overlays.Profile.Header.Components
((ProfileRulesetTabItem)tabItem).AccentColour = accentColour;
}
public void SetDefaultRuleset(RulesetInfo ruleset)
protected override void LoadComplete()
{
// Todo: This method shouldn't exist, but bindables don't provide the concept of observing a change to the default value
foreach (TabItem<RulesetInfo> tabItem in TabContainer)
((ProfileRulesetTabItem)tabItem).IsDefault = ((ProfileRulesetTabItem)tabItem).Value.ID == ruleset.ID;
base.LoadComplete();
User.BindValueChanged(u => SetDefaultRuleset(Rulesets.GetRuleset(u.NewValue?.PlayMode ?? "osu")), true);
}
public void SelectDefaultRuleset()
public void SetDefaultRuleset(RulesetInfo ruleset)
{
// Todo: This method shouldn't exist, but bindables don't provide the concept of observing a change to the default value
foreach (TabItem<RulesetInfo> tabItem in TabContainer)
{
if (((ProfileRulesetTabItem)tabItem).IsDefault)
{
Current.Value = ((ProfileRulesetTabItem)tabItem).Value;
return;
}
}
((ProfileRulesetTabItem)tabItem).IsDefault = ((ProfileRulesetTabItem)tabItem).Value.ID == ruleset.ID;
}
protected override TabItem<RulesetInfo> CreateTabItem(RulesetInfo value) => new ProfileRulesetTabItem(value)

View File

@ -80,7 +80,6 @@ namespace osu.Game.Overlays.Profile.Header.Components
private void load(OsuColour colours)
{
background.Colour = colours.Pink;
iconContainer.Colour = colours.GreySeafoam;
}
}
}

View File

@ -84,6 +84,7 @@ namespace osu.Game.Overlays.Settings
Content.Anchor = Anchor.CentreLeft;
Content.Origin = Anchor.CentreLeft;
RelativeSizeAxes = Axes.Both;
ScrollbarVisible = false;
}
}

View File

@ -186,7 +186,7 @@ namespace osu.Game.Overlays
base.UpdateAfterChildren();
ContentContainer.Margin = new MarginPadding { Left = Sidebar?.DrawWidth ?? 0 };
ContentContainer.Padding = new MarginPadding { Top = GetToolbarHeight?.Invoke() ?? 0 };
Padding = new MarginPadding { Top = GetToolbarHeight?.Invoke() ?? 0 };
}
protected class SettingsSectionsContainer : SectionsContainer<SettingsSection>

View File

@ -35,7 +35,7 @@ namespace osu.Game.Screens.Select
private readonly MetadataSection description, source, tags;
private readonly Container failRetryContainer;
private readonly FailRetryGraph failRetryGraph;
private readonly DimmedLoadingAnimation loading;
private readonly DimmedLoadingLayer loading;
private IAPIProvider api;
@ -156,10 +156,7 @@ namespace osu.Game.Screens.Select
},
},
},
loading = new DimmedLoadingAnimation
{
RelativeSizeAxes = Axes.Both,
},
loading = new DimmedLoadingLayer(),
};
}
@ -365,35 +362,5 @@ namespace osu.Game.Screens.Select
});
}
}
private class DimmedLoadingAnimation : VisibilityContainer
{
private readonly LoadingAnimation loading;
public DimmedLoadingAnimation()
{
Children = new Drawable[]
{
new Box
{
RelativeSizeAxes = Axes.Both,
Colour = Color4.Black.Opacity(0.5f),
},
loading = new LoadingAnimation(),
};
}
protected override void PopIn()
{
this.FadeIn(transition_duration, Easing.OutQuint);
loading.Show();
}
protected override void PopOut()
{
this.FadeOut(transition_duration, Easing.OutQuint);
loading.Hide();
}
}
}
}

View File

@ -4,13 +4,16 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using Newtonsoft.Json;
using NUnit.Framework;
using osu.Framework.Extensions.IEnumerableExtensions;
using osu.Framework.Audio.Track;
using osu.Framework.Graphics.Textures;
using osu.Game.Beatmaps;
using osu.Game.Beatmaps.Formats;
using osu.Game.Rulesets;
using osu.Game.Rulesets.Mods;
using osu.Game.Rulesets.Objects;
namespace osu.Game.Tests.Beatmaps
@ -25,8 +28,6 @@ namespace osu.Game.Tests.Beatmaps
protected abstract string ResourceAssembly { get; }
protected IBeatmapConverter Converter { get; private set; }
protected void Test(string name)
{
var ourResult = convert(name);
@ -98,26 +99,33 @@ namespace osu.Game.Tests.Beatmaps
var rulesetInstance = CreateRuleset();
beatmap.BeatmapInfo.Ruleset = beatmap.BeatmapInfo.RulesetID == rulesetInstance.RulesetInfo.ID ? rulesetInstance.RulesetInfo : new RulesetInfo();
Converter = rulesetInstance.CreateBeatmapConverter(beatmap);
var converterResult = new Dictionary<HitObject, IEnumerable<HitObject>>();
var result = new ConvertResult();
Converter.ObjectConverted += (orig, converted) =>
var working = new ConversionWorkingBeatmap(beatmap)
{
converted.ForEach(h => h.ApplyDefaults(beatmap.ControlPointInfo, beatmap.BeatmapInfo.BaseDifficulty));
var mapping = CreateConvertMapping();
mapping.StartTime = orig.StartTime;
foreach (var obj in converted)
mapping.Objects.AddRange(CreateConvertValue(obj));
result.Mappings.Add(mapping);
ConversionGenerated = (o, r, c) =>
{
converterResult[o] = r;
OnConversionGenerated(o, r, c);
}
};
IBeatmap convertedBeatmap = Converter.Convert();
rulesetInstance.CreateBeatmapProcessor(convertedBeatmap)?.PostProcess();
working.GetPlayableBeatmap(rulesetInstance.RulesetInfo, Array.Empty<Mod>());
return result;
return new ConvertResult
{
Mappings = converterResult.Select(r =>
{
var mapping = CreateConvertMapping(r.Key);
mapping.StartTime = r.Key.StartTime;
mapping.Objects.AddRange(r.Value.SelectMany(CreateConvertValue));
return mapping;
}).ToList()
};
}
protected virtual void OnConversionGenerated(HitObject original, IEnumerable<HitObject> result, IBeatmapConverter beatmapConverter)
{
}
private ConvertResult read(string name)
@ -154,7 +162,7 @@ namespace osu.Game.Tests.Beatmaps
/// This should be used to validate the integrity of the conversion process after a conversion has occurred.
/// </para>
/// </summary>
protected virtual TConvertMapping CreateConvertMapping() => new TConvertMapping();
protected virtual TConvertMapping CreateConvertMapping(HitObject source) => new TConvertMapping();
/// <summary>
/// Creates the conversion value for a <see cref="HitObject"/>. A conversion value stores information about the converted <see cref="HitObject"/>.
@ -176,6 +184,32 @@ namespace osu.Game.Tests.Beatmaps
[JsonProperty]
public List<TConvertMapping> Mappings = new List<TConvertMapping>();
}
private class ConversionWorkingBeatmap : WorkingBeatmap
{
public Action<HitObject, IEnumerable<HitObject>, IBeatmapConverter> ConversionGenerated;
private readonly IBeatmap beatmap;
public ConversionWorkingBeatmap(IBeatmap beatmap)
: base(beatmap.BeatmapInfo, null)
{
this.beatmap = beatmap;
}
protected override IBeatmap GetBeatmap() => beatmap;
protected override Texture GetBackground() => throw new NotImplementedException();
protected override Track GetTrack() => throw new NotImplementedException();
protected override IBeatmapConverter CreateBeatmapConverter(IBeatmap beatmap, Ruleset ruleset)
{
var converter = base.CreateBeatmapConverter(beatmap, ruleset);
converter.ObjectConverted += (orig, converted) => ConversionGenerated?.Invoke(orig, converted, converter);
return converter;
}
}
}
public abstract class BeatmapConversionTest<TConvertValue> : BeatmapConversionTest<ConvertMapping<TConvertValue>, TConvertValue>

View File

@ -11,8 +11,8 @@
</ItemGroup>
<ItemGroup Label="Package References">
<PackageReference Include="Humanizer" Version="2.6.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="2.2.4" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite.Core" Version="2.2.4" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="2.2.6" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite.Core" Version="2.2.6" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.2" />
<PackageReference Include="ppy.osu.Game.Resources" Version="2019.702.0" />
<PackageReference Include="ppy.osu.Framework" Version="2019.730.0" />

View File

@ -14,8 +14,6 @@
<string>0.1.0</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>LSSupportsOpeningDocumentsInPlace</key>
<true/>
<key>MinimumOSVersion</key>
<string>10.0</string>
<key>UIDeviceFamily</key>