mirror of
https://github.com/osukey/osukey.git
synced 2025-08-08 00:53:56 +09:00
Remove redundant ControlItemText
class
This commit is contained in:
@ -10,7 +10,9 @@ using osu.Framework.Graphics;
|
|||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Framework.Graphics.Shapes;
|
using osu.Framework.Graphics.Shapes;
|
||||||
using osu.Framework.Input.Events;
|
using osu.Framework.Input.Events;
|
||||||
|
using osu.Game.Graphics;
|
||||||
using osu.Game.Graphics.Containers;
|
using osu.Game.Graphics.Containers;
|
||||||
|
using osu.Game.Graphics.Sprites;
|
||||||
using osu.Game.Online.Chat;
|
using osu.Game.Online.Chat;
|
||||||
|
|
||||||
namespace osu.Game.Overlays.Chat.ChannelControl
|
namespace osu.Game.Overlays.Chat.ChannelControl
|
||||||
@ -28,18 +30,22 @@ namespace osu.Game.Overlays.Chat.ChannelControl
|
|||||||
|
|
||||||
private Box? hoverBox;
|
private Box? hoverBox;
|
||||||
private Box? selectBox;
|
private Box? selectBox;
|
||||||
|
private OsuSpriteText? text;
|
||||||
private ControlItemClose? close;
|
private ControlItemClose? close;
|
||||||
|
|
||||||
[Resolved]
|
[Resolved]
|
||||||
private Bindable<Channel> selectedChannel { get; set; } = null!;
|
private Bindable<Channel> selectedChannel { get; set; } = null!;
|
||||||
|
|
||||||
|
[Resolved]
|
||||||
|
private OverlayColourProvider colourProvider { get; set; } = null!;
|
||||||
|
|
||||||
public ControlItem(Channel channel)
|
public ControlItem(Channel channel)
|
||||||
{
|
{
|
||||||
this.channel = channel;
|
this.channel = channel;
|
||||||
}
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(OverlayColourProvider colourProvider)
|
private void load()
|
||||||
{
|
{
|
||||||
Height = 30;
|
Height = 30;
|
||||||
RelativeSizeAxes = Axes.X;
|
RelativeSizeAxes = Axes.X;
|
||||||
@ -77,11 +83,16 @@ namespace osu.Game.Overlays.Chat.ChannelControl
|
|||||||
new[]
|
new[]
|
||||||
{
|
{
|
||||||
createIcon(),
|
createIcon(),
|
||||||
new ControlItemText(channel)
|
text = new OsuSpriteText
|
||||||
{
|
{
|
||||||
Anchor = Anchor.CentreLeft,
|
Anchor = Anchor.CentreLeft,
|
||||||
Origin = Anchor.CentreLeft,
|
Origin = Anchor.CentreLeft,
|
||||||
Unread = { BindTarget = Unread },
|
Text = channel.Type == ChannelType.Public ? $"# {channel.Name.Substring(1)}" : channel.Name,
|
||||||
|
Font = OsuFont.Torus.With(size: 17, weight: FontWeight.SemiBold),
|
||||||
|
Colour = colourProvider.Light3,
|
||||||
|
Margin = new MarginPadding { Bottom = 2 },
|
||||||
|
RelativeSizeAxes = Axes.X,
|
||||||
|
Truncate = true,
|
||||||
},
|
},
|
||||||
new ControlItemMention
|
new ControlItemMention
|
||||||
{
|
{
|
||||||
@ -117,6 +128,11 @@ namespace osu.Game.Overlays.Chat.ChannelControl
|
|||||||
else
|
else
|
||||||
selectBox?.Hide();
|
selectBox?.Hide();
|
||||||
}, true);
|
}, true);
|
||||||
|
|
||||||
|
Unread.BindValueChanged(change =>
|
||||||
|
{
|
||||||
|
text!.Colour = change.NewValue ? colourProvider.Content1 : colourProvider.Light3;
|
||||||
|
}, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override bool OnHover(HoverEvent e)
|
protected override bool OnHover(HoverEvent e)
|
||||||
|
@ -1,59 +0,0 @@
|
|||||||
// 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.
|
|
||||||
|
|
||||||
#nullable enable
|
|
||||||
|
|
||||||
using osu.Framework.Allocation;
|
|
||||||
using osu.Framework.Bindables;
|
|
||||||
using osu.Framework.Graphics;
|
|
||||||
using osu.Framework.Graphics.Containers;
|
|
||||||
using osu.Game.Graphics;
|
|
||||||
using osu.Game.Graphics.Sprites;
|
|
||||||
using osu.Game.Online.Chat;
|
|
||||||
|
|
||||||
namespace osu.Game.Overlays.Chat.ChannelControl
|
|
||||||
{
|
|
||||||
public class ControlItemText : Container
|
|
||||||
{
|
|
||||||
public readonly BindableBool Unread = new BindableBool();
|
|
||||||
|
|
||||||
private readonly Channel channel;
|
|
||||||
|
|
||||||
private OsuSpriteText? text;
|
|
||||||
|
|
||||||
[Resolved]
|
|
||||||
private OverlayColourProvider colourProvider { get; set; } = null!;
|
|
||||||
|
|
||||||
public ControlItemText(Channel channel)
|
|
||||||
{
|
|
||||||
this.channel = channel;
|
|
||||||
}
|
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
|
||||||
private void load()
|
|
||||||
{
|
|
||||||
RelativeSizeAxes = Axes.Both;
|
|
||||||
Child = text = new OsuSpriteText
|
|
||||||
{
|
|
||||||
Anchor = Anchor.CentreLeft,
|
|
||||||
Origin = Anchor.CentreLeft,
|
|
||||||
Text = channel.Type == ChannelType.Public ? $"# {channel.Name.Substring(1)}" : channel.Name,
|
|
||||||
Font = OsuFont.Torus.With(size: 17, weight: FontWeight.SemiBold),
|
|
||||||
Colour = colourProvider.Light3,
|
|
||||||
Margin = new MarginPadding { Bottom = 2 },
|
|
||||||
RelativeSizeAxes = Axes.X,
|
|
||||||
Truncate = true,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void LoadComplete()
|
|
||||||
{
|
|
||||||
base.LoadComplete();
|
|
||||||
|
|
||||||
Unread.BindValueChanged(change =>
|
|
||||||
{
|
|
||||||
text!.Colour = change.NewValue ? colourProvider.Content1 : colourProvider.Light3;
|
|
||||||
}, true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
Reference in New Issue
Block a user