fix: wait to load sheet
This commit is contained in:
parent
0a8bd90cc7
commit
cf4dd19be1
|
@ -1,5 +1,6 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Diagnostics;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Dalamud.Game;
|
using Dalamud.Game;
|
||||||
using Lumina.Excel.GeneratedSheets;
|
using Lumina.Excel.GeneratedSheets;
|
||||||
|
@ -20,6 +21,7 @@ namespace NominaOcculta {
|
||||||
internal IReadOnlyDictionary<string, (byte, byte, byte)?> ReadOnlyLastSeenInfo => this.LastSeenInfo;
|
internal IReadOnlyDictionary<string, (byte, byte, byte)?> ReadOnlyLastSeenInfo => this.LastSeenInfo;
|
||||||
|
|
||||||
private readonly int _numRaces;
|
private readonly int _numRaces;
|
||||||
|
private readonly Stopwatch _loadSheetWatch = new();
|
||||||
|
|
||||||
internal bool Initialised;
|
internal bool Initialised;
|
||||||
|
|
||||||
|
@ -48,6 +50,13 @@ namespace NominaOcculta {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnFrameworkUpdate(Framework framework) {
|
private void OnFrameworkUpdate(Framework framework) {
|
||||||
|
// The game unloads the CharaMakeName sheet after logging in.
|
||||||
|
// We need this sheet to generate names, so we load it again.
|
||||||
|
if (this._loadSheetWatch.IsRunning && this._loadSheetWatch.Elapsed > TimeSpan.FromSeconds(3)) {
|
||||||
|
this.Plugin.Functions.LoadSheet("CharaMakeName");
|
||||||
|
this._loadSheetWatch.Reset();
|
||||||
|
}
|
||||||
|
|
||||||
// The in-game name generator will generate duplicate names if it is given
|
// The in-game name generator will generate duplicate names if it is given
|
||||||
// identical parameters on the same frame. Instead, we will fill up a queue
|
// identical parameters on the same frame. Instead, we will fill up a queue
|
||||||
// with 100 names (the maximum amount of players in the object table) for
|
// with 100 names (the maximum amount of players in the object table) for
|
||||||
|
@ -76,10 +85,7 @@ namespace NominaOcculta {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnLogin(object? sender, EventArgs e) {
|
private void OnLogin(object? sender, EventArgs e) {
|
||||||
// The game unloads the CharaMakeName sheet after logging in.
|
this._loadSheetWatch.Restart();
|
||||||
// We need this sheet to generate names, so we load it again.
|
|
||||||
|
|
||||||
this.Plugin.Functions.LoadSheet("CharaMakeName");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
Loading…
Reference in New Issue