mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-12 10:17:22 +01:00
Load valid sheets for AddFromSheetPopup asynchronously
This commit is contained in:
parent
2625f51021
commit
dceeccb242
1 changed files with 24 additions and 13 deletions
|
|
@ -2,6 +2,7 @@ using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Numerics;
|
using System.Numerics;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
using Dalamud.Bindings.ImGui;
|
using Dalamud.Bindings.ImGui;
|
||||||
using Dalamud.Data;
|
using Dalamud.Data;
|
||||||
|
|
@ -146,6 +147,7 @@ internal class SeStringCreatorWidget : IDataWindowWidget
|
||||||
private SeStringParameter[]? localParameters = [Util.GetScmVersion()];
|
private SeStringParameter[]? localParameters = [Util.GetScmVersion()];
|
||||||
private ReadOnlySeString input;
|
private ReadOnlySeString input;
|
||||||
private ClientLanguage? language;
|
private ClientLanguage? language;
|
||||||
|
private Task? validImportSheetNamesTask;
|
||||||
private int importSelectedSheetName;
|
private int importSelectedSheetName;
|
||||||
private int importRowId;
|
private int importRowId;
|
||||||
private string[]? validImportSheetNames;
|
private string[]? validImportSheetNames;
|
||||||
|
|
@ -565,22 +567,31 @@ internal class SeStringCreatorWidget : IDataWindowWidget
|
||||||
|
|
||||||
var dataManager = Service<DataManager>.Get();
|
var dataManager = Service<DataManager>.Get();
|
||||||
|
|
||||||
this.validImportSheetNames ??= dataManager.Excel.SheetNames.Where(sheetName =>
|
this.validImportSheetNamesTask ??= Task.Run(() =>
|
||||||
{
|
{
|
||||||
try
|
this.validImportSheetNames = dataManager.Excel.SheetNames.Where(sheetName =>
|
||||||
{
|
{
|
||||||
var headerFile = dataManager.GameData.GetFile<ExcelHeaderFile>($"exd/{sheetName}.exh");
|
try
|
||||||
if (headerFile.Header.Variant != ExcelVariant.Default)
|
{
|
||||||
return false;
|
var headerFile = dataManager.GameData.GetFile<ExcelHeaderFile>($"exd/{sheetName}.exh");
|
||||||
|
if (headerFile.Header.Variant != ExcelVariant.Default)
|
||||||
|
return false;
|
||||||
|
|
||||||
var sheet = dataManager.Excel.GetSheet<RawRow>(Language.English, sheetName);
|
var sheet = dataManager.Excel.GetSheet<RawRow>(Language.English, sheetName);
|
||||||
return sheet.Columns.Any(col => col.Type == ExcelColumnDataType.String);
|
return sheet.Columns.Any(col => col.Type == ExcelColumnDataType.String);
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}).OrderBy(sheetName => sheetName, StringComparer.InvariantCulture).ToArray();
|
}).OrderBy(sheetName => sheetName, StringComparer.InvariantCulture).ToArray();
|
||||||
|
});
|
||||||
|
|
||||||
|
if (this.validImportSheetNames == null)
|
||||||
|
{
|
||||||
|
ImGui.Text("Loading sheets..."u8);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
var sheetChanged = ImGui.Combo("Sheet Name", ref this.importSelectedSheetName, this.validImportSheetNames);
|
var sheetChanged = ImGui.Combo("Sheet Name", ref this.importSelectedSheetName, this.validImportSheetNames);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue