Skip to content

Commit

Permalink
feat(demo): dedicated chat page
Browse files Browse the repository at this point in the history
  • Loading branch information
akiver committed May 16, 2022
1 parent 1e23ceb commit a8e4168
Show file tree
Hide file tree
Showing 49 changed files with 472 additions and 327 deletions.
1 change: 1 addition & 0 deletions Core/Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@
<Compile Include="AppSettings.cs" />
<Compile Include="Logger.cs" />
<Compile Include="Models\DemoBasicData.cs" />
<Compile Include="Models\Events\ChatMessage.cs" />
<Compile Include="Models\Language.cs" />
<Compile Include="Models\Map.cs" />
<Compile Include="Models\Maps\Agency.cs" />
Expand Down
21 changes: 11 additions & 10 deletions Core/Models/Demo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@ public class Demo : ObservableObject
/// <summary>
/// Contains text messages from game chat
/// </summary>
private List<string> _chatMessageList;
private List<ChatMessage> _chatMessages;

#endregion

Expand Down Expand Up @@ -539,7 +539,8 @@ public string Path
public int CheaterCount
{
get { return _cheaterCounter; }
set {
set
{
Set(() => CheaterCount, ref _cheaterCounter, value);
RaisePropertyChanged(() => HasCheater);
}
Expand Down Expand Up @@ -1045,10 +1046,10 @@ public decimal AverageEseaRws
}

[JsonProperty("chat_messages")]
public List<string> ChatMessageList
public List<ChatMessage> ChatMessages
{
get { return _chatMessageList; }
set { Set(() => ChatMessageList, ref _chatMessageList, value); }
get { return _chatMessages; }
set { Set(() => ChatMessages, ref _chatMessages, value); }
}

#endregion
Expand All @@ -1069,7 +1070,7 @@ public Demo()
BombDefused = new Collection<BombDefusedEvent>();
PlayerBlinded = new Collection<PlayerBlindedEvent>();
Overtimes = new Collection<Overtime>();
ChatMessageList = new List<string>();
ChatMessages = new List<ChatMessage>();

_teamCt = new Team
{
Expand Down Expand Up @@ -1172,7 +1173,7 @@ public Demo Copy()
BombPlanted = new Collection<BombPlantedEvent>(),
MolotovsFireStarted = new Collection<MolotovFireStartedEvent>(),
IncendiariesFireStarted = new Collection<MolotovFireStartedEvent>(),
ChatMessageList = new List<string>(),
ChatMessages = new List<ChatMessage>(),
PlayersHurted = new Collection<PlayerHurtedEvent>(),
Kills = new Collection<KillEvent>(),
PlayerBlinded = new Collection<PlayerBlindedEvent>(),
Expand Down Expand Up @@ -1206,9 +1207,9 @@ public Demo Copy()
demo.BombExploded.Add(e);
}

foreach (string msg in ChatMessageList)
foreach (ChatMessage msg in ChatMessages)
{
demo.ChatMessageList.Add(msg);
demo.ChatMessages.Add(msg);
}

foreach (DecoyStartedEvent e in DecoyStarted)
Expand Down Expand Up @@ -1464,7 +1465,7 @@ public void ResetStats(bool resetTeams = true)
BombDefused.Clear();
BombExploded.Clear();
BombPlanted.Clear();
ChatMessageList.Clear();
ChatMessages.Clear();
DecoyStarted.Clear();
IncendiariesFireStarted.Clear();
Kills.Clear();
Expand Down
30 changes: 30 additions & 0 deletions Core/Models/Events/ChatMessage.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
using Core.Models.Serialization;
using Newtonsoft.Json;

namespace Core.Models.Events
{
public class ChatMessage : BaseEvent
{
[JsonProperty("sender_steamid")]
[JsonConverter(typeof(LongToStringConverter))]
public long SenderSteamId { get; set; }

[JsonProperty("sender_name")]
public string SenderName { get; set; }

[JsonProperty("sender_side")]
public Side SenderSide { get; set; }

[JsonProperty("is_sender_alive")]
public bool IsSenderAlive { get; set; }

[JsonProperty("text")]
public string Text { get; set; }


public ChatMessage(int tick, float seconds)
: base(tick, seconds)
{
}
}
}
28 changes: 28 additions & 0 deletions Manager/Converters/SecondsToTimerConverter.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using System;
using System.Globalization;
using System.Windows.Data;

namespace Manager.Converters
{
public class SecondsToTimerConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
float totalSeconds = value as float? ?? 0;
double minutes = Math.Floor(totalSeconds / 60 % 60);
double seconds = Math.Floor(totalSeconds % 60);

return $"{FormatValue(minutes)}:{FormatValue(seconds)}";
}

public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
return value;
}

