feat: add language select to settings

This commit is contained in:
goat 2020-06-08 18:07:43 +02:00
parent a9fa629e0b
commit a7687287fa
2 changed files with 25 additions and 9 deletions

View file

@ -68,7 +68,7 @@ namespace Dalamud {
public DataManager Data { get; private set; }
private Localization localizationMgr;
internal Localization LocalizationManager;
public bool IsReady { get; private set; }
@ -100,11 +100,11 @@ namespace Dalamud {
throw new Exception("Could not ensure assets.", task.Exception);
}
this.localizationMgr = new Localization(this.StartInfo.WorkingDirectory);
this.LocalizationManager = new Localization(this.StartInfo.WorkingDirectory);
if (!string.IsNullOrEmpty(this.Configuration.LanguageOverride)) {
this.localizationMgr.SetupWithLangCode(this.Configuration.LanguageOverride);
this.LocalizationManager.SetupWithLangCode(this.Configuration.LanguageOverride);
} else {
this.localizationMgr.SetupWithUiCulture();
this.LocalizationManager.SetupWithUiCulture();
}
if (Environment.GetEnvironmentVariable("DALAMUD_NOT_HAVE_INTERFACE") != "True") {
@ -333,13 +333,13 @@ namespace Dalamud {
}
if (ImGui.MenuItem("From UICulture")) {
this.localizationMgr.SetupWithUiCulture();
this.LocalizationManager.SetupWithUiCulture();
}
foreach (var applicableLangCode in Localization.ApplicableLangCodes) {
if (ImGui.MenuItem($"Applicable: {applicableLangCode}"))
{
this.localizationMgr.SetupWithLangCode(applicableLangCode);
this.LocalizationManager.SetupWithLangCode(applicableLangCode);
}
}
@ -741,12 +741,12 @@ namespace Dalamud {
private void OnSetLanguageCommand(string command, string arguments)
{
if (Localization.ApplicableLangCodes.Contains(arguments.ToLower())) {
this.localizationMgr.SetupWithLangCode(arguments.ToLower());
this.LocalizationManager.SetupWithLangCode(arguments.ToLower());
this.Configuration.LanguageOverride = arguments.ToLower();
this.Framework.Gui.Chat.Print(string.Format(Loc.Localize("DalamudLanguageSetTo", "Language set to {0}"), arguments));
} else {
this.localizationMgr.SetupWithUiCulture();
this.LocalizationManager.SetupWithUiCulture();
this.Configuration.LanguageOverride = null;
this.Framework.Gui.Chat.Print(string.Format(Loc.Localize("DalamudLanguageSetTo", "Language set to {0}"), "default"));

View file

@ -30,8 +30,14 @@ namespace Dalamud.Interface
this.doPluginTest = this.dalamud.Configuration.DoPluginTest;
this.doDalamudTest = this.dalamud.Configuration.DoDalamudTest;
this.languages = Localization.ApplicableLangCodes.Prepend("en").ToArray();
this.langIndex = string.IsNullOrEmpty(this.dalamud.Configuration.LanguageOverride) ? 0 : Array.IndexOf(this.languages, this.dalamud.Configuration.LanguageOverride);
}
private string[] languages;
private int langIndex;
private string[] chatTypes;
private Vector4 hintTextColor = new Vector4(0.70f, 0.70f, 0.70f, 1.00f);
@ -52,7 +58,7 @@ namespace Dalamud.Interface
var isOpen = true;
if (!ImGui.Begin("XIVLauncher Settings", ref isOpen, ImGuiWindowFlags.NoCollapse | ImGuiWindowFlags.NoResize)) {
if (!ImGui.Begin("Dalamud Settings", ref isOpen, ImGuiWindowFlags.NoCollapse | ImGuiWindowFlags.NoResize)) {
ImGui.End();
return false;
}
@ -61,6 +67,13 @@ namespace Dalamud.Interface
if (ImGui.BeginTabBar("SetTabBar")) {
if (ImGui.BeginTabItem("General")) {
ImGui.Text("Language");
ImGui.Combo("##XlLangCombo", ref this.langIndex, this.languages,
this.languages.Length);
ImGui.TextColored(this.hintTextColor, "Select the language Dalamud will be displayed in.");
ImGui.Dummy(new Vector2(5f, 5f));
ImGui.Text("General Chat Channel");
ImGui.Combo("##XlChatTypeCombo", ref this.dalamudMessagesChatType, this.chatTypes,
this.chatTypes.Length);
@ -110,6 +123,9 @@ namespace Dalamud.Interface
}
private void Save() {
this.dalamud.LocalizationManager.SetupWithLangCode(this.languages[this.langIndex]);
this.dalamud.Configuration.LanguageOverride = this.languages[this.langIndex];
this.dalamud.Configuration.GeneralChatType = (XivChatType) this.dalamudMessagesChatType;
this.dalamud.Configuration.DutyFinderTaskbarFlash = this.doCfTaskBarFlash;