1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-26 16:12:54 +08:00

Merge pull request #2948 from ekrctb/fix-disable-mouse

Fix "disable mouse buttons" not working
This commit is contained in:
Dean Herbert 2018-07-11 18:04:44 +09:00 committed by GitHub
commit a03db2e5fd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
20 changed files with 64 additions and 67 deletions

View File

@ -21,9 +21,9 @@ namespace osu.Game.Rulesets.Mania.Tests
this.direction = direction; this.direction = direction;
} }
protected override IReadOnlyDependencyContainer CreateLocalDependencies(IReadOnlyDependencyContainer parent) protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent)
{ {
var dependencies = new DependencyContainer(base.CreateLocalDependencies(parent)); var dependencies = new DependencyContainer(base.CreateChildDependencies(parent));
dependencies.CacheAs<IScrollingInfo>(new ScrollingInfo { Direction = { Value = direction }}); dependencies.CacheAs<IScrollingInfo>(new ScrollingInfo { Direction = { Value = direction }});
return dependencies; return dependencies;
} }

View File

@ -137,9 +137,9 @@ namespace osu.Game.Rulesets.Mania.Tests
}; };
} }
protected override IReadOnlyDependencyContainer CreateLocalDependencies(IReadOnlyDependencyContainer parent) protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent)
{ {
var dependencies = new DependencyContainer(base.CreateLocalDependencies(parent)); var dependencies = new DependencyContainer(base.CreateChildDependencies(parent));
dependencies.CacheAs<IBindable<ManiaAction>>(new Bindable<ManiaAction>()); dependencies.CacheAs<IBindable<ManiaAction>>(new Bindable<ManiaAction>());
return dependencies; return dependencies;
} }

View File

@ -19,14 +19,14 @@ namespace osu.Game.Rulesets.Mania
} }
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(ManiaConfigManager config) private void load()
{ {
Children = new Drawable[] Children = new Drawable[]
{ {
new SettingsEnumDropdown<ManiaScrollingDirection> new SettingsEnumDropdown<ManiaScrollingDirection>
{ {
LabelText = "Scrolling direction", LabelText = "Scrolling direction",
Bindable = config.GetBindable<ManiaScrollingDirection>(ManiaSetting.ScrollDirection) Bindable = ((ManiaConfigManager)Config).GetBindable<ManiaScrollingDirection>(ManiaSetting.ScrollDirection)
} }
}; };
} }

View File

@ -118,9 +118,9 @@ namespace osu.Game.Rulesets.Mania.UI
} }
} }
protected override IReadOnlyDependencyContainer CreateLocalDependencies(IReadOnlyDependencyContainer parent) protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent)
{ {
var dependencies = new DependencyContainer(base.CreateLocalDependencies(parent)); var dependencies = new DependencyContainer(base.CreateChildDependencies(parent));
dependencies.CacheAs<IBindable<ManiaAction>>(Action); dependencies.CacheAs<IBindable<ManiaAction>>(Action);
return dependencies; return dependencies;
} }

View File

@ -70,19 +70,19 @@ namespace osu.Game.Rulesets.Mania.UI
} }
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(ManiaConfigManager config) private void load()
{ {
BarLines.ForEach(Playfield.Add); BarLines.ForEach(Playfield.Add);
config.BindWith(ManiaSetting.ScrollDirection, configDirection); ((ManiaConfigManager)Config).BindWith(ManiaSetting.ScrollDirection, configDirection);
configDirection.BindValueChanged(d => scrollingInfo.Direction.Value = (ScrollingDirection)d, true); configDirection.BindValueChanged(d => scrollingInfo.Direction.Value = (ScrollingDirection)d, true);
} }
private DependencyContainer dependencies; private DependencyContainer dependencies;
protected override IReadOnlyDependencyContainer CreateLocalDependencies(IReadOnlyDependencyContainer parent) protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent)
{ {
dependencies = new DependencyContainer(base.CreateLocalDependencies(parent)); dependencies = new DependencyContainer(base.CreateChildDependencies(parent));
dependencies.CacheAs<IScrollingInfo>(scrollingInfo = new ScrollingInfo()); dependencies.CacheAs<IScrollingInfo>(scrollingInfo = new ScrollingInfo());
return dependencies; return dependencies;
} }

View File

@ -14,9 +14,9 @@ namespace osu.Game.Tests.Visual
{ {
private readonly PreviewTrackManager trackManager = new TestPreviewTrackManager(); private readonly PreviewTrackManager trackManager = new TestPreviewTrackManager();
protected override IReadOnlyDependencyContainer CreateLocalDependencies(IReadOnlyDependencyContainer parent) protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent)
{ {
var dependencies = new DependencyContainer(base.CreateLocalDependencies(parent)); var dependencies = new DependencyContainer(base.CreateChildDependencies(parent));
dependencies.CacheAs(trackManager); dependencies.CacheAs(trackManager);
dependencies.CacheAs<IPreviewTrackOwner>(this); dependencies.CacheAs<IPreviewTrackOwner>(this);
return dependencies; return dependencies;
@ -101,9 +101,9 @@ namespace osu.Game.Tests.Visual
AddInternal(track); AddInternal(track);
} }
protected override IReadOnlyDependencyContainer CreateLocalDependencies(IReadOnlyDependencyContainer parent) protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent)
{ {
var dependencies = new DependencyContainer(base.CreateLocalDependencies(parent)); var dependencies = new DependencyContainer(base.CreateChildDependencies(parent));
dependencies.CacheAs<IPreviewTrackOwner>(this); dependencies.CacheAs<IPreviewTrackOwner>(this);
return dependencies; return dependencies;
} }

View File

@ -26,9 +26,9 @@ namespace osu.Game.Graphics.Containers
protected readonly Bindable<OverlayActivation> OverlayActivationMode = new Bindable<OverlayActivation>(OverlayActivation.All); protected readonly Bindable<OverlayActivation> OverlayActivationMode = new Bindable<OverlayActivation>(OverlayActivation.All);
protected override IReadOnlyDependencyContainer CreateLocalDependencies(IReadOnlyDependencyContainer parent) protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent)
{ {
var dependencies = new DependencyContainer(base.CreateLocalDependencies(parent)); var dependencies = new DependencyContainer(base.CreateChildDependencies(parent));
dependencies.CacheAs<IPreviewTrackOwner>(this); dependencies.CacheAs<IPreviewTrackOwner>(this);
return dependencies; return dependencies;
} }

View File

@ -122,8 +122,8 @@ namespace osu.Game
private DependencyContainer dependencies; private DependencyContainer dependencies;
protected override IReadOnlyDependencyContainer CreateLocalDependencies(IReadOnlyDependencyContainer parent) => protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent) =>
dependencies = new DependencyContainer(base.CreateLocalDependencies(parent)); dependencies = new DependencyContainer(base.CreateChildDependencies(parent));
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(FrameworkConfigManager frameworkConfig) private void load(FrameworkConfigManager frameworkConfig)

View File

@ -95,8 +95,8 @@ namespace osu.Game
private DependencyContainer dependencies; private DependencyContainer dependencies;
protected override IReadOnlyDependencyContainer CreateLocalDependencies(IReadOnlyDependencyContainer parent) => protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent) =>
dependencies = new DependencyContainer(base.CreateLocalDependencies(parent)); dependencies = new DependencyContainer(base.CreateChildDependencies(parent));
private DatabaseContextFactory contextFactory; private DatabaseContextFactory contextFactory;

View File

@ -3,6 +3,7 @@
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Game.Rulesets; using osu.Game.Rulesets;
using osu.Game.Rulesets.Configuration;
namespace osu.Game.Overlays.Settings namespace osu.Game.Overlays.Settings
{ {
@ -14,6 +15,8 @@ namespace osu.Game.Overlays.Settings
{ {
private readonly Ruleset ruleset; private readonly Ruleset ruleset;
protected IRulesetConfigManager Config;
protected RulesetSettingsSubsection(Ruleset ruleset) protected RulesetSettingsSubsection(Ruleset ruleset)
{ {
this.ruleset = ruleset; this.ruleset = ruleset;
@ -21,13 +24,13 @@ namespace osu.Game.Overlays.Settings
private DependencyContainer dependencies; private DependencyContainer dependencies;
protected override IReadOnlyDependencyContainer CreateLocalDependencies(IReadOnlyDependencyContainer parent) protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent)
{ {
dependencies = new DependencyContainer(base.CreateLocalDependencies(parent)); dependencies = new DependencyContainer(base.CreateChildDependencies(parent));
var config = dependencies.Get<RulesetConfigCache>().GetConfigFor(ruleset); Config = dependencies.Get<RulesetConfigCache>().GetConfigFor(ruleset);
if (config != null) if (Config != null)
dependencies.Cache(config); dependencies.Cache(Config);
return dependencies; return dependencies;
} }

View File

@ -70,7 +70,8 @@ namespace osu.Game.Rulesets.UI
protected readonly Ruleset Ruleset; protected readonly Ruleset Ruleset;
private IRulesetConfigManager rulesetConfig; protected IRulesetConfigManager Config { get; private set; }
private OnScreenDisplay onScreenDisplay; private OnScreenDisplay onScreenDisplay;
/// <summary> /// <summary>
@ -85,17 +86,17 @@ namespace osu.Game.Rulesets.UI
Cursor = CreateCursor(); Cursor = CreateCursor();
} }
protected override IReadOnlyDependencyContainer CreateLocalDependencies(IReadOnlyDependencyContainer parent) protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent)
{ {
var dependencies = new DependencyContainer(base.CreateLocalDependencies(parent)); var dependencies = new DependencyContainer(base.CreateChildDependencies(parent));
onScreenDisplay = dependencies.Get<OnScreenDisplay>(); onScreenDisplay = dependencies.Get<OnScreenDisplay>();
rulesetConfig = dependencies.Get<RulesetConfigCache>().GetConfigFor(Ruleset); Config = dependencies.Get<RulesetConfigCache>().GetConfigFor(Ruleset);
if (rulesetConfig != null) if (Config != null)
{ {
dependencies.Cache(rulesetConfig); dependencies.Cache(Config);
onScreenDisplay?.BeginTracking(this, rulesetConfig); onScreenDisplay?.BeginTracking(this, Config);
} }
return dependencies; return dependencies;
@ -143,10 +144,10 @@ namespace osu.Game.Rulesets.UI
{ {
base.Dispose(isDisposing); base.Dispose(isDisposing);
if (rulesetConfig != null) if (Config != null)
{ {
onScreenDisplay?.StopTracking(this, rulesetConfig); onScreenDisplay?.StopTracking(this, Config);
rulesetConfig = null; Config = null;
} }
} }
} }

View File

@ -222,23 +222,16 @@ namespace osu.Game.Rulesets.UI
mouseDisabled = config.GetBindable<bool>(OsuSetting.MouseDisableButtons); mouseDisabled = config.GetBindable<bool>(OsuSetting.MouseDisableButtons);
} }
protected override void TransformState(InputState state) protected override bool OnMouseDown(InputState state, MouseDownEventArgs args)
{ {
base.TransformState(state); if (mouseDisabled.Value && (args.Button == MouseButton.Left || args.Button == MouseButton.Right)) return false;
return base.OnMouseDown(state, args);
}
// we don't want to transform the state if a replay is present (for now, at least). protected override bool OnMouseUp(InputState state, MouseUpEventArgs args)
if (replayInputHandler != null) return; {
if (!CurrentState.Mouse.IsPressed(args.Button)) return false;
var mouse = state.Mouse as Framework.Input.MouseState; return base.OnMouseUp(state, args);
if (mouse != null)
{
if (mouseDisabled.Value)
{
mouse.SetPressed(MouseButton.Left, false);
mouse.SetPressed(MouseButton.Right, false);
}
}
} }
#endregion #endregion

View File

@ -42,8 +42,8 @@ namespace osu.Game.Screens.Edit
private DependencyContainer dependencies; private DependencyContainer dependencies;
private GameHost host; private GameHost host;
protected override IReadOnlyDependencyContainer CreateLocalDependencies(IReadOnlyDependencyContainer parent) protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent)
=> dependencies = new DependencyContainer(base.CreateLocalDependencies(parent)); => dependencies = new DependencyContainer(base.CreateChildDependencies(parent));
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(OsuColour colours, GameHost host) private void load(OsuColour colours, GameHost host)

View File

