mirror of
https://github.com/goatcorp/Dalamud.git
synced 2026-01-03 14:23:40 +01:00
Add reshade unwrapping options
This commit is contained in:
parent
80ac97fea8
commit
d71fbc52fb
9 changed files with 513 additions and 75 deletions
|
|
@ -1,8 +1,10 @@
|
|||
using System.Diagnostics.CodeAnalysis;
|
||||
|
||||
using CheapLoc;
|
||||
|
||||
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;
|
||||
|
|
@ -11,28 +13,39 @@ using Dalamud.Utility;
|
|||
|
||||
namespace Dalamud.Interface.Internal.Windows.Settings.Tabs;
|
||||
|
||||
[SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1600:Elements should be documented", Justification = "Internals")]
|
||||
[SuppressMessage(
|
||||
"StyleCop.CSharp.DocumentationRules",
|
||||
"SA1600:Elements should be documented",
|
||||
Justification = "Internals")]
|
||||
public class SettingsTabExperimental : SettingsTab
|
||||
{
|
||||
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}\"."),
|
||||
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),
|
||||
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."),
|
||||
Loc.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 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."),
|
||||
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."),
|
||||
c => c.EnablePluginUiAdditionalOptions,
|
||||
(v, c) => c.EnablePluginUiAdditionalOptions = v),
|
||||
|
||||
|
|
@ -40,7 +53,9 @@ public class SettingsTabExperimental : SettingsTab
|
|||
|
||||
new ButtonSettingsEntry(
|
||||
Loc.Localize("DalamudSettingsClearHidden", "Clear hidden plugins"),
|
||||
Loc.Localize("DalamudSettingsClearHiddenHint", "Restore plugins you have previously hidden from the plugin installer."),
|
||||
Loc.Localize(
|
||||
"DalamudSettingsClearHiddenHint",
|
||||
"Restore plugins you have previously hidden from the plugin installer."),
|
||||
() =>
|
||||
{
|
||||
Service<DalamudConfiguration>.Get().HiddenPluginInternalName.Clear();
|
||||
|
|
@ -55,6 +70,45 @@ public class SettingsTabExperimental : SettingsTab
|
|||
|
||||
new ThirdRepoSettingsEntry(),
|
||||
|
||||
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."),
|
||||
c => c.ReShadeHandlingMode,
|
||||
(v, c) => c.ReShadeHandlingMode = v,
|
||||
fallbackValue: ReShadeHandlingMode.ReShadeAddon)
|
||||
{
|
||||
FriendlyEnumNameGetter = x => x switch
|
||||
{
|
||||
ReShadeHandlingMode.ReShadeAddon => Loc.Localize(
|
||||
"DalamudSettingsReShadeHandlingModeReShadeAddon",
|
||||
"ReShade addon"),
|
||||
ReShadeHandlingMode.UnwrapReShade => Loc.Localize(
|
||||
"DalamudSettingsReShadeHandlingModeUnwrapReShade",
|
||||
"Unwrap ReShade"),
|
||||
ReShadeHandlingMode.None => Loc.Localize(
|
||||
"DalamudSettingsReShadeHandlingModeNone",
|
||||
"Do not handle"),
|
||||
_ => "<invalid>",
|
||||
},
|
||||
FriendlyEnumDescriptionGetter = x => x switch
|
||||
{
|
||||
ReShadeHandlingMode.ReShadeAddon => Loc.Localize(
|
||||
"DalamudSettingsReShadeHandlingModeReShadeAddonDescription",
|
||||
"Dalamud will register itself as a ReShade addon. Most compatibility is expected, but multi-monitor window option won't work too well."),
|
||||
ReShadeHandlingMode.UnwrapReShade => Loc.Localize(
|
||||
"DalamudSettingsReShadeHandlingModeUnwrapReShadeDescription",
|
||||
"Dalamud will exclude itself from all ReShade handling. Multi-monitor windows should work fine with this mode, but it may not be supported and crash in future ReShade versions."),
|
||||
ReShadeHandlingMode.None => Loc.Localize(
|
||||
"DalamudSettingsReShadeHandlingModeNoneDescription",
|
||||
"No special handling will be done for ReShade. Dalamud will be under the effect of ReShade postprocessing."),
|
||||
_ => "<invalid>",
|
||||
},
|
||||
},
|
||||
|
||||
/* Disabling profiles after they've been enabled doesn't make much sense, at least not if the user has already created profiles.
|
||||
new GapSettingsEntry(5, true),
|
||||
|
||||
|
|
@ -64,7 +118,7 @@ public class SettingsTabExperimental : SettingsTab
|
|||
c => c.ProfilesEnabled,
|
||||
(v, c) => c.ProfilesEnabled = v),
|
||||
*/
|
||||
};
|
||||
];
|
||||
|
||||
public override string Title => Loc.Localize("DalamudSettingsExperimental", "Experimental");
|
||||
|
||||
|
|
@ -72,7 +126,9 @@ public class SettingsTabExperimental : SettingsTab
|
|||
{
|
||||
base.Draw();
|
||||
|
||||
ImGuiHelpers.SafeTextColoredWrapped(ImGuiColors.DalamudGrey, "Total memory used by Dalamud & Plugins: " + Util.FormatBytes(GC.GetTotalMemory(false)));
|
||||
ImGuiHelpers.SafeTextColoredWrapped(
|
||||
ImGuiColors.DalamudGrey,
|
||||
"Total memory used by Dalamud & Plugins: " + Util.FormatBytes(GC.GetTotalMemory(false)));
|
||||
ImGuiHelpers.ScaledDummy(15);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ public class SettingsTabGeneral : SettingsTab
|
|||
|
||||
new GapSettingsEntry(5),
|
||||
|
||||
new SettingsEntry<XivChatType>(
|
||||
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."),
|
||||
c => c.GeneralChatType,
|
||||
|
|
|
|||
|
|
@ -0,0 +1,175 @@
|
|||
using System.Diagnostics;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
|
||||
using Dalamud.Configuration.Internal;
|
||||
|
||||
using Dalamud.Interface.Colors;
|
||||
using Dalamud.Interface.Utility;
|
||||
using Dalamud.Interface.Utility.Raii;
|
||||
|
||||
using ImGuiNET;
|
||||
|
||||
namespace Dalamud.Interface.Internal.Windows.Settings.Widgets;
|
||||
|
||||
[SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1600:Elements should be documented", Justification = "Internals")]
|
||||
internal sealed class EnumSettingsEntry<T> : SettingsEntry
|
||||
where T : struct, Enum
|
||||
{
|
||||
private readonly LoadSettingDelegate load;
|
||||
private readonly SaveSettingDelegate save;
|
||||
private readonly Action<T>? change;
|
||||
|
||||
private readonly T fallbackValue;
|
||||
|
||||
private T valueBacking;
|
||||
|
||||
public EnumSettingsEntry(
|
||||
string name,
|
||||
string description,
|
||||
LoadSettingDelegate load,
|
||||
SaveSettingDelegate save,
|
||||
Action<T>? change = null,
|
||||
Func<T, string?>? warning = null,
|
||||
Func<T, string?>? validity = null,
|
||||
Func<bool>? visibility = null,
|
||||
T fallbackValue = default)
|
||||
{
|
||||
this.load = load;
|
||||
this.save = save;
|
||||
this.change = change;
|
||||
this.Name = name;
|
||||
this.Description = description;
|
||||
this.CheckWarning = warning;
|
||||
this.CheckValidity = validity;
|
||||
this.CheckVisibility = visibility;
|
||||
|
||||
this.fallbackValue = fallbackValue;
|
||||
}
|
||||
|
||||
public delegate T LoadSettingDelegate(DalamudConfiguration config);
|
||||
|
||||
public delegate void SaveSettingDelegate(T value, DalamudConfiguration config);
|
||||
|
||||
public T Value
|
||||
{
|
||||
get => this.valueBacking;
|
||||
set
|
||||
{
|
||||
if (Equals(value, this.valueBacking))
|
||||
return;
|
||||
this.valueBacking = value;
|
||||
this.change?.Invoke(value);
|
||||
}
|
||||
}
|
||||
|
||||
public string Description { get; }
|
||||
|
||||
public Action<EnumSettingsEntry<T>>? CustomDraw { get; init; }
|
||||
|
||||
public Func<T, string?>? CheckValidity { get; init; }
|
||||
|
||||
public Func<T, string?>? CheckWarning { get; init; }
|
||||
|
||||
public Func<bool>? CheckVisibility { get; init; }
|
||||
|
||||
public Func<T, string> FriendlyEnumNameGetter { get; init; } = x => x.ToString();
|
||||
|
||||
public Func<T, string> FriendlyEnumDescriptionGetter { get; init; } = _ => string.Empty;
|
||||
|
||||
public override bool IsVisible => this.CheckVisibility?.Invoke() ?? true;
|
||||
|
||||
public override void Draw()
|
||||
{
|
||||
Debug.Assert(this.Name != null, "this.Name != null");
|
||||
|
||||
if (this.CustomDraw is not null)
|
||||
{
|
||||
this.CustomDraw.Invoke(this);
|
||||
}
|
||||
else
|
||||
{
|
||||
ImGuiHelpers.SafeTextWrapped(this.Name);
|
||||
|
||||
var idx = this.valueBacking;
|
||||
var values = Enum.GetValues<T>();
|
||||
|
||||
if (!values.Contains(idx))
|
||||
{
|
||||
idx = Enum.IsDefined(this.fallbackValue)
|
||||
? this.fallbackValue
|
||||
: throw new InvalidOperationException("No fallback value for enum");
|
||||
this.valueBacking = idx;
|
||||
}
|
||||
|
||||
if (ImGui.BeginCombo($"###{this.Id.ToString()}", this.FriendlyEnumNameGetter(idx)))
|
||||
{
|
||||
foreach (var value in values)
|
||||
{
|
||||
if (ImGui.Selectable(this.FriendlyEnumNameGetter(value), idx.Equals(value)))
|
||||
{
|
||||
this.valueBacking = value;
|
||||
}
|
||||
}
|
||||
|
||||
ImGui.EndCombo();
|
||||
}
|
||||
}
|
||||
|
||||
using (ImRaii.PushColor(ImGuiCol.Text, ImGuiColors.DalamudGrey))
|
||||
{
|
||||
var desc = this.FriendlyEnumDescriptionGetter(this.valueBacking);
|
||||
if (!string.IsNullOrWhiteSpace(desc))
|
||||
{
|
||||
ImGuiHelpers.SafeTextWrapped(desc);
|
||||
ImGuiHelpers.ScaledDummy(2);
|
||||
}
|
||||
|
||||
ImGuiHelpers.SafeTextWrapped(this.Description);
|
||||
}
|
||||
|
||||
if (this.CheckValidity != null)
|
||||
{
|
||||
var validityMsg = this.CheckValidity.Invoke(this.Value);
|
||||
this.IsValid = string.IsNullOrEmpty(validityMsg);
|
||||
|
||||
if (!this.IsValid)
|
||||
{
|
||||
using (ImRaii.PushColor(ImGuiCol.Text, ImGuiColors.DalamudRed))
|
||||
{
|
||||
ImGui.Text(validityMsg);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.IsValid = true;
|
||||
}
|
||||
|
||||
var warningMessage = this.CheckWarning?.Invoke(this.Value);
|
||||
|
||||
if (warningMessage != null)
|
||||
{
|
||||
using (ImRaii.PushColor(ImGuiCol.Text, ImGuiColors.DalamudRed))
|
||||
{
|
||||
ImGui.Text(warningMessage);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override void Load()
|
||||
{
|
||||
this.valueBacking = this.load(Service<DalamudConfiguration>.Get());
|
||||
|
||||
if (this.CheckValidity != null)
|
||||
{
|
||||
this.IsValid = this.CheckValidity(this.Value) == null;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.IsValid = true;
|
||||
}
|
||||
}
|
||||
|
||||
public override void Save() => this.save(this.Value, Service<DalamudConfiguration>.Get());
|
||||
}
|
||||
|
|
@ -1,15 +1,13 @@
|
|||
using System.Diagnostics;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Numerics;
|
||||
|
||||
using Dalamud.Configuration.Internal;
|
||||
|
||||
using Dalamud.Interface.Colors;
|
||||
using Dalamud.Interface.Utility;
|
||||
using Dalamud.Interface.Utility.Raii;
|
||||
using Dalamud.Utility;
|
||||
|
||||
using ImGuiNET;
|
||||
|
||||
namespace Dalamud.Interface.Internal.Windows.Settings.Widgets;
|
||||
|
|
@ -22,7 +20,6 @@ internal sealed class SettingsEntry<T> : SettingsEntry
|
|||
private readonly Action<T?>? change;
|
||||
|
||||
private object? valueBacking;
|
||||
private object? fallbackValue;
|
||||
|
||||
public SettingsEntry(
|
||||
string name,
|
||||
|
|
@ -32,8 +29,7 @@ internal sealed class SettingsEntry<T> : SettingsEntry
|
|||
Action<T?>? change = null,
|
||||
Func<T?, string?>? warning = null,
|
||||
Func<T?, string?>? validity = null,
|
||||
Func<bool>? visibility = null,
|
||||
object? fallbackValue = null)
|
||||
Func<bool>? visibility = null)
|
||||
{
|
||||
this.load = load;
|
||||
this.save = save;
|
||||
|
|
@ -43,8 +39,6 @@ internal sealed class SettingsEntry<T> : SettingsEntry
|
|||
this.CheckWarning = warning;
|
||||
this.CheckValidity = validity;
|
||||
this.CheckVisibility = visibility;
|
||||
|
||||
this.fallbackValue = fallbackValue;
|
||||
}
|
||||
|
||||
public delegate T? LoadSettingDelegate(DalamudConfiguration config);
|
||||
|
|
@ -118,34 +112,6 @@ internal sealed class SettingsEntry<T> : SettingsEntry
|
|||
this.change?.Invoke(this.Value);
|
||||
}
|
||||
}
|
||||
else if (type.IsEnum)
|
||||
{
|
||||
ImGuiHelpers.SafeTextWrapped(this.Name);
|
||||
|
||||
var idx = (Enum)(this.valueBacking ?? 0);
|
||||
var values = Enum.GetValues(type);
|
||||
var descriptions =
|
||||
values.Cast<Enum>().ToDictionary(x => x, x => x.GetAttribute<SettingsAnnotationAttribute>() ?? new SettingsAnnotationAttribute(x.ToString(), string.Empty));
|
||||
|
||||
if (!descriptions.ContainsKey(idx))
|
||||
{
|
||||
idx = (Enum)this.fallbackValue ?? throw new Exception("No fallback value for enum");
|
||||
this.valueBacking = idx;
|
||||
}
|
||||
|
||||
if (ImGui.BeginCombo($"###{this.Id.ToString()}", descriptions[idx].FriendlyName))
|
||||
{
|
||||
foreach (Enum value in values)
|
||||
{
|
||||
if (ImGui.Selectable(descriptions[value].FriendlyName, idx.Equals(value)))
|
||||
{
|
||||
this.valueBacking = value;
|
||||
}
|
||||
}
|
||||
|
||||
ImGui.EndCombo();
|
||||
}
|
||||
}
|
||||
|
||||
using (ImRaii.PushColor(ImGuiCol.Text, ImGuiColors.DalamudGrey))
|
||||
{
|
||||
|
|
@ -197,18 +163,3 @@ internal sealed class SettingsEntry<T> : SettingsEntry
|
|||
|
||||
public override void Save() => this.save(this.Value, Service<DalamudConfiguration>.Get());
|
||||
}
|
||||
|
||||
[SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1600:Elements should be documented", Justification = "Internals")]
|
||||
[AttributeUsage(AttributeTargets.Field)]
|
||||
internal class SettingsAnnotationAttribute : Attribute
|
||||
{
|
||||
public SettingsAnnotationAttribute(string friendlyName, string description)
|
||||
{
|
||||
this.FriendlyName = friendlyName;
|
||||
this.Description = description;
|
||||
}
|
||||
|
||||
public string FriendlyName { get; set; }
|
||||
|
||||
public string Description { get; set; }
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue