From 5d65144cda523b4f9a3bbc52c68d78367d39e2f2 Mon Sep 17 00:00:00 2001 From: Florian Maunier Date: Thu, 14 Nov 2024 19:26:36 +0100 Subject: [PATCH 1/2] =?UTF-8?q?=E2=9C=A8=20Update=20to=20API=2011?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Extensions/ClassExtensions.cs | 15 +-- .../GUI/MarketBoardShoppingListWindow.cs | 2 +- MarketBoardPlugin/GUI/MarketBoardWindow.cs | 100 ++++++++++-------- MarketBoardPlugin/MBPlugin.cs | 2 +- MarketBoardPlugin/MarketBoardPlugin.csproj | 4 +- .../Models/ShoppingList/SavedItem.cs | 2 +- MarketBoardPlugin/packages.lock.json | 18 ++-- OtterGui | 2 +- 8 files changed, 74 insertions(+), 71 deletions(-) diff --git a/MarketBoardPlugin/Extensions/ClassExtensions.cs b/MarketBoardPlugin/Extensions/ClassExtensions.cs index 4431f25..50d1e08 100644 --- a/MarketBoardPlugin/Extensions/ClassExtensions.cs +++ b/MarketBoardPlugin/Extensions/ClassExtensions.cs @@ -4,7 +4,7 @@ namespace MarketBoardPlugin.Extensions { - using Lumina.Excel.GeneratedSheets; + using Lumina.Excel.Sheets; /// /// and extensions. @@ -18,21 +18,16 @@ public static class ClassExtensions /// A . /// /// True if contained or classJob is null. - /// False if not contained or classJobCategory is null. + /// False if not contained. /// - public static bool HasClass(this ClassJobCategory classJobCategory, ClassJob classJob) + public static bool HasClass(this ClassJobCategory classJobCategory, ClassJob? classJob) { - if (classJobCategory == null) - { - return false; - } - - if (classJob == null) + if (!classJob.HasValue) { return true; } - return classJob.RowId switch + return classJob.Value.RowId switch { 0 => classJobCategory.ADV, 1 => classJobCategory.GLA, diff --git a/MarketBoardPlugin/GUI/MarketBoardShoppingListWindow.cs b/MarketBoardPlugin/GUI/MarketBoardShoppingListWindow.cs index 0e33de7..e321ebd 100644 --- a/MarketBoardPlugin/GUI/MarketBoardShoppingListWindow.cs +++ b/MarketBoardPlugin/GUI/MarketBoardShoppingListWindow.cs @@ -65,7 +65,7 @@ public override void Draw() int k = 0; foreach (var item in this.Plugin.ShoppingList) { - ImGui.Text(item.SourceItem.Name); + ImGui.Text(item.SourceItem.Name.ExtractText()); ImGui.NextColumn(); if (this.Plugin.Config.PriceIconShown) { diff --git a/MarketBoardPlugin/GUI/MarketBoardWindow.cs b/MarketBoardPlugin/GUI/MarketBoardWindow.cs index ecf1e63..31e7efe 100644 --- a/MarketBoardPlugin/GUI/MarketBoardWindow.cs +++ b/MarketBoardPlugin/GUI/MarketBoardWindow.cs @@ -22,9 +22,10 @@ namespace MarketBoardPlugin.GUI using Dalamud.Interface.Textures.TextureWraps; using Dalamud.Interface.Windowing; using Dalamud.Plugin.Services; + using Dalamud.Utility; using ImGuiNET; using ImPlotNET; - using Lumina.Excel.GeneratedSheets; + using Lumina.Excel.Sheets; using MarketBoardPlugin.Extensions; using MarketBoardPlugin.Helpers; using MarketBoardPlugin.Models.ShoppingList; @@ -75,7 +76,7 @@ public class MarketBoardWindow : Window, IDisposable private string searchString = string.Empty; private string lastSearchString = string.Empty; - private ClassJob lastSelectedClassJob; + private ClassJob? lastSelectedClassJob; private int lvlmin; private int lastlvlmin; @@ -83,9 +84,9 @@ public class MarketBoardWindow : Window, IDisposable private int lastlvlmax = 100; private int itemCategory; private int lastItemCategory; - private Item selectedItem; + private Item? selectedItem; - private ClassJob selectedClassJob; + private ClassJob? selectedClassJob; private bool hQOnly; @@ -226,7 +227,7 @@ public override void Draw() if (this.searchString != this.lastSearchString || this.itemCategory != this.lastItemCategory || this.lastlvlmin != this.lvlmin || this.lastlvlmax != this.lvlmax - || this.lastSelectedClassJob != this.selectedClassJob) + || this.lastSelectedClassJob?.RowId != this.selectedClassJob?.RowId) { this.UpdateCategoriesAndItems(); } @@ -302,12 +303,12 @@ public override void Draw() ImGui.SameLine(); if (ImGui.BeginCombo( "###ClassJobCombo", - this.selectedClassJob == null ? "All Classes" : this.selectedClassJob.Abbreviation)) + this.selectedClassJob == null ? "All Classes" : this.selectedClassJob?.Abbreviation.ExtractText())) { - void SelectClassJob(ClassJob classJob) + void SelectClassJob(ClassJob? classJob) { - var selected = this.selectedClassJob == classJob; - if (ImGui.Selectable(classJob == null ? "All Classes" : classJob.Abbreviation, selected)) + var selected = this.selectedClassJob?.RowId == classJob?.RowId; + if (ImGui.Selectable(classJob == null ? "All Classes" : classJob?.Abbreviation.ExtractText(), selected)) { this.selectedClassJob = classJob; } @@ -356,13 +357,13 @@ void SelectClassJob(ClassJob classJob) var sheet = this.plugin.DataManager.Excel.GetSheet(); foreach (var id in this.plugin.Config.History.ToArray()) { - var item = sheet.GetRow(id); - if (item == null) + var item = sheet.GetRowOrDefault(id); + if (!item.HasValue) { continue; } - if (ImGui.Selectable($"{item.Name}", this.selectedItem == item)) + if (ImGui.Selectable($"{item.Value.Name.ExtractText()}", this.selectedItem?.RowId == id)) { this.ChangeSelectedItem(id, true); } @@ -375,35 +376,37 @@ void SelectClassJob(ClassJob classJob) var sheet = this.plugin.DataManager.Excel.GetSheet(); foreach (var id in this.plugin.Config.Favorites.ToArray()) { - var item = sheet.GetRow(id); - if (item == null) + var item = sheet.GetRowOrDefault(id); + if (!item.HasValue) { continue; } - if (ImGui.Selectable($"{item.Name}", this.selectedItem == item)) + var itemName = item.Value.Name.ExtractText(); + + if (ImGui.Selectable($"{itemName}", this.selectedItem?.RowId == id)) { this.ChangeSelectedItem(id, true); } - if (ImGui.BeginPopupContextItem($"itemContextMenu{item.Name}")) + if (ImGui.BeginPopupContextItem($"itemContextMenu{itemName}")) { if (ImGui.Selectable("Remove from the favorites")) { - this.plugin.Config.Favorites.Remove(item.RowId); + this.plugin.Config.Favorites.Remove(item.Value.RowId); } ImGui.EndPopup(); } - ImGui.OpenPopupOnItemClick($"itemContextMenu{item.Name}", ImGuiPopupFlags.MouseButtonRight); + ImGui.OpenPopupOnItemClick($"itemContextMenu{itemName}", ImGuiPopupFlags.MouseButtonRight); } } else { foreach (var category in this.enumerableCategoriesAndItems) { - if (ImGui.TreeNode(category.Key.Name + "##cat" + category.Key.RowId)) + if (ImGui.TreeNode(category.Key.Name.ExtractText() + "##cat" + category.Key.RowId)) { ImGui.Unindent(ImGui.GetTreeNodeToLabelSpacing()); @@ -444,16 +447,16 @@ void SelectClassJob(ClassJob classJob) nodeFlags |= ImGuiTreeNodeFlags.Selected; } - ImGui.TreeNodeEx(item.Name + "##item" + item.RowId, nodeFlags); + ImGui.TreeNodeEx(item.Name.ExtractText() + "##item" + item.RowId, nodeFlags); if (ImGui.IsItemClicked()) { this.ChangeSelectedItem(item.RowId); } - if (ImGui.BeginPopupContextItem("itemContextMenu" + category.Key.Name + i)) + if (ImGui.BeginPopupContextItem("itemContextMenu" + category.Key.Name.ExtractText() + i)) { - if (this.selectedItem != null && item != null && this.selectedItem.RowId != item.RowId) + if (this.selectedItem != null && this.selectedItem?.RowId != item.RowId) { this.ChangeSelectedItem(item.RowId); } @@ -475,7 +478,7 @@ void SelectClassJob(ClassJob classJob) ImGui.EndPopup(); } - ImGui.OpenPopupOnItemClick("itemContextMenu" + category.Key.Name + i, ImGuiPopupFlags.MouseButtonRight); + ImGui.OpenPopupOnItemClick("itemContextMenu" + category.Key.Name.ExtractText() + i, ImGuiPopupFlags.MouseButtonRight); } ImGui.Indent(ImGui.GetTreeNodeToLabelSpacing()); @@ -525,7 +528,7 @@ void SelectClassJob(ClassJob classJob) { var couldGetIcon = this.plugin.TextureProvider.GetFromGameIcon(new GameIconLookup { - IconId = this.selectedItem.Icon, + IconId = this.selectedItem.Value.Icon, }).TryGetWrap(out var selectedItemIcon, out _); using (selectedItemIcon) @@ -535,7 +538,7 @@ void SelectClassJob(ClassJob classJob) if (ImGui.ImageButton(selectedItemIcon.ImGuiHandle, new Vector2(40, 40))) { ImGui.LogToClipboard(); - ImGui.LogText(this.selectedItem.Name); + ImGui.LogText(this.selectedItem?.Name.ExtractText()); ImGui.LogFinish(); } } @@ -548,7 +551,7 @@ void SelectClassJob(ClassJob classJob) this.titleFontHandle.Push(); ImGui.SameLine(); ImGui.SetCursorPosY(ImGui.GetCursorPosY() - (ImGui.GetFontSize() / 2.0f) + (20 * scale)); - ImGui.Text(this.selectedItem?.Name); + ImGui.Text(this.selectedItem?.Name.ExtractText()); ImGui.SameLine(ImGui.GetContentRegionAvail().X - (250 * scale)); ImGui.SetCursorPosY(0); this.titleFontHandle.Pop(); @@ -844,7 +847,7 @@ void SelectClassJob(ClassJob classJob) var universalisUrl = "https://universalis.app"; if (this.selectedItem != null) { - universalisUrl += $"/market/{this.selectedItem.RowId}"; + universalisUrl += $"/market/{this.selectedItem.Value.RowId}"; } Utilities.OpenBrowser(universalisUrl); @@ -899,7 +902,7 @@ internal void ChangeSelectedItem(uint itemId, bool noHistory = false) { this.selectedItem = this.items.Single(i => i.RowId == itemId); - var iconId = this.selectedItem.Icon; + var iconId = this.selectedItem.Value.Icon; this.RefreshMarketData(); if (!noHistory) @@ -992,7 +995,7 @@ private void UpdateCategoriesAndItems() kv.Key, kv.Value .Where(i => - i.Name.ToString().ToUpperInvariant().Contains(this.searchString.ToUpperInvariant(), StringComparison.InvariantCulture)) + i.Name.ExtractText().ToUpperInvariant().Contains(this.searchString.ToUpperInvariant(), StringComparison.InvariantCulture)) .Where(i => i.LevelEquip >= this.lvlmin && i.LevelEquip <= this.lvlmax) .Where(i => i.ClassJobCategory.Value.HasClass(this.selectedClassJob)) .ToList())) @@ -1036,7 +1039,7 @@ private Dictionary> SortCategoriesAndItems() continue; } - sortedCategoriesDict.Add(c, this.items.Where(i => i.ItemSearchCategory.Row == c.RowId).OrderBy(i => ConvertItemNameToSortableFormat(i.Name.ToString())).ToList()); + sortedCategoriesDict.Add(c, this.items.Where(i => i.ItemSearchCategory.RowId == c.RowId).OrderBy(i => ConvertItemNameToSortableFormat(i.Name.ExtractText())).ToList()); } return sortedCategoriesDict; @@ -1058,23 +1061,23 @@ private void HandleFrameworkUpdateEvent(IFramework framework) return; } - var currentDc = localPlayer.CurrentWorld.GameData.DataCenter; + var currentDc = localPlayer.CurrentWorld.Value.DataCenter; var dcWorlds = this.plugin.DataManager.GetExcelSheet() - .Where(w => w.DataCenter.Row == currentDc.Row && w.IsPublic) - .OrderBy(w => w.Name.ToString()) + .Where(w => w.DataCenter.RowId == currentDc.RowId && w.IsPublic) + .OrderBy(w => w.Name.ExtractText()) .Select(w => { - string displayName = w.Name; + string displayName = w.Name.ExtractText(); - if (localPlayer.CurrentWorld.Id == w.RowId) + if (localPlayer.CurrentWorld.Value.RowId == w.RowId) { displayName += $" {SeIconChar.Hyadelyn.ToChar()}"; } - return (w.Name.ToString(), displayName); + return (w.Name.ExtractText(), displayName); }); - var regionName = localPlayer.CurrentWorld.GameData.DataCenter.Value.Region switch + var regionName = localPlayer.CurrentWorld.Value.DataCenter.Value.Region switch { 1 => "Japan", 2 => "North-America", @@ -1085,7 +1088,7 @@ private void HandleFrameworkUpdateEvent(IFramework framework) this.worldList.Clear(); this.worldList.Add((regionName, $"Cross-DC {SeIconChar.CrossWorld.ToChar()}")); - this.worldList.Add((currentDc.Value?.Name, $"Cross-World {SeIconChar.CrossWorld.ToChar()}")); + this.worldList.Add((currentDc.Value.Name.ExtractText(), $"Cross-World {SeIconChar.CrossWorld.ToChar()}")); this.worldList.AddRange(dcWorlds); if (this.plugin.Config.CrossDataCenter) @@ -1098,7 +1101,7 @@ private void HandleFrameworkUpdateEvent(IFramework framework) } else { - this.selectedWorld = this.worldList.FindIndex(w => w.Item1 == localPlayer.CurrentWorld.GameData.Name); + this.selectedWorld = this.worldList.FindIndex(w => w.Item1 == localPlayer.CurrentWorld.Value.Name); } if (this.worldList.Count > 1) @@ -1128,9 +1131,9 @@ private void HandleHoveredItemChange(object sender, ulong itemId) return; } - var item = this.plugin.DataManager.Excel.GetSheet().GetRow((uint)itemId % 500000); + var item = this.plugin.DataManager.Excel.GetSheet().GetRowOrDefault((uint)itemId % 500000); - if (item != null && this.enumerableCategoriesAndItems != null && this.sortedCategoriesAndItems.Any(i => i.Value != null && i.Value.Any(k => k.ToString() == item.ToString()))) + if (item != null && this.enumerableCategoriesAndItems != null && this.sortedCategoriesAndItems.Any(i => i.Value != null && i.Value.Any(k => k.RowId == item.Value.RowId))) { this.itemBeingHovered = itemId; } @@ -1142,6 +1145,11 @@ private void HandleHoveredItemChange(object sender, ulong itemId) private void RefreshMarketData() { + if (!this.selectedItem.HasValue) + { + return; + } + this.marketData = null; if (this.currentRefreshTask?.Status != TaskStatus.RanToCompletion) @@ -1156,7 +1164,7 @@ private void RefreshMarketData() this.currentRefreshTask = Task.Run( async () => { - var cachedItem = this.marketDataCache.GetValueOrDefault(this.selectedItem.RowId); + var cachedItem = this.marketDataCache.GetValueOrDefault(this.selectedItem.Value.RowId); if ( cachedItem != default(MarketDataResponse) && DateTimeOffset.Now.ToUnixTimeMilliseconds() - cachedItem.FetchTimestamp < this.plugin.Config.ItemRefreshTimeout) @@ -1165,13 +1173,13 @@ private void RefreshMarketData() return; } - this.marketDataCache.Remove(this.selectedItem.RowId); + this.marketDataCache.Remove(this.selectedItem.Value.RowId); try { this.marketData = await this.plugin.UniversalisClient .GetMarketData( - this.selectedItem.RowId, + this.selectedItem.Value.RowId, this.worldList[this.selectedWorld].Item1, this.plugin.Config.ListingCount, this.plugin.Config.HistoryCount, @@ -1180,7 +1188,7 @@ private void RefreshMarketData() } catch (AggregateException ae) { - this.plugin.Log.Warning(ae, $"Failed to fetch market data for item {this.selectedItem.RowId} from Universalis."); + this.plugin.Log.Warning(ae, $"Failed to fetch market data for item {this.selectedItem.Value.RowId} from Universalis."); foreach (var ex in ae.InnerExceptions) { @@ -1192,7 +1200,7 @@ private void RefreshMarketData() if (this.marketData != null) { - this.marketDataCache.Add(this.selectedItem.RowId, this.marketData); + this.marketDataCache.Add(this.selectedItem.Value.RowId, this.marketData); } }, this.currentRefreshCancellationTokenSource.Token); diff --git a/MarketBoardPlugin/MBPlugin.cs b/MarketBoardPlugin/MBPlugin.cs index 0826d9b..e1aef19 100644 --- a/MarketBoardPlugin/MBPlugin.cs +++ b/MarketBoardPlugin/MBPlugin.cs @@ -17,7 +17,7 @@ namespace MarketBoardPlugin using Dalamud.Plugin; using Dalamud.Plugin.Services; using FFXIVClientStructs.FFXIV.Client.UI.Agent; - using Lumina.Excel.GeneratedSheets; + using Lumina.Excel.Sheets; using MarketBoardPlugin.GUI; using MarketBoardPlugin.Helpers; diff --git a/MarketBoardPlugin/MarketBoardPlugin.csproj b/MarketBoardPlugin/MarketBoardPlugin.csproj index 9657dcd..81b9663 100644 --- a/MarketBoardPlugin/MarketBoardPlugin.csproj +++ b/MarketBoardPlugin/MarketBoardPlugin.csproj @@ -1,4 +1,4 @@ - + MarketBoardPlugin Florian "fmauNeko" Maunier @@ -38,7 +38,7 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/MarketBoardPlugin/Models/ShoppingList/SavedItem.cs b/MarketBoardPlugin/Models/ShoppingList/SavedItem.cs index 8df2469..cb0599e 100644 --- a/MarketBoardPlugin/Models/ShoppingList/SavedItem.cs +++ b/MarketBoardPlugin/Models/ShoppingList/SavedItem.cs @@ -4,7 +4,7 @@ namespace MarketBoardPlugin.Models.ShoppingList { - using Lumina.Excel.GeneratedSheets; + using Lumina.Excel.Sheets; /// /// A model representing an Item saved into the shopping list. diff --git a/MarketBoardPlugin/packages.lock.json b/MarketBoardPlugin/packages.lock.json index 423e231..5a6306a 100644 --- a/MarketBoardPlugin/packages.lock.json +++ b/MarketBoardPlugin/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", @@ -22,9 +22,9 @@ }, "Polly.Core": { "type": "Direct", - "requested": "[8.4.1, )", - "resolved": "8.4.1", - "contentHash": "bg4kE7mFwXc6FJ8NLknTgVgLAMlbToWC7vpdqAITv8lPzKpp9v7aWJPc04GRoZQaJhVY/tdr8K2/VW2aTmaA1Q==" + "requested": "[8.5.0, )", + "resolved": "8.5.0", + "contentHash": "VYYMZNitZ85UEhwOKkTQI63WEMvzUqwQc74I2mm8h/DBVAMcBBxqYPni4DmuRtbCwngmuONuK2yBJfWNRKzI+A==" }, "StyleCop.Analyzers": { "type": "Direct", @@ -37,8 +37,8 @@ }, "JetBrains.Annotations": { "type": "Transitive", - "resolved": "2023.3.0", - "contentHash": "PHfnvdBUdGaTVG9bR/GEfxgTwWM0Z97Y6X3710wiljELBISipSfF5okn/vz+C2gfO+ihoEyVPjaJwn8ZalVukA==" + "resolved": "2024.2.0", + "contentHash": "GNnqCFW/163p1fOehKx0CnAqjmpPrUSqrgfHM6qca+P+RN39C9rhlfZHQpJhxmQG/dkOYe/b3Z0P8b6Kv5m1qw==" }, "Microsoft.Build.Tasks.Git": { "type": "Transitive", @@ -107,7 +107,7 @@ "ottergui": { "type": "Project", "dependencies": { - "JetBrains.Annotations": "[2023.3.0, )", + "JetBrains.Annotations": "[2024.2.0, )", "Microsoft.Extensions.DependencyInjection": "[8.0.0, )" } } diff --git a/OtterGui b/OtterGui index c2738e1..8ba88ef 160000 --- a/OtterGui +++ b/OtterGui @@ -1 +1 @@ -Subproject commit c2738e1d42974cddbe5a31238c6ed236a831d17d +Subproject commit 8ba88eff15326bb28ed5e6157f5252c114d40b5f From 9b73c57cfe64ebba90d554f977ecdf0c8c22f392 Mon Sep 17 00:00:00 2001 From: Florian Maunier Date: Thu, 14 Nov 2024 19:35:04 +0100 Subject: [PATCH 2/2] =?UTF-8?q?=F0=9F=94=96=20bump=20version=20to=201.9.0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- MarketBoardPlugin/MarketBoardPlugin.csproj | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/MarketBoardPlugin/MarketBoardPlugin.csproj b/MarketBoardPlugin/MarketBoardPlugin.csproj index 81b9663..743bdfa 100644 --- a/MarketBoardPlugin/MarketBoardPlugin.csproj +++ b/MarketBoardPlugin/MarketBoardPlugin.csproj @@ -5,9 +5,9 @@ bin/$(Configuration)/$(TargetFramework)/$(AssemblyName).xml PdbOnly true - 1.8.0 - 1.8.0 - 1.8.0 + 1.9.0 + 1.9.0 + 1.9.0 Florian Maunier Market board plugin for Dalamud. Copyright (c) Florian Maunier. All rights reserved. @@ -49,4 +49,4 @@ - + \ No newline at end of file