修复mod本地化成员访问错误

This commit is contained in:
LA
2026-01-26 00:16:28 +08:00
parent 71bfa3def9
commit 6999de4645
13 changed files with 54 additions and 50 deletions

View File

@@ -9,6 +9,7 @@ using osu.Framework.Localisation;
using osu.Game.Audio;
using osu.Game.Beatmaps;
using osu.Game.Configuration;
using osu.Game.LAsEzExtensions.Mods;
using osu.Game.Overlays.Settings;
using osu.Game.Rulesets.Mania.Beatmaps;
using osu.Game.Rulesets.Mania.Objects;
@@ -29,7 +30,7 @@ namespace osu.Game.Rulesets.Mania.Mods.LAsMods
public override string Acronym => "SB";
public override double ScoreMultiplier => 1;
public override LocalisableString Description => EzManiaModStrings.SpaceBody_Description;
public override LocalisableString Description => EzModStrings.SpaceBody_Description;
public override ModType Type => ModType.LA_Mod;
@@ -38,7 +39,7 @@ namespace osu.Game.Rulesets.Mania.Mods.LAsMods
public override bool ValidForFreestyleAsRequiredMod => false;
public override Type[] IncompatibleMods => new[] { typeof(ManiaModHoldOff) };
[SettingSource(typeof(EzManiaModStrings), nameof(EzManiaModStrings.SpaceBody_Label), nameof(EzManiaModStrings.SpaceBodyGap_Description), SettingControlType = typeof(MultiplierSettingsSlider))]
[SettingSource(typeof(EzModStrings), nameof(EzModStrings.SpaceBody_Label), nameof(EzModStrings.SpaceBodyGap_Description), SettingControlType = typeof(MultiplierSettingsSlider))]
public BindableNumber<double> SpaceBeat { get; } = new BindableDouble(4)
{
MinValue = 1,
@@ -46,7 +47,7 @@ namespace osu.Game.Rulesets.Mania.Mods.LAsMods
Precision = 1
};
[SettingSource(typeof(EzManiaModStrings), nameof(EzManiaModStrings.AddShield_Label), nameof(EzManiaModStrings.AddShield_Description))]
[SettingSource(typeof(EzModStrings), nameof(EzModStrings.AddShield_Label), nameof(EzModStrings.AddShield_Description))]
public BindableBool Shield { get; } = new BindableBool();
[SettingSource(typeof(EzManiaModStrings), nameof(EzManiaModStrings.ApplyOrder_Label), nameof(EzManiaModStrings.ApplyOrder_Description), SettingControlType = typeof(SettingsNumberBox))]

View File

