1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-21 20:07:25 +08:00

Simplify ordering by using only numbers, add xmldoc

This commit is contained in:
voidedWarranties 2020-02-10 16:21:49 -08:00
parent ea521b466f
commit ca237fd987
4 changed files with 14 additions and 26 deletions

View File

@ -5,13 +5,12 @@ using osu.Framework.Bindables;
using osu.Game.Beatmaps;
using osu.Game.Configuration;
using osu.Game.Rulesets.Mods;
using static osu.Game.Configuration.SettingSourceAttribute;
namespace osu.Game.Rulesets.Catch.Mods
{
public class CatchModDifficultyAdjust : ModDifficultyAdjust
{
[SettingSource("Circle Size", "Override a beatmap's set CS.", OrderMode.FIRST)]
[SettingSource("Circle Size", "Override a beatmap's set CS.", 0)]
public BindableNumber<float> CircleSize { get; } = new BindableFloat
{
Precision = 0.1f,
@ -21,7 +20,7 @@ namespace osu.Game.Rulesets.Catch.Mods
Value = 5,
};
[SettingSource("Approach Rate", "Override a beatmap's set AR.", OrderMode.LAST)]
[SettingSource("Approach Rate", "Override a beatmap's set AR.", 3)]
public BindableNumber<float> ApproachRate { get; } = new BindableFloat
{
Precision = 0.1f,

View File

@ -5,13 +5,12 @@ using osu.Framework.Bindables;
using osu.Game.Beatmaps;
using osu.Game.Configuration;
using osu.Game.Rulesets.Mods;
using static osu.Game.Configuration.SettingSourceAttribute;
namespace osu.Game.Rulesets.Osu.Mods
{
public class OsuModDifficultyAdjust : ModDifficultyAdjust
{
[SettingSource("Circle Size", "Override a beatmap's set CS.", OrderMode.FIRST)]
[SettingSource("Circle Size", "Override a beatmap's set CS.", 0)]
public BindableNumber<float> CircleSize { get; } = new BindableFloat
{
Precision = 0.1f,
@ -21,7 +20,7 @@ namespace osu.Game.Rulesets.Osu.Mods
Value = 5,
};
[SettingSource("Approach Rate", "Override a beatmap's set AR.", OrderMode.LAST)]
[SettingSource("Approach Rate", "Override a beatmap's set AR.", 3)]
public BindableNumber<float> ApproachRate { get; } = new BindableFloat
{
Precision = 0.1f,

View File

@ -17,31 +17,24 @@ namespace osu.Game.Configuration
/// An attribute to mark a bindable as being exposed to the user via settings controls.
/// Can be used in conjunction with <see cref="SettingSourceExtensions.CreateSettingsControls"/> to automatically create UI controls.
/// </summary>
/// <remarks>
/// All controls with OrderPosition set to an int greater than 0 will be placed first in ascending order.
/// All controls with no OrderPosition will come afterward in default order.
/// </remarks>
[MeansImplicitUse]
[AttributeUsage(AttributeTargets.Property)]
public class SettingSourceAttribute : Attribute
{
public enum OrderMode
{
FIRST,
ORDERED_RELATIVE,
UNORDERED,
LAST
}
public string Label { get; }
public string Description { get; }
public OrderMode OrderingMode { get; }
public int OrderPosition { get; }
public SettingSourceAttribute(string label, string description = null, OrderMode order = OrderMode.UNORDERED, int orderPosition = 0)
public SettingSourceAttribute(string label, string description = null, int orderPosition = -1)
{
Label = label ?? string.Empty;
Description = description ?? string.Empty;
OrderingMode = order;
OrderPosition = orderPosition;
}
}
@ -136,12 +129,10 @@ namespace osu.Game.Configuration
{
var original = obj.GetSettingsSourceProperties();
var first = original.Where(attr => attr.Item1.OrderingMode == SettingSourceAttribute.OrderMode.FIRST);
var orderedRelative = original.Where(attr => attr.Item1.OrderingMode == SettingSourceAttribute.OrderMode.ORDERED_RELATIVE).OrderBy(attr => attr.Item1.OrderPosition);
var unordered = original.Where(attr => attr.Item1.OrderingMode == SettingSourceAttribute.OrderMode.UNORDERED);
var last = original.Where(attr => attr.Item1.OrderingMode == SettingSourceAttribute.OrderMode.LAST);
var orderedRelative = original.Where(attr => attr.Item1.OrderPosition > -1).OrderBy(attr => attr.Item1.OrderPosition);
var unordered = original.Except(orderedRelative);
return first.Concat(orderedRelative).Concat(unordered).Concat(last);
return orderedRelative.Concat(unordered);
}
}
}

View File

@ -7,7 +7,6 @@ using osu.Framework.Graphics.Sprites;
using System;
using System.Collections.Generic;
using osu.Game.Configuration;
using static osu.Game.Configuration.SettingSourceAttribute;
namespace osu.Game.Rulesets.Mods
{
@ -29,7 +28,7 @@ namespace osu.Game.Rulesets.Mods
public override Type[] IncompatibleMods => new[] { typeof(ModEasy), typeof(ModHardRock) };
[SettingSource("HP Drain", "Override a beatmap's set HP.", OrderMode.ORDERED_RELATIVE, 1)]
[SettingSource("HP Drain", "Override a beatmap's set HP.", 1)]
public BindableNumber<float> DrainRate { get; } = new BindableFloat
{
Precision = 0.1f,
@ -39,7 +38,7 @@ namespace osu.Game.Rulesets.Mods
Value = 5,
};
[SettingSource("Accuracy", "Override a beatmap's set OD.", OrderMode.ORDERED_RELATIVE, 1)]
[SettingSource("Accuracy", "Override a beatmap's set OD.", 2)]
public BindableNumber<float> OverallDifficulty { get; } = new BindableFloat
{
Precision = 0.1f,