Update texts in SettingsWindow when locale changes

This commit is contained in:
Haselnussbomber 2025-09-05 02:30:00 +02:00
parent f3e462eb6b
commit 3aa5aa4a82
No known key found for this signature in database
GPG key ID: BB905BB49E7295D1
19 changed files with 309 additions and 267 deletions

View file

@ -1,14 +1,16 @@
namespace Dalamud.Interface.Internal.Windows.Settings;
using Dalamud.Utility.Internal;
namespace Dalamud.Interface.Internal.Windows.Settings;
/// <summary>
/// Basic, drawable settings entry.
/// </summary>
public abstract class SettingsEntry
internal abstract class SettingsEntry
{
/// <summary>
/// Gets or sets the public, searchable name of this settings entry.
/// </summary>
public string? Name { get; protected set; }
public LocRef Name { get; protected set; }
/// <summary>
/// Gets or sets a value indicating whether this entry is valid.

View file

@ -1,16 +1,18 @@
using System.Diagnostics.CodeAnalysis;
using System.Diagnostics.CodeAnalysis;
using Dalamud.Interface.Utility;
namespace Dalamud.Interface.Internal.Windows.Settings;
[SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1600:Elements should be documented", Justification = "Internals")]
public abstract class SettingsTab : IDisposable
internal abstract class SettingsTab : IDisposable
{
public abstract SettingsEntry[] Entries { get; }
public abstract string Title { get; }
public abstract SettingsOpenKind Kind { get; }
public bool IsOpen { get; set; } = false;
public virtual bool IsVisible { get; } = true;

View file

@ -17,10 +17,9 @@ namespace Dalamud.Interface.Internal.Windows.Settings;
/// <summary>
/// The window that allows for general configuration of Dalamud itself.
/// </summary>
internal class SettingsWindow : Window
internal sealed class SettingsWindow : Window
{
private readonly SettingsTab[] tabs;
private string searchInput = string.Empty;
private bool isSearchInputPrefilled = false;
@ -30,7 +29,7 @@ internal class SettingsWindow : Window
/// Initializes a new instance of the <see cref="SettingsWindow"/> class.
/// </summary>
public SettingsWindow()
: base(Loc.Localize("DalamudSettingsHeader", "Dalamud Settings") + "###XlSettings2", ImGuiWindowFlags.NoCollapse | ImGuiWindowFlags.NoScrollbar)
: base(Title, ImGuiWindowFlags.NoCollapse | ImGuiWindowFlags.NoScrollbar)
{
this.Size = new Vector2(740, 550);
this.SizeConstraints = new WindowSizeConstraints()
@ -52,6 +51,8 @@ internal class SettingsWindow : Window
];
}
private static string Title => Loc.Localize("DalamudSettingsHeader", "Dalamud Settings") + "###XlSettings2";
/// <summary>
/// Open the settings window to the tab specified by <paramref name="kind"/>.
/// </summary>
@ -59,7 +60,7 @@ internal class SettingsWindow : Window
public void OpenTo(SettingsOpenKind kind)
{
this.IsOpen = true;
this.SetOpenTab(kind);
this.setActiveTab = this.tabs.Single(tab => tab.Kind == kind);
}
/// <summary>
@ -83,12 +84,19 @@ internal class SettingsWindow : Window
/// <inheritdoc/>
public override void OnOpen()
{
var localization = Service<Localization>.Get();
foreach (var settingsTab in this.tabs)
{
settingsTab.Load();
}
if (!this.isSearchInputPrefilled) this.searchInput = string.Empty;
if (!this.isSearchInputPrefilled)
{
this.searchInput = string.Empty;
}
localization.LocalizationChanged += this.OnLocalizationChanged;
base.OnOpen();
}
@ -99,6 +107,7 @@ internal class SettingsWindow : Window
var configuration = Service<DalamudConfiguration>.Get();
var interfaceManager = Service<InterfaceManager>.Get();
var fontAtlasFactory = Service<FontAtlasFactory>.Get();
var localization = Service<Localization>.Get();
var scaleChanged = !Equals(ImGui.GetIO().FontGlobalScale, configuration.GlobalUiScale);
var rebuildFont = !Equals(fontAtlasFactory.DefaultFontSpec, configuration.DefaultFontSpec);
@ -107,7 +116,7 @@ internal class SettingsWindow : Window
ImGui.GetIO().FontGlobalScale = configuration.GlobalUiScale;
if (scaleChanged)
{
Service<InterfaceManager>.Get().InvokeGlobalScaleChanged();
interfaceManager.InvokeGlobalScaleChanged();
}
fontAtlasFactory.DefaultFontSpecOverride = null;
@ -115,7 +124,7 @@ internal class SettingsWindow : Window
if (rebuildFont)
{
interfaceManager.RebuildFonts();
Service<InterfaceManager>.Get().InvokeFontChanged();
interfaceManager.InvokeFontChanged();
}
foreach (var settingsTab in this.tabs)
@ -133,98 +142,28 @@ internal class SettingsWindow : Window
this.isSearchInputPrefilled = false;
this.searchInput = string.Empty;
}
localization.LocalizationChanged -= this.OnLocalizationChanged;
}
/// <inheritdoc/>
public override void Draw()
{
ImGui.SetNextItemWidth(-1);
ImGui.InputTextWithHint("###searchInput"u8, "Search for settings..."u8, ref this.searchInput, 100);
ImGui.Spacing();
var windowSize = ImGui.GetWindowSize();
if (ImGui.BeginTabBar("###settingsTabs"u8))
using (var tabBar = ImRaii.TabBar("###settingsTabs"u8))
{
if (string.IsNullOrEmpty(this.searchInput))
if (tabBar)
{
foreach (var settingsTab in this.tabs.Where(x => x.IsVisible))
{
var flags = ImGuiTabItemFlags.NoCloseWithMiddleMouseButton;
if (this.setActiveTab == settingsTab)
{
flags |= ImGuiTabItemFlags.SetSelected;
this.setActiveTab = null;
}
using var tab = ImRaii.TabItem(settingsTab.Title, flags);
if (tab)
{
if (!settingsTab.IsOpen)
{
settingsTab.IsOpen = true;
settingsTab.OnOpen();
}
// Don't add padding for the about tab(credits)
{
using var padding = ImRaii.PushStyle(
ImGuiStyleVar.WindowPadding,
new Vector2(2, 2),
settingsTab is not SettingsTabAbout);
using var borderColor = ImRaii.PushColor(
ImGuiCol.Border,
ImGui.GetColorU32(ImGuiCol.ChildBg));
using var tabChild = ImRaii.Child(
$"###settings_scrolling_{settingsTab.Title}",
new Vector2(-1, -1),
true);
if (tabChild)
settingsTab.Draw();
}
settingsTab.PostDraw();
}
else if (settingsTab.IsOpen)
{
settingsTab.IsOpen = false;
settingsTab.OnClose();
}
}
if (string.IsNullOrEmpty(this.searchInput))
this.DrawTabs();
else
this.DrawSearchResults();
}
else
{
if (ImGui.BeginTabItem("Search Results"u8))
{
var any = false;
foreach (var settingsTab in this.tabs.Where(x => x.IsVisible))
{
var eligible = settingsTab.Entries.Where(x => !x.Name.IsNullOrEmpty() && x.Name.ToLowerInvariant().Contains(this.searchInput.ToLowerInvariant())).ToArray();
if (!eligible.Any())
continue;
any = true;
ImGui.TextColored(ImGuiColors.DalamudGrey, settingsTab.Title);
ImGui.Dummy(new Vector2(5));
foreach (var settingsTabEntry in eligible)
{
settingsTabEntry.Draw();
ImGuiHelpers.ScaledDummy(3);
}
ImGui.Separator();
ImGui.Dummy(new Vector2(10));
}
if (!any)
ImGui.TextColored(ImGuiColors.DalamudGrey, "No results found..."u8);
ImGui.EndTabItem();
}
}
ImGui.EndTabBar();
}
ImGui.SetCursorPos(windowSize - ImGuiHelpers.ScaledVector2(70));
@ -256,10 +195,92 @@ internal class SettingsWindow : Window
}
}
}
}
ImGui.SetCursorPos(new Vector2(windowSize.X - 250, ImGui.GetTextLineHeightWithSpacing() + (ImGui.GetStyle().FramePadding.Y * 2)));
ImGui.SetNextItemWidth(240);
ImGui.InputTextWithHint("###searchInput"u8, "Search for settings..."u8, ref this.searchInput, 100);
private void DrawTabs()
{
foreach (var settingsTab in this.tabs.Where(x => x.IsVisible))
{
var flags = ImGuiTabItemFlags.NoCloseWithMiddleMouseButton;
if (this.setActiveTab == settingsTab)
{
flags |= ImGuiTabItemFlags.SetSelected;
this.setActiveTab = null;
}
using var tab = ImRaii.TabItem(settingsTab.Title, flags);
if (tab)
{
if (!settingsTab.IsOpen)
{
settingsTab.IsOpen = true;
settingsTab.OnOpen();
}
// Don't add padding for the about tab(credits)
{
using var padding = ImRaii.PushStyle(
ImGuiStyleVar.WindowPadding,
new Vector2(2, 2),
settingsTab is not SettingsTabAbout);
using var borderColor = ImRaii.PushColor(
ImGuiCol.Border,
ImGui.GetColorU32(ImGuiCol.ChildBg));
using var tabChild = ImRaii.Child(
$"###settings_scrolling_{settingsTab.Title}",
new Vector2(-1, -1),
true);
if (tabChild)
settingsTab.Draw();
}
settingsTab.PostDraw();
}
else if (settingsTab.IsOpen)
{
settingsTab.IsOpen = false;
settingsTab.OnClose();
}
}
}
private void DrawSearchResults()
{
using var tab = ImRaii.TabItem("Search Results"u8);
if (!tab) return;
var any = false;
foreach (var settingsTab in this.tabs.Where(x => x.IsVisible))
{
var eligible = settingsTab.Entries.Where(x =>
{
var name = x.Name.ToString();
return !name.IsNullOrEmpty() && name.Contains(this.searchInput, StringComparison.InvariantCultureIgnoreCase);
});
if (!eligible.Any())
continue;
any |= true;
ImGui.TextColored(ImGuiColors.DalamudGrey, settingsTab.Title);
ImGui.Dummy(new Vector2(5));
foreach (var settingsTabEntry in eligible)
{
settingsTabEntry.Draw();
ImGuiHelpers.ScaledDummy(3);
}
ImGui.Separator();
ImGui.Dummy(new Vector2(10));
}
if (!any)
ImGui.TextColored(ImGuiColors.DalamudGrey, "No results found..."u8);
}
private void Save()
@ -301,17 +322,8 @@ internal class SettingsWindow : Window
Service<InterfaceManager>.Get().RebuildFonts();
}
private void SetOpenTab(SettingsOpenKind kind)
private void OnLocalizationChanged(string langCode)
{
this.setActiveTab = kind switch
{
SettingsOpenKind.General => this.tabs[0],
SettingsOpenKind.LookAndFeel => this.tabs[1],
SettingsOpenKind.AutoUpdates => this.tabs[2],
SettingsOpenKind.ServerInfoBar => this.tabs[3],
SettingsOpenKind.Experimental => this.tabs[4],
SettingsOpenKind.About => this.tabs[5],
_ => throw new ArgumentOutOfRangeException(nameof(kind), kind, null),
};
this.WindowName = Title;
}
}

