Merge pull request #350 from kalilistic/expose-chat-type

This commit is contained in:
goaaats 2021-05-25 16:17:55 +02:00 committed by GitHub
commit d3b8f8494b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 26 additions and 0 deletions

View file

@ -17,6 +17,17 @@ namespace Dalamud.Configuration
[JsonIgnore]
private string configPath;
/// <summary>
/// Delegate for the <see cref="DalamudConfiguration.OnDalamudConfigurationSaved"/> event that occurs when the dalamud configuration is saved.
/// </summary>
/// <param name="dalamudConfiguration">The current dalamud configuration.</param>
public delegate void DalamudConfigurationSavedDelegate(DalamudConfiguration dalamudConfiguration);
/// <summary>
/// Event that occurs when dalamud configuration is saved.
/// </summary>
public event DalamudConfigurationSavedDelegate OnDalamudConfigurationSaved;
/// <summary>
/// Gets or sets a list of muted works.
/// </summary>
@ -156,6 +167,7 @@ namespace Dalamud.Configuration
public void Save()
{
File.WriteAllText(this.configPath, JsonConvert.SerializeObject(this, Formatting.Indented));
this.OnDalamudConfigurationSaved?.Invoke(this);
}
}
}

View file

@ -11,6 +11,7 @@ using Dalamud.Game;
using Dalamud.Game.ClientState;
using Dalamud.Game.Command;
using Dalamud.Game.Internal;
using Dalamud.Game.Text;
using Dalamud.Game.Text.Sanitizer;
using Dalamud.Game.Text.SeStringHandling;
using Dalamud.Game.Text.SeStringHandling.Payloads;
@ -50,6 +51,7 @@ namespace Dalamud.Plugin
this.pluginName = pluginName;
this.configs = configs;
this.GeneralChatType = this.dalamud.Configuration.GeneralChatType;
this.Sanitizer = new Sanitizer(this.Data.Language);
if (this.dalamud.Configuration.LanguageOverride != null)
{
@ -65,6 +67,7 @@ namespace Dalamud.Plugin
}
dalamud.LocalizationManager.OnLocalizationChanged += this.OnLocalizationChanged;
dalamud.Configuration.OnDalamudConfigurationSaved += this.OnDalamudConfigurationSaved;
}
/// <summary>
@ -152,6 +155,11 @@ namespace Dalamud.Plugin
/// </summary>
public ISanitizer Sanitizer { get; }
/// <summary>
/// Gets the chat type used by default for plugin messages.
/// </summary>
public XivChatType GeneralChatType { get; private set; }
/// <summary>
/// Gets the action that should be executed when any plugin sends a message.
/// </summary>
@ -374,6 +382,7 @@ namespace Dalamud.Plugin
this.UiBuilder.Dispose();
this.Framework.Gui.Chat.RemoveChatLinkHandler(this.pluginName);
this.dalamud.LocalizationManager.OnLocalizationChanged -= this.OnLocalizationChanged;
this.dalamud.Configuration.OnDalamudConfigurationSaved -= this.OnDalamudConfigurationSaved;
}
private void OnLocalizationChanged(string langCode)
@ -381,5 +390,10 @@ namespace Dalamud.Plugin
this.UiLanguage = langCode;
this.OnLanguageChanged?.Invoke(langCode);
}
private void OnDalamudConfigurationSaved(DalamudConfiguration dalamudConfiguration)
{
this.GeneralChatType = dalamudConfiguration.GeneralChatType;
}
}
}