feat: add option to choose language source
This commit is contained in:
parent
f64cc0e5b1
commit
cc474a2094
|
@ -3,7 +3,6 @@ using System.Collections.Generic;
|
|||
using System.Numerics;
|
||||
using System.Text.RegularExpressions;
|
||||
using Dalamud.Interface;
|
||||
using Dalamud.Plugin;
|
||||
using ImGuiNET;
|
||||
using NoSoliciting.Ml;
|
||||
using NoSoliciting.Resources;
|
||||
|
@ -61,21 +60,7 @@ namespace NoSoliciting.Interface {
|
|||
|
||||
this.DrawOtherFilters();
|
||||
|
||||
if (ImGui.BeginTabItem(Language.OtherTab)) {
|
||||
var logFilteredPfs = this.Plugin.Config.LogFilteredPfs;
|
||||
if (ImGui.Checkbox(Language.LogFilteredPfs, ref logFilteredPfs)) {
|
||||
this.Plugin.Config.LogFilteredPfs = logFilteredPfs;
|
||||
this.Plugin.Config.Save();
|
||||
}
|
||||
|
||||
var logFilteredMessages = this.Plugin.Config.LogFilteredChat;
|
||||
if (ImGui.Checkbox(Language.LogFilteredMessages, ref logFilteredMessages)) {
|
||||
this.Plugin.Config.LogFilteredChat = logFilteredMessages;
|
||||
this.Plugin.Config.Save();
|
||||
}
|
||||
|
||||
ImGui.EndTabItem();
|
||||
}
|
||||
this.DrawOtherTab();
|
||||
|
||||
ImGui.EndTabBar();
|
||||
|
||||
|
@ -329,5 +314,32 @@ namespace NoSoliciting.Interface {
|
|||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private void DrawOtherTab() {
|
||||
if (!ImGui.BeginTabItem(Language.OtherTab)) {
|
||||
return;
|
||||
}
|
||||
|
||||
var useGameLanguage = this.Plugin.Config.FollowGameLanguage;
|
||||
if (ImGui.Checkbox(Language.OtherGameLanguage, ref useGameLanguage)) {
|
||||
this.Plugin.Config.FollowGameLanguage = useGameLanguage;
|
||||
this.Plugin.Config.Save();
|
||||
this.Plugin.ConfigureLanguage();
|
||||
}
|
||||
|
||||
var logFilteredPfs = this.Plugin.Config.LogFilteredPfs;
|
||||
if (ImGui.Checkbox(Language.LogFilteredPfs, ref logFilteredPfs)) {
|
||||
this.Plugin.Config.LogFilteredPfs = logFilteredPfs;
|
||||
this.Plugin.Config.Save();
|
||||
}
|
||||
|
||||
var logFilteredMessages = this.Plugin.Config.LogFilteredChat;
|
||||
if (ImGui.Checkbox(Language.LogFilteredMessages, ref logFilteredMessages)) {
|
||||
this.Plugin.Config.LogFilteredChat = logFilteredMessages;
|
||||
this.Plugin.Config.Save();
|
||||
}
|
||||
|
||||
ImGui.EndTabItem();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,9 +5,9 @@ using System.Globalization;
|
|||
using System.IO;
|
||||
using System.Reflection;
|
||||
using System.Threading.Tasks;
|
||||
using Dalamud;
|
||||
using NoSoliciting.Interface;
|
||||
using NoSoliciting.Ml;
|
||||
using Resourcer;
|
||||
using XivCommon;
|
||||
|
||||
namespace NoSoliciting {
|
||||
|
@ -44,14 +44,13 @@ namespace NoSoliciting {
|
|||
|
||||
this.Interface = pluginInterface;
|
||||
|
||||
Util.PreLoadResourcesFromMainAssembly();
|
||||
|
||||
Resources.Language.Culture = new CultureInfo(this.Interface.UiLanguage);
|
||||
this.Interface.OnLanguageChanged += OnLanguageUpdate;
|
||||
|
||||
this.Config = this.Interface.GetPluginConfig() as PluginConfiguration ?? new PluginConfiguration();
|
||||
this.Config.Initialise(this.Interface);
|
||||
|
||||
Util.PreLoadResourcesFromMainAssembly();
|
||||
this.ConfigureLanguage();
|
||||
this.Interface.OnLanguageChanged += this.OnLanguageUpdate;
|
||||
|
||||
this.Common = new XivCommonBase(this.Interface, Hooks.PartyFinder | Hooks.ContextMenu);
|
||||
|
||||
this.Ui = new PluginUi(this);
|
||||
|
@ -82,13 +81,29 @@ namespace NoSoliciting {
|
|||
this.Commands.Dispose();
|
||||
this.Ui.Dispose();
|
||||
this.Common.Dispose();
|
||||
this.Interface.OnLanguageChanged -= OnLanguageUpdate;
|
||||
this.Interface.OnLanguageChanged -= this.OnLanguageUpdate;
|
||||
}
|
||||
|
||||
this._disposedValue = true;
|
||||
}
|
||||
|
||||
private static void OnLanguageUpdate(string langCode) {
|
||||
private void OnLanguageUpdate(string langCode) {
|
||||
this.ConfigureLanguage(langCode);
|
||||
}
|
||||
|
||||
internal void ConfigureLanguage(string? langCode = null) {
|
||||
if (this.Config.FollowGameLanguage) {
|
||||
langCode = this.Interface.ClientState.ClientLanguage switch {
|
||||
ClientLanguage.Japanese => "ja",
|
||||
ClientLanguage.English => "en",
|
||||
ClientLanguage.German => "de",
|
||||
ClientLanguage.French => "fr",
|
||||
_ => throw new ArgumentOutOfRangeException(),
|
||||
};
|
||||
} else {
|
||||
langCode ??= this.Interface.UiLanguage;
|
||||
}
|
||||
|
||||
Resources.Language.Culture = new CultureInfo(langCode);
|
||||
}
|
||||
|
||||
|
|
|
@ -51,6 +51,8 @@ namespace NoSoliciting {
|
|||
|
||||
public bool FilterHugeItemLevelPFs { get; set; }
|
||||
|
||||
public bool FollowGameLanguage { get; set; }
|
||||
|
||||
public HashSet<MessageCategory> BasicMlFilters { get; set; } = new() {
|
||||
MessageCategory.RmtGil,
|
||||
MessageCategory.RmtContent,
|
||||
|
|
|
@ -258,6 +258,15 @@ namespace NoSoliciting.Resources {
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Use the game's language setting instead of Dalamud's.
|
||||
/// </summary>
|
||||
internal static string OtherGameLanguage {
|
||||
get {
|
||||
return ResourceManager.GetString("OtherGameLanguage", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Other.
|
||||
/// </summary>
|
||||
|
|
|
@ -234,4 +234,7 @@
|
|||
<data name="ReportToastFailure" xml:space="preserve">
|
||||
<value>Failed to report Party Finder listing hosted by {0}.</value>
|
||||
</data>
|
||||
<data name="OtherGameLanguage" xml:space="preserve">
|
||||
<value>Use the game's language setting instead of Dalamud's</value>
|
||||
</data>
|
||||
</root>
|
Loading…
Reference in New Issue