@ -69,8 +69,8 @@ namespace osu.Game.Screens.Select
private DependencyContainer dependencies; private DependencyContainer dependencies;
protected override IReadOnlyDependencyContainer CreateLocalDependencies(IReadOnlyDependencyContainer parent) protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent)
=> dependencies = new DependencyContainer(base.CreateLocalDependencies(parent)); => dependencies = new DependencyContainer(base.CreateChildDependencies(parent));
protected SongSelect() protected SongSelect()
{ {

View File

@ -49,8 +49,8 @@ namespace osu.Game.Screens.Tournament
private DependencyContainer dependencies; private DependencyContainer dependencies;
protected override IReadOnlyDependencyContainer CreateLocalDependencies(IReadOnlyDependencyContainer parent) => protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent) =>
dependencies = new DependencyContainer(base.CreateLocalDependencies(parent)); dependencies = new DependencyContainer(base.CreateChildDependencies(parent));
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(TextureStore textures, Storage storage) private void load(TextureStore textures, Storage storage)

View File

@ -71,9 +71,9 @@ namespace osu.Game.Skinning
private void onSourceChanged() => SourceChanged?.Invoke(); private void onSourceChanged() => SourceChanged?.Invoke();
protected override IReadOnlyDependencyContainer CreateLocalDependencies(IReadOnlyDependencyContainer parent) protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent)
{ {
var dependencies = new DependencyContainer(base.CreateLocalDependencies(parent)); var dependencies = new DependencyContainer(base.CreateChildDependencies(parent));
fallbackSource = dependencies.Get<ISkinSource>(); fallbackSource = dependencies.Get<ISkinSource>();
dependencies.CacheAs<ISkinSource>(this); dependencies.CacheAs<ISkinSource>(this);

View File

@ -36,8 +36,8 @@ namespace osu.Game.Storyboards.Drawables
public override bool RemoveCompletedTransforms => false; public override bool RemoveCompletedTransforms => false;
private DependencyContainer dependencies; private DependencyContainer dependencies;
protected override IReadOnlyDependencyContainer CreateLocalDependencies(IReadOnlyDependencyContainer parent) => protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent) =>
dependencies = new DependencyContainer(base.CreateLocalDependencies(parent)); dependencies = new DependencyContainer(base.CreateChildDependencies(parent));
public DrawableStoryboard(Storyboard storyboard) public DrawableStoryboard(Storyboard storyboard)
{ {

View File

@ -25,9 +25,9 @@ namespace osu.Game.Tests.Visual
Clock = new EditorClock(new ControlPointInfo(), 5000, BeatDivisor) { IsCoupled = false }; Clock = new EditorClock(new ControlPointInfo(), 5000, BeatDivisor) { IsCoupled = false };
} }
protected override IReadOnlyDependencyContainer CreateLocalDependencies(IReadOnlyDependencyContainer parent) protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent)
{ {
var dependencies = new DependencyContainer(base.CreateLocalDependencies(parent)); var dependencies = new DependencyContainer(base.CreateChildDependencies(parent));
dependencies.Cache(BeatDivisor); dependencies.Cache(BeatDivisor);
dependencies.CacheAs<IFrameBasedClock>(Clock); dependencies.CacheAs<IFrameBasedClock>(Clock);

View File

@ -20,9 +20,9 @@ namespace osu.Game.Tests.Visual
protected DependencyContainer Dependencies { get; private set; } protected DependencyContainer Dependencies { get; private set; }
protected override IReadOnlyDependencyContainer CreateLocalDependencies(IReadOnlyDependencyContainer parent) protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent)
{ {
Dependencies = new DependencyContainer(base.CreateLocalDependencies(parent)); Dependencies = new DependencyContainer(base.CreateChildDependencies(parent));
Dependencies.CacheAs<BindableBeatmap>(beatmap); Dependencies.CacheAs<BindableBeatmap>(beatmap);
Dependencies.CacheAs<IBindableBeatmap>(beatmap); Dependencies.CacheAs<IBindableBeatmap>(beatmap);

View File

@ -18,7 +18,7 @@
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="2.1.1" /> <PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="2.1.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite.Core" Version="2.1.1" /> <PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite.Core" Version="2.1.1" />
<PackageReference Include="Newtonsoft.Json" Version="11.0.2" /> <PackageReference Include="Newtonsoft.Json" Version="11.0.2" />
<PackageReference Include="ppy.osu.Framework" Version="2018.710.0" /> <PackageReference Include="ppy.osu.Framework" Version="2018.711.0" />
<PackageReference Include="SharpCompress" Version="0.17.1" /> <PackageReference Include="SharpCompress" Version="0.17.1" />
<PackageReference Include="NUnit" Version="3.10.1" /> <PackageReference Include="NUnit" Version="3.10.1" />
<PackageReference Include="System.ComponentModel.Annotations" Version="4.5.0" /> <PackageReference Include="System.ComponentModel.Annotations" Version="4.5.0" />