mirror of
https://github.com/ppy/osu
synced 2025-02-15 01:27:03 +00:00
Remove all usage of DI to retrieve InputManager
Uses GetContainingInputManager instead, as per framework changes.
This commit is contained in:
parent
a74ebdfe56
commit
6ded194c53
@ -34,9 +34,8 @@ namespace osu.Game.Graphics.Containers
|
|||||||
protected override Container<Drawable> Content => content;
|
protected override Container<Drawable> Content => content;
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(UserInputManager input, OsuConfigManager config)
|
private void load(OsuConfigManager config)
|
||||||
{
|
{
|
||||||
this.input = input;
|
|
||||||
parallaxEnabled = config.GetBindable<bool>(OsuSetting.MenuParallax);
|
parallaxEnabled = config.GetBindable<bool>(OsuSetting.MenuParallax);
|
||||||
parallaxEnabled.ValueChanged += delegate
|
parallaxEnabled.ValueChanged += delegate
|
||||||
{
|
{
|
||||||
@ -48,6 +47,12 @@ namespace osu.Game.Graphics.Containers
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override void LoadComplete()
|
||||||
|
{
|
||||||
|
base.LoadComplete();
|
||||||
|
input = GetContainingInputManager();
|
||||||
|
}
|
||||||
|
|
||||||
private bool firstUpdate = true;
|
private bool firstUpdate = true;
|
||||||
|
|
||||||
protected override void Update()
|
protected override void Update()
|
||||||
|
@ -28,18 +28,10 @@ namespace osu.Game.Graphics.UserInterface
|
|||||||
{
|
{
|
||||||
focus = value;
|
focus = value;
|
||||||
if (!focus && HasFocus)
|
if (!focus && HasFocus)
|
||||||
inputManager.ChangeFocus(null);
|
GetContainingInputManager().ChangeFocus(null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private InputManager inputManager;
|
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
|
||||||
private void load(UserInputManager inputManager)
|
|
||||||
{
|
|
||||||
this.inputManager = inputManager;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void OnFocus(InputState state)
|
protected override void OnFocus(InputState state)
|
||||||
{
|
{
|
||||||
base.OnFocus(state);
|
base.OnFocus(state);
|
||||||
|
@ -31,12 +31,10 @@ namespace osu.Game.Overlays.Music
|
|||||||
private readonly Bindable<WorkingBeatmap> beatmapBacking = new Bindable<WorkingBeatmap>();
|
private readonly Bindable<WorkingBeatmap> beatmapBacking = new Bindable<WorkingBeatmap>();
|
||||||
|
|
||||||
public IEnumerable<BeatmapSetInfo> BeatmapSets;
|
public IEnumerable<BeatmapSetInfo> BeatmapSets;
|
||||||
private InputManager inputManager;
|
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(OsuGameBase game, BeatmapManager beatmaps, OsuColour colours, UserInputManager inputManager)
|
private void load(OsuGameBase game, BeatmapManager beatmaps, OsuColour colours)
|
||||||
{
|
{
|
||||||
this.inputManager = inputManager;
|
|
||||||
this.beatmaps = beatmaps;
|
this.beatmaps = beatmaps;
|
||||||
|
|
||||||
Children = new Drawable[]
|
Children = new Drawable[]
|
||||||
@ -102,7 +100,7 @@ namespace osu.Game.Overlays.Music
|
|||||||
protected override void PopIn()
|
protected override void PopIn()
|
||||||
{
|
{
|
||||||
filter.Search.HoldFocus = true;
|
filter.Search.HoldFocus = true;
|
||||||
Schedule(() => inputManager.ChangeFocus(filter.Search));
|
Schedule(() => GetContainingInputManager().ChangeFocus(filter.Search));
|
||||||
|
|
||||||
this.ResizeTo(new Vector2(1, playlist_height), transition_duration, Easing.OutQuint);
|
this.ResizeTo(new Vector2(1, playlist_height), transition_duration, Easing.OutQuint);
|
||||||
this.FadeIn(transition_duration, Easing.OutQuint);
|
this.FadeIn(transition_duration, Easing.OutQuint);
|
||||||
|
@ -57,12 +57,9 @@ namespace osu.Game.Overlays.Settings.Sections.General
|
|||||||
Spacing = new Vector2(0f, 5f);
|
Spacing = new Vector2(0f, 5f);
|
||||||
}
|
}
|
||||||
|
|
||||||
private InputManager inputManager;
|
|
||||||
|
|
||||||
[BackgroundDependencyLoader(permitNulls: true)]
|
[BackgroundDependencyLoader(permitNulls: true)]
|
||||||
private void load(OsuColour colours, APIAccess api, UserInputManager inputManager)
|
private void load(OsuColour colours, APIAccess api)
|
||||||
{
|
{
|
||||||
this.inputManager = inputManager;
|
|
||||||
this.colours = colours;
|
this.colours = colours;
|
||||||
|
|
||||||
api?.Register(this);
|
api?.Register(this);
|
||||||
@ -174,7 +171,7 @@ namespace osu.Game.Overlays.Settings.Sections.General
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (form != null) inputManager.ChangeFocus(form);
|
if (form != null) GetContainingInputManager().ChangeFocus(form);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool AcceptsFocus => true;
|
public override bool AcceptsFocus => true;
|
||||||
@ -183,7 +180,7 @@ namespace osu.Game.Overlays.Settings.Sections.General
|
|||||||
|
|
||||||
protected override void OnFocus(InputState state)
|
protected override void OnFocus(InputState state)
|
||||||
{
|
{
|
||||||
if (form != null) inputManager.ChangeFocus(form);
|
if (form != null) GetContainingInputManager().ChangeFocus(form);
|
||||||
base.OnFocus(state);
|
base.OnFocus(state);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -192,7 +189,6 @@ namespace osu.Game.Overlays.Settings.Sections.General
|
|||||||
private TextBox username;
|
private TextBox username;
|
||||||
private TextBox password;
|
private TextBox password;
|
||||||
private APIAccess api;
|
private APIAccess api;
|
||||||
private InputManager inputManager;
|
|
||||||
|
|
||||||
private void performLogin()
|
private void performLogin()
|
||||||
{
|
{
|
||||||
@ -201,9 +197,8 @@ namespace osu.Game.Overlays.Settings.Sections.General
|
|||||||
}
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader(permitNulls: true)]
|
[BackgroundDependencyLoader(permitNulls: true)]
|
||||||
private void load(APIAccess api, OsuConfigManager config, UserInputManager inputManager)
|
private void load(APIAccess api, OsuConfigManager config)
|
||||||
{
|
{
|
||||||
this.inputManager = inputManager;
|
|
||||||
this.api = api;
|
this.api = api;
|
||||||
Direction = FillDirection.Vertical;
|
Direction = FillDirection.Vertical;
|
||||||
Spacing = new Vector2(0, 5);
|
Spacing = new Vector2(0, 5);
|
||||||
@ -256,7 +251,7 @@ namespace osu.Game.Overlays.Settings.Sections.General
|
|||||||
|
|
||||||
protected override void OnFocus(InputState state)
|
protected override void OnFocus(InputState state)
|
||||||
{
|
{
|
||||||
Schedule(() => { inputManager.ChangeFocus(string.IsNullOrEmpty(username.Text) ? username : password); });
|
Schedule(() => { GetContainingInputManager().ChangeFocus(string.IsNullOrEmpty(username.Text) ? username : password); });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -153,7 +153,7 @@ namespace osu.Game.Screens.Select
|
|||||||
{
|
{
|
||||||
searchTextBox.HoldFocus = false;
|
searchTextBox.HoldFocus = false;
|
||||||
if (searchTextBox.HasFocus)
|
if (searchTextBox.HasFocus)
|
||||||
inputManager.ChangeFocus(searchTextBox);
|
GetContainingInputManager().ChangeFocus(searchTextBox);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Activate()
|
public void Activate()
|
||||||
@ -163,13 +163,9 @@ namespace osu.Game.Screens.Select
|
|||||||
|
|
||||||
private readonly Bindable<RulesetInfo> ruleset = new Bindable<RulesetInfo>();
|
private readonly Bindable<RulesetInfo> ruleset = new Bindable<RulesetInfo>();
|
||||||
|
|
||||||
private InputManager inputManager;
|
|
||||||
|
|
||||||
[BackgroundDependencyLoader(permitNulls: true)]
|
[BackgroundDependencyLoader(permitNulls: true)]
|
||||||
private void load(OsuColour colours, OsuGame osu, UserInputManager inputManager)
|
private void load(OsuColour colours, OsuGame osu)
|
||||||
{
|
{
|
||||||
this.inputManager = inputManager;
|
|
||||||
|
|
||||||
sortTabs.AccentColour = colours.GreenLight;
|
sortTabs.AccentColour = colours.GreenLight;
|
||||||
|
|
||||||
if (osu != null)
|
if (osu != null)
|
||||||
|
@ -156,11 +156,11 @@ namespace osu.Game.Screens.Select
|
|||||||
}
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader(permitNulls: true)]
|
[BackgroundDependencyLoader(permitNulls: true)]
|
||||||
private void load(BeatmapManager beatmaps, AudioManager audio, DialogOverlay dialog, OsuGame osu, OsuColour colours, UserInputManager input)
|
private void load(BeatmapManager beatmaps, AudioManager audio, DialogOverlay dialog, OsuGame osu, OsuColour colours)
|
||||||
{
|
{
|
||||||
if (Footer != null)
|
if (Footer != null)
|
||||||
{
|
{
|
||||||
Footer.AddButton(@"random", colours.Green, () => triggerRandom(input), Key.F2);
|
Footer.AddButton(@"random", colours.Green, triggerRandom, Key.F2);
|
||||||
Footer.AddButton(@"options", colours.Blue, BeatmapOptions.ToggleVisibility, Key.F3);
|
Footer.AddButton(@"options", colours.Blue, BeatmapOptions.ToggleVisibility, Key.F3);
|
||||||
|
|
||||||
BeatmapOptions.AddButton(@"Delete", @"Beatmap", FontAwesome.fa_trash, colours.Pink, promptDelete, Key.Number4, float.MaxValue);
|
BeatmapOptions.AddButton(@"Delete", @"Beatmap", FontAwesome.fa_trash, colours.Pink, promptDelete, Key.Number4, float.MaxValue);
|
||||||
@ -267,9 +267,9 @@ namespace osu.Game.Screens.Select
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void triggerRandom(UserInputManager input)
|
private void triggerRandom()
|
||||||
{
|
{
|
||||||
if (input.CurrentState.Keyboard.ShiftPressed)
|
if (GetContainingInputManager().CurrentState.Keyboard.ShiftPressed)
|
||||||
carousel.SelectPreviousRandom();
|
carousel.SelectPreviousRandom();
|
||||||
else
|
else
|
||||||
carousel.SelectNextRandom();
|
carousel.SelectNextRandom();
|
||||||
|
Loading…
Reference in New Issue
Block a user