mirror of
https://github.com/osukey/osukey.git
synced 2025-08-08 09:03:50 +09:00
Tidy up Player.cs.
This commit is contained in:
@ -13,7 +13,6 @@ using osu.Game.Database;
|
|||||||
using osu.Game.Modes;
|
using osu.Game.Modes;
|
||||||
using osu.Game.Modes.Objects;
|
using osu.Game.Modes.Objects;
|
||||||
using osu.Game.Modes.Objects.Drawables;
|
using osu.Game.Modes.Objects.Drawables;
|
||||||
using osu.Game.Modes.UI;
|
|
||||||
using osu.Game.Screens.Backgrounds;
|
using osu.Game.Screens.Backgrounds;
|
||||||
using OpenTK.Input;
|
using OpenTK.Input;
|
||||||
using MouseState = osu.Framework.Input.MouseState;
|
using MouseState = osu.Framework.Input.MouseState;
|
||||||
@ -30,45 +29,14 @@ namespace osu.Game.Screens.Play
|
|||||||
|
|
||||||
public BeatmapInfo BeatmapInfo;
|
public BeatmapInfo BeatmapInfo;
|
||||||
|
|
||||||
PlayerInputManager inputManager;
|
|
||||||
|
|
||||||
class PlayerInputManager : UserInputManager
|
|
||||||
{
|
|
||||||
public PlayerInputManager(BasicGameHost host)
|
|
||||||
: base(host)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void UpdateMouseState(InputState state)
|
|
||||||
{
|
|
||||||
base.UpdateMouseState(state);
|
|
||||||
|
|
||||||
MouseState mouse = (MouseState)state.Mouse;
|
|
||||||
|
|
||||||
foreach (Key k in state.Keyboard.Keys)
|
|
||||||
{
|
|
||||||
switch (k)
|
|
||||||
{
|
|
||||||
case Key.Z:
|
|
||||||
mouse.ButtonStates.Find(s => s.Button == MouseButton.Left).State = true;
|
|
||||||
break;
|
|
||||||
case Key.X:
|
|
||||||
mouse.ButtonStates.Find(s => s.Button == MouseButton.Right).State = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public PlayMode PreferredPlayMode;
|
public PlayMode PreferredPlayMode;
|
||||||
|
|
||||||
protected override IFrameBasedClock Clock => playerClock;
|
protected override IFrameBasedClock Clock => playerClock;
|
||||||
|
|
||||||
private InterpolatingFramedClock playerClock;
|
private InterpolatingFramedClock playerClock;
|
||||||
private IAdjustableClock sourceClock;
|
private IAdjustableClock sourceClock;
|
||||||
private Ruleset Ruleset;
|
|
||||||
|
private Ruleset ruleset;
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(AudioManager audio, BeatmapDatabase beatmaps, OsuGameBase game)
|
private void load(AudioManager audio, BeatmapDatabase beatmaps, OsuGameBase game)
|
||||||
@ -102,9 +70,6 @@ namespace osu.Game.Screens.Play
|
|||||||
sourceClock.Start();
|
sourceClock.Start();
|
||||||
});
|
});
|
||||||
|
|
||||||
HitRenderer hitRenderer;
|
|
||||||
ScoreOverlay scoreOverlay;
|
|
||||||
|
|
||||||
var beatmap = Beatmap.Beatmap;
|
var beatmap = Beatmap.Beatmap;
|
||||||
|
|
||||||
if (beatmap.BeatmapInfo?.Mode > PlayMode.Osu)
|
if (beatmap.BeatmapInfo?.Mode > PlayMode.Osu)
|
||||||
@ -116,11 +81,10 @@ namespace osu.Game.Screens.Play
|
|||||||
|
|
||||||
PlayMode usablePlayMode = beatmap.BeatmapInfo?.Mode > PlayMode.Osu ? beatmap.BeatmapInfo.Mode : PreferredPlayMode;
|
PlayMode usablePlayMode = beatmap.BeatmapInfo?.Mode > PlayMode.Osu ? beatmap.BeatmapInfo.Mode : PreferredPlayMode;
|
||||||
|
|
||||||
Ruleset = Ruleset.GetRuleset(usablePlayMode);
|
ruleset = Ruleset.GetRuleset(usablePlayMode);
|
||||||
|
|
||||||
scoreOverlay = Ruleset.CreateScoreOverlay();
|
var scoreOverlay = ruleset.CreateScoreOverlay();
|
||||||
|
var hitRenderer = ruleset.CreateHitRendererWith(beatmap.HitObjects);
|
||||||
hitRenderer = Ruleset.CreateHitRendererWith(beatmap.HitObjects);
|
|
||||||
|
|
||||||
hitRenderer.OnHit += delegate (HitObject h) { scoreOverlay.OnHit(h); };
|
hitRenderer.OnHit += delegate (HitObject h) { scoreOverlay.OnHit(h); };
|
||||||
hitRenderer.OnMiss += delegate (HitObject h) { scoreOverlay.OnMiss(h); };
|
hitRenderer.OnMiss += delegate (HitObject h) { scoreOverlay.OnMiss(h); };
|
||||||
@ -130,7 +94,7 @@ namespace osu.Game.Screens.Play
|
|||||||
|
|
||||||
Children = new Drawable[]
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
inputManager = new PlayerInputManager(game.Host)
|
new PlayerInputManager(game.Host)
|
||||||
{
|
{
|
||||||
PassThrough = false,
|
PassThrough = false,
|
||||||
Children = new Drawable[]
|
Children = new Drawable[]
|
||||||
@ -147,5 +111,34 @@ namespace osu.Game.Screens.Play
|
|||||||
base.Update();
|
base.Update();
|
||||||
playerClock.ProcessFrame();
|
playerClock.ProcessFrame();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class PlayerInputManager : UserInputManager
|
||||||
|
{
|
||||||
|
public PlayerInputManager(BasicGameHost host)
|
||||||
|
: base(host)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void UpdateMouseState(InputState state)
|
||||||
|
{
|
||||||
|
base.UpdateMouseState(state);
|
||||||
|
|
||||||
|
MouseState mouse = (MouseState)state.Mouse;
|
||||||
|
|
||||||
|
foreach (Key k in state.Keyboard.Keys)
|
||||||
|
{
|
||||||
|
switch (k)
|
||||||
|
{
|
||||||
|
case Key.Z:
|
||||||
|
mouse.ButtonStates.Find(s => s.Button == MouseButton.Left).State = true;
|
||||||
|
break;
|
||||||
|
case Key.X:
|
||||||
|
mouse.ButtonStates.Find(s => s.Button == MouseButton.Right).State = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user