mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-12 18:27:23 +01:00
Update Settings Window (#2400)
* Load new localization before firing change event * Update texts in SettingsWindow when locale changes * Localize settings search * Update settings search input - Disable when Credits are scrolling, so Search Results aren't shown instead - Select all on single click, as usual for a search bar * Remove unused IsVisible property * Fix General tab being unselected on language change * Fix search results throwing, oops * Missed using LocRef in EnumSettingsEntry * Set CultureInfo before loading locs * Change it to LazyLoc instead So CheapLoc can export localizations...
This commit is contained in:
parent
efaff769b5
commit
d61a35b81f
20 changed files with 341 additions and 283 deletions
|
|
@ -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 LazyLoc Name { get; protected set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether this entry is valid.
|
||||
|
|
|
|||
|
|
@ -1,19 +1,19 @@
|
|||
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 bool IsOpen { get; set; } = false;
|
||||
public abstract SettingsOpenKind Kind { get; }
|
||||
|
||||
public virtual bool IsVisible { get; } = true;
|
||||
public bool IsOpen { get; set; } = false;
|
||||
|
||||
public virtual void OnOpen()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -17,20 +17,19 @@ 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;
|
||||
|
||||
private SettingsTab setActiveTab = null!;
|
||||
private SettingsTab? setActiveTab;
|
||||
|
||||
/// <summary>
|
||||
/// 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,10 @@ internal class SettingsWindow : Window
|
|||
];
|
||||
}
|
||||
|
||||
private static string Title => Loc.Localize("DalamudSettingsHeader", "Dalamud Settings") + "###XlSettings2";
|
||||
|
||||
private SettingsTab? CurrentlyOpenTab => this.tabs.FirstOrDefault(tab => tab.IsOpen);
|
||||
|
||||
/// <summary>
|
||||
/// Open the settings window to the tab specified by <paramref name="kind"/>.
|
||||
/// </summary>
|
||||
|
|
@ -59,7 +62,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 +86,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 +109,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 +118,7 @@ internal class SettingsWindow : Window
|
|||
ImGui.GetIO().FontGlobalScale = configuration.GlobalUiScale;
|
||||
if (scaleChanged)
|
||||
{
|
||||
Service<InterfaceManager>.Get().InvokeGlobalScaleChanged();
|
||||
interfaceManager.InvokeGlobalScaleChanged();
|
||||
}
|
||||
|
||||
fontAtlasFactory.DefaultFontSpecOverride = null;
|
||||
|
|
@ -115,7 +126,7 @@ internal class SettingsWindow : Window
|
|||
if (rebuildFont)
|
||||
{
|
||||
interfaceManager.RebuildFonts();
|
||||
Service<InterfaceManager>.Get().InvokeFontChanged();
|
||||
interfaceManager.InvokeFontChanged();
|
||||
}
|
||||
|
||||
foreach (var settingsTab in this.tabs)
|
||||
|
|
@ -133,98 +144,29 @@ internal class SettingsWindow : Window
|
|||
this.isSearchInputPrefilled = false;
|
||||
this.searchInput = string.Empty;
|
||||
}
|
||||
|
||||
localization.LocalizationChanged -= this.OnLocalizationChanged;
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override void Draw()
|
||||
{
|
||||
ImGui.SetNextItemWidth(-1);
|
||||
using (ImRaii.Disabled(this.CurrentlyOpenTab is SettingsTabAbout))
|
||||
ImGui.InputTextWithHint("###searchInput"u8, Loc.Localize("DalamudSettingsSearchPlaceholder", "Search for settings..."), ref this.searchInput, 100, ImGuiInputTextFlags.AutoSelectAll);
|
||||
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 +198,88 @@ 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)
|
||||
{
|
||||
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(Loc.Localize("DalamudSettingsSearchResults", "Search Results"));
|
||||
if (!tab) return;
|
||||
|
||||
var any = false;
|
||||
|
||||
foreach (var settingsTab in this.tabs)
|
||||
{
|
||||
var eligible = settingsTab.Entries.Where(x => !x.Name.Key.IsNullOrEmpty() && x.Name.ToString().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, Loc.Localize("DalamudSettingsNoSearchResultsFound", "No results found..."));
|
||||
}
|
||||
|
||||
private void Save()
|
||||
|
|
@ -301,17 +321,9 @@ 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;
|
||||
this.setActiveTab = this.CurrentlyOpenTab;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
|
|
@ -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",
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -6,11 +6,11 @@ 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;
|
||||
using Dalamud.Utility;
|
||||
using Dalamud.Utility.Internal;
|
||||
|
||||
namespace Dalamud.Interface.Internal.Windows.Settings.Tabs;
|
||||
|
||||
|
|
@ -18,33 +18,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),
|
||||
LazyLoc.Localize("DalamudSettingsPluginTest", "Get plugin testing builds"),
|
||||
LazyLoc.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 \"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."),
|
||||
LazyLoc.Localize("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."),
|
||||
LazyLoc.Localize("DalamudSettingsClearHidden", "Clear hidden plugins"),
|
||||
LazyLoc.Localize("DalamudSettingsClearHiddenHint", "Restore plugins you have previously hidden from the plugin installer."),
|
||||
() =>
|
||||
{
|
||||
Service<DalamudConfiguration>.Get().HiddenPluginInternalName.Clear();
|
||||
|
|
@ -56,23 +51,16 @@ public class SettingsTabExperimental : SettingsTab
|
|||
new DevPluginsSettingsEntry(),
|
||||
|
||||
new SettingsEntry<bool>(
|
||||
Loc.Localize(
|
||||
"DalamudSettingEnableImGuiAsserts",
|
||||
"Enable ImGui asserts"),
|
||||
Loc.Localize(
|
||||
"DalamudSettingEnableImGuiAssertsHint",
|
||||
LazyLoc.Localize("DalamudSettingEnableImGuiAsserts", "Enable ImGui asserts"),
|
||||
LazyLoc.Localize("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."),
|
||||
LazyLoc.Localize("DalamudSettingEnableImGuiAssertsAtStartup", "Always enable ImGui asserts at startup"),
|
||||
LazyLoc.Localize("DalamudSettingEnableImGuiAssertsAtStartupHint", "This will enable ImGui asserts every time the game starts."),
|
||||
c => c.ImGuiAssertsEnabledAtStartup ?? false,
|
||||
(v, c) => c.ImGuiAssertsEnabledAtStartup = v),
|
||||
|
||||
|
|
@ -83,10 +71,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."),
|
||||
LazyLoc.Localize("DalamudSettingsReShadeHandlingMode", "ReShade handling mode"),
|
||||
LazyLoc.Localize("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 +132,6 @@ public class SettingsTabExperimental : SettingsTab
|
|||
*/
|
||||
];
|
||||
|
||||
public override string Title => Loc.Localize("DalamudSettingsExperimental", "Experimental");
|
||||
|
||||
public override void Draw()
|
||||
{
|
||||
base.Draw();
|
||||
|
|
|
|||
|
|
@ -1,23 +1,29 @@
|
|||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
|
||||
using CheapLoc;
|
||||
|
||||
using Dalamud.Game.Text;
|
||||
using Dalamud.Interface.Internal.Windows.Settings.Widgets;
|
||||
using Dalamud.Utility.Internal;
|
||||
|
||||
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."),
|
||||
LazyLoc.Localize("DalamudSettingsChannel", "Dalamud Chat Channel"),
|
||||
LazyLoc.Localize("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 +39,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."),
|
||||
LazyLoc.Localize("DalamudSettingsWaitForPluginsOnStartup", "Wait for plugins before game loads"),
|
||||
LazyLoc.Localize("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."),
|
||||
LazyLoc.Localize("DalamudSettingsFlash", "Flash FFXIV window on duty pop"),
|
||||
LazyLoc.Localize("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."),
|
||||
LazyLoc.Localize("DalamudSettingsDutyFinderMessage", "Chatlog message on duty pop"),
|
||||
LazyLoc.Localize("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."),
|
||||
LazyLoc.Localize("DalamudSettingsPrintDalamudWelcomeMsg", "Display Dalamud's welcome message"),
|
||||
LazyLoc.Localize("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."),
|
||||
LazyLoc.Localize("DalamudSettingsPrintPluginsWelcomeMsg", "Display loaded plugins in the welcome message"),
|
||||
LazyLoc.Localize("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."),
|
||||
LazyLoc.Localize("DalamudSettingsSystemMenu", "Dalamud buttons in system menu"),
|
||||
LazyLoc.Localize("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!"),
|
||||
LazyLoc.Localize("DalamudSettingDoMbCollect", "Anonymously upload market board data"),
|
||||
LazyLoc.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!"),
|
||||
c => c.IsMbCollect,
|
||||
(v, c) => c.IsMbCollect = v),
|
||||
};
|
||||
|
||||
public override string Title => Loc.Localize("DalamudSettingsGeneral", "General");
|
||||
];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,54 +7,58 @@ 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;
|
||||
using Dalamud.Utility;
|
||||
using Dalamud.Utility.Internal;
|
||||
|
||||
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."),
|
||||
LazyLoc.Localize("DalamudSettingsOpenStyleEditor", "Open Style Editor"),
|
||||
LazyLoc.Localize("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."),
|
||||
LazyLoc.Localize("DalamudSettingsOpenNotificationEditor", "Modify Notification Position"),
|
||||
LazyLoc.Localize("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."),
|
||||
LazyLoc.Localize("DalamudSettingsUseDarkMode", "Use Windows immersive/dark mode"),
|
||||
LazyLoc.Localize("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 +76,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(LazyLoc.Localize("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."),
|
||||
LazyLoc.Localize("DalamudSettingToggleUiHide", "Hide plugin UI when the game UI is toggled off"),
|
||||
LazyLoc.Localize("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."),
|
||||
LazyLoc.Localize("DalamudSettingToggleUiHideDuringCutscenes", "Hide plugin UI during cutscenes"),
|
||||
LazyLoc.Localize("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."),
|
||||
LazyLoc.Localize("DalamudSettingToggleUiHideDuringGpose", "Hide plugin UI while gpose is active"),
|
||||
LazyLoc.Localize("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."),
|
||||
LazyLoc.Localize("DalamudSettingToggleFocusManagement", "Use escape to close Dalamud windows"),
|
||||
LazyLoc.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."),
|
||||
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."),
|
||||
LazyLoc.Localize("DalamudSettingToggleViewports", "Enable multi-monitor windows"),
|
||||
LazyLoc.Localize("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."),
|
||||
LazyLoc.Localize("DalamudSettingToggleDocking", "Enable window docking"),
|
||||
LazyLoc.Localize("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."),
|
||||
LazyLoc.Localize("DalamudSettingEnablePluginUIAdditionalOptions", "Add a button to the title bar of plugin windows to open additional options"),
|
||||
LazyLoc.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."),
|
||||
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."),
|
||||
LazyLoc.Localize("DalamudSettingEnablePluginUISoundEffects", "Enable sound effects for plugin windows"),
|
||||
LazyLoc.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."),
|
||||
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."),
|
||||
LazyLoc.Localize("DalamudSettingToggleGamepadNavigation", "Control plugins via gamepad"),
|
||||
LazyLoc.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."),
|
||||
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."),
|
||||
LazyLoc.Localize("DalamudSettingToggleTsm", "Show title screen menu"),
|
||||
LazyLoc.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."),
|
||||
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."),
|
||||
LazyLoc.Localize("DalamudSettingInstallerOpenDefault", "Open the Plugin Installer to the \"Installed Plugins\" tab by default"),
|
||||
LazyLoc.Localize("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."),
|
||||
LazyLoc.Localize("DalamudSettingReducedMotion", "Reduce motions"),
|
||||
LazyLoc.Localize("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."),
|
||||
LazyLoc.Localize("DalamudSettingImeStateIndicatorOpacity", "IME State Indicator Opacity (CJK only)"),
|
||||
LazyLoc.Localize("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 +176,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 +210,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)]);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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 LazyLoc description;
|
||||
private readonly Action runs;
|
||||
|
||||
public ButtonSettingsEntry(string name, string description, Action runs)
|
||||
public ButtonSettingsEntry(LazyLoc name, LazyLoc description, Action runs)
|
||||
{
|
||||
this.description = description;
|
||||
this.runs = runs;
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ using System.Numerics;
|
|||
using System.Threading.Tasks;
|
||||
|
||||
using CheapLoc;
|
||||
|
||||
using Dalamud.Bindings.ImGui;
|
||||
using Dalamud.Configuration;
|
||||
using Dalamud.Configuration.Internal;
|
||||
|
|
@ -15,13 +16,14 @@ using Dalamud.Interface.ImGuiFileDialog;
|
|||
using Dalamud.Interface.Utility;
|
||||
using Dalamud.Interface.Utility.Raii;
|
||||
using Dalamud.Plugin.Internal;
|
||||
using Dalamud.Utility.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 +31,25 @@ public class DevPluginsSettingsEntry : SettingsEntry
|
|||
|
||||
public DevPluginsSettingsEntry()
|
||||
{
|
||||
this.Name = Loc.Localize("DalamudSettingsDevPluginLocation", "Dev Plugin Locations");
|
||||
this.Name = LazyLoc.Localize("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 +61,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))
|
||||
|
|
|
|||
|
|
@ -1,12 +1,15 @@
|
|||
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;
|
||||
using Dalamud.Interface.Utility;
|
||||
using Dalamud.Interface.Utility.Raii;
|
||||
using Dalamud.Utility.Internal;
|
||||
|
||||
namespace Dalamud.Interface.Internal.Windows.Settings.Widgets;
|
||||
|
||||
|
|
@ -23,8 +26,8 @@ internal sealed class EnumSettingsEntry<T> : SettingsEntry
|
|||
private T valueBacking;
|
||||
|
||||
public EnumSettingsEntry(
|
||||
string name,
|
||||
string description,
|
||||
LazyLoc name,
|
||||
LazyLoc description,
|
||||
LoadSettingDelegate load,
|
||||
SaveSettingDelegate save,
|
||||
Action<T>? change = null,
|
||||
|
|
@ -61,7 +64,7 @@ internal sealed class EnumSettingsEntry<T> : SettingsEntry
|
|||
}
|
||||
}
|
||||
|
||||
public string Description { get; }
|
||||
public LazyLoc Description { get; }
|
||||
|
||||
public Action<EnumSettingsEntry<T>>? CustomDraw { get; init; }
|
||||
|
||||
|
|
@ -79,7 +82,10 @@ internal sealed class EnumSettingsEntry<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");
|
||||
|
||||
if (this.CustomDraw is not null)
|
||||
{
|
||||
|
|
@ -87,7 +93,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 +123,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)
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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 LazyLoc text;
|
||||
private readonly Vector4 color;
|
||||
|
||||
public HintSettingsEntry(string text, Vector4? color = null)
|
||||
public HintSettingsEntry(LazyLoc text, Vector4? color = null)
|
||||
{
|
||||
this.text = text;
|
||||
this.color = color ?? ImGuiColors.DalamudGrey;
|
||||
|
|
|
|||
|
|
@ -3,15 +3,16 @@ using System.Diagnostics.CodeAnalysis;
|
|||
using System.Linq;
|
||||
|
||||
using CheapLoc;
|
||||
|
||||
using Dalamud.Bindings.ImGui;
|
||||
using Dalamud.Configuration.Internal;
|
||||
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 sealed class LanguageChooserSettingsEntry : SettingsEntry
|
||||
internal sealed class LanguageChooserSettingsEntry : SettingsEntry
|
||||
{
|
||||
private readonly string[] languages;
|
||||
private readonly string[] locLanguages;
|
||||
|
|
@ -20,9 +21,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 = LazyLoc.Localize("DalamudSettingsLanguage", "Language");
|
||||
this.IsValid = true;
|
||||
this.IsVisible = true;
|
||||
|
||||
|
|
@ -46,7 +47,7 @@ public sealed class LanguageChooserSettingsEntry : SettingsEntry
|
|||
}
|
||||
}
|
||||
|
||||
this.locLanguages = locLanguagesList.ToArray();
|
||||
this.locLanguages = [.. locLanguagesList];
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
LazyLoc name,
|
||||
LazyLoc description,
|
||||
LoadSettingDelegate load,
|
||||
SaveSettingDelegate save,
|
||||
Action<T?>? change = null,
|
||||
|
|
@ -55,7 +55,7 @@ internal sealed class SettingsEntry<T> : SettingsEntry
|
|||
}
|
||||
}
|
||||
|
||||
public string Description { get; }
|
||||
public LazyLoc 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)
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -112,11 +112,14 @@ public class Localization : IServiceType
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set up the UI language with "fallbacks"(original English text).
|
||||
/// Set up the UI language with "fallbacks" (original English text).
|
||||
/// </summary>
|
||||
public void SetupWithFallbacks()
|
||||
{
|
||||
this.DalamudLanguageCultureInfo = CultureInfo.InvariantCulture;
|
||||
|
||||
Loc.SetupWithFallbacks(this.assembly);
|
||||
|
||||
foreach (var d in Delegate.EnumerateInvocationList(this.LocalizationChanged))
|
||||
{
|
||||
try
|
||||
|
|
@ -128,8 +131,6 @@ public class Localization : IServiceType
|
|||
Log.Error(ex, "Exception during raise of {handler}", d.Method);
|
||||
}
|
||||
}
|
||||
|
||||
Loc.SetupWithFallbacks(this.assembly);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -145,6 +146,17 @@ public class Localization : IServiceType
|
|||
}
|
||||
|
||||
this.DalamudLanguageCultureInfo = GetCultureInfoFromLangCode(langCode);
|
||||
|
||||
try
|
||||
{
|
||||
Loc.Setup(this.ReadLocData(langCode), this.assembly);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex, "Could not load loc {0}. Setting up fallbacks.", langCode);
|
||||
this.SetupWithFallbacks();
|
||||
}
|
||||
|
||||
foreach (var d in Delegate.EnumerateInvocationList(this.LocalizationChanged))
|
||||
{
|
||||
try
|
||||
|
|
@ -156,16 +168,6 @@ public class Localization : IServiceType
|
|||
Log.Error(ex, "Exception during raise of {handler}", d.Method);
|
||||
}
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
Loc.Setup(this.ReadLocData(langCode), this.assembly);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex, "Could not load loc {0}. Setting up fallbacks.", langCode);
|
||||
this.SetupWithFallbacks();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
|||
31
Dalamud/Utility/Internal/LazyLoc.cs
Normal file
31
Dalamud/Utility/Internal/LazyLoc.cs
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
using CheapLoc;
|
||||
|
||||
using Dalamud.Bindings.ImGui;
|
||||
|
||||
namespace Dalamud.Utility.Internal;
|
||||
|
||||
/// <summary>
|
||||
/// Represents a lazily localized string, consisting of a localization key and a fallback value.
|
||||
/// </summary>
|
||||
/// <param name="Key">The localization key used to retrieve the localized value.</param>
|
||||
/// <param name="Fallback">The fallback text to use if the localization key is not found.</param>
|
||||
internal readonly record struct LazyLoc(string Key, string Fallback)
|
||||
{
|
||||
public static implicit operator ImU8String(LazyLoc locRef)
|
||||
=> new(locRef.ToString());
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new instance of <see cref="LazyLoc"/> with the specified localization key and fallback text.
|
||||
/// </summary>
|
||||
/// <param name="key">The localization key used to retrieve the localized value.</param>
|
||||
/// <param name="fallback">The fallback text to use if the localization key is not found.</param>
|
||||
/// <returns>A <see cref="LazyLoc"/> instance representing the localized value.</returns>
|
||||
public static LazyLoc Localize(string key, string fallback)
|
||||
=> new(key, fallback);
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override string ToString()
|
||||
{
|
||||
return Loc.Localize(this.Key, this.Fallback);
|
||||
}
|
||||
}
|
||||
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue