1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-12 19:42:55 +08:00

Change BeatmapAttributesDisplay retrieval to proper method

This commit is contained in:
Salman Ahmed 2024-02-23 16:59:08 +03:00
parent 918577d530
commit 323d7f8e2d
2 changed files with 33 additions and 39 deletions

View File

@ -130,13 +130,6 @@ namespace osu.Game.Overlays.Mods
private RankingInformationDisplay? rankingInformationDisplay;
private BeatmapAttributesDisplay? beatmapAttributesDisplay;
protected virtual BeatmapAttributesDisplay GetBeatmapAttributesDisplay => new BeatmapAttributesDisplay
{
Anchor = Anchor.BottomRight,
Origin = Anchor.BottomRight,
BeatmapInfo = { Value = Beatmap?.BeatmapInfo }
};
protected ShearedButton BackButton { get; private set; } = null!;
protected ShearedToggleButton? CustomisationButton { get; private set; }
protected SelectAllModsButton? SelectAllModsButton { get; set; }
@ -283,7 +276,12 @@ namespace osu.Game.Overlays.Mods
Anchor = Anchor.BottomRight,
Origin = Anchor.BottomRight
},
beatmapAttributesDisplay = GetBeatmapAttributesDisplay
beatmapAttributesDisplay = CreateBeatmapAttributesDisplay().With(b =>
{
b.Anchor = Anchor.BottomRight;
b.Origin = Anchor.BottomRight;
b.BeatmapInfo.Value = Beatmap?.BeatmapInfo;
}),
}
});
}
@ -293,6 +291,8 @@ namespace osu.Game.Overlays.Mods
textSearchStartsActive = configManager.GetBindable<bool>(OsuSetting.ModSelectTextSearchStartsActive);
}
protected virtual BeatmapAttributesDisplay CreateBeatmapAttributesDisplay() => new BeatmapAttributesDisplay();
public override void Hide()
{
base.Hide();

View File

@ -6,7 +6,6 @@ using System.Diagnostics;
using System.Linq;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Game.Online.Rooms;
using osu.Game.Overlays;
using osu.Game.Overlays.Mods;
@ -28,13 +27,6 @@ namespace osu.Game.Screens.OnlinePlay.Match
[Resolved]
private RulesetStore rulesets { get; set; } = null!;
protected override BeatmapAttributesDisplay GetBeatmapAttributesDisplay => new RoomBeatmapAttributesDisplay
{
Anchor = Anchor.BottomRight,
Origin = Anchor.BottomRight,
BeatmapInfo = { Value = Beatmap?.BeatmapInfo }
};
private readonly List<Mod> roomMods = new List<Mod>();
protected override void LoadComplete()
@ -57,37 +49,39 @@ namespace osu.Game.Screens.OnlinePlay.Match
}
protected override IEnumerable<Mod> AllSelectedMods => roomMods.Concat(base.AllSelectedMods);
}
public partial class RoomBeatmapAttributesDisplay : BeatmapAttributesDisplay
{
[Resolved(CanBeNull = true)]
private IBindable<PlaylistItem>? selectedItem { get; set; }
protected override BeatmapAttributesDisplay CreateBeatmapAttributesDisplay() => new RoomBeatmapAttributesDisplay();
[Resolved]
private RulesetStore rulesets { get; set; } = null!;
private readonly List<Mod> roomMods = new List<Mod>();
protected override void LoadComplete()
private partial class RoomBeatmapAttributesDisplay : BeatmapAttributesDisplay
{
base.LoadComplete();
[Resolved(CanBeNull = true)]
private IBindable<PlaylistItem>? selectedItem { get; set; }
selectedItem?.BindValueChanged(_ =>
[Resolved]
private RulesetStore rulesets { get; set; } = null!;
private readonly List<Mod> roomMods = new List<Mod>();
protected override void LoadComplete()
{
roomMods.Clear();
base.LoadComplete();
if (selectedItem?.Value != null)
selectedItem?.BindValueChanged(_ =>
{
var rulesetInstance = rulesets.GetRuleset(selectedItem.Value.RulesetID)?.CreateInstance();
Debug.Assert(rulesetInstance != null);
roomMods.AddRange(selectedItem.Value.RequiredMods.Select(m => m.ToMod(rulesetInstance)));
}
roomMods.Clear();
Mods.TriggerChange();
});
if (selectedItem?.Value != null)
{
var rulesetInstance = rulesets.GetRuleset(selectedItem.Value.RulesetID)?.CreateInstance();
Debug.Assert(rulesetInstance != null);
roomMods.AddRange(selectedItem.Value.RequiredMods.Select(m => m.ToMod(rulesetInstance)));
}
Mods.TriggerChange();
});
}
protected override IEnumerable<Mod> SelectedMods => roomMods.Concat(base.SelectedMods);
}
protected override IEnumerable<Mod> SelectedMods => roomMods.Concat(base.SelectedMods);
}
}