@@ -17,14 +17,12 @@ using osu.Game.Configuration;
using osu.Game.LAsEzExtensions.Mods;
using osu.Game.Overlays.Settings;
using osu.Game.Rulesets.Mania.Beatmaps;
using osu.Game.Rulesets.Mania.LAsEZMania;
using osu.Game.Rulesets.Mania.LAsEzMania.Mods;
using osu.Game.Rulesets.Mania.Objects;
using osu.Game.Rulesets.Mania.Objects.Drawables;
using osu.Game.Rulesets.Mania.Scoring;
using osu.Game.Rulesets.Mania.UI;
using osu.Game.Rulesets.Mods;
using osu.Game.Rulesets.Objects;
using osu.Game.Rulesets.Scoring;
using osu.Game.Rulesets.UI;
using osu.Game.Scoring;
@@ -63,7 +61,7 @@ namespace osu.Game.Rulesets.Mania.Mods.YuLiangSSSMods
public BindableDouble OriginalOD = new BindableDouble();
[SettingSource("Score Multiplier")]
[SettingSource(typeof(EzManiaModStrings), nameof(EzManiaModStrings.ScoreMultiplier_Label))]
public BindableNumber<double> ScoreMultiplierAdjust { get; } = new BindableDouble(1)
{
MinValue = 0,
@@ -83,8 +81,7 @@ namespace osu.Game.Rulesets.Mania.Mods.YuLiangSSSMods
ReadCurrentFromDifficulty = diff => diff.DrainRate
};
[SettingSource(typeof(EzManiaModStrings), nameof(EzManiaModStrings.AdjustAccuracy_Label), nameof(EzManiaModStrings.AdjustAccuracy_Description),
SettingControlType = typeof(DifficultyAdjustSettingsControl))]
[SettingSource(typeof(EzManiaModStrings), nameof(EzManiaModStrings.AdjustAccuracy_Label), nameof(EzManiaModStrings.AdjustAccuracy_Description), SettingControlType = typeof(DifficultyAdjustSettingsControl))]
public DifficultyBindable OverallDifficulty { get; } = new DifficultyBindable(0)
{
Precision = 0.1f,
@@ -102,13 +99,13 @@ namespace osu.Game.Rulesets.Mania.Mods.YuLiangSSSMods
Precision = 0.1
};
[SettingSource("Custom HP")]
[SettingSource(typeof(EzManiaModStrings), nameof(EzManiaModStrings.CustomHP_Label))]
public BindableBool CustomHP { get; } = new BindableBool(false);
[SettingSource("Custom OD")]
[SettingSource(typeof(EzManiaModStrings), nameof(EzManiaModStrings.CustomOD_Label))]
public BindableBool CustomOD { get; } = new BindableBool(true);
[SettingSource("Custom Release")]
[SettingSource(typeof(EzManiaModStrings), nameof(EzManiaModStrings.CustomRelease_Label))]
public BindableBool CustomRelease { get; } = new BindableBool();
[SettingSource(typeof(EzManiaModStrings), nameof(EzManiaModStrings.ExtendedLimits_Label), nameof(EzManiaModStrings.ExtendedLimits_Description))]
@@ -173,8 +170,7 @@ namespace osu.Game.Rulesets.Mania.Mods.YuLiangSSSMods
public override string ExtendedIconInformation => "";
[SettingSource(typeof(EzManiaModStrings), nameof(EzManiaModStrings.SpeedChange_Label), nameof(EzManiaModStrings.SpeedChange_Description),
SettingControlType = typeof(MultiplierSettingsSlider))]
[SettingSource(typeof(EzModStrings), nameof(EzModStrings.SpeedChange_Label), nameof(EzModStrings.SpeedChange_Description), SettingControlType = typeof(MultiplierSettingsSlider))]
public override BindableNumber<double> SpeedChange { get; } = new BindableDouble(1)
{
MinValue = 0.1,
@@ -182,7 +178,7 @@ namespace osu.Game.Rulesets.Mania.Mods.YuLiangSSSMods
Precision = 0.025
};
[SettingSource(typeof(EzManiaModStrings), nameof(EzManiaModStrings.AdjustPitch_Label), nameof(EzManiaModStrings.AdjustPitch_Description))]
[SettingSource(typeof(EzModStrings), nameof(EzModStrings.AdjustPitch_Label), nameof(EzModStrings.AdjustPitch_Description))]
public virtual BindableBool AdjustPitch { get; } = new BindableBool();
private readonly RateAdjustModHelper rateAdjustHelper;
@@ -275,7 +271,7 @@ namespace osu.Game.Rulesets.Mania.Mods.YuLiangSSSMods
}
}
[SettingSource(typeof(EzManiaModStrings), nameof(EzManiaModStrings.Mirror_Label), nameof(EzManiaModStrings.Mirror_Description))]
[SettingSource(typeof(EzModStrings), nameof(EzModStrings.Mirror_Label), nameof(EzModStrings.Mirror_Description))]
public BindableBool Mirror { get; } = new BindableBool();
[SettingSource(typeof(EzManiaModStrings), nameof(EzManiaModStrings.RandomMirror_Label), nameof(EzManiaModStrings.RandomMirror_Description))]
@@ -293,7 +289,7 @@ namespace osu.Game.Rulesets.Mania.Mods.YuLiangSSSMods
[SettingSource(typeof(EzManiaModStrings), nameof(EzManiaModStrings.TrueRandom_Label), nameof(EzManiaModStrings.TrueRandom_Description))]
public BindableBool TrueRandom { get; } = new BindableBool();
[SettingSource(typeof(EzManiaModStrings), nameof(EzManiaModStrings.Seed_Label), nameof(EzManiaModStrings.Seed_Description), SettingControlType = typeof(SettingsNumberBox))]
[SettingSource(typeof(EzModStrings), nameof(EzModStrings.Seed_Label), nameof(EzModStrings.Seed_Description), SettingControlType = typeof(SettingsNumberBox))]
public Bindable<int?> Seed { get; } = new Bindable<int?>();
public void ApplyToBeatmap(IBeatmap beatmap)

