Skip to content

Commit

Permalink
Merge pull request #8 from FFXIV-CombatReborn/api11
Browse files Browse the repository at this point in the history
Api11
  • Loading branch information
NostraThomas99 authored Nov 23, 2024
2 parents bc1b12e + 9e6c444 commit 30922a5
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 29 deletions.
2 changes: 1 addition & 1 deletion ECommons
Submodule ECommons updated 142 files
10 changes: 3 additions & 7 deletions RebornToolbox/Features/ChocoboRacing/ChocoboRacing.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
using FFXIVClientStructs.FFXIV.Client.UI;
using FFXIVClientStructs.FFXIV.Client.UI.Agent;
using FFXIVClientStructs.FFXIV.Component.GUI;
using Lumina.Excel.GeneratedSheets;
using Lumina.Excel.Sheets;

namespace RebornToolbox.Features.ChocoboRacing;

Expand Down Expand Up @@ -166,11 +166,7 @@ private unsafe void SelectDuty(AddonContentsFinder* addonContentsFinder)

var vectorDutyListItems = addonContentsFinder->DutyList->Items;
List<AtkComponentTreeListItem> listAtkComponentTreeListItems = [];
vectorDutyListItems.ForEach(pointAtkComponentTreeListItem =>
listAtkComponentTreeListItems.Add(*(pointAtkComponentTreeListItem.Value)));

