mirror of
https://github.com/ppy/osu.git
synced 2025-02-21 23:23:52 +08:00
Switch numerical consts to an enum
This commit is contained in:
parent
137181017b
commit
ea521b466f
@ -5,12 +5,13 @@ using osu.Framework.Bindables;
|
|||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
using osu.Game.Configuration;
|
using osu.Game.Configuration;
|
||||||
using osu.Game.Rulesets.Mods;
|
using osu.Game.Rulesets.Mods;
|
||||||
|
using static osu.Game.Configuration.SettingSourceAttribute;
|
||||||
|
|
||||||
namespace osu.Game.Rulesets.Catch.Mods
|
namespace osu.Game.Rulesets.Catch.Mods
|
||||||
{
|
{
|
||||||
public class CatchModDifficultyAdjust : ModDifficultyAdjust
|
public class CatchModDifficultyAdjust : ModDifficultyAdjust
|
||||||
{
|
{
|
||||||
[SettingSource("Circle Size", "Override a beatmap's set CS.", SettingSourceAttribute.FIRST)]
|
[SettingSource("Circle Size", "Override a beatmap's set CS.", OrderMode.FIRST)]
|
||||||
public BindableNumber<float> CircleSize { get; } = new BindableFloat
|
public BindableNumber<float> CircleSize { get; } = new BindableFloat
|
||||||
{
|
{
|
||||||
Precision = 0.1f,
|
Precision = 0.1f,
|
||||||
@ -20,7 +21,7 @@ namespace osu.Game.Rulesets.Catch.Mods
|
|||||||
Value = 5,
|
Value = 5,
|
||||||
};
|
};
|
||||||
|
|
||||||
[SettingSource("Approach Rate", "Override a beatmap's set AR.", SettingSourceAttribute.LAST)]
|
[SettingSource("Approach Rate", "Override a beatmap's set AR.", OrderMode.LAST)]
|
||||||
public BindableNumber<float> ApproachRate { get; } = new BindableFloat
|
public BindableNumber<float> ApproachRate { get; } = new BindableFloat
|
||||||
{
|
{
|
||||||
Precision = 0.1f,
|
Precision = 0.1f,
|
||||||
|
@ -5,12 +5,13 @@ using osu.Framework.Bindables;
|
|||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
using osu.Game.Configuration;
|
using osu.Game.Configuration;
|
||||||
using osu.Game.Rulesets.Mods;
|
using osu.Game.Rulesets.Mods;
|
||||||
|
using static osu.Game.Configuration.SettingSourceAttribute;
|
||||||
|
|
||||||
namespace osu.Game.Rulesets.Osu.Mods
|
namespace osu.Game.Rulesets.Osu.Mods
|
||||||
{
|
{
|
||||||
public class OsuModDifficultyAdjust : ModDifficultyAdjust
|
public class OsuModDifficultyAdjust : ModDifficultyAdjust
|
||||||
{
|
{
|
||||||
[SettingSource("Circle Size", "Override a beatmap's set CS.", SettingSourceAttribute.FIRST)]
|
[SettingSource("Circle Size", "Override a beatmap's set CS.", OrderMode.FIRST)]
|
||||||
public BindableNumber<float> CircleSize { get; } = new BindableFloat
|
public BindableNumber<float> CircleSize { get; } = new BindableFloat
|
||||||
{
|
{
|
||||||
Precision = 0.1f,
|
Precision = 0.1f,
|
||||||
@ -20,7 +21,7 @@ namespace osu.Game.Rulesets.Osu.Mods
|
|||||||
Value = 5,
|
Value = 5,
|
||||||
};
|
};
|
||||||
|
|
||||||
[SettingSource("Approach Rate", "Override a beatmap's set AR.", SettingSourceAttribute.LAST)]
|
[SettingSource("Approach Rate", "Override a beatmap's set AR.", OrderMode.LAST)]
|
||||||
public BindableNumber<float> ApproachRate { get; } = new BindableFloat
|
public BindableNumber<float> ApproachRate { get; } = new BindableFloat
|
||||||
{
|
{
|
||||||
Precision = 0.1f,
|
Precision = 0.1f,
|
||||||
|
@ -21,24 +21,27 @@ namespace osu.Game.Configuration
|
|||||||
[AttributeUsage(AttributeTargets.Property)]
|
[AttributeUsage(AttributeTargets.Property)]
|
||||||
public class SettingSourceAttribute : Attribute
|
public class SettingSourceAttribute : Attribute
|
||||||
{
|
{
|
||||||
public const int FIRST = 0;
|
public enum OrderMode
|
||||||
public const int ORDERED_RELATIVE = 1;
|
{
|
||||||
public const int UNORDERED = 2;
|
FIRST,
|
||||||
public const int LAST = 3;
|
ORDERED_RELATIVE,
|
||||||
|
UNORDERED,
|
||||||
|
LAST
|
||||||
|
}
|
||||||
|
|
||||||
public string Label { get; }
|
public string Label { get; }
|
||||||
|
|
||||||
public string Description { get; }
|
public string Description { get; }
|
||||||
|
|
||||||
public int OrderMode { get; }
|
public OrderMode OrderingMode { get; }
|
||||||
|
|
||||||
public int OrderPosition { get; }
|
public int OrderPosition { get; }
|
||||||
|
|
||||||
public SettingSourceAttribute(string label, string description = null, int order = UNORDERED, int orderPosition = 0)
|
public SettingSourceAttribute(string label, string description = null, OrderMode order = OrderMode.UNORDERED, int orderPosition = 0)
|
||||||
{
|
{
|
||||||
Label = label ?? string.Empty;
|
Label = label ?? string.Empty;
|
||||||
Description = description ?? string.Empty;
|
Description = description ?? string.Empty;
|
||||||
OrderMode = order;
|
OrderingMode = order;
|
||||||
OrderPosition = orderPosition;
|
OrderPosition = orderPosition;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -133,10 +136,10 @@ namespace osu.Game.Configuration
|
|||||||
{
|
{
|
||||||
var original = obj.GetSettingsSourceProperties();
|
var original = obj.GetSettingsSourceProperties();
|
||||||
|
|
||||||
var first = original.Where(attr => attr.Item1.OrderMode == SettingSourceAttribute.FIRST);
|
var first = original.Where(attr => attr.Item1.OrderingMode == SettingSourceAttribute.OrderMode.FIRST);
|
||||||
var orderedRelative = original.Where(attr => attr.Item1.OrderMode == SettingSourceAttribute.ORDERED_RELATIVE).OrderBy(attr => attr.Item1.OrderPosition);
|
var orderedRelative = original.Where(attr => attr.Item1.OrderingMode == SettingSourceAttribute.OrderMode.ORDERED_RELATIVE).OrderBy(attr => attr.Item1.OrderPosition);
|
||||||
var unordered = original.Where(attr => attr.Item1.OrderMode == SettingSourceAttribute.UNORDERED);
|
var unordered = original.Where(attr => attr.Item1.OrderingMode == SettingSourceAttribute.OrderMode.UNORDERED);
|
||||||
var last = original.Where(attr => attr.Item1.OrderMode == SettingSourceAttribute.LAST);
|
var last = original.Where(attr => attr.Item1.OrderingMode == SettingSourceAttribute.OrderMode.LAST);
|
||||||
|
|
||||||
return first.Concat(orderedRelative).Concat(unordered).Concat(last);
|
return first.Concat(orderedRelative).Concat(unordered).Concat(last);
|
||||||
}
|
}
|
||||||
|
@ -7,6 +7,7 @@ using osu.Framework.Graphics.Sprites;
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using osu.Game.Configuration;
|
using osu.Game.Configuration;
|
||||||
|
using static osu.Game.Configuration.SettingSourceAttribute;
|
||||||
|
|
||||||
namespace osu.Game.Rulesets.Mods
|
namespace osu.Game.Rulesets.Mods
|
||||||
{
|
{
|
||||||
@ -28,7 +29,7 @@ namespace osu.Game.Rulesets.Mods
|
|||||||
|
|
||||||
public override Type[] IncompatibleMods => new[] { typeof(ModEasy), typeof(ModHardRock) };
|
public override Type[] IncompatibleMods => new[] { typeof(ModEasy), typeof(ModHardRock) };
|
||||||
|
|
||||||
[SettingSource("HP Drain", "Override a beatmap's set HP.", SettingSourceAttribute.ORDERED_RELATIVE, 1)]
|
[SettingSource("HP Drain", "Override a beatmap's set HP.", OrderMode.ORDERED_RELATIVE, 1)]
|
||||||
public BindableNumber<float> DrainRate { get; } = new BindableFloat
|
public BindableNumber<float> DrainRate { get; } = new BindableFloat
|
||||||
{
|
{
|
||||||
Precision = 0.1f,
|
Precision = 0.1f,
|
||||||
@ -38,7 +39,7 @@ namespace osu.Game.Rulesets.Mods
|
|||||||
Value = 5,
|
Value = 5,
|
||||||
};
|
};
|
||||||
|
|
||||||
[SettingSource("Accuracy", "Override a beatmap's set OD.", SettingSourceAttribute.ORDERED_RELATIVE, 1)]
|
[SettingSource("Accuracy", "Override a beatmap's set OD.", OrderMode.ORDERED_RELATIVE, 1)]
|
||||||
public BindableNumber<float> OverallDifficulty { get; } = new BindableFloat
|
public BindableNumber<float> OverallDifficulty { get; } = new BindableFloat
|
||||||
{
|
{
|
||||||
Precision = 0.1f,
|
Precision = 0.1f,
|
||||||
|
Loading…
Reference in New Issue
Block a user