private static string FormatValue(double value)
{
return value.ToString(CultureInfo.InvariantCulture).PadLeft(2, '0');
}
}
}
9 changes: 8 additions & 1 deletion Manager/Internals/Navigation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public static void ShowPlayerDetails(Demo demo, Player player)
public static void ShowDemoHeatmap(Demo demo)
{
new ViewModelLocator().DemoHeatmap.Demo = demo;

ShowPage(new DemoHeatmapView());
}

Expand All @@ -76,6 +76,13 @@ public static void ShowDemoDamages(Demo demo)
ShowPage(new DemoDamagesView());
}

public static void ShowDemoChat(Demo demo)
{
new ViewModelLocator().DemoChat.Demo = demo;

ShowPage(new DemoChatView());
}

public static void ShowDemoFlashbangs(Demo demo)
{
new ViewModelLocator().DemoFlashbangs.Demo = demo;
Expand Down
9 changes: 9 additions & 0 deletions Manager/Manager.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@
<Compile Include="Converters\RankToImageConverter.cs" />
<Compile Include="Converters\RoundEndReasonToStringConverter.cs" />
<Compile Include="Converters\RoundTypeToStringConverter.cs" />
<Compile Include="Converters\SecondsToTimerConverter.cs" />
<Compile Include="Converters\SideToStringConverter.cs" />
<Compile Include="Converters\SteamAccountStatusToStringConverter.cs" />
<Compile Include="Converters\SteamAccountVisibilityToStringConverter.cs" />
Expand Down Expand Up @@ -231,6 +232,7 @@
<Compile Include="Services\Config.cs" />
<Compile Include="Services\IDialogService.cs" />
<Compile Include="ViewModel\Accounts\AccountViewModel.cs" />
<Compile Include="ViewModel\Demos\DemoChatViewModel.cs" />
<Compile Include="ViewModel\Demos\DemoFlashbangsViewModel.cs" />
<Compile Include="ViewModel\Demos\DemoMovieViewModel.cs" />
<Compile Include="ViewModel\Demos\DemoStuffsViewModel.cs" />
Expand All @@ -241,6 +243,9 @@
<Compile Include="ViewModel\Rounds\RoundDetailsViewModel.cs" />
<Compile Include="ViewModel\Shared\BaseViewModel.cs" />
<Compile Include="ViewModel\Suspects\WhitelistViewModel.cs" />
<Compile Include="Views\Demos\DemoChatView.xaml.cs">
<DependentUpon>DemoChatView.xaml</DependentUpon>
</Compile>
<Compile Include="Views\Demos\DemoFlashbangsView.xaml.cs">
<DependentUpon>DemoFlashbangsView.xaml</DependentUpon>
</Compile>
Expand Down Expand Up @@ -332,6 +337,10 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Views\Demos\DemoChatView.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Views\Demos\DemoFlashbangsView.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
Expand Down
16 changes: 8 additions & 8 deletions Manager/MultilingualResources/Manager.ar.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -3314,14 +3314,6 @@ Message Error :
<source>Export chat</source>
<target state="new">Export chat</target>
</trans-unit>
<trans-unit id="DialogChatFileCreated" translate="yes" xml:space="preserve">
<source>Chat messages file has been created.</source>
<target state="new">Chat messages file has been created.</target>
</trans-unit>
<trans-unit id="DialogNoChatFound" translate="yes" xml:space="preserve">
<source>No chat messages found. (It only works for demos coming from a server that has "tv_relaytextchat" set to a value different from "0" which is not the case for Valve matchmaking).</source>
<target state="new">No chat messages found. (It only works for demos coming from a server that has "tv_relaytextchat" set to a value different from "0" which is not the case for Valve matchmaking).</target>
</trans-unit>
<trans-unit id="NoHeatmapDataFound" translate="yes" xml:space="preserve">
<source>No {0} found for this selection.</source>
<target state="new">No {0} found for this selection.</target>
Expand Down Expand Up @@ -4223,6 +4215,14 @@ Please update it by clicking on the "Update" button.</target>
<source>KAST</source>
<target state="new">KAST</target>
</trans-unit>
<trans-unit id="Chat" translate="yes" xml:space="preserve">
<source>Chat</source>
<target state="new">Chat</target>
</trans-unit>
<trans-unit id="TooltipChat" translate="yes" xml:space="preserve">
<source>Chat</source>
<target state="new">Chat</target>
</trans-unit>
</group>
</body>
</file>
Expand Down
16 changes: 8 additions & 8 deletions Manager/MultilingualResources/Manager.da.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -3315,14 +3315,6 @@ Besked Fejl :
<source>Export chat</source>
<target state="new">Export chat</target>
</trans-unit>
<trans-unit id="DialogChatFileCreated" translate="yes" xml:space="preserve">
<source>Chat messages file has been created.</source>
<target state="new">Chat messages file has been created.</target>
</trans-unit>
<trans-unit id="DialogNoChatFound" translate="yes" xml:space="preserve">
<source>No chat messages found. (It only works for demos coming from a server that has "tv_relaytextchat" set to a value different from "0" which is not the case for Valve matchmaking).</source>
<target state="new">No chat messages found. (It only works for demos coming from a server that has "tv_relaytextchat" set to a value different from "0" which is not the case for Valve matchmaking).</target>
</trans-unit>
<trans-unit id="NoHeatmapDataFound" translate="yes" xml:space="preserve">
<source>No {0} found for this selection.</source>
<target state="new">No {0} found for this selection.</target>
Expand Down Expand Up @@ -4224,6 +4216,14 @@ Please update it by clicking on the "Update" button.</target>
<source>KAST</source>
<target state="new">KAST</target>
</trans-unit>
<trans-unit id="Chat" translate="yes" xml:space="preserve">
<source>Chat</source>
<target state="new">Chat</target>
</trans-unit>
<trans-unit id="TooltipChat" translate="yes" xml:space="preserve">
<source>Chat</source>
<target state="new">Chat</target>
</trans-unit>
</group>
</body>
</file>
Expand Down
16 changes: 8 additions & 8 deletions Manager/MultilingualResources/Manager.de.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -3315,14 +3315,6 @@ Message Error :
<source>Export chat</source>
<target state="final">Exportiere Chat</target>
</trans-unit>
<trans-unit id="DialogChatFileCreated" translate="yes" xml:space="preserve">
<source>Chat messages file has been created.</source>
<target state="final">Chat Message Datei wurde erstellt.</target>
</trans-unit>
<trans-unit id="DialogNoChatFound" translate="yes" xml:space="preserve">
<source>No chat messages found. (It only works for demos coming from a server that has "tv_relaytextchat" set to a value different from "0" which is not the case for Valve matchmaking).</source>
<target state="final">Keine Chatnachrichten gefunden. (Es funktioniert nur bei Demos, die auf einem Server aufgenommen wurden, mit "tv_relaytextchat" ungleich "0" - dies ist nicht der Fall bei Valve Matchmaking)</target>
</trans-unit>
<trans-unit id="NoHeatmapDataFound" translate="yes" xml:space="preserve">
<source>No {0} found for this selection.</source>
<target state="needs-review-translation">Nichts {0} gefunden bei dieser Auswahl.</target>
Expand Down Expand Up @@ -4224,6 +4216,14 @@ Bitte aktualisieren Sie mit dem Klicken auf den "Update"-Button.</target>
<source>KAST</source>
<target state="new">KAST</target>
</trans-unit>
<trans-unit id="Chat" translate="yes" xml:space="preserve">
<source>Chat</source>
<target state="new">Chat</target>
</trans-unit>
<trans-unit id="TooltipChat" translate="yes" xml:space="preserve">
<source>Chat</source>
<target state="new">Chat</target>
</trans-unit>
</group>
</body>
</file>
Expand Down
16 changes: 8 additions & 8 deletions Manager/MultilingualResources/Manager.es.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -3331,14 +3331,6 @@ Mensaje de error:
<source>Export chat</source>
<target state="translated">Exportar chat</target>
</trans-unit>
<trans-unit id="DialogChatFileCreated" translate="yes" xml:space="preserve">
<source>Chat messages file has been created.</source>
<target state="translated">El archivo de mensajes de chat ha sido creado.</target>
</trans-unit>
<trans-unit id="DialogNoChatFound" translate="yes" xml:space="preserve">
<source>No chat messages found. (It only works for demos coming from a server that has "tv_relaytextchat" set to a value different from "0" which is not the case for Valve matchmaking).</source>
<target state="translated">No se han encontrado mensajes de chat. (Solo funciona para repeticiones de un servidor que tenga "tv_relaytextchat" con un valor diferente de "0", no es el caso de los de Valve)</target>
</trans-unit>
<trans-unit id="NoHeatmapDataFound" translate="yes" xml:space="preserve">
<source>No {0} found for this selection.</source>
<target state="translated">No se ha encontrado {0} en esta selección.</target>
Expand Down Expand Up @@ -4241,6 +4233,14 @@ Please update it by clicking on the "Update" button.</target>
<source>KAST</source>
<target state="new">KAST</target>
</trans-unit>
<trans-unit id="Chat" translate="yes" xml:space="preserve">
<source>Chat</source>
<target state="new">Chat</target>
</trans-unit>
<trans-unit id="TooltipChat" translate="yes" xml:space="preserve">
<source>Chat</source>
<target state="new">Chat</target>
</trans-unit>
</group>
</body>
</file>
Expand Down
16 changes: 8 additions & 8 deletions Manager/MultilingualResources/Manager.fr.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -3317,14 +3317,6 @@ Message d'erreur :
<source>Export chat</source>
<target state="final">Exporter tchat</target>
</trans-unit>
<trans-unit id="DialogChatFileCreated" translate="yes" xml:space="preserve">
<source>Chat messages file has been created.</source>
<target state="final">Le fichier contenant les messages du tchat a été créé avec succès.</target>
</trans-unit>
<trans-unit id="DialogNoChatFound" translate="yes" xml:space="preserve">
<source>No chat messages found. (It only works for demos coming from a server that has "tv_relaytextchat" set to a value different from "0" which is not the case for Valve matchmaking).</source>
<target state="final">Aucun message de tchat trouvé. (L'export ne fonctionne que lorsque la démo provient d'un serveur ayant "tv_relaytextchat" différent de "0", ce qui n'est pas le cas des serveurs Valve matchmaking)</target>
</trans-unit>
<trans-unit id="NoHeatmapDataFound" translate="yes" xml:space="preserve">
<source>No {0} found for this selection.</source>
<target state="final">Pas de {0} pour cette selection.</target>
Expand Down Expand Up @@ -4230,6 +4222,14 @@ Il peut être pratique dans ce cas d'ajouter un commentaire pour noter les ticks
<source>KAST</source>
<target state="final">KAST</target>
</trans-unit>
<trans-unit id="Chat" translate="yes" xml:space="preserve">
<source>Chat</source>
<target state="final">Tchat</target>
</trans-unit>
<trans-unit id="TooltipChat" translate="yes" xml:space="preserve">
<source>Chat</source>
<target state="final">Tchat</target>
</trans-unit>
</group>
</body>
</file>
Expand Down
16 changes: 8 additions & 8 deletions Manager/MultilingualResources/Manager.hr.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -3314,14 +3314,6 @@ Message Error :
<source>Export chat</source>
<target state="new">Export chat</target>
</trans-unit>
<trans-unit id="DialogChatFileCreated" translate="yes" xml:space="preserve">
<source>Chat messages file has been created.</source>
<target state="new">Chat messages file has been created.</target>
</trans-unit>
<trans-unit id="DialogNoChatFound" translate="yes" xml:space="preserve">
<source>No chat messages found. (It only works for demos coming from a server that has "tv_relaytextchat" set to a value different from "0" which is not the case for Valve matchmaking).</source>
<target state="new">No chat messages found. (It only works for demos coming from a server that has "tv_relaytextchat" set to a value different from "0" which is not the case for Valve matchmaking).</target>
</trans-unit>
<trans-unit id="NoHeatmapDataFound" translate="yes" xml:space="preserve">
<source>No {0} found for this selection.</source>
<target state="new">No {0} found for this selection.</target>
Expand Down Expand Up @@ -4223,6 +4215,14 @@ Please update it by clicking on the "Update" button.</target>
<source>KAST</source>
<target state="new">KAST</target>
</trans-unit>
<trans-unit id="Chat" translate="yes" xml:space="preserve">
<source>Chat</source>
<target state="new">Chat</target>
</trans-unit>
<trans-unit id="TooltipChat" translate="yes" xml:space="preserve">
<source>Chat</source>
<target state="new">Chat</target>
</trans-unit>
</group>
</body>
</file>
Expand Down
Loading

0 comments on commit a8e4168

Please sign in to comment.