View file

@ -20,7 +20,7 @@ using FFXIVClientStructs.FFXIV.Client.Game.UI;
namespace Dalamud.Interface.Internal.Windows.Settings.Tabs;
[SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1600:Elements should be documented", Justification = "Internals")]
public class SettingsTabAbout : SettingsTab
internal sealed class SettingsTabAbout : SettingsTab
{
private const float CreditFps = 60.0f;
private const string ThankYouText = "Thank you!";
@ -209,10 +209,12 @@ Contribute at: https://github.com/goatcorp/Dalamud
.CreateFontAtlas(nameof(SettingsTabAbout), FontAtlasAutoRebuildMode.Async);
}
public override SettingsEntry[] Entries { get; } = { };
public override string Title => Loc.Localize("DalamudAbout", "About");
public override SettingsOpenKind Kind => SettingsOpenKind.About;
public override SettingsEntry[] Entries { get; } = [];
/// <inheritdoc/>
public override unsafe void OnOpen()
{
@ -287,7 +289,7 @@ Contribute at: https://github.com/goatcorp/Dalamud
var windowX = ImGui.GetWindowSize().X;
foreach (var creditsLine in this.creditsText.Split(new[] { "\r\n", "\r", "\n" }, StringSplitOptions.None))
foreach (var creditsLine in this.creditsText.Split(["\r\n", "\r", "\n"], StringSplitOptions.None))
{
var lineLenX = ImGui.CalcTextSize(creditsLine).X;

View file

@ -1,4 +1,4 @@
using System.Collections.Generic;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Numerics;
@ -18,7 +18,7 @@ using Dalamud.Plugin.Internal.Types;
namespace Dalamud.Interface.Internal.Windows.Settings.Tabs;
[SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1600:Elements should be documented", Justification = "Internals")]
public class SettingsTabAutoUpdates : SettingsTab
internal sealed class SettingsTabAutoUpdates : SettingsTab
{
private AutoUpdateBehavior behavior;
private bool updateDisabledPlugins;
@ -31,6 +31,8 @@ public class SettingsTabAutoUpdates : SettingsTab
public override string Title => Loc.Localize("DalamudSettingsAutoUpdates", "Auto-Updates");
public override SettingsOpenKind Kind => SettingsOpenKind.AutoUpdates;
public override void Draw()
{
ImGui.TextColoredWrapped(ImGuiColors.DalamudWhite, Loc.Localize("DalamudSettingsAutoUpdateHint",

View file

@ -14,17 +14,19 @@ using Dalamud.Interface.Utility;
namespace Dalamud.Interface.Internal.Windows.Settings.Tabs;
[SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1600:Elements should be documented", Justification = "Internals")]
public class SettingsTabDtr : SettingsTab
internal sealed class SettingsTabDtr : SettingsTab
{
private List<string>? dtrOrder;
private List<string>? dtrIgnore;
private int dtrSpacing;
private bool dtrSwapDirection;
public override SettingsEntry[] Entries { get; } = Array.Empty<SettingsEntry>();
public override string Title => Loc.Localize("DalamudSettingsServerInfoBar", "Server Info Bar");
public override SettingsOpenKind Kind => SettingsOpenKind.ServerInfoBar;
public override SettingsEntry[] Entries { get; } = [];
public override void Draw()
{
ImGui.TextColoredWrapped(ImGuiColors.DalamudGrey, Loc.Localize("DalamudSettingServerInfoBarHint", "Plugins can put additional information into your server information bar(where world & time can be seen).\nYou can reorder and disable these here."));
@ -125,8 +127,8 @@ public class SettingsTabDtr : SettingsTab
ImGui.GetIO().MousePos = moveMouseTo[moveMouseToIndex];
}
configuration.DtrOrder = order.Concat(orderLeft).ToList();
configuration.DtrIgnore = ignore.Concat(ignoreLeft).ToList();
configuration.DtrOrder = [.. order, .. orderLeft];
configuration.DtrIgnore = [.. ignore, .. ignoreLeft];
if (isOrderChange)
dtrBar.ApplySort();

View file

@ -6,7 +6,6 @@ using Dalamud.Bindings.ImGui;
using Dalamud.Configuration.Internal;
using Dalamud.Interface.Colors;
using Dalamud.Interface.Internal.ReShadeHandling;
using Dalamud.Interface.Internal.Windows.PluginInstaller;
using Dalamud.Interface.Internal.Windows.Settings.Widgets;
using Dalamud.Interface.Utility;
using Dalamud.Plugin.Internal;
@ -18,33 +17,28 @@ namespace Dalamud.Interface.Internal.Windows.Settings.Tabs;
"StyleCop.CSharp.DocumentationRules",
"SA1600:Elements should be documented",
Justification = "Internals")]
public class SettingsTabExperimental : SettingsTab
internal sealed class SettingsTabExperimental : SettingsTab
{
public override string Title => Loc.Localize("DalamudSettingsExperimental", "Experimental");
public override SettingsOpenKind Kind => SettingsOpenKind.Experimental;
public override SettingsEntry[] Entries { get; } =
[
new SettingsEntry<bool>(
Loc.Localize("DalamudSettingsPluginTest", "Get plugin testing builds"),
string.Format(
Loc.Localize(
"DalamudSettingsPluginTestHint",
"Receive testing prereleases for selected plugins.\nTo opt-in to testing builds for a plugin, you have to right click it in the \"{0}\" tab of the plugin installer and select \"{1}\"."),
PluginCategoryManager.Locs.Group_Installed,
PluginInstallerWindow.Locs.PluginContext_TestingOptIn),
("DalamudSettingsPluginTest", "Get plugin testing builds"),
("DalamudSettingsPluginTestHint", "Receive testing prereleases for selected plugins.\nTo opt-in to testing builds for a plugin, you have to right click it in the \"Installed Plugins\" tab of the plugin installer and select \"Receive plugin testing versions\"."),
c => c.DoPluginTest,
(v, c) => c.DoPluginTest = v),
new HintSettingsEntry(
Loc.Localize(
"DalamudSettingsPluginTestWarning",
"Testing plugins may contain bugs or crash your game. Please only enable this if you are aware of the risks."),
("DalamudSettingsPluginTestWarning", "Testing plugins may contain bugs or crash your game. Please only enable this if you are aware of the risks."),
ImGuiColors.DalamudRed),
new GapSettingsEntry(5),
new ButtonSettingsEntry(
Loc.Localize("DalamudSettingsClearHidden", "Clear hidden plugins"),
Loc.Localize(
"DalamudSettingsClearHiddenHint",
"Restore plugins you have previously hidden from the plugin installer."),
("DalamudSettingsClearHidden", "Clear hidden plugins"),
("DalamudSettingsClearHiddenHint", "Restore plugins you have previously hidden from the plugin installer."),
() =>
{
Service<DalamudConfiguration>.Get().HiddenPluginInternalName.Clear();
@ -56,23 +50,16 @@ public class SettingsTabExperimental : SettingsTab
new DevPluginsSettingsEntry(),
new SettingsEntry<bool>(
Loc.Localize(
"DalamudSettingEnableImGuiAsserts",
"Enable ImGui asserts"),
Loc.Localize(
"DalamudSettingEnableImGuiAssertsHint",
("DalamudSettingEnableImGuiAsserts", "Enable ImGui asserts"),
("DalamudSettingEnableImGuiAssertsHint",
"If this setting is enabled, a window containing further details will be shown when an internal assertion in ImGui fails.\nWe recommend enabling this when developing plugins. " +
"This setting does not persist and will reset when the game restarts.\nUse the setting below to enable it at startup."),
c => Service<InterfaceManager>.Get().ShowAsserts,
(v, _) => Service<InterfaceManager>.Get().ShowAsserts = v),
new SettingsEntry<bool>(
Loc.Localize(
"DalamudSettingEnableImGuiAssertsAtStartup",
"Always enable ImGui asserts at startup"),
Loc.Localize(
"DalamudSettingEnableImGuiAssertsAtStartupHint",
"This will enable ImGui asserts every time the game starts."),
("DalamudSettingEnableImGuiAssertsAtStartup", "Always enable ImGui asserts at startup"),
("DalamudSettingEnableImGuiAssertsAtStartupHint", "This will enable ImGui asserts every time the game starts."),
c => c.ImGuiAssertsEnabledAtStartup ?? false,
(v, c) => c.ImGuiAssertsEnabledAtStartup = v),
@ -83,10 +70,8 @@ public class SettingsTabExperimental : SettingsTab
new GapSettingsEntry(5, true),
new EnumSettingsEntry<ReShadeHandlingMode>(
Loc.Localize("DalamudSettingsReShadeHandlingMode", "ReShade handling mode"),
Loc.Localize(
"DalamudSettingsReShadeHandlingModeHint",
"You may try different options to work around problems you may encounter.\nRestart is required for changes to take effect."),
("DalamudSettingsReShadeHandlingMode", "ReShade handling mode"),
("DalamudSettingsReShadeHandlingModeHint", "You may try different options to work around problems you may encounter.\nRestart is required for changes to take effect."),
c => c.ReShadeHandlingMode,
(v, c) => c.ReShadeHandlingMode = v,
fallbackValue: ReShadeHandlingMode.Default,
@ -146,8 +131,6 @@ public class SettingsTabExperimental : SettingsTab
*/
];
public override string Title => Loc.Localize("DalamudSettingsExperimental", "Experimental");
public override void Draw()
{
base.Draw();

View file

@ -1,4 +1,4 @@
using System.Diagnostics.CodeAnalysis;
using System.Diagnostics.CodeAnalysis;
using CheapLoc;
using Dalamud.Game.Text;
@ -7,17 +7,21 @@ using Dalamud.Interface.Internal.Windows.Settings.Widgets;
namespace Dalamud.Interface.Internal.Windows.Settings.Tabs;
[SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1600:Elements should be documented", Justification = "Internals")]
public class SettingsTabGeneral : SettingsTab
internal sealed class SettingsTabGeneral : SettingsTab
{
public override string Title => Loc.Localize("DalamudSettingsGeneral", "General");
public override SettingsOpenKind Kind => SettingsOpenKind.General;
public override SettingsEntry[] Entries { get; } =
{
[
new LanguageChooserSettingsEntry(),
new GapSettingsEntry(5),
new EnumSettingsEntry<XivChatType>(
Loc.Localize("DalamudSettingsChannel", "Dalamud Chat Channel"),
Loc.Localize("DalamudSettingsChannelHint", "Select the chat channel that is to be used for general Dalamud messages."),
("DalamudSettingsChannel", "Dalamud Chat Channel"),
("DalamudSettingsChannelHint", "Select the chat channel that is to be used for general Dalamud messages."),
c => c.GeneralChatType,
(v, c) => c.GeneralChatType = v,
warning: v =>
@ -33,49 +37,47 @@ public class SettingsTabGeneral : SettingsTab
new GapSettingsEntry(5),
new SettingsEntry<bool>(
Loc.Localize("DalamudSettingsWaitForPluginsOnStartup", "Wait for plugins before game loads"),
Loc.Localize("DalamudSettingsWaitForPluginsOnStartupHint", "Do not let the game load, until plugins are loaded."),
("DalamudSettingsWaitForPluginsOnStartup", "Wait for plugins before game loads"),
("DalamudSettingsWaitForPluginsOnStartupHint", "Do not let the game load, until plugins are loaded."),
c => c.IsResumeGameAfterPluginLoad,
(v, c) => c.IsResumeGameAfterPluginLoad = v),
new SettingsEntry<bool>(
Loc.Localize("DalamudSettingsFlash", "Flash FFXIV window on duty pop"),
Loc.Localize("DalamudSettingsFlashHint", "Flash the FFXIV window in your task bar when a duty is ready."),
("DalamudSettingsFlash", "Flash FFXIV window on duty pop"),
("DalamudSettingsFlashHint", "Flash the FFXIV window in your task bar when a duty is ready."),
c => c.DutyFinderTaskbarFlash,
(v, c) => c.DutyFinderTaskbarFlash = v),
new SettingsEntry<bool>(
Loc.Localize("DalamudSettingsDutyFinderMessage", "Chatlog message on duty pop"),
Loc.Localize("DalamudSettingsDutyFinderMessageHint", "Send a message in FFXIV chat when a duty is ready."),
("DalamudSettingsDutyFinderMessage", "Chatlog message on duty pop"),
("DalamudSettingsDutyFinderMessageHint", "Send a message in FFXIV chat when a duty is ready."),
c => c.DutyFinderChatMessage,
(v, c) => c.DutyFinderChatMessage = v),
new SettingsEntry<bool>(
Loc.Localize("DalamudSettingsPrintDalamudWelcomeMsg", "Display Dalamud's welcome message"),
Loc.Localize("DalamudSettingsPrintDalamudWelcomeMsgHint", "Display Dalamud's welcome message in FFXIV chat when logging in with a character."),
("DalamudSettingsPrintDalamudWelcomeMsg", "Display Dalamud's welcome message"),
("DalamudSettingsPrintDalamudWelcomeMsgHint", "Display Dalamud's welcome message in FFXIV chat when logging in with a character."),
c => c.PrintDalamudWelcomeMsg,
(v, c) => c.PrintDalamudWelcomeMsg = v),
new SettingsEntry<bool>(
Loc.Localize("DalamudSettingsPrintPluginsWelcomeMsg", "Display loaded plugins in the welcome message"),
Loc.Localize("DalamudSettingsPrintPluginsWelcomeMsgHint", "Display loaded plugins in FFXIV chat when logging in with a character."),
("DalamudSettingsPrintPluginsWelcomeMsg", "Display loaded plugins in the welcome message"),
("DalamudSettingsPrintPluginsWelcomeMsgHint", "Display loaded plugins in FFXIV chat when logging in with a character."),
c => c.PrintPluginsWelcomeMsg,
(v, c) => c.PrintPluginsWelcomeMsg = v),
new SettingsEntry<bool>(
Loc.Localize("DalamudSettingsSystemMenu", "Dalamud buttons in system menu"),
Loc.Localize("DalamudSettingsSystemMenuMsgHint", "Add buttons for Dalamud plugins and settings to the system menu."),
("DalamudSettingsSystemMenu", "Dalamud buttons in system menu"),
("DalamudSettingsSystemMenuMsgHint", "Add buttons for Dalamud plugins and settings to the system menu."),
c => c.DoButtonsSystemMenu,
(v, c) => c.DoButtonsSystemMenu = v),
new GapSettingsEntry(5),
new SettingsEntry<bool>(
Loc.Localize("DalamudSettingDoMbCollect", "Anonymously upload market board data"),
Loc.Localize("DalamudSettingDoMbCollectHint", "Anonymously provide data about in-game economics to Universalis when browsing the market board. This data can't be tied to you in any way and everyone benefits!"),
("DalamudSettingDoMbCollect", "Anonymously upload market board data"),
("DalamudSettingDoMbCollectHint", "Anonymously provide data about in-game economics to Universalis when browsing the market board. This data can't be tied to you in any way and everyone benefits!"),
c => c.IsMbCollect,
(v, c) => c.IsMbCollect = v),
};
public override string Title => Loc.Localize("DalamudSettingsGeneral", "General");
];
}

View file

@ -7,13 +7,11 @@ using CheapLoc;
using Dalamud.Bindings.ImGui;
using Dalamud.Configuration.Internal;
using Dalamud.Game;
using Dalamud.Game.Text;
using Dalamud.Interface.Colors;
using Dalamud.Interface.FontIdentifier;
using Dalamud.Interface.GameFonts;
using Dalamud.Interface.ImGuiFontChooserDialog;
using Dalamud.Interface.ImGuiNotification.Internal;
using Dalamud.Interface.Internal.Windows.PluginInstaller;
using Dalamud.Interface.Internal.Windows.Settings.Widgets;
using Dalamud.Interface.ManagedFontAtlas.Internals;
using Dalamud.Interface.Utility;
@ -23,38 +21,42 @@ using Serilog;
namespace Dalamud.Interface.Internal.Windows.Settings.Tabs;
[SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1600:Elements should be documented", Justification = "Internals")]
public class SettingsTabLook : SettingsTab
internal sealed class SettingsTabLook : SettingsTab
{
private static readonly (string, float)[] GlobalUiScalePresets =
{
[
("80%##DalamudSettingsGlobalUiScaleReset96", 0.8f),
("100%##DalamudSettingsGlobalUiScaleReset12", 1f),
("117%##DalamudSettingsGlobalUiScaleReset14", 14 / 12f),
("150%##DalamudSettingsGlobalUiScaleReset18", 1.5f),
("200%##DalamudSettingsGlobalUiScaleReset24", 2f),
("300%##DalamudSettingsGlobalUiScaleReset36", 3f),
};
];
private float globalUiScale;
private IFontSpec defaultFontSpec = null!;
public override string Title => Loc.Localize("DalamudSettingsVisual", "Look & Feel");
public override SettingsOpenKind Kind => SettingsOpenKind.LookAndFeel;
public override SettingsEntry[] Entries { get; } =
[
new GapSettingsEntry(5, true),
new ButtonSettingsEntry(
Loc.Localize("DalamudSettingsOpenStyleEditor", "Open Style Editor"),
Loc.Localize("DalamudSettingsStyleEditorHint", "Modify the look & feel of Dalamud windows."),
("DalamudSettingsOpenStyleEditor", "Open Style Editor"),
("DalamudSettingsStyleEditorHint", "Modify the look & feel of Dalamud windows."),
() => Service<DalamudInterface>.Get().OpenStyleEditor()),
new ButtonSettingsEntry(
Loc.Localize("DalamudSettingsOpenNotificationEditor", "Modify Notification Position"),
Loc.Localize("DalamudSettingsNotificationEditorHint", "Choose where Dalamud notifications appear on the screen."),
("DalamudSettingsOpenNotificationEditor", "Modify Notification Position"),
("DalamudSettingsNotificationEditorHint", "Choose where Dalamud notifications appear on the screen."),
() => Service<NotificationManager>.Get().StartPositionChooser()),
new SettingsEntry<bool>(
Loc.Localize("DalamudSettingsUseDarkMode", "Use Windows immersive/dark mode"),
Loc.Localize("DalamudSettingsUseDarkModeHint", "This will cause the FFXIV window title bar to follow your preferred Windows color settings, and switch to dark mode if enabled."),
("DalamudSettingsUseDarkMode", "Use Windows immersive/dark mode"),
("DalamudSettingsUseDarkModeHint", "This will cause the FFXIV window title bar to follow your preferred Windows color settings, and switch to dark mode if enabled."),
c => c.WindowIsImmersive,
(v, c) => c.WindowIsImmersive = v,
b =>
@ -72,91 +74,87 @@ public class SettingsTabLook : SettingsTab
new GapSettingsEntry(5, true),
new HintSettingsEntry(Loc.Localize("DalamudSettingToggleUiHideOptOutNote", "Plugins may independently opt out of the settings below.")),
new HintSettingsEntry(("DalamudSettingToggleUiHideOptOutNote", "Plugins may independently opt out of the settings below.")),
new GapSettingsEntry(3),
new SettingsEntry<bool>(
Loc.Localize("DalamudSettingToggleUiHide", "Hide plugin UI when the game UI is toggled off"),
Loc.Localize("DalamudSettingToggleUiHideHint", "Hide any open windows by plugins when toggling the game overlay."),
("DalamudSettingToggleUiHide", "Hide plugin UI when the game UI is toggled off"),
("DalamudSettingToggleUiHideHint", "Hide any open windows by plugins when toggling the game overlay."),
c => c.ToggleUiHide,
(v, c) => c.ToggleUiHide = v),
new SettingsEntry<bool>(
Loc.Localize("DalamudSettingToggleUiHideDuringCutscenes", "Hide plugin UI during cutscenes"),
Loc.Localize("DalamudSettingToggleUiHideDuringCutscenesHint", "Hide any open windows by plugins during cutscenes."),
("DalamudSettingToggleUiHideDuringCutscenes", "Hide plugin UI during cutscenes"),
("DalamudSettingToggleUiHideDuringCutscenesHint", "Hide any open windows by plugins during cutscenes."),
c => c.ToggleUiHideDuringCutscenes,
(v, c) => c.ToggleUiHideDuringCutscenes = v),
new SettingsEntry<bool>(
Loc.Localize("DalamudSettingToggleUiHideDuringGpose", "Hide plugin UI while gpose is active"),
Loc.Localize("DalamudSettingToggleUiHideDuringGposeHint", "Hide any open windows by plugins while gpose is active."),
("DalamudSettingToggleUiHideDuringGpose", "Hide plugin UI while gpose is active"),
("DalamudSettingToggleUiHideDuringGposeHint", "Hide any open windows by plugins while gpose is active."),
c => c.ToggleUiHideDuringGpose,
(v, c) => c.ToggleUiHideDuringGpose = v),
new GapSettingsEntry(5, true),
new SettingsEntry<bool>(
Loc.Localize("DalamudSettingToggleFocusManagement", "Use escape to close Dalamud windows"),
Loc.Localize("DalamudSettingToggleFocusManagementHint", "This will cause Dalamud windows to behave like in-game windows when pressing escape.\nThey will close one after another until all are closed. May not work for all plugins."),
("DalamudSettingToggleFocusManagement", "Use escape to close Dalamud windows"),
("DalamudSettingToggleFocusManagementHint", "This will cause Dalamud windows to behave like in-game windows when pressing escape.\nThey will close one after another until all are closed. May not work for all plugins."),
c => c.IsFocusManagementEnabled,
(v, c) => c.IsFocusManagementEnabled = v),
// This is applied every frame in InterfaceManager::CheckViewportState()
new SettingsEntry<bool>(
Loc.Localize("DalamudSettingToggleViewports", "Enable multi-monitor windows"),
Loc.Localize("DalamudSettingToggleViewportsHint", "This will allow you move plugin windows onto other monitors.\nWill only work in Borderless Window or Windowed mode."),
("DalamudSettingToggleViewports", "Enable multi-monitor windows"),
("DalamudSettingToggleViewportsHint", "This will allow you move plugin windows onto other monitors.\nWill only work in Borderless Window or Windowed mode."),
c => !c.IsDisableViewport,
(v, c) => c.IsDisableViewport = !v),
new SettingsEntry<bool>(
Loc.Localize("DalamudSettingToggleDocking", "Enable window docking"),
Loc.Localize("DalamudSettingToggleDockingHint", "This will allow you to fuse and tab plugin windows."),
("DalamudSettingToggleDocking", "Enable window docking"),
("DalamudSettingToggleDockingHint", "This will allow you to fuse and tab plugin windows."),
c => c.IsDocking,
(v, c) => c.IsDocking = v),
new SettingsEntry<bool>(
Loc.Localize(
"DalamudSettingEnablePluginUIAdditionalOptions",
"Add a button to the title bar of plugin windows to open additional options"),
Loc.Localize(
"DalamudSettingEnablePluginUIAdditionalOptionsHint",
"This will allow you to pin certain plugin windows, make them clickthrough or adjust their opacity.\nThis may not be supported by all of your plugins. Contact the plugin author if you want them to support this feature."),
("DalamudSettingEnablePluginUIAdditionalOptions", "Add a button to the title bar of plugin windows to open additional options"),
("DalamudSettingEnablePluginUIAdditionalOptionsHint", "This will allow you to pin certain plugin windows, make them clickthrough or adjust their opacity.\nThis may not be supported by all of your plugins. Contact the plugin author if you want them to support this feature."),
c => c.EnablePluginUiAdditionalOptions,
(v, c) => c.EnablePluginUiAdditionalOptions = v),
new SettingsEntry<bool>(
Loc.Localize("DalamudSettingEnablePluginUISoundEffects", "Enable sound effects for plugin windows"),
Loc.Localize("DalamudSettingEnablePluginUISoundEffectsHint", "This will allow you to enable or disable sound effects generated by plugin user interfaces.\nThis is affected by your in-game `System Sounds` volume settings."),
("DalamudSettingEnablePluginUISoundEffects", "Enable sound effects for plugin windows"),
("DalamudSettingEnablePluginUISoundEffectsHint", "This will allow you to enable or disable sound effects generated by plugin user interfaces.\nThis is affected by your in-game `System Sounds` volume settings."),
c => c.EnablePluginUISoundEffects,
(v, c) => c.EnablePluginUISoundEffects = v),
new SettingsEntry<bool>(
Loc.Localize("DalamudSettingToggleGamepadNavigation", "Control plugins via gamepad"),
Loc.Localize("DalamudSettingToggleGamepadNavigationHint", "This will allow you to toggle between game and plugin navigation via L1+L3.\nToggle the PluginInstaller window via R3 if ImGui navigation is enabled."),
("DalamudSettingToggleGamepadNavigation", "Control plugins via gamepad"),
("DalamudSettingToggleGamepadNavigationHint", "This will allow you to toggle between game and plugin navigation via L1+L3.\nToggle the PluginInstaller window via R3 if ImGui navigation is enabled."),
c => c.IsGamepadNavigationEnabled,
(v, c) => c.IsGamepadNavigationEnabled = v),
new SettingsEntry<bool>(
Loc.Localize("DalamudSettingToggleTsm", "Show title screen menu"),
Loc.Localize("DalamudSettingToggleTsmHint", "This will allow you to access certain Dalamud and Plugin functionality from the title screen.\nDisabling this will also hide the Dalamud version text on the title screen."),
("DalamudSettingToggleTsm", "Show title screen menu"),
("DalamudSettingToggleTsmHint", "This will allow you to access certain Dalamud and Plugin functionality from the title screen.\nDisabling this will also hide the Dalamud version text on the title screen."),
c => c.ShowTsm,
(v, c) => c.ShowTsm = v),
new SettingsEntry<bool>(
Loc.Localize("DalamudSettingInstallerOpenDefault", "Open the Plugin Installer to the \"Installed Plugins\" tab by default"),
Loc.Localize("DalamudSettingInstallerOpenDefaultHint", "This will allow you to open the Plugin Installer to the \"Installed Plugins\" tab by default, instead of the \"Available Plugins\" tab."),
("DalamudSettingInstallerOpenDefault", "Open the Plugin Installer to the \"Installed Plugins\" tab by default"),
("DalamudSettingInstallerOpenDefaultHint", "This will allow you to open the Plugin Installer to the \"Installed Plugins\" tab by default, instead of the \"Available Plugins\" tab."),
c => c.PluginInstallerOpen == PluginInstallerOpenKind.InstalledPlugins,
(v, c) => c.PluginInstallerOpen = v ? PluginInstallerOpenKind.InstalledPlugins : PluginInstallerOpenKind.AllPlugins),
new SettingsEntry<bool>(
Loc.Localize("DalamudSettingReducedMotion", "Reduce motions"),
Loc.Localize("DalamudSettingReducedMotionHint", "This will suppress certain animations from Dalamud, such as the notification popup."),
("DalamudSettingReducedMotion", "Reduce motions"),
("DalamudSettingReducedMotionHint", "This will suppress certain animations from Dalamud, such as the notification popup."),
c => c.ReduceMotions ?? false,
(v, c) => c.ReduceMotions = v),
new SettingsEntry<float>(
Loc.Localize("DalamudSettingImeStateIndicatorOpacity", "IME State Indicator Opacity (CJK only)"),
Loc.Localize("DalamudSettingImeStateIndicatorOpacityHint", "When any of CJK IMEs is in use, the state of IME will be shown with the opacity specified here."),
("DalamudSettingImeStateIndicatorOpacity", "IME State Indicator Opacity (CJK only)"),
("DalamudSettingImeStateIndicatorOpacityHint", "When any of CJK IMEs is in use, the state of IME will be shown with the opacity specified here."),
c => c.ImeStateIndicatorOpacity,
(v, c) => c.ImeStateIndicatorOpacity = v)
{
@ -176,8 +174,6 @@ public class SettingsTabLook : SettingsTab
}
];
public override string Title => Loc.Localize("DalamudSettingsVisual", "Look & Feel");
public override void Draw()
{
var interfaceManager = Service<InterfaceManager>.Get();
@ -212,7 +208,7 @@ public class SettingsTabLook : SettingsTab
var p = stackalloc byte[len];
Encoding.UTF8.GetBytes(buildingFonts, new(p, len));
ImGui.Text(
new ReadOnlySpan<byte>(p, len)[..((len + ((Environment.TickCount / 200) % 3)) - 2)]);
new ReadOnlySpan<byte>(p, len)[..(len + (Environment.TickCount / 200 % 3) - 2)]);
}
}

View file

@ -1,18 +1,18 @@
using System.Diagnostics.CodeAnalysis;
using System.Diagnostics.CodeAnalysis;
using Dalamud.Bindings.ImGui;
using Dalamud.Interface.Colors;
using Dalamud.Interface.Utility;
using Dalamud.Utility.Internal;
namespace Dalamud.Interface.Internal.Windows.Settings.Widgets;
[SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1600:Elements should be documented", Justification = "Internals")]
public class ButtonSettingsEntry : SettingsEntry
internal sealed class ButtonSettingsEntry : SettingsEntry
{
private readonly string description;
private readonly LocRef description;
private readonly Action runs;
public ButtonSettingsEntry(string name, string description, Action runs)
public ButtonSettingsEntry(LocRef name, LocRef description, Action runs)
{
this.description = description;
this.runs = runs;

View file

@ -19,9 +19,9 @@ using Dalamud.Plugin.Internal;
namespace Dalamud.Interface.Internal.Windows.Settings.Widgets;
[SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1600:Elements should be documented", Justification = "Internals")]
public class DevPluginsSettingsEntry : SettingsEntry
internal sealed class DevPluginsSettingsEntry : SettingsEntry
{
private List<DevPluginLocationSettings> devPluginLocations = new();
private List<DevPluginLocationSettings> devPluginLocations = [];
private bool devPluginLocationsChanged;
private string devPluginTempLocation = string.Empty;
private string devPluginLocationAddError = string.Empty;
@ -29,25 +29,25 @@ public class DevPluginsSettingsEntry : SettingsEntry
public DevPluginsSettingsEntry()
{
this.Name = Loc.Localize("DalamudSettingsDevPluginLocation", "Dev Plugin Locations");
this.Name = ("DalamudSettingsDevPluginLocation", "Dev Plugin Locations");
}
public override void OnClose()
{
this.devPluginLocations =
Service<DalamudConfiguration>.Get().DevPluginLoadLocations.Select(x => x.Clone()).ToList();
[.. Service<DalamudConfiguration>.Get().DevPluginLoadLocations.Select(x => x.Clone())];
}
public override void Load()
{
this.devPluginLocations =
Service<DalamudConfiguration>.Get().DevPluginLoadLocations.Select(x => x.Clone()).ToList();
[.. Service<DalamudConfiguration>.Get().DevPluginLoadLocations.Select(x => x.Clone())];
this.devPluginLocationsChanged = false;
}
public override void Save()
{
Service<DalamudConfiguration>.Get().DevPluginLoadLocations = this.devPluginLocations.Select(x => x.Clone()).ToList();
Service<DalamudConfiguration>.Get().DevPluginLoadLocations = [.. this.devPluginLocations.Select(x => x.Clone())];
if (this.devPluginLocationsChanged)
{
@ -59,7 +59,9 @@ public class DevPluginsSettingsEntry : SettingsEntry
public override void Draw()
{
using var id = ImRaii.PushId("devPluginLocation"u8);
ImGui.Text(this.Name);
if (this.devPluginLocationsChanged)
{
using (ImRaii.PushColor(ImGuiCol.Text, ImGuiColors.HealerGreen))

View file

@ -1,7 +1,9 @@
using System.Diagnostics;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using CheapLoc;
using Dalamud.Bindings.ImGui;
using Dalamud.Configuration.Internal;
using Dalamud.Interface.Colors;
@ -23,8 +25,8 @@ internal sealed class EnumSettingsEntry<T> : SettingsEntry
private T valueBacking;
public EnumSettingsEntry(
string name,
string description,
(string Key, string Fallback) name,
(string Key, string Fallback) description,
LoadSettingDelegate load,
SaveSettingDelegate save,
Action<T>? change = null,
@ -61,7 +63,7 @@ internal sealed class EnumSettingsEntry<T> : SettingsEntry
}
}
public string Description { get; }
public (string Key, string Fallback) Description { get; }
public Action<EnumSettingsEntry<T>>? CustomDraw { get; init; }
@ -79,7 +81,10 @@ internal sealed class EnumSettingsEntry<T> : SettingsEntry
public override void Draw()
{
Debug.Assert(this.Name != null, "this.Name != null");
var name = Loc.Localize(this.Name.Key, this.Name.Fallback);
var description = Loc.Localize(this.Description.Key, this.Description.Fallback);
Debug.Assert(!string.IsNullOrWhiteSpace(name), "Name is empty");
if (this.CustomDraw is not null)
{
@ -87,7 +92,7 @@ internal sealed class EnumSettingsEntry<T> : SettingsEntry
}
else
{
ImGui.TextWrapped(this.Name);
ImGui.TextWrapped(name);
var idx = this.valueBacking;
var values = Enum.GetValues<T>();
@ -117,13 +122,14 @@ internal sealed class EnumSettingsEntry<T> : SettingsEntry
using (ImRaii.PushColor(ImGuiCol.Text, ImGuiColors.DalamudGrey))
{
var desc = this.FriendlyEnumDescriptionGetter(this.valueBacking);
if (!string.IsNullOrWhiteSpace(desc))
{
ImGui.TextWrapped(desc);
ImGuiHelpers.ScaledDummy(2);
}
ImGui.TextWrapped(this.Description);
ImGui.TextWrapped(description);
}
if (this.CheckValidity != null)

View file

@ -1,4 +1,4 @@
using System.Diagnostics.CodeAnalysis;
using System.Diagnostics.CodeAnalysis;
using Dalamud.Bindings.ImGui;
using Dalamud.Interface.Utility;
@ -6,7 +6,7 @@ using Dalamud.Interface.Utility;
namespace Dalamud.Interface.Internal.Windows.Settings.Widgets;
[SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1600:Elements should be documented", Justification = "Internals")]
public sealed class GapSettingsEntry : SettingsEntry
internal sealed class GapSettingsEntry : SettingsEntry
{
private readonly float size;
private readonly bool hr;

View file

@ -3,16 +3,17 @@ using System.Numerics;
using Dalamud.Bindings.ImGui;
using Dalamud.Interface.Colors;
using Dalamud.Utility.Internal;
namespace Dalamud.Interface.Internal.Windows.Settings.Widgets;
[SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1600:Elements should be documented", Justification = "Internals")]
public class HintSettingsEntry : SettingsEntry
internal sealed class HintSettingsEntry : SettingsEntry
{
private readonly string text;
private readonly LocRef text;
private readonly Vector4 color;
public HintSettingsEntry(string text, Vector4? color = null)
public HintSettingsEntry(LocRef text, Vector4? color = null)
{
this.text = text;
this.color = color ?? ImGuiColors.DalamudGrey;

View file

@ -6,12 +6,11 @@ using CheapLoc;
using Dalamud.Bindings.ImGui;
using Dalamud.Configuration.Internal;
using Dalamud.Interface.Colors;
using Dalamud.Interface.Utility;
namespace Dalamud.Interface.Internal.Windows.Settings.Widgets;
[SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1600:Elements should be documented", Justification = "Internals")]
public sealed class LanguageChooserSettingsEntry : SettingsEntry
internal sealed class LanguageChooserSettingsEntry : SettingsEntry
{
private readonly string[] languages;
private readonly string[] locLanguages;
@ -20,9 +19,9 @@ public sealed class LanguageChooserSettingsEntry : SettingsEntry
public LanguageChooserSettingsEntry()
{
this.languages = Localization.ApplicableLangCodes.Prepend("en").ToArray();
this.languages = [.. Localization.ApplicableLangCodes.Prepend("en")];
this.Name = Loc.Localize("DalamudSettingsLanguage", "Language");
this.Name = ("DalamudSettingsLanguage", "Language");
this.IsValid = true;
this.IsVisible = true;
@ -46,7 +45,7 @@ public sealed class LanguageChooserSettingsEntry : SettingsEntry
}
}
this.locLanguages = locLanguagesList.ToArray();
this.locLanguages = [.. locLanguagesList];
}
catch (Exception)
{

View file

@ -1,12 +1,12 @@
using System.Diagnostics;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.IO;
using Dalamud.Bindings.ImGui;
using Dalamud.Configuration.Internal;
using Dalamud.Interface.Colors;
using Dalamud.Interface.Utility;
using Dalamud.Interface.Utility.Raii;
using Dalamud.Utility.Internal;
namespace Dalamud.Interface.Internal.Windows.Settings.Widgets;
@ -20,8 +20,8 @@ internal sealed class SettingsEntry<T> : SettingsEntry
private object? valueBacking;
public SettingsEntry(
string name,
string description,
LocRef name,
LocRef description,
LoadSettingDelegate load,
SaveSettingDelegate save,
Action<T?>? change = null,
@ -55,7 +55,7 @@ internal sealed class SettingsEntry<T> : SettingsEntry
}
}
public string Description { get; }
public LocRef Description { get; }
public Action<SettingsEntry<T>>? CustomDraw { get; init; }
@ -69,7 +69,10 @@ internal sealed class SettingsEntry<T> : SettingsEntry
public override void Draw()
{
Debug.Assert(this.Name != null, "this.Name != null");
var name = this.Name.ToString();
var description = this.Description.ToString();
Debug.Assert(!string.IsNullOrWhiteSpace(name), "Name is empty");
var type = typeof(T);
@ -79,7 +82,7 @@ internal sealed class SettingsEntry<T> : SettingsEntry
}
else if (type == typeof(DirectoryInfo))
{
ImGui.TextWrapped(this.Name);
ImGui.TextWrapped(name);
var value = this.Value as DirectoryInfo;
var nativeBuffer = value?.FullName ?? string.Empty;
@ -91,7 +94,7 @@ internal sealed class SettingsEntry<T> : SettingsEntry
}
else if (type == typeof(string))
{
ImGui.TextWrapped(this.Name);
ImGui.TextWrapped(name);
var nativeBuffer = this.Value as string ?? string.Empty;
@ -104,16 +107,19 @@ internal sealed class SettingsEntry<T> : SettingsEntry
{
var nativeValue = this.Value as bool? ?? false;
if (ImGui.Checkbox($"{this.Name}###{this.Id.ToString()}", ref nativeValue))
if (ImGui.Checkbox($"{name}###{this.Id.ToString()}", ref nativeValue))
{
this.valueBacking = nativeValue;
this.change?.Invoke(this.Value);
}
}
using (ImRaii.PushColor(ImGuiCol.Text, ImGuiColors.DalamudGrey))
if (!string.IsNullOrWhiteSpace(description))
{
ImGui.TextWrapped(this.Description);
using (ImRaii.PushColor(ImGuiCol.Text, ImGuiColors.DalamudGrey))
{
ImGui.TextWrapped(this.Description);
}
}
if (this.CheckValidity != null)

View file

@ -18,9 +18,9 @@ using Dalamud.Utility;
namespace Dalamud.Interface.Internal.Windows.Settings.Widgets;
[SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1600:Elements should be documented", Justification = "Internals")]
public class ThirdRepoSettingsEntry : SettingsEntry
internal class ThirdRepoSettingsEntry : SettingsEntry
{
private List<ThirdPartyRepoSettings> thirdRepoList = new();
private List<ThirdPartyRepoSettings> thirdRepoList = [];
private bool thirdRepoListChanged;
private string thirdRepoTempUrl = string.Empty;
private string thirdRepoAddError = string.Empty;
@ -34,20 +34,20 @@ public class ThirdRepoSettingsEntry : SettingsEntry
public override void OnClose()
{
this.thirdRepoList =
Service<DalamudConfiguration>.Get().ThirdRepoList.Select(x => x.Clone()).ToList();
[.. Service<DalamudConfiguration>.Get().ThirdRepoList.Select(x => x.Clone())];
}
public override void Load()
{
this.thirdRepoList =
Service<DalamudConfiguration>.Get().ThirdRepoList.Select(x => x.Clone()).ToList();
[.. Service<DalamudConfiguration>.Get().ThirdRepoList.Select(x => x.Clone())];
this.thirdRepoListChanged = false;
}
public override void Save()
{
Service<DalamudConfiguration>.Get().ThirdRepoList =
this.thirdRepoList.Select(x => x.Clone()).ToList();
[.. this.thirdRepoList.Select(x => x.Clone())];
if (this.thirdRepoListChanged)
{

View file

@ -0,0 +1,25 @@
using CheapLoc;
using Dalamud.Bindings.ImGui;
namespace Dalamud.Utility.Internal;
/// <summary>
/// Represents a localization reference consisting of a key and a fallback text.
/// </summary>
/// <param name="Key">The localization key used to retrieve the localized text.</param>
/// <param name="Fallback">The fallback text to use if the localization key is not found.</param>
internal readonly record struct LocRef(string Key, string Fallback)
{
public static implicit operator LocRef((string Key, string Fallback) tuple)
=> new(tuple.Key, tuple.Fallback);
public static implicit operator ImU8String(LocRef locRef)
=> new(locRef.ToString());
/// <inheritdoc/>
public override string ToString()
{
return Loc.Localize(this.Key, this.Fallback);
}
}

View file

@ -301,7 +301,7 @@ public ref struct ImU8String
{
var startingPos = this.Length;
this.AppendFormatted(value, format);
FixAlignment(startingPos, alignment);
this.FixAlignment(startingPos, alignment);
}
public void AppendFormatted(ReadOnlySpan<char> value) => this.AppendFormatted(value, null);
@ -322,7 +322,7 @@ public ref struct ImU8String
{
var startingPos = this.Length;
this.AppendFormatted(value, format);
FixAlignment(startingPos, alignment);
this.FixAlignment(startingPos, alignment);
}
public void AppendFormatted(object? value) => this.AppendFormatted<object>(value!);
@ -358,13 +358,13 @@ public ref struct ImU8String
{
var startingPos = this.Length;
this.AppendFormatted(value, format);
FixAlignment(startingPos, alignment);
this.FixAlignment(startingPos, alignment);
}
public void Reserve(int length)
{
if (length >= AllocFreeBufferSize)
IncreaseBuffer(out _, length);
this.IncreaseBuffer(out _, length);
}
private void FixAlignment(int startingPos, int alignment)