Merge branch 'apiX' into feature/itextureprovider-updates

This commit is contained in:
Soreepeong 2024-05-12 22:17:32 +09:00
commit 8c7771bf7d
2213 changed files with 10372 additions and 1088868 deletions

View file

@ -1,8 +1,10 @@
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
using Dalamud.Game.Text;
using Dalamud.Interface.FontIdentifier;
@ -26,7 +28,7 @@ namespace Dalamud.Configuration.Internal;
#pragma warning disable SA1015
[InherentDependency<ReliableFileStorage>] // We must still have this when unloading
#pragma warning restore SA1015
internal sealed class DalamudConfiguration : IServiceType, IDisposable
internal sealed class DalamudConfiguration : IInternalDisposableService
{
private static readonly JsonSerializerSettings SerializerSettings = new()
{
@ -367,6 +369,11 @@ internal sealed class DalamudConfiguration : IServiceType, IDisposable
/// </summary>
public bool ShowTsm { get; set; } = true;
/// <summary>
/// Gets or sets a value indicating whether to reduce motions (animations).
/// </summary>
public bool? ReduceMotions { get; set; }
/// <summary>
/// Gets or sets a value indicating whether or not market board data should be uploaded.
/// </summary>
@ -484,6 +491,15 @@ internal sealed class DalamudConfiguration : IServiceType, IDisposable
deserialized ??= new DalamudConfiguration();
deserialized.configPath = path;
try
{
deserialized.SetDefaults();
}
catch (Exception e)
{
Log.Error(e, "Failed to set defaults for DalamudConfiguration");
}
return deserialized;
}
@ -505,7 +521,7 @@ internal sealed class DalamudConfiguration : IServiceType, IDisposable
}
/// <inheritdoc/>
public void Dispose()
void IInternalDisposableService.DisposeService()
{
// Make sure that we save, if a save is queued while we are shutting down
this.Update();
@ -525,6 +541,31 @@ internal sealed class DalamudConfiguration : IServiceType, IDisposable
}
}
private void SetDefaults()
{
// "Reduced motion"
if (!this.ReduceMotions.HasValue)
{
// https://source.chromium.org/chromium/chromium/src/+/main:ui/gfx/animation/animation_win.cc;l=29?q=ReducedMotion&ss=chromium
var winAnimEnabled = 0;
var success = NativeFunctions.SystemParametersInfo(
(uint)NativeFunctions.AccessibilityParameter.SPI_GETCLIENTAREAANIMATION,
0,
ref winAnimEnabled,
0);
if (!success)
{
Log.Warning("Failed to get Windows animation setting, assuming reduced motion is off (GetLastError: {GetLastError:X})", Marshal.GetLastPInvokeError());
this.ReduceMotions = false;
}
else
{
this.ReduceMotions = winAnimEnabled == 0;
}
}
}
private void Save()
{
ThreadSafety.AssertMainThread();

View file

@ -1,4 +1,5 @@
using System;
using System.Collections.Generic;
namespace Dalamud.Configuration.Internal;
@ -21,4 +22,9 @@ internal sealed class DevPluginSettings
/// Gets or sets an ID uniquely identifying this specific instance of a devPlugin.
/// </summary>
public Guid WorkingPluginId { get; set; } = Guid.Empty;
/// <summary>
/// Gets or sets a list of validation problems that have been dismissed by the user.
/// </summary>
public List<string> DismissedValidationProblems { get; set; } = new();
}