diff --git a/LLib b/LLib index fde09c7..e4bbc05 160000 --- a/LLib +++ b/LLib @@ -1 +1 @@ -Subproject commit fde09c705b648f03c287814191a554f0a4b92cc4 +Subproject commit e4bbc05ede6f6f01e7028b24614ed8cb333e909c diff --git a/Workshoppa/GameData/GameStrings.cs b/Workshoppa/GameData/GameStrings.cs index 9124c82..73bb1a0 100644 --- a/Workshoppa/GameData/GameStrings.cs +++ b/Workshoppa/GameData/GameStrings.cs @@ -4,8 +4,8 @@ using System.Text.RegularExpressions; using Dalamud.Plugin.Services; using LLib; using Lumina.Excel; -using Lumina.Excel.CustomSheets; -using Lumina.Excel.GeneratedSheets; +using Lumina.Excel.Sheets; +using Lumina.Text.ReadOnly; namespace Workshoppa.GameData; @@ -38,7 +38,16 @@ internal sealed class GameStrings [Sheet("custom/001/CmnDefCompanyManufactory_00150")] [SuppressMessage("Performance", "CA1812")] - private sealed class WorkshopDialogue : QuestDialogueText + private readonly struct WorkshopDialogue(ExcelPage page, uint offset, uint row) + : IQuestDialogueText, IExcelRow { + public uint RowId => row; + + public ReadOnlySeString Key => page.ReadString(offset, offset); + public ReadOnlySeString Value => page.ReadString(offset + 4, offset); + + static WorkshopDialogue IExcelRow.Create(ExcelPage page, uint offset, + uint row) => + new(page, offset, row); } } diff --git a/Workshoppa/GameData/RecipeTree.cs b/Workshoppa/GameData/RecipeTree.cs index 20bbfca..6f2449a 100644 --- a/Workshoppa/GameData/RecipeTree.cs +++ b/Workshoppa/GameData/RecipeTree.cs @@ -2,7 +2,7 @@ using System.Collections.Generic; using System.Linq; using Dalamud.Plugin.Services; -using Lumina.Excel.GeneratedSheets2; +using Lumina.Excel.Sheets; namespace Workshoppa.GameData; @@ -31,9 +31,10 @@ internal sealed class RecipeTree 262211, // Z'ranmaia, upper decks }; - _shopItemsOnly = _dataManager.GetExcelSheet()! + _shopItemsOnly = _dataManager.GetSubrowExcelSheet() + .Flatten() .Where(x => shopVendorIds.Contains(x.RowId)) - .Select(x => x.Item.Row) + .Select(x => x.Item.RowId) .Where(x => x > 0) .Distinct() .ToList() @@ -121,32 +122,32 @@ internal sealed class RecipeTree for (int i = 0; i < 8; ++ i) { - var ingredient = recipe.Ingredient[i]; - if (ingredient == null || ingredient.Row == 0) + var ingredient = recipe.Value.Ingredient[i]; + if (!ingredient.IsValid || ingredient.RowId == 0) continue; - Item? item = ingredient.Value; - if (item == null || !IsValidItem(item.RowId)) + Item item = ingredient.Value; + if (!IsValidItem(item.RowId)) continue; - Recipe? ingredientRecipe = GetFirstRecipeForItem(ingredient.Row); + Recipe? ingredientRecipe = GetFirstRecipeForItem(ingredient.RowId); //_pluginLog.Information($"Adding {item.Name}"); ingredients.Add(new RecipeInfo { - ItemId = ingredient.Row, - Name = item.Name, - TotalQuantity = material.TotalQuantity * recipe.AmountIngredient[i], + ItemId = ingredient.RowId, + Name = item.Name.ToString(), + TotalQuantity = material.TotalQuantity * recipe.Value.AmountIngredient[i], Type = - _shopItemsOnly.Contains(ingredient.Row) ? Ingredient.EType.ShopItem : + _shopItemsOnly.Contains(ingredient.RowId) ? Ingredient.EType.ShopItem : ingredientRecipe != null ? Ingredient.EType.Craftable : - GetGatheringItem(ingredient.Row) != null ? Ingredient.EType.Gatherable : - GetVentureItem(ingredient.Row) != null ? Ingredient.EType.Gatherable : + GetGatheringItem(ingredient.RowId) != null ? Ingredient.EType.Gatherable : + GetVentureItem(ingredient.RowId) != null ? Ingredient.EType.Gatherable : Ingredient.EType.Other, AmountCrafted = ingredientRecipe?.AmountResult ?? 1, - DependsOn = ingredientRecipe?.Ingredient.Where(x => x != null && IsValidItem(x.Row)) - .Select(x => x.Row) + DependsOn = ingredientRecipe?.Ingredient.Where(x => x.IsValid && IsValidItem(x.RowId)) + .Select(x => x.RowId) .ToList() ?? new(), }); @@ -170,9 +171,9 @@ internal sealed class RecipeTree Name = x.Ingredient.Name, TotalQuantity = x.Ingredient.TotalQuantity, Type = _shopItemsOnly.Contains(x.Ingredient.ItemId) ? Ingredient.EType.ShopItem : x.Ingredient.Type, - AmountCrafted = x.Recipe!.AmountResult, - DependsOn = x.Recipe.Ingredient.Where(y => y != null && IsValidItem(y.Row)) - .Select(y => y.Row) + AmountCrafted = x.Recipe!.Value.AmountResult, + DependsOn = x.Recipe.Value.Ingredient.Where(y => y.IsValid && IsValidItem(y.RowId)) + .Select(y => y.RowId) .ToList(), }) .ToList(); @@ -180,18 +181,18 @@ internal sealed class RecipeTree private Recipe? GetFirstRecipeForItem(uint itemId) { - return _dataManager.GetExcelSheet()!.FirstOrDefault(x => x.RowId > 0 && x.ItemResult.Row == itemId); + return _dataManager.GetExcelSheet().FirstOrDefault(x => x.RowId > 0 && x.ItemResult.RowId == itemId); } private GatheringItem? GetGatheringItem(uint itemId) { - return _dataManager.GetExcelSheet()!.FirstOrDefault(x => x.RowId > 0 && x.Item.Row == itemId); + return _dataManager.GetExcelSheet().FirstOrDefault(x => x.RowId > 0 && x.Item.RowId == itemId); } private RetainerTaskNormal? GetVentureItem(uint itemId) { - return _dataManager.GetExcelSheet()! - .FirstOrDefault(x => x.RowId > 0 && x.Item.Row == itemId); + return _dataManager.GetExcelSheet() + .FirstOrDefault(x => x.RowId > 0 && x.Item.RowId == itemId); } private static bool IsValidItem(uint itemId) diff --git a/Workshoppa/GameData/WorkshopCache.cs b/Workshoppa/GameData/WorkshopCache.cs index 9a959e6..9ee76fe 100644 --- a/Workshoppa/GameData/WorkshopCache.cs +++ b/Workshoppa/GameData/WorkshopCache.cs @@ -1,9 +1,10 @@ using System; using System.Collections.Generic; +using System.Diagnostics; using System.Linq; using System.Threading.Tasks; using Dalamud.Plugin.Services; -using Lumina.Excel.GeneratedSheets; +using Lumina.Excel.Sheets; namespace Workshoppa.GameData; @@ -15,41 +16,45 @@ internal sealed class WorkshopCache { try { - Dictionary itemMapping = dataManager.GetExcelSheet()! + Dictionary itemMapping = dataManager.GetExcelSheet() .Where(x => x.RowId > 0) - .ToDictionary(x => (ushort)x.RowId, x => x.Item.Value!); + .ToDictionary(x => x.RowId, x => x.Item.Value); - Crafts = dataManager.GetExcelSheet()! + Crafts = dataManager.GetExcelSheet() .Where(x => x.RowId > 0) .Select(x => new WorkshopCraft { WorkshopItemId = x.RowId, - ResultItem = x.ResultItem.Row, - Name = x.ResultItem.Value!.Name.ToString(), - IconId = x.ResultItem.Value!.Icon, - Category = (WorkshopCraftCategory)x.CompanyCraftDraftCategory.Row, - Type = x.CompanyCraftType.Row, - Phases = x.CompanyCraftPart.Where(part => part.Row != 0) + ResultItem = x.ResultItem.RowId, + Name = x.ResultItem.Value.Name.ToString(), + IconId = x.ResultItem.Value.Icon, + Category = (WorkshopCraftCategory)x.CompanyCraftDraftCategory.RowId, + Type = x.CompanyCraftType.RowId, + Phases = x.CompanyCraftPart.Where(part => part.RowId != 0) .SelectMany(part => - part.Value!.CompanyCraftProcess - .Where(y => y.Value!.UnkData0.Any(z => z.SupplyItem > 0)) - .Select(y => (Type: part.Value!.CompanyCraftType.Value, Process: y))) - .Select(y => new WorkshopCraftPhase - { - Name = y.Type!.Name.ToString(), - Items = y.Process.Value!.UnkData0 - .Where(item => item.SupplyItem > 0) - .Select(item => new WorkshopCraftItem + part.Value.CompanyCraftProcess + .Select(y => new WorkshopCraftPhase { - ItemId = itemMapping[item.SupplyItem].RowId, - Name = itemMapping[item.SupplyItem].Name.ToString(), - IconId = itemMapping[item.SupplyItem].Icon, - SetQuantity = item.SetQuantity, - SetsRequired = item.SetsRequired, - }) - .ToList() - .AsReadOnly(), - }) + Name = part.Value.CompanyCraftType.Value.Name.ToString(), + Items = Enumerable.Range(0, y.Value.SupplyItem.Count) + .Select(i => new + { + SupplyItem = y.Value.SupplyItem[i], + SetsRequired = y.Value.SetsRequired[i], + SetQuantity = y.Value.SetQuantity[i], + }) + .Where(item => item.SupplyItem.RowId > 0) + .Select(item => new WorkshopCraftItem + { + ItemId = itemMapping[item.SupplyItem.RowId].RowId, + Name = itemMapping[item.SupplyItem.RowId].Name.ToString(), + IconId = itemMapping[item.SupplyItem.RowId].Icon, + SetQuantity = item.SetQuantity, + SetsRequired = item.SetsRequired, + }) + .ToList() + .AsReadOnly(), + })) .ToList() .AsReadOnly(), }) diff --git a/Workshoppa/Windows/MainWindow.cs b/Workshoppa/Windows/MainWindow.cs index 61488e8..f5f4afc 100644 --- a/Workshoppa/Windows/MainWindow.cs +++ b/Workshoppa/Windows/MainWindow.cs @@ -70,7 +70,7 @@ internal sealed class MainWindow : LWindow, IPersistableWindowConfig public ButtonState State { get; set; } = ButtonState.None; private bool IsDiscipleOfHand => - _clientState.LocalPlayer != null && _clientState.LocalPlayer.ClassJob.Id is >= 8 and <= 15; + _clientState.LocalPlayer != null && _clientState.LocalPlayer.ClassJob.RowId is >= 8 and <= 15; public WindowConfig WindowConfig => _configuration.MainWindowConfig; diff --git a/Workshoppa/Workshoppa.csproj b/Workshoppa/Workshoppa.csproj index 87e0cd8..fce7eff 100644 --- a/Workshoppa/Workshoppa.csproj +++ b/Workshoppa/Workshoppa.csproj @@ -1,6 +1,6 @@ - + - 6.2 + 7.0 dist diff --git a/Workshoppa/packages.lock.json b/Workshoppa/packages.lock.json index f5ad582..f6a8acd 100644 --- a/Workshoppa/packages.lock.json +++ b/Workshoppa/packages.lock.json @@ -4,9 +4,9 @@ "net8.0-windows7.0": { "DalamudPackager": { "type": "Direct", - "requested": "[2.1.13, )", - "resolved": "2.1.13", - "contentHash": "rMN1omGe8536f4xLMvx9NwfvpAc9YFFfeXJ1t4P4PE6Gu8WCIoFliR1sh07hM+bfODmesk/dvMbji7vNI+B/pQ==" + "requested": "[11.0.0, )", + "resolved": "11.0.0", + "contentHash": "bjT7XUlhIJSmsE/O76b7weUX+evvGQctbQB8aKXt94o+oPWxHpCepxAGMs7Thow3AzCyqWs7cOpp9/2wcgRRQA==" }, "DotNet.ReproducibleBuilds": { "type": "Direct", @@ -79,7 +79,7 @@ "llib": { "type": "Project", "dependencies": { - "DalamudPackager": "[2.1.13, )" + "DalamudPackager": "[11.0.0, )" } } }