View File

@@ -71,7 +71,7 @@ namespace osu.Game.Rulesets.Mania.Mods.YuLiangSSSMods
Precision = 0.1,
};
[SettingSource(typeof(EzManiaModStrings), nameof(EzManiaModStrings.AdjustPitch_Label), nameof(EzManiaModStrings.AdjustPitch_Description))]
[SettingSource(typeof(EzModStrings), nameof(EzModStrings.AdjustPitch_Label), nameof(EzModStrings.AdjustPitch_Description))]
public virtual BindableBool AdjustPitch { get; } = new BindableBool();
public ManiaModChangeSpeedByAccuracy()

View File

@@ -79,7 +79,7 @@ namespace osu.Game.Rulesets.Mania.Mods.YuLiangSSSMods
Precision = 5
};
[SettingSource(typeof(EzManiaModStrings), nameof(EzManiaModStrings.Seed_Label), nameof(EzManiaModStrings.Seed_Description), SettingControlType = typeof(SettingsNumberBox))]
[SettingSource(typeof(EzModStrings), nameof(EzModStrings.Seed_Label), nameof(EzModStrings.Seed_Description), SettingControlType = typeof(SettingsNumberBox))]
public Bindable<int?> Seed { get; } = new Bindable<int?>();
public void ApplyToBeatmap(IBeatmap beatmap)

View File

@@ -74,7 +74,7 @@ namespace osu.Game.Rulesets.Mania.Mods.YuLiangSSSMods
[SettingSource(typeof(EzManiaModStrings), nameof(EzManiaModStrings.Alignment_Label), nameof(EzManiaModStrings.Alignment_Description))]
public BindableBool Align { get; set; } = new BindableBool(true);
[SettingSource(typeof(EzManiaModStrings), nameof(EzManiaModStrings.Seed_Label), nameof(EzManiaModStrings.Seed_Description), SettingControlType = typeof(SettingsNumberBox))]
[SettingSource(typeof(EzModStrings), nameof(EzModStrings.Seed_Label), nameof(EzModStrings.Seed_Description), SettingControlType = typeof(SettingsNumberBox))]
public Bindable<int?> Seed { get; } = new Bindable<int?>();
public void ApplyToBeatmap(IBeatmap beatmap)

View File

@@ -85,7 +85,7 @@ namespace osu.Game.Rulesets.Mania.Mods.YuLiangSSSMods
Precision = 0.5
};
[SettingSource(typeof(EzManiaModStrings), nameof(EzManiaModStrings.Seed_Label), nameof(EzManiaModStrings.Seed_Description), SettingControlType = typeof(SettingsNumberBox))]
[SettingSource(typeof(EzModStrings), nameof(EzModStrings.Seed_Label), nameof(EzModStrings.Seed_Description), SettingControlType = typeof(SettingsNumberBox))]
public Bindable<int?> Seed { get; } = new Bindable<int?>();
public override IEnumerable<(LocalisableString setting, LocalisableString value)> SettingDescription

View File

@@ -10,6 +10,7 @@ using osu.Framework.Localisation;
using osu.Framework.Utils;
using osu.Game.Beatmaps;
using osu.Game.Configuration;
using osu.Game.LAsEzExtensions.Mods;
using osu.Game.Overlays.Settings;
using osu.Game.Rulesets.Mania.Beatmaps;
using osu.Game.Rulesets.Mania.LAsEZMania;
@@ -171,7 +172,7 @@ namespace osu.Game.Rulesets.Mania.Mods.YuLiangSSSMods
[SettingSource(typeof(EzManiaModStrings), nameof(EzManiaModStrings.InvertLineSpacing_Label), nameof(EzManiaModStrings.InvertLineSpacing_Description))]
public BindableBool InvertLineSpacing { get; set; } = new BindableBool(false);
[SettingSource(typeof(EzManiaModStrings), nameof(EzManiaModStrings.Seed_Label), nameof(EzManiaModStrings.Seed_Description), SettingControlType = typeof(SettingsNumberBox))]
[SettingSource(typeof(EzModStrings), nameof(EzModStrings.Seed_Label), nameof(EzModStrings.Seed_Description), SettingControlType = typeof(SettingsNumberBox))]
public Bindable<int?> Seed { get; } = new Bindable<int?>();
public void ApplyToBeatmap(IBeatmap beatmap)

View File

@@ -74,7 +74,7 @@ namespace osu.Game.Rulesets.Mania.Mods.YuLiangSSSMods
transformColumnNum = keys;
}
var randomColumnSet = ManiaModHelper.SelectRandom(Enumerable.Range(0, keys), rng, transformColumnNum == 0 ? keys : transformColumnNum).ToHashSet();
var randomColumnSet = Enumerable.Range(0, keys).SelectRandom(rng, transformColumnNum == 0 ? keys : transformColumnNum).ToHashSet();
int gap = Gap.Value;
foreach (var timeGroup in oldObjects.GroupBy(x => x.StartTime))
@@ -100,7 +100,7 @@ namespace osu.Game.Rulesets.Mania.Mods.YuLiangSSSMods
if (gap <= 0)
{
randomColumnSet = ManiaModHelper.SelectRandom(Enumerable.Range(0, keys), rng, transformColumnNum).ToHashSet();
randomColumnSet = Enumerable.Range(0, keys).SelectRandom(rng, transformColumnNum).ToHashSet();
gap = Gap.Value;
}
}
@@ -256,27 +256,27 @@ namespace osu.Game.Rulesets.Mania.Mods.YuLiangSSSMods
}
}
double lastStartTime = locations[locations.Count - 1].startTime;
double lastEndTime = locations[locations.Count - 1].endTime;
double lastStartTime = locations[^1].startTime;
double lastEndTime = locations[^1].endTime;
if (OriginalLN.Value && lastStartTime != lastEndTime)
{
newColumnObjects.Add(new HoldNote
{
Column = column.Key,
StartTime = locations[locations.Count - 1].startTime,
EndTime = locations[locations.Count - 1].endTime,
NodeSamples = [locations[locations.Count - 1].samples, Array.Empty<HitSampleInfo>()]
StartTime = locations[^1].startTime,
EndTime = locations[^1].endTime,
NodeSamples = [locations[^1].samples, Array.Empty<HitSampleInfo>()]
});
originalLNObjects.AddNote(locations[locations.Count - 1].samples, column.Key, locations[locations.Count - 1].startTime, locations[locations.Count - 1].endTime);
originalLNObjects.AddNote(locations[^1].samples, column.Key, locations[^1].startTime, locations[^1].endTime);
}
else
{
newColumnObjects.Add(new Note
{
Column = column.Key,
StartTime = locations[locations.Count - 1].startTime,
Samples = locations[locations.Count - 1].samples
StartTime = locations[^1].startTime,
Samples = locations[^1].samples
});
}

