Skip to content

Commit

Permalink
Added alteration color to chat windows for better readability, replac…
Browse files Browse the repository at this point in the history
…e author and message separator with non-breakable space
  • Loading branch information
Arcidev committed Aug 16, 2024
1 parent 7e95a58 commit 74ad294
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Client.UI/ViewModels/MainGame/ChatMessageViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ public record ChatMessageViewModel(string Author, string Message, ChatMessageTyp
{
public string Text => Type switch
{
ChatMessageType.Message => $"{Author}> {Message}",
ChatMessageType.Message => $"{Author}>\u00A0{Message}",
_ => Message,
};
}
Expand Down
11 changes: 8 additions & 3 deletions Client.UI/Views/Game/Chat.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,20 +34,25 @@
<RowDefinition />
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<ItemsControl ItemsSource="{Binding Messages}">
<ItemsControl ItemsSource="{Binding Messages}" AlternationCount="2">
<ItemsControl.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding Text, Mode=OneWay}" TextWrapping="Wrap">
<TextBlock Text="{Binding Text, Mode=OneWay}" TextWrapping="Wrap" x:Name="MessageTextBlock">
<TextBlock.Style>
<Style TargetType="TextBlock">
<Style.Triggers>
<DataTrigger Binding="{Binding Type}" Value="{x:Static enums:ChatMessageType.System}">
<Setter Property="TextElement.Foreground" Value="OrangeRed"/>
<Setter Property="Foreground" Value="OrangeRed"/>
</DataTrigger>
</Style.Triggers>
</Style>
</TextBlock.Style>
</TextBlock>
<DataTemplate.Triggers>
<Trigger Property="ItemsControl.AlternationIndex" Value="1">
<Setter Property="Background" Value="#F1F1F1" TargetName="MessageTextBlock" />
</Trigger>
</DataTemplate.Triggers>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
Expand Down

0 comments on commit 74ad294

Please sign in to comment.