mirror of
https://github.com/goatcorp/Dalamud.git
synced 2026-02-13 03:17:43 +01:00
Merge branch 'master' into sestring_payloads_refactor
This commit is contained in:
commit
c8938622a5
7 changed files with 97 additions and 49 deletions
|
|
@ -14,10 +14,10 @@
|
|||
</PropertyGroup>
|
||||
<PropertyGroup Label="Feature">
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
<AssemblyVersion>4.8.9.0</AssemblyVersion>
|
||||
<FileVersion>4.8.9.0</FileVersion>
|
||||
<AssemblyVersion>4.9.1.0</AssemblyVersion>
|
||||
<FileVersion>4.9.1.0</FileVersion>
|
||||
<Description>XIVLauncher addon injection</Description>
|
||||
<Version>4.8.9.0</Version>
|
||||
<Version>4.9.1.0</Version>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
|
||||
<DocumentationFile></DocumentationFile>
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ using Dalamud.Game.Network;
|
|||
using Dalamud.Interface;
|
||||
using Dalamud.Plugin;
|
||||
using ImGuiNET;
|
||||
using Lumina.Excel.GeneratedSheets;
|
||||
using Newtonsoft.Json;
|
||||
using Serilog;
|
||||
using Serilog.Core;
|
||||
|
|
@ -93,6 +94,10 @@ namespace Dalamud {
|
|||
this.WinSock2 = new WinSockHandlers();
|
||||
|
||||
AssetManager.EnsureAssets(this.baseDirectory).ContinueWith(async task => {
|
||||
if (task.IsCanceled || task.IsFaulted) {
|
||||
throw new Exception("Could not ensure assets.", task.Exception);
|
||||
}
|
||||
|
||||
this.localizationMgr = new Localization(this.StartInfo.WorkingDirectory);
|
||||
if (!string.IsNullOrEmpty(this.Configuration.LanguageOverride)) {
|
||||
this.localizationMgr.SetupWithLangCode(this.Configuration.LanguageOverride);
|
||||
|
|
|
|||
|
|
@ -14,9 +14,9 @@
|
|||
</PropertyGroup>
|
||||
<PropertyGroup Label="Feature">
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
<AssemblyVersion>4.8.9.0</AssemblyVersion>
|
||||
<Version>4.8.9.0</Version>
|
||||
<FileVersion>4.8.9.0</FileVersion>
|
||||
<AssemblyVersion>4.9.1.0</AssemblyVersion>
|
||||
<Version>4.9.1.0</Version>
|
||||
<FileVersion>4.9.1.0</FileVersion>
|
||||
</PropertyGroup>
|
||||
<ItemGroup Label="Resources">
|
||||
<None Include="$(SolutionDir)/Resources/**/*" CopyToOutputDirectory="PreserveNewest" Visible="false" />
|
||||
|
|
@ -76,9 +76,4 @@
|
|||
<ProjectReference Include="..\lib\ImGuiScene\deps\SDL2-CS\SDL2-CS.csproj" />
|
||||
<ProjectReference Include="..\lib\ImGuiScene\ImGuiScene\ImGuiScene.csproj" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Update="NotoSansCJKjp-Medium.otf">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
|
|
|||
|
|
@ -91,10 +91,33 @@ namespace Dalamud.Game {
|
|||
|
||||
public ChatHandlers(Dalamud dalamud) {
|
||||
this.dalamud = dalamud;
|
||||
|
||||
|
||||
dalamud.Framework.Gui.Chat.OnCheckMessageHandled += OnCheckMessageHandled;
|
||||
dalamud.Framework.Gui.Chat.OnChatMessageRaw += OnChatMessage;
|
||||
}
|
||||
|
||||
private void OnCheckMessageHandled(XivChatType type, uint senderid, ref SeString sender, ref SeString message, ref bool isHandled) {
|
||||
var textVal = message.TextValue;
|
||||
|
||||
var matched = this.rmtRegex.IsMatch(textVal);
|
||||
if (matched)
|
||||
{
|
||||
// This seems to be a RMT ad - let's not show it
|
||||
Log.Debug("Handled RMT ad: " + message.TextValue);
|
||||
isHandled = true;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (this.dalamud.Configuration.BadWords != null &&
|
||||
this.dalamud.Configuration.BadWords.Any(x => textVal.Contains(x)))
|
||||
{
|
||||
// This seems to be in the user block list - let's not show it
|
||||
Log.Debug("Blocklist triggered");
|
||||
isHandled = true;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
public string LastLink { get; private set; }
|
||||
|
||||
|
|
@ -142,25 +165,9 @@ namespace Dalamud.Game {
|
|||
return;
|
||||
#endif
|
||||
|
||||
var matched = this.rmtRegex.IsMatch(message.Value);
|
||||
if (matched) {
|
||||
// This seems to be a RMT ad - let's not show it
|
||||
Log.Debug("Handled RMT ad");
|
||||
isHandled = true;
|
||||
return;
|
||||
}
|
||||
|
||||
var messageVal = message.Value;
|
||||
var senderVal = sender.Value;
|
||||
|
||||
if (this.dalamud.Configuration.BadWords != null &&
|
||||
this.dalamud.Configuration.BadWords.Any(x => messageVal.Contains(x))) {
|
||||
// This seems to be in the user block list - let's not show it
|
||||
Log.Debug("Blocklist triggered");
|
||||
isHandled = true;
|
||||
return;
|
||||
}
|
||||
|
||||
if (type == XivChatType.RetainerSale)
|
||||
{
|
||||
foreach (var regex in retainerSaleRegexes[dalamud.StartInfo.Language])
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ using System.Collections.Generic;
|
|||
using System.Collections.ObjectModel;
|
||||
using System.Text.RegularExpressions;
|
||||
using Dalamud.Game.Chat;
|
||||
using Dalamud.Game.Chat.SeStringHandling;
|
||||
using Dalamud.Game.Internal.Libc;
|
||||
using Serilog;
|
||||
|
||||
|
|
@ -54,13 +55,12 @@ namespace Dalamud.Game.Command {
|
|||
break;
|
||||
}
|
||||
|
||||
dalamud.Framework.Gui.Chat.OnChatMessageRaw += OnChatMessage;
|
||||
dalamud.Framework.Gui.Chat.OnCheckMessageHandled += OnCheckMessageHandled;
|
||||
}
|
||||
|
||||
private void OnChatMessage(XivChatType type, uint senderId, ref StdString sender,
|
||||
ref StdString message, ref bool isHandled) {
|
||||
private void OnCheckMessageHandled(XivChatType type, uint senderId, ref SeString sender, ref SeString message, ref bool isHandled) {
|
||||
if (type == XivChatType.ErrorMessage && senderId == 0) {
|
||||
var cmdMatch = this.currentLangCommandRegex.Match(message.Value).Groups["command"];
|
||||
var cmdMatch = this.currentLangCommandRegex.Match(message.TextValue).Groups["command"];
|
||||
if (cmdMatch.Success) {
|
||||
// Yes, it's a chat command.
|
||||
var command = cmdMatch.Value;
|
||||
|
|
|
|||
|
|
@ -11,30 +11,52 @@ using Serilog;
|
|||
|
||||
namespace Dalamud.Game.Internal.Gui {
|
||||
public sealed class ChatGui : IDisposable {
|
||||
private readonly Queue<XivChatEntry> chatQueue = new Queue<XivChatEntry>();
|
||||
|
||||
#region Events
|
||||
|
||||
public delegate void OnMessageDelegate(XivChatType type, uint senderId, ref SeString sender, ref SeString message, ref bool isHandled);
|
||||
public delegate void OnMessageRawDelegate(XivChatType type, uint senderId, ref StdString sender, ref StdString message, ref bool isHandled);
|
||||
public delegate void OnCheckMessageHandledDelegate(XivChatType type, uint senderId, ref SeString sender, ref SeString message, ref bool isHandled);
|
||||
|
||||
/// <summary>
|
||||
/// Event that allows you to stop messages from appearing in chat by setting the isHandled parameter to true.
|
||||
/// </summary>
|
||||
public event OnCheckMessageHandledDelegate OnCheckMessageHandled;
|
||||
|
||||
/// <summary>
|
||||
/// Event that will be fired when a chat message is sent to chat by the game.
|
||||
/// </summary>
|
||||
public event OnMessageDelegate OnChatMessage;
|
||||
|
||||
/// <summary>
|
||||
/// Event that will be fired when a chat message is sent by the game, containing raw, unparsed data.
|
||||
/// </summary>
|
||||
[Obsolete("Please use OnChatMessage instead. For modifications, it will take precedence.")]
|
||||
public event OnMessageRawDelegate OnChatMessageRaw;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Hooks
|
||||
|
||||
private readonly Hook<PrintMessageDelegate> printMessageHook;
|
||||
|
||||
private readonly Hook<PopulateItemLinkDelegate> populateItemLinkHook;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Delegates
|
||||
|
||||
[UnmanagedFunctionPointer(CallingConvention.ThisCall)]
|
||||
private delegate IntPtr PrintMessageDelegate(IntPtr manager, XivChatType chatType, IntPtr senderName,
|
||||
IntPtr message,
|
||||
uint senderId, IntPtr parameter);
|
||||
|
||||
public delegate void OnMessageDelegate(XivChatType type, uint senderId, ref SeString sender, ref SeString message,
|
||||
ref bool isHandled);
|
||||
|
||||
public delegate void OnMessageRawDelegate(XivChatType type, uint senderId, ref StdString sender, ref StdString message,
|
||||
ref bool isHandled);
|
||||
IntPtr message,
|
||||
uint senderId, IntPtr parameter);
|
||||
|
||||
|
||||
[UnmanagedFunctionPointer(CallingConvention.ThisCall)]
|
||||
private delegate void PopulateItemLinkDelegate(IntPtr linkObjectPtr, IntPtr itemInfoPtr);
|
||||
|
||||
private readonly Queue<XivChatEntry> chatQueue = new Queue<XivChatEntry>();
|
||||
|
||||
private readonly Hook<PrintMessageDelegate> printMessageHook;
|
||||
|
||||
public event OnMessageDelegate OnChatMessage;
|
||||
[Obsolete("Please use OnChatMessage instead. For modifications, it will take precedence.")]
|
||||
public event OnMessageRawDelegate OnChatMessageRaw;
|
||||
|
||||
private readonly Hook<PopulateItemLinkDelegate> populateItemLinkHook;
|
||||
#endregion
|
||||
|
||||
public int LastLinkedItemId { get; private set; }
|
||||
public byte LastLinkedItemFlags { get; private set; }
|
||||
|
|
@ -106,6 +128,8 @@ namespace Dalamud.Game.Internal.Gui {
|
|||
|
||||
// Call events
|
||||
var isHandled = false;
|
||||
OnCheckMessageHandled?.Invoke(chattype, senderid, ref parsedSender, ref parsedMessage, ref isHandled);
|
||||
|
||||
OnChatMessage?.Invoke(chattype, senderid, ref parsedSender, ref parsedMessage, ref isHandled);
|
||||
OnChatMessageRaw?.Invoke(chattype, senderid, ref sender, ref message, ref isHandled);
|
||||
|
||||
|
|
|
|||
|
|
@ -122,6 +122,23 @@ namespace Dalamud.Plugin
|
|||
// Assembly.Load() by name here will not load multiple versions with the same name, in the case of updates
|
||||
var pluginAssembly = Assembly.LoadFile(dllFile.FullName);
|
||||
|
||||
// Don't wanna fuck this up
|
||||
// This is a fix for earlier Chat Extender versions, since they break command handlers
|
||||
try
|
||||
{
|
||||
var ver = int.Parse(pluginAssembly.GetName().Version.ToString().Replace(".", ""));
|
||||
if (dllFile.Name.Contains("ChatExtender") &&
|
||||
ver < 1410)
|
||||
{
|
||||
Log.Information($"Found banned v{ver} ChatExtender, skipping...");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
// ignored
|
||||
}
|
||||
|
||||
if (pluginAssembly != null)
|
||||
{
|
||||
Log.Information("Loading types for {0}", pluginAssembly.FullName);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue