mirror of
https://github.com/ppy/osu.git
synced 2025-02-19 13:12:54 +08:00
Merge pull request #5488 from hbnrmx/truncate-long-usernames-in-private-chat
Truncate long usernames in private chat tab
This commit is contained in:
commit
558845dc6d
@ -35,7 +35,7 @@ namespace osu.Game.Tests.Visual.Online
|
|||||||
private TestChatOverlay chatOverlay;
|
private TestChatOverlay chatOverlay;
|
||||||
private ChannelManager channelManager;
|
private ChannelManager channelManager;
|
||||||
|
|
||||||
private readonly Channel channel1 = new Channel(new User()) { Name = "test1" };
|
private readonly Channel channel1 = new Channel(new User()) { Name = "test really long username" };
|
||||||
private readonly Channel channel2 = new Channel(new User()) { Name = "test2" };
|
private readonly Channel channel2 = new Channel(new User()) { Name = "test2" };
|
||||||
|
|
||||||
[SetUp]
|
[SetUp]
|
||||||
|
@ -13,6 +13,8 @@ namespace osu.Game.Overlays.Chat.Tabs
|
|||||||
|
|
||||||
public override bool IsSwitchable => false;
|
public override bool IsSwitchable => false;
|
||||||
|
|
||||||
|
protected override bool IsBoldWhenActive => false;
|
||||||
|
|
||||||
public ChannelSelectorTabItem()
|
public ChannelSelectorTabItem()
|
||||||
: base(new ChannelSelectorTabChannel())
|
: base(new ChannelSelectorTabChannel())
|
||||||
{
|
{
|
||||||
@ -22,7 +24,7 @@ namespace osu.Game.Overlays.Chat.Tabs
|
|||||||
Icon.Alpha = 0;
|
Icon.Alpha = 0;
|
||||||
|
|
||||||
Text.Font = Text.Font.With(size: 45);
|
Text.Font = Text.Font.With(size: 45);
|
||||||
TextBold.Font = Text.Font.With(size: 45);
|
Text.Truncate = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
|
@ -29,7 +29,6 @@ namespace osu.Game.Overlays.Chat.Tabs
|
|||||||
public override bool IsRemovable => !Pinned;
|
public override bool IsRemovable => !Pinned;
|
||||||
|
|
||||||
protected readonly SpriteText Text;
|
protected readonly SpriteText Text;
|
||||||
protected readonly SpriteText TextBold;
|
|
||||||
protected readonly ClickableContainer CloseButton;
|
protected readonly ClickableContainer CloseButton;
|
||||||
private readonly Box box;
|
private readonly Box box;
|
||||||
private readonly Box highlightBox;
|
private readonly Box highlightBox;
|
||||||
@ -88,20 +87,17 @@ namespace osu.Game.Overlays.Chat.Tabs
|
|||||||
},
|
},
|
||||||
Text = new OsuSpriteText
|
Text = new OsuSpriteText
|
||||||
{
|
{
|
||||||
Margin = new MarginPadding(5),
|
|
||||||
Origin = Anchor.CentreLeft,
|
Origin = Anchor.CentreLeft,
|
||||||
Anchor = Anchor.CentreLeft,
|
Anchor = Anchor.CentreLeft,
|
||||||
Text = value.ToString(),
|
Text = value.ToString(),
|
||||||
Font = OsuFont.GetFont(size: 18)
|
Font = OsuFont.GetFont(size: 18),
|
||||||
},
|
Padding = new MarginPadding(5)
|
||||||
TextBold = new OsuSpriteText
|
{
|
||||||
{
|
Left = LeftTextPadding,
|
||||||
Alpha = 0,
|
Right = RightTextPadding,
|
||||||
Margin = new MarginPadding(5),
|
},
|
||||||
Origin = Anchor.CentreLeft,
|
RelativeSizeAxes = Axes.X,
|
||||||
Anchor = Anchor.CentreLeft,
|
Truncate = true,
|
||||||
Text = value.ToString(),
|
|
||||||
Font = OsuFont.GetFont(size: 18, weight: FontWeight.Bold)
|
|
||||||
},
|
},
|
||||||
CloseButton = new TabCloseButton
|
CloseButton = new TabCloseButton
|
||||||
{
|
{
|
||||||
@ -119,10 +115,16 @@ namespace osu.Game.Overlays.Chat.Tabs
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected virtual float LeftTextPadding => 5;
|
||||||
|
|
||||||
|
protected virtual float RightTextPadding => IsRemovable ? 40 : 5;
|
||||||
|
|
||||||
protected virtual IconUsage DisplayIcon => FontAwesome.Solid.Hashtag;
|
protected virtual IconUsage DisplayIcon => FontAwesome.Solid.Hashtag;
|
||||||
|
|
||||||
protected virtual bool ShowCloseOnHover => true;
|
protected virtual bool ShowCloseOnHover => true;
|
||||||
|
|
||||||
|
protected virtual bool IsBoldWhenActive => true;
|
||||||
|
|
||||||
protected override bool OnHover(HoverEvent e)
|
protected override bool OnHover(HoverEvent e)
|
||||||
{
|
{
|
||||||
if (IsRemovable && ShowCloseOnHover)
|
if (IsRemovable && ShowCloseOnHover)
|
||||||
@ -203,8 +205,7 @@ namespace osu.Game.Overlays.Chat.Tabs
|
|||||||
box.FadeColour(BackgroundActive, TRANSITION_LENGTH, Easing.OutQuint);
|
box.FadeColour(BackgroundActive, TRANSITION_LENGTH, Easing.OutQuint);
|
||||||
highlightBox.FadeIn(TRANSITION_LENGTH, Easing.OutQuint);
|
highlightBox.FadeIn(TRANSITION_LENGTH, Easing.OutQuint);
|
||||||
|
|
||||||
Text.FadeOut(TRANSITION_LENGTH, Easing.OutQuint);
|
if (IsBoldWhenActive) Text.Font = Text.Font.With(weight: FontWeight.Bold);
|
||||||
TextBold.FadeIn(TRANSITION_LENGTH, Easing.OutQuint);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected virtual void FadeInactive()
|
protected virtual void FadeInactive()
|
||||||
@ -216,8 +217,7 @@ namespace osu.Game.Overlays.Chat.Tabs
|
|||||||
box.FadeColour(BackgroundInactive, TRANSITION_LENGTH, Easing.OutQuint);
|
box.FadeColour(BackgroundInactive, TRANSITION_LENGTH, Easing.OutQuint);
|
||||||
highlightBox.FadeOut(TRANSITION_LENGTH, Easing.OutQuint);
|
highlightBox.FadeOut(TRANSITION_LENGTH, Easing.OutQuint);
|
||||||
|
|
||||||
Text.FadeIn(TRANSITION_LENGTH, Easing.OutQuint);
|
Text.Font = Text.Font.With(weight: FontWeight.Medium);
|
||||||
TextBold.FadeOut(TRANSITION_LENGTH, Easing.OutQuint);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnActivated() => updateState();
|
protected override void OnActivated() => updateState();
|
||||||
|
@ -62,11 +62,10 @@ namespace osu.Game.Overlays.Chat.Tabs
|
|||||||
});
|
});
|
||||||
|
|
||||||
avatar.OnLoadComplete += d => d.FadeInFromZero(300, Easing.OutQuint);
|
avatar.OnLoadComplete += d => d.FadeInFromZero(300, Easing.OutQuint);
|
||||||
|
|
||||||
Text.X = ChatOverlay.TAB_AREA_HEIGHT;
|
|
||||||
TextBold.X = ChatOverlay.TAB_AREA_HEIGHT;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override float LeftTextPadding => base.LeftTextPadding + ChatOverlay.TAB_AREA_HEIGHT;
|
||||||
|
|
||||||
protected override bool ShowCloseOnHover => false;
|
protected override bool ShowCloseOnHover => false;
|
||||||
|
|
||||||
protected override void FadeActive()
|
protected override void FadeActive()
|
||||||
|
Loading…
Reference in New Issue
Block a user