mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-12 18:27:23 +01:00
Merge pull request #1145 from kalilistic/hitch
This commit is contained in:
commit
3cbdcccfe4
6 changed files with 115 additions and 5 deletions
|
|
@ -351,6 +351,26 @@ internal sealed class DalamudConfiguration : IServiceType
|
|||
/// </summary>
|
||||
public bool WindowIsImmersive { get; set; } = false;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets hitch threshold for game network up in milliseconds.
|
||||
/// </summary>
|
||||
public double GameNetworkUpHitch { get; set; } = 30;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets hitch threshold for game network down in milliseconds.
|
||||
/// </summary>
|
||||
public double GameNetworkDownHitch { get; set; } = 30;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets hitch threshold for framework update in milliseconds.
|
||||
/// </summary>
|
||||
public double FrameworkUpdateHitch { get; set; } = 50;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets hitch threshold for ui builder in milliseconds.
|
||||
/// </summary>
|
||||
public double UiBuilderHitch { get; set; } = 100;
|
||||
|
||||
/// <summary>
|
||||
/// Load a configuration from the provided path.
|
||||
/// </summary>
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ public sealed class Framework : IDisposable, IServiceType
|
|||
private static Stopwatch statsStopwatch = new();
|
||||
|
||||
private readonly Stopwatch updateStopwatch = new();
|
||||
private readonly HitchDetector hitchDetector = new("FrameworkUpdate", 50);
|
||||
private readonly HitchDetector hitchDetector;
|
||||
|
||||
private readonly Hook<OnUpdateDetour> updateHook;
|
||||
private readonly Hook<OnRealDestroyDelegate> destroyHook;
|
||||
|
|
@ -39,9 +39,14 @@ public sealed class Framework : IDisposable, IServiceType
|
|||
|
||||
private Thread? frameworkUpdateThread;
|
||||
|
||||
[ServiceManager.ServiceDependency]
|
||||
private readonly DalamudConfiguration configuration = Service<DalamudConfiguration>.Get();
|
||||
|
||||
[ServiceManager.ServiceConstructor]
|
||||
private Framework(SigScanner sigScanner)
|
||||
{
|
||||
this.hitchDetector = new HitchDetector("FrameworkUpdate", this.configuration.FrameworkUpdateHitch);
|
||||
|
||||
this.Address = new FrameworkAddressResolver();
|
||||
this.Address.Setup(sigScanner);
|
||||
|
||||
|
|
|
|||
|
|
@ -1,12 +1,13 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
using Dalamud.Configuration.Internal;
|
||||
using Dalamud.Hooking;
|
||||
using Dalamud.IoC;
|
||||
using Dalamud.IoC.Internal;
|
||||
using Dalamud.Utility;
|
||||
using Serilog;
|
||||
using Serilog.Core;
|
||||
|
||||
namespace Dalamud.Game.Network;
|
||||
|
||||
|
|
@ -22,14 +23,20 @@ public sealed class GameNetwork : IDisposable, IServiceType
|
|||
private readonly Hook<ProcessZonePacketDownDelegate> processZonePacketDownHook;
|
||||
private readonly Hook<ProcessZonePacketUpDelegate> processZonePacketUpHook;
|
||||
|
||||
private readonly HitchDetector hitchDetectorUp = new("GameNetworkUp", 30);
|
||||
private readonly HitchDetector hitchDetectorDown = new("GameNetworkDown", 30);
|
||||
private readonly HitchDetector hitchDetectorUp;
|
||||
private readonly HitchDetector hitchDetectorDown;
|
||||
|
||||
private IntPtr baseAddress;
|
||||
|
||||
[ServiceManager.ServiceDependency]
|
||||
private readonly DalamudConfiguration configuration = Service<DalamudConfiguration>.Get();
|
||||
|
||||
[ServiceManager.ServiceConstructor]
|
||||
private GameNetwork(SigScanner sigScanner)
|
||||
{
|
||||
this.hitchDetectorUp = new HitchDetector("GameNetworkUp", this.configuration.GameNetworkUpHitch);
|
||||
this.hitchDetectorDown = new HitchDetector("GameNetworkDown", this.configuration.GameNetworkDownHitch);
|
||||
|
||||
this.address = new GameNetworkAddressResolver();
|
||||
this.address.Setup(sigScanner);
|
||||
|
||||
|
|
|
|||
|
|
@ -61,6 +61,7 @@ internal class DalamudInterface : IDisposable, IServiceType
|
|||
private readonly TitleScreenMenuWindow titleScreenMenuWindow;
|
||||
private readonly ProfilerWindow profilerWindow;
|
||||
private readonly BranchSwitcherWindow branchSwitcherWindow;
|
||||
private readonly HitchSettingsWindow hitchSettingsWindow;
|
||||
|
||||
private readonly TextureWrap logoTexture;
|
||||
private readonly TextureWrap tsmLogoTexture;
|
||||
|
|
@ -108,6 +109,7 @@ internal class DalamudInterface : IDisposable, IServiceType
|
|||
this.titleScreenMenuWindow = new TitleScreenMenuWindow() { IsOpen = false };
|
||||
this.profilerWindow = new ProfilerWindow() { IsOpen = false };
|
||||
this.branchSwitcherWindow = new BranchSwitcherWindow() { IsOpen = false };
|
||||
this.hitchSettingsWindow = new HitchSettingsWindow() { IsOpen = false };
|
||||
|
||||
this.WindowSystem.AddWindow(this.changelogWindow);
|
||||
this.WindowSystem.AddWindow(this.colorDemoWindow);
|
||||
|
|
@ -124,6 +126,7 @@ internal class DalamudInterface : IDisposable, IServiceType
|
|||
this.WindowSystem.AddWindow(this.titleScreenMenuWindow);
|
||||
this.WindowSystem.AddWindow(this.profilerWindow);
|
||||
this.WindowSystem.AddWindow(this.branchSwitcherWindow);
|
||||
this.WindowSystem.AddWindow(this.hitchSettingsWindow);
|
||||
|
||||
ImGuiManagedAsserts.AssertsEnabled = configuration.AssertsEnabledAtStartup;
|
||||
this.isImGuiDrawDevMenu = this.isImGuiDrawDevMenu || configuration.DevBarOpenAtStartup;
|
||||
|
|
@ -307,6 +310,15 @@ internal class DalamudInterface : IDisposable, IServiceType
|
|||
this.profilerWindow.IsOpen = true;
|
||||
this.profilerWindow.BringToFront();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Opens the <see cref="HitchSettingsWindow"/>.
|
||||
/// </summary>
|
||||
public void OpenHitchSettings()
|
||||
{
|
||||
this.hitchSettingsWindow.IsOpen = true;
|
||||
this.hitchSettingsWindow.BringToFront();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Opens the <see cref="BranchSwitcherWindow"/>.
|
||||
|
|
@ -676,6 +688,11 @@ internal class DalamudInterface : IDisposable, IServiceType
|
|||
{
|
||||
this.OpenProfiler();
|
||||
}
|
||||
|
||||
if (ImGui.MenuItem("Open Hitch Settings"))
|
||||
{
|
||||
this.OpenHitchSettings();
|
||||
}
|
||||
|
||||
ImGui.Separator();
|
||||
|
||||
|
|
|
|||
58
Dalamud/Interface/Internal/Windows/HitchSettingsWindow.cs
Normal file
58
Dalamud/Interface/Internal/Windows/HitchSettingsWindow.cs
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
using Dalamud.Configuration.Internal;
|
||||
using Dalamud.Interface.Windowing;
|
||||
using ImGuiNET;
|
||||
|
||||
namespace Dalamud.Interface.Internal.Windows;
|
||||
|
||||
/// <summary>
|
||||
/// Window responsible for hitch settings.
|
||||
/// </summary>
|
||||
public class HitchSettingsWindow : Window
|
||||
{
|
||||
private const float MinHitch = 1;
|
||||
private const float MaxHitch = 500;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="HitchSettingsWindow"/> class.
|
||||
/// </summary>
|
||||
public HitchSettingsWindow()
|
||||
: base("Hitch Settings", ImGuiWindowFlags.AlwaysAutoResize)
|
||||
{
|
||||
this.ShowCloseButton = true;
|
||||
this.RespectCloseHotkey = true;
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override void Draw()
|
||||
{
|
||||
var config = Service<DalamudConfiguration>.Get();
|
||||
|
||||
var uiBuilderHitch = (float)config.UiBuilderHitch;
|
||||
if (ImGui.SliderFloat("UiBuilderHitch", ref uiBuilderHitch, MinHitch, MaxHitch))
|
||||
{
|
||||
config.UiBuilderHitch = uiBuilderHitch;
|
||||
config.QueueSave();
|
||||
}
|
||||
|
||||
var frameworkUpdateHitch = (float)config.FrameworkUpdateHitch;
|
||||
if (ImGui.SliderFloat("FrameworkUpdateHitch", ref frameworkUpdateHitch, MinHitch, MaxHitch))
|
||||
{
|
||||
config.FrameworkUpdateHitch = frameworkUpdateHitch;
|
||||
config.QueueSave();
|
||||
}
|
||||
|
||||
var gameNetworkUpHitch = (float)config.GameNetworkUpHitch;
|
||||
if (ImGui.SliderFloat("GameNetworkUpHitch", ref gameNetworkUpHitch, MinHitch, MaxHitch))
|
||||
{
|
||||
config.GameNetworkUpHitch = gameNetworkUpHitch;
|
||||
config.QueueSave();
|
||||
}
|
||||
|
||||
var gameNetworkDownHitch = (float)config.GameNetworkDownHitch;
|
||||
if (ImGui.SliderFloat("GameNetworkDownHitch", ref gameNetworkDownHitch, MinHitch, MaxHitch))
|
||||
{
|
||||
config.GameNetworkDownHitch = gameNetworkDownHitch;
|
||||
config.QueueSave();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -34,6 +34,9 @@ public sealed class UiBuilder : IDisposable
|
|||
private bool hasErrorWindow = false;
|
||||
private bool lastFrameUiHideState = false;
|
||||
|
||||
[ServiceManager.ServiceDependency]
|
||||
private readonly DalamudConfiguration configuration = Service<DalamudConfiguration>.Get();
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="UiBuilder"/> class and registers it.
|
||||
/// You do not have to call this manually.
|
||||
|
|
@ -42,7 +45,7 @@ public sealed class UiBuilder : IDisposable
|
|||
internal UiBuilder(string namespaceName)
|
||||
{
|
||||
this.stopwatch = new Stopwatch();
|
||||
this.hitchDetector = new HitchDetector($"UiBuilder({namespaceName})", 100);
|
||||
this.hitchDetector = new HitchDetector($"UiBuilder({namespaceName})", this.configuration.UiBuilderHitch);
|
||||
this.namespaceName = namespaceName;
|
||||
|
||||
this.interfaceManager.Draw += this.OnDraw;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue