-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathApp.ChatQueue.cs
More file actions
69 lines (57 loc) · 1.45 KB
/
Copy pathApp.ChatQueue.cs
File metadata and controls
69 lines (57 loc) · 1.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
using System.Text.RegularExpressions;
using System.Windows;
using IRSDKSharper;
namespace MarvinsAIRA
{
public partial class App : Application
{
private readonly List<string> _chatQueue_messageList = [];
private bool _chatQueue_windowOpened = false;
[GeneratedRegex( "[{}()+^&~[\\]]" )]
private static partial Regex _chatQueue_regex();
private void Chat( string message )
{
if ( Settings.EnableChat && _irsdk_connected && ( _irsdk_playerCarNumber != string.Empty ) )
{
message = _chatQueue_regex().Replace( message, "{($1)}" );
_chatQueue_messageList.Add( $"/{_irsdk_playerCarNumber} {message}\r" );
}
}
public void ProcessChatMessageQueue()
{
if ( _chatQueue_messageList.Count > 0 )
{
if ( _chatQueue_windowOpened )
{
if ( _irsdk_windowHandle != null )
{
string chatMessage = _chatQueue_messageList[ 0 ];
foreach ( var ch in chatMessage )
{
WinApi.PostMessage( (IntPtr) _irsdk_windowHandle, 0x0102, ch, 0 );
}
}
_chatQueue_messageList.RemoveAt( 0 );
if ( _chatQueue_messageList.Count > 0 )
{
_chatQueue_windowOpened = false;
}
}
else
{
_irsdk.ChatComand( IRacingSdkEnum.ChatCommandMode.BeginChat, 0 );
_chatQueue_windowOpened = true;
}
}
else
{
if ( _chatQueue_windowOpened )
{
_irsdk.ChatComand( IRacingSdkEnum.ChatCommandMode.Cancel, 0 );
_chatQueue_windowOpened = false;
}
}
}
}
}