Apply NRT and simplify some remaining code

This commit is contained in:
Dean Herbert 2023-05-17 16:13:54 +09:00
parent e97d027230
commit 730bc3a961
5 changed files with 8 additions and 19 deletions

View File

@ -20,8 +20,7 @@ namespace osu.Game.Screens.OnlinePlay.Lounge.Components
private void onMatchTypeChanged(ValueChangedEvent<MatchType> type) private void onMatchTypeChanged(ValueChangedEvent<MatchType> type)
{ {
TextFlow.Clear(); TextFlow.Text = type.NewValue.GetLocalisableDescription();
TextFlow.AddText(type.NewValue.GetLocalisableDescription());
} }
} }
} }

View File

@ -1,8 +1,6 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. // Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text. // See the LICENCE file in the repository root for full licence text.
#nullable disable
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Game.Graphics; using osu.Game.Graphics;
@ -12,8 +10,8 @@ namespace osu.Game.Screens.OnlinePlay.Lounge.Components
{ {
public abstract partial class OnlinePlayPill : OnlinePlayComposite public abstract partial class OnlinePlayPill : OnlinePlayComposite
{ {
protected PillContainer Pill; protected PillContainer Pill { get; private set; } = null!;
protected OsuTextFlowContainer TextFlow; protected OsuTextFlowContainer TextFlow { get; private set; } = null!;
protected OnlinePlayPill() protected OnlinePlayPill()
{ {

View File

@ -20,8 +20,7 @@ namespace osu.Game.Screens.OnlinePlay.Lounge.Components
private void onQueueModeChanged(ValueChangedEvent<QueueMode> mode) private void onQueueModeChanged(ValueChangedEvent<QueueMode> mode)
{ {
TextFlow.Clear(); TextFlow.Text = mode.NewValue.GetLocalisableDescription();
TextFlow.AddText(mode.NewValue.GetLocalisableDescription());
} }
} }
} }

View File

@ -19,18 +19,13 @@ namespace osu.Game.Screens.OnlinePlay.Lounge.Components
{ {
base.LoadComplete(); base.LoadComplete();
Pill.Background.Colour = colours.Pink;
Pill.Background.Alpha = 1; Pill.Background.Alpha = 1;
TextFlow.Colour = Color4.Black; TextFlow.Colour = Color4.Black;
Category.BindValueChanged(c => Category.BindValueChanged(c =>
{ {
TextFlow.Clear(); TextFlow.Text = c.NewValue.GetLocalisableDescription();
TextFlow.AddText(c.NewValue.GetLocalisableDescription()); Pill.Background.Colour = colours.ForRoomCategory(c.NewValue) ?? colours.Pink;
var backgroundColour = colours.ForRoomCategory(Category.Value);
if (backgroundColour != null)
Pill.Background.Colour = backgroundColour.Value;
}, true); }, true);
} }
} }

View File

@ -30,17 +30,15 @@ namespace osu.Game.Screens.OnlinePlay.Lounge.Components
FinishTransforms(true); FinishTransforms(true);
TextFlow.Colour = Colour4.Black; TextFlow.Colour = Colour4.Black;
Pill.Background.Alpha = 1;
} }
private void updateDisplay() private void updateDisplay()
{ {
RoomStatus status = getDisplayStatus(); RoomStatus status = getDisplayStatus();
Pill.Background.Alpha = 1;
Pill.Background.FadeColour(status.GetAppropriateColour(colours), 100); Pill.Background.FadeColour(status.GetAppropriateColour(colours), 100);
TextFlow.Text = status.Message;
TextFlow.Clear();
TextFlow.AddText(status.Message);
} }
private RoomStatus getDisplayStatus() private RoomStatus getDisplayStatus()