Remove all usage of DI to retrieve InputManager

Uses GetContainingInputManager instead, as per framework changes.
This commit is contained in:
Dean Herbert 2017-08-15 14:30:50 +09:00
parent a74ebdfe56
commit 6ded194c53
6 changed files with 21 additions and 35 deletions

View File

@ -34,9 +34,8 @@ namespace osu.Game.Graphics.Containers
protected override Container<Drawable> Content => content;
[BackgroundDependencyLoader]
private void load(UserInputManager input, OsuConfigManager config)
private void load(OsuConfigManager config)
{
this.input = input;
parallaxEnabled = config.GetBindable<bool>(OsuSetting.MenuParallax);
parallaxEnabled.ValueChanged += delegate
{
@ -48,6 +47,12 @@ namespace osu.Game.Graphics.Containers
};
}
protected override void LoadComplete()
{
base.LoadComplete();
input = GetContainingInputManager();
}
private bool firstUpdate = true;
protected override void Update()

View File

@ -28,18 +28,10 @@ namespace osu.Game.Graphics.UserInterface
{
focus = value;
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)
{
base.OnFocus(state);

View File

@ -31,12 +31,10 @@ namespace osu.Game.Overlays.Music
private readonly Bindable<WorkingBeatmap> beatmapBacking = new Bindable<WorkingBeatmap>();
public IEnumerable<BeatmapSetInfo> BeatmapSets;
private InputManager inputManager;
[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;
Children = new Drawable[]
@ -102,7 +100,7 @@ namespace osu.Game.Overlays.Music
protected override void PopIn()
{
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.FadeIn(transition_duration, Easing.OutQuint);

View File

@ -57,12 +57,9 @@ namespace osu.Game.Overlays.Settings.Sections.General
Spacing = new Vector2(0f, 5f);
}
private InputManager inputManager;
[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;
api?.Register(this);
@ -174,7 +171,7 @@ namespace osu.Game.Overlays.Settings.Sections.General
break;
}
if (form != null) inputManager.ChangeFocus(form);
if (form != null) GetContainingInputManager().ChangeFocus(form);
}
public override bool AcceptsFocus => true;
@ -183,7 +180,7 @@ namespace osu.Game.Overlays.Settings.Sections.General
protected override void OnFocus(InputState state)
{
if (form != null) inputManager.ChangeFocus(form);
if (form != null) GetContainingInputManager().ChangeFocus(form);
base.OnFocus(state);
}
@ -192,7 +189,6 @@ namespace osu.Game.Overlays.Settings.Sections.General
private TextBox username;
private TextBox password;
private APIAccess api;
private InputManager inputManager;
private void performLogin()
{
@ -201,9 +197,8 @@ namespace osu.Game.Overlays.Settings.Sections.General
}
[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;
Direction = FillDirection.Vertical;
Spacing = new Vector2(0, 5);
@ -256,7 +251,7 @@ namespace osu.Game.Overlays.Settings.Sections.General
protected override void OnFocus(InputState state)
{
Schedule(() => { inputManager.ChangeFocus(string.IsNullOrEmpty(username.Text) ? username : password); });
Schedule(() => { GetContainingInputManager().ChangeFocus(string.IsNullOrEmpty(username.Text) ? username : password); });
}
}

View File

@ -153,7 +153,7 @@ namespace osu.Game.Screens.Select
{
searchTextBox.HoldFocus = false;
if (searchTextBox.HasFocus)
inputManager.ChangeFocus(searchTextBox);
GetContainingInputManager().ChangeFocus(searchTextBox);
}
public void Activate()
@ -163,13 +163,9 @@ namespace osu.Game.Screens.Select
private readonly Bindable<RulesetInfo> ruleset = new Bindable<RulesetInfo>();
private InputManager inputManager;
[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;
if (osu != null)

View File

@ -156,11 +156,11 @@ namespace osu.Game.Screens.Select
}
[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)
{
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);
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();
else
carousel.SelectNextRandom();