View File

@@ -118,7 +118,7 @@ namespace osu.Game.Rulesets.Mania.Mods.YuLiangSSSMods
[SettingSource(typeof(EzManiaModStrings), nameof(EzManiaModStrings.IgnoreInterval_Label), nameof(EzManiaModStrings.IgnoreInterval_Description))]
public BindableBool IgnoreInterval { get; set; } = new BindableBool(false);
[SettingSource(typeof(EzManiaModStrings), nameof(EzManiaModStrings.Seed_Label), nameof(EzManiaModStrings.Seed_Description), SettingControlType = typeof(SettingsNumberBox))]
[SettingSource(typeof(EzModStrings), nameof(EzModStrings.Seed_Label), nameof(EzModStrings.Seed_Description), SettingControlType = typeof(SettingsNumberBox))]
public Bindable<int?> Seed { get; } = new Bindable<int?>();
// Column Number: 0 to n - 1

View File

@@ -66,7 +66,7 @@ namespace osu.Game.Rulesets.Mania.Mods.YuLiangSSSMods
Precision = 1
};
[SettingSource(typeof(EzManiaModStrings), nameof(EzManiaModStrings.Seed_Label), nameof(EzManiaModStrings.Seed_Description), SettingControlType = typeof(SettingsNumberBox))]
[SettingSource(typeof(EzModStrings), nameof(EzModStrings.Seed_Label), nameof(EzModStrings.Seed_Description), SettingControlType = typeof(SettingsNumberBox))]
public Bindable<int?> Seed { get; } = new Bindable<int?>();
[SettingSource(typeof(EzManiaModStrings), nameof(EzManiaModStrings.ApplyOrder_Label), nameof(EzManiaModStrings.ApplyOrder_Description), SettingControlType = typeof(SettingsNumberBox))]

View File

