Add IME state indicator opacity setting (#1811)

This commit is contained in:
srkizer 2024-05-21 15:41:25 +09:00 committed by GitHub
parent eca40bc5dd
commit 0a219fcd82
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 99 additions and 32 deletions

View file

@ -6,6 +6,7 @@ using System.Text;
using CheapLoc;
using Dalamud.Configuration.Internal;
using Dalamud.Game;
using Dalamud.Game.Text;
using Dalamud.Interface.Colors;
using Dalamud.Interface.FontIdentifier;
using Dalamud.Interface.GameFonts;
@ -136,6 +137,27 @@ public class SettingsTabLook : SettingsTab
Loc.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."),
c => c.ImeStateIndicatorOpacity,
(v, c) => c.ImeStateIndicatorOpacity = v)
{
CustomDraw = static e =>
{
ImGuiHelpers.SafeTextWrapped(e.Name!);
var v = e.Value * 100f;
if (ImGui.SliderFloat($"###{e}", ref v, 0f, 100f, "%.1f%%"))
e.Value = v / 100f;
ImGui.SameLine();
ImGui.PushStyleVar(ImGuiStyleVar.Alpha, v / 100);
ImGui.TextUnformatted("\uE020\uE021\uE022\uE023\uE024\uE025\uE026\uE027");
ImGui.PopStyleVar(1);
},
},
};
public override string Title => Loc.Localize("DalamudSettingsVisual", "Look & Feel");

View file

@ -2,6 +2,7 @@
using System.Diagnostics.CodeAnalysis;
using System.IO;
using System.Linq;
using System.Numerics;
using Dalamud.Configuration.Internal;
@ -50,10 +51,22 @@ internal sealed class SettingsEntry<T> : SettingsEntry
public delegate void SaveSettingDelegate(T? value, DalamudConfiguration config);
public T? Value => this.valueBacking == default ? default : (T)this.valueBacking;
public T? Value
{
get => this.valueBacking == default ? default : (T)this.valueBacking;
set
{
if (Equals(value, this.valueBacking))
return;
this.valueBacking = value;
this.change?.Invoke(value);
}
}
public string Description { get; }
public Action<SettingsEntry<T>>? CustomDraw { get; init; }
public Func<T?, string?>? CheckValidity { get; init; }
public Func<T?, string?>? CheckWarning { get; init; }
@ -68,7 +81,11 @@ internal sealed class SettingsEntry<T> : SettingsEntry
var type = typeof(T);
if (type == typeof(DirectoryInfo))
if (this.CustomDraw is not null)
{
this.CustomDraw.Invoke(this);
}
else if (type == typeof(DirectoryInfo))
{
ImGuiHelpers.SafeTextWrapped(this.Name);