Callback.Fire((AtkUnitBase*)addonContentsFinder, true, 3,
addonContentsFinder->SelectedRow -
(HeadersCount(addonContentsFinder->SelectedRow, listAtkComponentTreeListItems) - 1));
vectorDutyListItems.ForEach(pointAtkComponentTreeListItem => listAtkComponentTreeListItems.Add(*(pointAtkComponentTreeListItem.Value)));
Callback.Fire((AtkUnitBase*)addonContentsFinder, true, 3, HeadersCount((uint)addonContentsFinder->DutyList->SelectedItemIndex, listAtkComponentTreeListItems) + 1); // - (HeadersCount(addonContentsFinder->DutyList->SelectedItemIndex, listAtkComponentTreeListItems) + 1));
}
}
22 changes: 11 additions & 11 deletions RebornToolbox/Features/MBShoppingList/MBShoppingList.UI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
using FFXIVClientStructs.FFXIV.Client.UI;
using FFXIVClientStructs.FFXIV.Client.UI.Info;
using ImGuiNET;
using Lumina.Excel.GeneratedSheets;
using Lumina.Excel.Sheets;
using OtterGui;
using OtterGui.Classes;
using RebornToolbox.Features.MBShoppingList.Models;
Expand Down Expand Up @@ -114,14 +114,14 @@ private void ExtractClipboardText()
bool saveNeeded = false;
foreach (var item in items)
{
var itemObj = MBShoppingList.AllItems.FirstOrDefault(i => string.Equals(i.Name, item.Key, StringComparison.OrdinalIgnoreCase));
var itemObj = MBShoppingList.AllItems.FirstOrNull(i => string.Equals(i.Name.ToString(), item.Key, StringComparison.OrdinalIgnoreCase));
if (itemObj is null)
{
Svc.Log.Error($"Item {item.Key} not found");
continue;
}

var shoppingListItem = new ShoppingListItem(itemObj, item.Value);
var shoppingListItem = new ShoppingListItem(itemObj.Value, item.Value);
_manager.WantedItems.Add(shoppingListItem);
saveNeeded = true;
}
Expand Down Expand Up @@ -307,7 +307,7 @@ private void DrawItemAdd()
ImGui.BeginChild($"ItemList", new Vector2(0, 150), true);
foreach (var item in matchingItems)
{
if (ImGui.Selectable(item.Name))
if (ImGui.Selectable(item.Name.ToString()))
{
_selectedItem = item;
_searchTerm = item.Name.ToString();
Expand All @@ -327,7 +327,7 @@ private void DrawItemAdd()
return;
}

var shoppingListItem = new ShoppingListItem(_selectedItem, 1);
var shoppingListItem = new ShoppingListItem(_selectedItem.Value, 1);
_manager.WantedItems.Add(shoppingListItem);
_searchTerm = string.Empty;
_selectedItem = null;
Expand Down Expand Up @@ -395,12 +395,12 @@ void ExtractItemsFromMakePlaceList(string text, string startSection, string endS
itemName += " Dye";
int quantity = int.Parse(match.Groups[2].Value.Trim());

var item = MBShoppingList.AllItems.FirstOrDefault(i =>
string.Equals(i.Name, itemName, StringComparison.OrdinalIgnoreCase));
var item = MBShoppingList.AllItems.FirstOrNull(i =>
string.Equals(i.Name.ToString(), itemName, StringComparison.OrdinalIgnoreCase));
if (item == null && string.Equals(startSection, "Dyes", StringComparison.OrdinalIgnoreCase))
{
item = MBShoppingList.AllItems.FirstOrDefault(i =>
string.Equals(i.Name, $"General-purpose {itemName}", StringComparison.OrdinalIgnoreCase));
item = MBShoppingList.AllItems.FirstOrNull(i =>
string.Equals(i.Name.ToString(), $"General-purpose {itemName}", StringComparison.OrdinalIgnoreCase));
}

if (item == null)
Expand All @@ -409,7 +409,7 @@ void ExtractItemsFromMakePlaceList(string text, string startSection, string endS
continue;
}

var existingItem = _manager.WantedItems.FirstOrDefault(i => i.ItemId == item.RowId);
var existingItem = _manager.WantedItems.FirstOrDefault(i => i.ItemId == item.Value.RowId);

// Add or update the item in the dictionary
if (existingItem != null)
Expand All @@ -418,7 +418,7 @@ void ExtractItemsFromMakePlaceList(string text, string startSection, string endS
}
else
{
_manager.WantedItems.Add(new ShoppingListItem(item, quantity));
_manager.WantedItems.Add(new ShoppingListItem(item.Value, quantity));
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions RebornToolbox/Features/MBShoppingList/MBShoppingList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
using ECommons.GameHelpers;
using FFXIVClientStructs.FFXIV.Client.Game;
using FFXIVClientStructs.FFXIV.Client.Game.Control;
using Lumina.Excel.GeneratedSheets;
using Lumina.Excel.Sheets;
using Newtonsoft.Json;
using RebornToolbox.Features.MBShoppingList.Models;
using RebornToolbox.IPC;
Expand Down Expand Up @@ -46,7 +46,7 @@ public class MBShoppingList
public MBShoppingList()
{
AllItems = Svc.Data.GameData.GetExcelSheet<Item>()!.ToList();
MarketableItems = AllItems.Where(i => i.ItemSearchCategory.Row != 0).ToList();
MarketableItems = AllItems.Where(i => i.ItemSearchCategory.RowId != 0).ToList();

Chat = new Chat();

Expand Down
15 changes: 8 additions & 7 deletions RebornToolbox/Features/MBShoppingList/Models/ShoppingListItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,23 @@
using ECommons;
using ECommons.DalamudServices;
using FFXIVClientStructs.FFXIV.Client.Game;
using Lumina.Excel.GeneratedSheets;
using Lumina.Excel.Sheets;
using Lumina.Excel.Sheets;
using Newtonsoft.Json;
using RebornToolbox.IPC;

namespace RebornToolbox.Features.MBShoppingList.Models;

public class ShoppingListItem
{
[Newtonsoft.Json.JsonIgnore] private Item _itemRecord;
[Newtonsoft.Json.JsonIgnore] private Item? _itemRecord;

public ShoppingListItem(Item item, int quantity)
{
ItemId = item.RowId;
Quantity = quantity;
_itemRecord = item; // Cache the item here
IsMarketable = MBShoppingList.MarketableItems.Contains(ItemRecord);
IsMarketable = MBShoppingList.MarketableItems.Contains(ItemRecord!.Value);
}

public ShoppingListItem()
Expand All @@ -29,21 +30,21 @@ public ShoppingListItem()
internal void OnDeserializedMethod(StreamingContext context)
{
// Initialize _itemRecord after deserialization
_itemRecord = MBShoppingList.AllItems.FirstOrDefault(x => x.RowId == ItemId);
_itemRecord = MBShoppingList.AllItems.FirstOrNull(x => x.RowId == ItemId);
if (_itemRecord == null)
{
// Handle the case where the item is not found
Svc.Log.Error($"Item with ID {ItemId} not found in AllItems.");
}
else
{
IsMarketable = MBShoppingList.MarketableItems.Contains(_itemRecord);
IsMarketable = MBShoppingList.MarketableItems.Contains(_itemRecord.Value);
}
}

[Newtonsoft.Json.JsonIgnore] public Item ItemRecord => _itemRecord;
[Newtonsoft.Json.JsonIgnore] public Item? ItemRecord => _itemRecord;

[Newtonsoft.Json.JsonIgnore] public string Name => _itemRecord.Name;
[Newtonsoft.Json.JsonIgnore] public string Name => _itemRecord.Value.Name.ToString();

public uint ItemId { get; set; }

Expand Down
2 changes: 1 addition & 1 deletion RebornToolbox/RebornToolbox.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"Toolbox",
"Reborn"
],
"DalamudApiLevel": 10,
"DalamudApiLevel": 11,
"LoadRequiredState": 0,
"LoadSync": false,
"CanUnloadAsync": false,
Expand Down

0 comments on commit 30922a5

Please sign in to comment.