@@ -1,5 +1,8 @@
// Universal loop play clip mod that applies to arbitrary rulesets using best-effort cloning.
// 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 System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using osu.Game.Beatmaps;
@@ -9,7 +12,7 @@ using osu.Game.Rulesets.Objects;
namespace osu.Game.LAsEzExtensions.Mods
{
public class UniversalLoopPlayClip : ModLoopPlayClip,
IApplicableAfterBeatmapConversion
IApplicableAfterBeatmapConversion
{
public void ApplyToBeatmap(IBeatmap beatmap)
{
@@ -25,9 +28,10 @@ namespace osu.Game.LAsEzExtensions.Mods
try
{
var breaksProp = beatmap.GetType().GetProperty("Breaks");
if (breaksProp != null && breaksProp.CanWrite)
{
var breaks = breaksProp.GetValue(beatmap) as System.Collections.IList;
var breaks = breaksProp.GetValue(beatmap) as IList;
breaks?.Clear();
}
else
@@ -40,6 +44,7 @@ namespace osu.Game.LAsEzExtensions.Mods
}
double breakTime;
try
{
var timing = beatmap.ControlPointInfo.TimingPointAt(cutTimeStart);
@@ -55,7 +60,7 @@ namespace osu.Game.LAsEzExtensions.Mods
var newPart = new List<HitObject>();
var rng = seed.HasValue ? new Random((int)seed.Value) : new Random();
var rng = seed.HasValue ? new Random(seed.Value) : new Random();
double length = cutTimeEnd - cutTimeStart;
@@ -84,6 +89,7 @@ namespace osu.Game.LAsEzExtensions.Mods
// Samples
var samplesProp = type.GetProperty("Samples");
if (samplesProp != null && samplesProp.CanWrite)
{
try
@@ -123,10 +129,12 @@ namespace osu.Game.LAsEzExtensions.Mods
}
var propHitObjects = beatmap.GetType().GetProperty("HitObjects");
if (propHitObjects != null && propHitObjects.CanWrite)
{
// Ensure we assign a list whose element type matches the property's generic argument
var propType = propHitObjects.PropertyType;
if (propType.IsGenericType)
{
var elementType = propType.GetGenericArguments()[0];
@@ -140,13 +148,11 @@ namespace osu.Game.LAsEzExtensions.Mods
try
{
var listType = typeof(List<>).MakeGenericType(elementType);
var listInstance = (System.Collections.IList)Activator.CreateInstance(listType)!;
var listInstance = (IList)Activator.CreateInstance(listType)!;
foreach (var h in newPart)
{
if (h == null) continue;
if (elementType.IsAssignableFrom(h.GetType()))
if (elementType.IsInstanceOfType(h))
{
listInstance.Add(h);
continue;
@@ -155,8 +161,7 @@ namespace osu.Game.LAsEzExtensions.Mods
// Attempt best-effort conversion: create instance of elementType and copy common fields.
try
{
var target = Activator.CreateInstance(elementType) as HitObject;
if (target != null)
if (Activator.CreateInstance(elementType) is HitObject target)
{
var startProp = elementType.GetProperty("StartTime");
if (startProp != null && startProp.CanWrite)
@@ -165,6 +170,7 @@ namespace osu.Game.LAsEzExtensions.Mods
target.StartTime = h.StartTime;
var samplesProp = elementType.GetProperty("Samples");
if (samplesProp != null && samplesProp.CanWrite)
{
try { samplesProp.SetValue(target, h.Samples?.ToList()); }
@@ -176,7 +182,6 @@ namespace osu.Game.LAsEzExtensions.Mods
}
listInstance.Add(target);
continue;
}
}
catch
@@ -215,8 +220,7 @@ namespace osu.Game.LAsEzExtensions.Mods
{
try
{
var current = beatmap.HitObjects as IList<HitObject>;
if (current != null)
if (beatmap.HitObjects is IList<HitObject> current)
{
current.Clear();
foreach (var h in newPart) current.Add(h);

View File

@@ -288,7 +288,7 @@ namespace osu.Game.Screens.Utility
statusText.AddParagraph($"Input: {host.InputThread.Clock.FramesPerSecond} Hz "
+ $"Update: {host.UpdateThread.Clock.FramesPerSecond} Hz "
+ $"Draw: {host.DrawThread.Clock.FramesPerSecond} Hz"
, cp => cp.Font = OsuFont.Default.With(size: 15, weight: FontWeight.SemiBold));
, cp => cp.Font = OsuFont.Default.With(size: 15, weight: FontWeight.SemiBold));
if (isCertifying && isPass)
{

View File

@@ -7,11 +7,13 @@ using System;
using System.Linq;
using JetBrains.Annotations;
using osu.Framework.Audio;
using osu.Framework.Audio.EzLatency;
using osu.Framework.Audio.Sample;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Audio;
using osu.Framework.Graphics.Containers;
using osu.Framework.Logging;
using osu.Game.Audio;
namespace osu.Game.Skinning
@@ -128,12 +130,12 @@ namespace osu.Game.Skinning
// Framework-level latency instrumentation: best-effort playback event routing.
try
{
if (osu.Framework.Audio.EzLatency.EzLatencyManager.GLOBAL.Enabled.Value)
osu.Framework.Audio.EzLatency.EzLatencyManager.GLOBAL.RecordPlaybackEvent();
if (EzLatencyManager.GLOBAL.Enabled.Value)
EzLatencyManager.GLOBAL.RecordPlaybackEvent();
}
catch (Exception ex)
{
osu.Framework.Logging.Logger.Log($"PoolableSkinnableSample: failed to record playback event: {ex.Message}", osu.Framework.Logging.LoggingTarget.Runtime, osu.Framework.Logging.LogLevel.Debug);
Logger.Log($"PoolableSkinnableSample: failed to record playback event: {ex.Message}", LoggingTarget.Runtime, LogLevel.Debug);
}
Played = true;