mirror of
https://github.com/ppy/osu.git
synced 2025-01-14 02:22:56 +08:00
Move BeatmapInfoOverlay into its own class.
No loading async optimizations yet.
This commit is contained in:
parent
9bf23bc4ad
commit
5cf5e8c80c
121
osu.Game/Screens/Select/BeatmapInfoOverlay.cs
Normal file
121
osu.Game/Screens/Select/BeatmapInfoOverlay.cs
Normal file
@ -0,0 +1,121 @@
|
||||
using OpenTK;
|
||||
using OpenTK.Graphics;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Primitives;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Database;
|
||||
using osu.Framework.Graphics.Colour;
|
||||
|
||||
namespace osu.Game.Screens.Select
|
||||
{
|
||||
class BeatmapInfoOverlay : Container
|
||||
{
|
||||
private Container beatmapInfoContainer;
|
||||
|
||||
public void UpdateBeatmap(WorkingBeatmap beatmap)
|
||||
{
|
||||
if (beatmap == null)
|
||||
return;
|
||||
|
||||
if (beatmapInfoContainer != null)
|
||||
{
|
||||
Drawable oldWedgedBeatmapInfo = beatmapInfoContainer;
|
||||
oldWedgedBeatmapInfo.Depth = 1;
|
||||
oldWedgedBeatmapInfo.FadeOut(250);
|
||||
oldWedgedBeatmapInfo.Expire();
|
||||
}
|
||||
|
||||
FadeIn(250);
|
||||
|
||||
BeatmapSetInfo beatmapSetInfo = beatmap.BeatmapSetInfo;
|
||||
BeatmapInfo beatmapInfo = beatmap.BeatmapInfo;
|
||||
Add(beatmapInfoContainer = new BufferedContainer
|
||||
{
|
||||
PixelSnapping = true,
|
||||
CacheDrawnFrameBuffer = true,
|
||||
Shear = -Shear,
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Children = new Drawable[]
|
||||
{
|
||||
// We will create the white-to-black gradient by modulating transparency and having
|
||||
// a black backdrop. This results in an sRGB-space gradient and not linear space,
|
||||
// transitioning from white to black more perceptually uniformly.
|
||||
new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Colour = Color4.Black,
|
||||
},
|
||||
// We use a container, such that we can set the colour gradient to go across the
|
||||
// vertices of the masked container instead of the vertices of the (larger) sprite.
|
||||
beatmap.Background == null ? new Container() : new Container
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
ColourInfo = ColourInfo.GradientVertical(Color4.White, new Color4(1f, 1f, 1f, 0.3f)),
|
||||
Children = new []
|
||||
{
|
||||
// Zoomed-in and cropped beatmap background
|
||||
new Sprite
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Texture = beatmap.Background,
|
||||
Scale = new Vector2(1366 / beatmap.Background.Width * 0.6f),
|
||||
},
|
||||
},
|
||||
},
|
||||
// Text for beatmap info
|
||||
new FlowContainer
|
||||
{
|
||||
Anchor = Anchor.BottomLeft,
|
||||
Origin = Anchor.BottomLeft,
|
||||
Direction = FlowDirection.VerticalOnly,
|
||||
Margin = new MarginPadding { Top = 10, Left = 25, Right = 10, Bottom = 40 },
|
||||
AutoSizeAxes = Axes.Both,
|
||||
Children = new[]
|
||||
{
|
||||
new SpriteText
|
||||
{
|
||||
Font = @"Exo2.0-MediumItalic",
|
||||
Text = beatmapSetInfo.Metadata.Artist + " -- " + beatmapSetInfo.Metadata.Title,
|
||||
TextSize = 28,
|
||||
Shadow = true,
|
||||
},
|
||||
new SpriteText
|
||||
{
|
||||
Font = @"Exo2.0-MediumItalic",
|
||||
Text = beatmapInfo.Version,
|
||||
TextSize = 17,
|
||||
Shadow = true,
|
||||
},
|
||||
new FlowContainer
|
||||
{
|
||||
Margin = new MarginPadding { Top = 10 },
|
||||
Direction = FlowDirection.HorizontalOnly,
|
||||
AutoSizeAxes = Axes.Both,
|
||||
Children = new []
|
||||
{
|
||||
new SpriteText
|
||||
{
|
||||
Font = @"Exo2.0-Medium",
|
||||
Text = "mapped by ",
|
||||
TextSize = 15,
|
||||
Shadow = true,
|
||||
},
|
||||
new SpriteText
|
||||
{
|
||||
Font = @"Exo2.0-Bold",
|
||||
Text = beatmapSetInfo.Metadata.Author,
|
||||
TextSize = 15,
|
||||
Shadow = true,
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
@ -22,7 +22,6 @@ using osu.Game.Modes;
|
||||
using osu.Game.Screens.Backgrounds;
|
||||
using OpenTK;
|
||||
using OpenTK.Graphics;
|
||||
using osu.Framework.Graphics.Colour;
|
||||
using osu.Game.Screens.Play;
|
||||
using osu.Framework;
|
||||
|
||||
@ -41,8 +40,7 @@ namespace osu.Game.Screens.Select
|
||||
private static readonly Vector2 wedged_container_size = new Vector2(700, 225);
|
||||
private static readonly Vector2 wedged_container_shear = new Vector2(0.15f, 0);
|
||||
private static readonly Vector2 wedged_container_start_position = new Vector2(0, 50);
|
||||
private Container wedgedContainer;
|
||||
private Container wedgedBeatmapInfo;
|
||||
private BeatmapInfoOverlay wedgedBeatmapInfoOverlay;
|
||||
|
||||
private static readonly Vector2 BACKGROUND_BLUR = new Vector2(20);
|
||||
private CancellationTokenSource initialAddSetsTask;
|
||||
@ -90,11 +88,12 @@ namespace osu.Game.Screens.Select
|
||||
Anchor = Anchor.CentreRight,
|
||||
Origin = Anchor.CentreRight,
|
||||
},
|
||||
wedgedContainer = new Container
|
||||
wedgedBeatmapInfoOverlay = new BeatmapInfoOverlay
|
||||
{
|
||||
Alpha = 0,
|
||||
Position = wedged_container_start_position,
|
||||
Size = wedged_container_size,
|
||||
Shear = wedged_container_shear,
|
||||
Margin = new MarginPadding { Top = 20, Right = 20, },
|
||||
Masking = true,
|
||||
BorderColour = new Color4(221, 255, 255, 255),
|
||||
@ -106,7 +105,6 @@ namespace osu.Game.Screens.Select
|
||||
Radius = 20,
|
||||
Roundness = 15,
|
||||
},
|
||||
Shear = wedged_container_shear,
|
||||
},
|
||||
new Container
|
||||
{
|
||||
@ -226,112 +224,7 @@ namespace osu.Game.Screens.Select
|
||||
(Background as BackgroundModeBeatmap)?.BlurTo(BACKGROUND_BLUR, 1000);
|
||||
}
|
||||
|
||||
//todo: move to own class and fix async logic (move every call on WorkingBeatmap.* to load() and use Preload to create it.
|
||||
refreshWedgedBeatmapInfo(beatmap);
|
||||
}
|
||||
|
||||
private void refreshWedgedBeatmapInfo(WorkingBeatmap beatmap)
|
||||
{
|
||||
if (beatmap == null)
|
||||
return;
|
||||
|
||||
if (wedgedBeatmapInfo != null)
|
||||
{
|
||||
Drawable oldWedgedBeatmapInfo = wedgedBeatmapInfo;
|
||||
oldWedgedBeatmapInfo.Depth = 1;
|
||||
oldWedgedBeatmapInfo.FadeOut(250);
|
||||
oldWedgedBeatmapInfo.Expire();
|
||||
}
|
||||
|
||||
wedgedContainer.FadeIn(250);
|
||||
|
||||
BeatmapSetInfo beatmapSetInfo = beatmap.BeatmapSetInfo;
|
||||
BeatmapInfo beatmapInfo = beatmap.BeatmapInfo;
|
||||
wedgedContainer.Add(wedgedBeatmapInfo = new BufferedContainer
|
||||
{
|
||||
PixelSnapping = true,
|
||||
CacheDrawnFrameBuffer = true,
|
||||
Shear = -wedged_container_shear,
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Children = new Drawable[]
|
||||
{
|
||||
// We will create the white-to-black gradient by modulating transparency and having
|
||||
// a black backdrop. This results in an sRGB-space gradient and not linear space,
|
||||
// transitioning from white to black more perceptually uniformly.
|
||||
new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Colour = Color4.Black,
|
||||
},
|
||||
// We use a container, such that we can set the colour gradient to go across the
|
||||
// vertices of the masked container instead of the vertices of the (larger) sprite.
|
||||
beatmap.Background == null ? new Container() : new Container
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
ColourInfo = ColourInfo.GradientVertical(Color4.White, new Color4(1f, 1f, 1f, 0.3f)),
|
||||
Children = new []
|
||||
{
|
||||
// Zoomed-in and cropped beatmap background
|
||||
new Sprite
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Texture = beatmap.Background,
|
||||
Scale = new Vector2(1366 / beatmap.Background.Width * 0.6f),
|
||||
},
|
||||
},
|
||||
},
|
||||
// Text for beatmap info
|
||||
new FlowContainer
|
||||
{
|
||||
Anchor = Anchor.BottomLeft,
|
||||
Origin = Anchor.BottomLeft,
|
||||
Direction = FlowDirection.VerticalOnly,
|
||||
Margin = new MarginPadding { Top = 10, Left = 25, Right = 10, Bottom = 40 },
|
||||
AutoSizeAxes = Axes.Both,
|
||||
Children = new[]
|
||||
{
|
||||
new SpriteText
|
||||
{
|
||||
Font = @"Exo2.0-MediumItalic",
|
||||
Text = beatmapSetInfo.Metadata.Artist + " -- " + beatmapSetInfo.Metadata.Title,
|
||||
TextSize = 28,
|
||||
Shadow = true,
|
||||
},
|
||||
new SpriteText
|
||||
{
|
||||
Font = @"Exo2.0-MediumItalic",
|
||||
Text = beatmapInfo.Version,
|
||||
TextSize = 17,
|
||||
Shadow = true,
|
||||
},
|
||||
new FlowContainer
|
||||
{
|
||||
Margin = new MarginPadding { Top = 10 },
|
||||
Direction = FlowDirection.HorizontalOnly,
|
||||
AutoSizeAxes = Axes.Both,
|
||||
Children = new []
|
||||
{
|
||||
new SpriteText
|
||||
{
|
||||
Font = @"Exo2.0-Medium",
|
||||
Text = "mapped by ",
|
||||
TextSize = 15,
|
||||
Shadow = true,
|
||||
},
|
||||
new SpriteText
|
||||
{
|
||||
Font = @"Exo2.0-Bold",
|
||||
Text = beatmapSetInfo.Metadata.Author,
|
||||
TextSize = 15,
|
||||
Shadow = true,
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
wedgedBeatmapInfoOverlay.UpdateBeatmap(beatmap);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -159,6 +159,7 @@
|
||||
<Compile Include="Overlays\ToolbarModeButton.cs" />
|
||||
<Compile Include="Overlays\ToolbarModeSelector.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Screens\Select\BeatmapInfoOverlay.cs" />
|
||||
<Compile Include="Users\User.cs" />
|
||||
<Compile Include="Graphics\UserInterface\Volume\VolumeControl.cs" />
|
||||
<Compile Include="Database\BeatmapDatabase.cs" />
|
||||
|
Loading…
Reference in New Issue
Block a user