punish v6.8.18.0
This commit is contained in:
commit
e786325cda
322 changed files with 554232 additions and 0 deletions
103
Questionable/Questionable.Functions/ExcelFunctions.cs
Normal file
103
Questionable/Questionable.Functions/ExcelFunctions.cs
Normal file
|
@ -0,0 +1,103 @@
|
|||
using System;
|
||||
using System.Linq;
|
||||
using Dalamud.Plugin.Services;
|
||||
using Dalamud.Utility;
|
||||
using LLib;
|
||||
using Lumina.Excel.Exceptions;
|
||||
using Lumina.Excel.Sheets;
|
||||
using Lumina.Text.ReadOnly;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Questionable.Model;
|
||||
|
||||
namespace Questionable.Functions;
|
||||
|
||||
internal sealed class ExcelFunctions
|
||||
{
|
||||
private readonly IDataManager _dataManager;
|
||||
|
||||
private readonly ILogger<ExcelFunctions> _logger;
|
||||
|
||||
public ExcelFunctions(IDataManager dataManager, ILogger<ExcelFunctions> logger)
|
||||
{
|
||||
_dataManager = dataManager;
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
public StringOrRegex GetDialogueText(Questionable.Model.Quest? currentQuest, string? excelSheetName, string key, bool isRegex)
|
||||
{
|
||||
ReadOnlySeString? rawDialogueText = GetRawDialogueText(currentQuest, excelSheetName, key);
|
||||
if (isRegex)
|
||||
{
|
||||
return new StringOrRegex(rawDialogueText.ToRegex());
|
||||
}
|
||||
return new StringOrRegex(rawDialogueText?.WithCertainMacroCodeReplacements());
|
||||
}
|
||||
|
||||
public ReadOnlySeString? GetRawDialogueText(Questionable.Model.Quest? currentQuest, string? excelSheetName, string key)
|
||||
{
|
||||
if (currentQuest != null && excelSheetName == null)
|
||||
{
|
||||
Lumina.Excel.Sheets.Quest? rowOrDefault = _dataManager.GetExcelSheet<Lumina.Excel.Sheets.Quest>().GetRowOrDefault((uint)(currentQuest.Id.Value + 65536));
|
||||
if (!rowOrDefault.HasValue)
|
||||
{
|
||||
_logger.LogError("Could not find quest row for {QuestId}", currentQuest.Id);
|
||||
return null;
|
||||
}
|
||||
excelSheetName = $"quest/{currentQuest.Id.Value / 100:000}/{rowOrDefault.Value.Id}";
|
||||
}
|
||||
ArgumentNullException.ThrowIfNull(excelSheetName, "excelSheetName");
|
||||
try
|
||||
{
|
||||
IDataManager dataManager = _dataManager;
|
||||
string name = excelSheetName;
|
||||
return dataManager.GetExcelSheet<QuestDialogueText>(null, name).Cast<QuestDialogueText?>().FirstOrDefault((QuestDialogueText? x) => x.Value.Key == key)?.Value;
|
||||
}
|
||||
catch (SheetNotFoundException innerException)
|
||||
{
|
||||
throw new SheetNotFoundException("Sheet '" + excelSheetName + "' not found", innerException);
|
||||
}
|
||||
}
|
||||
|
||||
public StringOrRegex GetDialogueTextByRowId(string? excelSheet, uint rowId, bool isRegex)
|
||||
{
|
||||
ReadOnlySeString? rawDialogueTextByRowId = GetRawDialogueTextByRowId(excelSheet, rowId);
|
||||
if (isRegex)
|
||||
{
|
||||
return new StringOrRegex(rawDialogueTextByRowId.ToRegex());
|
||||
}
|
||||
return new StringOrRegex(rawDialogueTextByRowId?.ToDalamudString().ToString());
|
||||
}
|
||||
|
||||
public ReadOnlySeString? GetRawDialogueTextByRowId(string? excelSheet, uint rowId)
|
||||
{
|
||||
bool flag;
|
||||
switch (excelSheet)
|
||||
{
|
||||
case "GimmickYesNo":
|
||||
return _dataManager.GetExcelSheet<GimmickYesNo>().GetRowOrDefault(rowId)?.Unknown0;
|
||||
case "Warp":
|
||||
return _dataManager.GetExcelSheet<Warp>().GetRowOrDefault(rowId)?.Name;
|
||||
case "Addon":
|
||||
return _dataManager.GetExcelSheet<Addon>().GetRowOrDefault(rowId)?.Text;
|
||||
case "EventPathMove":
|
||||
return _dataManager.GetExcelSheet<EventPathMove>().GetRowOrDefault(rowId)?.Unknown0;
|
||||
case "GilShop":
|
||||
return _dataManager.GetExcelSheet<GilShop>().GetRowOrDefault(rowId)?.Name;
|
||||
default:
|
||||
if (excelSheet != null)
|
||||
{
|
||||
flag = false;
|
||||
break;
|
||||
}
|
||||
goto case "ContentTalk";
|
||||
case "ContentTalk":
|
||||
flag = true;
|
||||
break;
|
||||
}
|
||||
if (flag)
|
||||
{
|
||||
return _dataManager.GetExcelSheet<ContentTalk>().GetRowOrDefault(rowId)?.Text;
|
||||
}
|
||||
throw new ArgumentOutOfRangeException("excelSheet", "Unsupported excel sheet " + excelSheet);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue