1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-19 09:12:54 +08:00

Only create a new drawable object when the background is needed

This commit is contained in:
jkh675 2024-07-29 17:50:23 +08:00
parent 63757a77a5
commit 5ec46a79b4

View File

@ -21,7 +21,6 @@ using osu.Game.Graphics.Sprites;
using osu.Game.Online.API.Requests.Responses; using osu.Game.Online.API.Requests.Responses;
using osu.Game.Online.Chat; using osu.Game.Online.Chat;
using osuTK.Graphics; using osuTK.Graphics;
using Message = osu.Game.Online.Chat.Message;
namespace osu.Game.Overlays.Chat namespace osu.Game.Overlays.Chat
{ {
@ -118,6 +117,11 @@ namespace osu.Game.Overlays.Chat
InternalChild = new GridContainer InternalChild = new GridContainer
{ {
Margin = new MarginPadding
{
Horizontal = 10,
Vertical = 1,
},
RelativeSizeAxes = Axes.X, RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y, AutoSizeAxes = Axes.Y,
RowDimensions = new[] { new Dimension(GridSizeMode.AutoSize) }, RowDimensions = new[] { new Dimension(GridSizeMode.AutoSize) },
@ -275,17 +279,23 @@ namespace osu.Game.Overlays.Chat
private void updateBackground() private void updateBackground()
{ {
if (background == null) if (alteringBackground)
{ {
AddInternal(background = new Box if (background?.IsAlive != true)
{ {
BypassAutoSizeAxes = Axes.Both, AddInternal(background = new Circle
RelativeSizeAxes = Axes.Both, {
Colour = Color4.White, MaskingSmoothness = 2.5f,
}); Depth = float.MaxValue,
} RelativeSizeAxes = Axes.Both,
Colour = Color4.White,
});
}
background.Alpha = alteringBackground ? 0.04f : 0f; background.Alpha = 0.04f;
}
else
background?.Expire();
} }
} }
} }