feat: respect game sound mixer settings for sfx

This commit is contained in:
goaaats 2022-04-01 03:03:59 +02:00
parent 77b0a1f4e5
commit 691c256d60
No known key found for this signature in database
GPG key ID: 49E2AA8C6A76498B
2 changed files with 51 additions and 2 deletions

View file

@ -279,7 +279,7 @@ namespace Dalamud
var offset = timeZone.GetUtcOffset(DateTime.UtcNow);
var config = Service<DalamudConfiguration>.Get();
config.Fools22New = offset.Hours < 1;
config.Fools22New ??= offset.Hours < 1;
config.Save();
this.fools22 = new Fools22();

View file

@ -17,6 +17,7 @@ using Dalamud.Interface;
using Dalamud.Interface.Animation;
using Dalamud.Interface.Animation.EasingFunctions;
using Dalamud.Interface.Internal;
using Dalamud.Memory;
using Dalamud.Utility;
using ImGuiNET;
using ImGuiScene;
@ -313,7 +314,10 @@ public class Fools22 : IDisposable
this.time.Reset();
this.time.Start();
this.player.Play();
if (this.CheckIsSfxEnabled())
{
this.player.Play();
}
}
private bool CheckFoolsApplicable()
@ -329,6 +333,51 @@ public class Fools22 : IDisposable
return this.assetsReady;
}
private unsafe bool CheckIsSfxEnabled()
{
try
{
var framework = FFXIVClientStructs.FFXIV.Client.System.Framework.Framework.Instance();
var configBase = framework->SystemConfig.CommonSystemConfig.ConfigBase;
var seEnabled = false;
var masterEnabled = false;
for (var i = 0; i < configBase.ConfigCount; i++)
{
var entry = configBase.ConfigEntry[i];
if (entry.Name != null)
{
var name = MemoryHelper.ReadStringNullTerminated(new IntPtr(entry.Name));
if (name == "IsSndSe")
{
var value = entry.Value.UInt;
Log.Information("Fools21: {Name} - {Type} - {Value}", name, entry.Type, value);
seEnabled = value == 0;
}
if (name == "IsSndMaster")
{
var value = entry.Value.UInt;
Log.Information("Fools21: {Name} - {Type} - {Value}", name, entry.Type, value);
masterEnabled = value == 0;
}
}
}
return seEnabled && masterEnabled;
}
catch (Exception ex)
{
Log.Error(ex, "Fools21: Error checking if sfx is enabled");
return true;
}
}
public void Dispose()
{
this.erDeathBgTexture.Dispose();