feat(plugin): add chat channel change message
This commit is contained in:
parent
30a6b7de00
commit
4be585c2de
|
@ -13,6 +13,7 @@ namespace XIVChatCommon.Message.Client {
|
|||
PlayerList = 6,
|
||||
LinkshellList = 7,
|
||||
Preferences = 8,
|
||||
Channel = 9,
|
||||
}
|
||||
|
||||
#region Ping
|
||||
|
@ -21,7 +22,7 @@ namespace XIVChatCommon.Message.Client {
|
|||
public static Ping Instance { get; } = new Ping();
|
||||
|
||||
[IgnoreMember]
|
||||
protected override byte Code => (byte)ClientOperation.Ping;
|
||||
protected override byte Code => (byte) ClientOperation.Ping;
|
||||
|
||||
protected override byte[] PayloadEncode() {
|
||||
return new byte[0];
|
||||
|
@ -38,7 +39,7 @@ namespace XIVChatCommon.Message.Client {
|
|||
public string Content { get; set; }
|
||||
|
||||
[IgnoreMember]
|
||||
protected override byte Code => (byte)ClientOperation.Message;
|
||||
protected override byte Code => (byte) ClientOperation.Message;
|
||||
|
||||
public ClientMessage(string content) {
|
||||
this.Content = content;
|
||||
|
@ -61,7 +62,7 @@ namespace XIVChatCommon.Message.Client {
|
|||
public static ClientShutdown Instance { get; } = new ClientShutdown();
|
||||
|
||||
[IgnoreMember]
|
||||
protected override byte Code => (byte)ClientOperation.Shutdown;
|
||||
protected override byte Code => (byte) ClientOperation.Shutdown;
|
||||
|
||||
protected override byte[] PayloadEncode() {
|
||||
return new byte[0];
|
||||
|
@ -77,7 +78,7 @@ namespace XIVChatCommon.Message.Client {
|
|||
[Key(0)]
|
||||
public ushort Amount { get; set; }
|
||||
|
||||
protected override byte Code => (byte)ClientOperation.Backlog;
|
||||
protected override byte Code => (byte) ClientOperation.Backlog;
|
||||
|
||||
public static ClientBacklog Decode(byte[] bytes) {
|
||||
return MessagePackSerializer.Deserialize<ClientBacklog>(bytes);
|
||||
|
@ -94,7 +95,7 @@ namespace XIVChatCommon.Message.Client {
|
|||
[Key(0)]
|
||||
public DateTime After { get; set; }
|
||||
|
||||
protected override byte Code => (byte)ClientOperation.CatchUp;
|
||||
protected override byte Code => (byte) ClientOperation.CatchUp;
|
||||
|
||||
public ClientCatchUp(DateTime after) {
|
||||
this.After = after;
|
||||
|
@ -118,7 +119,7 @@ namespace XIVChatCommon.Message.Client {
|
|||
[Key(0)]
|
||||
public PlayerListType Type { get; set; }
|
||||
|
||||
protected override byte Code => (byte)ClientOperation.PlayerList;
|
||||
protected override byte Code => (byte) ClientOperation.PlayerList;
|
||||
|
||||
public static ClientPlayerList Decode(byte[] bytes) {
|
||||
return MessagePackSerializer.Deserialize<ClientPlayerList>(bytes);
|
||||
|
@ -138,7 +139,7 @@ namespace XIVChatCommon.Message.Client {
|
|||
[Key(0)]
|
||||
public Dictionary<ClientPreference, object> Preferences { get; set; } = new Dictionary<ClientPreference, object>();
|
||||
|
||||
protected override byte Code => (byte)ClientOperation.Preferences;
|
||||
protected override byte Code => (byte) ClientOperation.Preferences;
|
||||
|
||||
protected override byte[] PayloadEncode() {
|
||||
return MessagePackSerializer.Serialize(this);
|
||||
|
@ -171,7 +172,7 @@ namespace XIVChatCommon.Message.Client {
|
|||
return false;
|
||||
}
|
||||
|
||||
value = (T)obj;
|
||||
value = (T) obj;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -185,4 +186,24 @@ namespace XIVChatCommon.Message.Client {
|
|||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Channel
|
||||
|
||||
[MessagePackObject]
|
||||
public class ClientChannel : IEncodable {
|
||||
protected override byte Code => (byte) ClientOperation.Channel;
|
||||
|
||||
[Key(0)]
|
||||
public InputChannel Channel { get; set; }
|
||||
|
||||
public static ClientChannel Decode(byte[] bytes) {
|
||||
return MessagePackSerializer.Deserialize<ClientChannel>(bytes);
|
||||
}
|
||||
|
||||
protected override byte[] PayloadEncode() {
|
||||
return MessagePackSerializer.Serialize(this);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
|
|
@ -565,7 +565,7 @@ namespace XIVChatCommon.Message {
|
|||
OtherPet = 2048,
|
||||
}
|
||||
|
||||
public enum InputChannel : byte {
|
||||
public enum InputChannel : uint {
|
||||
Tell = 0,
|
||||
Say = 1,
|
||||
Party = 2,
|
||||
|
|
|
@ -11,6 +11,8 @@ using XIVChatCommon.Message;
|
|||
|
||||
namespace XIVChatPlugin {
|
||||
public class GameFunctions : IDisposable {
|
||||
private const int ChannelOffset = 4048; // update 5.4-HF1
|
||||
|
||||
private Plugin Plugin { get; }
|
||||
|
||||
private delegate IntPtr GetUiModuleDelegate(IntPtr basePtr);
|
||||
|
@ -40,6 +42,7 @@ namespace XIVChatPlugin {
|
|||
private IntPtr ColourHandler { get; }
|
||||
private IntPtr ColourLookup { get; }
|
||||
private IntPtr _friendListManager = IntPtr.Zero;
|
||||
private IntPtr _chatManager = IntPtr.Zero;
|
||||
|
||||
public bool RequestingFriendList { get; private set; }
|
||||
|
||||
|
@ -124,6 +127,15 @@ namespace XIVChatPlugin {
|
|||
this._chatChannelChangeHook?.Enable();
|
||||
}
|
||||
|
||||
public void ChangeChatChannel(InputChannel channel) {
|
||||
if (this._chatManager == IntPtr.Zero || this._chatChannelChangeHook == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
Marshal.WriteInt32(this._chatManager + ChannelOffset, (int) channel);
|
||||
this._chatChannelChangeHook.Original(this._chatManager, (uint) channel);
|
||||
}
|
||||
|
||||
// This function looks up a channel's user-defined colour.
|
||||
//
|
||||
// If this function would ever return 0, it returns null instead.
|
||||
|
@ -188,6 +200,7 @@ namespace XIVChatPlugin {
|
|||
}
|
||||
|
||||
private byte ChangeChatChannelDetour(IntPtr a1, uint channel) {
|
||||
this._chatManager = a1;
|
||||
// a1 + 0xfd0 is the chat channel byte (including for when clicking on shout)
|
||||
this.Plugin.Server.OnChatChannelChange(channel);
|
||||
return this._chatChannelChangeHook!.Original(a1, channel);
|
||||
|
|
|
@ -414,6 +414,11 @@ namespace XIVChatPlugin {
|
|||
var preferences = ClientPreferences.Decode(payload);
|
||||
client.Preferences = preferences;
|
||||
|
||||
break;
|
||||
case ClientOperation.Channel:
|
||||
var channel = ClientChannel.Decode(payload);
|
||||
this.plugin.Functions.ChangeChatChannel(channel.Channel);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -700,9 +705,7 @@ namespace XIVChatPlugin {
|
|||
continue;
|
||||
}
|
||||
|
||||
Task.Run(async () => {
|
||||
await SecretMessage.SendSecretMessage(client.Conn.GetStream(), client.Handshake.Keys.tx, message);
|
||||
});
|
||||
Task.Run(async () => { await SecretMessage.SendSecretMessage(client.Conn.GetStream(), client.Handshake.Keys.tx, message); });
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user