mirror of
https://github.com/ppy/osu.git
synced 2024-09-22 04:47:24 +08:00
Initial implementation
Note this won't work with the osu!bgm because it is not a beatmap
This commit is contained in:
parent
793b760ff2
commit
4e83f12f34
@ -54,7 +54,8 @@ namespace osu.Game.Screens.Menu
|
||||
OnSolo = delegate { Push(consumeSongSelect()); },
|
||||
OnMulti = delegate { Push(new Lobby()); },
|
||||
OnExit = delegate { Exit(); },
|
||||
}
|
||||
},
|
||||
new MenuSideFlashes(),
|
||||
}
|
||||
}
|
||||
};
|
||||
|
95
osu.Game/Screens/Menu/MenuSideFlashes.cs
Normal file
95
osu.Game/Screens/Menu/MenuSideFlashes.cs
Normal file
@ -0,0 +1,95 @@
|
||||
using OpenTK.Graphics;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Configuration;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Colour;
|
||||
using osu.Game.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Beatmaps.Timing;
|
||||
using System;
|
||||
|
||||
namespace osu.Game.Screens.Menu
|
||||
{
|
||||
public class MenuSideFlashes : BeatSyncedContainer
|
||||
{
|
||||
public override bool HandleInput => false;
|
||||
|
||||
private Bindable<WorkingBeatmap> beatmap = new Bindable<WorkingBeatmap>();
|
||||
|
||||
private Box leftBox;
|
||||
private Box rightBox;
|
||||
|
||||
private const int amplitude_dead_zone = 9000;
|
||||
private const float alpha_multiplier = (short.MaxValue - amplitude_dead_zone) / 0.55f;
|
||||
private const int box_max_alpha = 200;
|
||||
private const double box_fade_in_time = 65;
|
||||
|
||||
public MenuSideFlashes()
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both;
|
||||
Anchor = Anchor.Centre;
|
||||
Origin = Anchor.Centre;
|
||||
BlendingMode = BlendingMode.Additive;
|
||||
Children = new Drawable[]
|
||||
{
|
||||
leftBox = new Box
|
||||
{
|
||||
Anchor = Anchor.CentreLeft,
|
||||
Origin = Anchor.CentreLeft,
|
||||
RelativeSizeAxes = Axes.Y,
|
||||
Width = 300,
|
||||
Alpha = 0,
|
||||
BlendingMode = BlendingMode.Additive,
|
||||
ColourInfo = ColourInfo.GradientHorizontal(new Color4(255, 255, 255, box_max_alpha), Color4.Transparent),
|
||||
},
|
||||
rightBox = new Box
|
||||
{
|
||||
Anchor = Anchor.CentreRight,
|
||||
Origin = Anchor.CentreRight,
|
||||
RelativeSizeAxes = Axes.Y,
|
||||
Width = 300,
|
||||
Alpha = 0,
|
||||
BlendingMode = BlendingMode.Additive,
|
||||
ColourInfo = ColourInfo.GradientHorizontal(Color4.Transparent, new Color4(255, 255, 255, box_max_alpha)),
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
protected override void OnNewBeat(int newBeat, double beatLength, TimeSignatures timeSignature, bool kiai)
|
||||
{
|
||||
if (!beatmap?.Value?.Track?.IsRunning ?? false)
|
||||
{
|
||||
leftBox.FadeOut(50);
|
||||
rightBox.FadeOut(50);
|
||||
}
|
||||
else if (newBeat >= 0)
|
||||
{
|
||||
short[] lev = beatmap.Value.Track.ChannelPeakAmplitudes;
|
||||
bool nextIsLeft = newBeat % 2 == 0;
|
||||
if (kiai ? nextIsLeft : newBeat % (int)timeSignature == 0)
|
||||
{
|
||||
leftBox.ClearTransforms();
|
||||
leftBox.FadeTo(Math.Max(0, (lev[0] - amplitude_dead_zone) / alpha_multiplier), 65);
|
||||
using (leftBox.BeginDelayedSequence(box_fade_in_time))
|
||||
leftBox.FadeOut(beatLength, EasingTypes.In);
|
||||
leftBox.DelayReset();
|
||||
}
|
||||
if (kiai ? !nextIsLeft : newBeat % (int)timeSignature == 0)
|
||||
{
|
||||
rightBox.ClearTransforms();
|
||||
rightBox.FadeTo(Math.Max(0, (lev[1] - amplitude_dead_zone) / alpha_multiplier), 65);
|
||||
using (rightBox.BeginDelayedSequence(box_fade_in_time))
|
||||
rightBox.FadeOut(beatLength, EasingTypes.In);
|
||||
rightBox.DelayReset();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuGameBase game)
|
||||
{
|
||||
beatmap = game.Beatmap;
|
||||
}
|
||||
}
|
||||
}
|
@ -183,6 +183,7 @@
|
||||
<Compile Include="Database\RulesetDatabase.cs" />
|
||||
<Compile Include="Rulesets\Scoring\Score.cs" />
|
||||
<Compile Include="Rulesets\Scoring\ScoreProcessor.cs" />
|
||||
<Compile Include="Screens\Menu\MenuSideFlashes.cs" />
|
||||
<Compile Include="Screens\Play\HUD\HealthDisplay.cs" />
|
||||
<Compile Include="Screens\Play\HUDOverlay.cs" />
|
||||
<Compile Include="Screens\Play\HUD\StandardHealthDisplay.cs" />
|
||||
|
Loading…
Reference in New Issue
Block a user