mirror of
https://github.com/ppy/osu.git
synced 2025-02-05 05:52:56 +08:00
Merge pull request #21145 from Joehuu/chat-timestamps-prefer-24hr
Make chat line timestamp adjust to 24-hour time setting
This commit is contained in:
commit
cb6b9898c1
@ -191,7 +191,6 @@ namespace osu.Game.Online.Chat
|
|||||||
{
|
{
|
||||||
protected override float TextSize => 15;
|
protected override float TextSize => 15;
|
||||||
protected override float Spacing => 5;
|
protected override float Spacing => 5;
|
||||||
protected override float TimestampWidth => 45;
|
|
||||||
protected override float UsernameWidth => 75;
|
protected override float UsernameWidth => 75;
|
||||||
|
|
||||||
public StandAloneMessage(Message message)
|
public StandAloneMessage(Message message)
|
||||||
|
@ -5,6 +5,7 @@ using System;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
|
using osu.Framework.Bindables;
|
||||||
using osu.Framework.Extensions.Color4Extensions;
|
using osu.Framework.Extensions.Color4Extensions;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
@ -12,6 +13,7 @@ using osu.Framework.Graphics.Cursor;
|
|||||||
using osu.Framework.Graphics.Effects;
|
using osu.Framework.Graphics.Effects;
|
||||||
using osu.Framework.Graphics.Shapes;
|
using osu.Framework.Graphics.Shapes;
|
||||||
using osu.Framework.Graphics.UserInterface;
|
using osu.Framework.Graphics.UserInterface;
|
||||||
|
using osu.Game.Configuration;
|
||||||
using osu.Game.Graphics;
|
using osu.Game.Graphics;
|
||||||
using osu.Game.Graphics.Containers;
|
using osu.Game.Graphics.Containers;
|
||||||
using osu.Game.Graphics.Sprites;
|
using osu.Game.Graphics.Sprites;
|
||||||
@ -48,8 +50,6 @@ namespace osu.Game.Overlays.Chat
|
|||||||
|
|
||||||
protected virtual float Spacing => 15;
|
protected virtual float Spacing => 15;
|
||||||
|
|
||||||
protected virtual float TimestampWidth => 60;
|
|
||||||
|
|
||||||
protected virtual float UsernameWidth => 130;
|
protected virtual float UsernameWidth => 130;
|
||||||
|
|
||||||
private Color4 usernameColour;
|
private Color4 usernameColour;
|
||||||
@ -62,6 +62,8 @@ namespace osu.Game.Overlays.Chat
|
|||||||
|
|
||||||
private Container? highlight;
|
private Container? highlight;
|
||||||
|
|
||||||
|
private readonly Bindable<bool> prefer24HourTime = new Bindable<bool>();
|
||||||
|
|
||||||
private bool senderHasColour => !string.IsNullOrEmpty(message.Sender.Colour);
|
private bool senderHasColour => !string.IsNullOrEmpty(message.Sender.Colour);
|
||||||
|
|
||||||
private bool messageHasColour => Message.IsAction && senderHasColour;
|
private bool messageHasColour => Message.IsAction && senderHasColour;
|
||||||
@ -80,7 +82,7 @@ namespace osu.Game.Overlays.Chat
|
|||||||
}
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(OverlayColourProvider? colourProvider)
|
private void load(OverlayColourProvider? colourProvider, OsuConfigManager configManager)
|
||||||
{
|
{
|
||||||
usernameColour = senderHasColour
|
usernameColour = senderHasColour
|
||||||
? Color4Extensions.FromHex(message.Sender.Colour)
|
? Color4Extensions.FromHex(message.Sender.Colour)
|
||||||
@ -93,18 +95,13 @@ namespace osu.Game.Overlays.Chat
|
|||||||
RowDimensions = new[] { new Dimension(GridSizeMode.AutoSize) },
|
RowDimensions = new[] { new Dimension(GridSizeMode.AutoSize) },
|
||||||
ColumnDimensions = new[]
|
ColumnDimensions = new[]
|
||||||
{
|
{
|
||||||
new Dimension(GridSizeMode.Absolute, TimestampWidth + Spacing + UsernameWidth + Spacing),
|
new Dimension(GridSizeMode.AutoSize),
|
||||||
|
new Dimension(GridSizeMode.Absolute, Spacing + UsernameWidth + Spacing),
|
||||||
new Dimension(),
|
new Dimension(),
|
||||||
},
|
},
|
||||||
Content = new[]
|
Content = new[]
|
||||||
{
|
{
|
||||||
new Drawable[]
|
new Drawable[]
|
||||||
{
|
|
||||||
new Container
|
|
||||||
{
|
|
||||||
RelativeSizeAxes = Axes.X,
|
|
||||||
AutoSizeAxes = Axes.Y,
|
|
||||||
Children = new Drawable[]
|
|
||||||
{
|
{
|
||||||
timestamp = new OsuSpriteText
|
timestamp = new OsuSpriteText
|
||||||
{
|
{
|
||||||
@ -112,8 +109,8 @@ namespace osu.Game.Overlays.Chat
|
|||||||
Anchor = Anchor.CentreLeft,
|
Anchor = Anchor.CentreLeft,
|
||||||
Origin = Anchor.CentreLeft,
|
Origin = Anchor.CentreLeft,
|
||||||
Font = OsuFont.GetFont(size: TextSize * 0.75f, weight: FontWeight.SemiBold, fixedWidth: true),
|
Font = OsuFont.GetFont(size: TextSize * 0.75f, weight: FontWeight.SemiBold, fixedWidth: true),
|
||||||
MaxWidth = TimestampWidth,
|
|
||||||
Colour = colourProvider?.Background1 ?? Colour4.White,
|
Colour = colourProvider?.Background1 ?? Colour4.White,
|
||||||
|
AlwaysPresent = true,
|
||||||
},
|
},
|
||||||
new MessageSender(message.Sender)
|
new MessageSender(message.Sender)
|
||||||
{
|
{
|
||||||
@ -124,8 +121,6 @@ namespace osu.Game.Overlays.Chat
|
|||||||
Child = createUsername(),
|
Child = createUsername(),
|
||||||
Margin = new MarginPadding { Horizontal = Spacing },
|
Margin = new MarginPadding { Horizontal = Spacing },
|
||||||
},
|
},
|
||||||
},
|
|
||||||
},
|
|
||||||
ContentFlow = new LinkFlowContainer(t =>
|
ContentFlow = new LinkFlowContainer(t =>
|
||||||
{
|
{
|
||||||
t.Shadow = false;
|
t.Shadow = false;
|
||||||
@ -139,6 +134,8 @@ namespace osu.Game.Overlays.Chat
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
configManager.BindWith(OsuSetting.Prefer24HourTime, prefer24HourTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void LoadComplete()
|
protected override void LoadComplete()
|
||||||
@ -147,6 +144,8 @@ namespace osu.Game.Overlays.Chat
|
|||||||
|
|
||||||
updateMessageContent();
|
updateMessageContent();
|
||||||
FinishTransforms(true);
|
FinishTransforms(true);
|
||||||
|
|
||||||
|
prefer24HourTime.BindValueChanged(_ => updateTimestamp());
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -176,7 +175,7 @@ namespace osu.Game.Overlays.Chat
|
|||||||
this.FadeTo(message is LocalEchoMessage ? 0.4f : 1.0f, 500, Easing.OutQuint);
|
this.FadeTo(message is LocalEchoMessage ? 0.4f : 1.0f, 500, Easing.OutQuint);
|
||||||
timestamp.FadeTo(message is LocalEchoMessage ? 0 : 1, 500, Easing.OutQuint);
|
timestamp.FadeTo(message is LocalEchoMessage ? 0 : 1, 500, Easing.OutQuint);
|
||||||
|
|
||||||
timestamp.Text = $@"{message.Timestamp.LocalDateTime:HH:mm:ss}";
|
updateTimestamp();
|
||||||
username.Text = $@"{message.Sender.Username}";
|
username.Text = $@"{message.Sender.Username}";
|
||||||
|
|
||||||
// remove non-existent channels from the link list
|
// remove non-existent channels from the link list
|
||||||
@ -186,6 +185,13 @@ namespace osu.Game.Overlays.Chat
|
|||||||
ContentFlow.AddLinks(message.DisplayContent, message.Links);
|
ContentFlow.AddLinks(message.DisplayContent, message.Links);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void updateTimestamp()
|
||||||
|
{
|
||||||
|
timestamp.Text = prefer24HourTime.Value
|
||||||
|
? $@"{message.Timestamp.LocalDateTime:HH:mm:ss}"
|
||||||
|
: $@"{message.Timestamp.LocalDateTime:hh:mm:ss tt}";
|
||||||
|
}
|
||||||
|
|
||||||
private Drawable createUsername()
|
private Drawable createUsername()
|
||||||
{
|
{
|
||||||
username = new OsuSpriteText
|
username = new OsuSpriteText
|
||||||
|
Loading…
Reference in New Issue
Block a user