Merge pull request #472 from peppy/general-fixes

Update framework.
This commit is contained in:
Dean Herbert
2017-03-14 12:12:02 +09:00
committed by GitHub
4 changed files with 16 additions and 22 deletions

View File

@ -4,6 +4,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using osu.Framework.Extensions.IEnumerableExtensions;
using osu.Framework.Input; using osu.Framework.Input;
using osu.Framework.MathUtils; using osu.Framework.MathUtils;
using osu.Game.Input.Handlers; using osu.Game.Input.Handlers;
@ -95,24 +96,17 @@ namespace osu.Game.Modes
public override List<InputState> GetPendingStates() public override List<InputState> GetPendingStates()
{ {
var buttons = new HashSet<MouseButton>();
if (CurrentFrame?.MouseLeft ?? false)
buttons.Add(MouseButton.Left);
if (CurrentFrame?.MouseRight ?? false)
buttons.Add(MouseButton.Right);
return new List<InputState> return new List<InputState>
{ {
new InputState new InputState
{ {
Mouse = new ReplayMouseState( Mouse = new ReplayMouseState(ToScreenSpace(position ?? Vector2.Zero), buttons),
ToScreenSpace(position ?? Vector2.Zero),
new List<MouseState.ButtonState>
{
new MouseState.ButtonState(MouseButton.Left)
{
State = CurrentFrame?.MouseLeft ?? false
},
new MouseState.ButtonState(MouseButton.Right)
{
State = CurrentFrame?.MouseRight ?? false
},
}
),
Keyboard = new ReplayKeyboardState(new List<Key>()) Keyboard = new ReplayKeyboardState(new List<Key>())
} }
}; };
@ -171,10 +165,10 @@ namespace osu.Game.Modes
private class ReplayMouseState : MouseState private class ReplayMouseState : MouseState
{ {
public ReplayMouseState(Vector2 position, List<ButtonState> list) public ReplayMouseState(Vector2 position, IEnumerable<MouseButton> list)
{ {
Position = position; Position = position;
ButtonStates = list; list.ForEach(b => PressedButtons.Add(b));
} }
} }

View File

@ -70,14 +70,14 @@ namespace osu.Game.Screens.Play
{ {
if (mouseDisabled.Value) if (mouseDisabled.Value)
{ {
mouse.ButtonStates.Find(s => s.Button == MouseButton.Left).State = false; mouse.PressedButtons.Remove(MouseButton.Left);
mouse.ButtonStates.Find(s => s.Button == MouseButton.Right).State = false; mouse.PressedButtons.Remove(MouseButton.Right);
} }
if (leftViaKeyboard) if (leftViaKeyboard)
mouse.ButtonStates.Find(s => s.Button == MouseButton.Left).State = true; mouse.PressedButtons.Add(MouseButton.Left);
if (rightViaKeyboard) if (rightViaKeyboard)
mouse.ButtonStates.Find(s => s.Button == MouseButton.Right).State = true; mouse.PressedButtons.Add(MouseButton.Right);
} }
} }