mirror of
https://github.com/ppy/osu.git
synced 2024-11-14 15:57:24 +08:00
Merge pull request #23836 from frenzibyte/fix-aspect-ratio-crop-texture-stuff
Fix beatmap panel background looking different than usual
This commit is contained in:
commit
392287e9fb
@ -17,9 +17,8 @@ namespace osu.Game.Beatmaps
|
|||||||
// If issues are found it's worth checking to make sure similar issues exist there.
|
// If issues are found it's worth checking to make sure similar issues exist there.
|
||||||
public class BeatmapPanelBackgroundTextureLoaderStore : IResourceStore<TextureUpload>
|
public class BeatmapPanelBackgroundTextureLoaderStore : IResourceStore<TextureUpload>
|
||||||
{
|
{
|
||||||
// These numbers are taken from the draw visualiser size requirements for song select panel textures at extreme aspect ratios.
|
// The aspect ratio of SetPanelBackground at its maximum size (very tall window).
|
||||||
private const int max_height = 130;
|
private const float minimum_display_ratio = 512 / 80f;
|
||||||
private const int max_width = 1280;
|
|
||||||
|
|
||||||
private readonly IResourceStore<TextureUpload>? textureStore;
|
private readonly IResourceStore<TextureUpload>? textureStore;
|
||||||
|
|
||||||
@ -66,14 +65,21 @@ namespace osu.Game.Beatmaps
|
|||||||
textureUpload.Dispose();
|
textureUpload.Dispose();
|
||||||
|
|
||||||
Size size = image.Size();
|
Size size = image.Size();
|
||||||
int usableWidth = Math.Min(max_width, size.Width);
|
|
||||||
int usableHeight = Math.Min(max_height, size.Height);
|
// Assume that panel backgrounds are always displayed using `FillMode.Fill`.
|
||||||
|
// Also assume that all backgrounds are wider than they are tall, so the
|
||||||
|
// fill is always going to be based on width.
|
||||||
|
//
|
||||||
|
// We need to include enough height to make this work for all ratio panels are displayed at.
|
||||||
|
int usableHeight = (int)Math.Ceiling(size.Width * 1 / minimum_display_ratio);
|
||||||
|
|
||||||
|
usableHeight = Math.Min(size.Height, usableHeight);
|
||||||
|
|
||||||
// Crop the centre region of the background for now.
|
// Crop the centre region of the background for now.
|
||||||
Rectangle cropRectangle = new Rectangle(
|
Rectangle cropRectangle = new Rectangle(
|
||||||
(size.Width - usableWidth) / 2,
|
0,
|
||||||
(size.Height - usableHeight) / 2,
|
(size.Height - usableHeight) / 2,
|
||||||
usableWidth,
|
size.Width,
|
||||||
usableHeight
|
usableHeight
|
||||||
);
|
);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user