antilag: Use last 5 frames, even on title screen with notif
This commit is contained in:
parent
ec59c46440
commit
fa05bb6383
4 changed files with 48 additions and 8 deletions
|
@ -176,9 +176,7 @@ public static class ResolutionScalingModeExt
|
|||
|
||||
public static bool IsBroken(this ResolutionScalingMode mode) => mode switch
|
||||
{
|
||||
#if !DEBUG
|
||||
ResolutionScalingMode.DLSS => true,
|
||||
#endif
|
||||
ResolutionScalingMode.DLSS => !Service.DebugConfig.IsDebug,
|
||||
_ => false
|
||||
};
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
using Dalamud.Game.ClientState.Keys;
|
||||
using Dalamud.Game.Config;
|
||||
using Dalamud.Interface.ImGuiNotification;
|
||||
using Dalamud.Plugin;
|
||||
using Dalamud.Plugin.Services;
|
||||
using ImGuiNET;
|
||||
|
@ -16,6 +17,9 @@ public sealed unsafe class Plugin : IDalamudPlugin
|
|||
private readonly List<Cmd> _cmds;
|
||||
private bool _ignoreConfigChanges = false;
|
||||
|
||||
private int _lagsIndex = 0;
|
||||
private readonly bool[] _lagsAll = new bool[5];
|
||||
|
||||
public Plugin(IDalamudPluginInterface pluginInterface)
|
||||
{
|
||||
pluginInterface.Create<Service>();
|
||||
|
@ -54,6 +58,9 @@ public sealed unsafe class Plugin : IDalamudPlugin
|
|||
|
||||
public bool Unloading { get; private set; } = false;
|
||||
|
||||
public int LagsTotal { get; private set; } = 0;
|
||||
public bool Lag { get; private set; } = false;
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Unloading = true;
|
||||
|
@ -80,10 +87,25 @@ public sealed unsafe class Plugin : IDalamudPlugin
|
|||
|
||||
private void OnFrameworkUpdateForSize(IFramework framework, string type, ref ConfigurationV1.SizeConfig size)
|
||||
{
|
||||
if (Service.ClientState.IsLoggedIn && framework.UpdateDelta.TotalSeconds >= 1 && Service.Config._.DisableOnHang && size.IsEnabled)
|
||||
if (Lag && Service.Config._.DisableOnHang && size.IsEnabled)
|
||||
{
|
||||
Service.PluginLog.Warning($"Disabling because hang: {type}");
|
||||
Service.PrintChat($"Lag detected, \"{type}\" custom resolution disabled.");
|
||||
if (Service.ClientState.IsLoggedIn)
|
||||
{
|
||||
Service.PrintChat($"Lag detected, \"{type}\" custom resolution disabled.");
|
||||
}
|
||||
else
|
||||
{
|
||||
// An initial duration of 15 might seem absurd, but we're dealing with lag here!
|
||||
Service.NotificationManager.AddNotification(new Notification()
|
||||
{
|
||||
Title = "CustomResolution",
|
||||
Content = $"Lag detected, \"{type}\" custom resolution disabled.",
|
||||
Type = NotificationType.Error,
|
||||
InitialDuration = TimeSpan.FromSeconds(framework.UpdateDelta.TotalSeconds + 15),
|
||||
Minimized = false
|
||||
});
|
||||
}
|
||||
size.IsEnabled = false;
|
||||
Service.Config.Save();
|
||||
}
|
||||
|
@ -114,6 +136,18 @@ public sealed unsafe class Plugin : IDalamudPlugin
|
|||
|
||||
private void OnFrameworkUpdate(IFramework framework)
|
||||
{
|
||||
if (_lagsAll[_lagsIndex])
|
||||
{
|
||||
LagsTotal--;
|
||||
}
|
||||
if (_lagsAll[_lagsIndex] = framework.UpdateDelta.TotalSeconds > 1.0)
|
||||
{
|
||||
LagsTotal++;
|
||||
}
|
||||
_lagsIndex = (_lagsIndex + 1) % _lagsAll.Length;
|
||||
|
||||
Lag = LagsTotal == _lagsAll.Length;
|
||||
|
||||
lock (_disposeLock)
|
||||
{
|
||||
OnFrameworkUpdateForSize(framework, "Display", ref Service.Config._.Display);
|
||||
|
|
|
@ -58,6 +58,9 @@ public sealed class Service
|
|||
[PluginService]
|
||||
public static IGameConfig GameConfig { get; private set; } = null!;
|
||||
|
||||
[PluginService]
|
||||
public static INotificationManager NotificationManager { get; private set; } = null!;
|
||||
|
||||
public static void PrintChat(string msg)
|
||||
{
|
||||
ChatGui.Print(new XivChatEntry
|
||||
|
|
|
@ -166,7 +166,7 @@ Changed via /gres");
|
|||
{
|
||||
using var border = ImRaii.PushColor(ImGuiCol.Border, 0xFF00FFFF);
|
||||
if (ImGui.Button(@$"Your game system configuration is currently stuck on
|
||||
an unsupported graphics upscaling option: {Service.GameSize.ConfigGraphicsRezoType}
|
||||
an unsupported graphics upscaling option: {Service.GameSize.ConfigGraphicsRezoType.ToHumanNameString()}
|
||||
|
||||
This can happen after you've replaced your GPU,
|
||||
or when your graphic driver has encountered problems.
|
||||
|
@ -330,11 +330,11 @@ Not intended to be used with proper fullscreen.");
|
|||
ImGui.EndCombo();
|
||||
}
|
||||
|
||||
ImGui.Checkbox("Game hang protection", ref _.DisableOnHang);
|
||||
ImGui.Checkbox("Disable on lag", ref _.DisableOnHang);
|
||||
|
||||
if (ImGui.IsItemHovered())
|
||||
{
|
||||
ImGui.SetTooltip(@$"Automatically disables scaling if the game hangs for more than a second.
|
||||
ImGui.SetTooltip(@$"Automatically disables scaling if FPS goes below 1 FPS.
|
||||
|
||||
Leave this option enabled if you want this plugin to disable itself as a protection
|
||||
in case the resolution changes unexpectedly, or in case the resolution goes too high.
|
||||
|
@ -348,5 +348,10 @@ In the absolute worst case, delete the following file to reset your settings:
|
|||
ImGui.Checkbox("DEBUG!", ref debug);
|
||||
Service.DebugConfig.IsDebug = debug;
|
||||
#endif
|
||||
|
||||
if (Service.DebugConfig.IsDebug)
|
||||
{
|
||||
ImGui.Text($"LAG: {Service.Plugin.LagsTotal} {Service.Plugin.Lag}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue