mirror of
https://github.com/ppy/osu.git
synced 2024-11-11 12:57:36 +08:00
Add forceful set helper methods in OsuGame
This commit is contained in:
parent
e4e1bde5da
commit
3cdeeb7ac5
@ -671,6 +671,32 @@ namespace osu.Game
|
||||
MenuCursorContainer.CanShowCursor = currentScreen?.CursorVisible ?? false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets <see cref="Beatmap"/> while ignoring any beatmap.
|
||||
/// </summary>
|
||||
/// <param name="beatmap">The beatmap to set.</param>
|
||||
public void ForcefullySetBeatmap(WorkingBeatmap beatmap)
|
||||
{
|
||||
var beatmapDisabled = Beatmap.Disabled;
|
||||
|
||||
Beatmap.Disabled = false;
|
||||
Beatmap.Value = beatmap;
|
||||
Beatmap.Disabled = beatmapDisabled;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets <see cref="Ruleset"/> while ignoring any ruleset restrictions.
|
||||
/// </summary>
|
||||
/// <param name="beatmap">The beatmap to set.</param>
|
||||
public void ForcefullySetRuleset(RulesetInfo ruleset)
|
||||
{
|
||||
var rulesetDisabled = this.ruleset.Disabled;
|
||||
|
||||
this.ruleset.Disabled = false;
|
||||
this.ruleset.Value = ruleset;
|
||||
this.ruleset.Disabled = rulesetDisabled;
|
||||
}
|
||||
|
||||
private void screenAdded(Screen newScreen)
|
||||
{
|
||||
currentScreen = (OsuScreen)newScreen;
|
||||
|
@ -54,6 +54,9 @@ namespace osu.Game.Screens.Multi.Match
|
||||
[Resolved]
|
||||
private APIAccess api { get; set; }
|
||||
|
||||
[Resolved]
|
||||
private OsuGame game { get; set; }
|
||||
|
||||
public MatchScreen(Room room, Action<Screen> pushGameplayScreen)
|
||||
{
|
||||
this.room = room;
|
||||
@ -167,18 +170,11 @@ namespace osu.Game.Screens.Multi.Match
|
||||
// Todo: item.Beatmap can be null here...
|
||||
var localBeatmap = beatmapManager.QueryBeatmap(b => b.OnlineBeatmapID == item.BeatmapID) ?? item.Beatmap;
|
||||
|
||||
// Bypass any beatmap and ruleset restrictions
|
||||
var beatmapDisabled = Beatmap.Disabled;
|
||||
var rulesetDisabled = Ruleset.Disabled;
|
||||
Beatmap.Disabled = false;
|
||||
Ruleset.Disabled = false;
|
||||
var newBeatmap = beatmapManager.GetWorkingBeatmap(localBeatmap);
|
||||
newBeatmap.Mods.Value = item.RequiredMods.ToArray();
|
||||
|
||||
Beatmap.Value = beatmapManager.GetWorkingBeatmap(localBeatmap);
|
||||
Beatmap.Value.Mods.Value = item.RequiredMods.ToArray();
|
||||
Ruleset.Value = item.Ruleset;
|
||||
|
||||
Beatmap.Disabled = beatmapDisabled;
|
||||
Ruleset.Disabled = rulesetDisabled;
|
||||
game.ForcefullySetBeatmap(newBeatmap);
|
||||
game.ForcefullySetRuleset(item.Ruleset);
|
||||
}
|
||||
|
||||
private void onStart()
|
||||
|
Loading…
Reference in New Issue
Block a user