feat: add option to sort auto translate list
This commit is contained in:
parent
70cecf4a6d
commit
212835c33a
@ -33,6 +33,7 @@ internal class Configuration : IPluginConfiguration {
|
|||||||
public bool LoadPreviousSession;
|
public bool LoadPreviousSession;
|
||||||
public bool FilterIncludePreviousSessions;
|
public bool FilterIncludePreviousSessions;
|
||||||
public bool SharedMode;
|
public bool SharedMode;
|
||||||
|
public bool SortAutoTranslate;
|
||||||
|
|
||||||
public bool FontsEnabled = true;
|
public bool FontsEnabled = true;
|
||||||
public float FontSize = 17f;
|
public float FontSize = 17f;
|
||||||
@ -67,6 +68,7 @@ internal class Configuration : IPluginConfiguration {
|
|||||||
this.LoadPreviousSession = other.LoadPreviousSession;
|
this.LoadPreviousSession = other.LoadPreviousSession;
|
||||||
this.FilterIncludePreviousSessions = other.FilterIncludePreviousSessions;
|
this.FilterIncludePreviousSessions = other.FilterIncludePreviousSessions;
|
||||||
this.SharedMode = other.SharedMode;
|
this.SharedMode = other.SharedMode;
|
||||||
|
this.SortAutoTranslate = other.SortAutoTranslate;
|
||||||
this.FontsEnabled = other.FontsEnabled;
|
this.FontsEnabled = other.FontsEnabled;
|
||||||
this.FontSize = other.FontSize;
|
this.FontSize = other.FontSize;
|
||||||
this.JapaneseFontSize = other.JapaneseFontSize;
|
this.JapaneseFontSize = other.JapaneseFontSize;
|
||||||
|
1660
ChatTwo/Resources/Language.Designer.cs
generated
1660
ChatTwo/Resources/Language.Designer.cs
generated
File diff suppressed because it is too large
Load Diff
@ -497,4 +497,13 @@
|
|||||||
<data name="Options_FontsEnabled" xml:space="preserve">
|
<data name="Options_FontsEnabled" xml:space="preserve">
|
||||||
<value>Enable custom fonts</value>
|
<value>Enable custom fonts</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="AutoTranslate_Search_Hint" xml:space="preserve">
|
||||||
|
<value>Search Auto Translate...</value>
|
||||||
|
</data>
|
||||||
|
<data name="Options_SortAutoTranslate_Name" xml:space="preserve">
|
||||||
|
<value>Sort the Auto Translate list</value>
|
||||||
|
</data>
|
||||||
|
<data name="Options_SortAutoTranslate_Description" xml:space="preserve">
|
||||||
|
<value>If this is enabled, the Auto Translate list will be sorted alphabetically.</value>
|
||||||
|
</data>
|
||||||
</root>
|
</root>
|
||||||
|
@ -955,7 +955,7 @@ internal sealed class ChatLog : IUiComponent {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this._autoCompleteList ??= AutoTranslate.Matching(this.Ui.Plugin.DataManager, this._autoCompleteInfo.ToComplete);
|
this._autoCompleteList ??= AutoTranslate.Matching(this.Ui.Plugin.DataManager, this._autoCompleteInfo.ToComplete, this.Ui.Plugin.Config.SortAutoTranslate);
|
||||||
|
|
||||||
if (this._autoCompleteOpen) {
|
if (this._autoCompleteOpen) {
|
||||||
ImGui.OpenPopup(AutoCompleteId);
|
ImGui.OpenPopup(AutoCompleteId);
|
||||||
@ -975,8 +975,8 @@ internal sealed class ChatLog : IUiComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ImGui.SetNextItemWidth(-1);
|
ImGui.SetNextItemWidth(-1);
|
||||||
if (ImGui.InputTextWithHint("##auto-complete-filter", "Search auto translate...", ref this._autoCompleteInfo.ToComplete, 256, ImGuiInputTextFlags.CallbackAlways, this.FixCursor)) {
|
if (ImGui.InputTextWithHint("##auto-complete-filter", Language.AutoTranslate_Search_Hint, ref this._autoCompleteInfo.ToComplete, 256, ImGuiInputTextFlags.CallbackAlways, this.FixCursor)) {
|
||||||
this._autoCompleteList = AutoTranslate.Matching(this.Ui.Plugin.DataManager, this._autoCompleteInfo.ToComplete);
|
this._autoCompleteList = AutoTranslate.Matching(this.Ui.Plugin.DataManager, this._autoCompleteInfo.ToComplete, this.Ui.Plugin.Config.SortAutoTranslate);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ImGui.IsWindowAppearing()) {
|
if (ImGui.IsWindowAppearing()) {
|
||||||
|
@ -58,5 +58,9 @@ internal sealed class Miscellaneous : ISettingsTab {
|
|||||||
|
|
||||||
ImGuiUtil.HelpText(string.Format(Language.Options_KeybindMode_Description, Plugin.PluginName));
|
ImGuiUtil.HelpText(string.Format(Language.Options_KeybindMode_Description, Plugin.PluginName));
|
||||||
ImGui.Spacing();
|
ImGui.Spacing();
|
||||||
|
|
||||||
|
ImGui.Checkbox(Language.Options_SortAutoTranslate_Name, ref this.Mutable.SortAutoTranslate);
|
||||||
|
ImGuiUtil.HelpText(Language.Options_SortAutoTranslate_Description);
|
||||||
|
ImGui.Spacing();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -186,7 +186,7 @@ internal static class AutoTranslate {
|
|||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static List<AutoTranslateEntry> Matching(DataManager data, string prefix) {
|
internal static List<AutoTranslateEntry> Matching(DataManager data, string prefix, bool sort) {
|
||||||
var wholeMatches = new List<AutoTranslateEntry>();
|
var wholeMatches = new List<AutoTranslateEntry>();
|
||||||
var prefixMatches = new List<AutoTranslateEntry>();
|
var prefixMatches = new List<AutoTranslateEntry>();
|
||||||
var otherMatches = new List<AutoTranslateEntry>();
|
var otherMatches = new List<AutoTranslateEntry>();
|
||||||
@ -200,9 +200,16 @@ internal static class AutoTranslate {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return wholeMatches.OrderBy(entry => entry.String, StringComparer.OrdinalIgnoreCase)
|
if (sort) {
|
||||||
.Concat(prefixMatches.OrderBy(entry => entry.String, StringComparer.OrdinalIgnoreCase))
|
return wholeMatches.OrderBy(entry => entry.String, StringComparer.OrdinalIgnoreCase)
|
||||||
.Concat(otherMatches.OrderBy(entry => entry.String, StringComparer.OrdinalIgnoreCase))
|
.Concat(prefixMatches.OrderBy(entry => entry.String, StringComparer.OrdinalIgnoreCase))
|
||||||
|
.Concat(otherMatches.OrderBy(entry => entry.String, StringComparer.OrdinalIgnoreCase))
|
||||||
|
.ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
return wholeMatches
|
||||||
|
.Concat(prefixMatches)
|
||||||
|
.Concat(otherMatches)
|
||||||
.ToList();
|
.ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user